summaryrefslogtreecommitdiff
path: root/dgedit/mainwindow.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2011-10-02 09:58:10 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2011-10-02 09:58:10 +0200
commitf474c3c923fe5bb27c1ee11e2c6dd57e41889f27 (patch)
tree93e2a3e2624bb2e4d238d22124956cd066643b03 /dgedit/mainwindow.cc
parent83807cf93ef362098d6fea6030646653cc62e37f (diff)
Made conenctions for CanvasTool work (again...).
Diffstat (limited to 'dgedit/mainwindow.cc')
-rw-r--r--dgedit/mainwindow.cc43
1 files changed, 38 insertions, 5 deletions
diff --git a/dgedit/mainwindow.cc b/dgedit/mainwindow.cc
index 9454a97..c750a22 100644
--- a/dgedit/mainwindow.cc
+++ b/dgedit/mainwindow.cc
@@ -36,11 +36,29 @@
#include <QApplication>
#include <QDockWidget>
#include <QSettings>
+#include <QToolBar>
+#include <QAction>
+#include <QMenuBar>
+
+#include "canvastool.h"
+#include "canvastoolselections.h"
+#include "canvastoolthreshold.h"
+#include "canvastoollisten.h"
#define MAXVAL 10000000L
#define SINGLESTEP MAXVAL/100000
#define PAGESTEP MAXVAL/10000
+static void addTool(QToolBar *toolbar, Canvas *canvas, CanvasTool *tool)
+{
+ QAction *action = new QAction(tool->name(), toolbar);
+ action->setCheckable(true);
+ toolbar->addAction(action);
+ tool->connect(action, SIGNAL(toggled(bool)), tool, SLOT(setActive(bool)));
+ tool->setActive(false);
+ canvas->tools.push_back(tool);
+}
+
MainWindow::MainWindow()
{
QWidget *central = new QWidget();
@@ -52,6 +70,21 @@ MainWindow::MainWindow()
extractor = new AudioExtractor(this);
canvas = new Canvas(this);
+ QToolBar *toolbar = addToolBar("Tools");
+ CanvasTool *listen = new CanvasToolListen(canvas);
+ addTool(toolbar, canvas, listen);
+ CanvasTool *threshold = new CanvasToolThreshold(canvas);
+ addTool(toolbar, canvas, threshold);
+ CanvasTool *selections = new CanvasToolSelections(canvas);
+ connect(threshold, SIGNAL(thresholdChanged(double)),
+ selections, SLOT(thresholdChanged(double)));
+ addTool(toolbar, canvas, selections);
+
+ QMenu *fileMenu = menuBar()->addMenu("&File");
+ QAction *act_quit = new QAction("&Quit", this);
+ fileMenu->addAction(act_quit);
+ connect(act_quit, SIGNAL(triggered()), this, SLOT(close()));
+
QWidget *dock = new QWidget();
yoffset = new QScrollBar(Qt::Vertical);
yoffset->setRange(0, MAXVAL);
@@ -78,9 +111,9 @@ MainWindow::MainWindow()
connect(xoffset, SIGNAL(valueChanged(int)), this, SLOT(setXOffset(int)));
sorter = new SampleSorter();
- connect(canvas, SIGNAL(selectionsChanged(Selections)),
+ connect(selections, SIGNAL(selectionsChanged(Selections)),
sorter, SLOT(setSelections(Selections)));
- connect(canvas, SIGNAL(activeSelectionChanged(Selection)),
+ connect(selections, SIGNAL(activeSelectionChanged(Selection)),
sorter, SLOT(setActiveSelection(Selection)));
lh->addWidget(canvas);
@@ -96,12 +129,12 @@ MainWindow::MainWindow()
QPushButton *autosel = new QPushButton();
autosel->setText("Auto");
- connect(autosel, SIGNAL(clicked()), canvas, SLOT(clearSelections()));
- connect(autosel, SIGNAL(clicked()), canvas, SLOT(autoCreateSelections()));
+ connect(autosel, SIGNAL(clicked()), selections, SLOT(clearSelections()));
+ connect(autosel, SIGNAL(clicked()), selections, SLOT(autoCreateSelections()));
QPushButton *clearsel = new QPushButton();
clearsel->setText("Clear");
- connect(clearsel, SIGNAL(clicked()), canvas, SLOT(clearSelections()));
+ connect(clearsel, SIGNAL(clicked()), selections, SLOT(clearSelections()));
QPushButton *exportsel = new QPushButton();
exportsel->setText("Export");