summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt/configure.cpp
diff options
context:
space:
mode:
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()
725 this->setCursor(Qt::WaitCursor); 725 this->setCursor(Qt::WaitCursor);
726 QCoreApplication::processEvents(); 726 QCoreApplication::processEvents();
727 727
728 if(detector.detect()) //let it detect 728 detector.detect();
729 QList<struct Autodetection::Detected> detected;
730 detected = detector.detected();
731 this->unsetCursor();
732 if(detected.size() > 1) {
733 // FIXME: handle multiple found players.
734 QMessageBox::information(this, tr("Device Detection"),
735 tr("Multiple devices have been detected. Please disconnect "
736 "all players but one and try again."));
737 ui.treeDevices->setEnabled(true);
738 }
739 else if(detected.size() == 0) {
740 QMessageBox::warning(this, tr("Device Detection"),
741 tr("Could not detect a device.\n"
742 "Select your device and Mountpoint manually."),
743 QMessageBox::Ok ,QMessageBox::Ok);
744 ui.treeDevices->setEnabled(true);
745 }
746 else if(detected.at(0).status != Autodetection::PlayerOk) {
747 QString msg;
748 switch(detected.at(0).status) {
749 case Autodetection::PlayerIncompatible:
750 msg += tr("Detected an unsupported player:\n%1\n"
751 "Sorry, Rockbox doesn't run on your player.")
752 .arg(SystemInfo::platformValue(detected.at(0).device,
753 SystemInfo::CurName).toString());
754 break;
755 case Autodetection::PlayerMtpMode:
756 msg = tr("%1 in MTP mode found!\n"
757 "You need to change your player to MSC mode for installation. ")
758 .arg(SystemInfo::platformValue(detected.at(0).device,
759 SystemInfo::CurName).toString());
760 break;
761 case Autodetection::PlayerWrongFilesystem:
762 if(SystemInfo::platformValue(detected.at(0).device,
763 SystemInfo::CurBootloaderMethod) == "ipod") {
764 msg = tr("%1 \"MacPod\" found!\n"
765 "Rockbox needs a FAT formatted Ipod (so-called \"WinPod\") "
766 "to run. ").arg(SystemInfo::platformValue(
767 detected.at(0).device, SystemInfo::CurName).toString());
768 }
769 else {
770 msg = tr("The player contains an incompatible filesystem.\n"
771 "Make sure you selected the correct mountpoint and "
772 "the player is set up to use a filesystem compatible "
773 "with Rockbox.");
774 }
775 break;
776 case Autodetection::PlayerError:
777 msg += tr("An unknown error occured during player detection.");
778 break;
779 default:
780 break;
781 }
782 QMessageBox::information(this, tr("Device Detection"), msg);
783 ui.treeDevices->setEnabled(true);
784 }
785 else {
786 selectDevice(detected.at(0).device, detected.at(0).mountpoint);
787 }
788
789}
790
791void Config::selectDevice(QString device, QString mountpoint)
792{
793 // collapse all items
794 for(int a = 0; a < ui.treeDevices->topLevelItemCount(); a++)
795 ui.treeDevices->topLevelItem(a)->setExpanded(false);
796 // deselect the selected item(s)
797 for(int a = 0; a < ui.treeDevices->selectedItems().size(); a++)
798 ui.treeDevices->selectedItems().at(a)->setSelected(false);
799
800 // find the new item
801 // enumerate all platform items
802 QList<QTreeWidgetItem*> itmList
803 = ui.treeDevices->findItems("*",Qt::MatchWildcard);
804 for(int i=0; i< itmList.size();i++)
729 { 805 {
730 QString devicename = detector.getDevice(); 806 //enumerate device items
731 // deexpand all items 807 for(int j=0;j < itmList.at(i)->childCount();j++)
732 for(int a = 0; a < ui.treeDevices->topLevelItemCount(); a++)
733 ui.treeDevices->topLevelItem(a)->setExpanded(false);
734 //deselect the selected item(s)
735 for(int a = 0; a < ui.treeDevices->selectedItems().size(); a++)
736 ui.treeDevices->selectedItems().at(a)->setSelected(false);
737
738 // find the new item
739 // enumerate all platform items
740 QList<QTreeWidgetItem*> itmList
741 = ui.treeDevices->findItems("*",Qt::MatchWildcard);
742 for(int i=0; i< itmList.size();i++)
743 { 808 {
744 //enumerate device items 809 QString data = itmList.at(i)->child(j)->data(0, Qt::UserRole).toString();
745 for(int j=0;j < itmList.at(i)->childCount();j++) 810 // unset bold flag
811 QFont f = itmList.at(i)->child(j)->font(0);
812 f.setBold(false);
813 itmList.at(i)->child(j)->setFont(0, f);
814
815 if(device == data) // item found
746 { 816 {
747 QString data = itmList.at(i)->child(j)->data(0, Qt::UserRole).toString(); 817 f.setBold(true);
748 // unset bold flag
749 QFont f = itmList.at(i)->child(j)->font(0);
750 f.setBold(false);
751 itmList.at(i)->child(j)->setFont(0, f); 818 itmList.at(i)->child(j)->setFont(0, f);
752 819 itmList.at(i)->child(j)->setSelected(true); //select the item
753 if(devicename == data) // item found 820 itmList.at(i)->setExpanded(true); //expand the platform item
754 { 821 //ui.treeDevices->indexOfTopLevelItem(itmList.at(i)->child(j));
755 f.setBold(true); 822 ui.treeDevices->scrollToItem(itmList.at(i)->child(j));
756 itmList.at(i)->child(j)->setFont(0, f); 823 break;
757 itmList.at(i)->child(j)->setSelected(true); //select the item
758 itmList.at(i)->setExpanded(true); //expand the platform item
759 //ui.treeDevices->indexOfTopLevelItem(itmList.at(i)->child(j));
760 ui.treeDevices->scrollToItem(itmList.at(i)->child(j));
761 break;
762 }
763 }
764 }
765 this->unsetCursor();
766
767 if(!detector.errdev().isEmpty()) {
768 QString text;
769 if(SystemInfo::platformValue(detector.errdev(),
770 SystemInfo::CurBootloaderMethod) == "ipod") {
771 text = tr("%1 \"MacPod\" found!\n"
772 "Rockbox needs a FAT formatted Ipod (so-called \"WinPod\") "
773 "to run. ").arg(SystemInfo::platformValue(
774 detector.errdev(), SystemInfo::CurName).toString());
775 } 824 }
776 // treat all other errors as MTP device for now.
777 else {
778 text = tr("%1 in MTP mode found!\n"
779 "You need to change your player to MSC mode for installation. ")
780 .arg(SystemInfo::platformValue(detector.errdev(),
781 SystemInfo::CurName).toString());
782 }
783 text += tr("Until you change this installation will fail!");
784
785 QMessageBox::critical(this, tr("Fatal error"), text, QMessageBox::Ok);
786 return;
787 } 825 }
788 if(!detector.incompatdev().isEmpty()) { 826 }
789 QString text; 827 this->unsetCursor();
790 text = tr("Detected an unsupported player:\n%1\n"
791 "Sorry, Rockbox doesn't run on your player.")
792 .arg(SystemInfo::platformValue(detector.incompatdev(),
793 SystemInfo::CurName).toString());
794
795 QMessageBox::critical(this, tr("Fatal: player incompatible"),
796 text, QMessageBox::Ok);
797 return;
798 }
799 828
800 if(detector.getMountPoint() != "" ) 829 if(!mountpoint.isEmpty())
801 { 830 {
802 setMountpoint(detector.getMountPoint()); 831 setMountpoint(mountpoint);
803 }
804 else
805 {
806 QMessageBox::warning(this, tr("Autodetection"),
807 tr("Could not detect a Mountpoint.\n"
808 "Select your Mountpoint manually."),
809 QMessageBox::Ok ,QMessageBox::Ok);
810 }
811 } 832 }
812 else 833 else
813 { 834 {
814 this->unsetCursor();
815 QMessageBox::warning(this, tr("Autodetection"), 835 QMessageBox::warning(this, tr("Autodetection"),
816 tr("Could not detect a device.\n" 836 tr("Could not detect a Mountpoint.\n"
817 "Select your device and Mountpoint manually."), 837 "Select your Mountpoint manually."),
818 QMessageBox::Ok ,QMessageBox::Ok); 838 QMessageBox::Ok, QMessageBox::Ok);
819
820 } 839 }
821 ui.treeDevices->setEnabled(true); 840 ui.treeDevices->setEnabled(true);
822} 841}