setStart setStop working

This commit is contained in:
mrbesen 2021-12-20 15:00:13 +01:00
parent ffa03cc0e6
commit b4dcbd176d
Signed by untrusted user: MrBesen
GPG Key ID: 596B2350DCD67504
2 changed files with 24 additions and 0 deletions

View File

@ -20,6 +20,10 @@ public slots:
void play();
void stop();
private slots:
void setStartToCurrent();
void setStopToCurrent();
private:
Ui::EditSample* ui;

View File

@ -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 (((((