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 "db/databasemanager.h"
27 MainWindow::MainWindow()
29 setWindowTitle("EmuFront");
38 void MainWindow::createActions()
40 configPlatformAction = new QAction(tr("&Platforms"), this);
41 configPlatformAction->setStatusTip(tr("Configure platforms"));
42 connect(configPlatformAction, SIGNAL(triggered()),
43 this, SLOT(configurePlatforms()));
45 configMediaTypeAction = new QAction(tr("&Media Types"), this);
46 configMediaTypeAction->setStatusTip(tr("Configure media types"));
47 connect(configMediaTypeAction, SIGNAL(triggered()), this, SLOT(configureMediaTypes()));
49 configMediaImagePathAction = new QAction(tr("Media &Image Paths"), this);
50 configMediaImagePathAction->setStatusTip(tr("Configure media image file paths."));
51 connect(configMediaImagePathAction, SIGNAL(triggered()),
52 this, SLOT(configureMediaImagePaths()));
54 exitAction = new QAction(tr("&Exit"), this);
55 exitAction->setShortcut(tr("Ctrl+Q"));
56 exitAction->setStatusTip(tr("Exit EmuFront"));
57 connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
60 void MainWindow::configurePlatforms()
64 platformDialog = new PlatformDialog(this);
66 activateDialog(platformDialog);
69 void MainWindow::configureMediaTypes()
73 mediaTypeDialog = new MediaTypeDialog(this);
75 activateDialog(mediaTypeDialog);
78 void MainWindow::configureMediaImagePaths()
80 if (!mediaImagePathDialog)
82 mediaImagePathDialog = new MediaImagePathMainDialog(this);
84 activateDialog(mediaImagePathDialog);
87 void MainWindow::activateDialog(EmuFrontDialog* dia) const
91 dia->activateWindow();
95 void MainWindow::createMenus()
97 fileMenu = menuBar()->addMenu(tr("&File"));
98 fileMenu->addAction(exitAction);
100 configMenu = menuBar()->addMenu(tr("&Config"));
101 configMenu->addAction(configPlatformAction);
102 configMenu->addAction(configMediaTypeAction);
103 configMenu->addAction(configMediaImagePathAction);
106 void MainWindow::createStatusBar()
108 messageLabel = new QLabel;
109 statusBar()->addWidget(messageLabel);
112 void MainWindow::readSettings()
116 void MainWindow::writeSettings()
120 void MainWindow::closeEvent(QCloseEvent *event)
124 else event->ignore();
127 bool MainWindow::okToContinue()