Add some accelerator keys to the Actions menu.
[Rockbox.git] / rbutil / rbutilqt / install.cpp
blobb64e1637d62a8b5562fe8bff70bb6c204f779da5
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
9 * Copyright (C) 2007 by Dominik Riebeling
10 * $Id$
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include "install.h"
21 #include "ui_installfrm.h"
23 Install::Install(QWidget *parent) : QDialog(parent)
25 ui.setupUi(this);
27 connect(ui.radioCurrent, SIGNAL(toggled(bool)), this, SLOT(setCached(bool)));
28 connect(ui.radioStable, SIGNAL(toggled(bool)), this, SLOT(setDetailsStable(bool)));
29 connect(ui.radioCurrent, SIGNAL(toggled(bool)), this, SLOT(setDetailsCurrent(bool)));
30 connect(ui.radioArchived, SIGNAL(toggled(bool)), this, SLOT(setDetailsArchived(bool)));
34 void Install::setCached(bool cache)
36 ui.checkBoxCache->setEnabled(!cache);
40 void Install::setProxy(QUrl proxy_url)
42 proxy = proxy_url;
43 qDebug() << "Install::setProxy" << proxy;
47 void Install::accept()
49 logger = new ProgressLoggerGui(this);
50 logger->show();
51 QString mountPoint = settings->mountpoint();
52 qDebug() << "mountpoint:" << settings->mountpoint();
53 // show dialog with error if mount point is wrong
54 if(!QFileInfo(mountPoint).isDir()) {
55 logger->addItem(tr("Mount point is wrong!"),LOGERROR);
56 logger->abort();
57 return;
60 QString myversion;
61 QString buildname = settings->curPlatform();
62 if(ui.radioStable->isChecked()) {
63 file = QString("%1/rockbox-%2-%3.zip")
64 .arg(settings->downloadUrl(),
65 settings->lastRelease(), buildname);
66 fileName = QString("rockbox-%1-%2.zip")
67 .arg(settings->lastRelease(), buildname);
68 settings->setBuild("stable");
69 myversion = version.value("rel_rev");
71 else if(ui.radioArchived->isChecked()) {
72 file = QString("%1%2/rockbox-%3-%4.zip")
73 .arg(settings->dailyUrl(),
74 buildname, buildname, version.value("arch_date"));
75 fileName = QString("rockbox-%1-%2.zip")
76 .arg(buildname, version.value("arch_date"));
77 settings->setBuild("archived");
78 myversion = "r" + version.value("arch_rev") + "-" + version.value("arch_date");
80 else if(ui.radioCurrent->isChecked()) {
81 file = QString("%1%2/rockbox.zip")
82 .arg(settings->bleedingUrl(), buildname);
83 fileName = QString("rockbox.zip");
84 settings->setBuild("current");
85 myversion = "r" + version.value("bleed_rev");
87 else {
88 qDebug() << "no build selected -- this shouldn't happen";
89 return;
91 settings->sync();
93 installer = new ZipInstaller(this);
94 installer->setUrl(file);
95 installer->setProxy(proxy);
96 installer->setLogSection("Rockbox (Base)");
97 if(!settings->cacheDisabled()
98 && !ui.radioCurrent->isChecked()
99 && !ui.checkBoxCache->isChecked())
100 installer->setCache(settings->cachePath());
102 installer->setLogVersion(myversion);
103 installer->setMountPoint(mountPoint);
104 installer->install(logger);
106 connect(installer, SIGNAL(done(bool)), this, SLOT(done(bool)));
110 // Zip installer has finished
111 void Install::done(bool error)
113 qDebug() << "Install::done, error:" << error;
115 if(error)
117 logger->abort();
118 return;
121 // no error, close the window, when the logger is closed
122 connect(logger,SIGNAL(closed()),this,SLOT(close()));
123 // add platform info to log file for later detection
124 QSettings installlog(settings->mountpoint()
125 + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
126 installlog.setValue("platform", settings->curPlatform());
127 installlog.sync();
131 void Install::setDetailsCurrent(bool show)
133 if(show) {
134 ui.labelDetails->setText(tr("This is the absolute up to the minute "
135 "Rockbox built. A current build will get updated every time "
136 "a change is made. Latest version is r%1 (%2).")
137 .arg(version.value("bleed_rev"), version.value("bleed_date")));
138 if(version.value("rel_rev").isEmpty())
139 ui.labelNote->setText(tr("<b>Note:</b> This option will always "
140 "download a fresh copy. "
141 "<b>This is the recommended version.</b>"));
142 else
143 ui.labelNote->setText(tr("<b>Note:</b> This option will always "
144 "download a fresh copy."));
149 void Install::setDetailsStable(bool show)
151 if(show) {
152 ui.labelDetails->setText(
153 tr("This is the last released version of Rockbox."));
155 if(!version.value("rel_rev").isEmpty())
156 ui.labelNote->setText(tr("<b>Note:</b>"
157 "The lastest released version is %1. "
158 "<b>This is the recommended version.</b>")
159 .arg(version.value("rel_rev")));
160 else ui.labelNote->setText("");
165 void Install::setDetailsArchived(bool show)
167 if(show) {
168 ui.labelDetails->setText(tr("These are automatically built each day "
169 "from the current development source code. This generally has more "
170 "features than the last stable release but may be much less stable. "
171 "Features may change regularly."));
172 ui.labelNote->setText(tr("<b>Note:</b> archived version is r%1 (%2).")
173 .arg(version.value("arch_rev"), version.value("arch_date")));
179 void Install::setVersionStrings(QMap<QString, QString> ver)
181 version = ver;
182 // version strings map is as following:
183 // rel_rev release version revision id
184 // rel_date release version release date
185 // same for arch_* and bleed_*
187 if(version.value("arch_rev").isEmpty()) {
188 ui.radioArchived->setEnabled(false);
189 qDebug() << "no information about archived version available!";
192 if(!version.value("rel_rev").isEmpty()) {
193 ui.radioStable->setChecked(true);
194 ui.radioStable->setEnabled(true);
195 QFont font;
196 font.setBold(true);
197 ui.radioStable->setFont(font);
199 else {
200 ui.radioCurrent->setChecked(true);
201 ui.radioStable->setEnabled(false);
202 ui.radioStable->setChecked(false);
203 QFont font;
204 font.setBold(true);
205 ui.radioCurrent->setFont(font);
207 qDebug() << "Install::setVersionStrings" << version;
210 void Install::setSettings(RbSettings *sett)
212 settings = sett;