(qt) #5206 'tray icon cancels logout in KDE' -- fixed with patch from basinilya

This commit is contained in:
Jordan Lee 2013-01-01 20:02:20 +00:00
parent fd61c3af0b
commit 5cfcfd95c4
2 changed files with 31 additions and 21 deletions

View File

@ -250,11 +250,11 @@ TrMainWindow :: TrMainWindow( Session& session, Prefs& prefs, TorrentModel& mode
myTrayIcon.setIcon( QApplication::windowIcon( ) );
connect( &myPrefs, SIGNAL(changed(int)), this, SLOT(refreshPref(int)) );
connect( ui.action_ShowMainWindow, SIGNAL(toggled(bool)), this, SLOT(toggleWindows(bool)));
connect( ui.action_ShowMainWindow, SIGNAL(triggered(bool)), this, SLOT(toggleWindows(bool)));
connect( &myTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
this, SLOT(trayActivated(QSystemTrayIcon::ActivationReason)));
ui.action_ShowMainWindow->setChecked( !minimized );
toggleWindows( !minimized );
ui.action_TrayIcon->setChecked( minimized || prefs.getBool( Prefs::SHOW_TRAY_ICON ) );
ui.verticalLayout->addWidget( createStatusBar( ) );
@ -312,23 +312,6 @@ TrMainWindow :: ~TrMainWindow( )
*****
****/
void
TrMainWindow :: closeEvent( QCloseEvent * event )
{
// if they're using a tray icon, close to the tray
// instead of exiting
if( !myPrefs.getBool( Prefs :: SHOW_TRAY_ICON ) )
event->accept( );
else {
toggleWindows( false );
event->ignore( );
}
}
/****
*****
****/
void
TrMainWindow :: onSessionSourceChanged( )
{
@ -566,6 +549,31 @@ TrMainWindow :: setSortAscendingPref( bool b )
*****
****/
void
TrMainWindow :: showEvent( QShowEvent * event )
{
Q_UNUSED (event);
ui.action_ShowMainWindow->setChecked(true);
}
/****
*****
****/
void
TrMainWindow :: hideEvent( QHideEvent * event )
{
Q_UNUSED (event);
if (!isVisible())
ui.action_ShowMainWindow->setChecked(false);
}
/****
*****
****/
void
TrMainWindow :: onPrefsDestroyed( )
{
@ -999,7 +1007,7 @@ TrMainWindow :: trayActivated( QSystemTrayIcon::ActivationReason reason )
if( isMinimized ( ) )
toggleWindows( true );
else
ui.action_ShowMainWindow->toggle( );
toggleWindows( !isVisible() );
}
}
@ -1085,6 +1093,7 @@ TrMainWindow :: refreshPref( int key )
b = myPrefs.getBool( key );
ui.action_TrayIcon->setChecked( b );
myTrayIcon.setVisible( b );
dynamic_cast<MyApp*>(QCoreApplication::instance())->setQuitOnLastWindowClosed(!b);
refreshTrayIconSoon( );
break;

View File

@ -52,7 +52,8 @@ class TrMainWindow: public QMainWindow
Q_OBJECT
private:
virtual void closeEvent( QCloseEvent * event );
virtual void hideEvent( QHideEvent * event );
virtual void showEvent( QShowEvent * event );
private:
time_t myLastFullUpdateTime;