Fixed that sidebar was not selected after the disk was mounted

This commit is contained in:
cutefishd 2021-04-19 04:44:03 +08:00
parent 04a6e5028c
commit 145ae607b5
2 changed files with 10 additions and 6 deletions

View file

@ -62,9 +62,6 @@ void PlacesItem::setIconPath(const QString &path)
QUrl PlacesItem::url() const
{
if (m_access)
return QUrl::fromLocalFile(m_access->filePath());
return m_url;
}
@ -75,7 +72,10 @@ void PlacesItem::setUrl(const QUrl &url)
QString PlacesItem::path() const
{
if (m_url.isValid())
return m_url.toString(QUrl::PreferLocalFile);
return QString();
}
QString PlacesItem::udi() const

View file

@ -220,8 +220,12 @@ void PlacesModel::requestSetup(const int &index)
Solid::Device device = Solid::Device(item->udi());
Solid::StorageAccess *access = device.as<Solid::StorageAccess>();
access->setup();
connect(access, &Solid::StorageAccess::setupDone, this, [this, access]() {
connect(access, &Solid::StorageAccess::setupDone, this, [this, item, access]() {
if (item) {
// 更新信息,让 qml 里的 sidebar 识别到
item->setUrl(QUrl::fromLocalFile(access->filePath()));
emit deviceSetupDone(access->filePath());
}
});
}
}