From b4d11415097186cd0dc8720893c8017d57e1d62a Mon Sep 17 00:00:00 2001 From: Tsu Jan Date: Mon, 6 May 2024 16:59:57 +0330 Subject: [PATCH] Workaround for mount plugin with a GLib-mounted encrypted volume `Solid::StorageAccess::accessibilityChanged` isn't emitted when an encrypted volume is mounted by GLib/GIO (e.g., through pcmanfm-qt). This is a workaround. Closes https://github.com/lxqt/lxqt-panel/issues/1639 --- plugin-mount/menudiskitem.cpp | 9 ++++++--- plugin-mount/menudiskitem.h | 2 +- plugin-mount/popup.cpp | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/plugin-mount/menudiskitem.cpp b/plugin-mount/menudiskitem.cpp index 3f4af34ab..4b8f02ab4 100644 --- a/plugin-mount/menudiskitem.cpp +++ b/plugin-mount/menudiskitem.cpp @@ -80,9 +80,12 @@ MenuDiskItem::MenuDiskItem(Solid::Device device, Popup *popup): MenuDiskItem::~MenuDiskItem() = default; -void MenuDiskItem::setMountStatus(bool mounted) +void MenuDiskItem::setMountStatus() { - mEjectButton->setEnabled(mounted); + if (mDevice.isValid()) + { + mEjectButton->setEnabled(mDevice.as()->isAccessible() || !opticalParent().udi().isEmpty()); + } } void MenuDiskItem::updateMountStatus() @@ -96,7 +99,7 @@ void MenuDiskItem::updateMountStatus() mDiskButton->setIcon(icon); mDiskButton->setText(mDevice.description()); - setMountStatus(mDevice.as()->isAccessible() || !opticalParent().udi().isEmpty()); + setMountStatus(); } else emit invalid(mDevice.udi()); diff --git a/plugin-mount/menudiskitem.h b/plugin-mount/menudiskitem.h index 52ffa3405..e9be3b582 100644 --- a/plugin-mount/menudiskitem.h +++ b/plugin-mount/menudiskitem.h @@ -44,7 +44,7 @@ class MenuDiskItem : public QFrame ~MenuDiskItem(); QString deviceUdi() const { return mDevice.udi(); } - void setMountStatus(bool mounted); + void setMountStatus(); private: void updateMountStatus(); diff --git a/plugin-mount/popup.cpp b/plugin-mount/popup.cpp index 20720266f..b6d40e27e 100644 --- a/plugin-mount/popup.cpp +++ b/plugin-mount/popup.cpp @@ -137,6 +137,20 @@ void Popup::onDeviceRemoved(QString const & udi) void Popup::showEvent(QShowEvent *event) { + // NOTE: This is a workaround for the lack of "Solid::StorageAccess::accessibilityChanged" + // when an encrypted volume is mounted by GLib/GIO. + const int size = layout()->count() - 1; + for (int i = size; 0 <= i; --i) + { + QWidget *w = layout()->itemAt(i)->widget(); + if (w == mPlaceholder) + continue; + if (MenuDiskItem *it = static_cast(w)) + { + it->setMountStatus(); + } + } + mPlaceholder->setVisible(mDisplayCount == 0); realign(); setFocus();