summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2009-01-23 22:03:46 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2009-01-23 22:03:46 +0000
commitf8816724112cf035fc18889235ce84a76bb34803 (patch)
tree9e1df8da4e2aa0918b88640f4bcc2a2286f7093c
parent1a79cfd17407e0d5e02c99273a55dbc3775adfef (diff)
downloadrockbox-f8816724112cf035fc18889235ce84a76bb34803.tar.gz
rockbox-f8816724112cf035fc18889235ce84a76bb34803.zip
Make backup location text elide based of the label width instead of fixed size. Adjust on window resizes as well.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19832 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--rbutil/rbutilqt/install.cpp34
-rw-r--r--rbutil/rbutilqt/install.h6
-rw-r--r--rbutil/rbutilqt/installfrm.ui25
3 files changed, 32 insertions, 33 deletions
diff --git a/rbutil/rbutilqt/install.cpp b/rbutil/rbutilqt/install.cpp
index dc861ec14d..a277adaa22 100644
--- a/rbutil/rbutilqt/install.cpp
+++ b/rbutil/rbutilqt/install.cpp
@@ -31,8 +31,8 @@ Install::Install(RbSettings *sett,QWidget *parent) : QDialog(parent)
31 connect(ui.radioStable, SIGNAL(toggled(bool)), this, SLOT(setDetailsStable(bool))); 31 connect(ui.radioStable, SIGNAL(toggled(bool)), this, SLOT(setDetailsStable(bool)));
32 connect(ui.radioCurrent, SIGNAL(toggled(bool)), this, SLOT(setDetailsCurrent(bool))); 32 connect(ui.radioCurrent, SIGNAL(toggled(bool)), this, SLOT(setDetailsCurrent(bool)));
33 connect(ui.radioArchived, SIGNAL(toggled(bool)), this, SLOT(setDetailsArchived(bool))); 33 connect(ui.radioArchived, SIGNAL(toggled(bool)), this, SLOT(setDetailsArchived(bool)));
34 connect(ui.changeBackup,SIGNAL(pressed()),this,SLOT(changeBackupPath())); 34 connect(ui.changeBackup, SIGNAL(pressed()), this, SLOT(changeBackupPath()));
35 connect(ui.backup,SIGNAL(stateChanged(int)),this,SLOT(backupCheckboxChanged(int))); 35 connect(ui.backup, SIGNAL(stateChanged(int)), this, SLOT(backupCheckboxChanged(int)));
36 36
37 //! check if rockbox is already installed 37 //! check if rockbox is already installed
38 QString version = Detect::installedVersion(settings->mountpoint()); 38 QString version = Detect::installedVersion(settings->mountpoint());
@@ -43,7 +43,8 @@ Install::Install(RbSettings *sett,QWidget *parent) : QDialog(parent)
43 m_backupName = settings->mountpoint(); 43 m_backupName = settings->mountpoint();
44 if(!m_backupName.endsWith("/")) m_backupName += "/"; 44 if(!m_backupName.endsWith("/")) m_backupName += "/";
45 m_backupName += ".backup/rockbox-backup-"+version+".zip"; 45 m_backupName += ".backup/rockbox-backup-"+version+".zip";
46 ui.backupLocation->setText(QDir::toNativeSeparators(fontMetrics().elidedText(m_backupName,Qt::ElideMiddle,200))); 46 // for some reason the label doesn't return its final size yet.
47 // Delay filling ui.backupLocation until the checkbox is changed.
47 } 48 }
48 else 49 else
49 { 50 {
@@ -52,17 +53,35 @@ Install::Install(RbSettings *sett,QWidget *parent) : QDialog(parent)
52 backupCheckboxChanged(Qt::Unchecked); 53 backupCheckboxChanged(Qt::Unchecked);
53} 54}
54 55
56
57void Install::resizeEvent(QResizeEvent *e)
58{
59 (void)e;
60
61 // recalculate width of elided text.
62 updateBackupLocation();
63}
64
65
66void Install::updateBackupLocation(void)
67{
68 ui.backupLocation->setText(QDir::toNativeSeparators(
69 fontMetrics().elidedText(tr("Backup to %1").arg(m_backupName),
70 Qt::ElideMiddle, ui.backupLocation->size().width())));
71}
72
73
55void Install::backupCheckboxChanged(int state) 74void Install::backupCheckboxChanged(int state)
56{ 75{
57 if(state == Qt::Checked) 76 if(state == Qt::Checked)
58 { 77 {
59 ui.backupLabel->show();
60 ui.backupLocation->show(); 78 ui.backupLocation->show();
61 ui.changeBackup->show(); 79 ui.changeBackup->show();
80 // update backup location display.
81 updateBackupLocation();
62 } 82 }
63 else 83 else
64 { 84 {
65 ui.backupLabel->hide();
66 ui.backupLocation->hide(); 85 ui.backupLocation->hide();
67 ui.changeBackup->hide(); 86 ui.changeBackup->hide();
68 } 87 }
@@ -182,11 +201,12 @@ void Install::accept()
182 201
183void Install::changeBackupPath() 202void Install::changeBackupPath()
184{ 203{
185 QString backupString = QFileDialog::getSaveFileName(this,"Select Backup Filename",m_backupName, "*.zip"); 204 QString backupString = QFileDialog::getSaveFileName(this,
205 tr("Select Backup Filename"), m_backupName, "*.zip");
186 // only update if a filename was entered, ignore if cancelled 206 // only update if a filename was entered, ignore if cancelled
187 if(!backupString.isEmpty()) { 207 if(!backupString.isEmpty()) {
188 ui.backupLocation->setText(QDir::toNativeSeparators(fontMetrics().elidedText(backupString,Qt::ElideMiddle,200)));
189 m_backupName = backupString; 208 m_backupName = backupString;
209 updateBackupLocation();
190 } 210 }
191} 211}
192 212
diff --git a/rbutil/rbutilqt/install.h b/rbutil/rbutilqt/install.h
index 0df0f03499..6eed631956 100644
--- a/rbutil/rbutilqt/install.h
+++ b/rbutil/rbutilqt/install.h
@@ -38,8 +38,8 @@ class Install : public QDialog
38 38
39 public slots: 39 public slots:
40 void accept(void); 40 void accept(void);
41 41
42 private: 42 private:
43 Ui::InstallFrm ui; 43 Ui::InstallFrm ui;
44 ProgressLoggerGui* logger; 44 ProgressLoggerGui* logger;
45 RbSettings* settings; 45 RbSettings* settings;
@@ -50,8 +50,10 @@ class Install : public QDialog
50 ZipInstaller* installer; 50 ZipInstaller* installer;
51 QMap<QString, QString> version; 51 QMap<QString, QString> version;
52 QString m_backupName; 52 QString m_backupName;
53 void resizeEvent(QResizeEvent*);
53 54
54 void changeBackupPath(QString); 55 void changeBackupPath(QString);
56 void updateBackupLocation(void);
55 57
56 private slots: 58 private slots:
57 void setCached(bool); 59 void setCached(bool);
diff --git a/rbutil/rbutilqt/installfrm.ui b/rbutil/rbutilqt/installfrm.ui
index bdb42d765d..472e773187 100644
--- a/rbutil/rbutilqt/installfrm.ui
+++ b/rbutil/rbutilqt/installfrm.ui
@@ -163,7 +163,7 @@
163 </property> 163 </property>
164 </widget> 164 </widget>
165 </item> 165 </item>
166 <item row="1" column="1" > 166 <item row="1" column="0" colspan="2" >
167 <widget class="QLabel" name="backupLocation" > 167 <widget class="QLabel" name="backupLocation" >
168 <property name="text" > 168 <property name="text" >
169 <string>Backup location</string> 169 <string>Backup location</string>
@@ -189,30 +189,7 @@
189 </property> 189 </property>
190 </widget> 190 </widget>
191 </item> 191 </item>
192 <item row="1" column="0" >
193 <widget class="QLabel" name="backupLabel" >
194 <property name="sizePolicy" >
195 <sizepolicy vsizetype="Preferred" hsizetype="Minimum" >
196 <horstretch>0</horstretch>
197 <verstretch>0</verstretch>
198 </sizepolicy>
199 </property>
200 <property name="maximumSize" >
201 <size>
202 <width>120</width>
203 <height>16777215</height>
204 </size>
205 </property>
206 <property name="text" >
207 <string>Backup Location</string>
208 </property>
209 </widget>
210 </item>
211 </layout> 192 </layout>
212 <zorder>backup</zorder>
213 <zorder>backupLocation</zorder>
214 <zorder>changeBackup</zorder>
215 <zorder>backupLabel</zorder>
216 </widget> 193 </widget>
217 </item> 194 </item>
218 <item row="5" column="1" > 195 <item row="5" column="1" >