Skip to content

Commit b4d1141

Browse files
committed
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 #1639
1 parent 05f04fa commit b4d1141

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

plugin-mount/menudiskitem.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,12 @@ MenuDiskItem::MenuDiskItem(Solid::Device device, Popup *popup):
8080

8181
MenuDiskItem::~MenuDiskItem() = default;
8282

83-
void MenuDiskItem::setMountStatus(bool mounted)
83+
void MenuDiskItem::setMountStatus()
8484
{
85-
mEjectButton->setEnabled(mounted);
85+
if (mDevice.isValid())
86+
{
87+
mEjectButton->setEnabled(mDevice.as<Solid::StorageAccess>()->isAccessible() || !opticalParent().udi().isEmpty());
88+
}
8689
}
8790

8891
void MenuDiskItem::updateMountStatus()
@@ -96,7 +99,7 @@ void MenuDiskItem::updateMountStatus()
9699
mDiskButton->setIcon(icon);
97100
mDiskButton->setText(mDevice.description());
98101

99-
setMountStatus(mDevice.as<Solid::StorageAccess>()->isAccessible() || !opticalParent().udi().isEmpty());
102+
setMountStatus();
100103
}
101104
else
102105
emit invalid(mDevice.udi());

plugin-mount/menudiskitem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class MenuDiskItem : public QFrame
4444
~MenuDiskItem();
4545

4646
QString deviceUdi() const { return mDevice.udi(); }
47-
void setMountStatus(bool mounted);
47+
void setMountStatus();
4848

4949
private:
5050
void updateMountStatus();

plugin-mount/popup.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,20 @@ void Popup::onDeviceRemoved(QString const & udi)
137137

138138
void Popup::showEvent(QShowEvent *event)
139139
{
140+
// NOTE: This is a workaround for the lack of "Solid::StorageAccess::accessibilityChanged"
141+
// when an encrypted volume is mounted by GLib/GIO.
142+
const int size = layout()->count() - 1;
143+
for (int i = size; 0 <= i; --i)
144+
{
145+
QWidget *w = layout()->itemAt(i)->widget();
146+
if (w == mPlaceholder)
147+
continue;
148+
if (MenuDiskItem *it = static_cast<MenuDiskItem *>(w))
149+
{
150+
it->setMountStatus();
151+
}
152+
}
153+
140154
mPlaceholder->setVisible(mDisplayCount == 0);
141155
realign();
142156
setFocus();

0 commit comments

Comments
 (0)