Browse Source

chatgui: настройка звука уведомления на канал (sound_on_message)

v2
evgeny 2 weeks ago
parent
commit
910cfeac20
  1. 7
      tools/chatgui/src/channelsettingsdialog.cpp
  2. 1
      tools/chatgui/src/channelsettingsdialog.h
  3. 3
      tools/chatgui/src/mainwindow.cpp

7
tools/chatgui/src/channelsettingsdialog.cpp

@ -38,6 +38,10 @@ ChannelSettingsDialog::ChannelSettingsDialog(const QString& channelId, DbManager
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_soundOnMessage = new QCheckBox(QStringLiteral("Play sound on incoming message"), this);
m_soundOnMessage->setToolTip(QStringLiteral("Play a notification sound when a message arrives in this channel."));
layout->addWidget(m_soundOnMessage);
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);
@ -74,6 +78,8 @@ ChannelSettingsDialog::ChannelSettingsDialog(const QString& channelId, DbManager
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 soundKey = QStringLiteral("ch_%1_sound_on_message").arg(channelId);
m_soundOnMessage->setChecked(m_db->getUiStateInt(soundKey, 1) != 0);
QString pttKey = QStringLiteral("ch_%1_ptt_mode").arg(channelId);
m_pttMode->setChecked(m_db->getUiStateInt(pttKey, 0) != 0);
}
@ -94,6 +100,7 @@ void ChannelSettingsDialog::onSave() {
}
};
saveKey("auto_play_voice", m_autoPlayVoice->isChecked() ? 1 : 0);
saveKey("sound_on_message", m_soundOnMessage->isChecked() ? 1 : 0);
saveKey("ptt_mode", m_pttMode->isChecked() ? 1 : 0);
accept();
}

1
tools/chatgui/src/channelsettingsdialog.h

@ -18,5 +18,6 @@ private:
QString m_channelId;
DbManager* m_db;
QCheckBox* m_autoPlayVoice;
QCheckBox* m_soundOnMessage;
QCheckBox* m_pttMode;
};

3
tools/chatgui/src/mainwindow.cpp

@ -593,7 +593,8 @@ void MainWindow::openImage(const QString& filePath) {
void MainWindow::onMessageReceived(const char* ch_id, int ch_id_len, uint64_t author) {
QString cid = QString::fromUtf8(ch_id, ch_id_len);
if (m_db && author != m_db->myNodeId())
if (m_db && author != m_db->myNodeId()
&& m_db->getUiStateInt(QStringLiteral("ch_%1_sound_on_message").arg(cid), 1))
SoundManager::instance()->play("msg_incoming");
if (m_messageList) {
if (cid == m_currentChannelId) {

Loading…
Cancel
Save