Fix quit menu

This commit is contained in:
Ximi1970
2020-02-25 21:17:53 +01:00
parent 221c88e2d0
commit 21b1242995
6 changed files with 86 additions and 43 deletions

View File

@@ -18,7 +18,7 @@
/*
* Constants
*/
const QString SysTrayX::JSON_PREF_REQUEST = "{\"preferences\":{}}";
const QString SysTrayX::JSON_PREF_REQUEST = "{\"preferences\":{}}";
/*
@@ -107,7 +107,7 @@ SysTrayX::SysTrayX( QObject *parent ) : QObject( parent )
* Connect link signals
*/
connect( m_link, &SysTrayXLink::signalUnreadMail, m_tray_icon, &SysTrayXIcon::slotSetUnreadMail );
connect( m_link, &SysTrayXLink::signalShutdown, this, &SysTrayX::slotShutdown );
connect( m_link, &SysTrayXLink::signalAddOnShutdown, this, &SysTrayX::slotAddOnShutdown );
connect( m_link, &SysTrayXLink::signalWindowState, m_win_ctrl, &WindowCtrl::slotWindowState );
connect( m_link, &SysTrayXLink::signalTitle, m_win_ctrl, &WindowCtrl::slotWindowTitle );
@@ -122,6 +122,11 @@ SysTrayX::SysTrayX( QObject *parent ) : QObject( parent )
*/
connect( m_tray_icon, &SysTrayXIcon::signalShowHide, m_win_ctrl, &WindowCtrl::slotShowHide );
/*
* SysTrayX
*/
connect( this, &SysTrayX::signalClose, m_win_ctrl, &WindowCtrl::slotClose );
/*
* Request preferences from add-on
*/
@@ -132,7 +137,7 @@ SysTrayX::SysTrayX( QObject *parent ) : QObject( parent )
/*
* Send a preferences request
*/
void SysTrayX::getPreferences()
void SysTrayX::getPreferences()
{
/*
* Request preferences from add-on
@@ -145,7 +150,7 @@ void SysTrayX::getPreferences()
/*
* Create the actions for the system tray icon menu
*/
void SysTrayX::createActions()
void SysTrayX::createActions()
{
/*
m_minimizeAction = new QAction(tr("Mi&nimize"), this);
@@ -165,7 +170,7 @@ void SysTrayX::createActions()
connect( m_pref_action, &QAction::triggered, m_pref_dialog, &PreferencesDialog::showNormal );
m_quit_action = new QAction(tr("&Quit"), this);
connect( m_quit_action, &QAction::triggered, qApp, &QCoreApplication::quit );
connect( m_quit_action, &QAction::triggered, this, &SysTrayX::slotShutdown );
}
@@ -173,7 +178,7 @@ void SysTrayX::createActions()
/*
* Create the system tray icon
*/
void SysTrayX::createTrayIcon()
void SysTrayX::createTrayIcon()
{
/*
* Setup menu actions
@@ -210,12 +215,29 @@ void SysTrayX::createTrayIcon()
/*
* Quit the app
* Quit the app by add-on request
*/
void SysTrayX::slotShutdown()
void SysTrayX::slotAddOnShutdown()
{
/*
* Let's quit
*/
QCoreApplication::quit();
}
/*
* Quit the app by quit menu
*/
void SysTrayX::slotShutdown()
{
/*
* Close the TB window
*/
emit signalClose();
/*
* Let's quit
*/
QCoreApplication::quit();
}

View File

@@ -49,17 +49,17 @@ class SysTrayX : public QObject
/**
* @brief SysTrayX::getPreferences
*/
void getPreferences();
void getPreferences();
/**
* @brief createTrayIcon. Create the system tray icon.
*/
void createTrayIcon();
void createTrayIcon();
/**
* @brief createActions. Create the menu actions.
*/
void createActions();
void createActions();
signals:
@@ -68,58 +68,68 @@ class SysTrayX : public QObject
*
* @param message
*/
void signalWriteMessage( QByteArray message );
void signalWriteMessage( QByteArray message );
/**
* @brief signalClose. Signal close all TB windows.
*/
void signalClose();
private slots:
/**
* @brief slotShutdown Shutdown the app.
*/
void slotShutdown();
* @brief slotAddOnShutdown. Hnadle shutdown request from the add-on.
*/
void slotAddOnShutdown();
/**
* @brief slotShutdown. Hnadle shutdown request from the menu.
*/
void slotShutdown();
private:
/**
* @brief m_preferences. Pointer to the preferences storage.
*/
Preferences *m_preferences;
Preferences* m_preferences;
/**
* @brief m_debug
*/
DebugWidget *m_debug;
DebugWidget* m_debug;
/**
* @brief m_win_ctrl. Pointer to the window control.
*/
WindowCtrl *m_win_ctrl;
WindowCtrl* m_win_ctrl;
/**
* @brief m_link. Pointer to the link object.
*/
SysTrayXLink *m_link;
SysTrayXLink* m_link;
/**
* @brief m_pref_dialog. Pointer to the preferences dialog.
*/
PreferencesDialog *m_pref_dialog;
PreferencesDialog* m_pref_dialog;
/**
* @brief m_tray_icon. Pointer to the system tray icon.
*/
SysTrayXIcon *m_tray_icon;
SysTrayXIcon* m_tray_icon;
/**
* @brief m_tray_icon_menu. Pointer to the tray icon menu.
*/
QMenu *m_tray_icon_menu;
QMenu* m_tray_icon_menu;
/**
* @brief m_xxxx_action. Pointer to the menu actions.
*/
QAction *m_pref_action;
QAction *m_quit_action;
QAction *m_showhide_action;
QAction* m_pref_action;
QAction* m_quit_action;
QAction* m_showhide_action;
};
#endif // SYSTRAYX_H

View File

@@ -140,7 +140,7 @@ void SysTrayXLinkReader::slotWorker()
if( error_count > 20 )
{
emit signalShutdown();
emit signalAddOnShutdown();
}
}
}
@@ -186,7 +186,7 @@ SysTrayXLink::SysTrayXLink( Preferences* pref )
connect( m_reader_thread, &QThread::finished, reader, &QObject::deleteLater );
connect( reader, &SysTrayXLinkReader::signalReceivedMessage, this, &SysTrayXLink::slotLinkRead );
connect( reader, &SysTrayXLinkReader::signalShutdown, this, &SysTrayXLink::slotShutdown );
connect( reader, &SysTrayXLinkReader::signalAddOnShutdown, this, &SysTrayXLink::slotAddOnShutdown );
connect( reader, &SysTrayXLinkReader::signalDebugMessage, this, &SysTrayXLink::slotDebugMessage );
@@ -320,7 +320,7 @@ void SysTrayXLink::DecodeMessage( const QByteArray& message )
if( jsonObject.contains( "shutdown" ) && jsonObject[ "shutdown" ].isString() )
{
emit signalShutdown();
emit signalAddOnShutdown();
}
if( jsonObject.contains( "window" ) && jsonObject[ "window" ].isString() )
@@ -465,9 +465,9 @@ void SysTrayXLink::slotReceivedData( QByteArray data )
/*
* Relay shutdown signal
*/
void SysTrayXLink::slotShutdown()
void SysTrayXLink::slotAddOnShutdown()
{
emit signalShutdown();
emit signalAddOnShutdown();
}

View File

@@ -86,9 +86,9 @@ class SysTrayXLinkReader : public QObject
void signalReceivedMessage( QByteArray message );
/**
* @brief signalShutdown. Signal to shutdown the app.
* @brief signalAddOnShutdown. Signal to shutdown the app.
*/
void signalShutdown();
void signalAddOnShutdown();
private:
@@ -173,9 +173,9 @@ class SysTrayXLink : public QObject
/**
* @brief signalShutdown. Signal to shutdown the app.
* @brief signalAddOnShutdown. Signal to shutdown the app.
*/
void signalShutdown();
void signalAddOnShutdown();
/**
* @brief signalWindowState. Signal a change in the window state.
@@ -283,9 +283,9 @@ class SysTrayXLink : public QObject
void slotLinkRead( QByteArray message );
/**
* @brief slotShutdown. Handle sahutdown signal from reader thread.
* @brief slotAddOnShutdown. Handle sahutdown signal from reader thread.
*/
void slotShutdown();
void slotAddOnShutdown();
private:

View File

@@ -45,7 +45,7 @@ void WindowCtrl::slotWindowTest1()
// Do something.
// findWindow( "- Mozilla Thunderbird" );
findWindow( "- Mozilla Thunderbird" );
displayWindowElements( "- Mozilla Thunderbird" );
// findWindow( 4313 );
@@ -61,12 +61,6 @@ void WindowCtrl::slotWindowTest2()
// Do something.
// foreach( quint64 win_id, getWinIds() )
// {
// closeWindow( (HWND)win_id );
// }
/*
* Disconnect container?
*/
@@ -203,3 +197,15 @@ void WindowCtrl::slotShowHide()
}
}
/*
* Handle close signal
*/
void WindowCtrl::slotClose()
{
foreach( quint64 win_id, getWinIds() )
{
deleteWindow( win_id );
}
}

View File

@@ -92,6 +92,11 @@ class WindowCtrl : public QObject
*/
void slotShowHide();
/**
* @brief slotClose.
*/
void slotClose();
private:
/**