Mercurial > trustbridge
annotate ui/main.cpp @ 76:63b79d135631
Remove QTextStream usage. The QTextStream usage in this way
caused a segmentation fault on Windows
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Wed, 19 Mar 2014 16:33:25 +0000 |
parents | 5c616934cbe4 |
children | 3349c9596043 |
rev | line source |
---|---|
0
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
1 #include "mainwindow.h" |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
2 |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
3 #include <QApplication> |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
4 #include <QSystemTrayIcon> |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
5 #include <QtPlugin> |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
6 #include <QMessageBox> |
17
c12825a651ed
Read out content-length and use this to skip existing files
Andre Heinecke <aheinecke@intevation.de>
parents:
16
diff
changeset
|
7 #include <QSettings> |
0
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
8 |
16
225a5ec20dad
Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
9 #ifndef VERSION |
225a5ec20dad
Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
10 #define VERSION "0.0.1" |
225a5ec20dad
Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
11 #endif |
225a5ec20dad
Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
12 |
225a5ec20dad
Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
13 #ifndef APPNAME |
225a5ec20dad
Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
14 #define APPNAME "m13ui" |
225a5ec20dad
Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
15 #endif |
225a5ec20dad
Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
16 |
225a5ec20dad
Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
17 #ifndef ORGANIZATION |
225a5ec20dad
Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
18 #define ORGANIZATION "m13org" |
225a5ec20dad
Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
19 #endif |
0
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
20 |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
21 #ifdef Q_OS_WIN |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
22 Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin) |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
23 #else |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
24 Q_IMPORT_PLUGIN(QXcbIntegrationPlugin) |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
25 #endif |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
26 |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
27 int main(int argc, char **argv) |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
28 { |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
29 QApplication app (argc, argv); |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
30 |
73
5c616934cbe4
Also check that the system tray supports messages
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
31 if (!QSystemTrayIcon::isSystemTrayAvailable() || |
5c616934cbe4
Also check that the system tray supports messages
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
32 !QSystemTrayIcon::supportsMessages()) { |
16
225a5ec20dad
Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
33 QMessageBox::critical(0, QString::fromLatin1(APPNAME), |
0
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
34 QObject::tr("Couldn't detect any system tray " |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
35 "on this system. This software can only " |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
36 "be used in a desktop environment.")); |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
37 return 1; |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
38 } |
16
225a5ec20dad
Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
39 |
0
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
40 QApplication::setQuitOnLastWindowClosed(false); |
16
225a5ec20dad
Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
41 QApplication::setOrganizationName(QString::fromLatin1(ORGANIZATION)); |
225a5ec20dad
Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
42 QApplication::setApplicationName(QString::fromLatin1(APPNAME)); |
225a5ec20dad
Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents:
0
diff
changeset
|
43 QApplication::setApplicationVersion(QString::fromLatin1(VERSION)); |
17
c12825a651ed
Read out content-length and use this to skip existing files
Andre Heinecke <aheinecke@intevation.de>
parents:
16
diff
changeset
|
44 QSettings::setDefaultFormat(QSettings::IniFormat); |
0
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
45 |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
46 MainWindow mainWin; |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
47 |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
48 return app.exec(); |
cb0cde2c5eb9
Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
49 } |