From f474c3c923fe5bb27c1ee11e2c6dd57e41889f27 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 2 Oct 2011 09:58:10 +0200 Subject: Made conenctions for CanvasTool work (again...). --- dgedit/mainwindow.cc | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) (limited to 'dgedit/mainwindow.cc') 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 #include #include +#include +#include +#include + +#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"); -- cgit v1.2.3