Mercurial > trustbridge
view ui/mainwindow.cpp @ 6:1f6455d46b30
Add a test list
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Tue, 11 Feb 2014 17:57:55 +0000 |
parents | cf88cc432b9d |
children | 992c0ec57660 |
line wrap: on
line source
#include "mainwindow.h" #include <QDebug> #include <QMessageBox> #include <QSystemTrayIcon> #include <QAction> #include <QDialog> #include <QMenu> #include <QApplication> MainWindow::MainWindow() { createActions(); createTrayIcon(); connect(mTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); } void MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason) { showMessage(); qDebug() << "Activated for reason: " << reason; switch (reason) { case QSystemTrayIcon::Trigger: case QSystemTrayIcon::DoubleClick: case QSystemTrayIcon::MiddleClick: showMessage(); break; default: ; } } void MainWindow::showMessage() { mTrayIcon->showMessage("Hello", "World", QSystemTrayIcon::Information, 10000); } void MainWindow::manualCheck() { QMessageBox::information(0, "Yay", "It Woarx.\n"); } void MainWindow::createActions() { mCheckUpdates = new QAction(tr("Check for Updates"), this); connect(mCheckUpdates, SIGNAL(triggered()), this, SLOT(manualCheck())); mQuitAction = new QAction(tr("Quit"), this); connect(mQuitAction, SIGNAL(triggered()), qApp, SLOT(quit())); } void MainWindow::createTrayIcon() { QIcon trayImg = QIcon(":/img/tray_22.png"); mTrayMenu = new QMenu(this); mTrayMenu->addAction(mCheckUpdates); mTrayMenu->addAction(mQuitAction); mTrayIcon = new QSystemTrayIcon(this); mTrayIcon->setContextMenu(mTrayMenu); mTrayIcon->setIcon(trayImg); setWindowIcon(trayImg); mTrayIcon->show(); mTrayIcon->setToolTip(tr("m13ui")); showMessage(); }