Skip to content

Commit

Permalink
qite update
Browse files Browse the repository at this point in the history
  • Loading branch information
Ri0n committed Mar 21, 2024
1 parent a30cb7a commit 5cfe2f5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/qite
36 changes: 18 additions & 18 deletions src/msgmle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <QLabel>
#include <QLayout>
#include <QMenu>
#include <QMessageBox>
#include <QMimeData>
#include <QMimeDatabase>
#include <QRegularExpression>
Expand Down Expand Up @@ -675,7 +676,11 @@ void ChatEdit::addSoundRecButton()

recorder_.reset(new AudioRecorder);
recorder_->setMaxDuration(TIMEOUT);
connect(recorder_.get(), &AudioRecorder::recorded, this, [this]() {
connect(recorder_.get(), &AudioRecorder::finished, this, [this](bool success) {
if (!success) {
QMessageBox::warning(this, tr("Audio recording failed"), recorder_->errorString(), QMessageBox::Ok);
return;
}
if (recorder_->duration() < 1000)
return;

Expand All @@ -686,25 +691,20 @@ void ChatEdit::addSoundRecButton()
md.setData("application/x-psi-amplitudes", recorder_->amplitudes());
emit fileSharingRequested(&md);
});
connect(recorder_.get(), &AudioRecorder::stateChanged, this, [this]() {
if (recorder_->state() != AudioRecorder::RecordingState) {
return;
recButton_->setIcon(IconsetFactory::iconPixmap("psi/mic_rec", fontInfo().pixelSize() * 1.5));
overlay_->setVisible(true);
timeout_ = TIMEOUT;
timer_ = new QTimer(this); // countdown timer to stop recording while the button is pressed
connect(timer_, &QTimer::timeout, this, [this]() {
if (timeout_ > 0) {
timeout_ -= SECOND;
setOverlayText(timeout_ / SECOND);
} else {
timer_->stop();
recorder_->stop();
}
recButton_->setIcon(IconsetFactory::iconPixmap("psi/mic_rec", fontInfo().pixelSize() * 1.5));
overlay_->setVisible(true);
timeout_ = TIMEOUT;
timer_ = new QTimer(this); // countdown timer to stop recording while the button is pressed
connect(timer_, &QTimer::timeout, this, [this]() {
if (timeout_ > 0) {
timeout_ -= SECOND;
setOverlayText(timeout_ / SECOND);
} else {
timer_->stop();
recorder_->stop();
}
});
timer_->start(SECOND);
});
timer_->start(SECOND);
recorder_->record();
});
connect(recButton_, &QToolButton::released, this, [this]() { // Rec button relesed
Expand Down

0 comments on commit 5cfe2f5

Please sign in to comment.