mirror of
https://github.com/Ximi1970/systray-x.git
synced 2025-10-26 00:36:07 +02:00
Add new menu item: new message
This commit is contained in:
@@ -243,6 +243,10 @@ void SysTrayX::createMenu()
|
||||
m_showhide_action->setIcon( QIcon( ":/files/icons/window-restore.png" ) );
|
||||
connect( m_showhide_action, &QAction::triggered, m_win_ctrl, &WindowCtrl::slotShowHide );
|
||||
|
||||
m_new_action = new QAction(tr("&New message..."), this);
|
||||
m_new_action->setIcon( QIcon( ":/files/icons/document-new.png" ) );
|
||||
connect( m_new_action, &QAction::triggered, this, &SysTrayX::slotNewMessage );
|
||||
|
||||
m_pref_action = new QAction(tr("&Preferences"), this);
|
||||
m_pref_action->setIcon( QIcon( ":/files/icons/gtk-preferences.png" ) );
|
||||
connect( m_pref_action, &QAction::triggered, m_pref_dialog, &PreferencesDialog::slotShowDialog );
|
||||
@@ -262,6 +266,8 @@ void SysTrayX::createMenu()
|
||||
|
||||
m_tray_icon_menu->addAction( m_showhide_action );
|
||||
m_tray_icon_menu->addSeparator();
|
||||
m_tray_icon_menu->addAction( m_new_action );
|
||||
m_tray_icon_menu->addSeparator();
|
||||
m_tray_icon_menu->addAction( m_pref_action );
|
||||
m_tray_icon_menu->addAction( m_about_action );
|
||||
m_tray_icon_menu->addSeparator();
|
||||
@@ -784,6 +790,10 @@ void SysTrayX::slotCloseApp()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Handle a show / hide shortcut change
|
||||
*/
|
||||
void SysTrayX::slotShowHideShortcutChange()
|
||||
{
|
||||
if( m_show_hide_shortcut != nullptr )
|
||||
@@ -797,3 +807,12 @@ void SysTrayX::slotShowHideShortcutChange()
|
||||
m_show_hide_shortcut = new Shortcut( m_preferences->getShowHideShortcut(), this );
|
||||
connect( m_show_hide_shortcut, &Shortcut::activated, m_win_ctrl, &WindowCtrl::slotShowHide );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Handle a new message request
|
||||
*/
|
||||
void SysTrayX::slotNewMessage()
|
||||
{
|
||||
m_link->sendNewMessage();
|
||||
}
|
||||
|
||||
@@ -193,6 +193,11 @@ class SysTrayX : public QObject
|
||||
*/
|
||||
void slotShowHideShortcutChange();
|
||||
|
||||
/**
|
||||
* @brief slotNewMessage. Handle a new message request.
|
||||
*/
|
||||
void slotNewMessage();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
@@ -239,6 +244,7 @@ class SysTrayX : public QObject
|
||||
* @brief m_xxxx_action. Pointer to the menu actions.
|
||||
*/
|
||||
QAction* m_showhide_action;
|
||||
QAction* m_new_action;
|
||||
QAction* m_pref_action;
|
||||
QAction* m_about_action;
|
||||
QAction* m_quit_action;
|
||||
|
||||
@@ -301,6 +301,26 @@ void SysTrayXLink::sendPositions( QList< QPoint > positions )
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Send a new message request.
|
||||
*/
|
||||
void SysTrayXLink::sendNewMessage()
|
||||
{
|
||||
QJsonObject newMessageObject;
|
||||
newMessageObject.insert("newMessage", QJsonValue::fromVariant( "true" ) );
|
||||
|
||||
/*
|
||||
* Store the new document
|
||||
*/
|
||||
QJsonDocument json_doc = QJsonDocument( newMessageObject );
|
||||
|
||||
/*
|
||||
* Send it to the add-on
|
||||
*/
|
||||
linkWrite( json_doc.toJson( QJsonDocument::Compact ) );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Decode JSON message
|
||||
*/
|
||||
|
||||
@@ -121,12 +121,17 @@ class SysTrayXLink : public QObject
|
||||
void sendOptions();
|
||||
|
||||
/**
|
||||
* @brief sendPositions
|
||||
* @brief sendPositions. Send the positions of the TB windows.
|
||||
*
|
||||
* @param positions List of the positions of the TB windows
|
||||
*/
|
||||
void sendPositions( QList< QPoint > positions );
|
||||
|
||||
/**
|
||||
* @brief sendNewMessage. Send a new message request.
|
||||
*/
|
||||
void sendNewMessage();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user