2 // Copyright 2010 Mikko Keinänen
4 // This file is part of EmuFront.
7 // EmuFront is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License version 2 as published by
9 // the Free Software Foundation and appearing in the file gpl.txt included in the
10 // packaging of this file.
12 // EmuFront 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.
17 // You should have received a copy of the GNU General Public License
18 // along with EmuFront. If not, see <http://www.gnu.org/licenses/>.
21 #include "mainwindow.h"
22 #include "emulauncher.h"
23 #include "dialogs/platformdialog.h"
24 #include "dialogs/mediatypedialog.h"
25 #include "dialogs/mediaimagepathmaindialog.h"
26 #include "dialogs/setupmaindialog.h"
27 #include "dialogs/executablemaindialog.h"
28 #include "db/databasemanager.h"
30 MainWindow::MainWindow()
32 setWindowTitle("EmuFront");
33 launcher = new EmuLauncher(this);
34 setCentralWidget(launcher);
41 mediaImagePathDialog = 0;
43 executableMainDialog = 0;
46 void MainWindow::createActions()
48 configPlatformAction = new QAction(tr("&Platforms"), this);
49 configPlatformAction->setStatusTip(tr("Configure platforms"));
50 connect(configPlatformAction, SIGNAL(triggered()),
51 this, SLOT(configurePlatforms()));
53 configMediaTypeAction = new QAction(tr("&Media Types"), this);
54 configMediaTypeAction->setStatusTip(tr("Configure media types"));
55 connect(configMediaTypeAction, SIGNAL(triggered()), this, SLOT(configureMediaTypes()));
57 configMediaImagePathAction = new QAction(tr("Media &Image Paths"), this);
58 configMediaImagePathAction->setStatusTip(tr("Configure media image file paths."));
59 connect(configMediaImagePathAction, SIGNAL(triggered()),
60 this, SLOT(configureMediaImagePaths()));
62 configSetupAction = new QAction(tr("S&etups"), this);
63 configSetupAction->setStatusTip(tr("Configure set ups"));
64 connect(configSetupAction, SIGNAL(triggered()), this, SLOT(configureSetups()));
66 configEmulatorAction = new QAction(tr("Em&ulators"), this);
67 configEmulatorAction->setStatusTip(tr("Configure emulators"));
68 connect(configEmulatorAction, SIGNAL(triggered()), this, SLOT(configureEmulators()));
70 exitAction = new QAction(tr("&Exit"), this);
71 exitAction->setShortcut(tr("Ctrl+Q"));
72 exitAction->setStatusTip(tr("Exit EmuFront"));
73 connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
76 void MainWindow::configurePlatforms()
80 platformDialog = new PlatformDialog(this);
82 activateDialog(platformDialog);
85 void MainWindow::configureMediaTypes()
89 mediaTypeDialog = new MediaTypeDialog(this);
91 activateDialog(mediaTypeDialog);
94 void MainWindow::configureMediaImagePaths()
96 if (!mediaImagePathDialog)
98 mediaImagePathDialog = new MediaImagePathMainDialog(this);
100 activateDialog(mediaImagePathDialog);
103 void MainWindow::configureSetups()
105 if (!setupMainDialog)
107 qDebug() << "MainWindow: Creating a setup main dialog.";
108 setupMainDialog = new SetupMainDialog(this);
110 activateDialog(setupMainDialog);
111 setupMainDialog->refreshDataModel();
114 void MainWindow::configureEmulators()
116 if (!executableMainDialog) {
117 executableMainDialog = new ExecutableMainDialog(this);
119 activateDialog(executableMainDialog);
120 executableMainDialog->refreshDataModel();
123 void MainWindow::activateDialog(EmuFrontDialog* dia) const
127 dia->activateWindow();
130 void MainWindow::createMenus()
132 fileMenu = menuBar()->addMenu(tr("&File"));
133 fileMenu->addAction(exitAction);
135 configMenu = menuBar()->addMenu(tr("&Config"));
136 configMenu->addAction(configPlatformAction);
137 configMenu->addAction(configMediaTypeAction);
138 configMenu->addAction(configMediaImagePathAction);
139 configMenu->addAction(configSetupAction);
140 configMenu->addAction(configEmulatorAction);
143 void MainWindow::createStatusBar()
145 messageLabel = new QLabel;
146 statusBar()->addWidget(messageLabel);
149 void MainWindow::readSettings()
153 void MainWindow::writeSettings()
157 void MainWindow::closeEvent(QCloseEvent *event)
161 else event->ignore();
164 bool MainWindow::okToContinue()