|
|
|
|
@ -377,27 +377,11 @@ MessageList::MessageList(DbManager* db, AudioRecorder* recorder, QWidget *parent
|
|
|
|
|
m_channelTitle->setStyleSheet("font-weight: bold; font-size: 14px;"); |
|
|
|
|
m_channelTitle->setText(QCoreApplication::translate("ChatGui", "Channel")); |
|
|
|
|
hl->addWidget(m_channelTitle, 1); |
|
|
|
|
m_pollBtn = new QPushButton(QCoreApplication::translate("ChatGui", "Create poll"), header); |
|
|
|
|
hl->addWidget(m_pollBtn); |
|
|
|
|
connect(m_pollBtn, &QPushButton::clicked, this, &MessageList::createPoll); |
|
|
|
|
|
|
|
|
|
m_talkingLabel = new QLabel(header); |
|
|
|
|
m_talkingLabel->setStyleSheet("color: #27ae60; font-size: 12px;"); |
|
|
|
|
m_talkingLabel->hide(); |
|
|
|
|
hl->addWidget(m_talkingLabel); |
|
|
|
|
|
|
|
|
|
m_ownFilesButton = new QPushButton(header); |
|
|
|
|
m_ownFilesButton->setObjectName("ownFilesButton"); |
|
|
|
|
m_ownFilesButton->setIcon(style()->standardIcon(QStyle::SP_DirOpenIcon)); |
|
|
|
|
m_ownFilesButton->setIconSize(QSize(24, 24)); |
|
|
|
|
m_ownFilesButton->setFixedSize(34, 30); |
|
|
|
|
m_ownFilesButton->setCursor(Qt::PointingHandCursor); |
|
|
|
|
m_ownFilesButton->setToolTip(QCoreApplication::translate("ChatGui", "My files in the selected group")); |
|
|
|
|
m_ownFilesButton->setAccessibleName(m_ownFilesButton->toolTip()); |
|
|
|
|
m_ownFilesButton->hide(); |
|
|
|
|
hl->addWidget(m_ownFilesButton); |
|
|
|
|
connect(m_ownFilesButton, &QPushButton::clicked, this, [this] { emit ownFilesRequested(m_currentChannelId); }); |
|
|
|
|
|
|
|
|
|
m_inviteBtn = new QPushButton(QStringLiteral("+"), header); |
|
|
|
|
m_inviteBtn->setAccessibleName(QCoreApplication::translate("ChatGui", "Invite to group")); |
|
|
|
|
m_inviteBtn->setToolTip(QCoreApplication::translate("ChatGui", "Invite to group")); |
|
|
|
|
@ -442,6 +426,56 @@ MessageList::MessageList(DbManager* db, AudioRecorder* recorder, QWidget *parent
|
|
|
|
|
connect(m_radioBtn, &QPushButton::toggled, this, &MessageList::onRadioToggled); |
|
|
|
|
hl->addWidget(m_radioBtn); |
|
|
|
|
|
|
|
|
|
m_groupMenuButton = new QPushButton(QStringLiteral("…"), header); |
|
|
|
|
m_groupMenuButton->setObjectName("groupMenuButton"); |
|
|
|
|
m_groupMenuButton->setFixedSize(34, 30); |
|
|
|
|
m_groupMenuButton->setCursor(Qt::PointingHandCursor); |
|
|
|
|
m_groupMenuButton->setToolTip(QCoreApplication::translate("ChatGui", "Options")); |
|
|
|
|
m_groupMenuButton->setAccessibleName(m_groupMenuButton->toolTip()); |
|
|
|
|
m_groupMenuButton->hide(); |
|
|
|
|
hl->addWidget(m_groupMenuButton); |
|
|
|
|
connect(m_groupMenuButton, &QPushButton::clicked, this, [this] { |
|
|
|
|
const QString channel = m_currentChannelId; |
|
|
|
|
if (!channel.toULongLong()) return; |
|
|
|
|
auto text = [](const char* s) { return QCoreApplication::translate("ChatGui", s); }; |
|
|
|
|
QMenu menu(this); |
|
|
|
|
auto* files = menu.addAction(text("Group files")); |
|
|
|
|
auto* ownFiles = menu.addAction(text("My files")); |
|
|
|
|
auto* poll = menu.addAction(text("Create poll")); |
|
|
|
|
menu.addSeparator(); |
|
|
|
|
auto* share = menu.addAction(text("Invite link")); |
|
|
|
|
auto* invite = menu.addAction(text("Invite by node link")); |
|
|
|
|
menu.addSeparator(); |
|
|
|
|
auto* sound = menu.addAction(text("Sound")); sound->setCheckable(true); |
|
|
|
|
sound->setEnabled(m_db && m_db->isOpen() && gui_bridge_is_uasync_ready()); |
|
|
|
|
sound->setChecked(m_db && m_db->getUiStateInt(QStringLiteral("ch_%1_sound_on_message").arg(channel), 1)); |
|
|
|
|
auto* settings = menu.addAction(text("Channel Settings")); |
|
|
|
|
QPointer<MessageList> guard(this); |
|
|
|
|
auto* action = menu.exec(m_groupMenuButton->mapToGlobal(QPoint(0, m_groupMenuButton->height()))); |
|
|
|
|
if (!guard || !action) return; |
|
|
|
|
if (channel != m_currentChannelId) { |
|
|
|
|
DEBUG_WARN(DEBUG_CATEGORY_CHAT, "group menu: channel changed old=%s current=%s", qPrintable(channel), qPrintable(m_currentChannelId)); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_CHAT, "group menu: channel=%s action=%s", qPrintable(channel), qPrintable(action->text())); |
|
|
|
|
if (action == files) emit filesRequested(channel); |
|
|
|
|
else if (action == ownFiles) emit ownFilesRequested(channel); |
|
|
|
|
else if (action == poll) createPoll(); |
|
|
|
|
else if (action == share) emit shareInviteRequested(channel); |
|
|
|
|
else if (action == invite) emit inviteByLinkRequested(channel); |
|
|
|
|
else if (action == settings) emit channelSettingsRequested(channel); |
|
|
|
|
else if (action == sound) { |
|
|
|
|
if (!gui_bridge_is_uasync_ready()) { |
|
|
|
|
DEBUG_WARN(DEBUG_CATEGORY_CHAT, "group menu: sound update unavailable channel=%s", qPrintable(channel)); return; |
|
|
|
|
} |
|
|
|
|
auto* arg = (chat_sound_arg*)u_calloc(1, sizeof(chat_sound_arg)); |
|
|
|
|
if (!arg) { DEBUG_ERROR(DEBUG_CATEGORY_CHAT, "group menu: sound allocation failed"); return; } |
|
|
|
|
arg->inst = gui_bridge_get_inst(); arg->on = sound->isChecked(); |
|
|
|
|
snprintf(arg->ch_id, sizeof(arg->ch_id), "%s", channel.toUtf8().constData()); |
|
|
|
|
gui_bridge_post_uasync_fn(chat_core_set_sound_on_message_trampoline, arg); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
header->setStyleSheet("background: palette(window);"); |
|
|
|
|
layout->addWidget(header); |
|
|
|
|
} |
|
|
|
|
@ -715,8 +749,7 @@ void MessageList::loadChannel(const QString& channelId) {
|
|
|
|
|
m_avatarCache.clear(); |
|
|
|
|
if (m_currentChannelId != channelId) { m_feedback.clear(); m_pendingPoll.clear(); } |
|
|
|
|
m_currentChannelId = channelId; |
|
|
|
|
m_ownFilesButton->setVisible(channelId.toULongLong() != 0); |
|
|
|
|
m_pollBtn->setVisible(!isDmChannel(channelId)); |
|
|
|
|
m_groupMenuButton->setVisible(channelId.toULongLong() != 0); |
|
|
|
|
clearDmCallRoute(); |
|
|
|
|
m_callBtn->setVisible(isDmChannel(channelId)); |
|
|
|
|
m_inviteBtn->setVisible(isDmChannel(channelId)); |
|
|
|
|
|