From 9aefea2dc8af8db7954ee41c2e88d52b2542c256 Mon Sep 17 00:00:00 2001 From: Konstantin Isakov Date: Fri, 9 Oct 2009 21:03:55 +0000 Subject: [PATCH] +! Don't allow interacting with the tray icon until the program loads fully. --- src/mainwindow.cc | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/mainwindow.cc b/src/mainwindow.cc index c3dd2d2d..6fb1f711 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -168,11 +168,15 @@ MainWindow::MainWindow( Config::Class & cfg_ ): connect( dictionaryBar.toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT(dictionaryBarToggled(bool)) ); - // Show tray icon early so the user would be happy - updateTrayIcon(); + // Show tray icon early so the user would be happy. It won't be functional + // though until the program inits fully. - if ( trayIcon ) + if ( cfg.preferences.enableTrayIcon ) + { + trayIcon = new QSystemTrayIcon( QIcon( ":/icons/programicon.png" ), this ); trayIcon->setToolTip( tr( "Loading..." ) ); + trayIcon->show(); + } connect( navBack, SIGNAL( activated() ), this, SLOT( backClicked() ) ); @@ -270,6 +274,17 @@ MainWindow::MainWindow( Config::Class & cfg_ ): ui.translateLine->setFocus(); + if ( trayIcon ) + { + // Upgrade existing dummy tray icon into a full-functional one + + trayIcon->setContextMenu( &trayIconMenu ); + trayIcon->show(); + + connect( trayIcon, SIGNAL( activated( QSystemTrayIcon::ActivationReason ) ), + this, SLOT( trayIconActivated( QSystemTrayIcon::ActivationReason ) ) ); + } + updateTrayIcon(); // Update zoomers