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()));
}
}
+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) {
+ qDebug() << e.what();
+ QMessageBox::critical(this, "Exception", 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"));
" 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;
}
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));
+ throw EmuFrontException(msg);
+ }
+}
+
void configureSetups();
void configureEmulators();
void configureTmpDir();
+ void resetDb();
void updateData();
void manageDatFiles();
void about();
void connectSignals();
void activateDialog(EmuFrontDialog*) const;
bool testDB(bool reset);
+ void createDB() const;
PlatformDialog *platformDialog;
MediaTypeDialog *mediaTypeDialog;
MediaImagePathMainDialog *mediaImagePathDialog;
QAction *configSetupAction;
QAction *configEmulatorAction;
QAction *exitAction;
+ QAction *resetDbAction;
QAction *aboutAction;
QAction *configTmpDirAction;
QAction *manageDatFilesAction;