From ce2a66656fe153b8a6b01bd574e77ebc1dd3e071 Mon Sep 17 00:00:00 2001 From: pjx206 Date: Thu, 15 Apr 2021 11:01:48 +0800 Subject: [PATCH] Fix device open Now we do not have to click twice to open a external disk. --- model/placesmodel.cpp | 3 +++ model/placesmodel.h | 3 +++ qml/SideBar.qml | 1 + 3 files changed, 7 insertions(+) diff --git a/model/placesmodel.cpp b/model/placesmodel.cpp index 0b8834c..3956155 100644 --- a/model/placesmodel.cpp +++ b/model/placesmodel.cpp @@ -220,6 +220,9 @@ void PlacesModel::requestSetup(const int &index) Solid::Device device = Solid::Device(item->udi()); Solid::StorageAccess *access = device.as(); access->setup(); + connect(access, &Solid::StorageAccess::setupDone, this, [this, access]() { + emit deviceSetupDone(access->filePath()); + }); } } diff --git a/model/placesmodel.h b/model/placesmodel.h index a372908..fbeb4d3 100644 --- a/model/placesmodel.h +++ b/model/placesmodel.h @@ -56,6 +56,9 @@ public: Q_INVOKABLE void requestSetup(const int &index); Q_INVOKABLE void requestEject(const int &index); +signals: + void deviceSetupDone(const QString &filePath); + private slots: void onDeviceAdded(const QString &udi); void onDeviceRemoved(const QString &udi); diff --git a/qml/SideBar.qml b/qml/SideBar.qml index 70dafa8..01bc174 100644 --- a/qml/SideBar.qml +++ b/qml/SideBar.qml @@ -13,6 +13,7 @@ ListView { PlacesModel { id: placesModel + onDeviceSetupDone: sideBar.clicked(filePath) // 设备挂载上后,模拟点击了该设备以打开该页面 } model: placesModel