I'm developing an application, where I have a system tray icon. I'm trying to catch QSystemTrayIcon::DoubleClick
in the system tray. For some reason I do not understand, I have been unable to catch. In its stead, I just get two QSystemTrayIcon::Trigger
events. I have tried this using both Qt4 (v4.8.7
) and Qt5 (v5.5.1
). My platform is KDE/Plasma 5(v5.4.3
), on Debian Testing. I have tested this even on LXDE available on Debian Testing.
So my question here is: is this a bug in Qt or some other issue else where?
/* My Header File */
class MyTrayIcon : public QSystemTrayIcon {
Q_OBJECT
public :
NBTrayIcon();
public slots:
void handleActivation( QSystemTrayIcon::ActivationReason reason );
private slots:
void toggleVisible();
void showInfo();
void quit();
Q_SIGNALS:
void newWindow();
};
/* My Cpp File */
MyTrayIcon::MyTrayIcon() : QSystemTrayIcon() {
setIcon( QIcon( ":/icons/newbreeze.png" ) );
connect( this, SIGNAL( activated( QSystemTrayIcon::ActivationReason ) ), this, SLOT( handleActivation( QSystemTrayIcon::ActivationReason ) ) );
QMenu *menu = new QMenu( "TrayMenu" );
menu->addAction( "&Toggle Visible Windows", this, SLOT( toggleVisible() ) );
menu->addAction( QIcon::fromTheme( "application-exit", QIcon( ":/icons/delete.png" ) ), "&Quit NewBreeze", this, SLOT( quit() ) );
setContextMenu( menu );
};
void MyTrayIcon::handleActivation( QSystemTrayIcon::ActivationReason reason ) {
qDebug() << reason;
switch( reason ) {
case MyTrayIcon::Context: {
qDebug() << "Context";
break;
};
case MyTrayIcon::MiddleClick: {
qDebug() << "Middle Click";
break;
};
case MyTrayIcon::Trigger: {
qDebug() << "Trigger";
break;
}
case MyTrayIcon::DoubleClick: {
qDebug() << "DoubleClick";
break;
};
default:{
qDebug() << reason;
break;
};
};
};
PS: I have added the code as listed above.