|
|
|
|
@ -100,9 +100,9 @@ InputBar::InputBar(EmojiPanel *emojiPanel, AudioRecorder *recorder, QWidget *par
|
|
|
|
|
m_attachPreview->hide(); |
|
|
|
|
mainLayout->addWidget(m_attachPreview); |
|
|
|
|
|
|
|
|
|
m_videoProgressTimer = new QTimer(this); |
|
|
|
|
m_videoProgressTimer->setInterval(150); |
|
|
|
|
connect(m_videoProgressTimer, &QTimer::timeout, this, &InputBar::onVideoProgressTick); |
|
|
|
|
m_preparationLabel = new QLabel(this); |
|
|
|
|
m_preparationLabel->hide(); |
|
|
|
|
mainLayout->addWidget(m_preparationLabel); |
|
|
|
|
|
|
|
|
|
auto *layout = new QHBoxLayout(); |
|
|
|
|
layout->setSpacing(4); |
|
|
|
|
@ -260,9 +260,7 @@ void InputBar::onSendClicked() {
|
|
|
|
|
snprintf(request->source, sizeof(request->source), "%s", source.constData()); |
|
|
|
|
snprintf(request->info.name, sizeof(request->info.name), "%s", name.constData()); |
|
|
|
|
emit submitAttachment(m_channelIdForRecord, request); |
|
|
|
|
m_attachPreviewLabel->setText(QString::fromUtf8("\xF0\x9F\x8E\xAC Перекодирование… 0%")); |
|
|
|
|
m_attachPreview->show(); |
|
|
|
|
m_videoProgressTimer->start(); |
|
|
|
|
m_attachPreview->hide(); |
|
|
|
|
} else { |
|
|
|
|
GUI_INFO("send: file=%s name=%s", qPrintable(m_pendingAttachSrc), qPrintable(m_pendingAttachName)); |
|
|
|
|
emit sendFileAttachment(m_channelIdForRecord, m_pendingAttachSrc, m_pendingAttachDest, m_pendingAttachName); |
|
|
|
|
@ -287,6 +285,7 @@ void InputBar::setRecordingContext(const QString& mediaDirBase, const QString& c
|
|
|
|
|
if (m_channelIdForRecord != channelId) clearPendingAttachment(); |
|
|
|
|
m_mediaDirBase = mediaDirBase; |
|
|
|
|
m_channelIdForRecord = channelId; |
|
|
|
|
showPreparation(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void InputBar::setDmMode(bool enabled) { |
|
|
|
|
@ -407,18 +406,25 @@ void InputBar::clearPendingAttachment() {
|
|
|
|
|
m_pendingAttachSize = 0; |
|
|
|
|
m_pendingAttachAsVideo = false; |
|
|
|
|
m_pendingAttachAsImage = false; |
|
|
|
|
m_videoProgressTimer->stop(); |
|
|
|
|
m_attachPreview->hide(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void InputBar::onVideoProgressTick() { |
|
|
|
|
int p = video_transcode_get_progress(); |
|
|
|
|
if (p < 0) { |
|
|
|
|
m_videoProgressTimer->stop(); |
|
|
|
|
m_attachPreview->hide(); |
|
|
|
|
return; |
|
|
|
|
void InputBar::updatePreparation(const QString& target, const QByteArray& job, int state) { |
|
|
|
|
if (state == 0) { m_preparations[target].insert(job); m_preparationErrors.remove(target); } |
|
|
|
|
else { |
|
|
|
|
m_preparations[target].remove(job); |
|
|
|
|
if (m_preparations[target].isEmpty()) m_preparations.remove(target); |
|
|
|
|
if (state == 2) m_preparationErrors.insert(target); |
|
|
|
|
} |
|
|
|
|
m_attachPreviewLabel->setText(QString::fromUtf8("\xF0\x9F\x8E\xAC Перекодирование… %1%").arg(p / 10)); |
|
|
|
|
showPreparation(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void InputBar::showPreparation() { |
|
|
|
|
QString status; |
|
|
|
|
if (!m_preparations.value(m_channelIdForRecord).isEmpty()) status = QString::fromUtf8("Подготовка медиа…"); |
|
|
|
|
else if (m_preparationErrors.contains(m_channelIdForRecord)) status = QString::fromUtf8("Не удалось подготовить вложение"); |
|
|
|
|
m_preparationLabel->setText(status); |
|
|
|
|
m_preparationLabel->setVisible(!status.isEmpty()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void InputBar::resizeEvent(QResizeEvent* event) { |
|
|
|
|
|