forked from MrBesen/soundboard
setStart setStop working
This commit is contained in:
parent
ffa03cc0e6
commit
b4dcbd176d
|
@ -20,6 +20,10 @@ public slots:
|
||||||
void play();
|
void play();
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void setStartToCurrent();
|
||||||
|
void setStopToCurrent();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::EditSample* ui;
|
Ui::EditSample* ui;
|
||||||
|
|
||||||
|
|
|
@ -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->playButton, SIGNAL( clicked() ), this, SLOT( play() ));
|
||||||
QObject::connect(ui->stopButton, SIGNAL( clicked() ), this, SLOT( stop() ));
|
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);
|
setCurrentPosition(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +49,23 @@ void EditSample::stop() {
|
||||||
Sound::instance().stopAll();
|
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 {
|
uint64_t EditSample::getTimeInfo(const QTimeEdit* time) const {
|
||||||
QTime timedata = time->time();
|
QTime timedata = time->time();
|
||||||
return (((((
|
return (((((
|
||||||
|
|
Loading…
Reference in New Issue