Minor formatting tidying up.
[qwerkisync] / Windows / BaseWindow.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 "BaseWindow.h"
20
21 #include <QtGui>
22
23 using namespace Windows;
24
25 BaseWindow::BaseWindow(Settings& settings, QWidget *parent) :
26         QMainWindow(parent),
27         m_Settings(settings),
28         m_Parent(parent)
29 {
30         setWindowIcon(QIcon(":/resources/sphone.png"));
31
32 #ifdef Q_WS_MAEMO_5
33         this->setAttribute(Qt::WA_Maemo5StackedWindow, true);
34         this->setAttribute(Qt::WA_Maemo5AutoOrientation, true);
35 #endif
36         this->setAttribute(Qt::WA_DeleteOnClose);
37         this->setWindowTitle("QwerkiSync");
38         this->setWindowIcon(QIcon(":/resources/sphone.png"));
39
40         CreateActions();
41         CreateMenus();
42         CreateContents();
43 }
44
45 BaseWindow::~BaseWindow()
46 {
47 }
48
49 void BaseWindow::closeEvent(QCloseEvent *)
50 {
51         if(Parent() != NULL && CurrentSettings().IsConfirmed())
52                 Parent()->close();
53 }
54
55 void BaseWindow::CreateMenus()
56 {
57         m_HelpMenu = menuBar()->addMenu(tr("&Help"));
58         m_HelpMenu->addAction(m_AboutAct);
59         m_HelpMenu->addAction(m_AboutQtAct);
60 }
61
62 void BaseWindow::CreateActions()
63 {
64         m_AboutAct = new QAction(QIcon(":/resources/sphone.png"), tr("&About"), this);
65         m_AboutAct->setStatusTip(tr("Show the application's About box"));
66         m_AboutAct->setIconVisibleInMenu(true);
67         connect(m_AboutAct, SIGNAL(triggered()), this, SLOT(About()));
68
69         m_AboutQtAct = new QAction(tr("&About Qt"), this);
70         m_AboutQtAct->setStatusTip(tr("Qt"));
71         connect(m_AboutQtAct, SIGNAL(triggered()), this, SLOT(AboutQt()));
72 }
73
74 void BaseWindow::CreateContents()
75 {
76         QWidget *central = new QWidget(this);
77         setCentralWidget(central);
78 }
79
80 void BaseWindow::About()
81 {
82         QMessageBox::about(this, "about", "about me");
83 }
84
85 void BaseWindow::AboutQt()
86 {
87         QMessageBox::aboutQt(this, tr("About Qt"));
88 }