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()));
80 aboutAction = new QAction(tr("&About"), this);
81 aboutAction->setStatusTip(tr("About EmuFront"));
82 connect(aboutAction, SIGNAL(triggered()), this, SLOT(about()));
85 void MainWindow::configurePlatforms()
89 platformDialog = new PlatformDialog(this);
90 connect(platformDialog, SIGNAL(finished(int)), this, SLOT(updateData()));
92 activateDialog(platformDialog);
95 void MainWindow::configureMediaTypes()
99 mediaTypeDialog = new MediaTypeDialog(this);
100 connect(mediaTypeDialog, SIGNAL(finished(int)), this, SLOT(updateData()));
102 activateDialog(mediaTypeDialog);
105 void MainWindow::configureMediaImagePaths()
107 if (!mediaImagePathDialog)
109 mediaImagePathDialog = new MediaImagePathMainDialog(this);
111 activateDialog(mediaImagePathDialog);
114 void MainWindow::configureSetups()
116 if (!setupMainDialog)
118 qDebug() << "MainWindow: Creating a setup main dialog.";
119 setupMainDialog = new SetupMainDialog(this);
121 activateDialog(setupMainDialog);
122 setupMainDialog->refreshDataModel();
125 void MainWindow::configureEmulators()
127 if (!executableMainDialog) {
128 executableMainDialog = new ExecutableMainDialog(this);
129 connect(executableMainDialog, SIGNAL(finished(int)), this, SLOT(updateData()));
131 activateDialog(executableMainDialog);
132 executableMainDialog->refreshDataModel();
135 void MainWindow::activateDialog(EmuFrontDialog* dia) const
139 dia->activateWindow();
142 void MainWindow::createMenus()
144 fileMenu = menuBar()->addMenu(tr("&File"));
145 fileMenu->addAction(exitAction);
147 configMenu = menuBar()->addMenu(tr("&Config"));
148 configMenu->addAction(configPlatformAction);
149 configMenu->addAction(configMediaTypeAction);
150 configMenu->addAction(configMediaImagePathAction);
151 configMenu->addAction(configSetupAction);
152 configMenu->addAction(configEmulatorAction);
154 helpMenu = menuBar()->addMenu(tr("&Help"));
155 helpMenu->addAction(aboutAction);
158 void MainWindow::createStatusBar()
160 messageLabel = new QLabel;
161 statusBar()->addWidget(messageLabel);
164 void MainWindow::readSettings()
168 void MainWindow::writeSettings()
172 void MainWindow::closeEvent(QCloseEvent *event)
176 else event->ignore();
179 bool MainWindow::okToContinue()
184 void MainWindow::updateData()
186 qDebug() << "MainWindow::updateData()";
187 launcher->updateData();
190 void MainWindow::about()
192 QMessageBox::about(this, tr("About EmuFront"),
194 "<p>© 2010 Mikko Keinänen</p>"
195 "<p>EmuFront is free software: you can redistribute it and/or modify "
196 "it under the terms of the GNU General Public License version 2 as published by "
197 "the Free Software Foundation.</p>"