summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dgedit/audioextractor.cc9
-rw-r--r--dgedit/audioextractor.h4
-rw-r--r--dgedit/canvastoolthreshold.cc13
-rw-r--r--dgedit/canvastoolthreshold.h1
-rw-r--r--dgedit/mainwindow.cc14
5 files changed, 39 insertions, 2 deletions
diff --git a/dgedit/audioextractor.cc b/dgedit/audioextractor.cc
index 5e37312..4250afb 100644
--- a/dgedit/audioextractor.cc
+++ b/dgedit/audioextractor.cc
@@ -29,6 +29,7 @@
#include <QDomDocument>
#include <QFile>
#include <QDir>
+#include <QApplication>
#include <sndfile.h>
@@ -44,6 +45,11 @@ AudioExtractor::AudioExtractor(Selections &s, QObject *parent)
void AudioExtractor::exportSelections()
{
+ emit setMaximumProgress(selections.ids().size());
+ int progress = 0;
+ emit progressUpdate(progress++);
+ qApp->processEvents();
+
// Open all input audio files:
audiodata_t audiodata[audiofiles.size()];
@@ -137,6 +143,9 @@ void AudioExtractor::exportSelections()
idx++;
si++;
+
+ emit progressUpdate(progress++);
+ qApp->processEvents();
}
// Close all input audio files:
diff --git a/dgedit/audioextractor.h b/dgedit/audioextractor.h
index a91fe6c..ae50d17 100644
--- a/dgedit/audioextractor.h
+++ b/dgedit/audioextractor.h
@@ -52,6 +52,10 @@ public slots:
void setExportPath(const QString &path);
void setOutputPrefix(const QString &prefix);
+signals:
+ void progressUpdate(int value);
+ void setMaximumProgress(int value);
+
private:
Selections &selections;
AudioFileList audiofiles;
diff --git a/dgedit/canvastoolthreshold.cc b/dgedit/canvastoolthreshold.cc
index d8e2dff..a321ff2 100644
--- a/dgedit/canvastoolthreshold.cc
+++ b/dgedit/canvastoolthreshold.cc
@@ -45,7 +45,9 @@ CanvasToolThreshold::CanvasToolThreshold(Canvas *c)
bool CanvasToolThreshold::mouseMoveEvent(QMouseEvent *event)
{
- if(event->button() != Qt::LeftButton) {
+ if(!isActive()) return false;
+
+ if(event->button() != Qt::LeftButton) {
if(abs(event->y() - mapY(threshold)) < 2 ||
abs(event->y() - mapY(-threshold)) < 2 ) {
canvas->setCursor(Qt::SplitVCursor);
@@ -58,6 +60,9 @@ bool CanvasToolThreshold::mouseMoveEvent(QMouseEvent *event)
if(fabs(val) > 1.0) val = 1.0;
threshold = fabs(val);
canvas->update();
+
+ emit thresholdChanging(threshold);
+
return true;
}
@@ -66,6 +71,8 @@ bool CanvasToolThreshold::mouseMoveEvent(QMouseEvent *event)
bool CanvasToolThreshold::mousePressEvent(QMouseEvent *event)
{
+ if(!isActive()) return false;
+
if(event->button() == Qt::LeftButton) {
// Check if threshold is being dragged.
@@ -82,6 +89,8 @@ bool CanvasToolThreshold::mousePressEvent(QMouseEvent *event)
bool CanvasToolThreshold::mouseReleaseEvent(QMouseEvent *event)
{
+ if(!isActive()) return false;
+
if(event->button() == Qt::LeftButton) {
if(threshold_is_moving) {
threshold_is_moving = false;
@@ -99,6 +108,8 @@ bool CanvasToolThreshold::mouseReleaseEvent(QMouseEvent *event)
void CanvasToolThreshold::paintEvent(QPaintEvent *event, QPainter &painter)
{
+ if(!isActive()) return;
+
if(threshold_is_moving) painter.setPen(colThresholdMoving);
else painter.setPen(colThreshold);
painter.drawLine(event->rect().x(), mapY(threshold),
diff --git a/dgedit/canvastoolthreshold.h b/dgedit/canvastoolthreshold.h
index 0c593e8..907e312 100644
--- a/dgedit/canvastoolthreshold.h
+++ b/dgedit/canvastoolthreshold.h
@@ -46,6 +46,7 @@ public:
signals:
void thresholdChanged(double threshold);
+ void thresholdChanging(double threshold);
private:
float threshold;
diff --git a/dgedit/mainwindow.cc b/dgedit/mainwindow.cc
index 1b82841..8cefa82 100644
--- a/dgedit/mainwindow.cc
+++ b/dgedit/mainwindow.cc
@@ -41,6 +41,7 @@
#include <QFileDialog>
#include <QIntValidator>
#include <QTabWidget>
+#include <QProgressBar>
#include <unistd.h>
@@ -86,11 +87,13 @@ MainWindow::MainWindow()
CanvasTool *listen = g_listen;
addTool(toolbar, canvas, listen);
threshold = new CanvasToolThreshold(canvas);
- addTool(toolbar, canvas, threshold);
+ canvas->tools.push_back(threshold);//addTool(toolbar, canvas, threshold);
tool_selections = new CanvasToolSelections(canvas, selections,
selections_preview);
connect(threshold, SIGNAL(thresholdChanged(double)),
tool_selections, SLOT(thresholdChanged(double)));
+ connect(threshold, SIGNAL(thresholdChanging(double)),
+ tool_selections, SLOT(thresholdChanged(double)));
connect(&selections, SIGNAL(activeChanged(sel_id_t)),
canvas, SLOT(update()));
addTool(toolbar, canvas, tool_selections);
@@ -217,6 +220,7 @@ void MainWindow::tabChanged(int tabid)
tool_selections->setShowPreview(tabid == generateTabId);
sorter->setShowPreview(tabid == generateTabId);
tool_selections->autoCreateSelectionsPreview();
+ threshold->setActive(tabid == generateTabId);
}
QWidget *MainWindow::createFilesTab()
@@ -267,6 +271,8 @@ QWidget *MainWindow::createGenerateTab()
connect(threshold, SIGNAL(thresholdChanged(double)),
tool_selections, SLOT(autoCreateSelectionsPreview()));
+ connect(threshold, SIGNAL(thresholdChanging(double)),
+ tool_selections, SLOT(autoCreateSelectionsPreview()));
QPushButton *clearsel = new QPushButton();
clearsel->setText("Clear");
@@ -375,6 +381,12 @@ QWidget *MainWindow::createExportTab()
connect(exportsel, SIGNAL(clicked()), this, SLOT(doExport()));
l->addWidget(exportsel);
+ QProgressBar *bar = new QProgressBar();
+ connect(extractor, SIGNAL(progressUpdate(int)), bar, SLOT(setValue(int)));
+ connect(extractor, SIGNAL(setMaximumProgress(int)),
+ bar, SLOT(setMaximum(int)));
+ l->addWidget(bar);
+
l->addStretch();
return w;