2011-04-06 13:48:02 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Duncan Mac-Vicar P. <duncan@kde.org>
|
|
|
|
*
|
|
|
|
* 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 2 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.
|
|
|
|
*/
|
2011-02-17 02:21:45 +03:00
|
|
|
|
|
|
|
#include "mirall/application.h"
|
2013-07-08 04:58:26 +04:00
|
|
|
#include "mirall/theme.h"
|
2013-09-10 13:35:30 +04:00
|
|
|
#include "mirall/utility.h"
|
2013-07-08 04:58:26 +04:00
|
|
|
|
|
|
|
#include <QMessageBox>
|
2013-09-10 13:35:30 +04:00
|
|
|
#include <QTimer>
|
|
|
|
|
|
|
|
void warnSystray()
|
|
|
|
{
|
|
|
|
QMessageBox::critical(0, qApp->translate("main.cpp", "System Tray not available"),
|
|
|
|
qApp->translate("main.cpp", "%1 requires on a working system tray. "
|
|
|
|
"If you are running XFCE, please follow "
|
|
|
|
"<a href=\"http://docs.xfce.org/xfce/xfce4-panel/systray\">these instructions</a>. "
|
|
|
|
"Otherwise, please install a system tray application such as 'trayer' and try again.")
|
|
|
|
.arg(Mirall::Theme::instance()->appNameGUI()));
|
|
|
|
}
|
2011-02-17 02:21:45 +03:00
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
2012-03-31 13:31:28 +04:00
|
|
|
Q_INIT_RESOURCE(mirall);
|
|
|
|
|
|
|
|
Mirall::Application app(argc, argv);
|
2012-07-30 18:10:48 +04:00
|
|
|
app.initialize();
|
2013-08-15 14:15:39 +04:00
|
|
|
|
|
|
|
if( app.giveHelp() ) {
|
|
|
|
app.showHelp();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-07-30 18:10:48 +04:00
|
|
|
// if the application is already running, notify it.
|
|
|
|
if( app.isRunning() ) {
|
2012-10-16 21:05:28 +04:00
|
|
|
QStringList args = app.arguments();
|
|
|
|
if ( args.size() > 1 && ! app.giveHelp() ) {
|
|
|
|
QString msg = args.join( QLatin1String("|") );
|
|
|
|
if( ! app.sendMessage( msg ) )
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
2013-07-08 04:58:26 +04:00
|
|
|
} else {
|
2013-09-10 13:35:30 +04:00
|
|
|
int attempts = 0;
|
|
|
|
forever {
|
|
|
|
if (!QSystemTrayIcon::isSystemTrayAvailable() && qgetenv("DESKTOP_SESSION") != "ubuntu") {
|
|
|
|
Mirall::Utility::sleep(1);
|
|
|
|
attempts++;
|
|
|
|
if (attempts < 30) continue;
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
warnSystray();
|
|
|
|
break;
|
2013-07-08 04:58:26 +04:00
|
|
|
}
|
2012-07-30 18:10:48 +04:00
|
|
|
}
|
2013-08-15 14:15:39 +04:00
|
|
|
return app.exec();
|
2011-02-17 02:21:45 +03:00
|
|
|
}
|
|
|
|
|