summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.cc68
-rw-r--r--src/mainwindow.h4
-rw-r--r--src/project.cc10
-rw-r--r--src/project.h4
4 files changed, 76 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();
}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index a7c9ba2..7671494 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -44,9 +44,12 @@ public:
~MainWindow();
public slots:
+ void updateWindowTitle();
+
void newProject();
void loadProject();
void saveProject();
+ void saveProjectAs();
void projectChanged();
protected:
@@ -58,6 +61,7 @@ private:
Settings& settings;
Project project;
+ bool project_dirty{false};
InstrumentWindow instrument_window;
};
diff --git a/src/project.cc b/src/project.cc
index 072425c..33c3054 100644
--- a/src/project.cc
+++ b/src/project.cc
@@ -44,6 +44,16 @@ void Project::bulkUpdateEnd()
}
+QString Project::getProjectFile() const
+{
+ return project_file;
+}
+
+void Project::setProjectFile(const QString& project_file)
+{
+ this->project_file = project_file;
+}
+
QString Project::getProjectName() const
{
return project_name;
diff --git a/src/project.h b/src/project.h
index 306bc17..097b7c9 100644
--- a/src/project.h
+++ b/src/project.h
@@ -54,6 +54,9 @@ public:
Project& project;
};
+ QString getProjectFile() const;
+ void setProjectFile(const QString& project_file);
+
QString getProjectName() const;
void setProjectName(const QString& project_name);
@@ -68,6 +71,7 @@ signals:
private:
friend class ProjectSerialiser;
+ QString project_file;
QString project_name;
QString raw_file_root;