diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 051a592e8..24415637b 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -102,11 +102,7 @@ const char* MainWindow::kAllFilesFilterSpec = MainWindow::MainWindow(NetworkAccessManager* network, Engine::Type engine, QWidget *parent) : QMainWindow(parent), ui_(new Ui_MainWindow), -#ifdef Q_OS_DARWIN - tray_icon_(new MacSystemTrayIcon(this)), -#else - tray_icon_(new QtSystemTrayIcon(this)), -#endif + tray_icon_(SystemTrayIcon::CreateSystemTrayIcon(this)), osd_(new OSD(tray_icon_, network, this)), edit_tag_dialog_(new EditTagDialog), about_dialog_(new About), diff --git a/src/ui/systemtrayicon.cpp b/src/ui/systemtrayicon.cpp index c20d5b616..45599b4a2 100644 --- a/src/ui/systemtrayicon.cpp +++ b/src/ui/systemtrayicon.cpp @@ -16,6 +16,9 @@ #include "systemtrayicon.h" +#include "macsystemtrayicon.h" +#include "qtsystemtrayicon.h" + #include #include #include @@ -94,3 +97,11 @@ void SystemTrayIcon::SetStopped() { current_state_icon_ = QPixmap(); UpdateIcon(); } + +SystemTrayIcon* SystemTrayIcon::CreateSystemTrayIcon(QObject* parent) { +#ifdef Q_OS_DARWIN + return new MacSystemTrayIcon(parent); +#else + return new QtSystemTrayIcon(parent); +#endif +} diff --git a/src/ui/systemtrayicon.h b/src/ui/systemtrayicon.h index 699bd9b09..e15e277b6 100644 --- a/src/ui/systemtrayicon.h +++ b/src/ui/systemtrayicon.h @@ -40,6 +40,8 @@ class SystemTrayIcon : public QObject { virtual void ShowPopup(const QString& summary, const QString& message, int timeout) {} + static SystemTrayIcon* CreateSystemTrayIcon(QObject* parent = 0); + public slots: void SetProgress(int percentage); void SetPaused();