Changeset 29 for gui/main_window.cpp
- Timestamp:
- 01/06/08 11:59:56 (4 years ago)
- File:
-
- 1 edited
-
gui/main_window.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
gui/main_window.cpp
r28 r29 1 1 #include <cmath> 2 2 #include <QtGui> 3 #include <QIcon> 3 4 4 5 #include "main_window.h" … … 7 8 MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) 8 9 { 9 QSettings settings;10 11 10 setupUi(this); 12 11 … … 60 59 connect(&statusTimer, SIGNAL(timeout()), &mpd, SLOT(getStatus())); 61 60 61 //Tray icon 62 setupTrayIcon(); 63 if (settings.value("systemtray").toBool()) { 64 trayIcon->show(); 65 } 66 62 67 mpd.getStatus(); 63 68 mpd.listAllInfo(); … … 71 76 }*/ 72 77 78 void MainWindow::closeEvent(QCloseEvent *event) 79 { 80 if (trayIcon->isVisible()) { 81 QMessageBox::information(this, tr("Systray"), 82 tr("The program will keep running in the " 83 "system tray. To terminate the program, " 84 "choose <b>Quit</b> in the context menu " 85 "of the system tray entry.")); 86 hide(); 87 event->ignore(); 88 } 89 } 90 91 void MainWindow::setupTrayIcon() 92 { 93 //Setup Actions 94 minimizeAction = new QAction(tr("Mi&nimize"), this); 95 connect(minimizeAction, SIGNAL(triggered()), this, SLOT(hide())); 96 97 maximizeAction = new QAction(tr("Ma&ximize"), this); 98 connect(maximizeAction, SIGNAL(triggered()), this, SLOT(showMaximized())); 99 100 restoreAction = new QAction(tr("&Restore"), this); 101 connect(restoreAction, SIGNAL(triggered()), this, SLOT(showNormal())); 102 103 quitAction = new QAction(tr("&Quit"), this); 104 connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); 105 106 //Setup Menu 107 trayIconMenu = new QMenu(this); 108 trayIconMenu->addAction(minimizeAction); 109 trayIconMenu->addAction(maximizeAction); 110 trayIconMenu->addAction(restoreAction); 111 trayIconMenu->addSeparator(); 112 trayIconMenu->addAction(quitAction); 113 114 //Setup Icon 115 QIcon icon("images/bad.svg"); 116 117 //Mix it 118 trayIcon = new QSystemTrayIcon(this); 119 trayIcon->setContextMenu(trayIconMenu); 120 trayIcon->setIcon(icon); 121 } 122 73 123 void MainWindow::showPreferencesDialog() 74 124 { 75 125 PreferencesDialog pref(this); 126 connect(&pref, SIGNAL(systemTraySet(bool)), trayIcon, SLOT(setVisible(bool))); 76 127 pref.exec(); 77 128 }
Note: See TracChangeset
for help on using the changeset viewer.
