diff --git a/tools/chatgui/src/chatview.cpp b/tools/chatgui/src/chatview.cpp index b1bff242..043a4eb3 100644 --- a/tools/chatgui/src/chatview.cpp +++ b/tools/chatgui/src/chatview.cpp @@ -92,7 +92,7 @@ void ChatView::mousePressEvent(QMouseEvent *event) { QModelIndex idx = indexAt(viewport()->mapFrom(this, event->pos())); m_pressIndex = QPersistentModelIndex(idx); m_pressPos = event->pos(); - event->accept(); + QListView::mousePressEvent(event); } void ChatView::mouseMoveEvent(QMouseEvent *event) { diff --git a/tools/chatgui/src/inputbar.cpp b/tools/chatgui/src/inputbar.cpp index e2f26ada..14421717 100644 --- a/tools/chatgui/src/inputbar.cpp +++ b/tools/chatgui/src/inputbar.cpp @@ -206,7 +206,7 @@ void InputBar::onPttReleased() { int durationMs = m_recorder->durationMs(); if (durationMs < 500) { - qDebug("InputBar: voice message too short (%dms), discarded", durationMs); + GUI_INFO("InputBar: voice message too short (%dms), discarded", durationMs); return; } @@ -215,8 +215,8 @@ void InputBar::onPttReleased() { QString mediaPath = m_mediaDirBase + "/" + m_channelIdForRecord; VoiceEncoder::ensureMediaDir(mediaPath); - qDebug("InputBar::onPttReleased: mediaDir=%s exists=%d channel=%s", - qPrintable(mediaPath), QDir(mediaPath).exists(), qPrintable(m_channelIdForRecord)); + GUI_INFO("InputBar::onPttReleased: mediaDir=%s exists=%d channel=%s", + qPrintable(mediaPath), QDir(mediaPath).exists(), qPrintable(m_channelIdForRecord)); QString fileName = VoiceEncoder::generateFileName(); QString filePath = mediaPath + "/" + fileName; @@ -224,7 +224,7 @@ void InputBar::onPttReleased() { int frames = VoiceEncoder::encodeToFile(pcm, 48000, 1, filePath, durationSec); if (frames > 0) { m_voiceFilePath = filePath; - qDebug("InputBar: voice message ready: %s (%.1fs)", qPrintable(filePath), durationSec); + GUI_INFO("InputBar: voice message ready: %s (%.1fs)", qPrintable(filePath), durationSec); emit sendVoiceMessage(filePath, durationMs); } } diff --git a/tools/chatgui/src/messagedelegate.cpp b/tools/chatgui/src/messagedelegate.cpp index fe870610..43d650d3 100644 --- a/tools/chatgui/src/messagedelegate.cpp +++ b/tools/chatgui/src/messagedelegate.cpp @@ -67,8 +67,8 @@ bool MessageDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, if (!L.voicePlayBtnRect.contains(localPos)) return false; QString filePath = index.data(MsgVoiceFileRole).toString(); - qDebug("MessageDelegate::editorEvent voice click: filePath=%s exists=%d", - qPrintable(filePath), QFile::exists(filePath)); + GUI_DEBUG("editorEvent voice click: filePath=%s exists=%d", + qPrintable(filePath), QFile::exists(filePath)); if (filePath.isEmpty()) return false; ensureVoiceTimer(); diff --git a/tools/chatgui/src/messagelist.cpp b/tools/chatgui/src/messagelist.cpp index bb93f9e0..24a2e403 100644 --- a/tools/chatgui/src/messagelist.cpp +++ b/tools/chatgui/src/messagelist.cpp @@ -103,10 +103,10 @@ static void setVoiceMessageRoles(QStandardItem* item, const QByteArray& data, if (!fname.isEmpty()) { QString fullPath = mediaDirBase + "/" + channelId + "/" + fname; item->setData(fullPath, MsgVoiceFileRole); - qDebug("setVoiceMessageRoles: voice file=%s dur=%s exists=%d", - qPrintable(fullPath), qPrintable(dur), QFile::exists(fullPath)); + DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "setVoiceMessageRoles: voice file=%s dur=%s exists=%d", + qPrintable(fullPath), qPrintable(dur), QFile::exists(fullPath)); } else { - qWarning("setVoiceMessageRoles: empty filename, raw='%s'", qPrintable(raw)); + DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "setVoiceMessageRoles: empty filename, raw='%s'", qPrintable(raw)); } } } diff --git a/tools/chatgui/src/voicemessageencoder.cpp b/tools/chatgui/src/voicemessageencoder.cpp index 92344d71..c04f1f1c 100644 --- a/tools/chatgui/src/voicemessageencoder.cpp +++ b/tools/chatgui/src/voicemessageencoder.cpp @@ -4,6 +4,8 @@ extern "C" { #include "../../../lib/opus_codec.h" } +#include "../../lib/debug_config.h" + #include #include #include @@ -29,7 +31,7 @@ int VoiceEncoder::preset() { return s_preset; } int VoiceEncoder::encodeToFile(const std::vector& pcm, int sampleRate, int channels, const QString& filePath, float& outDurationSec) { if (pcm.empty() || sampleRate <= 0 || channels <= 0) { - qWarning("VoiceEncoder: invalid input (pcm=%zu rate=%d ch=%d)", pcm.size(), sampleRate, channels); + DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "VoiceEncoder: invalid input (pcm=%zu rate=%d ch=%d)", pcm.size(), sampleRate, channels); return -1; } @@ -39,7 +41,7 @@ int VoiceEncoder::encodeToFile(const std::vector& pcm, int sampleRate, opus_codec_encoder_t* enc = opus_codec_encoder_create(sampleRate, channels); if (!enc) { - qWarning("VoiceEncoder: encoder create failed"); + DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "VoiceEncoder: encoder create failed"); return -1; } opus_codec_encoder_bitrate_set(enc, s_bitrates[s_preset]); @@ -47,11 +49,12 @@ int VoiceEncoder::encodeToFile(const std::vector& pcm, int sampleRate, QFile file(filePath); if (!file.open(QIODevice::WriteOnly)) { - qWarning("VoiceEncoder: cannot open file %s (%s)", qPrintable(filePath), qPrintable(file.errorString())); + DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "VoiceEncoder: cannot open file %s (%s)", qPrintable(filePath), qPrintable(file.errorString())); opus_codec_encoder_destroy(enc); return -1; } - qDebug("VoiceEncoder::encodeToFile: writing to %s pcm=%zu samples", qPrintable(filePath), pcm.size()); + DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "VoiceEncoder::encodeToFile: writing to %s pcm=%zu samples preset=%d", + qPrintable(filePath), pcm.size(), s_preset); /* write header */ uint32_t magic = OPUS_MAGIC; @@ -78,7 +81,7 @@ int VoiceEncoder::encodeToFile(const std::vector& pcm, int sampleRate, file.write((const char*)packet, len); frameCount++; } else if (len < 0) { - qWarning("VoiceEncoder: encode error at frame %d: %d", frameCount, len); + DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "VoiceEncoder: encode error at frame %d: %d", frameCount, len); } } @@ -89,7 +92,7 @@ int VoiceEncoder::encodeToFile(const std::vector& pcm, int sampleRate, outDurationSec = (float)frameCount * FRAME_MS / 1000.0f; - qDebug("VoiceEncoder: wrote %d frames (%.1fs) to %s", frameCount, outDurationSec, qPrintable(filePath)); + DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "VoiceEncoder: wrote %d frames (%.1fs) to %s", frameCount, outDurationSec, qPrintable(filePath)); opus_codec_encoder_destroy(enc); return frameCount; } @@ -110,6 +113,6 @@ QString VoiceEncoder::mediaDir(const QString& dbPath, const QString& channelId) void VoiceEncoder::ensureMediaDir(const QString& dir) { QDir d; if (!d.mkpath(dir)) { - qWarning("VoiceEncoder: cannot create media dir %s", qPrintable(dir)); + DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "VoiceEncoder: cannot create media dir %s", qPrintable(dir)); } } diff --git a/tools/chatgui/src/voiceplayback.cpp b/tools/chatgui/src/voiceplayback.cpp index 7d87be1b..2d1942f9 100644 --- a/tools/chatgui/src/voiceplayback.cpp +++ b/tools/chatgui/src/voiceplayback.cpp @@ -5,6 +5,8 @@ extern "C" { #include "../../../lib/opus_codec.h" } +#include "../../lib/debug_config.h" + #include #include @@ -14,14 +16,14 @@ int VoicePlayer::decodeOpusFile(const QString& filePath, std::vector& o int& outSampleRate, int& outChannels, float& outDurationSec) { QFile file(filePath); if (!file.exists()) { - qWarning("VoicePlayer: file not found: %s", qPrintable(filePath)); + DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "VoicePlayer: file not found: %s", qPrintable(filePath)); return -1; } if (!file.open(QIODevice::ReadOnly)) { - qWarning("VoicePlayer: cannot open %s (%s)", qPrintable(filePath), qPrintable(file.errorString())); + DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "VoicePlayer: cannot open %s (%s)", qPrintable(filePath), qPrintable(file.errorString())); return -1; } - qDebug("VoicePlayer: opened file %s size=%lld", qPrintable(filePath), (long long)file.size()); + DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "VoicePlayer: opened file %s size=%lld", qPrintable(filePath), (long long)file.size()); uint32_t magic, sr32; uint16_t ch16, frameSamples; @@ -29,7 +31,7 @@ int VoicePlayer::decodeOpusFile(const QString& filePath, std::vector& o file.read((char*)&sr32, 4) != 4 || file.read((char*)&ch16, 2) != 2 || file.read((char*)&frameSamples, 2) != 2) { - qWarning("VoicePlayer: invalid header in %s", qPrintable(filePath)); + DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "VoicePlayer: invalid header in %s", qPrintable(filePath)); return -1; } @@ -40,7 +42,7 @@ int VoicePlayer::decodeOpusFile(const QString& filePath, std::vector& o opus_codec_decoder_t* dec = opus_codec_decoder_create(sampleRate, channels); if (!dec) { - qWarning("VoicePlayer: decoder create failed"); + DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "VoicePlayer: decoder create failed"); return -1; } @@ -67,23 +69,23 @@ int VoicePlayer::decodeOpusFile(const QString& filePath, std::vector& o } outDurationSec = (float)frameCount * 20.0f / 1000.0f; - qDebug("VoicePlayer: decoded %d frames (%.1fs) from %s", frameCount, outDurationSec, qPrintable(filePath)); + DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "VoicePlayer: decoded %d frames (%.1fs) from %s", frameCount, outDurationSec, qPrintable(filePath)); opus_codec_decoder_destroy(dec); return frameCount; } void VoicePlayer::playOpusFile(const QString& filePath) { - qDebug("VoicePlayer::playOpusFile: %s", qPrintable(filePath)); + DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "VoicePlayer::playOpusFile: %s", qPrintable(filePath)); std::vector pcm; int sampleRate, channels; float duration; if (decodeOpusFile(filePath, pcm, sampleRate, channels, duration) <= 0) { - qWarning("VoicePlayer::playOpusFile: decode failed for %s", qPrintable(filePath)); + DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "VoicePlayer::playOpusFile: decode failed for %s", qPrintable(filePath)); return; } - qDebug("VoicePlayer::playOpusFile: decoded %zu samples %dHz %dch %.1fs → playing", - pcm.size(), sampleRate, channels, duration); + DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "VoicePlayer::playOpusFile: decoded %zu samples %dHz %dch %.1fs", + pcm.size(), sampleRate, channels, duration); SoundManager::instance()->playRawPcm(pcm.data(), pcm.size() / channels, sampleRate, channels); }