summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2012-06-26 00:24:58 +0200
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2012-06-26 18:30:27 +0200
commit362f447ede988023951f85f86dc3e7c609fd5014 (patch)
treecf26486dc8f62a25590a88e87f40e62645e5a5e0 /rbutil/rbutilqt
parent8cc46fb01cc86c25e580400b6c2d6cc38665843d (diff)
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
Diffstat (limited to 'rbutil/rbutilqt')
-rw-r--r--rbutil/rbutilqt/base/rbsettings.cpp1
-rw-r--r--rbutil/rbutilqt/base/rbsettings.h1
-rw-r--r--rbutil/rbutilqt/gui/backupdialog.cpp141
-rw-r--r--rbutil/rbutilqt/gui/backupdialog.h49
-rw-r--r--rbutil/rbutilqt/gui/backupdialogfrm.ui142
-rw-r--r--rbutil/rbutilqt/icons/package-x-generic.pngbin540 -> 1900 bytes
-rw-r--r--rbutil/rbutilqt/rbutilqt.cpp9
-rw-r--r--rbutil/rbutilqt/rbutilqt.h3
-rw-r--r--rbutil/rbutilqt/rbutilqt.pri5
-rw-r--r--rbutil/rbutilqt/rbutilqtfrm.ui38
10 files changed, 376 insertions, 13 deletions
diff --git a/rbutil/rbutilqt/base/rbsettings.cpp b/rbutil/rbutilqt/base/rbsettings.cpp
index f584c6808c..f6a936ab9a 100644
--- a/rbutil/rbutilqt/base/rbsettings.cpp
+++ b/rbutil/rbutilqt/base/rbsettings.cpp
@@ -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)
diff --git a/rbutil/rbutilqt/base/rbsettings.h b/rbutil/rbutilqt/base/rbsettings.h
index 45ec7092e2..21234a4e9a 100644
--- a/rbutil/rbutilqt/base/rbsettings.h
+++ b/rbutil/rbutilqt/base/rbsettings.h
@@ -40,6 +40,7 @@ class RbSettings : public QObject
OfPath,
Platform,
Language,
+ BackupPath,
Tts,
UseTtsCorrections,
TalkFolders,
diff --git a/rbutil/rbutilqt/gui/backupdialog.cpp b/rbutil/rbutilqt/gui/backupdialog.cpp
new file mode 100644
index 0000000000..5d04b322ed
--- /dev/null
+++ b/rbutil/rbutilqt/gui/backupdialog.cpp
@@ -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();
+}
+
diff --git a/rbutil/rbutilqt/gui/backupdialog.h b/rbutil/rbutilqt/gui/backupdialog.h
new file mode 100644
index 0000000000..cd5ea398d9
--- /dev/null
+++ b/rbutil/rbutilqt/gui/backupdialog.h
@@ -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
+
diff --git a/rbutil/rbutilqt/gui/backupdialogfrm.ui b/rbutil/rbutilqt/gui/backupdialogfrm.ui
new file mode 100644
index 0000000000..5de61d1e91
--- /dev/null
+++ b/rbutil/rbutilqt/gui/backupdialogfrm.ui
@@ -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>
diff --git a/rbutil/rbutilqt/icons/package-x-generic.png b/rbutil/rbutilqt/icons/package-x-generic.png
index 9015426153..6728f590e0 100644
--- a/rbutil/rbutilqt/icons/package-x-generic.png
+++ b/rbutil/rbutilqt/icons/package-x-generic.png
Binary files differ
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp
index b62167a4e7..5bce622799 100644
--- a/rbutil/rbutilqt/rbutilqt.cpp
+++ b/rbutil/rbutilqt/rbutilqt.cpp
@@ -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;
diff --git a/rbutil/rbutilqt/rbutilqt.h b/rbutil/rbutilqt/rbutilqt.h
index 67fbff78e1..3e57af589b 100644
--- a/rbutil/rbutilqt/rbutilqt.h
+++ b/rbutil/rbutilqt/rbutilqt.h
@@ -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);
diff --git a/rbutil/rbutilqt/rbutilqt.pri b/rbutil/rbutilqt/rbutilqt.pri
index 6a74a7c52f..330a3cd19a 100644
--- a/rbutil/rbutilqt/rbutilqt.pri
+++ b/rbutil/rbutilqt/rbutilqt.pri
@@ -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 += \
diff --git a/rbutil/rbutilqt/rbutilqtfrm.ui b/rbutil/rbutilqt/rbutilqtfrm.ui
index d851b19021..aae4bd4f9b 100644
--- a/rbutil/rbutilqt/rbutilqtfrm.ui
+++ b/rbutil/rbutilqt/rbutilqtfrm.ui
@@ -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>