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 // 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.
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/>.
21 #include "mainwindow.h"
22 #include "dialogs/platformdialog.h"
23 #include "dialogs/mediatypedialog.h"
24 #include "dialogs/mediaimagepathmaindialog.h"
25 #include "dialogs/setupmaindialog.h"
26 #include "db/databasemanager.h"
28 MainWindow::MainWindow()
30 setWindowTitle("EmuFront");
37 mediaImagePathDialog = 0;
41 void MainWindow::createActions()
43 configPlatformAction = new QAction(tr("&Platforms"), this);
44 configPlatformAction->setStatusTip(tr("Configure platforms"));
45 connect(configPlatformAction, SIGNAL(triggered()),
46 this, SLOT(configurePlatforms()));
48 configMediaTypeAction = new QAction(tr("&Media Types"), this);
49 configMediaTypeAction->setStatusTip(tr("Configure media types"));
50 connect(configMediaTypeAction, SIGNAL(triggered()), this, SLOT(configureMediaTypes()));
52 configMediaImagePathAction = new QAction(tr("Media &Image Paths"), this);
53 configMediaImagePathAction->setStatusTip(tr("Configure media image file paths."));
54 connect(configMediaImagePathAction, SIGNAL(triggered()),
55 this, SLOT(configureMediaImagePaths()));
57 configSetupAction = new QAction(tr("S&etups"), this);
58 configSetupAction->setStatusTip(tr("Configure set ups"));
59 connect(configSetupAction, SIGNAL(triggered()), this, SLOT(configureSetups()));
61 exitAction = new QAction(tr("&Exit"), this);
62 exitAction->setShortcut(tr("Ctrl+Q"));
63 exitAction->setStatusTip(tr("Exit EmuFront"));
64 connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
67 void MainWindow::configurePlatforms()
71 platformDialog = new PlatformDialog(this);
73 activateDialog(platformDialog);
76 void MainWindow::configureMediaTypes()
80 mediaTypeDialog = new MediaTypeDialog(this);
82 activateDialog(mediaTypeDialog);
85 void MainWindow::configureMediaImagePaths()
87 if (!mediaImagePathDialog)
89 mediaImagePathDialog = new MediaImagePathMainDialog(this);
91 activateDialog(mediaImagePathDialog);
94 void MainWindow::configureSetups()
98 qDebug() << "MainWindow: Creating a setup main dialog.";
99 setupMainDialog = new SetupMainDialog(this);
101 activateDialog(setupMainDialog);
104 void MainWindow::activateDialog(EmuFrontDialog* dia) const
108 dia->activateWindow();
111 void MainWindow::createMenus()
113 fileMenu = menuBar()->addMenu(tr("&File"));
114 fileMenu->addAction(exitAction);
116 configMenu = menuBar()->addMenu(tr("&Config"));
117 configMenu->addAction(configPlatformAction);
118 configMenu->addAction(configMediaTypeAction);
119 configMenu->addAction(configMediaImagePathAction);
120 configMenu->addAction(configSetupAction);
123 void MainWindow::createStatusBar()
125 messageLabel = new QLabel;
126 statusBar()->addWidget(messageLabel);
129 void MainWindow::readSettings()
133 void MainWindow::writeSettings()
137 void MainWindow::closeEvent(QCloseEvent *event)
141 else event->ignore();
144 bool MainWindow::okToContinue()