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