MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), parent(parent), ui(new Ui::MainWindow), trayIcon(new QSystemTrayIcon(this)), trayIconMenu(new QMenu(this)), quitAction(new QAction("Zamknij", this)), restoreAction(new QAction("Przywróć", this)), wiadomosciAction(new QAction("Wiadomości", this)), wyslij(new QAction("Wyślij wiadomość", this)), info(new QAction("Informacje", this)), connection(new Connection(this)) { ui->setupUi(this); ui->Ustawienia_status->setText(QString("Rozłączony")); ui->Ustawienia_wersja->setText(QString("Wersja: ")+VERSION); connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayActivated(QSystemTrayIcon::ActivationReason))); connect (ui->Ustawienia_b_aktualizuj, SIGNAL(clicked()), this, SLOT(aktualizujButtonClicked())); connect (ui->Ustawienia_b_zaloguj, SIGNAL(clicked()), this, SLOT(zalogujButtonClicked())); connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); connect(restoreAction, SIGNAL(triggered()), this, SLOT(show())); connect(wiadomosciAction, SIGNAL(triggered()), this, SLOT(showWiadomosciDialog())); connect(ui->Grupy_list, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(setGrupaDane(QListWidgetItem *))); connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(trayMessageClicked())); setIconsAndTray(); trayMessageState.first = QString("INFORMATION"); }
/** * Creates a tray icon and tray icon menu for the application. * Connects actions for clicking on tray icon, message box and right-click. * @brief MainWindow::createTray */ void MainWindow::createTray() { trayIcon = new QSystemTrayIcon(this); trayIcon->setIcon(QIcon(APPLICATION_ICON)); connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayActions(QSystemTrayIcon::ActivationReason))); connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(trayMessageClicked())); trayMenu = new QMenu(this); trayMenu->addAction(new QAction(STR_SHOW, this)); trayMenu->addAction(new QAction(STR_EXIT, this)); connect(trayMenu, SIGNAL(triggered(QAction*)), this, SLOT(trayMenuClicked(QAction*))); trayIcon->setContextMenu(trayMenu); trayIcon->show(); }