summaryrefslogtreecommitdiffstats
path: root/kcontrol
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2023-02-04 12:19:24 +0900
committerMichele Calgaro <[email protected]>2023-02-06 17:58:43 +0900
commit8410f6bd00068b31a221e24ee619404ce8b6343a (patch)
tree73e90f16fbe3aa35137bbe4dadc957d8b20f8c3e /kcontrol
parentba7c5fa56a12b4105ca2f6cb958d3358e00f7f31 (diff)
downloadtdebase-8410f6bd00068b31a221e24ee619404ce8b6343a.tar.gz
tdebase-8410f6bd00068b31a221e24ee619404ce8b6343a.zip
hwmanager: remove current LMB menu. Rearrange code of RMB menu. Use MMB click to
show the Device Manager dialog directly. Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'kcontrol')
-rw-r--r--kcontrol/hwmanager/hwdevicetray.cpp80
-rw-r--r--kcontrol/hwmanager/hwdevicetray.h10
2 files changed, 49 insertions, 41 deletions
diff --git a/kcontrol/hwmanager/hwdevicetray.cpp b/kcontrol/hwmanager/hwdevicetray.cpp
index 509fe2835..615030589 100644
--- a/kcontrol/hwmanager/hwdevicetray.cpp
+++ b/kcontrol/hwmanager/hwdevicetray.cpp
@@ -1,8 +1,8 @@
/*
* Copyright 2015 Timothy Pearson <[email protected]>
- *
+ *
* This file is part of hwdevicetray, the TDE Hardware Device Monitor System Tray Application
- *
+ *
* hwdevicetray is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3
@@ -55,7 +55,7 @@
#include "hwdevicetray.h"
HwDeviceSystemTray::HwDeviceSystemTray(TQWidget* parent, const char *name)
- : KSystemTray(parent, name)
+ : KSystemTray(parent, name), m_RMBMenu(contextMenu())
{
// Create notifier
m_hardwareNotifierContainer = new TDEPassivePopupStackContainer();
@@ -142,16 +142,27 @@ void HwDeviceSystemTray::showEvent (TQShowEvent *) {
resizeTrayIcon();
}
-void HwDeviceSystemTray::mousePressEvent(TQMouseEvent* e) {
- // Popup the context menu with left-click
- if (e->button() == Qt::LeftButton) {
- contextMenuAboutToShow(contextMenu());
- contextMenu()->popup(e->globalPos());
- e->accept();
- return;
- }
+void HwDeviceSystemTray::mousePressEvent(TQMouseEvent* e)
+{
+ switch (e->button())
+ {
+ case Qt::LeftButton:
- KSystemTray::mousePressEvent(e);
+ break;
+
+ case Qt::MidButton:
+ TQTimer::singleShot(0, this, TQT_SLOT(slotHardwareConfig()));
+ break;
+
+ case Qt::RightButton:
+ contextMenuAboutToShow(m_RMBMenu);
+ m_RMBMenu->popup(e->globalPos());
+ break;
+
+ default:
+ // do nothing
+ break;
+ }
}
bool HwDeviceSystemTray::isMonitoredDevice(TDEStorageDevice* sdevice)
@@ -195,33 +206,17 @@ bool HwDeviceSystemTray::isMonitoredDevice(TDEStorageDevice* sdevice)
sdevice->isDiskOfType(TDEDiskDeviceType::Camera)));
}
-void HwDeviceSystemTray::contextMenuAboutToShow(TDEPopupMenu* menu) {
- menu->clear();
- menu->setCheckable(true);
-
- populateMenu(menu);
-
- menu->insertTitle(SmallIcon("configure"), i18n("Global Configuration"));
-
- TDEAction *actHardwareConfig = new TDEAction(i18n("Show Device Manager..."), SmallIconSet("kcmpci"), TDEShortcut(), TQT_TQOBJECT(this), TQT_SLOT(slotHardwareConfig()), actionCollection());
- actHardwareConfig->plug(menu);
-
- TDEAction *actShortcutKeys = new TDEAction(i18n("Configure Shortcut Keys..."), SmallIconSet("configure"), TDEShortcut(), TQT_TQOBJECT(this), TQT_SLOT(slotEditShortcutKeys()), actionCollection());
- actShortcutKeys->plug(menu);
-
- menu->insertItem(SmallIcon("help"), KStdGuiItem::help().text(), m_help->menu());
- TDEAction *quitAction = actionCollection()->action(KStdAction::name(KStdAction::Quit));
- quitAction->plug(menu);
-
- m_menu = menu;
-}
-
void HwDeviceSystemTray::configChanged() {
//
}
-void HwDeviceSystemTray::populateMenu(TDEPopupMenu* menu) {
- menu->insertTitle(SmallIcon("drive-harddisk-unmounted"), i18n("Storage Devices"));
+void HwDeviceSystemTray::contextMenuAboutToShow(TDEPopupMenu *menu)
+{
+ menu->clear();
+ menu->setCheckable(true);
+
+ // Device actions
+ menu->insertTitle(SmallIcon("drive-harddisk-unmounted"), i18n("Storage Device Actions"));
TDEActionMenu *openDeviceActionMenu = static_cast<TDEActionMenu*>(actionCollection()->action("open_menu"));
TDEActionMenu *mountDeviceActionMenu = static_cast<TDEActionMenu*>(actionCollection()->action("mount_menu"));
@@ -409,6 +404,21 @@ void HwDeviceSystemTray::populateMenu(TDEPopupMenu* menu) {
{
propertiesDeviceActionMenu->plug(menu);
}
+
+ // Global Configuration
+ menu->insertTitle(SmallIcon("configure"), i18n("Global Configuration"));
+
+ TDEAction *actHardwareConfig = new TDEAction(i18n("Show Device Manager..."), SmallIconSet("kcmpci"), TDEShortcut(), this, TQT_SLOT(slotHardwareConfig()), actionCollection());
+ actHardwareConfig->plug(menu);
+
+ TDEAction *actShortcutKeys = new TDEAction(i18n("Configure Shortcut Keys..."), SmallIconSet("configure"), TDEShortcut(), this, TQT_SLOT(slotEditShortcutKeys()), actionCollection());
+ actShortcutKeys->plug(menu);
+
+ // Help & Quit
+ menu->insertSeparator();
+ menu->insertItem(SmallIcon("help"), KStdGuiItem::help().text(), m_help->menu());
+ TDEAction *quitAction = actionCollection()->action(KStdAction::name(KStdAction::Quit));
+ quitAction->plug(menu);
}
void HwDeviceSystemTray::slotOpenDevice(int parameter)
diff --git a/kcontrol/hwmanager/hwdevicetray.h b/kcontrol/hwmanager/hwdevicetray.h
index c0465f2bf..54382cb8c 100644
--- a/kcontrol/hwmanager/hwdevicetray.h
+++ b/kcontrol/hwmanager/hwdevicetray.h
@@ -1,8 +1,8 @@
/*
* Copyright 2015 Timothy Pearson <[email protected]>
- *
+ *
* This file is part of hwdevicetray, the TDE Hardware Device Monitor System Tray Application
- *
+ *
* hwdevicetray is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3
@@ -45,7 +45,7 @@ public:
~HwDeviceSystemTray();
TDEGlobalAccel *globalKeys;
- virtual void contextMenuAboutToShow(TDEPopupMenu* menu);
+ virtual void contextMenuAboutToShow(TDEPopupMenu *menu);
void configChanged();
@@ -80,8 +80,6 @@ private slots:
private:
static bool isMonitoredDevice(TDEStorageDevice *sdevice);
-private:
- void populateMenu(TDEPopupMenu* menu);
void resizeTrayIcon();
bool m_popupUp;
@@ -98,7 +96,7 @@ private:
TQStringMap m_ejectMenuIndexMap;
TQStringMap m_safeRemoveMenuIndexMap;
TQStringMap m_propertiesMenuIndexMap;
- TDEPopupMenu* m_menu;
+ TDEPopupMenu* m_RMBMenu;
KSimpleConfig *r_config;
struct KnownDiskDeviceInfo