Changeset 42 for gui/main_window.cpp
- Timestamp:
- 01/07/08 16:25:46 (4 years ago)
- File:
-
- 1 edited
-
gui/main_window.cpp (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
gui/main_window.cpp
r41 r42 2 2 #include <QtGui> 3 3 #include <QIcon> 4 #include <Q Debug>4 #include <QString> 5 5 6 6 #include "main_window.h" … … 10 10 MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) 11 11 { 12 //Setup and set visible. 12 13 setupUi(this); 14 setVisible(true); 13 15 14 16 slidingVolume = false; … … 19 21 20 22 //Tray stuf 21 setupTrayIcon(); 22 if (settings.value("systemtray").toBool()) { 23 if (setupTrayIcon() && settings.value("systemtray").toBool()) { 23 24 trayIcon->show(); 24 25 } … … 79 80 } 80 81 81 /*MainWindow::~MainWindow()82 {83 qDebug("Closing main window...");84 }*/85 86 82 void MainWindow::closeEvent(QCloseEvent *event) 87 83 { 88 if (trayIcon->isVisible()) { 89 QMessageBox::information(this, tr("Systray"), 90 tr("The program will keep running in the " 91 "system tray. To terminate the program, " 92 "choose <b>Quit</b> in the context menu " 93 "of the system tray entry.")); 84 if (trayIcon != NULL && trayIcon->isVisible()) { 94 85 hide(); 95 86 event->ignore(); … … 97 88 } 98 89 99 void MainWindow::setupTrayIcon() 100 { 90 bool MainWindow::setupTrayIcon() 91 { 92 if (!QSystemTrayIcon::isSystemTrayAvailable()) { 93 trayIcon = NULL; 94 return false; 95 } 96 101 97 trayIcon = new QSystemTrayIcon(this); 102 98 trayIconMenu = new QMenu(this); … … 127 123 trayIcon->setIcon(icon); 128 124 trayIcon->setToolTip("QtMPC"); 125 126 return true; 129 127 } 130 128 … … 132 130 { 133 131 PreferencesDialog pref(this); 134 connect(&pref, SIGNAL(systemTraySet(bool)), trayIcon, SLOT(setVisible(bool))); 132 if (trayIcon != NULL) 133 connect(&pref, SIGNAL(systemTraySet(bool)), trayIcon, SLOT(setVisible(bool))); 135 134 pref.exec(); 136 135 } … … 210 209 211 210 playlistModel.updateCurrentSong(song->id); 211 212 if (settings.value("systemtrayPopup").toBool() && trayIcon != NULL && trayIcon->isVisible() && isHidden()) { 213 if (!song->title.isEmpty() && !song->artist.isEmpty() && !song->album.isEmpty()) { 214 trayIcon->showMessage(song->artist + " - " + song->title, 215 "album:" + song->album + "\n" + 216 "track:" + QString::number(song->track) + "\n" + 217 "time:" + QString::number(song->time) + "\n", 218 QSystemTrayIcon::Information, 5000); 219 } 220 } 212 221 213 222 delete song;
Note: See TracChangeset
for help on using the changeset viewer.
