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;
40 void MainWindow::createActions()
42 configPlatformAction = new QAction(tr("&Platforms"), this);
43 configPlatformAction->setStatusTip(tr("Configure platforms"));
44 connect(configPlatformAction, SIGNAL(triggered()),
45 this, SLOT(configurePlatforms()));
47 configMediaTypeAction = new QAction(tr("&Media Types"), this);
48 configMediaTypeAction->setStatusTip(tr("Configure media types"));
49 connect(configMediaTypeAction, SIGNAL(triggered()), this, SLOT(configureMediaTypes()));
51 configMediaImagePathAction = new QAction(tr("Media &Image Paths"), this);
52 configMediaImagePathAction->setStatusTip(tr("Configure media image file paths."));
53 connect(configMediaImagePathAction, SIGNAL(triggered()),
54 this, SLOT(configureMediaImagePaths()));
56 configSetupAction = new QAction(tr("S&etups"), this);
57 configSetupAction->setStatusTip(tr("Configure set ups"));
58 connect(configSetupAction, SIGNAL(triggered()), this, SLOT(configureSetups()));
60 exitAction = new QAction(tr("&Exit"), this);
61 exitAction->setShortcut(tr("Ctrl+Q"));
62 exitAction->setStatusTip(tr("Exit EmuFront"));
63 connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
66 void MainWindow::configurePlatforms()
70 platformDialog = new PlatformDialog(this);
72 activateDialog(platformDialog);
75 void MainWindow::configureMediaTypes()
79 mediaTypeDialog = new MediaTypeDialog(this);
81 activateDialog(mediaTypeDialog);
84 void MainWindow::configureMediaImagePaths()
86 if (!mediaImagePathDialog)
88 mediaImagePathDialog = new MediaImagePathMainDialog(this);
90 activateDialog(mediaImagePathDialog);
93 void MainWindow::configureSetups()
97 setupMainDialog = new SetupMainDialog(this);
99 activateDialog(setupMainDialog);
102 void MainWindow::activateDialog(EmuFrontDialog* dia) const
106 dia->activateWindow();
109 void MainWindow::createMenus()
111 fileMenu = menuBar()->addMenu(tr("&File"));
112 fileMenu->addAction(exitAction);
114 configMenu = menuBar()->addMenu(tr("&Config"));
115 configMenu->addAction(configPlatformAction);
116 configMenu->addAction(configMediaTypeAction);
117 configMenu->addAction(configMediaImagePathAction);
118 configMenu->addAction(configSetupAction);
121 void MainWindow::createStatusBar()
123 messageLabel = new QLabel;
124 statusBar()->addWidget(messageLabel);
127 void MainWindow::readSettings()
131 void MainWindow::writeSettings()
135 void MainWindow::closeEvent(QCloseEvent *event)
139 else event->ignore();
142 bool MainWindow::okToContinue()