diff --git a/src/main.cpp b/src/main.cpp index 8534c8c..87d069a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -51,6 +51,9 @@ int main(int argc, char* argv[]) if (!loadBackend()) return 0; + if (!checkAccessibleDevices()) + return 0; + MainWindow* mainWindow = new MainWindow(); mainWindow->show(); diff --git a/src/util/helpers.cpp b/src/util/helpers.cpp index aa3f2c0..cb61cdb 100644 --- a/src/util/helpers.cpp +++ b/src/util/helpers.cpp @@ -203,6 +203,20 @@ bool loadBackend() return true; } +bool checkAccessibleDevices() +{ + if (getSolidDeviceList().empty()) + { + KMessageBox::error(NULL, + i18nc("@info", "No usable devices could be found.Make sure you have sufficient " + "privileges to access block devices on your system."), + i18nc("@title:window", "Error: No Usable Devices Found")); + return false; + } + + return true; +} + QList getSolidDeviceList() { QString predicate = "StorageDrive.driveType == 'HardDisk'"; @@ -229,7 +243,5 @@ QList getSolidDeviceList() predicate += ']'; } - kDebug() << predicate; - return Solid::Device::listFromQuery(predicate); } diff --git a/src/util/helpers.h b/src/util/helpers.h index 03a0d8f..f5698ed 100644 --- a/src/util/helpers.h +++ b/src/util/helpers.h @@ -52,4 +52,6 @@ LIBPARTITIONMANAGERPRIVATE_EXPORT bool loadBackend(); LIBPARTITIONMANAGERPRIVATE_EXPORT QList getSolidDeviceList(); +LIBPARTITIONMANAGERPRIVATE_EXPORT bool checkAccessibleDevices(); + #endif