summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt/install.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/rbutilqt/install.cpp')
-rw-r--r--rbutil/rbutilqt/install.cpp34
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
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