Logo Search packages:      
Sourcecode: shutdown-qapps version File versions  Download package

main.cpp

/* qshutdown, a program to shutdown the system
 * Copyright (C) 2009 2010  Christian Metscher <hakaishi@web.de>

 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#include "gui.h"
#include <QApplication>

int main(int argc, char *argv[]){

     // here the QT_program is created
     QApplication app(argc, argv);

     QString lo = ":/locale/" + QLocale::system().name();
     QTranslator translator;
     translator.load(lo);
     app.installTranslator(&translator);

     Gui window;

   #ifndef Q_OS_WIN32
     QDBusConnection::sessionBus().registerObject(OBJECT_NAME, &window,
       QDBusConnection::ExportNonScriptableSlots);
     if(QDBusConnection::sessionBus().registerService(SERVICE_NAME)){
       //if possible register qshutdown as a service in the session bus
   #endif
       window.saved();
     #ifdef Q_OS_WIN32
       window.center();
     #endif
       window.show();

       return app.exec();
   #ifndef Q_OS_WIN32
     }
     else{ //if registering qshutdown fails (also because it is already
           // registered, show window
       QDBusInterface(SERVICE_NAME, OBJECT_NAME, "org.qshutdown.iface",
         QDBusConnection::sessionBus()).call("showRunningProgram");
     }
   #endif
}

Generated by  Doxygen 1.6.0   Back to index