summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2011-07-15 19:14:26 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2011-07-15 19:14:26 +0000
commit241f28eefce35e1cf9087ab06f1ee474017f6be8 (patch)
treeb3b0318a547f0516408cda1bbef3e7e96de49c2d
parent21a38713a685e04ab1533f487244f2dc2197e01c (diff)
downloadrockbox-241f28eefce35e1cf9087ab06f1ee474017f6be8.tar.gz
rockbox-241f28eefce35e1cf9087ab06f1ee474017f6be8.zip
Replace mountpoint selection with combo box.
Instead of entering the mountpoint via a tree browser or manually use a combo box that lists all available drives / mountpoints. This also allows to easily add more information like the free and total size for each mountpoint. For development this can still be overriden by editing the dropdown value manually. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30140 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--rbutil/rbutilqt/configure.cpp108
-rw-r--r--rbutil/rbutilqt/configure.h9
-rw-r--r--rbutil/rbutilqt/configurefrm.ui61
3 files changed, 114 insertions, 64 deletions
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp
index 35654f8711..e48a89f302 100644
--- a/rbutil/rbutilqt/configure.cpp
+++ b/rbutil/rbutilqt/configure.cpp
@@ -23,7 +23,6 @@
23#include "configure.h" 23#include "configure.h"
24#include "autodetection.h" 24#include "autodetection.h"
25#include "ui_configurefrm.h" 25#include "ui_configurefrm.h"
26#include "browsedirtree.h"
27#include "encoders.h" 26#include "encoders.h"
28#include "ttsbase.h" 27#include "ttsbase.h"
29#include "system.h" 28#include "system.h"
@@ -88,7 +87,7 @@ Config::Config(QWidget *parent,int index) : QDialog(parent)
88 connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(abort())); 87 connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(abort()));
89 connect(ui.radioNoProxy, SIGNAL(toggled(bool)), this, SLOT(setNoProxy(bool))); 88 connect(ui.radioNoProxy, SIGNAL(toggled(bool)), this, SLOT(setNoProxy(bool)));
90 connect(ui.radioSystemProxy, SIGNAL(toggled(bool)), this, SLOT(setSystemProxy(bool))); 89 connect(ui.radioSystemProxy, SIGNAL(toggled(bool)), this, SLOT(setSystemProxy(bool)));
91 connect(ui.browseMountPoint, SIGNAL(clicked()), this, SLOT(browseFolder())); 90 connect(ui.refreshMountPoint, SIGNAL(clicked()), this, SLOT(refreshMountpoint()));
92 connect(ui.buttonAutodetect,SIGNAL(clicked()),this,SLOT(autodetect())); 91 connect(ui.buttonAutodetect,SIGNAL(clicked()),this,SLOT(autodetect()));
93 connect(ui.buttonCacheBrowse, SIGNAL(clicked()), this, SLOT(browseCache())); 92 connect(ui.buttonCacheBrowse, SIGNAL(clicked()), this, SLOT(browseCache()));
94 connect(ui.buttonCacheClear, SIGNAL(clicked()), this, SLOT(cacheClear())); 93 connect(ui.buttonCacheClear, SIGNAL(clicked()), this, SLOT(cacheClear()));
@@ -98,6 +97,8 @@ Config::Config(QWidget *parent,int index) : QDialog(parent)
98 connect(ui.treeDevices, SIGNAL(itemSelectionChanged()), this, SLOT(updateEncState())); 97 connect(ui.treeDevices, SIGNAL(itemSelectionChanged()), this, SLOT(updateEncState()));
99 connect(ui.testTTS,SIGNAL(clicked()),this,SLOT(testTts())); 98 connect(ui.testTTS,SIGNAL(clicked()),this,SLOT(testTts()));
100 connect(ui.showDisabled, SIGNAL(toggled(bool)), this, SLOT(showDisabled(bool))); 99 connect(ui.showDisabled, SIGNAL(toggled(bool)), this, SLOT(showDisabled(bool)));
100 connect(ui.mountPoint, SIGNAL(editTextChanged(QString)), this, SLOT(updateMountpoint(QString)));
101 connect(ui.mountPoint, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMountpoint(int)));
101 // delete this dialog after it finished automatically. 102 // delete this dialog after it finished automatically.
102 connect(this, SIGNAL(finished(int)), this, SLOT(deleteLater())); 103 connect(this, SIGNAL(finished(int)), this, SLOT(deleteLater()));
103 104
@@ -149,25 +150,25 @@ void Config::accept()
149 RbSettings::setValue(RbSettings::Language, language); 150 RbSettings::setValue(RbSettings::Language, language);
150 151
151 // mountpoint 152 // mountpoint
152 QString mp = ui.mountPoint->text(); 153 if(mountpoint.isEmpty()) {
153 if(mp.isEmpty()) {
154 errormsg += "<li>" + tr("No mountpoint given") + "</li>"; 154 errormsg += "<li>" + tr("No mountpoint given") + "</li>";
155 error = true; 155 error = true;
156 } 156 }
157 else if(!QFileInfo(mp).exists()) { 157 else if(!QFileInfo(mountpoint).exists()) {
158 errormsg += "<li>" + tr("Mountpoint does not exist") + "</li>"; 158 errormsg += "<li>" + tr("Mountpoint does not exist") + "</li>";
159 error = true; 159 error = true;
160 } 160 }
161 else if(!QFileInfo(mp).isDir()) { 161 else if(!QFileInfo(mountpoint).isDir()) {
162 errormsg += "<li>" + tr("Mountpoint is not a directory.") + "</li>"; 162 errormsg += "<li>" + tr("Mountpoint is not a directory.") + "</li>";
163 error = true; 163 error = true;
164 } 164 }
165 else if(!QFileInfo(mp).isWritable()) { 165 else if(!QFileInfo(mountpoint).isWritable()) {
166 errormsg += "<li>" + tr("Mountpoint is not writeable") + "</li>"; 166 errormsg += "<li>" + tr("Mountpoint is not writeable") + "</li>";
167 error = true; 167 error = true;
168 } 168 }
169 else { 169 else {
170 RbSettings::setValue(RbSettings::Mountpoint, QDir::fromNativeSeparators(mp)); 170 RbSettings::setValue(RbSettings::Mountpoint,
171 QDir::fromNativeSeparators(mountpoint));
171 } 172 }
172 173
173 // platform 174 // platform
@@ -269,7 +270,9 @@ void Config::setUserSettings()
269 connect(ui.listLanguages, SIGNAL(itemSelectionChanged()), this, SLOT(updateLanguage())); 270 connect(ui.listLanguages, SIGNAL(itemSelectionChanged()), this, SLOT(updateLanguage()));
270 271
271 // devices tab 272 // devices tab
272 ui.mountPoint->setText(QDir::toNativeSeparators(RbSettings::value(RbSettings::Mountpoint).toString())); 273 refreshMountpoint();
274 mountpoint = RbSettings::value(RbSettings::Mountpoint).toString();
275 setMountpoint(mountpoint);
273 276
274 // cache tab 277 // cache tab
275 if(!QFileInfo(RbSettings::value(RbSettings::CachePath).toString()).isDir()) 278 if(!QFileInfo(RbSettings::value(RbSettings::CachePath).toString()).isDir())
@@ -556,28 +559,6 @@ void Config::updateLanguage()
556} 559}
557 560
558 561
559void Config::browseFolder()
560{
561 browser = new BrowseDirtree(this,tr("Select your device"));
562#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
563 browser->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
564#elif defined(Q_OS_WIN32)
565 browser->setFilter(QDir::Drives);
566#endif
567#if defined(Q_OS_MACX)
568 browser->setRoot("/Volumes");
569#elif defined(Q_OS_LINUX)
570 browser->setDir("/media");
571#endif
572 if( ui.mountPoint->text() != "" )
573 {
574 browser->setDir(ui.mountPoint->text());
575 }
576 browser->show();
577 connect(browser, SIGNAL(itemChanged(QString)), this, SLOT(setMountpoint(QString)));
578}
579
580
581void Config::browseCache() 562void Config::browseCache()
582{ 563{
583 QString old = ui.cachePath->text(); 564 QString old = ui.cachePath->text();
@@ -593,9 +574,70 @@ void Config::browseCache()
593} 574}
594 575
595 576
577void Config::refreshMountpoint()
578{
579 // avoid QComboBox to send signals during rebuild to avoid changing to an
580 // unwanted item.
581 ui.mountPoint->blockSignals(true);
582 ui.mountPoint->clear();
583 QStringList mps = Autodetection::mountpoints();
584 for(int i = 0; i < mps.size(); ++i) {
585 // add mountpoint as user data so we can change the displayed string
586 // later (to include volume label or similar)
587 // Skip unwritable mountpoints, they are not useable for us.
588 if(QFileInfo(mps.at(i)).isWritable()) {
589 QString title = QString("%1 (%2 GiB of %3 GiB free)")
590 .arg(QDir::toNativeSeparators(mps.at(i)))
591 .arg((double)Utils::filesystemFree(mps.at(i))/(1<<30), 0, 'f', 2)
592 .arg((double)Utils::filesystemTotal(mps.at(i))/(1<<30), 0, 'f', 2);
593 ui.mountPoint->addItem(title, mps.at(i));
594 }
595 }
596 if(!mountpoint.isEmpty()) {
597 setMountpoint(mountpoint);
598 }
599 ui.mountPoint->blockSignals(false);
600}
601
602
603void Config::updateMountpoint(QString m)
604{
605 if(!m.isEmpty()) {
606 mountpoint = m;
607 qDebug() << "[Config] Mountpoint set to" << mountpoint;
608 }
609}
610
611
612void Config::updateMountpoint(int idx)
613{
614 if(idx == -1) {
615 return;
616 }
617 QString mp = ui.mountPoint->itemData(idx).toString();
618 if(!mp.isEmpty()) {
619 mountpoint = mp;
620 qDebug() << "[Config] Mountpoint set to" << mountpoint;
621 }
622}
623
624
596void Config::setMountpoint(QString m) 625void Config::setMountpoint(QString m)
597{ 626{
598 ui.mountPoint->setText(m); 627 if(m.isEmpty()) {
628 return;
629 }
630 int index = ui.mountPoint->findData(m);
631 if(index != -1) {
632 ui.mountPoint->setCurrentIndex(index);
633 }
634 else {
635 // keep a mountpoint that is not in the list for convenience (to allow
636 // easier development)
637 ui.mountPoint->addItem(m);
638 ui.mountPoint->setCurrentIndex(ui.mountPoint->findText(m));
639 }
640 qDebug() << "[Config] Mountpoint set to" << mountpoint;
599} 641}
600 642
601 643
@@ -682,7 +724,7 @@ void Config::autodetect()
682 724
683 if(detector.getMountPoint() != "" ) 725 if(detector.getMountPoint() != "" )
684 { 726 {
685 ui.mountPoint->setText(QDir::toNativeSeparators(detector.getMountPoint())); 727 setMountpoint(detector.getMountPoint());
686 } 728 }
687 else 729 else
688 { 730 {
diff --git a/rbutil/rbutilqt/configure.h b/rbutil/rbutilqt/configure.h
index 3884d0d750..fcfa9cbe7d 100644
--- a/rbutil/rbutilqt/configure.h
+++ b/rbutil/rbutilqt/configure.h
@@ -23,7 +23,6 @@
23#define CONFIGURE_H 23#define CONFIGURE_H
24 24
25#include "ui_configurefrm.h" 25#include "ui_configurefrm.h"
26#include "browsedirtree.h"
27#include <QtGui> 26#include <QtGui>
28 27
29class Config : public QDialog 28class Config : public QDialog
@@ -51,19 +50,19 @@ class Config : public QDialog
51 QString language; 50 QString language;
52 QString programPath; 51 QString programPath;
53 QUrl proxy; 52 QUrl proxy;
53 QString mountpoint;
54 void updateCacheInfo(QString); 54 void updateCacheInfo(QString);
55 55
56 BrowseDirtree *browser;
57 BrowseDirtree *cbrowser;
58
59 private slots: 56 private slots:
60 void setNoProxy(bool); 57 void setNoProxy(bool);
61 void setSystemProxy(bool); 58 void setSystemProxy(bool);
62 void updateLanguage(void); 59 void updateLanguage(void);
63 void browseFolder(void); 60 void refreshMountpoint(void);
64 void browseCache(void); 61 void browseCache(void);
65 void autodetect(void); 62 void autodetect(void);
66 void setMountpoint(QString); 63 void setMountpoint(QString);
64 void updateMountpoint(QString);
65 void updateMountpoint(int);
67 void cacheClear(void); 66 void cacheClear(void);
68 void configTts(void); 67 void configTts(void);
69 void configEnc(void); 68 void configEnc(void);
diff --git a/rbutil/rbutilqt/configurefrm.ui b/rbutil/rbutilqt/configurefrm.ui
index 0c82e5d988..5d2de0647b 100644
--- a/rbutil/rbutilqt/configurefrm.ui
+++ b/rbutil/rbutilqt/configurefrm.ui
@@ -13,8 +13,8 @@
13 <property name="windowTitle"> 13 <property name="windowTitle">
14 <string>Configuration</string> 14 <string>Configuration</string>
15 </property> 15 </property>
16 <layout class="QGridLayout"> 16 <layout class="QGridLayout" name="gridLayout_2">
17 <item row="0" column="0" colspan="3"> 17 <item row="0" column="0">
18 <widget class="QLabel" name="labelTitle"> 18 <widget class="QLabel" name="labelTitle">
19 <property name="text"> 19 <property name="text">
20 <string>Configure Rockbox Utility</string> 20 <string>Configure Rockbox Utility</string>
@@ -34,7 +34,7 @@
34 <attribute name="title"> 34 <attribute name="title">
35 <string>&amp;Device</string> 35 <string>&amp;Device</string>
36 </attribute> 36 </attribute>
37 <layout class="QGridLayout"> 37 <layout class="QGridLayout" name="gridLayout">
38 <item row="0" column="0" colspan="2"> 38 <item row="0" column="0" colspan="2">
39 <widget class="QLabel" name="labelMountPoint"> 39 <widget class="QLabel" name="labelMountPoint">
40 <property name="text"> 40 <property name="text">
@@ -46,25 +46,25 @@
46 </widget> 46 </widget>
47 </item> 47 </item>
48 <item row="1" column="0" colspan="3"> 48 <item row="1" column="0" colspan="3">
49 <layout class="QHBoxLayout"> 49 <widget class="QComboBox" name="mountPoint">
50 <item> 50 <property name="editable">
51 <widget class="QLineEdit" name="mountPoint"/> 51 <bool>true</bool>
52 </item> 52 </property>
53 <item> 53 </widget>
54 <widget class="QPushButton" name="browseMountPoint"> 54 </item>
55 <property name="text"> 55 <item row="1" column="3">
56 <string>&amp;Browse</string> 56 <widget class="QPushButton" name="refreshMountPoint">
57 </property> 57 <property name="text">
58 <property name="icon"> 58 <string>&amp;Refresh</string>
59 <iconset resource="rbutilqt.qrc"> 59 </property>
60 <normaloff>:/icons/system-search.png</normaloff>:/icons/system-search.png</iconset> 60 <property name="icon">
61 </property> 61 <iconset resource="rbutilqt.qrc">
62 <property name="autoDefault"> 62 <normaloff>:/icons/view-refresh.png</normaloff>:/icons/view-refresh.png</iconset>
63 <bool>false</bool> 63 </property>
64 </property> 64 <property name="autoDefault">
65 </widget> 65 <bool>false</bool>
66 </item> 66 </property>
67 </layout> 67 </widget>
68 </item> 68 </item>
69 <item row="2" column="0"> 69 <item row="2" column="0">
70 <widget class="QLabel" name="labelPlayer"> 70 <widget class="QLabel" name="labelPlayer">
@@ -89,17 +89,26 @@
89 </property> 89 </property>
90 </spacer> 90 </spacer>
91 </item> 91 </item>
92 <item row="2" column="2"> 92 <item row="2" column="2" colspan="2">
93 <widget class="QCheckBox" name="showDisabled"> 93 <widget class="QCheckBox" name="showDisabled">
94 <property name="text"> 94 <property name="text">
95 <string>Show disabled targets</string> 95 <string>Show disabled targets</string>
96 </property> 96 </property>
97 </widget> 97 </widget>
98 </item> 98 </item>
99 <item row="3" column="0" colspan="3"> 99 <item row="3" column="0" colspan="4">
100 <widget class="QTreeWidget" name="treeDevices"/> 100 <widget class="QTreeWidget" name="treeDevices">
101 <attribute name="headerVisible">
102 <bool>false</bool>
103 </attribute>
104 <column>
105 <property name="text">
106 <string notr="true">1</string>
107 </property>
108 </column>
109 </widget>
101 </item> 110 </item>
102 <item row="4" column="0" colspan="3"> 111 <item row="4" column="0" colspan="4">
103 <widget class="QPushButton" name="buttonAutodetect"> 112 <widget class="QPushButton" name="buttonAutodetect">
104 <property name="text"> 113 <property name="text">
105 <string>&amp;Autodetect</string> 114 <string>&amp;Autodetect</string>