rbutilQt: the progressloggergui now uses little icons along the text.
[Rockbox.git] / rbutil / rbutilqt / installzipwindow.cpp
blob9e4381dce061c573fa5e06f8cef147a648efb308
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
9 * Copyright (C) 2007 by Dominik Wenger
10 * $Id: installzipwindow.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 "installzipwindow.h"
21 //#include "ui_installprogressfrm.h"
24 InstallZipWindow::InstallZipWindow(QWidget *parent) : QDialog(parent)
26 ui.setupUi(this);
27 connect(ui.buttonBrowse, SIGNAL(clicked()), this, SLOT(browseFolder()));
30 void InstallZipWindow::setProxy(QUrl proxy_url)
32 proxy = proxy_url;
33 qDebug() << "Install::setProxy" << proxy;
36 void InstallZipWindow::setMountPoint(QString mount)
38 QFileInfo m(mount);
39 if(m.isDir()) {
40 ui.lineMountPoint->clear();
41 ui.lineMountPoint->insert(mount);
45 void InstallZipWindow::setUrl(QString path)
47 url = path;
50 void InstallZipWindow::browseFolder()
52 QFileDialog browser(this);
53 if(QFileInfo(ui.lineMountPoint->text()).isDir())
54 browser.setDirectory(ui.lineMountPoint->text());
55 else
56 browser.setDirectory("/media");
57 browser.setReadOnly(true);
58 browser.setFileMode(QFileDialog::DirectoryOnly);
59 browser.setAcceptMode(QFileDialog::AcceptOpen);
60 if(browser.exec()) {
61 qDebug() << browser.directory();
62 QStringList files = browser.selectedFiles();
63 setMountPoint(files.at(0));
67 void InstallZipWindow::accept()
69 // create logger
70 logger = new ProgressLoggerGui(this);
71 logger->show();
73 // show dialog with error if mount point is wrong
74 if(QFileInfo(ui.lineMountPoint->text()).isDir()) {
75 mountPoint = ui.lineMountPoint->text();
76 userSettings->setValue("defaults/mountpoint", mountPoint);
78 else {
79 logger->addItem(tr("Mount point is wrong!"),LOGERROR);
80 logger->abort();
81 return;
84 userSettings->sync();
86 // create Zip installer
87 installer = new ZipInstaller(this);
89 QString fileName = url.section('/', -1);
90 installer->setFilename(fileName);
91 installer->setUrl(url);
92 installer->setProxy(proxy);
93 installer->setLogSection(logsection);
94 installer->setMountPoint(mountPoint);
95 installer->install(logger);
97 connect(installer, SIGNAL(done(bool)), this, SLOT(done(bool)));
102 // we are done with Zip installing
103 void InstallZipWindow::done(bool error)
105 qDebug() << "Install::done, error:" << error;
107 if(error) // if there was an error
109 logger->abort();
110 return;
113 // no error, close the window, when the logger is closed
114 connect(logger,SIGNAL(closed()),this,SLOT(close()));
117 void InstallZipWindow::setDeviceSettings(QSettings *dev)
119 devices = dev;
120 qDebug() << "Install::setDeviceSettings:" << devices;
123 void InstallZipWindow::setUserSettings(QSettings *user)
125 userSettings = user;