Merged
Conversation
add the toast info for audio device disabled Log: add the toast info for audio device disabled Task: https://pms.uniontech.com/task-view-378245.html
modify the 'Text to Speech' reading text Log: modify the 'Text to Speech' reading text Task: https://pms.uniontech.com/task-view-378245.html
There was a problem hiding this comment.
Sorry @pppanghu77, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
Note
详情{
"src/widgets/window.cpp": [
{
"line": " QString key = \"base/enable\";",
"line_number": 389,
"rule": "S106",
"reason": "Var naming | 64f28539d9"
}
]
} |
This commit includes the following changes:
1. **Qt5 Compatibility Fix in dtextedit.cpp**:
- Replaced `QList::removeIf()` (Qt6 only) with Qt5-compatible approach using `QSet::toSet()` and reverse iteration with `removeAt()`
- This fixes compilation issues on Qt5-based systems
2. **Code Cleanup in tabbar.cpp**:
- Removed dead code block wrapped in `#if 0` preprocessor directive
- Removed orphaned debug output `qDebug() << "Exit createDragPixmapFromTab"`
3. **Header Fixes**:
- Added `Q_DECLARE_METATYPE(DockRect)` macro in com_deepin_dde_daemon_dock.h to properly register DockRect type with Qt's meta-object system
- Added `mousePressEvent` declaration in tabbar.h
- Added `slotStopReadingAction` slot declaration in dtextedit.h
4. **Include Fixes**:
- Added missing `#include <QDebug>` to multiple source files where qDebug() is used
- Removed duplicate `#include "bottombar.h"` in bottombar.cpp
Log: Fix Qt5 compilation compatibility issue and clean up unused code in tab bar component
Task: https://pms.uniontech.com/task-view-383499.html
deepin pr auto review我来对这次代码变更进行审查:
改进建议:
bool TextEdit::checkAudioDevice(int direction)
{
QDBusMessage msg = QDBusMessage::createMethodCall("com.deepin.daemon.Audio",
"/com/deepin/daemon/Audio",
"org.freedesktop.DBus.Properties",
"Get");
msg << QString("com.deepin.daemon.Audio") << QString("CardsWithoutUnavailable");
QDBusReply<QVariant> reply = QDBusConnection::sessionBus().call(msg);
if (!reply.isValid()) {
qWarning() << "Failed to get audio devices:" << reply.error().message();
return false;
}
QJsonParseError error;
QJsonDocument doc = QJsonDocument::fromJson(reply.value().toByteArray(), &error);
if (error.error != QJsonParseError::NoError) {
qWarning() << "Failed to parse audio device JSON:" << error.errorString();
return false;
}
QJsonArray cards = doc.array();
for (const QJsonValue &cardValue : cards) {
QJsonObject card = cardValue.toObject();
QJsonArray ports = card["Ports"].toArray();
for (const QJsonValue &portValue : ports) {
QJsonObject port = portValue.toObject();
if (port["Direction"].toInt() == direction && port["Enabled"].toBool()) {
return true;
}
}
}
return false;
}
bool TextEdit::checkAudioOutputDevice()
{
return checkAudioDevice(1);
}
bool TextEdit::checkAudioInputDevice()
{
return checkAudioDevice(2);
}
void TextEdit::onAudioPortEnabledChanged(quint32 cardId, const QString &portName, bool enabled)
{
Q_UNUSED(cardId)
Q_UNUSED(portName)
if (!enabled) {
bool hasOutputDevice = checkAudioOutputDevice();
bool hasInputDevice = checkAudioInputDevice();
if (!hasOutputDevice) {
const QString message = tr("No audio output device was detected. Please ensure your speakers or headphones are properly connected and try again.");
showAudioDeviceMessage(message);
}
if (!hasInputDevice) {
const QString message = tr("No audio input device was detected. Please ensure your microphone is properly connected and try again.");
showAudioDeviceMessage(message);
}
}
}
void TextEdit::showAudioDeviceMessage(const QString &message)
{
#ifdef DTKWIDGET_CLASS_DSizeMode
Utils::sendFloatMessageFixedFont(this, QIcon(":/images/warning.svg"), message);
#else
DMessageManager::instance()->sendMessage(this, QIcon(":/images/warning.svg"), message);
#endif
}
void TextEdit::checkAudioDeviceAsync(int direction, std::function<void(bool)> callback)
{
QDBusMessage msg = QDBusMessage::createMethodCall("com.deepin.daemon.Audio",
"/com/deepin/daemon/Audio",
"org.freedesktop.DBus.Properties",
"Get");
msg << QString("com.deepin.daemon.Audio") << QString("CardsWithoutUnavailable");
QDBusPendingCall async = QDBusConnection::sessionBus().asyncCall(msg);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(async, this);
connect(watcher, &QDBusPendingCallWatcher::finished, [direction, callback](QDBusPendingCallWatcher *watcher) {
QDBusPendingReply<QVariant> reply = *watcher;
bool result = false;
if (reply.isValid()) {
QJsonDocument doc = QJsonDocument::fromJson(reply.value().toByteArray());
QJsonArray cards = doc.array();
for (const QJsonValue &cardValue : cards) {
QJsonObject card = cardValue.toObject();
QJsonArray ports = card["Ports"].toArray();
for (const QJsonValue &portValue : ports) {
QJsonObject port = portValue.toObject();
if (port["Direction"].toInt() == direction && port["Enabled"].toBool()) {
result = true;
break;
}
}
}
}
callback(result);
watcher->deleteLater();
});
}
class TextEdit {
private:
mutable QHash<int, bool> m_audioDeviceCache;
QDateTime m_cacheUpdateTime;
static const int CACHE_TIMEOUT_MS = 5000; // 5秒缓存超时
bool isCacheValid() const {
return m_cacheUpdateTime.isValid() &&
m_cacheUpdateTime.msecsTo(QDateTime::currentDateTime()) < CACHE_TIMEOUT_MS;
}
bool checkAudioDeviceCached(int direction) {
if (isCacheValid() && m_audioDeviceCache.contains(direction)) {
return m_audioDeviceCache[direction];
}
bool result = checkAudioDevice(direction);
m_audioDeviceCache[direction] = result;
m_cacheUpdateTime = QDateTime::currentDateTime();
return result;
}
};这些改进可以:
|
|
Note
详情{
"src/widgets/window.cpp": [
{
"line": " QString key = \"base/enable\";",
"line_number": 389,
"rule": "S106",
"reason": "Var naming | 64f28539d9"
}
]
} |
lzwind
approved these changes
Dec 18, 2025
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, pppanghu77 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Contributor
Author
|
/forcemerge |
Contributor
|
This pr force merged! (status: unstable) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
build