1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C) 2007 by Dominik Riebeling
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 ****************************************************************************/
21 #include "ui_installfrm.h"
23 Install::Install(QWidget
*parent
) : QDialog(parent
)
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
)
43 qDebug() << "Install::setProxy" << proxy
;
47 void Install::accept()
49 logger
= new ProgressLoggerGui(this);
51 QString mountPoint
= userSettings
->value("defaults/mountpoint").toString();
52 qDebug() << "mountpoint:" << userSettings
->value("defaults/mountpoint").toString();
53 // show dialog with error if mount point is wrong
54 if(!QFileInfo(mountPoint
).isDir()) {
55 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
61 if(ui
.radioStable
->isChecked()) {
62 file
= QString("%1/rockbox-%2-%3.zip")
63 .arg(devices
->value("download_url").toString(),
64 devices
->value("last_release").toString(),
65 userSettings
->value("defaults/platform").toString());
66 fileName
= QString("rockbox-%1-%2.zip")
67 .arg(devices
->value("last_release").toString(),
68 userSettings
->value("defaults/platform").toString());
69 userSettings
->setValue("defaults/build", "stable");
70 myversion
= version
.value("rel_rev");
72 else if(ui
.radioArchived
->isChecked()) {
73 file
= QString("%1%2/rockbox-%3-%4.zip")
74 .arg(devices
->value("daily_url").toString(),
75 userSettings
->value("defaults/platform").toString(),
76 userSettings
->value("defaults/platform").toString(),
77 version
.value("arch_date"));
78 fileName
= QString("rockbox-%1-%2.zip")
79 .arg(userSettings
->value("defaults/platform").toString(),
80 version
.value("arch_date"));
81 userSettings
->setValue("defaults/build", "archived");
82 myversion
= "r" + version
.value("arch_rev") + "-" + version
.value("arch_date");
84 else if(ui
.radioCurrent
->isChecked()) {
85 file
= QString("%1%2/rockbox.zip")
86 .arg(devices
->value("bleeding_url").toString(),
87 userSettings
->value("defaults/platform").toString());
88 fileName
= QString("rockbox.zip");
89 userSettings
->setValue("defaults/build", "current");
90 myversion
= "r" + version
.value("bleed_rev");
93 qDebug() << "no build selected -- this shouldn't happen";
98 installer
= new ZipInstaller(this);
99 installer
->setUrl(file
);
100 installer
->setProxy(proxy
);
101 installer
->setLogSection("rockboxbase");
102 if(!userSettings
->value("defaults/cachedisable").toBool())
103 installer
->setCache(userSettings
->value("defaults/cachepath", QDir::tempPath()).toString());
104 installer
->setLogVersion(myversion
);
105 installer
->setMountPoint(mountPoint
);
106 installer
->install(logger
);
108 connect(installer
, SIGNAL(done(bool)), this, SLOT(done(bool)));
112 // Zip installer has finished
113 void Install::done(bool error
)
115 qDebug() << "Install::done, error:" << error
;
123 // no error, close the window, when the logger is closed
124 connect(logger
,SIGNAL(closed()),this,SLOT(close()));
129 void Install::setDetailsCurrent(bool show
)
132 ui
.labelDetails
->setText(tr("This is the absolute up to the minute "
133 "Rockbox built. A current build will get updated every time "
134 "a change is made. Latest version is r%1 (%2).")
135 .arg(version
.value("bleed_rev"), version
.value("bleed_date")));
136 if(version
.value("rel_rev").isEmpty())
137 ui
.labelNote
->setText(tr("<b>Note:</b> This option will always "
138 "download a fresh copy. "
139 "<b>This is the recommended version.</b>"));
141 ui
.labelNote
->setText(tr("<b>Note:</b> This option will always "
142 "download a fresh copy."));
147 void Install::setDetailsStable(bool show
)
150 ui
.labelDetails
->setText(
151 tr("This is the last released version of Rockbox."));
153 if(!version
.value("rel_rev").isEmpty())
154 ui
.labelNote
->setText(tr("<b>Note:</b>"
155 "The lastest released version is %1. "
156 "<b>This is the recommended version.</b>")
157 .arg(version
.value("rel_rev")));
158 else ui
.labelNote
->setText("");
163 void Install::setDetailsArchived(bool show
)
166 ui
.labelDetails
->setText(tr("These are automatically built each day "
167 "from the current development source code. This generally has more "
168 "features than the last release but may be much less stable. "
169 "Features may change regularly."));
170 ui
.labelNote
->setText(tr("<b>Note:</b> archived version is r%1 (%2).")
171 .arg(version
.value("arch_rev"), version
.value("arch_date")));
176 void Install::setDeviceSettings(QSettings
*dev
)
179 qDebug() << "Install::setDeviceSettings:" << devices
;
183 void Install::setVersionStrings(QMap
<QString
, QString
> ver
)
186 // version strings map is as following:
187 // rel_rev release version revision id
188 // rel_date release version release date
189 // same for arch_* and bleed_*
191 if(version
.value("arch_rev").isEmpty()) {
192 ui
.radioArchived
->setEnabled(false);
193 qDebug() << "no information about archived version available!";
196 if(!version
.value("rel_rev").isEmpty()) {
197 ui
.radioStable
->setChecked(true);
198 ui
.radioStable
->setEnabled(true);
201 ui
.radioStable
->setFont(font
);
204 ui
.radioCurrent
->setChecked(true);
205 ui
.radioStable
->setEnabled(false);
206 ui
.radioStable
->setChecked(false);
209 ui
.radioCurrent
->setFont(font
);
211 qDebug() << "Install::setVersionStrings" << version
;
214 void Install::setUserSettings(QSettings
*user
)