diff options
Diffstat (limited to 'rbutil/rbutilqt/install.cpp')
-rw-r--r-- | rbutil/rbutilqt/install.cpp | 69 |
1 files changed, 55 insertions, 14 deletions
diff --git a/rbutil/rbutilqt/install.cpp b/rbutil/rbutilqt/install.cpp index 4461a6a633..e9f1f61837 100644 --- a/rbutil/rbutilqt/install.cpp +++ b/rbutil/rbutilqt/install.cpp | |||
@@ -20,15 +20,31 @@ | |||
20 | #include "install.h" | 20 | #include "install.h" |
21 | #include "ui_installfrm.h" | 21 | #include "ui_installfrm.h" |
22 | #include "rbzip.h" | 22 | #include "rbzip.h" |
23 | #include "utils.h" | ||
23 | 24 | ||
24 | Install::Install(QWidget *parent) : QDialog(parent) | 25 | Install::Install(RbSettings *sett,QWidget *parent) : QDialog(parent) |
25 | { | 26 | { |
27 | settings = sett; | ||
26 | ui.setupUi(this); | 28 | ui.setupUi(this); |
27 | 29 | ||
28 | connect(ui.radioCurrent, SIGNAL(toggled(bool)), this, SLOT(setCached(bool))); | 30 | connect(ui.radioCurrent, SIGNAL(toggled(bool)), this, SLOT(setCached(bool))); |
29 | connect(ui.radioStable, SIGNAL(toggled(bool)), this, SLOT(setDetailsStable(bool))); | 31 | connect(ui.radioStable, SIGNAL(toggled(bool)), this, SLOT(setDetailsStable(bool))); |
30 | connect(ui.radioCurrent, SIGNAL(toggled(bool)), this, SLOT(setDetailsCurrent(bool))); | 32 | connect(ui.radioCurrent, SIGNAL(toggled(bool)), this, SLOT(setDetailsCurrent(bool))); |
31 | 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())); | ||
35 | |||
36 | //! check if rockbox is already installed | ||
37 | QString version = installedVersion(settings->mountpoint()); | ||
38 | |||
39 | if(version != "") | ||
40 | { | ||
41 | ui.Backupgroup->show(); | ||
42 | ui.backupLocation->setText(settings->mountpoint() + ".backup/rockbox-backup-"+version+".zip"); | ||
43 | } | ||
44 | else | ||
45 | { | ||
46 | ui.Backupgroup->hide(); | ||
47 | } | ||
32 | } | 48 | } |
33 | 49 | ||
34 | 50 | ||
@@ -84,17 +100,32 @@ void Install::accept() | |||
84 | } | 100 | } |
85 | settings->sync(); | 101 | settings->sync(); |
86 | 102 | ||
87 | //! check if rockbox is already installed | 103 | //! check if we should backup |
88 | if(QDir(settings->mountpoint() + "/.rockbox").exists()) | 104 | if(ui.backup->isChecked()) |
89 | { | 105 | { |
90 | if(QMessageBox::question(this, tr("Installed Rockbox detected"), | 106 | logger->addItem(tr("Beginning Backup..."),LOGINFO); |
91 | tr("Rockbox installation detected. Do you want to backup first?"), | 107 | QString backupName = ui.backupLocation->text(); |
92 | QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) | 108 | |
109 | //! create dir, if it doesnt exist | ||
110 | QFileInfo backupFile(backupName); | ||
111 | if(!QDir(backupFile.path()).exists()) | ||
112 | { | ||
113 | QDir a; | ||
114 | a.mkpath(backupFile.path()); | ||
115 | } | ||
116 | |||
117 | //! create backup | ||
118 | RbZip backup; | ||
119 | connect(&backup,SIGNAL(zipProgress(int,int)),this,SLOT(updateDataReadProgress(int,int))); | ||
120 | if(backup.createZip(backupName,settings->mountpoint() + "/.rockbox") == Zip::Ok) | ||
121 | { | ||
122 | logger->addItem(tr("Backup successfull"),LOGOK); | ||
123 | } | ||
124 | else | ||
93 | { | 125 | { |
94 | QString backupName = QFileDialog::getSaveFileName(this,"Select Backup Filename",settings->mountpoint()); | 126 | logger->addItem(tr("Backup failed!"),LOGERROR); |
95 | logger->show(); | 127 | logger->abort(); |
96 | RbZip backup; | 128 | return; |
97 | backup.createZip(backupName,settings->mountpoint() + "/.rockbox",logger); | ||
98 | } | 129 | } |
99 | } | 130 | } |
100 | 131 | ||
@@ -116,6 +147,19 @@ void Install::accept() | |||
116 | 147 | ||
117 | } | 148 | } |
118 | 149 | ||
150 | void Install::changeBackupPath() | ||
151 | { | ||
152 | ui.backupLocation->setText(QFileDialog::getSaveFileName(this,"Select Backup Filename",ui.backupLocation->text())); | ||
153 | } | ||
154 | |||
155 | void Install::updateDataReadProgress(int read, int total) | ||
156 | { | ||
157 | logger->setProgressMax(total); | ||
158 | logger->setProgressValue(read); | ||
159 | //qDebug() << "progress:" << read << "/" << total; | ||
160 | |||
161 | } | ||
162 | |||
119 | // Zip installer has finished | 163 | // Zip installer has finished |
120 | void Install::done(bool error) | 164 | void Install::done(bool error) |
121 | { | 165 | { |
@@ -216,7 +260,4 @@ void Install::setVersionStrings(QMap<QString, QString> ver) | |||
216 | qDebug() << "Install::setVersionStrings" << version; | 260 | qDebug() << "Install::setVersionStrings" << version; |
217 | } | 261 | } |
218 | 262 | ||
219 | void Install::setSettings(RbSettings *sett) | 263 | |
220 | { | ||
221 | settings = sett; | ||
222 | } | ||