Fixed that sidebar was not selected after the disk was mounted
This commit is contained in:
parent
04a6e5028c
commit
145ae607b5
2 changed files with 10 additions and 6 deletions
|
@ -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
|
||||
{
|
||||
return m_url.toString(QUrl::PreferLocalFile);
|
||||
if (m_url.isValid())
|
||||
return m_url.toString(QUrl::PreferLocalFile);
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString PlacesItem::udi() const
|
||||
|
|
|
@ -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]() {
|
||||
emit deviceSetupDone(access->filePath());
|
||||
connect(access, &Solid::StorageAccess::setupDone, this, [this, item, access]() {
|
||||
if (item) {
|
||||
// 更新信息,让 qml 里的 sidebar 识别到
|
||||
item->setUrl(QUrl::fromLocalFile(access->filePath()));
|
||||
emit deviceSetupDone(access->filePath());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue