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;
47 void MainWindow::connectSignals()
51 void MainWindow::createActions()
53 configPlatformAction = new QAction(tr("&Platforms"), this);
54 configPlatformAction->setStatusTip(tr("Configure platforms"));
55 connect(configPlatformAction, SIGNAL(triggered()),
56 this, SLOT(configurePlatforms()));
58 configMediaTypeAction = new QAction(tr("&Media Types"), this);
59 configMediaTypeAction->setStatusTip(tr("Configure media types"));
60 connect(configMediaTypeAction, SIGNAL(triggered()), this, SLOT(configureMediaTypes()));
62 configMediaImagePathAction = new QAction(tr("Media &Image Paths"), this);
63 configMediaImagePathAction->setStatusTip(tr("Configure media image file paths."));
64 connect(configMediaImagePathAction, SIGNAL(triggered()),
65 this, SLOT(configureMediaImagePaths()));
67 configSetupAction = new QAction(tr("S&etups"), this);
68 configSetupAction->setStatusTip(tr("Configure set ups"));
69 connect(configSetupAction, SIGNAL(triggered()), this, SLOT(configureSetups()));
71 configEmulatorAction = new QAction(tr("Em&ulators"), this);
72 configEmulatorAction->setStatusTip(tr("Configure emulators"));
73 connect(configEmulatorAction, SIGNAL(triggered()), this, SLOT(configureEmulators()));
75 exitAction = new QAction(tr("&Exit"), this);
76 exitAction->setShortcut(tr("Ctrl+Q"));
77 exitAction->setStatusTip(tr("Exit EmuFront"));
78 connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
81 void MainWindow::configurePlatforms()
85 platformDialog = new PlatformDialog(this);
86 connect(platformDialog, SIGNAL(finished(int)), this, SLOT(updateData()));
88 activateDialog(platformDialog);
91 void MainWindow::configureMediaTypes()
95 mediaTypeDialog = new MediaTypeDialog(this);
96 connect(mediaTypeDialog, SIGNAL(finished(int)), this, SLOT(updateData()));
98 activateDialog(mediaTypeDialog);
101 void MainWindow::configureMediaImagePaths()
103 if (!mediaImagePathDialog)
105 mediaImagePathDialog = new MediaImagePathMainDialog(this);
107 activateDialog(mediaImagePathDialog);
110 void MainWindow::configureSetups()
112 if (!setupMainDialog)
114 qDebug() << "MainWindow: Creating a setup main dialog.";
115 setupMainDialog = new SetupMainDialog(this);
117 activateDialog(setupMainDialog);
118 setupMainDialog->refreshDataModel();
121 void MainWindow::configureEmulators()
123 if (!executableMainDialog) {
124 executableMainDialog = new ExecutableMainDialog(this);
125 connect(executableMainDialog, SIGNAL(finished(int)), this, SLOT(updateData()));
127 activateDialog(executableMainDialog);
128 executableMainDialog->refreshDataModel();
131 void MainWindow::activateDialog(EmuFrontDialog* dia) const
135 dia->activateWindow();
138 void MainWindow::createMenus()
140 fileMenu = menuBar()->addMenu(tr("&File"));
141 fileMenu->addAction(exitAction);
143 configMenu = menuBar()->addMenu(tr("&Config"));
144 configMenu->addAction(configPlatformAction);
145 configMenu->addAction(configMediaTypeAction);
146 configMenu->addAction(configMediaImagePathAction);
147 configMenu->addAction(configSetupAction);
148 configMenu->addAction(configEmulatorAction);
151 void MainWindow::createStatusBar()
153 messageLabel = new QLabel;
154 statusBar()->addWidget(messageLabel);
157 void MainWindow::readSettings()
161 void MainWindow::writeSettings()
165 void MainWindow::closeEvent(QCloseEvent *event)
169 else event->ignore();
172 bool MainWindow::okToContinue()
177 void MainWindow::updateData()
179 qDebug() << "MainWindow::updateData()";
180 launcher->updateData();