aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gpg4usb.pro2
-rw-r--r--gpg4usb.qrc5
-rw-r--r--main.cpp2
-rw-r--r--mainwindow.cpp25
-rw-r--r--mainwindow.h9
5 files changed, 43 insertions, 0 deletions
diff --git a/gpg4usb.pro b/gpg4usb.pro
index 9132d37..1c17f92 100644
--- a/gpg4usb.pro
+++ b/gpg4usb.pro
@@ -60,6 +60,8 @@ SOURCES += attachments.cpp \
RC_FILE = gpg4usb.rc
+RESOURCES = gpg4usb.qrc
+
# comment out line below for static building
LIBS += -lgpgme \
-lgpg-error \
diff --git a/gpg4usb.qrc b/gpg4usb.qrc
new file mode 100644
index 0000000..2629f0f
--- /dev/null
+++ b/gpg4usb.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file alias="tray.png">release/icons/keymgmt.png</file>
+ </qresource>
+</RCC>
diff --git a/main.cpp b/main.cpp
index 57ae4b8..2619f8e 100644
--- a/main.cpp
+++ b/main.cpp
@@ -25,6 +25,8 @@
int main(int argc, char *argv[])
{
+ Q_INIT_RESOURCE(gpg4usb);
+
QApplication app(argc, argv);
// get application path
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 8e03bfd..8c42c06 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -54,6 +54,7 @@ MainWindow::MainWindow()
createToolBars();
createStatusBar();
createDockWindows();
+ createTrayIcon();
mKeyList->addMenuAction(appendSelectedKeysAct);
mKeyList->addMenuAction(copyMailAddressToClipboardAct);
@@ -72,6 +73,7 @@ MainWindow::MainWindow()
edit->curTextPage()->setFocus();
this->setWindowTitle(qApp->applicationName());
this->show();
+ trayIcon->show();
// Show wizard, if the don't show wizard message box wasn't checked
// and keylist doesn't contain a private key
@@ -466,6 +468,29 @@ void MainWindow::createDockWindows()
}
}
+void MainWindow::createTrayIcon() {
+
+ trayIconMenu = new QMenu(this);
+ trayIconMenu->addAction(quitAct);
+
+ trayIcon = new QSystemTrayIcon(this);
+
+ QIcon icon(":/tray.png");
+ trayIcon->setIcon(icon);
+ /*QByteArray category = qgetenv("SNI_CATEGORY");
+ if (!category.isEmpty()) {
+ trayIcon->setProperty("_qt_sni_category", QString::fromLocal8Bit(category));
+ }*/
+ 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);
+}
+
void MainWindow::createAttachmentDock() {
if (attachmentDockCreated) {
return;
diff --git a/mainwindow.h b/mainwindow.h
index f2281a1..21939e0 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -193,6 +193,12 @@ private:
void createDockWindows();
/**
+ * @details Create icon for system tray
+ */
+ void createTrayIcon();
+ void showTrayMessage(QString title, QString body);
+
+ /**
* @details Create attachment-dockwindow.
*/
void createAttachmentDock();
@@ -234,6 +240,9 @@ private:
QDockWidget *attachmentDock; /** Attachment Dock */
QDialog *genkeyDialog; /** Dialog for key generation */
+ QSystemTrayIcon *trayIcon;
+ QMenu *trayIconMenu;
+
QAction *newTabAct; /** Action to create new tab */
QAction *switchTabUpAct; /** Action to switch tab up*/
QAction *switchTabDownAct; /** Action to switch tab down */