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)));
31 connect(ui
.buttonBrowse
, SIGNAL(clicked()), this, SLOT(browseFolder()));
35 void Install::setCached(bool cache
)
37 ui
.checkBoxCache
->setEnabled(!cache
);
41 void Install::setReleased(QString rel
)
45 ui
.radioStable
->setChecked(true);
46 ui
.radioStable
->setEnabled(true);
49 ui
.radioStable
->setFont(font
);
52 ui
.radioCurrent
->setChecked(true);
53 ui
.radioStable
->setEnabled(false);
54 ui
.radioStable
->setChecked(false);
57 ui
.radioCurrent
->setFont(font
);
59 qDebug() << "Install::setReleased" << releasever
;
64 void Install::setProxy(QUrl proxy_url
)
67 qDebug() << "Install::setProxy" << proxy
;
71 void Install::setMountPoint(QString mount
)
75 ui
.lineMountPoint
->setText(mount
);
79 void Install::browseFolder()
81 QFileDialog
browser(this);
82 if(QFileInfo(ui
.lineMountPoint
->text()).isDir())
83 browser
.setDirectory(ui
.lineMountPoint
->text());
85 browser
.setDirectory("/media");
86 browser
.setReadOnly(true);
87 browser
.setFileMode(QFileDialog::DirectoryOnly
);
88 browser
.setAcceptMode(QFileDialog::AcceptOpen
);
90 qDebug() << browser
.directory();
91 QStringList files
= browser
.selectedFiles();
92 setMountPoint(files
.at(0));
97 void Install::accept()
99 logger
= new ProgressLoggerGui(this);
102 // show dialog with error if mount point is wrong
103 if(QFileInfo(ui
.lineMountPoint
->text()).isDir()) {
104 mountPoint
= ui
.lineMountPoint
->text();
105 userSettings
->setValue("defaults/mountpoint", mountPoint
);
108 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
113 if(ui
.radioStable
->isChecked()) {
114 file
= "stable"; // FIXME: this is wrong!
115 fileName
= QString("rockbox.zip");
116 userSettings
->setValue("defaults/build", "stable");
118 else if(ui
.radioArchived
->isChecked()) {
119 file
= QString("%1%2/rockbox-%3-%4.zip")
120 .arg(devices
->value("daily_url").toString(),
121 userSettings
->value("defaults/platform").toString(),
122 userSettings
->value("defaults/platform").toString(),
124 fileName
= QString("rockbox-%1-%2.zip")
125 .arg(userSettings
->value("defaults/platform").toString(),
127 userSettings
->setValue("defaults/build", "archived");
129 else if(ui
.radioCurrent
->isChecked()) {
130 file
= QString("%1%2/rockbox.zip")
131 .arg(devices
->value("bleeding_url").toString(),
132 userSettings
->value("defaults/platform").toString());
133 fileName
= QString("rockbox.zip");
134 userSettings
->setValue("defaults/build", "current");
137 qDebug() << "no build selected -- this shouldn't happen";
140 userSettings
->sync();
142 installer
= new ZipInstaller(this);
143 installer
->setFilename(fileName
);
144 installer
->setUrl(file
);
145 installer
->setProxy(proxy
);
146 installer
->setLogSection("rockboxbase");
147 installer
->setMountPoint(mountPoint
);
148 installer
->install(logger
);
150 connect(installer
, SIGNAL(done(bool)), this, SLOT(done(bool)));
154 // Zip installer has finished
155 void Install::done(bool error
)
157 qDebug() << "Install::done, error:" << error
;
165 // no error, close the window, when the logger is closed
166 connect(logger
,SIGNAL(closed()),this,SLOT(close()));
171 void Install::setDetailsCurrent(bool show
)
174 ui
.labelDetails
->setText(tr("This is the absolute up to the minute "
175 "Rockbox built. A current build will get updated every time "
176 "a change is made."));
178 ui
.labelNote
->setText(tr("<b>Note:</b> This option will always "
179 "download a fresh copy. "
180 "<b>This is the recommended version.</b>"));
182 ui
.labelNote
->setText(tr("<b>Note:</b> This option will always "
183 "download a fresh copy."));
188 void Install::setDetailsStable(bool show
)
191 ui
.labelDetails
->setText(
192 tr("This is the last released version of Rockbox."));
194 if(releasever
!= "") ui
.labelNote
->setText(tr("<b>Note:</b>"
195 "The lastest released version is %1. "
196 "<b>This is the recommended version.</b>").arg(releasever
));
197 else ui
.labelNote
->setText("");
202 void Install::setDetailsArchived(bool show
)
205 ui
.labelDetails
->setText(tr("These are automatically built each day "
206 "from the current development source code. This generally has more "
207 "features than the last release but may be much less stable. "
208 "Features may change regularly."));
209 ui
.labelNote
->setText(tr("<b>Note:</b> archived version is %1.")
215 void Install::setDeviceSettings(QSettings
*dev
)
218 qDebug() << "Install::setDeviceSettings:" << devices
;
222 void Install::setArchivedString(QString string
)
225 if(archived
.isEmpty()) {
226 ui
.radioArchived
->setEnabled(false);
227 qDebug() << "no information about archived version available!";
229 qDebug() << "Install::setArchivedString" << archived
;
232 void Install::setUserSettings(QSettings
*user
)