Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for mount plugin with a GLib-mounted encrypted volume #2060

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading