2 * Copyright (C) 2011, Jamie Thompson
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.
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.
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/>.
19 #include "Windows/ModeWindow.h"
20 #include "Windows/TypesWindow.h"
21 #include "Windows/ProgressWindow.h"
23 #include "SyncerThread.h"
27 using namespace Windows;
29 ModeWindow::ModeWindow(Settings& settings, QWidget *parent) :
30 BaseWindow(settings, parent)
35 void ModeWindow::CreateContents()
37 switch(CurrentSettings().AppMode())
39 case Settings::APPMODE_GUI:
41 QVBoxLayout *layout = new QVBoxLayout();
43 QLabel* lblTest = new QLabel(CurrentSettings().Directory());
44 layout->addWidget(lblTest);
45 //layout->setAlignment(lblTest, Qt::AlignHCenter | Qt::AlignTop);
47 QPushButton* btnImport = new QPushButton(QIcon(":/resources/sphone.png"), "Import");
48 QObject::connect(btnImport, SIGNAL(clicked()), this, SLOT(Import()));
49 layout->addWidget(btnImport);
50 layout->setAlignment(btnImport, Qt::AlignHCenter);
52 QPushButton* btnExport = new QPushButton(QIcon(":/resources/sphone.png"), "Export");
53 QObject::connect(btnExport, SIGNAL(clicked()), this, SLOT(Export()));
54 layout->addWidget(btnExport);
55 layout->setAlignment(btnExport, Qt::AlignHCenter);
57 layout->addWidget(new QLabel());
59 centralWidget()->setLayout(layout);
65 case Settings::APPMODE_CONSOLE:
75 void ModeWindow::Import()
77 CurrentSettings().setMode(Settings::MODE_IMPORT);
78 CurrentSettings().setDirectory("IMPORT");
82 void ModeWindow::Export()
84 CurrentSettings().setMode(Settings::MODE_EXPORT);
85 CurrentSettings().setDirectory("EXPORT");
89 void ModeWindow::Advance()
91 QWidget* next = new TypesWindow(CurrentSettings(), this);
95 void ModeWindow::closeEvent(QCloseEvent *)
97 if(CurrentSettings().IsConfirmed())
99 SyncerThread* tSync = new SyncerThread(CurrentSettings());
100 QWidget* progressWindow = new ProgressWindow(CurrentSettings(), tSync);
101 progressWindow->show();