diff options
author | ubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2011-11-03 22:01:19 +0000 |
---|---|---|
committer | ubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2011-11-03 22:01:19 +0000 |
commit | e6e175d09e0046e1d7e1616602fa2677308c8d3b (patch) | |
tree | 0439e67fd891c690559e2195680d70e396c3e593 | |
parent | first tray with minimal functionality - close ;-) (diff) | |
download | gpg4usb-e6e175d09e0046e1d7e1616602fa2677308c8d3b.tar.gz gpg4usb-e6e175d09e0046e1d7e1616602fa2677308c8d3b.zip |
don't close on quit, keep in tray
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@598 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r-- | gpg4usb.qrc | 1 | ||||
-rw-r--r-- | mainwindow.cpp | 38 |
2 files changed, 35 insertions, 4 deletions
diff --git a/gpg4usb.qrc b/gpg4usb.qrc index 2629f0f..8a7e794 100644 --- a/gpg4usb.qrc +++ b/gpg4usb.qrc @@ -1,5 +1,6 @@ <RCC> <qresource prefix="/"> <file alias="tray.png">release/icons/keymgmt.png</file> + <file alias="help.png">release/icons/help.png</file> </qresource> </RCC> diff --git a/mainwindow.cpp b/mainwindow.cpp index 8c42c06..7710043 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -470,8 +470,25 @@ void MainWindow::createDockWindows() void MainWindow::createTrayIcon() { + QAction* minimizeAction = new QAction(tr("Mi&nimize"), this); + connect(minimizeAction, SIGNAL(triggered()), this, SLOT(hide())); + + QAction* maximizeAction = new QAction(tr("Ma&ximize"), this); + connect(maximizeAction, SIGNAL(triggered()), this, SLOT(showMaximized())); + + QAction* restoreAction = new QAction(tr("&Restore"), this); + connect(restoreAction, SIGNAL(triggered()), this, SLOT(showNormal())); + + QAction* quitAction = new QAction(tr("&Quit"), this); + connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); + trayIconMenu = new QMenu(this); - trayIconMenu->addAction(quitAct); + trayIconMenu->addAction(minimizeAction); + //trayIconMenu->addAction(maximizeAction); + trayIconMenu->addAction(restoreAction); + trayIconMenu->addSeparator(); + trayIconMenu->addAction(quitAction); + trayIcon = new QSystemTrayIcon(this); @@ -483,12 +500,12 @@ void MainWindow::createTrayIcon() { }*/ trayIcon->setProperty("_qt_sni_category", qApp->applicationDirPath() + "/tmp"); trayIcon->setContextMenu(trayIconMenu); - //showTrayMessage("tray is ready", "no further text"); + } void MainWindow::showTrayMessage(QString title, QString body) { - //QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::MessageIcon(":/icons/exit.png"); - trayIcon->showMessage(title, body, QSystemTrayIcon::Information, 10000); + QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::MessageIcon(QSystemTrayIcon::Information); + trayIcon->showMessage(title, body, icon, 15000); } void MainWindow::createAttachmentDock() { @@ -518,6 +535,19 @@ void MainWindow::closeAttachmentDock() { void MainWindow::closeEvent(QCloseEvent *event) { + + // TODO: if close via tray, check for unsaved documents + if (trayIcon->isVisible()) { + + showTrayMessage(tr("GPG4USB still alive"), tr("gpg4usb will keep running in the " + "system tray. To terminate the program, " + "choose <b>Quit</b> in the context menu " + "of the system tray entry.")); + + hide(); + event->ignore(); + return; + } /* * ask to save changes, if there are * modified documents in any tab |