diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2009-01-23 22:03:46 +0000 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2009-01-23 22:03:46 +0000 |
commit | f8816724112cf035fc18889235ce84a76bb34803 (patch) | |
tree | 9e1df8da4e2aa0918b88640f4bcc2a2286f7093c /rbutil/rbutilqt/install.cpp | |
parent | 1a79cfd17407e0d5e02c99273a55dbc3775adfef (diff) | |
download | rockbox-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
Diffstat (limited to 'rbutil/rbutilqt/install.cpp')
-rw-r--r-- | rbutil/rbutilqt/install.cpp | 34 |
1 files changed, 27 insertions, 7 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 | |||
57 | void Install::resizeEvent(QResizeEvent *e) | ||
58 | { | ||
59 | (void)e; | ||
60 | |||
61 | // recalculate width of elided text. | ||
62 | updateBackupLocation(); | ||
63 | } | ||
64 | |||
65 | |||
66 | void 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 | |||
55 | void Install::backupCheckboxChanged(int state) | 74 | void 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 | ||
183 | void Install::changeBackupPath() | 202 | void 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 | ||