mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-09 13:15:18 -05:00
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
This commit is contained in:
parent
1a79cfd174
commit
f881672411
3 changed files with 32 additions and 33 deletions
|
|
@ -31,8 +31,8 @@ Install::Install(RbSettings *sett,QWidget *parent) : QDialog(parent)
|
|||
connect(ui.radioStable, SIGNAL(toggled(bool)), this, SLOT(setDetailsStable(bool)));
|
||||
connect(ui.radioCurrent, SIGNAL(toggled(bool)), this, SLOT(setDetailsCurrent(bool)));
|
||||
connect(ui.radioArchived, SIGNAL(toggled(bool)), this, SLOT(setDetailsArchived(bool)));
|
||||
connect(ui.changeBackup,SIGNAL(pressed()),this,SLOT(changeBackupPath()));
|
||||
connect(ui.backup,SIGNAL(stateChanged(int)),this,SLOT(backupCheckboxChanged(int)));
|
||||
connect(ui.changeBackup, SIGNAL(pressed()), this, SLOT(changeBackupPath()));
|
||||
connect(ui.backup, SIGNAL(stateChanged(int)), this, SLOT(backupCheckboxChanged(int)));
|
||||
|
||||
//! check if rockbox is already installed
|
||||
QString version = Detect::installedVersion(settings->mountpoint());
|
||||
|
|
@ -43,7 +43,8 @@ Install::Install(RbSettings *sett,QWidget *parent) : QDialog(parent)
|
|||
m_backupName = settings->mountpoint();
|
||||
if(!m_backupName.endsWith("/")) m_backupName += "/";
|
||||
m_backupName += ".backup/rockbox-backup-"+version+".zip";
|
||||
ui.backupLocation->setText(QDir::toNativeSeparators(fontMetrics().elidedText(m_backupName,Qt::ElideMiddle,200)));
|
||||
// for some reason the label doesn't return its final size yet.
|
||||
// Delay filling ui.backupLocation until the checkbox is changed.
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -52,17 +53,35 @@ Install::Install(RbSettings *sett,QWidget *parent) : QDialog(parent)
|
|||
backupCheckboxChanged(Qt::Unchecked);
|
||||
}
|
||||
|
||||
|
||||
void Install::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
(void)e;
|
||||
|
||||
// recalculate width of elided text.
|
||||
updateBackupLocation();
|
||||
}
|
||||
|
||||
|
||||
void Install::updateBackupLocation(void)
|
||||
{
|
||||
ui.backupLocation->setText(QDir::toNativeSeparators(
|
||||
fontMetrics().elidedText(tr("Backup to %1").arg(m_backupName),
|
||||
Qt::ElideMiddle, ui.backupLocation->size().width())));
|
||||
}
|
||||
|
||||
|
||||
void Install::backupCheckboxChanged(int state)
|
||||
{
|
||||
if(state == Qt::Checked)
|
||||
{
|
||||
ui.backupLabel->show();
|
||||
ui.backupLocation->show();
|
||||
ui.changeBackup->show();
|
||||
// update backup location display.
|
||||
updateBackupLocation();
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.backupLabel->hide();
|
||||
ui.backupLocation->hide();
|
||||
ui.changeBackup->hide();
|
||||
}
|
||||
|
|
@ -182,11 +201,12 @@ void Install::accept()
|
|||
|
||||
void Install::changeBackupPath()
|
||||
{
|
||||
QString backupString = QFileDialog::getSaveFileName(this,"Select Backup Filename",m_backupName, "*.zip");
|
||||
QString backupString = QFileDialog::getSaveFileName(this,
|
||||
tr("Select Backup Filename"), m_backupName, "*.zip");
|
||||
// only update if a filename was entered, ignore if cancelled
|
||||
if(!backupString.isEmpty()) {
|
||||
ui.backupLocation->setText(QDir::toNativeSeparators(fontMetrics().elidedText(backupString,Qt::ElideMiddle,200)));
|
||||
m_backupName = backupString;
|
||||
updateBackupLocation();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@ class Install : public QDialog
|
|||
|
||||
public slots:
|
||||
void accept(void);
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
Ui::InstallFrm ui;
|
||||
ProgressLoggerGui* logger;
|
||||
RbSettings* settings;
|
||||
|
|
@ -50,8 +50,10 @@ class Install : public QDialog
|
|||
ZipInstaller* installer;
|
||||
QMap<QString, QString> version;
|
||||
QString m_backupName;
|
||||
void resizeEvent(QResizeEvent*);
|
||||
|
||||
void changeBackupPath(QString);
|
||||
void updateBackupLocation(void);
|
||||
|
||||
private slots:
|
||||
void setCached(bool);
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<item row="1" column="0" colspan="2" >
|
||||
<widget class="QLabel" name="backupLocation" >
|
||||
<property name="text" >
|
||||
<string>Backup location</string>
|
||||
|
|
@ -189,30 +189,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="backupLabel" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Preferred" hsizetype="Minimum" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Backup Location</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>backup</zorder>
|
||||
<zorder>backupLocation</zorder>
|
||||
<zorder>changeBackup</zorder>
|
||||
<zorder>backupLabel</zorder>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1" >
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue