Cleaning up here and there
[emufront] / src / mainwindow.cpp
1 // EmuFront
2 // Copyright 2010 Mikko Keinänen
3 //
4 // This file is part of EmuFront.
5 //
6 //
7 // EmuFront is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // Foobar is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
19
20 #include <QtGui>
21 #include "mainwindow.h"
22 #include "dialogs/platformdialog.h"
23 #include "db/databasemanager.h"
24
25 MainWindow::MainWindow()
26 {
27     setWindowTitle("EmuFront");
28     createActions();
29     createMenus();
30     createStatusBar();
31     readSettings();
32     platformDialog = 0;
33 }
34
35 void MainWindow::createActions()
36 {
37     configPlatformAction = new QAction(tr("&Platforms"), this);
38     configPlatformAction->setStatusTip(tr("Configure platforms"));
39     connect(configPlatformAction, SIGNAL(triggered()),
40             this, SLOT(configurePlatforms()));
41
42     exitAction = new QAction(tr("&Exit"), this);
43     exitAction->setShortcut(tr("Ctrl+Q"));
44     exitAction->setStatusTip(tr("Exit EmuFront"));
45     connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
46 }
47
48 void MainWindow::configurePlatforms()
49 {
50    if (!platformDialog)
51    {
52        platformDialog = new PlatformDialog(this);
53    } 
54    platformDialog->show();
55    platformDialog->raise();
56    platformDialog->activateWindow();
57 }
58
59 void MainWindow::createMenus()
60 {
61     fileMenu = menuBar()->addMenu(tr("&File"));
62     fileMenu->addAction(exitAction);
63
64     configMenu = menuBar()->addMenu(tr("&Config"));
65     configMenu->addAction(configPlatformAction);
66 }
67
68 void MainWindow::createStatusBar()
69 {
70     messageLabel = new QLabel;
71     statusBar()->addWidget(messageLabel);
72 }
73
74 void MainWindow::readSettings()
75 {
76 }
77
78 void MainWindow::writeSettings()
79 {
80 }
81
82 void MainWindow::closeEvent(QCloseEvent *event)
83 {
84     if (okToContinue())
85         event->accept();
86     else event->ignore();
87 }
88
89 bool MainWindow::okToContinue()
90 {
91     return true;
92 }