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 as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
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 "db/databasemanager.h"
29 MainWindow::MainWindow()
31 setWindowTitle("EmuFront");
32 launcher = new EmuLauncher(this);
33 setCentralWidget(launcher);
40 mediaImagePathDialog = 0;
44 void MainWindow::createActions()
46 configPlatformAction = new QAction(tr("&Platforms"), this);
47 configPlatformAction->setStatusTip(tr("Configure platforms"));
48 connect(configPlatformAction, SIGNAL(triggered()),
49 this, SLOT(configurePlatforms()));
51 configMediaTypeAction = new QAction(tr("&Media Types"), this);
52 configMediaTypeAction->setStatusTip(tr("Configure media types"));
53 connect(configMediaTypeAction, SIGNAL(triggered()), this, SLOT(configureMediaTypes()));
55 configMediaImagePathAction = new QAction(tr("Media &Image Paths"), this);
56 configMediaImagePathAction->setStatusTip(tr("Configure media image file paths."));
57 connect(configMediaImagePathAction, SIGNAL(triggered()),
58 this, SLOT(configureMediaImagePaths()));
60 configSetupAction = new QAction(tr("S&etups"), this);
61 configSetupAction->setStatusTip(tr("Configure set ups"));
62 connect(configSetupAction, SIGNAL(triggered()), this, SLOT(configureSetups()));
64 exitAction = new QAction(tr("&Exit"), this);
65 exitAction->setShortcut(tr("Ctrl+Q"));
66 exitAction->setStatusTip(tr("Exit EmuFront"));
67 connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
70 void MainWindow::configurePlatforms()
74 platformDialog = new PlatformDialog(this);
76 activateDialog(platformDialog);
79 void MainWindow::configureMediaTypes()
83 mediaTypeDialog = new MediaTypeDialog(this);
85 activateDialog(mediaTypeDialog);
88 void MainWindow::configureMediaImagePaths()
90 if (!mediaImagePathDialog)
92 mediaImagePathDialog = new MediaImagePathMainDialog(this);
94 activateDialog(mediaImagePathDialog);
97 void MainWindow::configureSetups()
101 qDebug() << "MainWindow: Creating a setup main dialog.";
102 setupMainDialog = new SetupMainDialog(this);
104 activateDialog(setupMainDialog);
105 setupMainDialog->refreshDataModel();
108 void MainWindow::activateDialog(EmuFrontDialog* dia) const
112 dia->activateWindow();
115 void MainWindow::createMenus()
117 fileMenu = menuBar()->addMenu(tr("&File"));
118 fileMenu->addAction(exitAction);
120 configMenu = menuBar()->addMenu(tr("&Config"));
121 configMenu->addAction(configPlatformAction);
122 configMenu->addAction(configMediaTypeAction);
123 configMenu->addAction(configMediaImagePathAction);
124 configMenu->addAction(configSetupAction);
127 void MainWindow::createStatusBar()
129 messageLabel = new QLabel;
130 statusBar()->addWidget(messageLabel);
133 void MainWindow::readSettings()
137 void MainWindow::writeSettings()
141 void MainWindow::closeEvent(QCloseEvent *event)
145 else event->ignore();
148 bool MainWindow::okToContinue()