Skip to content

Commit

Permalink
Workaround for mount plugin with a GLib-mounted encrypted volume
Browse files Browse the repository at this point in the history
`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
  • Loading branch information
tsujan committed May 6, 2024
1 parent 05f04fa commit b4d1141
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
9 changes: 6 additions & 3 deletions plugin-mount/menudiskitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Solid::StorageAccess>()->isAccessible() || !opticalParent().udi().isEmpty());
}
}

void MenuDiskItem::updateMountStatus()
Expand All @@ -96,7 +99,7 @@ void MenuDiskItem::updateMountStatus()
mDiskButton->setIcon(icon);
mDiskButton->setText(mDevice.description());

setMountStatus(mDevice.as<Solid::StorageAccess>()->isAccessible() || !opticalParent().udi().isEmpty());
setMountStatus();
}
else
emit invalid(mDevice.udi());
Expand Down
2 changes: 1 addition & 1 deletion plugin-mount/menudiskitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class MenuDiskItem : public QFrame
~MenuDiskItem();

QString deviceUdi() const { return mDevice.udi(); }
void setMountStatus(bool mounted);
void setMountStatus();

private:
void updateMountStatus();
Expand Down
14 changes: 14 additions & 0 deletions plugin-mount/popup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<MenuDiskItem *>(w))
{
it->setMountStatus();
}
}

mPlaceholder->setVisible(mDisplayCount == 0);
realign();
setFocus();
Expand Down

0 comments on commit b4d1141

Please sign in to comment.