show an error message box if no accessible devices are found on program launch

svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1250081
This commit is contained in:
Volker Lanz 2011-08-29 10:51:42 +00:00
parent 3cdd18fae5
commit b4d02bda27
3 changed files with 19 additions and 2 deletions

View File

@ -51,6 +51,9 @@ int main(int argc, char* argv[])
if (!loadBackend())
return 0;
if (!checkAccessibleDevices())
return 0;
MainWindow* mainWindow = new MainWindow();
mainWindow->show();

View File

@ -203,6 +203,20 @@ bool loadBackend()
return true;
}
bool checkAccessibleDevices()
{
if (getSolidDeviceList().empty())
{
KMessageBox::error(NULL,
i18nc("@info", "<para>No usable devices could be found.</para><para>Make sure you have sufficient "
"privileges to access block devices on your system.</para>"),
i18nc("@title:window", "Error: No Usable Devices Found"));
return false;
}
return true;
}
QList<Solid::Device> getSolidDeviceList()
{
QString predicate = "StorageDrive.driveType == 'HardDisk'";
@ -229,7 +243,5 @@ QList<Solid::Device> getSolidDeviceList()
predicate += ']';
}
kDebug() << predicate;
return Solid::Device::listFromQuery(predicate);
}

View File

@ -52,4 +52,6 @@ LIBPARTITIONMANAGERPRIVATE_EXPORT bool loadBackend();
LIBPARTITIONMANAGERPRIVATE_EXPORT QList<Solid::Device> getSolidDeviceList();
LIBPARTITIONMANAGERPRIVATE_EXPORT bool checkAccessibleDevices();
#endif