Browse Source
- node_put/node_update_verified: set online=1 on INSERT (nodes created when conn is UP) - channel_peers_all: fix peer_needed calculation (atl byte was missing) - cs_send_channel_join: add proto byte to address serialization matching all parserstopo_upd
18 changed files with 431 additions and 24 deletions
@ -0,0 +1,99 @@
|
||||
#include "channelsettingsdialog.h" |
||||
#include "../db/db_manager.h" |
||||
#include "../transport/gui_bridge.h" |
||||
#include "../../lib/mem.h" |
||||
extern "C" { |
||||
#include "chat/chat_core.h" |
||||
} |
||||
#include <QVBoxLayout> |
||||
#include <QHBoxLayout> |
||||
#include <QPushButton> |
||||
#include <QLabel> |
||||
|
||||
ChannelSettingsDialog::ChannelSettingsDialog(const QString& channelId, DbManager* db, QWidget* parent) |
||||
: QDialog(parent) |
||||
, m_channelId(channelId) |
||||
, m_db(db) |
||||
{ |
||||
setWindowTitle(QStringLiteral("Channel Settings")); |
||||
setMinimumWidth(340); |
||||
setModal(true); |
||||
|
||||
auto* layout = new QVBoxLayout(this); |
||||
layout->setContentsMargins(20, 16, 20, 16); |
||||
layout->setSpacing(12); |
||||
|
||||
auto* titleLabel = new QLabel(QStringLiteral("Settings for channel"), this); |
||||
titleLabel->setStyleSheet("font-weight: bold; font-size: 14px;"); |
||||
layout->addWidget(titleLabel); |
||||
|
||||
auto* chIdLabel = new QLabel(channelId, this); |
||||
chIdLabel->setStyleSheet("color: gray; font-size: 11px;"); |
||||
chIdLabel->setWordWrap(true); |
||||
layout->addWidget(chIdLabel); |
||||
|
||||
layout->addSpacing(8); |
||||
|
||||
m_autoPlayVoice = new QCheckBox(QStringLiteral("Auto-play voice messages on receive"), this); |
||||
m_autoPlayVoice->setToolTip(QStringLiteral("Voice messages will play automatically when received. Multiple messages queue up and play sequentially without interrupting current playback.")); |
||||
layout->addWidget(m_autoPlayVoice); |
||||
|
||||
m_pttMode = new QCheckBox(QStringLiteral("Push-To-Talk (PTT) mode"), this); |
||||
m_pttMode->setToolTip(QStringLiteral("Record voice messages with push-to-talk. (Coming soon)")); |
||||
m_pttMode->setEnabled(false); |
||||
layout->addWidget(m_pttMode); |
||||
|
||||
layout->addStretch(); |
||||
|
||||
auto* btnLayout = new QHBoxLayout(); |
||||
btnLayout->setSpacing(8); |
||||
btnLayout->addStretch(); |
||||
|
||||
auto* cancelBtn = new QPushButton(QStringLiteral("Cancel"), this); |
||||
cancelBtn->setFixedWidth(90); |
||||
cancelBtn->setStyleSheet( |
||||
"QPushButton { border: 1px solid palette(mid); border-radius: 4px;" |
||||
" padding: 6px 16px; font-size: 13px; background: palette(button); }" |
||||
"QPushButton:hover { background: palette(light); }"); |
||||
connect(cancelBtn, &QPushButton::clicked, this, &QDialog::reject); |
||||
btnLayout->addWidget(cancelBtn); |
||||
|
||||
auto* saveBtn = new QPushButton(QStringLiteral("Save"), this); |
||||
saveBtn->setFixedWidth(90); |
||||
saveBtn->setDefault(true); |
||||
saveBtn->setStyleSheet( |
||||
"QPushButton { border: none; border-radius: 4px;" |
||||
" padding: 6px 16px; font-size: 13px; font-weight: bold;" |
||||
" background: #3390EC; color: white; }" |
||||
"QPushButton:hover { background: #2B7ED4; }"); |
||||
connect(saveBtn, &QPushButton::clicked, this, &ChannelSettingsDialog::onSave); |
||||
btnLayout->addWidget(saveBtn); |
||||
|
||||
layout->addLayout(btnLayout); |
||||
|
||||
if (m_db && m_db->isOpen()) { |
||||
QString autoPlayKey = QStringLiteral("ch_%1_auto_play_voice").arg(channelId); |
||||
m_autoPlayVoice->setChecked(m_db->getUiStateInt(autoPlayKey, 0) != 0); |
||||
QString pttKey = QStringLiteral("ch_%1_ptt_mode").arg(channelId); |
||||
m_pttMode->setChecked(m_db->getUiStateInt(pttKey, 0) != 0); |
||||
} |
||||
} |
||||
|
||||
void ChannelSettingsDialog::onSave() { |
||||
auto saveKey = [&](const char* suffix, int val) { |
||||
QString key = QStringLiteral("ch_%1_%2").arg(m_channelId, QString::fromUtf8(suffix)); |
||||
QByteArray keyBA = key.toUtf8(); |
||||
QByteArray valBA = QByteArray::number(val); |
||||
size_t klen = (size_t)keyBA.size(), vlen = (size_t)valBA.size(); |
||||
size_t total = klen + 1 + vlen + 1; |
||||
if (total <= 256) { |
||||
void* arg = u_malloc(total); |
||||
memcpy(arg, keyBA.constData(), klen + 1); |
||||
memcpy((char*)arg + klen + 1, valBA.constData(), vlen + 1); |
||||
gui_bridge_post_uasync_fn(chat_core_save_ui_state_trampoline, arg); |
||||
} |
||||
}; |
||||
saveKey("auto_play_voice", m_autoPlayVoice->isChecked() ? 1 : 0); |
||||
saveKey("ptt_mode", m_pttMode->isChecked() ? 1 : 0); |
||||
accept(); |
||||
} |
||||
@ -0,0 +1,22 @@
|
||||
#pragma once |
||||
|
||||
#include <QDialog> |
||||
#include <QCheckBox> |
||||
#include <QString> |
||||
|
||||
class DbManager; |
||||
|
||||
class ChannelSettingsDialog : public QDialog { |
||||
Q_OBJECT |
||||
public: |
||||
explicit ChannelSettingsDialog(const QString& channelId, DbManager* db, QWidget* parent = nullptr); |
||||
|
||||
private slots: |
||||
void onSave(); |
||||
|
||||
private: |
||||
QString m_channelId; |
||||
DbManager* m_db; |
||||
QCheckBox* m_autoPlayVoice; |
||||
QCheckBox* m_pttMode; |
||||
}; |
||||
Loading…
Reference in new issue