Переглянути джерело

- Fixed the tray icon on all platforms.
- Simplified the application icon method in the theme
- Set a Window Icon

Klaas Freitag 14 роки тому
батько
коміт
c196f77732
5 змінених файлів з 23 додано та 19 видалено
  1. 5 3
      src/main.cpp
  2. 15 12
      src/mirall/application.cpp
  3. 0 1
      src/mirall/application.h
  4. 2 2
      src/mirall/theme.cpp
  5. 1 1
      src/mirall/theme.h

+ 5 - 3
src/main.cpp

@@ -16,8 +16,10 @@
 
 int main(int argc, char **argv)
 {
-  Mirall::Application app(argc, argv);
-  Q_INIT_RESOURCE(mirall);
-  return app.exec();
+    Q_INIT_RESOURCE(mirall);
+
+    Mirall::Application app(argc, argv);
+
+    return app.exec();
 }
 

+ 15 - 12
src/mirall/application.cpp

@@ -45,17 +45,19 @@ namespace Mirall {
 
 Application::Application(int argc, char **argv) :
     QApplication(argc, argv),
-    _tray(new QSystemTrayIcon(this)),
+    _tray(0),
     _networkMgr(new QNetworkConfigurationManager(this)),
     _contextMenu(0),
     _ocInfo(0)
 {
+
 #ifdef OWNCLOUD_CLIENT
     _theme = new ownCloudTheme();
 #else
     _theme = new mirallTheme();
 #endif
     setApplicationName( _theme->appName() );
+    setWindowIcon( _theme->applicationIcon() );
 
     _splash = new QSplashScreen( _theme->splashScreen() );
     _splash->show();
@@ -123,6 +125,8 @@ Application::Application(int argc, char **argv) :
     }
 
     setupActions();
+    setupSystemTray();
+    processEvents();
 
     QTimer::singleShot( 5000, this, SLOT(slotHideSplash()) );
     QTimer::singleShot( 0, this, SLOT( slotStartFolderSetup() ));
@@ -141,8 +145,6 @@ Application::~Application()
 
 void Application::slotStartFolderSetup()
 {
-    setupSystemTray();
-
     if( _ocInfo->isConfigured() ) {
       _ocInfo->checkInstallation();
     } else {
@@ -185,6 +187,8 @@ void Application::slotAuthCheck( const QString& ,QNetworkReply *reply )
         if( cnt ) {
             _tray->setIcon(_theme->folderIcon("owncloud", 24));
             _tray->show();
+            processEvents();
+
             if( _tray )
                 _tray->showMessage(tr("ownCloud Sync Started"), tr("Sync started for %1 configured sync folder(s).").arg(cnt));
         }
@@ -212,7 +216,7 @@ void Application::setupActions()
 
 void Application::setupSystemTray()
 {
-    // _tray = new QSystemTrayIcon(this);
+    _tray = new QSystemTrayIcon();
     _tray->setIcon( _theme->folderIcon("none", 48) ); // load the grey icon
 
     connect(_tray,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
@@ -223,8 +227,11 @@ void Application::setupSystemTray()
 
 void Application::setupContextMenu()
 {
-    if( _contextMenu ) delete _contextMenu;
-    _contextMenu = new QMenu();
+    if( _contextMenu ) {
+        _contextMenu->clear();
+    } else {
+        _contextMenu = new QMenu();
+    }
     _contextMenu->setTitle(_theme->appName() );
     _contextMenu->addAction(_actionConfigure);
     _contextMenu->addAction(_actionAddFolder);
@@ -505,12 +512,8 @@ void Application::computeOverallSyncStatus()
   QIcon statusIcon = _theme->syncStateIcon( overallResult.status(), 22 );
 
   if( overallResult.status() == SyncResult::Success ) {
-  // Rather display the mirall icon instead of the ok icon.
-#ifdef _WIN32
-      statusIcon = _theme->applicationIcon( 16 );
-#else
-      statusIcon = _theme->applicationIcon( 22 );
-#endif
+      // Rather display the mirall icon instead of the ok icon.
+      statusIcon = _theme->applicationIcon();
   }
 
   _tray->setIcon( statusIcon );

+ 0 - 1
src/mirall/application.h

@@ -49,7 +49,6 @@ public:
 signals:
 
 protected slots:
-
     void slotAddFolder();
     void slotRemoveFolder( const QString& );
 #ifdef HAVE_FETCH_AND_PUSH

+ 2 - 2
src/mirall/theme.cpp

@@ -89,9 +89,9 @@ QString Theme::statusHeaderText( SyncResult::Status status ) const
     return resultStr;
 }
 
-QIcon Theme::applicationIcon( int size ) const
+QIcon Theme::applicationIcon( ) const
 {
-    return QIcon(QString(":mirall/resources/mirall-%1").arg(size));
+    return QIcon(QString(":mirall/resources/mirall-48"));
 }
 
 QString Theme::version() const

+ 1 - 1
src/mirall/theme.h

@@ -44,7 +44,7 @@ public:
     virtual QIcon   syncStateIcon( SyncResult::Status, int ) const;
     virtual QString statusHeaderText( SyncResult::Status ) const;
     virtual QPixmap splashScreen() const = 0;
-    virtual QIcon   applicationIcon( int ) const;
+    virtual QIcon   applicationIcon() const;
 
     virtual QString version() const;
 private: