diff options
author | Slávek Banko <slavek.banko@axis.cz> | 2021-08-15 18:01:36 +0200 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2021-08-15 18:02:52 +0200 |
commit | 8665255c0c7ce0808fac7cd3834acac1cbbfc7a1 (patch) | |
tree | b4122a4fad1c3a02a2163557fb6735b086ad50ec | |
parent | bb2ea2317532d39688d93cc0bd404436d53d0973 (diff) | |
download | tdebase-8665255c0c7ce0808fac7cd3834acac1cbbfc7a1.tar.gz tdebase-8665255c0c7ce0808fac7cd3834acac1cbbfc7a1.zip |
hwdevicetray: Use the disk label for menu items, if available.
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
-rw-r--r-- | kcontrol/hwmanager/hwdevicetray.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/kcontrol/hwmanager/hwdevicetray.cpp b/kcontrol/hwmanager/hwdevicetray.cpp index c4089874a..354991699 100644 --- a/kcontrol/hwmanager/hwdevicetray.cpp +++ b/kcontrol/hwmanager/hwdevicetray.cpp @@ -269,12 +269,18 @@ void HwDeviceSystemTray::populateMenu(TDEPopupMenu* menu) { TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(hwdevice); if (isMonitoredDevice(sdevice)) { + TQString friendlyName = sdevice->diskLabel(); + if (friendlyName.isEmpty()) + { + friendlyName = sdevice->friendlyName(); + } + if (sdevice->isDiskOfType(TDEDiskDeviceType::LUKS) || sdevice->isDiskOfType(TDEDiskDeviceType::OtherCrypted)) { if (sdevice->isDiskOfType(TDEDiskDeviceType::UnlockedCrypt)) { lastLockIndex = lockDeviceActionMenu->popupMenu()->insertItem(hwdevice->icon(TDEIcon::SizeSmall), - i18n("%1 (%2)").arg(sdevice->friendlyName(), sdevice->deviceNode())); + i18n("%1 (%2)").arg(friendlyName, sdevice->deviceNode())); lockDeviceActionMenu->popupMenu()->connectItem(lastLockIndex, this, TQT_SLOT(slotLockDevice(int))); m_lockMenuIndexMap[lastLockIndex] = sdevice->diskUUID(); if (m_lockMenuIndexMap[lastLockIndex] == "") @@ -285,7 +291,7 @@ void HwDeviceSystemTray::populateMenu(TDEPopupMenu* menu) { else { lastUnlockIndex = unlockDeviceActionMenu->popupMenu()->insertItem(hwdevice->icon(TDEIcon::SizeSmall), - i18n("%1 (%2)").arg(sdevice->friendlyName(), sdevice->deviceNode())); + i18n("%1 (%2)").arg(friendlyName, sdevice->deviceNode())); unlockDeviceActionMenu->popupMenu()->connectItem(lastUnlockIndex, this, TQT_SLOT(slotUnlockDevice(int))); m_unlockMenuIndexMap[lastUnlockIndex] = sdevice->diskUUID(); if (m_unlockMenuIndexMap[lastUnlockIndex] == "") @@ -300,7 +306,7 @@ void HwDeviceSystemTray::populateMenu(TDEPopupMenu* menu) { if (sdevice->mountPath().isEmpty()) { lastMountIndex = mountDeviceActionMenu->popupMenu()->insertItem(hwdevice->icon(TDEIcon::SizeSmall), - i18n("%1 (%2)").arg(sdevice->friendlyName(), sdevice->deviceNode())); + i18n("%1 (%2)").arg(friendlyName, sdevice->deviceNode())); mountDeviceActionMenu->popupMenu()->connectItem(lastMountIndex, this, TQT_SLOT(slotMountDevice(int))); m_mountMenuIndexMap[lastMountIndex] = sdevice->diskUUID(); if (m_mountMenuIndexMap[lastMountIndex] == "") @@ -311,7 +317,7 @@ void HwDeviceSystemTray::populateMenu(TDEPopupMenu* menu) { else { lastUnmountIndex = unmountDeviceActionMenu->popupMenu()->insertItem(hwdevice->icon(TDEIcon::SizeSmall), - i18n("%1 (%2)").arg(sdevice->friendlyName(), sdevice->deviceNode())); + i18n("%1 (%2)").arg(friendlyName, sdevice->deviceNode())); unmountDeviceActionMenu->popupMenu()->connectItem(lastUnmountIndex, this, TQT_SLOT(slotUnmountDevice(int))); m_unmountMenuIndexMap[lastUnmountIndex] = sdevice->diskUUID(); if (m_unmountMenuIndexMap[lastMountIndex] == "") @@ -322,7 +328,7 @@ void HwDeviceSystemTray::populateMenu(TDEPopupMenu* menu) { // Both mounted and unmounted disks can be opened lastOpenIndex = openDeviceActionMenu->popupMenu()->insertItem(hwdevice->icon(TDEIcon::SizeSmall), - i18n("%1 (%2)").arg(sdevice->friendlyName(), sdevice->deviceNode())); + i18n("%1 (%2)").arg(friendlyName, sdevice->deviceNode())); openDeviceActionMenu->popupMenu()->connectItem(lastOpenIndex, this, TQT_SLOT(slotOpenDevice(int))); m_openMenuIndexMap[lastOpenIndex] = sdevice->diskUUID(); if (m_openMenuIndexMap[lastOpenIndex] == "") @@ -335,7 +341,7 @@ void HwDeviceSystemTray::populateMenu(TDEPopupMenu* menu) { sdevice->checkDiskStatus(TDEDiskDeviceStatus::Hotpluggable)) { lastEjectIndex = ejectDeviceActionMenu->popupMenu()->insertItem(hwdevice->icon(TDEIcon::SizeSmall), - i18n("%1 (%2)").arg(sdevice->friendlyName(), sdevice->deviceNode())); + i18n("%1 (%2)").arg(friendlyName, sdevice->deviceNode())); ejectDeviceActionMenu->popupMenu()->connectItem(lastEjectIndex, this, TQT_SLOT(slotEjectDevice(int))); m_ejectMenuIndexMap[lastEjectIndex] = sdevice->diskUUID(); if (m_ejectMenuIndexMap[lastEjectIndex] == "") @@ -345,7 +351,7 @@ void HwDeviceSystemTray::populateMenu(TDEPopupMenu* menu) { } lastPropertiesIndex = propertiesDeviceActionMenu->popupMenu()->insertItem(hwdevice->icon(TDEIcon::SizeSmall), - i18n("%1 (%2)").arg(sdevice->friendlyName(), sdevice->deviceNode())); + i18n("%1 (%2)").arg(friendlyName, sdevice->deviceNode())); propertiesDeviceActionMenu->popupMenu()->connectItem(lastPropertiesIndex, this, TQT_SLOT(slotPropertiesDevice(int))); m_propertiesMenuIndexMap[lastPropertiesIndex] = sdevice->diskUUID(); if (m_propertiesMenuIndexMap[lastPropertiesIndex] == "") |