From 6dbcd24cee07b519981f128c1fae8870e839e79e Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Tue, 22 Apr 2014 21:38:40 +0200 Subject: Make player play preview samples when 'generate' tab is active. --- dgedit/mainwindow.cc | 15 +++++++++------ dgedit/mainwindow.h | 3 +++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/dgedit/mainwindow.cc b/dgedit/mainwindow.cc index 58e048f..d815d5c 100644 --- a/dgedit/mainwindow.cc +++ b/dgedit/mainwindow.cc @@ -174,7 +174,7 @@ MainWindow::MainWindow() this, SLOT(setPreset(int))); dockWidget->widget()->layout()->addWidget(presets); - QTabWidget *tabs = new QTabWidget(this); + tabs = new QTabWidget(this); tabs->addTab(createFilesTab(), "Files"); generateTabId = tabs->addTab(createGenerateTab(), "Generate"); tabs->addTab(createEditTab(), "Edit"); @@ -402,12 +402,15 @@ QWidget *MainWindow::createExportTab() void MainWindow::playSamples() { - QVector ids = selections.ids(); + Selections *sels = &selections; + if(tabs->currentIndex() == generateTabId) sels = &selections_preview; + + QVector ids = sels->ids(); for(int v1 = 0; v1 < ids.size(); v1++) { for(int v2 = 0; v2 < ids.size(); v2++) { - Selection sel1 = selections.get(ids[v1]); - Selection sel2 = selections.get(ids[v2]); + Selection sel1 = sels->get(ids[v1]); + Selection sel2 = sels->get(ids[v2]); if(sel1.energy < sel2.energy) { sel_id_t vtmp = ids[v1]; @@ -419,7 +422,7 @@ void MainWindow::playSamples() QVector::iterator i = ids.begin(); while(i != ids.end()) { - Selection sel = selections.get(*i); + Selection sel = sels->get(*i); unsigned int length = sb_playsamples->value() * 44100 / 1000; @@ -429,7 +432,7 @@ void MainWindow::playSamples() if(sample_length > length) to = sel.from + length; - selections.setActive(*i); + sels->setActive(*i); connect(&player, SIGNAL(positionUpdate(size_t)), listen, SLOT(update(size_t))); diff --git a/dgedit/mainwindow.h b/dgedit/mainwindow.h index a47e729..ee25982 100644 --- a/dgedit/mainwindow.h +++ b/dgedit/mainwindow.h @@ -33,6 +33,7 @@ #include #include #include +#include #include "canvas.h" #include "audioextractor.h" @@ -105,6 +106,8 @@ private: QLineEdit *prefix; QLineEdit *lineed_exportp; + QTabWidget *tabs; + // Session state information: Selections selections; Selections selections_preview; -- cgit v1.2.3