diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-04-24 17:40:18 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-04-24 19:01:45 (GMT) |
commit | f45aa5ce9ee21679abbe263ec2df7f0254331f4b (patch) | |
tree | 1b67cf3e7f19ff74ae65204f20574537894c6304 /Slimber/Qt | |
parent | 9bff72701b1541180b92bfef8bac7a6921d19576 (diff) | |
download | swift-contrib-f45aa5ce9ee21679abbe263ec2df7f0254331f4b.zip swift-contrib-f45aa5ce9ee21679abbe263ec2df7f0254331f4b.tar.bz2 |
Add About dialog to Slimber/Qt.
Diffstat (limited to 'Slimber/Qt')
-rw-r--r-- | Slimber/Qt/QtAboutDialog.cpp | 37 | ||||
-rw-r--r-- | Slimber/Qt/QtAboutDialog.h | 14 | ||||
-rw-r--r-- | Slimber/Qt/QtMenulet.h | 13 | ||||
-rw-r--r-- | Slimber/Qt/SConscript | 3 | ||||
-rw-r--r-- | Slimber/Qt/Slimber.qrc | 1 | ||||
-rw-r--r-- | Slimber/Qt/main.cpp | 7 |
6 files changed, 74 insertions, 1 deletions
diff --git a/Slimber/Qt/QtAboutDialog.cpp b/Slimber/Qt/QtAboutDialog.cpp new file mode 100644 index 0000000..9b4e821 --- /dev/null +++ b/Slimber/Qt/QtAboutDialog.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2010 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#include "Slimber/Qt/QtAboutDialog.h" + +#include <QCoreApplication> +#include <QVBoxLayout> +#include <QLabel> +#include <QPixmap> + +QtAboutDialog::QtAboutDialog() { + setAttribute(Qt::WA_DeleteOnClose); + setWindowTitle("About Slimber"); + + QVBoxLayout* layout = new QVBoxLayout(this); + + QLabel* iconLabel = new QLabel(this); + iconLabel->setPixmap(QPixmap(":/icons/Icon-128.png")); + iconLabel->setAlignment(Qt::AlignHCenter); + layout->addWidget(iconLabel); + + QLabel* appNameLabel = new QLabel("<center><font size='+1'><b>" + QCoreApplication::applicationName() + "</b></font></center>", this); + layout->addWidget(appNameLabel); + + QLabel* versionLabel = new QLabel(QString("<center><font size='-1'>Version ") + QCoreApplication::applicationVersion() + "</font></center>", this); + layout->addWidget(versionLabel); + QString buildString = QString("<center><font size='-1'>Built with: Qt version ") + QT_VERSION_STR; + buildString += QString("<br/>Running with Qt version ") + qVersion(); + buildString += "</font></center>"; + QLabel* buildLabel = new QLabel(buildString, this); + layout->addWidget(buildLabel); + + setFixedSize(minimumSizeHint()); +} diff --git a/Slimber/Qt/QtAboutDialog.h b/Slimber/Qt/QtAboutDialog.h new file mode 100644 index 0000000..9e139da --- /dev/null +++ b/Slimber/Qt/QtAboutDialog.h @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2010 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +#include <QDialog> + +class QtAboutDialog : public QDialog { + public: + QtAboutDialog(); +}; diff --git a/Slimber/Qt/QtMenulet.h b/Slimber/Qt/QtMenulet.h index 19458b3..08bae0c 100644 --- a/Slimber/Qt/QtMenulet.h +++ b/Slimber/Qt/QtMenulet.h @@ -12,8 +12,10 @@ #include <QSystemTrayIcon> #include <QObject> #include <QPixmap> +#include <QPointer> #include "Slimber/Menulet.h" +#include "Slimber/Qt/QtAboutDialog.h" class QtMenulet : public QObject, public Menulet { Q_OBJECT @@ -33,7 +35,7 @@ class QtMenulet : public QObject, public Menulet { } void addAboutItem() { - menu.addAction("About"); + menu.addAction("About", this, SLOT(showAboutDialog())); } void addRestartItem() { @@ -59,6 +61,14 @@ class QtMenulet : public QObject, public Menulet { private slots: void showAboutDialog() { + if (aboutDialog) { + aboutDialog->raise(); + aboutDialog->activateWindow(); + } + else { + aboutDialog = new QtAboutDialog(); + aboutDialog->show(); + } } void restart() { @@ -68,4 +78,5 @@ class QtMenulet : public QObject, public Menulet { private: QMenu menu; QSystemTrayIcon trayIcon; + QPointer<QtAboutDialog> aboutDialog; }; diff --git a/Slimber/Qt/SConscript b/Slimber/Qt/SConscript index 5e28b58..6fced8b 100644 --- a/Slimber/Qt/SConscript +++ b/Slimber/Qt/SConscript @@ -22,9 +22,12 @@ if env["PLATFORM"] == "win32" : myenv.Append(LINKFLAGS = ["/SUBSYSTEM:WINDOWS"]) myenv.Append(LIBS = "qtmain") +myenv.BuildVersion("BuildVersion.h", version = env["SLIMBER_VERSION"]) + sources = [ "main.cpp", "QtMenulet.cpp", + "QtAboutDialog.cpp", myenv.Qrc("Slimber.qrc"), ] diff --git a/Slimber/Qt/Slimber.qrc b/Slimber/Qt/Slimber.qrc index 6cc21ff..26b5985 100644 --- a/Slimber/Qt/Slimber.qrc +++ b/Slimber/Qt/Slimber.qrc @@ -5,5 +5,6 @@ <file alias="icons/Online.png">../Resources/Online.png</file> <file alias="icons/UsersOffline.png">../Resources/UsersOffline.png</file> <file alias="icons/UsersOnline.png">../Resources/UsersOnline.png</file> + <file alias="icons/Icon-128.png">../Resources/Icon-128.png</file> </qresource> </RCC> diff --git a/Slimber/Qt/main.cpp b/Slimber/Qt/main.cpp index 6016945..6c6ea26 100644 --- a/Slimber/Qt/main.cpp +++ b/Slimber/Qt/main.cpp @@ -5,22 +5,29 @@ */ #include <QApplication> +#include <QCoreApplication> #include <QSystemTrayIcon> #include <QMessageBox> #include "QtMenulet.h" #include "Slimber/MainController.h" #include "Swiften/EventLoop/Qt/QtEventLoop.h" +#include "Slimber/Qt/BuildVersion.h" int main(int argc, char* argv[]) { QApplication app(argc, argv); QtEventLoop eventLoop; + QCoreApplication::setApplicationName("Slimber"); + QCoreApplication::setApplicationVersion(QString(buildVersion)); + if (!QSystemTrayIcon::isSystemTrayAvailable()) { QMessageBox::critical(0, QObject::tr("Systray"), QObject::tr("No system tray")); return 1; } + app.setQuitOnLastWindowClosed(false); + QtMenulet menulet; MainController controller(&menulet); |