Minor formatting tidying up.
[qwerkisync] / Windows / DirectoryWindow.cpp
1 /*
2  * Copyright (C) 2011, Jamie Thompson
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public
6  * License as published by the Free Software Foundation; either
7  * version 3 of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public
15  * License along with this program; If not, see
16  * <http://www.gnu.org/licenses/>.
17  */
18
19 #include "DirectoryWindow.h"
20
21 #include <QtGui>
22
23 using namespace Windows;
24
25 DirectoryWindow::DirectoryWindow(Settings& settings, QWidget *parent) :
26                 BaseWindow(settings, parent)
27 {
28         CreateContents();
29 }
30
31 void DirectoryWindow::CreateContents()
32 {
33         switch(CurrentSettings().AppMode())
34         {
35                 case Settings::APPMODE_GUI:
36                 {
37                         QVBoxLayout *layout = new QVBoxLayout();
38                         {
39                 //              QLabel* lblTest = new QLabel(CurrentSettings().Directory());
40                 //              layout->addWidget(lblTest);
41                 //              //layout->setAlignment(lblTest, Qt::AlignHCenter | Qt::AlignTop);
42
43                                 QPushButton* btnChoose = new QPushButton(QIcon(":/resources/sphone.png"), tr("Choose data directory"));
44                                 QObject::connect(btnChoose, SIGNAL(clicked()), this, SLOT(Choose()));
45                                 layout->addWidget(btnChoose);
46                                 layout->setAlignment(btnChoose, Qt::AlignHCenter);
47
48                 //              layout->addWidget(new QLabel());
49
50                                 centralWidget()->setLayout(layout);
51                         }
52
53                         break;
54                 }
55
56                 case Settings::APPMODE_CONSOLE:
57                 {
58                         // Process args.
59
60                         Advance();
61                         break;
62                 }
63         }
64 }
65
66 void DirectoryWindow::Choose()
67 {
68         CurrentSettings().setDirectory(QFileDialog::getExistingDirectory(
69                 this,
70                 "Data directory",
71                 QDir::homePath() + "/MyDocs",
72                 QFileDialog::ShowDirsOnly ));
73 //      if(CurrentSettings().Mode() == Settings::MODE_IMPORT)
74 //              CurrentSettings().setDirectory(QDir::homePath() + "/MyDocs/sms/");
75 //      else
76 //              CurrentSettings().setDirectory(QDir::homePath() + "/MyDocs/tmp/");
77         Advance();
78 }
79
80 void DirectoryWindow::Advance()
81 {
82         CurrentSettings().setConfirmed(true);
83         close();
84 }