Minor formatting tidying up.
[qwerkisync] / Windows / ProgressWindow.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 "ProgressWindow.h"
20
21 #include "SyncerThread.h"
22
23 #include <QProgressBar>
24 #include <QVBoxLayout>
25 #include <QWidget>
26
27 using namespace Windows;
28
29 ProgressWindow::ProgressWindow(Settings& settings, SyncerThread* syncThread, QWidget *parent) :
30                 BaseWindow(settings, parent)
31 {
32         CreateContents(syncThread);
33 }
34
35 void ProgressWindow::CreateContents(SyncerThread* syncThread)
36 {
37         switch(CurrentSettings().AppMode())
38         {
39                 case Settings::APPMODE_GUI:
40                 {
41                         QVBoxLayout *layout = new QVBoxLayout();
42                         {
43                 //              QLabel* lblTest = new QLabel(CurrentSettings().Directory());
44                 //              layout->addWidget(lblTest);
45                 //              //layout->setAlignment(lblTest, Qt::AlignHCenter | Qt::AlignTop);
46
47                                 m_ProgressBar = new QProgressBar(this);
48                                 QObject::connect(syncThread, SIGNAL(EventProcessed(int,int)), this, SLOT(UpdateBar(int,int)));
49                                 layout->addWidget(m_ProgressBar);
50                                 //layout->setAlignment(btnChoose, Qt::AlignHCenter);
51
52                 //              layout->addWidget(new QLabel());
53
54                                 centralWidget()->setLayout(layout);
55                         }
56
57                         break;
58                 }
59
60                 case Settings::APPMODE_CONSOLE:
61                 {
62                         break;
63                 }
64         }
65 }
66
67 void ProgressWindow::UpdateBar(int message, int total)
68 {
69         m_ProgressBar->setMaximum(total);
70         m_ProgressBar->setValue(message);
71 }
72
73 void ProgressWindow::Advance()
74 {
75         close();
76 }