Create dedicated backup dialog.

The "Installation" dialog allows backing up the current installation by
creating a zip file from the .rockbox folder since quite a while. However, this
has the drawback that you need to update your build to create a backup, but
creating a backup might be desireable in other cases as well (before updating
themes, or just for backup reasons). Since the functionality is somewhat hidden
it's also not obvious to users such a functionality exists (most users are
likely to use the "Quick Start" instead).

Implement backup functionality as dedicated dialog placed on the Uninstall tab.
Rename the Uninstall tab to accommodate this.

Change-Id: I1d2c6c8f646672d1b66bb442408fbfc2eeec700d
This commit is contained in:
Dominik Riebeling 2012-06-26 00:24:58 +02:00
parent 8cc46fb01c
commit 362f447ede
10 changed files with 376 additions and 13 deletions

View file

@ -40,6 +40,7 @@ const static struct {
{ RbSettings::OfPath, "ofpath", "" },
{ RbSettings::Platform, "platform", "" },
{ RbSettings::Language, "lang", "" },
{ RbSettings::BackupPath, "backuppath", "" },
#if defined(Q_OS_WIN32)
{ RbSettings::Tts, "tts", "sapi" },
#elif defined(Q_OS_MACX)

View file

@ -40,6 +40,7 @@ class RbSettings : public QObject
OfPath,
Platform,
Language,
BackupPath,
Tts,
UseTtsCorrections,
TalkFolders,

View file

@ -0,0 +1,141 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* Copyright (C) 2012 by Dominik Riebeling
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include <QtGui>
#include "backupdialog.h"
#include "ui_backupdialogfrm.h"
#include "rbsettings.h"
#include "progressloggergui.h"
#include "ziputil.h"
#include "rockboxinfo.h"
class BackupSizeThread : public QThread
{
public:
void run(void);
void setPath(QString p) { m_path = p; }
qint64 currentSize(void) { return m_currentSize; }
private:
QString m_path;
qint64 m_currentSize;
};
void BackupSizeThread::run(void)
{
qDebug() << "BackupSizeThread] Thread started, calculating" << m_path;
m_currentSize = 0;
QDirIterator it(m_path, QDirIterator::Subdirectories);
while(it.hasNext()) {
m_currentSize += QFileInfo(it.next()).size();
}
qDebug() << "[BackupSizeThread] Thread done, sum:" << m_currentSize;
}
BackupDialog::BackupDialog(QWidget* parent) : QDialog(parent)
{
ui.setupUi(this);
m_thread = new BackupSizeThread();
connect(m_thread, SIGNAL(finished()), this, SLOT(updateSizeInfo()));
connect(m_thread, SIGNAL(terminated()), this, SLOT(updateSizeInfo()));
connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(close()));
connect(ui.buttonCancel, SIGNAL(clicked()), m_thread, SLOT(quit()));
connect(ui.buttonChange, SIGNAL(clicked()), this, SLOT(changeBackupPath()));
connect(ui.buttonBackup, SIGNAL(clicked()), this, SLOT(backup()));
ui.backupSize->setText(tr("Installation size: calculating ..."));
m_mountpoint = RbSettings::value(RbSettings::Mountpoint).toString();
m_backupName = RbSettings::value(RbSettings::BackupPath).toString();
if(m_backupName.isEmpty()) {
m_backupName = m_mountpoint;
}
RockboxInfo info(m_mountpoint);
m_backupName += "/.backup/rockbox-backup-" + info.version() + ".zip";
ui.backupLocation->setText(QDir::toNativeSeparators(m_backupName));
m_thread->setPath(m_mountpoint + "/.rockbox");
m_thread->start();
}
void BackupDialog::changeBackupPath(void)
{
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()) {
m_backupName = backupString;
ui.backupLocation->setText(QDir::toNativeSeparators(m_backupName));
RbSettings::setValue(RbSettings::BackupPath, QFileInfo(m_backupName).absolutePath());
}
}
void BackupDialog::updateSizeInfo(void)
{
double size = m_thread->currentSize() / (1024 * 1024);
QString unit = "MiB";
if(size > 1024) {
size /= 1024;
unit = "GiB";
}
ui.backupSize->setText(tr("Installation size: %L1 %2").arg(size, 0, 'g', 4).arg(unit));
}
void BackupDialog::backup(void)
{
m_logger = new ProgressLoggerGui(this);
connect(m_logger, SIGNAL(closed()), this, SLOT(close()));
m_logger->show();
m_logger->addItem(tr("Starting backup ..."),LOGINFO);
QCoreApplication::processEvents();
// create dir, if it doesnt exist
QFileInfo backupFile(m_backupName);
if(!QDir(backupFile.path()).exists())
{
QDir a;
a.mkpath(backupFile.path());
}
// create backup
ZipUtil zip(this);
connect(&zip, SIGNAL(logProgress(int, int)), m_logger, SLOT(setProgress(int, int)));
connect(&zip, SIGNAL(logItem(QString, int)), m_logger, SLOT(addItem(QString, int)));
zip.open(m_backupName, QuaZip::mdCreate);
QString mp = m_mountpoint + "/.rockbox";
if(zip.appendDirToArchive(mp, m_mountpoint)) {
m_logger->addItem(tr("Backup successful."), LOGINFO);
}
else {
m_logger->addItem(tr("Backup failed!"), LOGERROR);
}
zip.close();
m_logger->setFinished();
}

View file

@ -0,0 +1,49 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* Copyright (C) 2012 by Dominik Riebeling
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef BACKUPDIALOG_H
#define BACKUPDIALOG_H
#include <QWidget>
#include <QDialog>
#include "ui_backupdialogfrm.h"
#include "progressloggergui.h"
class BackupSizeThread;
class BackupDialog : public QDialog
{
Q_OBJECT
public:
BackupDialog(QWidget* parent = 0);
private slots:
void changeBackupPath(void);
void updateSizeInfo(void);
void backup(void);
private:
Ui::BackupDialog ui;
QString m_backupName;
QString m_mountpoint;
BackupSizeThread *m_thread;
ProgressLoggerGui *m_logger;
};
#endif

View file

@ -0,0 +1,142 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BackupDialog</class>
<widget class="QDialog" name="BackupDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>554</width>
<height>448</height>
</rect>
</property>
<property name="windowTitle">
<string>Backup</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0" rowspan="4">
<widget class="QLabel" name="label_4">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../rbutilqt.qrc">:/icons/wizard.jpg</pixmap>
</property>
</widget>
</item>
<item row="0" column="1" colspan="3">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This dialog will create a backup by archiving the contents of the Rockbox installation on the player into a zip file. This will include installed themes and settings stored below the .rockbox folder on the player.&lt;/p&gt;&lt;p&gt;The backup filename will be created based on the installed version. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1" colspan="3">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Backup</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="backupSize">
<property name="text">
<string>Size: unknown</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="backupLocation">
<property name="text">
<string>Backup to: unknown</string>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>78</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="buttonChange">
<property name="text">
<string>&amp;Change</string>
</property>
<property name="icon">
<iconset resource="../rbutilqt.qrc">
<normaloff>:/icons/edit-find.png</normaloff>:/icons/edit-find.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="2" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="1">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>143</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="buttonBackup">
<property name="text">
<string>&amp;Backup</string>
</property>
<property name="icon">
<iconset resource="../rbutilqt.qrc">
<normaloff>:/icons/go-next.png</normaloff>:/icons/go-next.png</iconset>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QPushButton" name="buttonCancel">
<property name="text">
<string>&amp;Cancel</string>
</property>
<property name="icon">
<iconset resource="../rbutilqt.qrc">
<normaloff>:/icons/process-stop.png</normaloff>:/icons/process-stop.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>buttonBackup</tabstop>
<tabstop>buttonCancel</tabstop>
</tabstops>
<resources>
<include location="../rbutilqt.qrc"/>
</resources>
<connections/>
</ui>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 540 B

After

Width:  |  Height:  |  Size: 1.9 KiB

Before After
Before After

View file

@ -40,6 +40,7 @@
#include "ziputil.h"
#include "manualwidget.h"
#include "infowidget.h"
#include "backupdialog.h"
#include "progressloggerinterface.h"
@ -152,6 +153,7 @@ RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
connect(ui.buttonRemoveBootloader, SIGNAL(clicked()), this, SLOT(uninstallBootloader()));
connect(ui.buttonSmall, SIGNAL(clicked()), this, SLOT(smallInstall()));
connect(ui.buttonComplete, SIGNAL(clicked()), this, SLOT(completeInstall()));
connect(ui.buttonBackup, SIGNAL(clicked()), this, SLOT(backup()));
// actions accessible from the menu
connect(ui.actionComplete_Installation, SIGNAL(triggered()), this, SLOT(completeInstall()));
@ -386,6 +388,13 @@ void RbUtilQt::updateDevice()
}
void RbUtilQt::backup(void)
{
backupdialog = new BackupDialog(this);
backupdialog->show();
}
void RbUtilQt::completeInstall()
{
if(chkConfig(this)) return;

View file

@ -34,6 +34,7 @@
#include "bootloaderinstallbase.h"
#include "manualwidget.h"
#include "infowidget.h"
#include "backupdialog.h"
class RbUtilQt : public QMainWindow
{
@ -47,6 +48,7 @@ class RbUtilQt : public QMainWindow
private:
ManualWidget *manual;
InfoWidget *info;
BackupDialog *backupdialog;
Ui::RbUtilQtFrm ui;
void changeEvent(QEvent *e);
@ -106,6 +108,7 @@ class RbUtilQt : public QMainWindow
void createVoiceFile(void);
void downloadDone(bool);
void downloadInfo(void);
void backup(void);
void installVoice(void);
void installThemes(void);

View file

@ -78,6 +78,7 @@ SOURCES += \
quazip/ioapi.c \
base/ziputil.cpp \
comboboxviewdelegate.cpp \
gui/backupdialog.cpp \
HEADERS += \
@ -149,6 +150,7 @@ HEADERS += \
base/ziputil.h \
lame/lame.h \
comboboxviewdelegate.h \
gui/backupdialog.h \
FORMS += \
@ -165,7 +167,8 @@ FORMS += \
previewfrm.ui \
createvoicefrm.ui \
sysinfofrm.ui \
systracefrm.ui
systracefrm.ui \
gui/backupdialogfrm.ui \
TRANSLATIONS += \

View file

@ -282,9 +282,6 @@
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="buddy">
<cstring>buttonRockbox</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
@ -549,12 +546,12 @@
</widget>
<widget class="QWidget" name="uninstall">
<attribute name="title">
<string>&amp;Uninstallation</string>
<string>Backup &amp;&amp; &amp;Uninstallation</string>
</attribute>
<attribute name="toolTip">
<string>Uninstall Rockbox</string>
</attribute>
<layout class="QGridLayout">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QToolButton" name="buttonRemoveBootloader">
<property name="text">
@ -616,19 +613,36 @@
</widget>
</item>
<item row="2" column="0">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
<widget class="QToolButton" name="buttonBackup">
<property name="text">
<string>Backup</string>
</property>
<property name="sizeHint" stdset="0">
<property name="icon">
<iconset resource="rbutilqt.qrc">
<normaloff>:/icons/package-x-generic.png</normaloff>:/icons/package-x-generic.png</iconset>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>40</height>
<width>56</width>
<height>46</height>
</size>
</property>
</spacer>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="labelBackup">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Backup current installation.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Create a backup by archiving the contents of the Rockbox installation folder.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>