limit subtask list
[Sak.git] / main.cpp
blob29db0ce9edee477f5ac2b23edba1c30bc7dc5209
1 #include <QtGui>
2 #include <signal.h>
3 #include "sak.h"
5 void sighandler(int signum) {
6 static bool quitting = false;
7 qDebug() << "SAK: caught signal " << signum;
8 signal(signum, SIG_IGN);
9 if (!quitting) {
10 quitting = true;
11 qApp->quit();
16 class MySplashScreen : public QSplashScreen
18 public:
19 MySplashScreen(const QPixmap & px) : QSplashScreen(px) {}
20 protected:
21 void timerEvent(QTimerEvent*) { hide(); deleteLater(); }
25 int main(int argc, char** argv)
27 QApplication app (argc, argv);
29 #ifdef Q_OS_LINUX
30 app.setGraphicsSystem("raster");
31 #endif
33 if (!QSystemTrayIcon::isSystemTrayAvailable()) {
34 QMessageBox::critical(0, QObject::tr("Systray"),
35 QObject::tr("I couldn't detect any system tray "
36 "on this system."));
37 return 1;
40 #if 0
41 signal(SIGINT, sighandler);\v
42 #ifdef Q_OS_LINUX
43 signal(SIGQUIT, sighandler);
44 #endif
45 signal(SIGILL, sighandler);
46 signal(SIGABRT, sighandler);
47 signal(SIGFPE, sighandler);
48 signal(SIGSEGV, sighandler);
49 signal(SIGTERM, sighandler);
50 #endif
52 QFile lockFile(QDir::homePath() + QDir::separator() + ".sak.run");
53 if (lockFile.exists()) {
54 if ( QMessageBox::question(0, "Another instance of SAK is running ", "Another instance of SAK seems to be running right now. Proceeding with this new instance may results in data loss / corruptions. Do you want to proceed?", QMessageBox::Yes | QMessageBox::No , QMessageBox::No) == QMessageBox::No)
55 return -1;
56 else {
57 QFile::remove(lockFile.fileName());
60 lockFile.open(QIODevice::ReadWrite);
62 #ifdef CENSORED
63 QPixmap px(":/images/active.png");
64 #else
65 QPixmap px(":/images/splash.png");
66 #endif
67 MySplashScreen* splash = new MySplashScreen(px);
68 splash->setMask(px.createMaskFromColor(QColor(0,0,0,0), Qt::MaskInColor));
69 splash->show();
70 splash->startTimer(2000);
71 app.processEvents();
72 Sak sak;
73 bool rc = app.exec();
75 lockFile.close();
76 QFile::remove(lockFile.fileName());
77 return rc;