summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2018-05-06 13:32:24 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2018-05-06 13:32:24 +0200
commit8daea9831c1710a4f009a1837d86a5ed78d1ccb1 (patch)
tree0f0fc8c5e778b525a61d8c7f6d5c289c717e4de4 /src
parenteeef75b159369a6441641c2c14c217c29b02a3ff (diff)
Created Project dialog and project skeleton class for storing project related data (which will be serialised/deserialised using XML soon).
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am4
-rw-r--r--src/mainwindow.cc21
-rw-r--r--src/mainwindow.h4
-rw-r--r--src/project.cc81
-rw-r--r--src/project.h71
-rw-r--r--src/projectdialog.cc98
-rw-r--r--src/projectdialog.h51
7 files changed, 330 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 5ce2a58..2ef9ae1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -28,6 +28,8 @@ dgedit_SOURCES = \
mainwindow.cc \
mipmap.cc \
player.cc \
+ project.cc \
+ projectdialog.cc \
samplesorter.cc \
selection.cc \
selectioneditor.cc \
@@ -49,6 +51,8 @@ EXTRA_DIST = \
mainwindow.h \
mipmap.h \
player.h \
+ project.h \
+ projectdialog.h \
samplesorter.h \
selection.h \
selectioneditor.h \
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index d58ae2b..ea86b3c 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -51,6 +51,7 @@
#include "selectioneditor.h"
#include "zoomslider.h"
#include "settings.h"
+#include "projectdialog.h"
#define MAXVAL 10000000L
@@ -67,6 +68,7 @@ static void addTool(QToolBar* toolbar, Canvas* canvas, CanvasTool* tool)
MainWindow::MainWindow(Settings& settings)
: settings(settings)
{
+ setWindowTitle(tr("DGEdit - DrumGizmo Drumkit Editor"));
{
int start = 44100 * 60;
Selection p(start, start + 44100 * 60, 0, 0); // one minute selection
@@ -100,6 +102,11 @@ MainWindow::MainWindow(Settings& settings)
addTool(toolbar, canvaswidget->canvas, tool_selections);
QMenu* fileMenu = menuBar()->addMenu(tr("&File"));
+
+ QAction* act_new_project = new QAction(tr("&New Project"), this);
+ fileMenu->addAction(act_new_project);
+ connect(act_new_project, SIGNAL(triggered()), this, SLOT(newProject()));
+
QAction* act_quit = new QAction(tr("&Quit"), this);
fileMenu->addAction(act_quit);
connect(act_quit, SIGNAL(triggered()), this, SLOT(close()));
@@ -167,6 +174,8 @@ MainWindow::MainWindow(Settings& settings)
loadSettings();
statusBar()->showMessage(tr("Ready"));
+
+ connect(&project, SIGNAL(projectChanged()), this, SLOT(projectChanged()));
}
MainWindow::~MainWindow()
@@ -441,6 +450,18 @@ void MainWindow::saveSettings()
settings.saveExportPath(lineed_exportp->text());
}
+void MainWindow::newProject()
+{
+ ProjectDialog dlg(this, project);
+ dlg.show();
+ dlg.exec();
+}
+
+void MainWindow::projectChanged()
+{
+ statusBar()->showMessage(tr("Unsaved"));
+}
+
void MainWindow::doExport()
{
extractor->exportSelections();
diff --git a/src/mainwindow.h b/src/mainwindow.h
index b580101..b6c7e98 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -45,6 +45,7 @@
#include "player.h"
#include "zoomslider.h"
#include "canvaswidget.h"
+#include "project.h"
class Settings;
@@ -67,6 +68,8 @@ public:
~MainWindow();
public slots:
+ void newProject();
+ void projectChanged();
void doExport();
void loadFile(QString filename);
void playSamples();
@@ -114,4 +117,5 @@ private:
Player player;
Settings& settings;
+ Project project;
};
diff --git a/src/project.cc b/src/project.cc
new file mode 100644
index 0000000..ffa9689
--- /dev/null
+++ b/src/project.cc
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * project.cc
+ *
+ * Sun May 6 11:38:11 CEST 2018
+ * Copyright 2018 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of DrumGizmo.
+ *
+ * DrumGizmo is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * DrumGizmo is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with DrumGizmo; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#include "project.h"
+
+#include <QtGlobal>
+
+void Project::bulkUpdateBegin()
+{
+ ++update_count;
+}
+
+void Project::bulkUpdateEnd()
+{
+ Q_ASSERT(update_count);
+ --update_count;
+ if(update_count == 0)
+ {
+ emit projectChanged();
+ }
+}
+
+
+QString Project::getProjectName() const
+{
+ return project_name;
+}
+
+void Project::setProjectName(const QString& project_name)
+{
+ if(this->project_name == project_name)
+ {
+ return;
+ }
+
+ {
+ RAIIBulkUpdate bulkUpdate(*this);
+ this->project_name = project_name;
+ }
+}
+
+QString Project::getRawFileRoot() const
+{
+ return raw_file_root;
+}
+
+void Project::setRawFileRoot(const QString& raw_file_root)
+{
+ if(this->raw_file_root == raw_file_root)
+ {
+ return;
+ }
+
+ {
+ RAIIBulkUpdate bulkUpdate(*this);
+ this->raw_file_root = raw_file_root;
+ }
+}
diff --git a/src/project.h b/src/project.h
new file mode 100644
index 0000000..02970c0
--- /dev/null
+++ b/src/project.h
@@ -0,0 +1,71 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * project.h
+ *
+ * Sun May 6 11:38:11 CEST 2018
+ * Copyright 2018 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of DrumGizmo.
+ *
+ * DrumGizmo is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * DrumGizmo is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with DrumGizmo; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#pragma once
+
+#include <QObject>
+#include <QString>
+
+class Project
+ : public QObject
+{
+ Q_OBJECT
+public:
+ void bulkUpdateBegin();
+ void bulkUpdateEnd();
+
+ class RAIIBulkUpdate
+ {
+ public:
+ RAIIBulkUpdate(Project& project)
+ : project(project)
+ {
+ project.bulkUpdateBegin();
+ }
+ ~RAIIBulkUpdate()
+ {
+ project.bulkUpdateEnd();
+ }
+
+ private:
+ Project& project;
+ };
+
+ QString getProjectName() const;
+ void setProjectName(const QString& project_name);
+
+ QString getRawFileRoot() const;
+ void setRawFileRoot(const QString& raw_file_root);
+
+signals:
+ void projectChanged();
+
+private:
+ QString project_name;
+ QString raw_file_root;
+
+ int update_count{0};
+};
diff --git a/src/projectdialog.cc b/src/projectdialog.cc
new file mode 100644
index 0000000..3734b42
--- /dev/null
+++ b/src/projectdialog.cc
@@ -0,0 +1,98 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * projectdialog.cc
+ *
+ * Sat May 5 14:54:18 CEST 2018
+ * Copyright 2018 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of DrumGizmo.
+ *
+ * DrumGizmo is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * DrumGizmo is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with DrumGizmo; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#include "projectdialog.h"
+
+#include <QGridLayout>
+
+#include <QLabel>
+#include <QLineEdit>
+#include <QPushButton>
+
+#include <QFileDialog>
+#include <QDialogButtonBox>
+
+ProjectDialog::ProjectDialog(QWidget* parent, Project& project)
+ : QDialog(parent)
+ , project(project)
+{
+ setWindowModality(Qt::ApplicationModal);
+ setWindowTitle(tr("Project Dialog"));
+ setMinimumWidth(300);
+
+ auto layout = new QGridLayout();
+ setLayout(layout);
+
+ int idx = 0;
+
+ name = new QLineEdit();
+ layout->addWidget(new QLabel(tr("Name of the project:")), idx, 0, 1, 2);
+ idx++;
+ layout->addWidget(name, idx, 0);
+ idx++;
+
+ raw_dir = new QLineEdit();
+ auto btn = new QPushButton(tr("..."));
+ btn->setMaximumWidth(32);
+ connect(btn, SIGNAL(clicked()), this, SLOT(chooseRawFilesDir()));
+ layout->addWidget(new QLabel(tr("Base path of raw files:")), idx, 0, 1, 2);
+ idx++;
+ layout->addWidget(raw_dir, idx, 0);
+ layout->addWidget(btn, idx, 1);
+ idx++;
+
+ auto buttons =
+ new QDialogButtonBox(QDialogButtonBox::Ok |
+ QDialogButtonBox::Cancel |
+ QDialogButtonBox::Apply);
+ connect(buttons, SIGNAL(accepted()), this, SLOT(apply()));
+ connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
+ connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
+ connect(buttons->button(QDialogButtonBox::Apply), SIGNAL(clicked()),
+ this, SLOT(apply()));
+ layout->addWidget(buttons, idx, 0, 1, 2);
+}
+
+void ProjectDialog::chooseRawFilesDir()
+{
+ QString path =
+ QFileDialog::getExistingDirectory(
+ this, tr("Choose base directory with the raw sample files."),
+ raw_dir->text(), QFileDialog::ShowDirsOnly);
+
+ if(path != "")
+ {
+ raw_dir->setText(path);
+ }
+}
+
+void ProjectDialog::apply()
+{
+ // Only send out one update signal
+ Project::RAIIBulkUpdate bulkUpdate(project);
+ project.setProjectName(name->text());
+ project.setRawFileRoot(raw_dir->text());
+}
diff --git a/src/projectdialog.h b/src/projectdialog.h
new file mode 100644
index 0000000..7d2093d
--- /dev/null
+++ b/src/projectdialog.h
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * projectdialog.h
+ *
+ * Sat May 5 14:54:18 CEST 2018
+ * Copyright 2018 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of DrumGizmo.
+ *
+ * DrumGizmo is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * DrumGizmo is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with DrumGizmo; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#pragma once
+
+#include <QDialog>
+#include <QLineEdit>
+
+#include "project.h"
+
+class ProjectDialog
+ : public QDialog
+{
+ Q_OBJECT
+public:
+ ProjectDialog(QWidget* parent, Project& project);
+ ~ProjectDialog() = default;
+
+private slots:
+ void chooseRawFilesDir();
+ void apply();
+
+private:
+ QLineEdit* name{nullptr};
+ QLineEdit* raw_dir{nullptr};
+
+ Project& project;
+};