Did some fast and dirty refactoring (check later that everything's ok):
[emufront] / src / mainwindow.cpp
1 #include <QtGui>
2 #include "mainwindow.h"
3 #include "dialogs/platformdialog.h"
4 #include "db/databasemanager.h"
5
6 MainWindow::MainWindow()
7 {
8     setWindowTitle("EmuFront");
9     createActions();
10     createMenus();
11     createStatusBar();
12     readSettings();
13     platformDialog = 0;
14     //dbManager = new DatabaseManager;
15 }
16
17 void MainWindow::createActions()
18 {
19     configPlatformAction = new QAction(tr("&Platforms"), this);
20     configPlatformAction->setStatusTip(tr("Configure platforms"));
21     connect(configPlatformAction, SIGNAL(triggered()),
22             this, SLOT(configurePlatforms()));
23
24     exitAction = new QAction(tr("&Exit"), this);
25     exitAction->setShortcut(tr("Ctrl+Q"));
26     exitAction->setStatusTip(tr("Exit EmuFront"));
27     connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
28 }
29
30 void MainWindow::configurePlatforms()
31 {
32    if (!platformDialog)
33    {
34        platformDialog = new PlatformDialog(this);
35    } 
36    platformDialog->show();
37    platformDialog->raise();
38    platformDialog->activateWindow();
39 }
40
41 void MainWindow::createMenus()
42 {
43     fileMenu = menuBar()->addMenu(tr("&File"));
44     fileMenu->addAction(exitAction);
45
46     configMenu = menuBar()->addMenu(tr("&Config"));
47     configMenu->addAction(configPlatformAction);
48 }
49
50 void MainWindow::createStatusBar()
51 {
52     messageLabel = new QLabel;
53     statusBar()->addWidget(messageLabel);
54 }
55
56 void MainWindow::readSettings()
57 {
58 }
59
60 void MainWindow::writeSettings()
61 {
62 }
63
64 void MainWindow::closeEvent(QCloseEvent *event)
65 {
66     if (okToContinue())
67         event->accept();
68     else event->ignore();
69 }
70
71 bool MainWindow::okToContinue()
72 {
73     return true;
74 }