1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C) 2007 by Dominik Wenger
10 * $Id: installbootloaderwindow.cpp 14027 2007-07-27 17:42:49Z domonoky $
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 "installbootloaderwindow.h"
21 #include "ui_installprogressfrm.h"
24 InstallBootloaderWindow::InstallBootloaderWindow(QWidget
*parent
) : QDialog(parent
)
27 connect(ui
.buttonBrowse
, SIGNAL(clicked()), this, SLOT(browseFolder()));
28 connect(ui
.buttonBrowseOF
, SIGNAL(clicked()), this, SLOT(browseOF()));
32 void InstallBootloaderWindow::setProxy(QUrl proxy_url
)
35 qDebug() << "Install::setProxy" << proxy
;
38 void InstallBootloaderWindow::setMountPoint(QString mount
)
42 ui
.lineMountPoint
->clear();
43 ui
.lineMountPoint
->insert(mount
);
47 void InstallBootloaderWindow::setOFPath(QString path
)
51 ui
.lineOriginalFirmware
->clear();
52 ui
.lineOriginalFirmware
->insert(path
);
56 void InstallBootloaderWindow::browseFolder()
58 QFileDialog
browser(this);
59 if(QFileInfo(ui
.lineMountPoint
->text()).isDir())
60 browser
.setDirectory(ui
.lineMountPoint
->text());
62 browser
.setDirectory("/media");
63 browser
.setReadOnly(true);
64 browser
.setFileMode(QFileDialog::DirectoryOnly
);
65 browser
.setAcceptMode(QFileDialog::AcceptOpen
);
67 qDebug() << browser
.directory();
68 QStringList files
= browser
.selectedFiles();
69 setMountPoint(files
.at(0));
73 void InstallBootloaderWindow::browseOF()
75 QFileDialog
browser(this);
76 if(QFileInfo(ui
.lineOriginalFirmware
->text()).exists())
77 browser
.setDirectory(ui
.lineOriginalFirmware
->text());
79 browser
.setDirectory("/media");
80 browser
.setReadOnly(true);
81 browser
.setAcceptMode(QFileDialog::AcceptOpen
);
83 qDebug() << browser
.directory();
84 QStringList files
= browser
.selectedFiles();
85 setOFPath(files
.at(0));
89 void InstallBootloaderWindow::accept()
92 logger
= new ProgressLoggerGui(this);
95 // show dialog with error if mount point is wrong
96 if(QFileInfo(ui
.lineMountPoint
->text()).isDir()) {
97 mountPoint
= ui
.lineMountPoint
->text();
98 userSettings
->setValue("defaults/mountpoint", mountPoint
);
101 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
106 if(QFileInfo(ui
.lineOriginalFirmware
->text()).exists())
108 m_OrigFirmware
= ui
.lineOriginalFirmware
->text();
110 else if(needextrafile
)
112 logger
->addItem(tr("Original Firmware Path is wrong!"),LOGERROR
);
116 userSettings
->sync();
118 binstaller
= new BootloaderInstaller(this);
120 binstaller
->setMountPoint(mountPoint
);
121 binstaller
->setProxy(proxy
);
122 QString plattform
= userSettings
->value("defaults/platform").toString();
124 binstaller
->setDevice(plattform
);
125 binstaller
->setBootloaderMethod(devices
->value(plattform
+ "/bootloadermethod").toString());
126 binstaller
->setBootloaderName(devices
->value(plattform
+ "/bootloadername").toString());
127 binstaller
->setBootloaderBaseUrl(devices
->value("bootloader_url").toString());
128 binstaller
->setOrigFirmwarePath(m_OrigFirmware
);
130 binstaller
->install(logger
);
132 connect(binstaller
, SIGNAL(done(bool)), this, SLOT(done(bool)));
137 void InstallBootloaderWindow::done(bool error
)
139 qDebug() << "Install::done, error:" << error
;
147 // no error, close the window, when the logger is closed
148 connect(logger
,SIGNAL(closed()),this,SLOT(close()));
152 void InstallBootloaderWindow::setDeviceSettings(QSettings
*dev
)
155 qDebug() << "Install::setDeviceSettings:" << devices
;
158 void InstallBootloaderWindow::setUserSettings(QSettings
*user
)
161 if(userSettings
->value("defaults/platform").toString() == "h100" ||
162 userSettings
->value("defaults/platform").toString() == "h120" ||
163 userSettings
->value("defaults/platform").toString() == "h300")
165 ui
.buttonBrowseOF
->show();
166 ui
.lineOriginalFirmware
->show();
168 needextrafile
= true;
172 ui
.buttonBrowseOF
->hide();
173 ui
.lineOriginalFirmware
->hide();
175 needextrafile
= false;