Changeset 29
- Timestamp:
- 01/06/08 11:59:56 (4 years ago)
- Files:
-
- 4 added
- 6 edited
-
gui/main_window.cpp (modified) (4 diffs)
-
gui/main_window.h (modified) (3 diffs)
-
gui/preferences_dialog.cpp (modified) (2 diffs)
-
gui/preferences_dialog.h (modified) (1 diff)
-
gui/preferences_dialog.ui (modified) (1 diff)
-
images (added)
-
images/bad.svg (added)
-
images/heart.svg (added)
-
images/trash.svg (added)
-
main.cpp (modified) (2 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 } -
gui/main_window.h
r28 r29 5 5 #include <QSortFilterProxyModel> 6 6 #include <QTimer> 7 #include <QSettings> 8 #include <QSystemTrayIcon> 9 #include <QMenu> 7 10 8 11 #include "ui_main_window.h" … … 20 23 //~MainWindow(); 21 24 25 protected: 26 void closeEvent(QCloseEvent *event); 27 22 28 private: 29 QSettings settings; 23 30 MPDConnection mpd; 24 31 MPDStatus mpd_status; … … 28 35 QSortFilterProxyModel libraryProxyModel; 29 36 bool slidingVolume; 37 38 void setupTrayIcon(); 39 QAction *minimizeAction; 40 QAction *maximizeAction; 41 QAction *restoreAction; 42 QAction *quitAction; 43 QSystemTrayIcon *trayIcon; 44 QMenu *trayIconMenu; 30 45 31 46 private slots: -
gui/preferences_dialog.cpp
r25 r29 1 1 #include "preferences_dialog.h" 2 #include "main_window.h" 2 3 3 4 PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f) … … 29 30 settings.setValue("connection/port", portSpinBox->value()); 30 31 settings.setValue("connection/password", passwordLineEdit->text()); 32 settings.setValue("systemtray", systemTrayCheckBox->isChecked()); 33 emit systemTraySet(systemTrayCheckBox->isChecked()); 31 34 break; 32 35 case QDialogButtonBox::RejectRole: -
gui/preferences_dialog.h
r25 r29 21 21 void writeSettings(); 22 22 void buttonPressed(QAbstractButton *button); 23 24 signals: 25 void systemTraySet(bool visible); 23 26 }; 24 27 -
gui/preferences_dialog.ui
r21 r29 111 111 <widget class="QCheckBox" name="systemTrayCheckBox" > 112 112 <property name="enabled" > 113 <bool> false</bool>113 <bool>true</bool> 114 114 </property> 115 115 <property name="text" > -
main.cpp
r25 r29 1 1 #include <QApplication> 2 #include <QSystemTrayIcon> 3 #include <QMessageBox> 2 4 3 5 #include "gui/main_window.h" … … 9 11 QApplication::setOrganizationName("lowblogprojects"); 10 12 13 if (!QSystemTrayIcon::isSystemTrayAvailable()) { 14 QMessageBox::critical(0, QObject::tr("Systray"), 15 QObject::tr("I couldn't detect any system tray on this system.")); 16 return 1; 17 } 18 11 19 MainWindow w; 12 20 w.show();
Note: See TracChangeset
for help on using the changeset viewer.
