summaryrefslogtreecommitdiff
path: root/src/mainwindow.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/mainwindow.cc')
-rw-r--r--src/mainwindow.cc68
1 files changed, 58 insertions, 10 deletions
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index 8c08eed..435f0b0 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -62,8 +62,6 @@ MainWindow::MainWindow(Settings& settings)
: settings(settings)
, instrument_window(settings)
{
- setWindowTitle(tr("DGEdit - DrumGizmo Drumkit Editor"));
-
setCentralWidget(&instrument_window);
QMenu* fileMenu = menuBar()->addMenu(tr("&File"));
@@ -76,10 +74,15 @@ MainWindow::MainWindow(Settings& settings)
fileMenu->addAction(act_load_project);
connect(act_load_project, SIGNAL(triggered()), this, SLOT(loadProject()));
- QAction* act_save_project = new QAction(tr("&Save Project..."), this);
+ QAction* act_save_project = new QAction(tr("&Save Project"), this);
fileMenu->addAction(act_save_project);
connect(act_save_project, SIGNAL(triggered()), this, SLOT(saveProject()));
+ QAction* act_save_project_as = new QAction(tr("Save Project As..."), this);
+ fileMenu->addAction(act_save_project_as);
+ connect(act_save_project_as, SIGNAL(triggered()),
+ this, SLOT(saveProjectAs()));
+
QAction* act_quit = new QAction(tr("&Quit"), this);
fileMenu->addAction(act_quit);
connect(act_quit, SIGNAL(triggered()), this, SLOT(close()));
@@ -89,12 +92,36 @@ MainWindow::MainWindow(Settings& settings)
statusBar()->showMessage(tr("Ready"));
connect(&project, SIGNAL(projectChanged()), this, SLOT(projectChanged()));
+
+ updateWindowTitle();
}
MainWindow::~MainWindow()
{
}
+void MainWindow::updateWindowTitle()
+{
+ auto project_string = project.getProjectName();
+
+ if(project_string == "")
+ {
+ project_string = tr("[Untitled Project]");
+ }
+
+ if(project.getProjectFile() != "")
+ {
+ project_string += " (" + QFileInfo(project.getProjectFile()).fileName() + ")";
+ }
+
+ if(project_dirty)
+ {
+ project_string += "*";
+ }
+
+ setWindowTitle("DGEdit - " + project_string);
+}
+
void MainWindow::closeEvent(QCloseEvent*)
{
saveSettings();
@@ -149,19 +176,18 @@ void MainWindow::loadProject()
ProjectSerialiser ser;
ser.deserialise(xml, project);
+ project.setProjectFile(filename);
+
+ updateWindowTitle();
statusBar()->showMessage(tr("Loaded"));
}
void MainWindow::saveProject()
{
- QString filename
- = QFileDialog::getSaveFileName(this, tr("Save DGEdit Project"),
- "",
- tr("DGEdit Project Files (*.dgedit)"));
-
+ QString filename = project.getProjectFile();
if(filename == "")
{
- // User clicked cancel
+ saveProjectAs();
return;
}
@@ -176,10 +202,32 @@ void MainWindow::saveProject()
file.write(xml.toUtf8());
+ project_dirty = false;
+ updateWindowTitle();
+
statusBar()->showMessage(tr("Saved"));
}
+void MainWindow::saveProjectAs()
+{
+ QString filename
+ = QFileDialog::getSaveFileName(this, tr("Save DGEdit Project"),
+ "",
+ tr("DGEdit Project Files (*.dgedit)"));
+
+ if(filename == "")
+ {
+ // User clicked cancel
+ return;
+ }
+
+ project.setProjectFile(filename);
+
+ saveProject();
+}
+
void MainWindow::projectChanged()
{
- statusBar()->showMessage(tr("Unsaved"));
+ project_dirty = true;
+ updateWindowTitle();
}