|
|
|
@ -18,15 +18,18 @@ |
|
|
|
#include <QResizeEvent> |
|
|
|
#include <QResizeEvent> |
|
|
|
#include <QDir> |
|
|
|
#include <QDir> |
|
|
|
#include <QProgressBar> |
|
|
|
#include <QProgressBar> |
|
|
|
|
|
|
|
#include <QIcon> |
|
|
|
#include <cmath> |
|
|
|
#include <cmath> |
|
|
|
|
|
|
|
|
|
|
|
static QPushButton *makeIconBtn(const QString &text, const QString &tooltip, QWidget *parent) { |
|
|
|
static QPushButton *makeIconBtn(const QIcon& icon, const QString &tooltip, QWidget *parent) { |
|
|
|
auto *btn = new QPushButton(text, parent); |
|
|
|
auto *btn = new QPushButton(parent); |
|
|
|
|
|
|
|
btn->setIcon(icon); |
|
|
|
|
|
|
|
btn->setIconSize(QSize(20, 20)); |
|
|
|
btn->setFixedSize(34, 34); |
|
|
|
btn->setFixedSize(34, 34); |
|
|
|
btn->setCursor(Qt::PointingHandCursor); |
|
|
|
btn->setCursor(Qt::PointingHandCursor); |
|
|
|
btn->setToolTip(tooltip); |
|
|
|
btn->setToolTip(tooltip); |
|
|
|
btn->setStyleSheet( |
|
|
|
btn->setStyleSheet( |
|
|
|
"QPushButton { border: none; border-radius: 4px; font-size: 18px; background: transparent; }" |
|
|
|
"QPushButton { border: none; border-radius: 4px; background: transparent; }" |
|
|
|
"QPushButton:hover { background: palette(light); }" |
|
|
|
"QPushButton:hover { background: palette(light); }" |
|
|
|
); |
|
|
|
); |
|
|
|
return btn; |
|
|
|
return btn; |
|
|
|
@ -54,7 +57,7 @@ InputBar::InputBar(EmojiPanel *emojiPanel, AudioRecorder *recorder, QWidget *par |
|
|
|
layout->setContentsMargins(8, 4, 8, 4); |
|
|
|
layout->setContentsMargins(8, 4, 8, 4); |
|
|
|
layout->setSpacing(4); |
|
|
|
layout->setSpacing(4); |
|
|
|
|
|
|
|
|
|
|
|
m_attachBtn = makeIconBtn(QString::fromUtf8("\xF0\x9F\x93\x8E"), |
|
|
|
m_attachBtn = makeIconBtn(QIcon(":/icons/attach.png"), |
|
|
|
QString::fromUtf8("Прикрепить"), this); |
|
|
|
QString::fromUtf8("Прикрепить"), this); |
|
|
|
connect(m_attachBtn, &QPushButton::clicked, this, &InputBar::onAttachClicked); |
|
|
|
connect(m_attachBtn, &QPushButton::clicked, this, &InputBar::onAttachClicked); |
|
|
|
layout->addWidget(wrapBottomBtn(m_attachBtn, 3), 0, Qt::AlignBottom); |
|
|
|
layout->addWidget(wrapBottomBtn(m_attachBtn, 3), 0, Qt::AlignBottom); |
|
|
|
@ -72,18 +75,18 @@ InputBar::InputBar(EmojiPanel *emojiPanel, AudioRecorder *recorder, QWidget *par |
|
|
|
m_input->setFixedHeight(fm.lineSpacing() + 12); |
|
|
|
m_input->setFixedHeight(fm.lineSpacing() + 12); |
|
|
|
layout->addWidget(m_input, 1); |
|
|
|
layout->addWidget(m_input, 1); |
|
|
|
|
|
|
|
|
|
|
|
m_emojiBtn = makeIconBtn(QString::fromUtf8("\xF0\x9F\x99\x82"), |
|
|
|
m_emojiBtn = makeIconBtn(QIcon(":/icons/emoji.png"), |
|
|
|
QString::fromUtf8("Смайлики"), this); |
|
|
|
QString::fromUtf8("Смайлики"), this); |
|
|
|
layout->addWidget(wrapBottomBtn(m_emojiBtn, 3), 0, Qt::AlignBottom); |
|
|
|
layout->addWidget(wrapBottomBtn(m_emojiBtn, 3), 0, Qt::AlignBottom); |
|
|
|
|
|
|
|
|
|
|
|
m_pttBtn = makeIconBtn(QString::fromUtf8("\xF0\x9F\x8E\xA4"), |
|
|
|
m_pttBtn = makeIconBtn(QIcon(":/icons/mic.png"), |
|
|
|
QString::fromUtf8("Голосовое сообщение (удерживайте)"), this); |
|
|
|
QString::fromUtf8("Голосовое сообщение (удерживайте)"), this); |
|
|
|
layout->addWidget(wrapBottomBtn(m_pttBtn, 3), 0, Qt::AlignBottom); |
|
|
|
layout->addWidget(wrapBottomBtn(m_pttBtn, 3), 0, Qt::AlignBottom); |
|
|
|
|
|
|
|
|
|
|
|
auto *sendBtn = makeIconBtn(QString::fromUtf8("\xE2\x9E\xA4"), |
|
|
|
auto *sendBtn = makeIconBtn(QIcon(":/icons/send.png"), |
|
|
|
QString::fromUtf8("Отправить"), this); |
|
|
|
QString::fromUtf8("Отправить"), this); |
|
|
|
sendBtn->setStyleSheet(sendBtn->styleSheet() + |
|
|
|
sendBtn->setStyleSheet(sendBtn->styleSheet() + |
|
|
|
"QPushButton { color: palette(highlight); font-weight: bold; }"); |
|
|
|
"QPushButton { border: 1px solid palette(highlight); }"); |
|
|
|
layout->addWidget(sendBtn, 0, Qt::AlignBottom); |
|
|
|
layout->addWidget(sendBtn, 0, Qt::AlignBottom); |
|
|
|
|
|
|
|
|
|
|
|
connect(m_input, &QTextEdit::textChanged, this, &InputBar::adjustInputHeight); |
|
|
|
connect(m_input, &QTextEdit::textChanged, this, &InputBar::adjustInputHeight); |
|
|
|
@ -203,7 +206,7 @@ void InputBar::onPttPressed() { |
|
|
|
m_recorder->startRecording(); |
|
|
|
m_recorder->startRecording(); |
|
|
|
m_pttActive = true; |
|
|
|
m_pttActive = true; |
|
|
|
m_pttBtn->setStyleSheet(m_pttBtn->styleSheet() + |
|
|
|
m_pttBtn->setStyleSheet(m_pttBtn->styleSheet() + |
|
|
|
"QPushButton { background: #e74c3c; color: white; border-radius: 4px; }"); |
|
|
|
"QPushButton { background: #e74c3c; border-radius: 4px; }"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void InputBar::onPttReleased() { |
|
|
|
void InputBar::onPttReleased() { |
|
|
|
@ -211,7 +214,7 @@ void InputBar::onPttReleased() { |
|
|
|
m_pttActive = false; |
|
|
|
m_pttActive = false; |
|
|
|
m_recorder->stopRecording(); |
|
|
|
m_recorder->stopRecording(); |
|
|
|
m_pttBtn->setStyleSheet( |
|
|
|
m_pttBtn->setStyleSheet( |
|
|
|
"QPushButton { border: none; border-radius: 4px; font-size: 18px; background: transparent; }" |
|
|
|
"QPushButton { border: none; border-radius: 4px; background: transparent; }" |
|
|
|
"QPushButton:hover { background: palette(light); }"); |
|
|
|
"QPushButton:hover { background: palette(light); }"); |
|
|
|
|
|
|
|
|
|
|
|
int durationMs = m_recorder->durationMs(); |
|
|
|
int durationMs = m_recorder->durationMs(); |
|
|
|
|