New configuration option: Media image paths (not active yet).
[emufront] / src / mainwindow.cpp
1 // EmuFront
2 // Copyright 2010 Mikko Keinänen
3 //
4 // This file is part of EmuFront.
5 //
6 //
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.
11 //
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.
16 //
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/>.
19
20 #include <QtGui>
21 #include "mainwindow.h"
22 #include "dialogs/platformdialog.h"
23 #include "dialogs/mediatypedialog.h"
24 #include "dialogs/mediaimagepathmaindialog.h"
25 #include "db/databasemanager.h"
26
27 MainWindow::MainWindow()
28 {
29     setWindowTitle("EmuFront");
30     createActions();
31     createMenus();
32     createStatusBar();
33     readSettings();
34     platformDialog = 0;
35     mediaTypeDialog = 0;
36 }
37
38 void MainWindow::createActions()
39 {
40     configPlatformAction = new QAction(tr("&Platforms"), this);
41     configPlatformAction->setStatusTip(tr("Configure platforms"));
42     connect(configPlatformAction, SIGNAL(triggered()),
43             this, SLOT(configurePlatforms()));
44
45     configMediaTypeAction = new QAction(tr("&Media Types"), this);
46     configMediaTypeAction->setStatusTip(tr("Configure media types"));
47     connect(configMediaTypeAction, SIGNAL(triggered()), this, SLOT(configureMediaTypes()));
48
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()));
53
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()));
58 }
59
60 void MainWindow::configurePlatforms()
61 {
62    if (!platformDialog)
63    {
64        platformDialog = new PlatformDialog(this);
65    } 
66    activateDialog(platformDialog);
67 }
68
69 void MainWindow::configureMediaTypes()
70 {
71     if (!mediaTypeDialog)
72     {
73         mediaTypeDialog = new MediaTypeDialog(this);
74    }
75    activateDialog(mediaTypeDialog);
76 }
77
78 void MainWindow::configureMediaImagePaths()
79 {
80     /*if (!mediaImagePathDialog)
81     {
82         mediaImagePathDialog = new MediaImagePathMainDialog(this);
83     }
84     activateDialog(mediaImagePathDialog);
85     */
86 }
87
88 void MainWindow::activateDialog(EmuFrontDialog* dia) const
89 {
90     dia->show();
91     dia->raise();
92     dia->activateWindow();
93 }
94
95
96 void MainWindow::createMenus()
97 {
98     fileMenu = menuBar()->addMenu(tr("&File"));
99     fileMenu->addAction(exitAction);
100
101     configMenu = menuBar()->addMenu(tr("&Config"));
102     configMenu->addAction(configPlatformAction);
103     configMenu->addAction(configMediaTypeAction);
104     configMenu->addAction(configMediaImagePathAction);
105 }
106
107 void MainWindow::createStatusBar()
108 {
109     messageLabel = new QLabel;
110     statusBar()->addWidget(messageLabel);
111 }
112
113 void MainWindow::readSettings()
114 {
115 }
116
117 void MainWindow::writeSettings()
118 {
119 }
120
121 void MainWindow::closeEvent(QCloseEvent *event)
122 {
123     if (okToContinue())
124         event->accept();
125     else event->ignore();
126 }
127
128 bool MainWindow::okToContinue()
129 {
130     return true;
131 }