Fix device open

Now we do not have to click twice to open a external disk.
This commit is contained in:
pjx206 2021-04-15 11:01:48 +08:00
parent 845c0b40f0
commit ce2a66656f
3 changed files with 7 additions and 0 deletions

View file

@ -220,6 +220,9 @@ void PlacesModel::requestSetup(const int &index)
Solid::Device device = Solid::Device(item->udi()); Solid::Device device = Solid::Device(item->udi());
Solid::StorageAccess *access = device.as<Solid::StorageAccess>(); Solid::StorageAccess *access = device.as<Solid::StorageAccess>();
access->setup(); access->setup();
connect(access, &Solid::StorageAccess::setupDone, this, [this, access]() {
emit deviceSetupDone(access->filePath());
});
} }
} }

View file

@ -56,6 +56,9 @@ public:
Q_INVOKABLE void requestSetup(const int &index); Q_INVOKABLE void requestSetup(const int &index);
Q_INVOKABLE void requestEject(const int &index); Q_INVOKABLE void requestEject(const int &index);
signals:
void deviceSetupDone(const QString &filePath);
private slots: private slots:
void onDeviceAdded(const QString &udi); void onDeviceAdded(const QString &udi);
void onDeviceRemoved(const QString &udi); void onDeviceRemoved(const QString &udi);

View file

@ -13,6 +13,7 @@ ListView {
PlacesModel { PlacesModel {
id: placesModel id: placesModel
onDeviceSetupDone: sideBar.clicked(filePath) //
} }
model: placesModel model: placesModel