mirror of
https://github.com/Ximi1970/systray-x.git
synced 2026-07-04 14:38:49 +02:00
Add shutdown command
This commit is contained in:
@@ -94,6 +94,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 );
|
||||
|
||||
/*
|
||||
* Request preferences from add-on
|
||||
@@ -191,3 +192,15 @@ void SysTrayX::createTrayIcon()
|
||||
m_tray_icon->setIconData( m_preferences->getIconData() );
|
||||
m_tray_icon->setIconType( m_preferences->getIconType() );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Quit the app
|
||||
*/
|
||||
void SysTrayX::slotShutdown()
|
||||
{
|
||||
/*
|
||||
* Let's quit
|
||||
*/
|
||||
QCoreApplication::quit();
|
||||
}
|
||||
|
||||
@@ -77,6 +77,11 @@ class SysTrayX : public QObject
|
||||
|
||||
private slots:
|
||||
|
||||
/**
|
||||
* @brief slotShutdown Shutdown the app.
|
||||
*/
|
||||
void slotShutdown();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
|
||||
@@ -141,6 +141,11 @@ void SysTrayXLink::DecodeMessage( const QByteArray& message )
|
||||
{
|
||||
QJsonObject jsonObject = jsonResponse.object();
|
||||
|
||||
if( jsonObject.contains( "shutdown" ) && jsonObject[ "shutdown" ].isString() )
|
||||
{
|
||||
emit signalShutdown();
|
||||
}
|
||||
|
||||
if( jsonObject.contains( "unreadMail" ) && jsonObject[ "unreadMail" ].isDouble() )
|
||||
{
|
||||
int unreadMail = jsonObject[ "unreadMail" ].toInt();
|
||||
|
||||
@@ -68,42 +68,13 @@ class SysTrayXLink : public QObject
|
||||
*/
|
||||
void EncodePreferences( const Preferences& pref );
|
||||
|
||||
public slots:
|
||||
|
||||
/**
|
||||
* @brief slotDebugChange. Handle a change in debug state.
|
||||
*/
|
||||
void slotDebugChange();
|
||||
|
||||
/**
|
||||
* @brief slotLinkWrite. Write the link.
|
||||
*/
|
||||
void slotLinkWrite( QByteArray message );
|
||||
|
||||
/**
|
||||
* @brief slotIconTypeChange. Slot for handling icon type change signals.
|
||||
*/
|
||||
void slotIconTypeChange();
|
||||
|
||||
/**
|
||||
* @brief slotIconDataChange. Slot for handling icon data change signals.
|
||||
*/
|
||||
void slotIconDataChange();
|
||||
|
||||
private slots:
|
||||
|
||||
/**
|
||||
* @brief slotLinkRead. Read the link.
|
||||
*/
|
||||
void slotLinkRead();
|
||||
|
||||
/**
|
||||
* @brief slotLinkReadException. Handle a read link exception.
|
||||
*/
|
||||
void slotLinkReadException();
|
||||
|
||||
signals:
|
||||
|
||||
/**
|
||||
* @brief signalShutdown. Signal to shutdown the app.
|
||||
*/
|
||||
void signalShutdown();
|
||||
|
||||
/**
|
||||
* @brief signalReceivedMessageLength
|
||||
*
|
||||
@@ -139,6 +110,40 @@ class SysTrayXLink : public QObject
|
||||
*/
|
||||
void signalUnreadMail( int unread_mail );
|
||||
|
||||
public slots:
|
||||
|
||||
/**
|
||||
* @brief slotDebugChange. Handle a change in debug state.
|
||||
*/
|
||||
void slotDebugChange();
|
||||
|
||||
/**
|
||||
* @brief slotLinkWrite. Write the link.
|
||||
*/
|
||||
void slotLinkWrite( QByteArray message );
|
||||
|
||||
/**
|
||||
* @brief slotIconTypeChange. Slot for handling icon type change signals.
|
||||
*/
|
||||
void slotIconTypeChange();
|
||||
|
||||
/**
|
||||
* @brief slotIconDataChange. Slot for handling icon data change signals.
|
||||
*/
|
||||
void slotIconDataChange();
|
||||
|
||||
private slots:
|
||||
|
||||
/**
|
||||
* @brief slotLinkRead. Read the link.
|
||||
*/
|
||||
void slotLinkRead();
|
||||
|
||||
/**
|
||||
* @brief slotLinkReadException. Handle a read link exception.
|
||||
*/
|
||||
void slotLinkReadException();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,6 +22,18 @@ SysTrayX.Messaging = {
|
||||
|
||||
// this.unReadMessages(this.unreadFiltersTest).then(this.unreadCb);
|
||||
window.setInterval(SysTrayX.Messaging.pollAccounts, 10000);
|
||||
|
||||
// Semd the app a close command
|
||||
browser.windows.onRemoved.addListener(SysTrayX.Messaging.closeApp);
|
||||
},
|
||||
|
||||
closeApp: function() {
|
||||
console.debug("Shutting down");
|
||||
|
||||
// Send it to the app
|
||||
SysTrayX.Link.postSysTrayXMessage({
|
||||
shutdown: ""
|
||||
});
|
||||
},
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user