summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--icons/instrument.pngbin0 -> 2259 bytes
-rw-r--r--src/Makefile.am4
-rw-r--r--src/dgedit.qrc1
-rw-r--r--src/instrumentwidget.cc (renamed from src/instrumentwindow.cc)28
-rw-r--r--src/instrumentwidget.h (renamed from src/instrumentwindow.h)10
-rw-r--r--src/mainwindow.cc72
-rw-r--r--src/mainwindow.h6
-rw-r--r--src/settings.cc12
-rw-r--r--src/settings.h4
9 files changed, 83 insertions, 54 deletions
diff --git a/icons/instrument.png b/icons/instrument.png
new file mode 100644
index 0000000..0b4c551
--- /dev/null
+++ b/icons/instrument.png
Binary files differ
diff --git a/src/Makefile.am b/src/Makefile.am
index 69b224b..ba33043 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -23,7 +23,7 @@ dgedit_SOURCES = \
canvastoolthreshold.cc \
canvaswidget.cc \
filelist.cc \
- instrumentwindow.cc \
+ instrumentwidget.cc \
itemeditor.cc \
localehandler.cc \
mainwindow.cc \
@@ -48,7 +48,7 @@ EXTRA_DIST = \
canvastoolthreshold.h \
canvaswidget.h \
filelist.h \
- instrumentwindow.h \
+ instrumentwidget.h \
itemeditor.h \
localehandler.h \
mainwindow.h \
diff --git a/src/dgedit.qrc b/src/dgedit.qrc
index ccaaae3..df7e9ba 100644
--- a/src/dgedit.qrc
+++ b/src/dgedit.qrc
@@ -3,5 +3,6 @@
<qresource>
<file>../icons/master.png</file>
<file>../icons/file.png</file>
+ <file>../icons/instrument.png</file>
</qresource>
</RCC>
diff --git a/src/instrumentwindow.cc b/src/instrumentwidget.cc
index f40f527..e3b3061 100644
--- a/src/instrumentwindow.cc
+++ b/src/instrumentwidget.cc
@@ -1,6 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/***************************************************************************
- * instrumentwindow.cc
+ * instrumentwidget.cc
*
* Sat May 12 15:38:38 CEST 2018
* Copyright 2018 Bent Bisballe Nyeng
@@ -24,7 +24,7 @@
* along with DrumGizmo; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include "instrumentwindow.h"
+#include "instrumentwidget.h"
#include <iostream>
@@ -54,6 +54,7 @@
#include "selectioneditor.h"
#include "zoomslider.h"
#include "settings.h"
+#include "project.h"
#define MAXVAL 10000000L
@@ -67,8 +68,9 @@ static void addTool(QToolBar* toolbar, Canvas* canvas, CanvasTool* tool)
canvas->tools.push_back(tool);
}
-InstrumentWindow::InstrumentWindow(Settings& settings)
+InstrumentWidget::InstrumentWidget(Settings& settings, Instrument& instrument)
: settings(settings)
+ , instrument(instrument)
{
{
int start = 44100 * 60;
@@ -163,11 +165,11 @@ InstrumentWindow::InstrumentWindow(Settings& settings)
canvaswidget->xoffset->setValue(0);
}
-InstrumentWindow::~InstrumentWindow()
+InstrumentWidget::~InstrumentWidget()
{
}
-void InstrumentWindow::tabChanged(int tabid)
+void InstrumentWidget::tabChanged(int tabid)
{
tool_selections->setShowPreview(tabid == generateTabId);
sorter->setShowPreview(tabid == generateTabId);
@@ -175,7 +177,7 @@ void InstrumentWindow::tabChanged(int tabid)
threshold->setActive(tabid == generateTabId);
}
-QWidget* InstrumentWindow::createFilesTab()
+QWidget* InstrumentWidget::createFilesTab()
{
QWidget* w = new QWidget();
QVBoxLayout* l = new QVBoxLayout();
@@ -201,7 +203,7 @@ QWidget* InstrumentWindow::createFilesTab()
return w;
}
-QWidget* InstrumentWindow::createEditTab()
+QWidget* InstrumentWidget::createEditTab()
{
SelectionEditor* se = new SelectionEditor(selections);
@@ -241,7 +243,7 @@ static QSlider* createAttribute(QWidget* parent, QString name,
return slider;
}
-QWidget* InstrumentWindow::createGenerateTab()
+QWidget* InstrumentWidget::createGenerateTab()
{
QWidget* w = new QWidget();
QVBoxLayout* l = new QVBoxLayout();
@@ -311,7 +313,7 @@ QWidget* InstrumentWindow::createGenerateTab()
return w;
}
-QWidget* InstrumentWindow::createExportTab()
+QWidget* InstrumentWidget::createExportTab()
{
QWidget* w = new QWidget();
QVBoxLayout* l = new QVBoxLayout();
@@ -351,7 +353,7 @@ QWidget* InstrumentWindow::createExportTab()
return w;
}
-void InstrumentWindow::playSamples()
+void InstrumentWidget::playSamples()
{
Selections* sels = &selections;
if(tabs->currentIndex() == generateTabId)
@@ -413,12 +415,12 @@ void InstrumentWindow::playSamples()
}
}
-void InstrumentWindow::doExport()
+void InstrumentWidget::doExport()
{
extractor->exportSelections();
}
-void InstrumentWindow::loadFile(QString filename)
+void InstrumentWidget::loadFile(QString filename)
{
setCursor(Qt::WaitCursor);
statusBar()->showMessage(tr("Loading..."));
@@ -436,7 +438,7 @@ void InstrumentWindow::loadFile(QString filename)
setCursor(Qt::ArrowCursor);
}
-void InstrumentWindow::browse()
+void InstrumentWidget::browse()
{
QString path =
QFileDialog::getExistingDirectory(this, tr("Select export path"),
diff --git a/src/instrumentwindow.h b/src/instrumentwidget.h
index 4e3a1a4..7a2b40d 100644
--- a/src/instrumentwindow.h
+++ b/src/instrumentwidget.h
@@ -1,6 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/***************************************************************************
- * instrumentwindow.h
+ * instrumentwidget.h
*
* Sat May 12 15:38:38 CEST 2018
* Copyright 2018 Bent Bisballe Nyeng
@@ -46,6 +46,7 @@
#include "zoomslider.h"
#include "canvaswidget.h"
+class Instrument;
class Settings;
class Preset
@@ -58,13 +59,13 @@ public:
};
Q_DECLARE_METATYPE(Preset)
-class InstrumentWindow
+class InstrumentWidget
: public QMainWindow
{
Q_OBJECT
public:
- InstrumentWindow(Settings& settings);
- ~InstrumentWindow();
+ InstrumentWidget(Settings& settings, Instrument& instrument);
+ ~InstrumentWidget();
public slots:
void doExport();
@@ -108,4 +109,5 @@ private:
Player player;
Settings& settings;
+ Instrument& instrument;
};
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index 435f0b0..1217fe3 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -31,38 +31,41 @@
#include <QHBoxLayout>
#include <QVBoxLayout>
-#include <QPushButton>
-#include <QLabel>
#include <QStatusBar>
#include <QApplication>
-#include <QDockWidget>
-#include <QToolBar>
-#include <QAction>
#include <QMenuBar>
#include <QFileDialog>
-#include <QIntValidator>
-#include <QTabWidget>
-#include <QProgressBar>
-#include <QTime>
-#include <QSpinBox>
-
-#include "sleep.h"
-#include "canvastool.h"
-#include "canvastoolthreshold.h"
-#include "volumefader.h"
-#include "selectioneditor.h"
-#include "zoomslider.h"
+
#include "settings.h"
#include "projectdialog.h"
#include "projectserialiser.h"
+#include "instrumentwidget.h"
#define MAXVAL 10000000L
MainWindow::MainWindow(Settings& settings)
: settings(settings)
- , instrument_window(settings)
{
- setCentralWidget(&instrument_window);
+ tab_widget = new QTabWidget();
+ tab_widget->setTabsClosable(true);
+ tab_widget->setMovable(true);
+
+ auto instr_id1 = project.createInstrument();
+ auto instr_id2 = project.createInstrument();
+ auto instr_id3 = project.createInstrument();
+
+ auto instr1 = project.getInstrument(instr_id1);
+ auto instr2 = project.getInstrument(instr_id2);
+ auto instr3 = project.getInstrument(instr_id3);
+
+ tab_widget->addTab(new InstrumentWidget(settings, instr1),
+ QPixmap(":icons/instrument.png"), "Snare");
+ tab_widget->addTab(new InstrumentWidget(settings, instr2),
+ QPixmap(":icons/instrument.png"), "Kick-l");
+ tab_widget->addTab(new InstrumentWidget(settings, instr3),
+ QPixmap(":icons/instrument.png"), "Floor Tom 1");
+
+ setCentralWidget(tab_widget);
QMenu* fileMenu = menuBar()->addMenu(tr("&File"));
@@ -87,6 +90,25 @@ MainWindow::MainWindow(Settings& settings)
fileMenu->addAction(act_quit);
connect(act_quit, SIGNAL(triggered()), this, SLOT(close()));
+ instruments_dock = new QDockWidget(tr("Instruments:"), this);
+ instruments_dock->setAllowedAreas(Qt::LeftDockWidgetArea);
+ instruments_dock->setFeatures(QDockWidget::DockWidgetMovable);
+ QListWidget* instrument_list = new QListWidget();
+ instrument_list->addItems({"Snare", "Kick-l", "Floor Tom 1"});
+ instruments_dock->setWidget(instrument_list);
+ addDockWidget(Qt::LeftDockWidgetArea, instruments_dock);
+
+ channels_dock = new QDockWidget(tr("Channels:"), this);
+ channels_dock->setAllowedAreas(Qt::LeftDockWidgetArea);
+ channels_dock->setFeatures(QDockWidget::DockWidgetMovable);
+ QListWidget* channel_list = new QListWidget();
+ channel_list->addItems({"AmbL", "AmbR", "Kdrum_back", "Kdrum_front", "Hihat",
+ "OHL", "OHR", "Ride","Snare_bottom", "Snare_top",
+ "Tom1", "Tom2", "Tom3"});
+
+ channels_dock->setWidget(channel_list);
+ addDockWidget(Qt::LeftDockWidgetArea, channels_dock);
+
loadSettings();
statusBar()->showMessage(tr("Ready"));
@@ -130,17 +152,17 @@ void MainWindow::closeEvent(QCloseEvent*)
void MainWindow::loadSettings()
{
- QSize size;
- QPoint pos;
- settings.loadGeometry(size, pos);
- resize(size);
- move(pos);
+ QByteArray state;
+ QByteArray geometry;
+ settings.loadGeometry(state, geometry);
+ restoreGeometry(geometry);
+ restoreState(state);
// TODO: lineed_exportp->setText(settings.loadExportPath());
}
void MainWindow::saveSettings()
{
- settings.saveGeometry(size(), pos());
+ settings.saveGeometry(saveState(), saveGeometry());
// TODO: settings.saveExportPath(lineed_exportp->text());
}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 7671494..49ff13f 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -28,10 +28,10 @@
#include <QMainWindow>
#include <QCloseEvent>
+#include <QDockWidget>
#include <QTabWidget>
#include "project.h"
-#include "instrumentwindow.h"
class Settings;
@@ -63,5 +63,7 @@ private:
Project project;
bool project_dirty{false};
- InstrumentWindow instrument_window;
+ QDockWidget* instruments_dock;
+ QDockWidget* channels_dock;
+ QTabWidget* tab_widget;
};
diff --git a/src/settings.cc b/src/settings.cc
index af34b70..3573f58 100644
--- a/src/settings.cc
+++ b/src/settings.cc
@@ -36,23 +36,23 @@ Settings::~Settings()
{
}
-void Settings::loadGeometry(QSize& size, QPoint& pos) const
+void Settings::loadGeometry(QByteArray &state, QByteArray &geometry) const
{
QSettings settings;
settings.beginGroup("MainWindow");
- size = settings.value("size", QSize(700, 800)).toSize();
- pos = settings.value("pos", QPoint(0, 0)).toPoint();
+ state = settings.value("state").toByteArray();
+ geometry = settings.value("geometry").toByteArray();
settings.endGroup();
}
-void Settings::saveGeometry(const QSize& size, const QPoint& pos)
+void Settings::saveGeometry(const QByteArray &state, const QByteArray &geometry)
{
QSettings settings;
settings.beginGroup("MainWindow");
- settings.setValue("size", size);
- settings.setValue("pos", pos);
+ settings.setValue("state", state);
+ settings.setValue("geometry", geometry);
settings.endGroup();
}
diff --git a/src/settings.h b/src/settings.h
index 433edad..76e2220 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -36,8 +36,8 @@ public:
Settings();
~Settings();
- void loadGeometry(QSize& size, QPoint& pos) const;
- void saveGeometry(const QSize& size, const QPoint& pos);
+ void loadGeometry(QByteArray &state, QByteArray &geometry) const;
+ void saveGeometry(const QByteArray &state, const QByteArray &geometry);
QString loadExportPath() const;
void saveExportPath(const QString& export_path);