diff --git a/include/editsample.h b/include/editsample.h index b162528..f4c642b 100644 --- a/include/editsample.h +++ b/include/editsample.h @@ -20,6 +20,10 @@ public slots: void play(); void stop(); +private slots: + void setStartToCurrent(); + void setStopToCurrent(); + private: Ui::EditSample* ui; diff --git a/src/editsample.cpp b/src/editsample.cpp index 9fbf565..2aadf8b 100644 --- a/src/editsample.cpp +++ b/src/editsample.cpp @@ -18,6 +18,9 @@ EditSample::EditSample(const std::string& audioFile_, QWidget *parent) : QDialog QObject::connect(ui->playButton, SIGNAL( clicked() ), this, SLOT( play() )); QObject::connect(ui->stopButton, SIGNAL( clicked() ), this, SLOT( stop() )); + QObject::connect(ui->starttoCurrentButton, SIGNAL( clicked() ), this, SLOT( setStartToCurrent() )); + QObject::connect(ui->stoptoCurrentButton, SIGNAL( clicked() ), this, SLOT( setStopToCurrent() )); + setCurrentPosition(0); } @@ -46,6 +49,23 @@ void EditSample::stop() { Sound::instance().stopAll(); } +void EditSample::setStartToCurrent() { + QTime time = timeFromMS(currentposition); + ui->startTime->setTime(time); +} + +void EditSample::setStopToCurrent() { + uint64_t offset = getTimeInfo(ui->startTime); + if(offset < currentposition) { + // current position is behind startposition -> shorten length to match + QTime time = timeFromMS(currentposition-offset); + ui->lengthTime->setTime(time); + } else { + // TODO: + // currentposition is before offset -> move entire section to match? do nothing? + } +} + uint64_t EditSample::getTimeInfo(const QTimeEdit* time) const { QTime timedata = time->time(); return (((((