#include "mainwindow.h"
#include "emulauncher.h"
#include "dialogs/platformdialog.h"
+#include "dialogs/platformmaindialog.h"
#include "dialogs/mediatypedialog.h"
#include "dialogs/mediaimagepathmaindialog.h"
#include "dialogs/setupmaindialog.h"
MainWindow::MainWindow(bool reset)
{
if (!testDB(reset)) close();
+ errorMessage = new QErrorMessage(this);
setWindowTitle("EmuFront");
tmpDirFilePath = DbConfig::getTmpDir();
if (tmpDirFilePath.isEmpty())
tmpDirFilePath = QDir::homePath();
qDebug() << "Temporary dir is " << tmpDirFilePath;
- launcher = new EmuLauncher(this, tmpDirFilePath);
+ launcher = new EmuLauncher(errorMessage, this, tmpDirFilePath);
setCentralWidget(launcher);
createActions();
createMenus();
configPlatformAction = new QAction(tr("&Platforms"), this);
configPlatformAction->setStatusTip(tr("Configure platforms"));
connect(configPlatformAction, SIGNAL(triggered()),
- this, SLOT(configurePlatforms()));
+ this, SLOT(configurePlatforms()));
+
+ configPlatformsAction = new QAction(tr("&Set Platforms"), this);
+ configPlatformsAction->setStatusTip(tr("Add, edit and delete platforms"));
+ connect(configPlatformsAction, SIGNAL(triggered()),
+ this, SLOT(configurePlatformss()));
configMediaTypeAction = new QAction(tr("&Media Types"), this);
configMediaTypeAction->setStatusTip(tr("Configure media types"));
exitAction->setStatusTip(tr("Exit EmuFront"));
connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
+ resetDbAction = new QAction( tr("Reset database"), this);
+ resetDbAction->setStatusTip(tr("Deletes all the current data and create a new database."));
+ connect(resetDbAction, SIGNAL(triggered()), this, SLOT(resetDb()));
+
aboutAction = new QAction(tr("&About"), this);
aboutAction->setStatusTip(tr("About EmuFront"));
connect(aboutAction, SIGNAL(triggered()), this, SLOT(about()));
activateDialog(platformDialog);
}
+void MainWindow::configurePlatformss()
+{
+ plfDialog = new PlatformMainDialog(this);
+ connect(plfDialog, SIGNAL(finished(int)), this, SLOT(updateData()));
+ activateDialog(plfDialog);
+}
+
void MainWindow::configureMediaTypes()
{
if (!mediaTypeDialog)
}
}
+void MainWindow::resetDb()
+{
+ if (QMessageBox::question(this, "Reset database?",
+ "Are you REALLY SURE you want to do this? "
+ "All the current data WILL BE LOST!",
+ QMessageBox::No,
+ QMessageBox::Yes) == QMessageBox::No) {
+ return;
+ }
+ try {
+ createDB();
+ }
+ catch (EmuFrontException e) {
+ errorMessage->showMessage(e.what());
+ }
+}
+
void MainWindow::manageDatFiles()
{
DatFileUtil dfu;
void MainWindow::createMenus()
{
fileMenu = menuBar()->addMenu(tr("&File"));
+ fileMenu->addAction(resetDbAction);
+ fileMenu->addSeparator();
fileMenu->addAction(exitAction);
configMenu = menuBar()->addMenu(tr("&Config"));
configMenu->addAction(configTmpDirAction);
configMenu->addSeparator();
configMenu->addAction(configPlatformAction);
+ configMenu->addAction(configPlatformsAction);
configMenu->addAction(configMediaTypeAction);
configMenu->addAction(configSetupAction);
configMenu->addAction(configMediaImagePathAction);
void MainWindow::about()
{
- QMessageBox::about(this, aboutTitle, aboutStr );
+ QMessageBox::about(this, aboutTitle, aboutStr);
}
bool MainWindow::testDB(bool reset)
" Cannot continue.");
}
- if (reset)
- {
- try
- {
- DbCreator dbCreator;
- dbCreator.createDB();
- }
- catch (QString str) {
- QString msg(tr("Exception while trying to create"
- " EmuFront database: %s").arg(str));
- throw EmuFrontException(msg);
- }
+ if (reset) {
+ createDB();
}
return true;
}
catch (EmuFrontException e) {
qDebug() << e.what();
- QMessageBox::critical(this, "Exception", e.what());
+ errorMessage->showMessage(e.what());
return false;
}
}
+
+void MainWindow::createDB() const
+{
+ try
+ {
+ DbCreator dbCreator;
+ dbCreator.createDB();
+ }
+ catch (QString str) {
+ QString msg(tr("Exception while trying to create"
+ " EmuFront database: %s").arg(str));
+ errorMessage->showMessage(msg);
+ }
+}
+