summaryrefslogtreecommitdiffstats
path: root/rbutil/rbutilqt/configure.cpp
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2013-04-06 21:15:05 +0200
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2013-04-09 22:39:13 +0200
commite30b3d84e8d744098df13617fceed562bcdb8462 (patch)
tree707d86f86098b287de15e586dc4fb6d11f27127a /rbutil/rbutilqt/configure.cpp
parente6c0bd035046e6b97f408fcff14879a2fba6c9e6 (diff)
downloadrockbox-e30b3d84e8d744098df13617fceed562bcdb8462.tar.gz
rockbox-e30b3d84e8d744098df13617fceed562bcdb8462.tar.bz2
rockbox-e30b3d84e8d744098df13617fceed562bcdb8462.zip
Change autodetection result to a list.
Both autodetection functionality and the configuration dialog assumed detection to only return one found device. This isn't necessarily true, especially since some players can be detected but detecting their mountpoint might be ambiguous (only if no previous Rockbox installation is present). Instead of returning individual results (found "ok" player, found "error" player etc.) return a list containing an entry for each player. Current autodetection code will never return more than one entry since it doesn't handle multiple devices yet, and the configuration dialog will show an error if multiple devices are found. Thus there is no user visible change yet. Both autodetection and configuration dialog can now get extended to handle multiple devices. Change-Id: I79b763dbd6e7111783194bcc22ab7cc06a4061c1
Diffstat (limited to 'rbutil/rbutilqt/configure.cpp')
-rw-r--r--rbutil/rbutilqt/configure.cpp181
1 files changed, 100 insertions, 81 deletions
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp
index ccf3eea465..922dc19b7c 100644
--- a/rbutil/rbutilqt/configure.cpp
+++ b/rbutil/rbutilqt/configure.cpp
@@ -725,98 +725,117 @@ void Config::autodetect()
this->setCursor(Qt::WaitCursor);
QCoreApplication::processEvents();
- if(detector.detect()) //let it detect
+ detector.detect();
+ QList<struct Autodetection::Detected> detected;
+ detected = detector.detected();
+ this->unsetCursor();
+ if(detected.size() > 1) {
+ // FIXME: handle multiple found players.
+ QMessageBox::information(this, tr("Device Detection"),
+ tr("Multiple devices have been detected. Please disconnect "
+ "all players but one and try again."));
+ ui.treeDevices->setEnabled(true);
+ }
+ else if(detected.size() == 0) {
+ QMessageBox::warning(this, tr("Device Detection"),
+ tr("Could not detect a device.\n"
+ "Select your device and Mountpoint manually."),
+ QMessageBox::Ok ,QMessageBox::Ok);
+ ui.treeDevices->setEnabled(true);
+ }
+ else if(detected.at(0).status != Autodetection::PlayerOk) {
+ QString msg;
+ switch(detected.at(0).status) {
+ case Autodetection::PlayerIncompatible:
+ msg += tr("Detected an unsupported player:\n%1\n"
+ "Sorry, Rockbox doesn't run on your player.")
+ .arg(SystemInfo::platformValue(detected.at(0).device,
+ SystemInfo::CurName).toString());
+ break;
+ case Autodetection::PlayerMtpMode:
+ msg = tr("%1 in MTP mode found!\n"
+ "You need to change your player to MSC mode for installation. ")
+ .arg(SystemInfo::platformValue(detected.at(0).device,
+ SystemInfo::CurName).toString());
+ break;
+ case Autodetection::PlayerWrongFilesystem:
+ if(SystemInfo::platformValue(detected.at(0).device,
+ SystemInfo::CurBootloaderMethod) == "ipod") {
+ msg = tr("%1 \"MacPod\" found!\n"
+ "Rockbox needs a FAT formatted Ipod (so-called \"WinPod\") "
+ "to run. ").arg(SystemInfo::platformValue(
+ detected.at(0).device, SystemInfo::CurName).toString());
+ }
+ else {
+ msg = tr("The player contains an incompatible filesystem.\n"
+ "Make sure you selected the correct mountpoint and "
+ "the player is set up to use a filesystem compatible "
+ "with Rockbox.");
+ }
+ break;
+ case Autodetection::PlayerError:
+ msg += tr("An unknown error occured during player detection.");
+ break;
+ default:
+ break;
+ }
+ QMessageBox::information(this, tr("Device Detection"), msg);
+ ui.treeDevices->setEnabled(true);
+ }
+ else {
+ selectDevice(detected.at(0).device, detected.at(0).mountpoint);
+ }
+
+}
+
+void Config::selectDevice(QString device, QString mountpoint)
+{
+ // collapse all items
+ for(int a = 0; a < ui.treeDevices->topLevelItemCount(); a++)
+ ui.treeDevices->topLevelItem(a)->setExpanded(false);
+ // deselect the selected item(s)
+ for(int a = 0; a < ui.treeDevices->selectedItems().size(); a++)
+ ui.treeDevices->selectedItems().at(a)->setSelected(false);
+
+ // find the new item
+ // enumerate all platform items
+ QList<QTreeWidgetItem*> itmList
+ = ui.treeDevices->findItems("*",Qt::MatchWildcard);
+ for(int i=0; i< itmList.size();i++)
{
- QString devicename = detector.getDevice();
- // deexpand all items
- for(int a = 0; a < ui.treeDevices->topLevelItemCount(); a++)
- ui.treeDevices->topLevelItem(a)->setExpanded(false);
- //deselect the selected item(s)
- for(int a = 0; a < ui.treeDevices->selectedItems().size(); a++)
- ui.treeDevices->selectedItems().at(a)->setSelected(false);
-
- // find the new item
- // enumerate all platform items
- QList<QTreeWidgetItem*> itmList
- = ui.treeDevices->findItems("*",Qt::MatchWildcard);
- for(int i=0; i< itmList.size();i++)
+ //enumerate device items
+ for(int j=0;j < itmList.at(i)->childCount();j++)
{
- //enumerate device items
- for(int j=0;j < itmList.at(i)->childCount();j++)
+ QString data = itmList.at(i)->child(j)->data(0, Qt::UserRole).toString();
+ // unset bold flag
+ QFont f = itmList.at(i)->child(j)->font(0);
+ f.setBold(false);
+ itmList.at(i)->child(j)->setFont(0, f);
+
+ if(device == data) // item found
{
- QString data = itmList.at(i)->child(j)->data(0, Qt::UserRole).toString();
- // unset bold flag
- QFont f = itmList.at(i)->child(j)->font(0);
- f.setBold(false);
+ f.setBold(true);
itmList.at(i)->child(j)->setFont(0, f);
-
- if(devicename == data) // item found
- {
- f.setBold(true);
- itmList.at(i)->child(j)->setFont(0, f);
- itmList.at(i)->child(j)->setSelected(true); //select the item
- itmList.at(i)->setExpanded(true); //expand the platform item
- //ui.treeDevices->indexOfTopLevelItem(itmList.at(i)->child(j));
- ui.treeDevices->scrollToItem(itmList.at(i)->child(j));
- break;
- }
- }
- }
- this->unsetCursor();
-
- if(!detector.errdev().isEmpty()) {
- QString text;
- if(SystemInfo::platformValue(detector.errdev(),
- SystemInfo::CurBootloaderMethod) == "ipod") {
- text = tr("%1 \"MacPod\" found!\n"
- "Rockbox needs a FAT formatted Ipod (so-called \"WinPod\") "
- "to run. ").arg(SystemInfo::platformValue(
- detector.errdev(), SystemInfo::CurName).toString());
+ itmList.at(i)->child(j)->setSelected(true); //select the item
+ itmList.at(i)->setExpanded(true); //expand the platform item
+ //ui.treeDevices->indexOfTopLevelItem(itmList.at(i)->child(j));
+ ui.treeDevices->scrollToItem(itmList.at(i)->child(j));
+ break;
}
- // treat all other errors as MTP device for now.
- else {
- text = tr("%1 in MTP mode found!\n"
- "You need to change your player to MSC mode for installation. ")
- .arg(SystemInfo::platformValue(detector.errdev(),
- SystemInfo::CurName).toString());
- }
- text += tr("Until you change this installation will fail!");
-
- QMessageBox::critical(this, tr("Fatal error"), text, QMessageBox::Ok);
- return;
}
- if(!detector.incompatdev().isEmpty()) {
- QString text;
- text = tr("Detected an unsupported player:\n%1\n"
- "Sorry, Rockbox doesn't run on your player.")
- .arg(SystemInfo::platformValue(detector.incompatdev(),
- SystemInfo::CurName).toString());
-
- QMessageBox::critical(this, tr("Fatal: player incompatible"),
- text, QMessageBox::Ok);
- return;
- }
+ }
+ this->unsetCursor();
- if(detector.getMountPoint() != "" )
- {
- setMountpoint(detector.getMountPoint());
- }
- else
- {
- QMessageBox::warning(this, tr("Autodetection"),
- tr("Could not detect a Mountpoint.\n"
- "Select your Mountpoint manually."),
- QMessageBox::Ok ,QMessageBox::Ok);
- }
+ if(!mountpoint.isEmpty())
+ {
+ setMountpoint(mountpoint);
}
else
{
- this->unsetCursor();
QMessageBox::warning(this, tr("Autodetection"),
- tr("Could not detect a device.\n"
- "Select your device and Mountpoint manually."),
- QMessageBox::Ok ,QMessageBox::Ok);
-
+ tr("Could not detect a Mountpoint.\n"
+ "Select your Mountpoint manually."),
+ QMessageBox::Ok, QMessageBox::Ok);
}
ui.treeDevices->setEnabled(true);
}