Add shutdown command

This commit is contained in:
Ximi1970
2020-01-24 23:03:18 +01:00
parent cb1f0d2920
commit 4392b1fcc9
5 changed files with 74 additions and 34 deletions

View File

@@ -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();
}

View File

@@ -77,6 +77,11 @@ class SysTrayX : public QObject
private slots:
/**
* @brief slotShutdown Shutdown the app.
*/
void slotShutdown();
private:
/**

View File

@@ -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();

View File

@@ -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:
/**

View File

@@ -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: ""
});
},
//