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 <michele.calgaro@yahoo.it>
pull/308/head
Michele Calgaro 1 year ago
parent ba7c5fa56a
commit 8410f6bd00
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -1,8 +1,8 @@
/*
* Copyright 2015 Timothy Pearson <kb9vqf@pearsoncomputing.net>
*
*
* 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)

@ -1,8 +1,8 @@
/*
* Copyright 2015 Timothy Pearson <kb9vqf@pearsoncomputing.net>
*
*
* 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

Loading…
Cancel
Save