Added license information
[emufront] / src / mainwindow.cpp
1 // EmuFront
2 // Copyright Mikko Keinänen 2010
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     //dbManager = new DatabaseManager;
34 }
35
36 void MainWindow::createActions()
37 {
38     configPlatformAction = new QAction(tr("&Platforms"), this);
39     configPlatformAction->setStatusTip(tr("Configure platforms"));
40     connect(configPlatformAction, SIGNAL(triggered()),
41             this, SLOT(configurePlatforms()));
42
43     exitAction = new QAction(tr("&Exit"), this);
44     exitAction->setShortcut(tr("Ctrl+Q"));
45     exitAction->setStatusTip(tr("Exit EmuFront"));
46     connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
47 }
48
49 void MainWindow::configurePlatforms()
50 {
51    if (!platformDialog)
52    {
53        platformDialog = new PlatformDialog(this);
54    } 
55    platformDialog->show();
56    platformDialog->raise();
57    platformDialog->activateWindow();
58 }
59
60 void MainWindow::createMenus()
61 {
62     fileMenu = menuBar()->addMenu(tr("&File"));
63     fileMenu->addAction(exitAction);
64
65     configMenu = menuBar()->addMenu(tr("&Config"));
66     configMenu->addAction(configPlatformAction);
67 }
68
69 void MainWindow::createStatusBar()
70 {
71     messageLabel = new QLabel;
72     statusBar()->addWidget(messageLabel);
73 }
74
75 void MainWindow::readSettings()
76 {
77 }
78
79 void MainWindow::writeSettings()
80 {
81 }
82
83 void MainWindow::closeEvent(QCloseEvent *event)
84 {
85     if (okToContinue())
86         event->accept();
87     else event->ignore();
88 }
89
90 bool MainWindow::okToContinue()
91 {
92     return true;
93 }