1/****************************************************************************
2**
3** Copyright (C) 2008 Ralf Habacker <ralf.habacker@freenet.de>
4** All rights reserved.
5**
6** This file is part of the KDE installer for windows
7**
8** This file may be used under the terms of the GNU General Public
9** License version 2.0 as published by the Free Software Foundation
10** and appearing in the file LICENSE.GPL included in the packaging of
11** this file. Please review the following information to ensure GNU
12** General Public Licensing requirements will be met:
13** http://www.trolltech.com/products/qt/opensource.html
14**
15** If you are unsure which license is appropriate for your use, please
16** review the following information:
17** http://www.trolltech.com/products/qt/licensing.html or contact the
18** sales department at sales@trolltech.com.
19**
20** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
21** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22**
23****************************************************************************/
24
25#include "downloadsettingspage.h"
26
27#include <QFileDialog>
28#include <QMessageBox>
29
30DownloadSettingsPage::DownloadSettingsPage() : InstallWizardPage(0)
31{
32 ui.setupUi(this);
33 setTitle(windowTitle());
34 setSubTitle(statusTip());
35
36 connect( ui.tempPathSelect,SIGNAL(clicked()),this,SLOT(tempPathSelectClicked()) );
37}
38
39void DownloadSettingsPage::initializePage()
40{
41 Settings &s = Settings::instance();
42 ui.tempPathEdit->setText(s.downloadDir());
43}
44
45bool DownloadSettingsPage::validatePage()
46{
47 Settings &s = Settings::instance();
48 QFileInfo fi(ui.tempPathEdit->text());
49 if (!fi.isWritable())
50 {
51 QMessageBox::critical(this,
52 tr("Error"),
53 tr("You do not have write permissions on the selected download directory."),
54 QMessageBox::Ok);
55 return false;
56 }
57 s.setDownloadDir(ui.tempPathEdit->text());
58 return true;
59}
60
61bool DownloadSettingsPage::isComplete()
62{
63 return !ui.tempPathEdit->text().isEmpty();
64}
65
66void DownloadSettingsPage::tempPathSelectClicked()
67{
68 QString fileName = QFileDialog::getExistingDirectory(this,
69 tr("Select Package Download Directory"),
70 "",
71 QFileDialog::ShowDirsOnly| QFileDialog::DontResolveSymlinks);
72 if(!fileName.isEmpty())
73 ui.tempPathEdit->setText(QDir::toNativeSeparators(fileName));
74}
75