From e8a1a9c770ae25b6ff49aa0bf4180fea2a08084f Mon Sep 17 00:00:00 2001 From: zhanghongyuan Date: Thu, 29 Oct 2026 16:18:52 +0800 Subject: [PATCH] feat: adapt deepin-debug-config for dynamic log level control MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Convert plain qDebug/qInfo/qWarning to categorized qCDebug/qCInfo/qCWarning with org.deepin.camera category, register log_rules DConfig listening before application creation, and add dconfig meta org.deepin.camera.json. 将普通日志宏改为带 org.deepin.camera 分类的 qCDebug/qCInfo/qCWarning, 在应用创建前注册 log_rules DConfig 监听,并新增 dconfig 元数据文件。 Log: 适配deepin-debug-config调试模式,支持动态调整日志级别 Influence: 可通过deepin-debug-config动态切换deepin-camera的日志输出级别 --- src/CMakeLists.txt | 8 +- src/assets/org.deepin.camera.encode.json | 13 - src/assets/org.deepin.camera.json | 17 ++ src/main.cpp | 100 ++++---- src/src/Settings.cpp | 82 +++--- src/src/audioprocessingthread.cpp | 36 +-- src/src/basepub/datamanager.cpp | 22 +- src/src/camera.cpp | 158 ++++++------ src/src/capplication.cpp | 12 +- src/src/circlepushbutton.cpp | 8 +- src/src/closedialog.cpp | 10 +- src/src/devnummonitor.cpp | 20 +- src/src/exposureslider.cpp | 22 +- src/src/filterpreviewbutton.cpp | 52 ++-- src/src/globalutils.cpp | 24 +- src/src/gstvideowriter.cpp | 80 +++--- src/src/imageitem.cpp | 94 +++---- src/src/logconfigread.cpp | 9 +- src/src/mainwindow.cpp | 308 ++++++++++++----------- src/src/majorimageprocessingthread.cpp | 42 ++-- src/src/previewopenglwidget.cpp | 18 +- src/src/takephotosettingareawidget.cpp | 156 ++++++------ src/src/titlebar.cpp | 8 +- src/src/videowidget.cpp | 298 +++++++++++----------- src/src/windowstatethread.cpp | 32 +-- 25 files changed, 839 insertions(+), 790 deletions(-) create mode 100644 src/assets/org.deepin.camera.json diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a2d56693..347b6d06 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +# SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. # # SPDX-License-Identifier: GPL-3.0-or-later @@ -270,8 +270,10 @@ install(DIRECTORY ${PROJECT_SOURCE_DIR}/translations #hw机型增加DConfig配置 set(APPID org.deepin.camera) set(configFile ${PROJECT_SOURCE_DIR}/assets/org.deepin.camera.encode.json) +#日志规则配置(调试模式动态日志级别) +set(configFileLog ${PROJECT_SOURCE_DIR}/assets/org.deepin.camera.json) if (DTK_VERSION EQUAL "6") - dtk_add_config_meta_files(APPID ${APPID} FILES ${configFile}) + dtk_add_config_meta_files(APPID ${APPID} FILES ${configFile} ${configFileLog}) else() - install(FILES ${configFile} DESTINATION ${CMAKE_INSTALL_DATADIR}/dsg/configs/org.deepin.camera/) + install(FILES ${configFile} ${configFileLog} DESTINATION ${CMAKE_INSTALL_DATADIR}/dsg/configs/org.deepin.camera/) endif() diff --git a/src/assets/org.deepin.camera.encode.json b/src/assets/org.deepin.camera.encode.json index 02e7a9b3..acc66702 100644 --- a/src/assets/org.deepin.camera.encode.json +++ b/src/assets/org.deepin.camera.encode.json @@ -2,19 +2,6 @@ "magic": "dsg.config.meta", "version": "1.0", "contents": { - "rules": { - "value": "*.debug=false;*.info=false;*.warning=true", - "serial": 0, - "flags": [ - "global" - ], - "name": "rules", - "name[zh_CN]": "日志规则", - "description": "log rules", - "description[zh_CN]": "日志规则", - "permissions": "readwrite", - "visibility": "public" - }, "mp4EncodeMode": { "value": -1, "serial": 0, diff --git a/src/assets/org.deepin.camera.json b/src/assets/org.deepin.camera.json new file mode 100644 index 00000000..54f5e39f --- /dev/null +++ b/src/assets/org.deepin.camera.json @@ -0,0 +1,17 @@ +{ + "magic": "dsg.config.meta", + "version": "1.0", + "contents": { + "log_rules": { + "value": "*.debug=false;*.info=false;org.deepin.camera*.warning=true", + "serial": 0, + "flags": ["global"], + "name": "log rules", + "name[zh_CN]": "日志规则", + "description": "log rules", + "description[zh_CN]": "日志规则", + "permissions": "readwrite", + "visibility": "public" + } + } +} diff --git a/src/main.cpp b/src/main.cpp index e189a5aa..ad18c204 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,6 +3,8 @@ // // SPDX-License-Identifier: GPL-3.0-or-later +#include "ddlog.h" +using namespace DDLog; extern "C" { #include "camview.h" #include "v4l2_formats.h" @@ -56,22 +58,22 @@ DWIDGET_USE_NAMESPACE //判断是否采用wayland显示服务器 static bool CheckWayland() { - qDebug() << "Function started: CheckWayland"; + qCDebug(appLog) << "Function started: CheckWayland"; auto e = QProcessEnvironment::systemEnvironment(); QString XDG_SESSION_TYPE = e.value(QStringLiteral("XDG_SESSION_TYPE")); QString WAYLAND_DISPLAY = e.value(QStringLiteral("WAYLAND_DISPLAY")); if (XDG_SESSION_TYPE == QLatin1String("wayland") || WAYLAND_DISPLAY.contains(QLatin1String("wayland"), Qt::CaseInsensitive)) { - qDebug() << "Condition check: Wayland environment detected"; + qCDebug(appLog) << "Condition check: Wayland environment detected"; return true; } - qDebug() << "Condition check: Non-Wayland environment detected"; + qCDebug(appLog) << "Condition check: Non-Wayland environment detected"; return false; } static bool CheckFFmpegEnv() { - qDebug() << "Function started: CheckFFmpegEnv"; + qCDebug(appLog) << "Function started: CheckFFmpegEnv"; QDir dir; QString path = QLibraryInfo::location(QLibraryInfo::LibrariesPath); dir.setPath(path); @@ -83,7 +85,7 @@ static bool CheckFFmpegEnv() QRegularExpressionMatch match = re.match(list[i]); if (match.hasMatch()) { libName = list[i]; - qDebug() << "Found matching library:" << libName; + qCDebug(appLog) << "Found matching library:" << libName; break; } } @@ -92,7 +94,7 @@ static bool CheckFFmpegEnv() for (int i = 0; i < list.count(); i++) { if (re.exactMatch(list[i])) { libName = list[i]; - qDebug() << "Found matching library:" << libName; + qCDebug(appLog) << "Found matching library:" << libName; break; } } @@ -101,11 +103,11 @@ static bool CheckFFmpegEnv() QLibrary libavcodec; //检查编码器是否存在 libavcodec.setFileName(libName); if (!libavcodec.load()) { - qDebug() << "Condition check: Library loading failed"; - qWarning() << QString("Not found libavcodec: %1").arg(libavcodec.errorString()); + qCDebug(appLog) << "Condition check: Library loading failed"; + qCWarning(appLog) << QString("Not found libavcodec: %1").arg(libavcodec.errorString()); return false; } - qDebug() << "The libavcodec is loaded successfully."; + qCDebug(appLog) << "The libavcodec is loaded successfully."; typedef AVCodec *(*p_avcodec_find_encoder)(enum AVCodecID id); p_avcodec_find_encoder m_avcodec_find_encoder = nullptr; m_avcodec_find_encoder = reinterpret_cast(libavcodec.resolve("avcodec_find_encoder")); @@ -115,14 +117,14 @@ static bool CheckFFmpegEnv() pCodec = m_avcodec_find_encoder(AV_CODEC_ID_H264); if (pCodec) { - qDebug() << "Video encoder exists. AVCodecID:" << AV_CODEC_ID_H264; + qCDebug(appLog) << "Video encoder exists. AVCodecID:" << AV_CODEC_ID_H264; DataManager::instance()->setEncExists(true); } else { - qWarning() << "Can not find output video encoder! AVCodecID:" << AV_CODEC_ID_H264; + qCWarning(appLog) << "Can not find output video encoder! AVCodecID:" << AV_CODEC_ID_H264; DataManager::instance()->setEncExists(false); } - qDebug() << "Function completed: CheckFFmpegEnv"; + qCDebug(appLog) << "Function completed: CheckFFmpegEnv"; return true; } @@ -130,7 +132,7 @@ static bool CheckFFmpegEnv() // 添加信号处理函数 static void handleSignal(int sig) { - qWarning() << "Received signal:" << sig; + qCWarning(appLog) << "Received signal:" << sig; // 在HW机器、SW机器上,发现使用exit(0)退出会导致Qt某些函数空指针异常,从而导致崩溃,疑似在资源回收环节出了问题。所以我们使用QApplication::quit()更优雅地退出。 QTimer::singleShot(0, qApp, []() { QApplication::quit(); @@ -143,33 +145,33 @@ int main(int argc, char *argv[]) // 初始化日志规则:读取环境变量和 DConfig 配置 MLogger logger; - qInfo() << "Starting deepin-camera application..."; + qCInfo(appLog) << "Starting deepin-camera application..."; // Task 326583 不参与合成器崩溃重连 unsetenv("QT_WAYLAND_RECONNECT"); QAccessible::installFactory(accessibleFactory); bool bWayland = CheckWayland(); - qInfo() << "Wayland status:" << (bWayland ? "enabled" : "disabled"); + qCInfo(appLog) << "Wayland status:" << (bWayland ? "enabled" : "disabled"); bool bFFmpegEnv = CheckFFmpegEnv(); if (argc > 1) { - qDebug() << "Condition check: Arguments found"; + qCDebug(appLog) << "Condition check: Arguments found"; if (QString(argv[1]) == "-g") { bFFmpegEnv = false; - qDebug() << "Running in gstreamer test environment"; + qCDebug(appLog) << "Running in gstreamer test environment"; } } DataManager::instance()->setEncodeEnv(bFFmpegEnv ? FFmpeg_Env : GStreamer_Env); - qInfo() << "Encoding environment:" << (bFFmpegEnv ? "FFmpeg" : "GStreamer"); + qCInfo(appLog) << "Encoding environment:" << (bFFmpegEnv ? "FFmpeg" : "GStreamer"); //root login for this application if (!QString(qgetenv("XDG_CURRENT_DESKTOP")).toLower().startsWith("deepin")) { setenv("XDG_CURRENT_DESKTOP", "Deepin", 1); - qDebug() << "Set XDG_CURRENT_DESKTOP to Deepin"; + qCDebug(appLog) << "Set XDG_CURRENT_DESKTOP to Deepin"; } if (bWayland) { - qDebug() << "Condition check: Wayland configuration required"; + qCDebug(appLog) << "Condition check: Wayland configuration required"; QSurfaceFormat format; format.setRenderableType(QSurfaceFormat::OpenGLES); format.setDefaultFormat(format); @@ -218,7 +220,7 @@ int main(int argc, char *argv[]) if (dconfig && dconfig->isValid() && dconfig->keyList().contains("enableUsbGroup")) { bool enable = dconfig->value("enableUsbGroup").toBool(); - qInfo() << "enable USB group:" << enable; + qCInfo(appLog) << "enable USB group:" << enable; DataManager::instance()->setEnableUsbGroup(enable); } @@ -227,20 +229,20 @@ int main(int argc, char *argv[]) // 8K预览功能默认关闭,因为多个厂家的摄像头在8K预览的时候表现异常 if (dconfig && dconfig->isValid() && dconfig->keyList().contains("enable8kPreview")) { bool enable = dconfig->value("enable8kPreview").toBool(); - qInfo() << "enable 8K preview:" << enable; + qCInfo(appLog) << "enable 8K preview:" << enable; DataManager::instance()->setEnable8kPreview(enable); set_enable_8k_preview(enable ? 1 : 0); } if (dconfig && dconfig->isValid() && dconfig->keyList().contains("deviceBlacklist")) { QStringList deviceBlacklist = dconfig->value("deviceBlacklist").toStringList(); - qInfo() << "device blacklist:" << deviceBlacklist; + qCInfo(appLog) << "device blacklist:" << deviceBlacklist; DataManager::instance()->setDeviceBlacklist(deviceBlacklist); } if (dconfig && dconfig->isValid() && dconfig->keyList().contains("preferredResolution")) { QString preferredResolution = dconfig->value("preferredResolution").toString(); - qInfo() << "preferred resolution:" << preferredResolution; + qCInfo(appLog) << "preferred resolution:" << preferredResolution; if (!preferredResolution.isEmpty()) { DataManager::instance()->setPreferredResolution(preferredResolution); QSize size = DataManager::instance()->getPreferredResolution(); @@ -253,10 +255,10 @@ int main(int argc, char *argv[]) if (dconfig && dconfig->isValid() && dconfig->keyList().contains("useRgbData")) { int useRgbData = dconfig->value("useRgbData").toInt(); if (useRgbData != -1 && useRgbData != 0 && useRgbData != 1) { - qWarning() << "Invalid useRgbData value in config:" << useRgbData << "- mapping to default value -1 (auto)"; + qCWarning(appLog) << "Invalid useRgbData value in config:" << useRgbData << "- mapping to default value -1 (auto)"; useRgbData = -1; } - qInfo() << "use RGB data for preview:" << useRgbData; + qCInfo(appLog) << "use RGB data for preview:" << useRgbData; DataManager::instance()->setUseRgbData(useRgbData); } @@ -268,12 +270,12 @@ int main(int argc, char *argv[]) qputenv("VDPAU_DRIVER", libVdpauDriverName.toLocal8Bit()); } #endif - qInfo() << "mp4EncodeMode value is:" << get_pugx_status(); - qInfo() << "projectID value is:" << get_project_id(); - qInfo() << "libVaDriverName value is:" << get_libva_driver_name(); - qInfo() << "libVdpauDriverName value is:" << get_libvdpau_driver_name(); - qInfo() << "LIBVA_DRIVER_NAME value is:" << qgetenv("LIBVA_DRIVER_NAME"); - qInfo() << "VDPAU_DRIVER value is:" << qgetenv("VDPAU_DRIVER"); + qCInfo(appLog) << "mp4EncodeMode value is:" << get_pugx_status(); + qCInfo(appLog) << "projectID value is:" << get_project_id(); + qCInfo(appLog) << "libVaDriverName value is:" << get_libva_driver_name(); + qCInfo(appLog) << "libVdpauDriverName value is:" << get_libvdpau_driver_name(); + qCInfo(appLog) << "LIBVA_DRIVER_NAME value is:" << qgetenv("LIBVA_DRIVER_NAME"); + qCInfo(appLog) << "VDPAU_DRIVER value is:" << qgetenv("VDPAU_DRIVER"); if (mp4Encode == -1) { //判断是否是X机型 QStringList options; @@ -291,15 +293,15 @@ int main(int argc, char *argv[]) if (str_output.contains("PGUX", Qt::CaseInsensitive)) { mp4Encode = 1; - qDebug() << "this is PGUX"; + qCDebug(appLog) << "this is PGUX"; } else { mp4Encode = 0; } - qInfo() << "process find mp4EncodeMode value is:" << get_pugx_status(); + qCInfo(appLog) << "process find mp4EncodeMode value is:" << get_pugx_status(); } set_pugx_status(mp4Encode); - qInfo() << "last mp4EncodeMode value is:" << get_pugx_status(); + qCInfo(appLog) << "last mp4EncodeMode value is:" << get_pugx_status(); #if QT_VERSION_MAJOR > 5 QElapsedTimer time; @@ -309,8 +311,8 @@ int main(int argc, char *argv[]) time.start(); QString lutDir = LUT_DIR; initFilters(lutDir.toStdString().c_str()); - qDebug() << "LUT_DIR: " << lutDir; - qDebug() << QString("Filter initialization completed in %1 ms").arg(time.elapsed()); + qCDebug(appLog) << "LUT_DIR: " << lutDir; + qCDebug(appLog) << QString("Filter initialization completed in %1 ms").arg(time.elapsed()); CApplication a(argc, argv); // 注册信号处理函数 // 放在此处,是为了确保Application已经创建了实例 @@ -336,60 +338,60 @@ int main(int argc, char *argv[]) //日志 DLogManager::registerConsoleAppender(); DLogManager::registerFileAppender(); - qInfo() << "Log system initialized. Log file:" << DLogManager::getlogFilePath(); + qCInfo(appLog) << "Log system initialized. Log file:" << DLogManager::getlogFilePath(); //版本 qApp->setApplicationVersion(DApplication::buildVersion(VERSION)); QIcon myIcon = QIcon::fromTheme("deepin-camera"); qApp->setWindowIcon(myIcon); qApp->setProductIcon(myIcon);//08月21获悉已添加到系统,故更改为从系统获取 - qDebug() << "Application version:" << DApplication::buildVersion(VERSION); + qCDebug(appLog) << "Application version:" << DApplication::buildVersion(VERSION); //应用描述 qApp->setApplicationDescription(QObject::tr("Camera is an image and video capture utility using your PC camera or webcam.")); dc::Settings::get().init(); - qDebug() << "Application settings initialized"; + qCDebug(appLog) << "Application settings initialized"; #if QT_VERSION_MAJOR <= 5 DApplicationSettings saveTheme; #endif if (!qApp->setSingleInstance("deepin-camera")) { - qWarning() << "Another deepin camera instance is already running"; + qCWarning(appLog) << "Another deepin camera instance is already running"; QDBusInterface iface("com.deepin.camera", QDir::separator(), "com.deepin.camera"); if (iface.isValid()) { - qDebug() << "Attempting to raise existing instance"; + qCDebug(appLog) << "Attempting to raise existing instance"; iface.asyncCall("Raise"); } - qDebug() << "Function completed: main (exit due to existing instance)"; + qCDebug(appLog) << "Function completed: main (exit due to existing instance)"; exit(0); } CMainWindow w; a.setMainWindow(&w); - qDebug() << "Main window created and set"; + qCDebug(appLog) << "Main window created and set"; Dtk::Widget::moveToCenter(&w); w.setWayland(bWayland); //判断是否是平板环境 if (CamApp->isPanelEnvironment()) { w.showMaximized(); - qDebug() << "Running in panel environment, showing maximized window"; + qCDebug(appLog) << "Running in panel environment, showing maximized window"; } else { w.setMinimumSize(CMainWindow::minWindowWidth, CMainWindow::minWindowHeight); - qDebug() << "Running in desktop environment, showing normal window"; + qCDebug(appLog) << "Running in desktop environment, showing normal window"; } w.show(); w.loadAfterShow(); - qInfo() << "Main window displayed and initialized"; + qCInfo(appLog) << "Main window displayed and initialized"; ApplicationAdaptor adaptor(&w); QDBusConnection::sessionBus().registerService("com.deepin.Camera"); QDBusConnection::sessionBus().registerObject("/com/deepin/camera", &w); - qDebug() << "DBus service and object registered"; + qCDebug(appLog) << "DBus service and object registered"; - qInfo() << "Application startup completed successfully"; + qCInfo(appLog) << "Application startup completed successfully"; return qApp->exec(); } diff --git a/src/src/Settings.cpp b/src/src/Settings.cpp index a26aea62..921cbd57 100644 --- a/src/src/Settings.cpp +++ b/src/src/Settings.cpp @@ -1,8 +1,10 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// Copyright (C) 2020 - 2026 Uniontech Software Technology Co.,Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later +#include "ddlog.h" +using namespace DDLog; extern "C" { #include "v4l2_formats.h" } @@ -31,48 +33,48 @@ Settings::Settings() m_backend(nullptr), m_settings(nullptr) { - qDebug() << "Initializing Settings instance"; + qCDebug(appLog) << "Initializing Settings instance"; } void Settings::init() { - qDebug() << "Initializing Settings"; + qCDebug(appLog) << "Initializing Settings"; m_configPath.clear(); m_configPath.append(QString("%1/%2/%3/config.conf") .arg(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)) .arg(qApp->organizationName()) .arg(qApp->applicationName())); - qInfo() << "Loading config from path:" << m_configPath; + qCInfo(appLog) << "Loading config from path:" << m_configPath; m_backend = new QSettingBackend(m_configPath); if (CamApp->isPanelEnvironment()) { - qDebug() << "Loading panel environment settings"; + qCDebug(appLog) << "Loading panel environment settings"; m_settings = DSettings::fromJsonFile(":/resource/panel_settings.json"); } else { - qDebug() << "Loading normal environment settings"; + qCDebug(appLog) << "Loading normal environment settings"; m_settings = DSettings::fromJsonFile(":/resource/settings.json"); } QStringList videoFormatList; if (DataManager::instance()->encodeEnv() == FFmpeg_Env) { - qDebug() << "Using FFmpeg encoding environment"; + qCDebug(appLog) << "Using FFmpeg encoding environment"; if (DataManager::instance()->encExists()) { - qDebug() << "FFmpeg encoder exists, loading camera configuration"; + qCDebug(appLog) << "FFmpeg encoder exists, loading camera configuration"; GlobalUtils::loadCameraConf(); if (!GlobalUtils::isLowPerformanceBoard()) { - qDebug() << "High performance board detected, using mp4 and webm formats"; + qCDebug(appLog) << "High performance board detected, using mp4 and webm formats"; videoFormatList << tr("mp4") << tr("webm"); } else { - qDebug() << "Low performance board detected, using webm and mp4 formats"; + qCDebug(appLog) << "Low performance board detected, using webm and mp4 formats"; videoFormatList << tr("webm") << tr("mp4"); } } else { - qDebug() << "FFmpeg encoder not found, using webm format only"; + qCDebug(appLog) << "FFmpeg encoder not found, using webm format only"; videoFormatList << tr("webm"); m_settings->setOption("outsetting.outformat.vidformat", 0); } } else { - qDebug() << "Using non-FFmpeg encoding environment, using webm format only"; + qCDebug(appLog) << "Using non-FFmpeg encoding environment, using webm format only"; videoFormatList << "webm"; m_settings->setOption("outsetting.outformat.vidformat", 0); } @@ -82,29 +84,29 @@ void Settings::init() connect(m_settings, &DSettings::valueChanged, this, &Settings::onValueChanged); - qInfo() << "Available settings keys:" << m_settings->keys(); + qCInfo(appLog) << "Available settings keys:" << m_settings->keys(); setNewResolutionList(); } QVariant Settings::getOption(const QString &opt) { - qDebug() << "Getting option:" << opt; + qCDebug(appLog) << "Getting option:" << opt; return m_settings->getOption(opt); } void Settings::setOption(const QString &opt, const QVariant &v) { - qDebug() << "Setting option:" << opt << "to value:" << v; + qCDebug(appLog) << "Setting option:" << opt << "to value:" << v; m_settings->setOption(opt, v); } void Settings::setNewResolutionList() { - qDebug() << "Setting up new resolution list"; + qCDebug(appLog) << "Setting up new resolution list"; auto resolutionmodeFamily = m_settings->option("outsetting.resolutionsetting.resolution"); if (get_v4l2_device_handler() != nullptr) { - qDebug() << "V4L2 device handler found, getting resolution list"; + qCDebug(appLog) << "V4L2 device handler found, getting resolution list"; //格式索引 int format_index = v4l2core_get_frame_format_index( get_v4l2_device_handler(), @@ -117,7 +119,7 @@ void Settings::setNewResolutionList() v4l2core_get_frame_width(get_v4l2_device_handler()), v4l2core_get_frame_height(get_v4l2_device_handler())); - qDebug() << "Format index:" << format_index << "Resolution index:" << resolu_index; + qCDebug(appLog) << "Format index:" << format_index << "Resolution index:" << resolu_index; //获取当前摄像头的格式表 v4l2_stream_formats_t *list_stream_formats = v4l2core_get_formats_list(get_v4l2_device_handler()); @@ -129,7 +131,7 @@ void Settings::setNewResolutionList() //当前分辨率下标 if (format_index >= 0 && resolu_index >= 0) { - qDebug() << "Processing available resolutions"; + qCDebug(appLog) << "Processing available resolutions"; for (int i = 0 ; i < list_stream_formats[format_index].numb_res; i++) { int w = list_stream_formats[format_index].list_stream_cap[i].width; int h = list_stream_formats[format_index].list_stream_cap[i].height; @@ -139,13 +141,13 @@ void Settings::setNewResolutionList() //去重 if (resolutionDatabase.contains(res_str) == false) { resolutionDatabase.append(res_str); - qDebug() << "Added resolution:" << res_str; + qCDebug(appLog) << "Added resolution:" << res_str; } } } // Sort resolutions - qDebug() << "Sorting resolutions"; + qCDebug(appLog) << "Sorting resolutions"; int defres = 0; int tempostion = 0; int len = resolutionDatabase.size() - 1; @@ -175,7 +177,7 @@ void Settings::setNewResolutionList() if ((v4l2core_get_frame_width(get_v4l2_device_handler()) == resolutiontemp[0].toInt()) && (v4l2core_get_frame_height(get_v4l2_device_handler()) == resolutiontemp[1].toInt())) { defres = i; //set selected resolution index - qDebug() << "Found default resolution at index:" << defres; + qCDebug(appLog) << "Found default resolution at index:" << defres; break; } } @@ -185,7 +187,7 @@ void Settings::setNewResolutionList() //设置当前分辨率的索引 m_settings->setOption(QString("outsetting.resolutionsetting.resolution"), defres); } else { - qWarning() << "Invalid format or resolution index, setting default resolution"; + qCWarning(appLog) << "Invalid format or resolution index, setting default resolution"; resolutionDatabase.clear(); resolutionDatabase.append(QString(tr("None"))); m_settings->setOption(QString("outsetting.resolutionsetting.resolution"), 0); @@ -193,11 +195,11 @@ void Settings::setNewResolutionList() } } else { //初始化分辨率字符串表 - qDebug() << "No V4L2 device handler, using QCamera resolutions"; + qCDebug(appLog) << "No V4L2 device handler, using QCamera resolutions"; int defres = 0; QStringList resolutionDatabase = resolutionmodeFamily->data("items").toStringList(); if (DataManager::instance()->encodeEnv() == QCamera_Env && !Camera::instance()->getSupportResolutions().isEmpty()) { - qDebug() << "Using QCamera supported resolutions"; + qCDebug(appLog) << "Using QCamera supported resolutions"; resolutionDatabase = Camera::instance()->getSupportResolutions(); for (int i = 0; i < resolutionDatabase.size(); i++) { @@ -205,12 +207,12 @@ void Settings::setNewResolutionList() if ((Camera::instance()->getCameraResolution().width() == resolutiontemp[0].toInt()) && Camera::instance()->getCameraResolution().height() == resolutiontemp[1].toInt()) { defres = i; //设置分辨率下拉菜单当前索引 - qDebug() << "Found default QCamera resolution at index:" << defres; + qCDebug(appLog) << "Found default QCamera resolution at index:" << defres; break; } } } else { - qDebug() << "No supported resolutions found, using default"; + qCDebug(appLog) << "No supported resolutions found, using default"; if (resolutionDatabase.size() > 0) resolutionmodeFamily->data("items").clear(); @@ -222,37 +224,37 @@ void Settings::setNewResolutionList() } m_settings->sync(); - qDebug() << "Resolution list setup complete"; + qCDebug(appLog) << "Resolution list setup complete"; } void Settings::setPathOption(const QString &opt, const QVariant &v) { - qDebug() << "Setting path option:" << opt << "to:" << v; + qCDebug(appLog) << "Setting path option:" << opt << "to:" << v; m_settings->setOption(QString("base.save.%1").arg(opt), v); m_settings->sync(); } void Settings::setBackOption(const QString &opt, const QVariant &v) { - qDebug() << "Setting backend option:" << opt << "to:" << v; + qCDebug(appLog) << "Setting backend option:" << opt << "to:" << v; m_backend->setOption(opt,v); m_backend->sync(); } QVariant Settings::getBackOption(const QString &opt) { - qDebug() << "Getting backend option:" << opt; + qCDebug(appLog) << "Getting backend option:" << opt; return m_backend->getOption(opt); } void Settings::onValueChanged(const QString & key, const QVariant & value) { - qDebug() << "Settings value changed:" << key << "to:" << value; + qCDebug(appLog) << "Settings value changed:" << key << "to:" << value; if (key.startsWith("outsetting.resolutionsetting.resolution")) { auto mode_opt = m_settings->option("outsetting.resolutionsetting.resolution"); if (value.toInt() >= 0 && mode_opt->data("items").toStringList().size() > value.toInt()) { QString mode = mode_opt->data("items").toStringList()[value.toInt()]; - qInfo() << "Resolution changed to:" << mode; + qCInfo(appLog) << "Resolution changed to:" << mode; emit resolutionchanged(mode); } } @@ -260,7 +262,7 @@ void Settings::onValueChanged(const QString & key, const QVariant & value) if (key.startsWith("base.photogrid.photogrids")) { auto grid_opt1 = m_settings->option("base.photogrid.photogrids"); if (value.toInt() >= 0 && grid_opt1->data("items").toStringList().size() > value.toInt()) { - qInfo() << "Grid type changed to:" << value.toInt(); + qCInfo(appLog) << "Grid type changed to:" << value.toInt(); emit gridTypeChanged(value.toInt()); } } @@ -269,20 +271,20 @@ void Settings::onValueChanged(const QString & key, const QVariant & value) auto mode_opt1 = m_settings->option("photosetting.photosdelay.photodelays"); if (value.toInt() >= 0 && mode_opt1->data("items").toStringList().size() > value.toInt()) { QString mode1 = mode_opt1->data("items").toStringList()[value.toInt()]; - qInfo() << "Delay time changed to:" << mode1; + qCInfo(appLog) << "Delay time changed to:" << mode1; emit delayTimeChanged(mode1); } } if (key.startsWith("photosetting.mirrorMode.mirrorMode")){ bool bMirror = m_settings->getOption("photosetting.mirrorMode.mirrorMode").toBool(); - qInfo() << "Mirror mode changed to:" << bMirror; + qCInfo(appLog) << "Mirror mode changed to:" << bMirror; emit mirrorModeChanged(bMirror); } if (key.startsWith("photosetting.Flashlight.Flashlight")){ bool bLight = m_settings->getOption("photosetting.Flashlight.Flashlight").toBool(); - qInfo() << "Flashlight changed to:" << bLight; + qCInfo(appLog) << "Flashlight changed to:" << bLight; emit flashLightChanged(bLight); } @@ -290,7 +292,7 @@ void Settings::onValueChanged(const QString & key, const QVariant & value) QPointer formatOpt = m_settings->option("outsetting.outformat.vidformat"); if (value.toInt() >= 0 && formatOpt->data("items").toStringList().size() > value.toInt()) { QString videoFormat = formatOpt->data("items").toStringList()[value.toInt()]; - qInfo() << "Video format changed to:" << videoFormat; + qCInfo(appLog) << "Video format changed to:" << videoFormat; emit videoFormatChanged(videoFormat); } } @@ -298,7 +300,7 @@ void Settings::onValueChanged(const QString & key, const QVariant & value) Settings::~Settings() { - qDebug() << "Cleaning up Settings instance"; + qCDebug(appLog) << "Cleaning up Settings instance"; if (m_backend) { delete m_backend; m_backend = nullptr; diff --git a/src/src/audioprocessingthread.cpp b/src/src/audioprocessingthread.cpp index a799c094..e01a8ea5 100644 --- a/src/src/audioprocessingthread.cpp +++ b/src/src/audioprocessingthread.cpp @@ -1,15 +1,17 @@ -// Copyright (C) 2021 ~ 2022 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// Copyright (C) 2021 - 2026 Uniontech Software Technology Co.,Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later #include "audioprocessingthread.h" +#include "ddlog.h" +using namespace DDLog; #define FRAME_SIZE 512 AudioProcessingThread::AudioProcessingThread() { - qDebug() << "Initializing AudioProcessingThread"; + qCDebug(appLog) << "Initializing AudioProcessingThread"; m_auidoBuffer = nullptr; m_data = nullptr; m_datasize = 0; @@ -18,37 +20,37 @@ AudioProcessingThread::AudioProcessingThread() void AudioProcessingThread::stop() { - qDebug() << "Stopping audio processing thread"; + qCDebug(appLog) << "Stopping audio processing thread"; m_stopped = 1; } void AudioProcessingThread::init() { - qDebug() << "Initializing audio processing thread state"; + qCDebug(appLog) << "Initializing audio processing thread state"; m_stopped = 0; } void AudioProcessingThread::run() { - qDebug() << "Starting audio processing thread"; + qCDebug(appLog) << "Starting audio processing thread"; uint datasize = 0; audio_context_t *audio_ctx = get_audio_context(); if(!audio_ctx) { - qWarning() << "No audio context available: skipping audio processing"; + qCWarning(appLog) << "No audio context available: skipping audio processing"; return; } //初始化音频样本获取缓存大小 audio_set_cap_buffer_size(audio_ctx, FRAME_SIZE * audio_get_channels(audio_ctx)); - qDebug() << "Audio capture buffer size set to:" << FRAME_SIZE * audio_get_channels(audio_ctx); + qCDebug(appLog) << "Audio capture buffer size set to:" << FRAME_SIZE * audio_get_channels(audio_ctx); audio_start(audio_ctx); - qDebug() << "Audio capture started"; + qCDebug(appLog) << "Audio capture started"; datasize = audio_ctx->capture_buff_size * sizeof(sample_t); - qDebug() << "Audio data size:" << datasize << "bytes"; + qCDebug(appLog) << "Audio data size:" << datasize << "bytes"; /* * alloc the buffer after audio_start @@ -60,7 +62,7 @@ void AudioProcessingThread::run() m_auidoBuffer = audio_get_buffer(audio_ctx); uint sample_type = GV_SAMPLE_TYPE_FLOAT; - qDebug() << "Using sample type: FLOAT"; + qCDebug(appLog) << "Using sample type: FLOAT"; while (m_stopped == 0) { int ret = audio_get_next_buffer(audio_ctx, m_auidoBuffer, sample_type, get_audio_fx_mask()); @@ -76,7 +78,7 @@ void AudioProcessingThread::run() } else if (ret == 0) { if (m_datasize != datasize) { - qDebug() << "Resizing audio data buffer from" << m_datasize << "to" << datasize << "bytes"; + qCDebug(appLog) << "Resizing audio data buffer from" << m_datasize << "to" << datasize << "bytes"; m_datasize = datasize; if (m_data != nullptr) { delete [] m_data; @@ -92,24 +94,24 @@ void AudioProcessingThread::run() m_rwMtxData.unlock(); } else { - qWarning() << "Error getting next audio buffer, return code:" << ret; + qCWarning(appLog) << "Error getting next audio buffer, return code:" << ret; } } - qDebug() << "Stopping audio capture and cleaning up resources"; + qCDebug(appLog) << "Stopping audio capture and cleaning up resources"; audio_stop(audio_ctx); audio_delete_buffer(m_auidoBuffer); - qInfo() << "Audio processing thread stopped"; + qCInfo(appLog) << "Audio processing thread stopped"; return; } AudioProcessingThread::~AudioProcessingThread() { - qDebug() << "Destroying AudioProcessingThread"; + qCDebug(appLog) << "Destroying AudioProcessingThread"; if (m_data) { delete [] m_data; m_data = nullptr; } - qDebug() << "AudioProcessingThread destroyed"; + qCDebug(appLog) << "AudioProcessingThread destroyed"; } diff --git a/src/src/basepub/datamanager.cpp b/src/src/basepub/datamanager.cpp index 8d33eed6..43ebff69 100644 --- a/src/src/basepub/datamanager.cpp +++ b/src/src/basepub/datamanager.cpp @@ -3,6 +3,8 @@ // // SPDX-License-Identifier: GPL-3.0-or-later +#include "ddlog.h" +using namespace DDLog; extern "C" { #include "v4l2_formats.h" } @@ -73,7 +75,7 @@ void DataManager::setDeviceBlacklist(const QStringList &blacklist) // 无论是否为空,都先清空现有黑名单 m_deviceBlacklistSet.clear(); if (blacklist.isEmpty()) { - qInfo() << "Empty blacklist provided"; + qCInfo(appLog) << "Empty blacklist provided"; return; } @@ -83,24 +85,24 @@ void DataManager::setDeviceBlacklist(const QStringList &blacklist) for (const QString &item : blacklist) { QStringList parts = item.split(","); if (parts.size() != 3) { - qWarning() << "Drop blacklist item(format error):" << item; + qCWarning(appLog) << "Drop blacklist item(format error):" << item; continue; } // 验证VID和PID是否为4位十六进制数 static const QRegularExpression hexPattern("^[0-9a-fA-F]{4}$"); if (!hexPattern.match(parts[0]).hasMatch() || !hexPattern.match(parts[1]).hasMatch()) { - qWarning() << "Drop blacklist item(invalid VID/PID):" << item; + qCWarning(appLog) << "Drop blacklist item(invalid VID/PID):" << item; continue; } // 验证设备名称不为空,且长度不超过100个字符 if (parts[2].trimmed().isEmpty() || parts[2].size() > 100) { - qWarning() << "Drop blacklist item(empty device name OR too long):" << item; + qCWarning(appLog) << "Drop blacklist item(empty device name OR too long):" << item; continue; } - qInfo() << "Add blacklist item:" << item; + qCInfo(appLog) << "Add blacklist item:" << item; m_deviceBlacklistSet.insert(item.toLower()); } }; @@ -119,13 +121,13 @@ bool DataManager::isDeviceValid(const QString &vid, const QString &pid, const QS void DataManager::setPreferredResolution(const QString &resolution) { if (resolution.isEmpty()) { - qInfo() << "Preferred resolution is empty"; + qCInfo(appLog) << "Preferred resolution is empty"; return; } QStringList parts = resolution.split("x"); if (parts.size() != 2) { - qWarning() << "Invalid resolution format:" << resolution << "Expected format: WIDTHxHEIGHT"; + qCWarning(appLog) << "Invalid resolution format:" << resolution << "Expected format: WIDTHxHEIGHT"; return; } @@ -134,19 +136,19 @@ void DataManager::setPreferredResolution(const QString &resolution) int height = parts[1].toInt(&heightOk); if (!widthOk || !heightOk || width <= 0 || height <= 0) { - qWarning() << "Invalid resolution values:" << resolution; + qCWarning(appLog) << "Invalid resolution values:" << resolution; return; } // 添加合理的上限检查,例如16K static const int MAX_RESOLUTION = 16384; if (width > MAX_RESOLUTION || height > MAX_RESOLUTION) { - qWarning() << "Resolution exceeds maximum limit:" << resolution; + qCWarning(appLog) << "Resolution exceeds maximum limit:" << resolution; return; } if (!is_valid_resolution(width, height)) { - qWarning() << "Resolution does not meet validation requirements:" << resolution; + qCWarning(appLog) << "Resolution does not meet validation requirements:" << resolution; return; } diff --git a/src/src/camera.cpp b/src/src/camera.cpp index 39527a7d..7b1f66ed 100755 --- a/src/src/camera.cpp +++ b/src/src/camera.cpp @@ -1,9 +1,11 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// Copyright (C) 2020 - 2026 Uniontech Software Technology Co.,Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later #define TMPPATH "/tmp/tmp.jpg" +#include "ddlog.h" +using namespace DDLog; #include "camera.h" #if QT_VERSION_MAJOR > 5 @@ -101,7 +103,7 @@ Camera::Camera() , m_bReadyRecord(false) , m_bRecording(false) { - qDebug() << "Initializing Camera"; + qCDebug(appLog) << "Initializing Camera"; parseConfig(); initMember(); } @@ -109,34 +111,34 @@ Camera::Camera() void Camera::initMember() { // 连接相机surface,能够发送每帧QImage数据到外部 - qDebug() << "Initializing camera members"; + qCDebug(appLog) << "Initializing camera members"; #if QT_VERSION_MAJOR > 5 - qDebug() << "Condition check: Qt6 detected, using QVideoSink"; + qCDebug(appLog) << "Condition check: Qt6 detected, using QVideoSink"; #else - qDebug() << "Condition check: Qt5 detected, using VideoSurface"; + qCDebug(appLog) << "Condition check: Qt5 detected, using VideoSurface"; m_videoSurface = new VideoSurface(this); connect(m_videoSurface, &VideoSurface::presentImage, this, &Camera::presentImage); #endif // 初始设备名为空,默认启动config中的摄像头设备,若config设备名为空,则启动defaultCamera switchCamera(); - qDebug() << "Function completed: Camera::initMember"; + qCDebug(appLog) << "Function completed: Camera::initMember"; } void Camera::switchCamera() { - qDebug() << "Switching camera"; + qCDebug(appLog) << "Switching camera"; refreshCamDevList(); #if QT_VERSION_MAJOR > 5 QCameraDevice nextDevice; if (!m_cameraDeviceList.isEmpty()) { - qDebug() << "Condition check: Camera device list not empty"; + qCDebug(appLog) << "Condition check: Camera device list not empty"; int nCurIndex = m_cameraDeviceList.indexOf(m_curDevice); nCurIndex = (nCurIndex + 1) % m_cameraDeviceList.size(); nextDevice = m_cameraDeviceList[nCurIndex]; - qDebug() << "Switching to next camera device:" << nextDevice.description(); + qCDebug(appLog) << "Switching to next camera device:" << nextDevice.description(); } nextDevice = QMediaDevices::defaultVideoInput(); startCamera(nextDevice); @@ -144,43 +146,43 @@ void Camera::switchCamera() QString nextDevName; if (!m_cameraDevList.isEmpty()) { - qDebug() << "Condition check: Camera device list not empty"; + qCDebug(appLog) << "Condition check: Camera device list not empty"; int nCurIndex = m_cameraDevList.indexOf(m_curDevName); nCurIndex = (nCurIndex + 1) % m_cameraDevList.size(); nextDevName = m_cameraDevList[nCurIndex]; - qDebug() << "Switching to next camera device:" << nextDevName; + qCDebug(appLog) << "Switching to next camera device:" << nextDevName; } if (nextDevName.isEmpty()) { - qDebug() << "Condition check: No camera device selected, using config"; + qCDebug(appLog) << "Condition check: No camera device selected, using config"; nextDevName = camConfig.device_location; } if (nextDevName.isEmpty()) { - qDebug() << "Condition check: No device in config, using default"; + qCDebug(appLog) << "Condition check: No device in config, using default"; nextDevName = QCameraInfo::defaultCamera().deviceName(); - qDebug() << "Using default camera device:" << nextDevName; + qCDebug(appLog) << "Using default camera device:" << nextDevName; } startCamera(nextDevName); #endif - qDebug() << "Function completed: Camera::switchCamera"; + qCDebug(appLog) << "Function completed: Camera::switchCamera"; } void Camera::refreshCamera() { - qDebug() << "Refreshing camera"; + qCDebug(appLog) << "Refreshing camera"; refreshCamDevList(); // 设备链表找不到当前设备,发送设备断开信号 #if QT_VERSION_MAJOR > 5 if (!m_curDevice.isNull() && m_cameraDeviceList.indexOf(m_curDevice) == -1) { - qWarning() << "Current camera device disconnected"; + qCWarning(appLog) << "Current camera device disconnected"; m_curDevice = QCameraDevice(); emit currentCameraDisConnected(); } #else if (!m_curDevName.isEmpty() && m_cameraDevList.indexOf(m_curDevName) == -1) { - qWarning() << "Current camera device disconnected:" << m_curDevName; + qCWarning(appLog) << "Current camera device disconnected:" << m_curDevName; m_curDevName = ""; emit currentCameraDisConnected(); } @@ -188,17 +190,17 @@ void Camera::refreshCamera() // 若没有摄像头工作,则重启摄像头 restartCamera(); - qDebug() << "Function completed: Camera::refreshCamera"; + qCDebug(appLog) << "Function completed: Camera::refreshCamera"; } #include // 重启摄像头 void Camera::restartCamera() { - qDebug() << "Restarting camera"; + qCDebug(appLog) << "Restarting camera"; #if QT_VERSION_MAJOR > 5 if (!m_camera) { - qDebug() << "Condition check: No camera instance exists"; + qCDebug(appLog) << "Condition check: No camera instance exists"; QList availableCams = QMediaDevices::videoInputs(); if ((availableCams.isEmpty() || (m_camera && availableCams.indexOf(m_camera->cameraDevice()) != -1)) #if QT_VERSION_MAJOR > 5 @@ -206,17 +208,17 @@ void Camera::restartCamera() #else && !m_cameraDevList.isEmpty()) { #endif - qWarning() << "No available cameras found"; + qCWarning(appLog) << "No available cameras found"; emit cameraCannotUsed(); return; } #else if (!m_camera || m_camera->status() == QCamera::UnloadedStatus) { - qDebug() << "Condition check: Camera needs restart"; + qCDebug(appLog) << "Condition check: Camera needs restart"; QList availableCams = QCameraInfo::availableCameras(); if ((availableCams.isEmpty() || (m_camera && availableCams.indexOf(QCameraInfo(*m_camera)) != -1)) && !m_cameraDevList.isEmpty()) { - qWarning() << "No available cameras found"; + qCWarning(appLog) << "No available cameras found"; emit cameraCannotUsed(); return; } @@ -224,7 +226,7 @@ void Camera::restartCamera() } if (DataManager::instance()->getdevStatus() == CAM_CANUSE) { - qDebug() << "Camera is already in use"; + qCDebug(appLog) << "Camera is already in use"; return; } @@ -235,34 +237,34 @@ void Camera::restartCamera() #endif DataManager::instance()->setdevStatus(CAM_CANUSE); - qInfo() << "Camera restarted successfully"; + qCInfo(appLog) << "Camera restarted successfully"; emit cameraDevRestarted(); - qDebug() << "Function completed: Camera::restartCamera"; + qCDebug(appLog) << "Function completed: Camera::restartCamera"; } void Camera::refreshCamDevList() { - qDebug() << "Refreshing camera device list"; + qCDebug(appLog) << "Refreshing camera device list"; #if QT_VERSION_MAJOR > 5 m_cameraDeviceList.clear(); m_cameraDeviceList = QMediaDevices::videoInputs(); - qDebug() << "Found" << m_cameraDeviceList.size() << "camera devices"; + qCDebug(appLog) << "Found" << m_cameraDeviceList.size() << "camera devices"; #else m_cameraDevList.clear(); v4l2_device_list_t *devlist = get_device_list(); for (int i = 0; i < devlist->num_devices; i++) m_cameraDevList.push_back(devlist->list_devices[i].device); - qDebug() << "Found" << m_cameraDevList.size() << "camera devices"; + qCDebug(appLog) << "Found" << m_cameraDevList.size() << "camera devices"; #endif } #if QT_VERSION_MAJOR <= 5 void Camera::onCameraStatusChanged(QCamera::Status status) { - qDebug() << "Camera status changed to:" << status; + qCDebug(appLog) << "Camera status changed to:" << status; if (m_mediaRecoder) { - qDebug() << "Media recorder exists, checking status"; + qCDebug(appLog) << "Media recorder exists, checking status"; if (m_bReadyRecord && status == QCamera::ActiveStatus) { m_mediaRecoder->record(); m_bReadyRecord = false; @@ -273,12 +275,12 @@ void Camera::onCameraStatusChanged(QCamera::Status status) QStringList Camera::getSupportResolutions() { - qDebug() << "Getting supported resolutions"; + qCDebug(appLog) << "Getting supported resolutions"; QStringList resolutionsList; QList supportResolutionList = getSupportResolutionsSize(); if (supportResolutionList.isEmpty()) - qWarning() << "No supported resolutions found"; + qCWarning(appLog) << "No supported resolutions found"; int size = supportResolutionList.size(); resolutionsList.clear(); @@ -287,17 +289,17 @@ QStringList Camera::getSupportResolutions() resolutionsList.append(resol); } - qDebug() << "Supported resolutions:" << resolutionsList; + qCDebug(appLog) << "Supported resolutions:" << resolutionsList; return resolutionsList; } QList Camera::getSupportResolutionsSize() { - qDebug() << "Function started: Camera::getSupportResolutionsSize"; + qCDebug(appLog) << "Function started: Camera::getSupportResolutionsSize"; QList resolutions; #if QT_VERSION_MAJOR > 5 if (m_camera) { - qDebug() << "Condition check: Camera instance exists"; + qCDebug(appLog) << "Condition check: Camera instance exists"; resolutions = m_camera->cameraDevice().photoResolutions(); } #else @@ -305,20 +307,20 @@ QList Camera::getSupportResolutionsSize() resolutions = m_imageCapture->supportedResolutions(); #endif - qDebug() << "Function completed: Camera::getSupportResolutionsSize"; + qCDebug(appLog) << "Function completed: Camera::getSupportResolutionsSize"; return resolutions; } // 设置相机分辨率 void Camera::setCameraResolution(QSize size) { - qDebug() << "Setting camera resolution to:" << size; + qCDebug(appLog) << "Setting camera resolution to:" << size; #if QT_VERSION_MAJOR > 5 //TODO #else // 设置图片捕获器分辨率到相机 if (m_imageCapture) { - qDebug() << "Condition check: Setting image capture resolution"; + qCDebug(appLog) << "Condition check: Setting image capture resolution"; QImageEncoderSettings imageSettings = m_imageCapture->encodingSettings(); imageSettings.setResolution(size); m_imageCapture->setEncodingSettings(imageSettings); @@ -326,7 +328,7 @@ void Camera::setCameraResolution(QSize size) // 设置视频分辨率到相机 if (m_mediaRecoder) { - qDebug() << "Condition check: Setting media recorder resolution"; + qCDebug(appLog) << "Condition check: Setting media recorder resolution"; QAudioEncoderSettings audioSettings = m_mediaRecoder->audioSettings(); QVideoEncoderSettings videoSettings = m_mediaRecoder->videoSettings(); videoSettings.setCodec("video/x-vp8"); @@ -336,7 +338,7 @@ void Camera::setCameraResolution(QSize size) // 设置分辨率到相机 if (m_camera) { - qDebug() << "Condition check: Setting camera viewfinder resolution"; + qCDebug(appLog) << "Condition check: Setting camera viewfinder resolution"; QCameraViewfinderSettings viewfinderSettings = m_camera->viewfinderSettings(); viewfinderSettings.setResolution(size); m_camera->setViewfinderSettings(viewfinderSettings); @@ -347,12 +349,12 @@ void Camera::setCameraResolution(QSize size) camConfig.width = size.rwidth(); camConfig.height = size.rheight(); saveConfig(); - qDebug() << "Camera resolution set successfully"; + qCDebug(appLog) << "Camera resolution set successfully"; } QSize Camera::getCameraResolution() { - qDebug() << "Getting camera resolution"; + qCDebug(appLog) << "Getting camera resolution"; return QSize(camConfig.width,camConfig.height); } @@ -363,9 +365,9 @@ void Camera::startCamera(const QString &devName) #endif { // 存在上一相机,先停止 - qDebug() << "Starting camera"; + qCDebug(appLog) << "Starting camera"; if (m_camera) { - qDebug() << "Stopping existing camera"; + qCDebug(appLog) << "Stopping existing camera"; stopCamera(); } @@ -373,13 +375,13 @@ void Camera::startCamera(const QString &devName) m_camera = new QCamera(device); m_videoSink = new QVideoSink(this); m_curDevice = device; - qDebug() << "Started camera device:" << device.description(); + qCDebug(appLog) << "Started camera device:" << device.description(); #else m_camera = new QCamera(devName.toStdString().c_str()); QCameraInfo cameraInfo(*m_camera); connect(m_camera, SIGNAL(statusChanged(QCamera::Status)), this, SLOT(onCameraStatusChanged(QCamera::Status))); m_curDevName = devName; - qDebug() << "Started camera device:" << m_curDevName; + qCDebug(appLog) << "Started camera device:" << m_curDevName; m_imageCapture = new QCameraImageCapture(m_camera); m_mediaRecoder = new QMediaRecorder(m_camera); @@ -413,7 +415,7 @@ void Camera::startCamera(const QString &devName) if (m_curDevName != configDevName || (m_curDevName.isEmpty() && m_curDevName == configDevName)) { if (!supportList.isEmpty()) { - qDebug() << "Resetting resolution to maximum supported:" << supportList.last(); + qCDebug(appLog) << "Resetting resolution to maximum supported:" << supportList.last(); camConfig.width = supportList.last().rwidth(); camConfig.height = supportList.last().rheight(); } @@ -430,7 +432,7 @@ void Camera::startCamera(const QString &devName) } } if (bResetResolution) { - qDebug() << "Current resolution not supported, resetting to:" << supportList.last(); + qCDebug(appLog) << "Current resolution not supported, resetting to:" << supportList.last(); camConfig.width = supportList.last().width(); camConfig.height = supportList.last().height(); } @@ -446,7 +448,7 @@ void Camera::startCamera(const QString &devName) void Camera::stopCamera() { - qDebug() << "Stopping camera"; + qCDebug(appLog) << "Stopping camera"; if (m_camera) { #if QT_VERSION_MAJOR <= 5 connect(m_camera, SIGNAL(statusChanged(QCamera::Status)), this, SLOT(onCameraStatusChanged(QCamera::Status))); @@ -459,46 +461,46 @@ void Camera::stopCamera() #if QT_VERSION_MAJOR > 5 #else if (m_imageCapture) { - qDebug() << "Condition check: Image capture instance exists"; + qCDebug(appLog) << "Condition check: Image capture instance exists"; m_imageCapture->deleteLater(); m_imageCapture = nullptr; } #endif if (m_mediaRecoder) { - qDebug() << "Condition check: Media recorder instance exists"; + qCDebug(appLog) << "Condition check: Media recorder instance exists"; m_mediaRecoder->deleteLater(); m_mediaRecoder = nullptr; } - qDebug() << "Camera stopped successfully"; + qCDebug(appLog) << "Camera stopped successfully"; } void Camera::setVideoOutPutPath(QString &path) { - qDebug() << "Setting video output path:" << path; + qCDebug(appLog) << "Setting video output path:" << path; if (m_mediaRecoder) m_mediaRecoder->setOutputLocation(QUrl::fromLocalFile(path)); } void Camera::startRecoder() { - qDebug() << "Starting recorder"; + qCDebug(appLog) << "Starting recorder"; #if QT_VERSION_MAJOR > 5 #else m_bReadyRecord = true; if (m_camera && m_camera->captureMode() != QCamera::CaptureVideo) { - qDebug() << "Condition check: Setting camera to video capture mode"; + qCDebug(appLog) << "Condition check: Setting camera to video capture mode"; m_camera->setCaptureMode(QCamera::CaptureVideo); } m_bRecording = true; - qDebug() << "Recorder started successfully"; + qCDebug(appLog) << "Recorder started successfully"; #endif } void Camera::stopRecoder() { - qDebug() << "Stopping recorder"; + qCDebug(appLog) << "Stopping recorder"; #if QT_VERSION_MAJOR > 5 #else if (m_mediaRecoder) @@ -507,41 +509,41 @@ void Camera::stopRecoder() m_camera->setCaptureMode(QCamera::CaptureStillImage); m_bRecording = false; - qDebug() << "Recorder stopped successfully"; + qCDebug(appLog) << "Recorder stopped successfully"; #endif } qint64 Camera::getRecoderTime() { - qDebug() << "Function started: getRecoderTime"; + qCDebug(appLog) << "Function started: getRecoderTime"; qint64 nRecTime = 0; if (m_mediaRecoder) nRecTime = m_mediaRecoder->duration(); - qDebug() << "Function completed: getRecoderTime:" << nRecTime; + qCDebug(appLog) << "Function completed: getRecoderTime:" << nRecTime; return nRecTime; } #if QT_VERSION_MAJOR > 5 QMediaRecorder::RecorderState Camera::getRecoderState() { - qDebug() << "Function started: Camera::getRecoderState"; + qCDebug(appLog) << "Function started: Camera::getRecoderState"; QMediaRecorder::RecorderState recState = QMediaRecorder::StoppedState; if (m_mediaRecoder) recState = m_mediaRecoder->recorderState(); - qDebug() << "Function completed: Camera::getRecoderState"; + qCDebug(appLog) << "Function completed: Camera::getRecoderState"; return recState; } #else QMediaRecorder::State Camera::getRecoderState() { - qDebug() << "Function started: Camera::getRecoderState"; + qCDebug(appLog) << "Function started: Camera::getRecoderState"; QMediaRecorder::State recState = QMediaRecorder::StoppedState; if (m_mediaRecoder) recState = m_mediaRecoder->state(); - qDebug() << "Function completed: Camera::getRecoderState"; + qCDebug(appLog) << "Function completed: Camera::getRecoderState"; return recState; } #endif @@ -576,7 +578,7 @@ int Camera::parseConfig() { // qDebug() << "Condition check: Failed to open config file"; free(config_file); - qWarning() << "Could not open config file for reading:" << strerror(errno); + qCWarning(appLog) << "Could not open config file for reading:" << strerror(errno); return -1; } @@ -617,7 +619,7 @@ int Camera::parseConfig() /*skip invalid lines */ if(!token || !value || strlen(token) < 1 || strlen(value) < 1) { - qWarning() << "Skipping invalid config entry at line" << line; + qCWarning(appLog) << "Skipping invalid config entry at line" << line; if(token) free(token); if(value) @@ -627,18 +629,18 @@ int Camera::parseConfig() /*check tokens*/ if(strcmp(token, "width") == 0) { - qDebug() << "Condition check: Setting width"; + qCDebug(appLog) << "Condition check: Setting width"; camConfig.width = (int) strtoul(value, NULL, 10); } else if(strcmp(token, "height") == 0) { - qDebug() << "Condition check: Setting height"; + qCDebug(appLog) << "Condition check: Setting height"; camConfig.height = (int) strtoul(value, NULL, 10); } else if(strcmp(token, "device_name") == 0 && strlen(value) > 0) { - qDebug() << "Condition check: Setting device_name"; + qCDebug(appLog) << "Condition check: Setting device_name"; if(camConfig.device_name) free(camConfig.device_name); camConfig.device_name = strdup(value); } else if(strcmp(token, "device_location") == 0 && strlen(value) > 0) { - qDebug() << "Condition check: Setting device_location"; + qCDebug(appLog) << "Condition check: Setting device_location"; if(camConfig.device_location) free(camConfig.device_location); camConfig.device_location = strdup(value); @@ -652,13 +654,13 @@ int Camera::parseConfig() free(config_file); fclose(fp); - qDebug() << "Configuration parsed successfully"; + qCDebug(appLog) << "Configuration parsed successfully"; return 0; } int Camera::saveConfig() { - qDebug() << "Saving camera configuration"; + qCDebug(appLog) << "Saving camera configuration"; QString config_file = QString(getenv("HOME")) + QDir::separator() + QString(".config") + QDir::separator() + QString("deepin") + QDir::separator() + QString("deepin-camera") + QDir::separator() + QString("deepin-camera"); @@ -668,7 +670,7 @@ int Camera::saveConfig() /*open file for write*/ if((fp = fopen(filename,"w")) == NULL) { - qWarning() << "Could not open config file for writing:" << strerror(errno); + qCWarning(appLog) << "Could not open config file for writing:" << strerror(errno); free(filename); return -1; } @@ -710,10 +712,10 @@ int Camera::saveConfig() /* close file after fsync (sync file data to disk) */ if (fsync(fileno(fp)) || fclose(fp)) { - qWarning() << "Error writing configuration data to file:" << strerror(errno); + qCWarning(appLog) << "Error writing configuration data to file:" << strerror(errno); return -1; } - qDebug() << "Configuration saved successfully"; + qCDebug(appLog) << "Configuration saved successfully"; return 0; } diff --git a/src/src/capplication.cpp b/src/src/capplication.cpp index f7679b1d..2ebcad7f 100644 --- a/src/src/capplication.cpp +++ b/src/src/capplication.cpp @@ -1,16 +1,18 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// Copyright (C) 2020 - 2026 Uniontech Software Technology Co.,Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later #include "capplication.h" +#include "ddlog.h" +using namespace DDLog; CApplication *CApplication::cameraCore = nullptr; CApplication::CApplication(int &argc, char **argv) : QtSingleApplication(argc, argv) { - qDebug() << "Function started: CApplication constructor"; + qCDebug(appLog) << "Function started: CApplication constructor"; m_mainwindow = nullptr; #ifndef TABLE_ENVIRONMENT m_bpanel = false; @@ -19,7 +21,7 @@ CApplication::CApplication(int &argc, char **argv) #endif if (cameraCore == nullptr) { - qDebug() << "Condition check: Setting cameraCore instance"; + qCDebug(appLog) << "Condition check: Setting cameraCore instance"; cameraCore = this; } @@ -28,7 +30,7 @@ CApplication::CApplication(int &argc, char **argv) Dtk::Core::DVtableHook::overrideVfptrFun(dApplication(), &DApplication::handleQuitAction, CamApp, &CApplication::QuitAction); - qDebug() << "Function completed: CApplication constructor"; + qCDebug(appLog) << "Function completed: CApplication constructor"; } CApplication *CApplication::CamApplication() diff --git a/src/src/circlepushbutton.cpp b/src/src/circlepushbutton.cpp index 818c21a3..a5832a5a 100644 --- a/src/src/circlepushbutton.cpp +++ b/src/src/circlepushbutton.cpp @@ -1,5 +1,5 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// Copyright (C) 2020 - 2026 Uniontech Software Technology Co.,Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -11,6 +11,8 @@ #include #include #include +#include "ddlog.h" +using namespace DDLog; circlePushButton::circlePushButton(QWidget *parent): QPushButton(parent), m_radius(20) { @@ -270,7 +272,7 @@ void circlePushButton::setButtonRadius(int radius) { // qDebug() << "Function started: setButtonRadius"; if (radius <= 0) { - qWarning() << "Invalid button radius:" << radius; + qCWarning(appLog) << "Invalid button radius:" << radius; return; } diff --git a/src/src/closedialog.cpp b/src/src/closedialog.cpp index cc62e533..0bd589a4 100644 --- a/src/src/closedialog.cpp +++ b/src/src/closedialog.cpp @@ -1,5 +1,5 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// Copyright (C) 2020 - 2026 Uniontech Software Technology Co.,Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -17,6 +17,8 @@ #include #endif #include +#include "ddlog.h" +using namespace DDLog; DWIDGET_USE_NAMESPACE @@ -25,7 +27,7 @@ typedef DLabel QLbtoDLabel; CloseDialog::CloseDialog(QWidget *parent, QString strText) : DDialog(parent), m_leftNamebtn(tr("Cancel")), m_rightNamebtn(tr("Close")) { - qDebug() << "Function started: CloseDialog constructor"; + qCDebug(appLog) << "Function started: CloseDialog constructor"; this->setIcon(QIcon(":/images/icons/warning.svg")); setFixedSize(380, 140); m_widget = new DWidget(this); @@ -64,5 +66,5 @@ CloseDialog::CloseDialog(QWidget *parent, QString strText) setTabOrder(windowCloseBtn, cancelBtn); setTabOrder(cancelBtn, closeBtn); - qDebug() << "Function completed: CloseDialog constructor"; + qCDebug(appLog) << "Function completed: CloseDialog constructor"; } diff --git a/src/src/devnummonitor.cpp b/src/src/devnummonitor.cpp index f21e731d..e9974b2f 100644 --- a/src/src/devnummonitor.cpp +++ b/src/src/devnummonitor.cpp @@ -1,11 +1,13 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// Copyright (C) 2020 - 2026 Uniontech Software Technology Co.,Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later #include "devnummonitor.h" #include +#include "ddlog.h" +using namespace DDLog; extern "C" { @@ -15,7 +17,7 @@ extern "C" DevNumMonitor::DevNumMonitor() { - qDebug() << "Initializing DevNumMonitor"; + qCDebug(appLog) << "Initializing DevNumMonitor"; m_noDevice = false; m_pTimer = nullptr; } @@ -26,12 +28,12 @@ DevNumMonitor::DevNumMonitor() */ void DevNumMonitor::startCheck() { - qDebug() << "Starting device number monitoring"; + qCDebug(appLog) << "Starting device number monitoring"; m_pTimer = new QTimer; m_pTimer->setInterval(500); connect(m_pTimer, &QTimer::timeout, this, &DevNumMonitor::timeOutSlot); m_pTimer->start(); - qDebug() << "Device monitoring timer started with 500ms interval"; + qCDebug(appLog) << "Device monitoring timer started with 500ms interval"; } //void DevNumMonitor::run() @@ -59,7 +61,7 @@ void DevNumMonitor::timeOutSlot() if (deviceCount < 1) { if (!m_noDevice) { - qWarning() << "No camera devices found"; + qCWarning(appLog) << "No camera devices found"; emit noDeviceFound(); m_noDevice = true; } @@ -67,7 +69,7 @@ void DevNumMonitor::timeOutSlot() if (m_noDevice) { v4l2_dev_sys_data_t *v4l2_devices = get_device_list()->list_devices; if (v4l2_devices) { - qWarning() << "Device found:" << v4l2_devices[0].device << v4l2_devices[0].name; + qCWarning(appLog) << "Device found:" << v4l2_devices[0].device << v4l2_devices[0].name; } } m_noDevice = false; @@ -83,9 +85,9 @@ void DevNumMonitor::timeOutSlot() DevNumMonitor::~DevNumMonitor() { - qDebug() << "Destroying DevNumMonitor"; + qCDebug(appLog) << "Destroying DevNumMonitor"; if (nullptr != m_pTimer) { - qDebug() << "Stopping and cleaning up monitoring timer"; + qCDebug(appLog) << "Stopping and cleaning up monitoring timer"; m_pTimer->stop(); m_pTimer->deleteLater(); m_pTimer = nullptr; diff --git a/src/src/exposureslider.cpp b/src/src/exposureslider.cpp index 30e465af..ac77a3b0 100644 --- a/src/src/exposureslider.cpp +++ b/src/src/exposureslider.cpp @@ -15,6 +15,8 @@ #include #include +#include "ddlog.h" +using namespace DDLog; #define WIDTH 40 #define HEIGHT 192 @@ -28,7 +30,7 @@ ExposureSlider::ExposureSlider(QWidget *parent) : QWidget(parent) ,m_curValue(0) ,m_opacity(102) //UI默认 { - qDebug() << "Initializing ExposureSlider"; + qCDebug(appLog) << "Initializing ExposureSlider"; resize(WIDTH, HEIGHT); QVBoxLayout *vLayout = new QVBoxLayout(this); vLayout->setContentsMargins(0, 0, 0, 0); @@ -54,7 +56,7 @@ ExposureSlider::ExposureSlider(QWidget *parent) : QWidget(parent) m_pLabShowValue->setPalette(pa); //字体大小不随系统变化 connect(qApp, &QGuiApplication::fontChanged, this, [=](){ - qDebug() << "Updating font settings for value display"; + qCDebug(appLog) << "Updating font settings for value display"; QFont font("SourceHanSansSC"); font.setPixelSize(15); font.setWeight(QFont::Medium); @@ -80,19 +82,19 @@ ExposureSlider::ExposureSlider(QWidget *parent) : QWidget(parent) m_pLabShowValue->hide(); m_slider->hide(); - qDebug() << "ExposureSlider initialization completed"; + qCDebug(appLog) << "ExposureSlider initialization completed"; } void ExposureSlider::setOpacity(int opacity) { - qDebug() << "Setting slider opacity to:" << opacity; + qCDebug(appLog) << "Setting slider opacity to:" << opacity; m_opacity = opacity; update(); } void ExposureSlider::showContent(bool show, bool isShortCut) { - qDebug() << "Showing exposure slider content:" << show << "isShortCut:" << isShortCut; + qCDebug(appLog) << "Showing exposure slider content:" << show << "isShortCut:" << isShortCut; QGraphicsOpacityEffect *effectSlider = new QGraphicsOpacityEffect(m_slider); m_slider->setGraphicsEffect(effectSlider); QPropertyAnimation *opacity = new QPropertyAnimation(effectSlider, "opacity", this); @@ -110,14 +112,14 @@ void ExposureSlider::showContent(bool show, bool isShortCut) pGroup->addAnimation(opacity1); if (show) { - qDebug() << "Condition check: Showing content (fade in)"; + qCDebug(appLog) << "Condition check: Showing content (fade in)"; opacity->setStartValue(0); opacity->setEndValue(1); opacity1->setStartValue(0); opacity1->setEndValue(1); connect(pGroup, &QParallelAnimationGroup::finished, this, [=](){ - qDebug() << "Animation finished, handling cleanup"; + qCDebug(appLog) << "Animation finished, handling cleanup"; m_slider->slider()->setFocus(); pGroup->deleteLater(); }); @@ -126,7 +128,7 @@ void ExposureSlider::showContent(bool show, bool isShortCut) m_slider->show(); pGroup->start(); } else { - qDebug() << "Condition check: Hiding content (fade out)"; + qCDebug(appLog) << "Condition check: Hiding content (fade out)"; opacity->setStartValue(1); opacity->setEndValue(0); opacity1->setStartValue(1); @@ -134,7 +136,7 @@ void ExposureSlider::showContent(bool show, bool isShortCut) connect(pGroup, &QParallelAnimationGroup::finished, this, &ExposureSlider::contentHided); connect(pGroup, &QParallelAnimationGroup::finished, this, [=](){ - qDebug() << "Animation finished, hiding widgets"; + qCDebug(appLog) << "Animation finished, hiding widgets"; m_pLabShowValue->hide(); m_slider->hide(); pGroup->deleteLater(); @@ -142,7 +144,7 @@ void ExposureSlider::showContent(bool show, bool isShortCut) pGroup->start(); } - qDebug() << "Function completed: showContent"; + qCDebug(appLog) << "Function completed: showContent"; } void ExposureSlider::paintEvent(QPaintEvent *event) diff --git a/src/src/filterpreviewbutton.cpp b/src/src/filterpreviewbutton.cpp index 07bd90e7..cb403a8a 100644 --- a/src/src/filterpreviewbutton.cpp +++ b/src/src/filterpreviewbutton.cpp @@ -1,9 +1,11 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// Copyright (C) 2020 - 2026 Uniontech Software Technology Co.,Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later #include "filterpreviewbutton.h" +#include "ddlog.h" +using namespace DDLog; extern "C" { #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -32,11 +34,11 @@ DWIDGET_USE_NAMESPACE; filterPreviewButton::filterPreviewButton(QWidget *parent, efilterType filter/* = filter_Normal*/): QWidget(parent) , m_filterType(filter) { - qDebug() << "Function started: filterPreviewButton constructor"; + qCDebug(appLog) << "Function started: filterPreviewButton constructor"; QString objName = filterName_CUBE(filter); if (objName.isEmpty()) { - qDebug() << "Condition check: Filter name empty, using 'normal'"; + qCDebug(appLog) << "Condition check: Filter name empty, using 'normal'"; objName = "normal"; } setObjectName(objName); @@ -56,7 +58,7 @@ filterPreviewButton::filterPreviewButton(QWidget *parent, efilterType filter/* = setAutoFillBackground(false); resize(BUTTON_SIZE, BUTTON_SIZE); - qDebug() << "Function completed: filterPreviewButton constructor"; + qCDebug(appLog) << "Function completed: filterPreviewButton constructor"; } void filterPreviewButton::setbackground(QColor color) @@ -286,44 +288,44 @@ QString filterPreviewButton::filterName(efilterType type) QString name = tr("Normal"); switch (type) { case filter_Normal: - qDebug() << "Condition check: Normal filter"; + qCDebug(appLog) << "Condition check: Normal filter"; name = tr("Normal"); break; case filter_Vivid: - qDebug() << "Condition check: Vivid filter"; + qCDebug(appLog) << "Condition check: Vivid filter"; name = tr("Vivid"); break; case filter_Warm: - qDebug() << "Condition check: Warm filter"; + qCDebug(appLog) << "Condition check: Warm filter"; name = tr("Warm"); break; case filter_Cold: - qDebug() << "Condition check: Cold filter"; + qCDebug(appLog) << "Condition check: Cold filter"; name = tr("Cold"); break; case filter_Retro: - qDebug() << "Condition check: Retro filter"; + qCDebug(appLog) << "Condition check: Retro filter"; name = tr("Retro"); break; case filter_Film: - qDebug() << "Condition check: Film filter"; + qCDebug(appLog) << "Condition check: Film filter"; name = tr("Film"); break; case filter_Gray: - qDebug() << "Condition check: Gray filter"; + qCDebug(appLog) << "Condition check: Gray filter"; name = tr("Gray"); break; case filter_BAndW: - qDebug() << "Condition check: B&W filter"; + qCDebug(appLog) << "Condition check: B&W filter"; name = tr("B&W"); break; default: - qDebug() << "Condition check: Unknown filter type, using Normal"; + qCDebug(appLog) << "Condition check: Unknown filter type, using Normal"; name = tr("Normal"); break; } - qDebug() << "Function completed: filterName:" << name; + qCDebug(appLog) << "Function completed: filterName:" << name; return name; } @@ -333,43 +335,43 @@ QString filterPreviewButton::filterName_CUBE(efilterType type) QString name = ""; switch (type) { case filter_Normal: - qDebug() << "Condition check: Normal filter (no CUBE)"; + qCDebug(appLog) << "Condition check: Normal filter (no CUBE)"; name = ""; break; case filter_Vivid: - qDebug() << "Condition check: Vivid filter"; + qCDebug(appLog) << "Condition check: Vivid filter"; name = "bright"; break; case filter_Warm: - qDebug() << "Condition check: Warm filter"; + qCDebug(appLog) << "Condition check: Warm filter"; name = "warm"; break; case filter_Cold: - qDebug() << "Condition check: Cold filter"; + qCDebug(appLog) << "Condition check: Cold filter"; name = "cold"; break; case filter_Retro: - qDebug() << "Condition check: Retro filter"; + qCDebug(appLog) << "Condition check: Retro filter"; name = "classic"; break; case filter_Film: - qDebug() << "Condition check: Film filter"; + qCDebug(appLog) << "Condition check: Film filter"; name = "print"; break; case filter_Gray: - qDebug() << "Condition check: Gray filter"; + qCDebug(appLog) << "Condition check: Gray filter"; name = "gray"; break; case filter_BAndW: - qDebug() << "Condition check: B&W filter"; + qCDebug(appLog) << "Condition check: B&W filter"; name = "black"; break; default: - qDebug() << "Condition check: Unknown filter type, using empty"; + qCDebug(appLog) << "Condition check: Unknown filter type, using empty"; name = ""; break; } - qDebug() << "Function completed: filterName_CUBE:" << name; + qCDebug(appLog) << "Function completed: filterName_CUBE:" << name; return name; } diff --git a/src/src/globalutils.cpp b/src/src/globalutils.cpp index 72d9621d..ff23298e 100644 --- a/src/src/globalutils.cpp +++ b/src/src/globalutils.cpp @@ -12,6 +12,8 @@ #include #include #include +#include "ddlog.h" +using namespace DDLog; DCORE_USE_NAMESPACE @@ -83,7 +85,7 @@ bool GlobalUtils::isLowPerformanceBoard() QString systemInfoInterface = "com.deepin.system.SystemInfo"; auto ver = DSysInfo::majorVersion().toInt(); if (ver > 20) { - qDebug() << "Condition check: System version > 20, using newer D-Bus interface"; + qCDebug(appLog) << "Condition check: System version > 20, using newer D-Bus interface"; systemInfoService = "org.deepin.dde.SystemInfo1"; systemInfoPath = "/org/deepin/dde/SystemInfo1"; systemInfoInterface = "org.deepin.dde.SystemInfo1"; @@ -91,7 +93,7 @@ bool GlobalUtils::isLowPerformanceBoard() QDBusInterface *monitorInterface = new QDBusInterface(systemInfoService, systemInfoPath, "org.freedesktop.DBus.Properties", QDBusConnection::systemBus()); if (!monitorInterface->isValid()) { - qWarning() << "Failed to connect to system info D-Bus interface"; + qCWarning(appLog) << "Failed to connect to system info D-Bus interface"; return false; } @@ -100,32 +102,32 @@ bool GlobalUtils::isLowPerformanceBoard() replay.value().variant().value() >> dmiInfo; - qDebug() << "System DMI info - Product Name:" << dmiInfo.productName; - qDebug() << "System DMI info - Manufacturer:" << dmiInfo.Manufacturer; - qDebug() << "System DMI info - Version:" << dmiInfo.version; + qCDebug(appLog) << "System DMI info - Product Name:" << dmiInfo.productName; + qCDebug(appLog) << "System DMI info - Manufacturer:" << dmiInfo.Manufacturer; + qCDebug(appLog) << "System DMI info - Version:" << dmiInfo.version; // BXC 600F/NZ2750、CC GWMNDA1GL1等主板不能满足mp4封装的性能要求,因此需要特殊适配 for (auto board : m_LowPerformanceBoards) { if (dmiInfo.productName.contains(board)) { - qInfo() << "Detected low performance board:" << board; + qCInfo(appLog) << "Detected low performance board:" << board; return true; } } - qDebug() << "No low performance board detected"; + qCDebug(appLog) << "No low performance board detected"; return false; } void GlobalUtils::loadCameraConf() { - qDebug() << "Loading camera configuration from:" << CAMERA_CONF_PATH; + qCDebug(appLog) << "Loading camera configuration from:" << CAMERA_CONF_PATH; QSettings conf(CAMERA_CONF_PATH, QSettings::IniFormat); QVariant value = conf.value(LOW_PERFORMANCE_BOARD); if (value.isValid()) { - qDebug() << "Condition check: Configuration value valid"; + qCDebug(appLog) << "Condition check: Configuration value valid"; m_LowPerformanceBoards = value.toStringList(); } else { - qWarning() << "No low performance boards configuration found in" << CAMERA_CONF_PATH; + qCWarning(appLog) << "No low performance boards configuration found in" << CAMERA_CONF_PATH; m_LowPerformanceBoards = QStringList(); } @@ -137,5 +139,5 @@ void GlobalUtils::loadCameraConf() m_IsLowPerformanceDevice = dconfig->value("isLowPerformanceDevice").toBool(); } #endif - qDebug() << "Function completed: loadCameraConf"; + qCDebug(appLog) << "Function completed: loadCameraConf"; } diff --git a/src/src/gstvideowriter.cpp b/src/src/gstvideowriter.cpp index 4a9326b7..2a4b61bb 100644 --- a/src/src/gstvideowriter.cpp +++ b/src/src/gstvideowriter.cpp @@ -1,10 +1,12 @@ -// Copyright (C) 2021 ~ 2022 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// Copyright (C) 2021 - 2026 Uniontech Software Technology Co.,Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later #include "gstvideowriter.h" #include +#include "ddlog.h" +using namespace DDLog; extern "C" { #include #include "v4l2_core.h" @@ -125,152 +127,152 @@ GstVideoWriter::~GstVideoWriter() void GstVideoWriter::start() { - qDebug() << "Function started: start"; + qCDebug(appLog) << "Function started: start"; // 设置视频帧数据格式 loadAppSrcCaps(); #if defined(__mips__) || defined(__aarch64__) // mips/arm下,牺牲了成像质量 - qDebug() << "Condition check: MIPS/ARM architecture detected, adjusting quantizer"; + qCDebug(appLog) << "Condition check: MIPS/ARM architecture detected, adjusting quantizer"; if (m_nWidth >= 1920) { - qDebug() << "Condition check: High resolution (>=1920), setting quantizer to 30"; + qCDebug(appLog) << "Condition check: High resolution (>=1920), setting quantizer to 30"; setQuantizer(30); } else if (m_nWidth >= 1280) { - qDebug() << "Condition check: Medium resolution (>=1280), setting quantizer to 10"; + qCDebug(appLog) << "Condition check: Medium resolution (>=1280), setting quantizer to 10"; setQuantizer(10); } else { - qDebug() << "Condition check: Low resolution, setting quantizer to 5"; + qCDebug(appLog) << "Condition check: Low resolution, setting quantizer to 5"; setQuantizer(5); } #endif // 启动管道 - qDebug() << "Starting GStreamer pipeline"; + qCDebug(appLog) << "Starting GStreamer pipeline"; g_mvideo_gst_element_set_state(m_pipeline, GST_STATE_PLAYING); // 将录制任务放到线程中运行,bus回调收到eos信号,结束录制任务 - qDebug() << "Running main loop in separate thread"; + qCDebug(appLog) << "Running main loop in separate thread"; QtConcurrent::run(g_main_loop_run, m_gloop); - qDebug() << "Function completed: start"; + qCDebug(appLog) << "Function completed: start"; } void GstVideoWriter::stop() { - qDebug() << "Function started: stop"; + qCDebug(appLog) << "Function started: stop"; GstFlowReturn ret; // 停止音频流 if (m_audsrc) { - qDebug() << "Condition check: Stopping audio stream"; + qCDebug(appLog) << "Condition check: Stopping audio stream"; g_signal_emit_by_name(m_audsrc, "end-of-stream", &ret); } // 停止视频流 if (m_appsrc) { - qDebug() << "Condition check: Stopping video stream"; + qCDebug(appLog) << "Condition check: Stopping video stream"; g_signal_emit_by_name(m_appsrc, "end-of-stream", &ret); } - qDebug() << "Function completed: stop"; + qCDebug(appLog) << "Function completed: stop"; } void GstVideoWriter::setVideoPath(const QString &videoPath) { - qDebug() << "Function started: setVideoPath"; + qCDebug(appLog) << "Function started: setVideoPath"; if (!videoPath.isEmpty() && m_videoPath != videoPath) m_videoPath = videoPath; if (m_filesink) g_object_set(m_filesink, "location", videoPath.toStdString().c_str(), NULL); - qDebug() << "Function completed: setVideoPath"; + qCDebug(appLog) << "Function completed: setVideoPath"; } void GstVideoWriter::setQuantizer(uint quantizer) { - qDebug() << "Function started: setQuantizer"; + qCDebug(appLog) << "Function started: setQuantizer"; m_nQuantizer = quantizer; if (m_vp8enc) g_object_set(m_vp8enc, "min-quantizer", m_nQuantizer, NULL); - qDebug() << "Function completed: setQuantizer"; + qCDebug(appLog) << "Function completed: setQuantizer"; } bool GstVideoWriter::writeFrame(uchar *rgb, uint size) { - qDebug() << "Function started: writeFrame"; + qCDebug(appLog) << "Function started: writeFrame"; GstFlowReturn ret = GST_FLOW_CUSTOM_ERROR; guint8 *ptr = (guint8 *)g_malloc(size * sizeof(uchar)); if (ptr) { - qDebug() << "Condition check: Memory allocation successful"; + qCDebug(appLog) << "Condition check: Memory allocation successful"; memcpy(ptr, rgb, size); GstBuffer *buffer = g_mvideo_gst_buffer_new_wrapped((void*)ptr, size); //设置时间戳 if (m_pipeline) { - qDebug() << "Condition check: Setting timestamp for video buffer"; + qCDebug(appLog) << "Condition check: Setting timestamp for video buffer"; GST_BUFFER_PTS(buffer) = g_mvideo_gst_clock_get_time(m_pipeline->clock) - m_pipeline->base_time; } //注入视频帧数据 if (m_appsrc) { - qDebug() << "Condition check: Pushing video buffer to app source"; + qCDebug(appLog) << "Condition check: Pushing video buffer to app source"; g_signal_emit_by_name(m_appsrc, "push-buffer", buffer, &ret); } g_mvideo_gst_mini_object_unref(GST_MINI_OBJECT_CAST(buffer)); } - qDebug() << "Function completed: writeFrame, result:" << (ret == GST_FLOW_OK ? "success" : "failed"); + qCDebug(appLog) << "Function completed: writeFrame, result:" << (ret == GST_FLOW_OK ? "success" : "failed"); return ret == GST_FLOW_OK; } bool GstVideoWriter::writeAudio(uchar *audio, uint size) { - qDebug() << "Function started: writeAudio"; + qCDebug(appLog) << "Function started: writeAudio"; GstFlowReturn ret = GST_FLOW_CUSTOM_ERROR; guint8 *ptr = (guint8 *)g_malloc(size * sizeof(uchar)); if (ptr) { - qDebug() << "Condition check: Memory allocation successful"; + qCDebug(appLog) << "Condition check: Memory allocation successful"; memcpy(ptr, audio, size); GstBuffer *buffer = g_mvideo_gst_buffer_new_wrapped((void*)ptr, size); // 设置时间戳 if (m_pipeline) { - qDebug() << "Condition check: Setting timestamp for audio buffer"; + qCDebug(appLog) << "Condition check: Setting timestamp for audio buffer"; GST_BUFFER_PTS(buffer) = g_mvideo_gst_clock_get_time(m_pipeline->clock) - m_pipeline->base_time; } // 注入音频帧数据 if (m_audsrc) { - qDebug() << "Condition check: Pushing audio buffer to audio source"; + qCDebug(appLog) << "Condition check: Pushing audio buffer to audio source"; g_signal_emit_by_name(m_audsrc, "push-buffer", buffer, &ret); } g_mvideo_gst_mini_object_unref(GST_MINI_OBJECT_CAST(buffer)); } - qDebug() << "Function completed: writeAudio, result:" << (ret == GST_FLOW_OK ? "success" : "failed"); + qCDebug(appLog) << "Function completed: writeAudio, result:" << (ret == GST_FLOW_OK ? "success" : "failed"); return ret == GST_FLOW_OK; } float GstVideoWriter::getRecrodTime() { - qDebug() << "Function started: getRecrodTime"; + qCDebug(appLog) << "Function started: getRecrodTime"; float pts = 0; if (m_pipeline) { - qDebug() << "Condition check: Pipeline exists, getting timestamp"; + qCDebug(appLog) << "Condition check: Pipeline exists, getting timestamp"; pts = g_mvideo_gst_clock_get_time(m_pipeline->clock) - m_pipeline->base_time; } float result = pts / 1000 / 1000 / 1000; - qDebug() << "Function completed: getRecrodTime, result:" << result << "seconds"; + qCDebug(appLog) << "Function completed: getRecrodTime, result:" << result << "seconds"; return result; } void GstVideoWriter::init() { - qDebug() << "Function started: init"; + qCDebug(appLog) << "Function started: init"; g_mvideo_gst_init(nullptr, nullptr); // 使用vp8编码录制视频裸流数据、使用vorbis编码录制音频裸流数据 QString pipDesc = QString("webmmux name=mux ! filesink name=filename " @@ -291,14 +293,14 @@ void GstVideoWriter::init() m_bus = g_mvideo_gst_pipeline_get_bus(getGstPipline(m_pipeline)); if (m_bus) { - qDebug() << "Condition check: Bus exists, adding message watch"; + qCDebug(appLog) << "Condition check: Bus exists, adding message watch"; g_mvideo_gst_bus_add_watch(m_bus, (GstBusFunc)bus_message, this); } /* 设置视频src属性 */ m_appsrc = g_mvideo_gst_bin_get_by_name(getGstBin(m_pipeline), "source"); if (m_appsrc) { - qDebug() << "Condition check: Video app source exists, configuring properties"; + qCDebug(appLog) << "Condition check: Video app source exists, configuring properties"; loadAppSrcCaps(); g_object_set(m_appsrc, "format", GST_FORMAT_TIME, NULL); g_object_set(m_appsrc, "is-live", TRUE, NULL); @@ -307,7 +309,7 @@ void GstVideoWriter::init() /* 设置音频src属性 */ m_audsrc = g_mvideo_gst_bin_get_by_name(getGstBin(m_pipeline), "audiosource"); if (m_audsrc) { - qDebug() << "Condition check: Audio app source exists, configuring properties"; + qCDebug(appLog) << "Condition check: Audio app source exists, configuring properties"; GstCaps *audiocaps = g_mvideo_gst_caps_new_simple("audio/x-raw", "format", G_TYPE_STRING, "F32LE", "layout", G_TYPE_STRING, "interleaved", @@ -319,17 +321,17 @@ void GstVideoWriter::init() g_object_set(m_audsrc, "is-live", TRUE, NULL); } - qDebug() << "Function completed: init"; + qCDebug(appLog) << "Function completed: init"; } void GstVideoWriter::loadAppSrcCaps() { - qDebug() << "Function started: loadAppSrcCaps"; + qCDebug(appLog) << "Function started: loadAppSrcCaps"; // 获取当前相机分辨率 m_nWidth = v4l2core_get_frame_width(get_v4l2_device_handler()); m_nHeight = v4l2core_get_frame_height(get_v4l2_device_handler()); if (m_nWidth > 0 && m_nHeight > 0 && m_appsrc) { - qDebug() << "Condition check: Valid resolution and app source exist, setting caps"; + qCDebug(appLog) << "Condition check: Valid resolution and app source exist, setting caps"; GstCaps *caps = g_mvideo_gst_caps_new_simple("video/x-raw", "format", G_TYPE_STRING, "RGB", "width", G_TYPE_INT, m_nWidth, @@ -339,7 +341,7 @@ void GstVideoWriter::loadAppSrcCaps() g_mvideo_gst_app_src_set_caps(getGstAppSrc(m_appsrc), caps); } - qDebug() << "Function completed: loadAppSrcCaps"; + qCDebug(appLog) << "Function completed: loadAppSrcCaps"; } QString GstVideoWriter::libPath(const QString &strlib) diff --git a/src/src/imageitem.cpp b/src/src/imageitem.cpp index a601b5e7..c98c78a6 100644 --- a/src/src/imageitem.cpp +++ b/src/src/imageitem.cpp @@ -1,5 +1,5 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// Copyright (C) 2020 - 2026 Uniontech Software Technology Co.,Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -28,6 +28,8 @@ #include #include #include +#include "ddlog.h" +using namespace DDLog; extern "C" { #include @@ -101,7 +103,7 @@ ImageItem::ImageItem(QWidget *parent) m_menu->exec(QCursor::pos()); } #endif - qDebug() << "Click the right mouse to open the thumbnail menu bar"; + qCDebug(appLog) << "Click the right mouse to open the thumbnail menu bar"; }); connect(m_actCopy, &QAction::triggered, this, &ImageItem::onCopy); connect(m_actOpenFolder, &QAction::triggered, this, &ImageItem::onOpenFolder); @@ -116,14 +118,14 @@ ImageItem::ImageItem(QWidget *parent) void ImageItem::updatePicPath(const QString &filePath) { - qDebug() << "Updating picture path:" << filePath; + qCDebug(appLog) << "Updating picture path:" << filePath; m_path = filePath; QPixmap pix; QFileInfo fileInfo(filePath); if (fileInfo.suffix() == "webm" || fileInfo.suffix() == "mp4") { m_bVideo = true; - qDebug() << "Processing video file:" << filePath; + qCDebug(appLog) << "Processing video file:" << filePath; if (DataManager::instance()->encodeEnv() == FFmpeg_Env) { video_thumbnailer *m_video_thumbnailer = getLoadLibsInstance()->m_video_thumbnailer(); image_data *m_image_data = getLoadLibsInstance()->m_video_thumbnailer_create_image_data(); @@ -136,7 +138,7 @@ void ImageItem::updatePicPath(const QString &filePath) pix = QPixmap::fromImage(img); malloc_trim(0); } catch (...) { - qWarning() << "Failed to generate video thumbnail for:" << filePath; + qCWarning(appLog) << "Failed to generate video thumbnail for:" << filePath; } getLoadLibsInstance()->m_video_thumbnailer_destroy_image_data(m_image_data); @@ -147,7 +149,7 @@ void ImageItem::updatePicPath(const QString &filePath) } } else if (fileInfo.suffix() == "jpg") { m_bVideo = false; - qInfo() << "Processing image file:" << filePath; + qCInfo(appLog) << "Processing image file:" << filePath; QImage img(filePath); if (img.isNull()) { img.load(filePath); @@ -156,19 +158,19 @@ void ImageItem::updatePicPath(const QString &filePath) pix = QPixmap::fromImage(img); malloc_trim(0); } else { - qWarning() << "Unsupported file format:" << fileInfo.suffix(); + qCWarning(appLog) << "Unsupported file format:" << fileInfo.suffix(); pix = QPixmap(); } QTimer::singleShot(500, this, [ = ]() { updatePic(pix); pix.scaled(this->size(), Qt::KeepAspectRatio); }); - qDebug() << "Function completed: updatePicPath"; + qCDebug(appLog) << "Function completed: updatePicPath"; } void ImageItem::updatePic(QPixmap pixmap) { - qDebug() << "Function started: updatePic"; + qCDebug(appLog) << "Function started: updatePic"; m_pAniWidget->setVisible(true); m_pAniWidget->setPixmap(pixmap); @@ -187,7 +189,7 @@ void ImageItem::updatePic(QPixmap pixmap) update(); m_pAniWidget->setVisible(false); }); - qDebug() << "Function completed: updatePic"; + qCDebug(appLog) << "Function completed: updatePic"; } void ImageItem::paintEvent(QPaintEvent *event) @@ -307,41 +309,41 @@ void ImageItem::focusOutEvent(QFocusEvent *event) void ImageItem::onShowMenu() { - qDebug() << "Function started: onShowMenu"; + qCDebug(appLog) << "Function started: onShowMenu"; QPoint centerpos(width() / 2, height() / 2); QPoint screen_centerpos = mapToGlobal(centerpos); if (m_bVideo) { - qDebug() << "ImageItem::onShowMenu: Enter if branch (video mode, removing print action)"; + qCDebug(appLog) << "ImageItem::onShowMenu: Enter if branch (video mode, removing print action)"; m_menu->removeAction(m_actPrint); } else { - qDebug() << "ImageItem::onShowMenu: Enter else branch (image mode, inserting print action)"; + qCDebug(appLog) << "ImageItem::onShowMenu: Enter else branch (image mode, inserting print action)"; m_menu->insertAction(m_actOpenFolder, m_actPrint); } #ifndef UNITTEST if (!m_path.isEmpty()) { - qDebug() << "ImageItem::onShowMenu: Enter if branch (path not empty, executing menu)"; + qCDebug(appLog) << "ImageItem::onShowMenu: Enter if branch (path not empty, executing menu)"; m_menu->exec(screen_centerpos); } #endif - qDebug() << "Function completed: onShowMenu"; + qCDebug(appLog) << "Function completed: onShowMenu"; } void ImageItem::onOpenFolder() { - qDebug() << "Function started: onOpenFolder"; + qCDebug(appLog) << "Function started: onOpenFolder"; if (!m_path.isEmpty() && m_path == '~') { - qDebug() << "ImageItem::onOpenFolder: Enter if branch (path is home shortcut)"; + qCDebug(appLog) << "ImageItem::onOpenFolder: Enter if branch (path is home shortcut)"; //这里不能直接使用strFolder调replace函数 m_path.replace(0, 1, QDir::homePath()); } QString path = QFileInfo(m_path).absolutePath(); Dtk::Widget::DDesktopServices::showFolder(path); - qDebug() << "Click the right mouse or press the shortcut to open the folder"; + qCDebug(appLog) << "Click the right mouse or press the shortcut to open the folder"; } void ImageItem::initShortcut() { - qDebug() << "Function started: initShortcut"; + qCDebug(appLog) << "Function started: initShortcut"; QShortcutEx *shortcutCopy = new QShortcutEx(QKeySequence("ctrl+c"), this); shortcutCopy->setObjectName(SHORTCUT_COPY); connect(shortcutCopy, SIGNAL(activated()), this, SLOT(onCopy())); @@ -361,16 +363,16 @@ void ImageItem::initShortcut() QShortcutEx *shortcutPrint = new QShortcutEx(QKeySequence("Ctrl+P"), this); shortcutPrint->setObjectName(SHORTCUT_PRINT); connect(shortcutPrint, SIGNAL(activated()), this, SLOT(onPrint())); - qDebug() << "Function completed: initShortcut"; + qCDebug(appLog) << "Function completed: initShortcut"; } void ImageItem::openFile() { - qDebug() << "Function started: openFile"; + qCDebug(appLog) << "Function started: openFile"; const QString filePath = m_path; QFileInfo fileInfo(filePath); if (filePath.isEmpty()) { - qWarning() << "Cannot open file: path is empty"; + qCWarning(appLog) << "Cannot open file: path is empty"; return; } @@ -381,20 +383,20 @@ void ImageItem::openFile() QStringList arguments; bool opened = false; - qDebug() << "Using backup method to open file"; + qCDebug(appLog) << "Using backup method to open file"; if (fileInfo.suffix() == "jpg") { program = "deepin-image-viewer"; //用看图打开 arguments << filePath; - qDebug() << "Attempting to open image with deepin-image-viewer"; + qCDebug(appLog) << "Attempting to open image with deepin-image-viewer"; } else { program = "deepin-movie"; //用影院打开 arguments << filePath; - qDebug() << "Attempting to open video with deepin-movie"; + qCDebug(appLog) << "Attempting to open video with deepin-movie"; } opened = myProcess->startDetached(program, arguments); if (!opened) { //打开失败,调用文管选择"打开方式"窗口 - qWarning() << "Failed to open file with default applications, trying file manager"; + qCWarning(appLog) << "Failed to open file with default applications, trying file manager"; arguments.clear(); program = "dde-file-manager"; arguments << "-o" << filePath; @@ -409,7 +411,7 @@ void ImageItem::openFile() const int osMajor = DSysInfo::majorVersion().toInt(); if (osMajor >= kMinOsEdition) { - qInfo() << "Using DBus to open file on OS v23+"; + qCInfo(appLog) << "Using DBus to open file on OS v23+"; //玲珑环境下无法通过QProcess方式打开应用,通过DBus打开 if (fileInfo.suffix() == "jpg") { //用看图打开 @@ -420,9 +422,9 @@ void ImageItem::openFile() connect(watcher, &QDBusPendingCallWatcher::finished, this, [watcher, openWithBackup]() { const QDBusMessage retMessage = watcher->reply(); if (retMessage.type() != QDBusMessage::ErrorMessage) { - qDebug() << "Successfully opened image with deepin-image-viewer via DBus"; + qCDebug(appLog) << "Successfully opened image with deepin-image-viewer via DBus"; } else { - qWarning() << "Failed to open image with deepin-image-viewer via DBus:" << retMessage.errorMessage(); + qCWarning(appLog) << "Failed to open image with deepin-image-viewer via DBus:" << retMessage.errorMessage(); openWithBackup(); } watcher->deleteLater(); @@ -436,7 +438,7 @@ void ImageItem::openFile() << "org.deepin.movie" << "--" << "deepin-movie" << m_path; - qDebug() << "[process] Open it with deepin-movie (ll-cli)"; + qCDebug(appLog) << "[process] Open it with deepin-movie (ll-cli)"; ret = myProcess->startDetached(program, arguments); #else QDBusMessage message = QDBusMessage::createMethodCall("com.deepin.movie", "/", "com.deepin.movie", "openFile"); @@ -445,9 +447,9 @@ void ImageItem::openFile() connect(watcher, &QDBusPendingCallWatcher::finished, this, [watcher, openWithBackup]() { const QDBusMessage retMessage = watcher->reply(); if (retMessage.type() != QDBusMessage::ErrorMessage) { - qDebug() << "Successfully opened video with deepin-movie via DBus"; + qCDebug(appLog) << "Successfully opened video with deepin-movie via DBus"; } else { - qWarning() << "Failed to open video with deepin-movie via DBus:" << retMessage.errorMessage(); + qCWarning(appLog) << "Failed to open video with deepin-movie via DBus:" << retMessage.errorMessage(); openWithBackup(); } watcher->deleteLater(); @@ -463,12 +465,12 @@ void ImageItem::openFile() if (CamApp->isPanelEnvironment()) CamApp->getMainWindow()->showMinimized(); - qDebug() << "Function completed: openFile"; + qCDebug(appLog) << "Function completed: openFile"; } void ImageItem::onCopy() { - qDebug() << "Function started: onCopy"; + qCDebug(appLog) << "Function started: onCopy"; QStringList paths; paths << m_path; @@ -493,38 +495,38 @@ void ImageItem::onCopy() newMimeData->setData("x-special/gnome-copied-files", gnomeFormat); cb->setMimeData(newMimeData, QClipboard::Clipboard); - qDebug() << "Function completed: onCopy"; + qCDebug(appLog) << "Function completed: onCopy"; } void ImageItem::onShortcutDel() { - qDebug() << "Delete shortcut triggered"; + qCDebug(appLog) << "Delete shortcut triggered"; //改用datetime,避免跨天之后判断错误 QDateTime timeNow = QDateTime::currentDateTime(); if (m_lastDelTime.msecsTo(timeNow) < 100) { - qWarning() << "Delete operation too frequent, ignoring"; + qCWarning(appLog) << "Delete operation too frequent, ignoring"; return; } m_lastDelTime = timeNow; emit trashFile(m_path); - qDebug() << "Function completed: onShortcutDel"; + qCDebug(appLog) << "Function completed: onShortcutDel"; } void ImageItem::onPrint() { - qDebug() << "Function started: onPrint"; + qCDebug(appLog) << "Function started: onPrint"; if (!m_bVideo) { - qDebug() << "ImageItem::onPrint: Enter if branch (not video, showing print dialog)"; + qCDebug(appLog) << "ImageItem::onPrint: Enter if branch (not video, showing print dialog)"; showPrintDialog(QStringList(m_path), this); } - qDebug() << "Function completed: onPrint"; + qCDebug(appLog) << "Function completed: onPrint"; } void ImageItem::showPrintDialog(const QStringList &paths, QWidget *parent) { - qDebug() << "Opening print dialog for" << paths.size() << "files"; + qCDebug(appLog) << "Opening print dialog for" << paths.size() << "files"; m_imgs.clear(); QStringList tempExistPaths; @@ -558,11 +560,11 @@ void ImageItem::showPrintDialog(const QStringList &paths, QWidget *parent) // 连接打印信号 if (useNewAPI && printDialog.setAsynPreview(m_imgs.size())) { - qDebug() << "Using async preview for printing"; + qCDebug(appLog) << "Using async preview for printing"; connect(&printDialog, SIGNAL(paintRequested(DPrinter *, const QVector &)), this, SLOT(paintRequestedAsyn(DPrinter *, const QVector &))); } else { - qDebug() << "Using sync preview for printing"; + qCDebug(appLog) << "Using sync preview for printing"; connect(&printDialog, SIGNAL(paintRequested(DPrinter *)), this, SLOT(paintRequestSync(DPrinter *))); } @@ -572,7 +574,7 @@ void ImageItem::showPrintDialog(const QStringList &paths, QWidget *parent) #else printDialog.show(); #endif - qDebug() << "Function completed: showPrintDialog"; + qCDebug(appLog) << "Function completed: showPrintDialog"; } // 公共绘图方法 diff --git a/src/src/logconfigread.cpp b/src/src/logconfigread.cpp index bdfaf334..9b260a8e 100644 --- a/src/src/logconfigread.cpp +++ b/src/src/logconfigread.cpp @@ -21,18 +21,19 @@ MLogger::MLogger(QObject *parent) // 保存环境变量中的规则 m_rules = logRules; // 从 DConfig 读取日志规则 - m_config = DConfig::create("org.deepin.camera", "org.deepin.camera.encode"); + m_config = DConfig::create("org.deepin.camera", "org.deepin.camera"); if (m_config && m_config->isValid()) { - logRules = m_config->value("rules").toByteArray(); + logRules = m_config->value("log_rules").toByteArray(); appendRules(logRules); - setRules(m_rules); // 监听 DConfig 变化,动态更新日志规则 connect(m_config, &DConfig::valueChanged, this, [this](const QString &key) { - if (key == "rules") { + if (key == "log_rules") { setRules(m_config->value(key).toByteArray()); } }); } + // DConfig 不可用时兜底:环境变量中的规则仍然生效 + setRules(m_rules); } MLogger::~MLogger() { diff --git a/src/src/mainwindow.cpp b/src/src/mainwindow.cpp index 95631a8d..0366c9e3 100755 --- a/src/src/mainwindow.cpp +++ b/src/src/mainwindow.cpp @@ -3,6 +3,8 @@ // // SPDX-License-Identifier: GPL-3.0-or-later +#include "ddlog.h" +using namespace DDLog; extern "C" { #include "v4l2_formats.h" } @@ -383,7 +385,7 @@ static QWidget *createPicSelectableLineEditOptionHandle(QObject *opt) } QString qlastPath = Settings::get().getOption("base.save.picdatapath").toString(); - qDebug() << QString("-----------------qlastPath: %1").arg(qlastPath); + qCDebug(appLog) << QString("-----------------qlastPath: %1").arg(qlastPath); QFileInfo fm(selectPicSavePath); @@ -445,10 +447,10 @@ static QWidget *createPicSelectableLineEditOptionHandle(QObject *opt) auto pi = ElideText(value.toString(), { pathEditWidth, tem_fontmetrics.height() }, QTextOption::WrapAnywhere, picPathLineEdit->font(), Qt::ElideMiddle, tem_fontmetrics.height(), pathEditWidth); picPathLineEdit->setText(pi); - qDebug() << "picPathLineEdit text:" << picPathLineEdit->text(); + qCDebug(appLog) << "picPathLineEdit text:" << picPathLineEdit->text(); lastPicPath = value.toString(); option->setValue(value.toString()); - qDebug() << "save pic last path:" << value.toString(); + qCDebug(appLog) << "save pic last path:" << value.toString(); picPathLineEdit->update(); }); @@ -715,10 +717,10 @@ static QWidget *createVdSelectableLineEditOptionHandle(QObject *opt) QTextOption::WrapAnywhere, videoPathLineEdit->font(), Qt::ElideMiddle, tem_fontmetrics.height(), pathEditWidth); videoPathLineEdit->setText(pi); - qDebug() << "picPathLineEdit text:" << videoPathLineEdit->text(); + qCDebug(appLog) << "picPathLineEdit text:" << videoPathLineEdit->text(); lastVideoPath = value.toString(); option->setValue(value.toString()); - qDebug() << "save video last path:" << value.toString(); + qCDebug(appLog) << "save video last path:" << value.toString(); videoPathLineEdit->update(); }); @@ -762,9 +764,9 @@ QString CMainWindow::lastOpenedPath(QStandardPaths::StandardLocation standard) QDir dirNew(lastPath); if (!dirNew.exists()) { if (!dirNew.mkdir(lastPath)) { - qWarning() << "make dir error:" << lastPath; + qCWarning(appLog) << "make dir error:" << lastPath; lastPath = QDir::currentPath(); //这是错误的路径,但肯定存在 - qDebug() << "now lastVdPath is:" << lastPath; + qCDebug(appLog) << "now lastVdPath is:" << lastPath; } } } @@ -791,7 +793,7 @@ CMainWindow::CMainWindow(QWidget *parent) m_bUIinit(false), m_windowStateThread(nullptr) { - qDebug() << "Function started: CMainWindow constructor"; + qCDebug(appLog) << "Function started: CMainWindow constructor"; m_cameraSwitchBtn = nullptr; m_photoRecordBtn = nullptr; m_modeSwitchBox = nullptr; @@ -816,18 +818,18 @@ CMainWindow::CMainWindow(QWidget *parent) //修复在性能较差的电脑上启动闪烁白框 initUI(); - qDebug() << "Function completed: CMainWindow constructor"; + qCDebug(appLog) << "Function completed: CMainWindow constructor"; } void CMainWindow::slotPopupSettingsDialog() { - qDebug() << "Function started: slotPopupSettingsDialog"; + qCDebug(appLog) << "Function started: slotPopupSettingsDialog"; #ifndef UNITTEST settingDialog(); m_SetDialog->exec(); settingDialogDel(); #endif - qDebug() << "Function completed: slotPopupSettingsDialog"; + qCDebug(appLog) << "Function completed: slotPopupSettingsDialog"; } QString CMainWindow::libPath(const QString &strlib) @@ -878,9 +880,9 @@ void CMainWindow::reflushSnapshotLabel() void CMainWindow::getMediaFileInfoList(const QString &path, QFileInfoList &fileList) { - qDebug() << "Function started: getMediaFileInfoList"; + qCDebug(appLog) << "Function started: getMediaFileInfoList"; if (path.isEmpty()) { - qDebug() << "path is empty, return."; + qCDebug(appLog) << "path is empty, return."; return; } @@ -890,15 +892,15 @@ void CMainWindow::getMediaFileInfoList(const QString &path, QFileInfoList &fileL dir.setNameFilters(filters); dir.setSorting(QDir::Time /*| QDir::Reversed*/); //按时间逆序排序 if (dir.exists()) { - qDebug() << "dir exists, get file list."; + qCDebug(appLog) << "dir exists, get file list."; fileList = dir.entryInfoList(); } - qDebug() << "Function completed: getMediaFileInfoList"; + qCDebug(appLog) << "Function completed: getMediaFileInfoList"; } void CMainWindow::initDynamicLibPath() { - qDebug() << "Function started: initDynamicLibPath"; + qCDebug(appLog) << "Function started: initDynamicLibPath"; LoadLibNames tmp; QByteArray avcodec = libPath("libavcodec.so").toLatin1(); tmp.chAvcodec = avcodec.data(); @@ -921,14 +923,14 @@ void CMainWindow::initDynamicLibPath() QByteArray swresample = libPath("libswresample.so").toLatin1(); tmp.chSwresample = swresample.data(); setLibNames(tmp); - qDebug() << "Function completed: initDynamicLibPath"; + qCDebug(appLog) << "Function completed: initDynamicLibPath"; } void CMainWindow::initBlockShutdown() { - qDebug() << "Function started: initBlockShutdown"; + qCDebug(appLog) << "Function started: initBlockShutdown"; if (!m_arg.isEmpty() || m_reply.value().isValid()) { - qInfo() << "m_reply.value().isValid():" << m_reply.value().isValid(); + qCInfo(appLog) << "m_reply.value().isValid():" << m_reply.value().isValid(); return; } @@ -951,16 +953,16 @@ void CMainWindow::initBlockShutdown() if (m_reply.isValid()) { QDBusReply tmp = m_reply; m_reply = QDBusReply(); - qDebug() << "init Unblock shutdown."; + qCDebug(appLog) << "init Unblock shutdown."; } - qDebug() << "Function completed: initBlockShutdown"; + qCDebug(appLog) << "Function completed: initBlockShutdown"; } void CMainWindow::initBlockSleep() { - qDebug() << "Function started: initBlockSleep"; + qCDebug(appLog) << "Function started: initBlockSleep"; if (!m_argSleep.isEmpty() || m_replySleep.value().isValid()) { - qInfo() << "m_reply.value().isValid():" << m_replySleep.value().isValid(); + qCInfo(appLog) << "m_reply.value().isValid():" << m_replySleep.value().isValid(); return; } @@ -983,14 +985,14 @@ void CMainWindow::initBlockSleep() if (m_replySleep.isValid()) { QDBusReply tmp = m_replySleep; m_replySleep = QDBusReply(); - qDebug() << "init Unblock sleep."; + qCDebug(appLog) << "init Unblock sleep."; } - qDebug() << "Function completed: initBlockSleep"; + qCDebug(appLog) << "Function completed: initBlockSleep"; } void CMainWindow::initTabOrder() { - qDebug() << "Function started: initTabOrder"; + qCDebug(appLog) << "Function started: initTabOrder"; m_windowMinBtn = m_pTitlebar->titlebar()->findChild("DTitlebarDWindowMinButton"); m_windowoptionButton = m_pTitlebar->titlebar()->findChild("DTitlebarDWindowOptionButton"); m_windowMaxBtn = m_pTitlebar->titlebar()->findChild("DTitlebarDWindowMaxButton"); @@ -1006,12 +1008,12 @@ void CMainWindow::initTabOrder() setTabOrder(m_windowMinBtn, m_windowMaxBtn); setTabOrder(m_windowMaxBtn, m_windowCloseBtn); setTabOrder(m_windowCloseBtn, m_takePhotoSettingArea); - qDebug() << "Function completed: initTabOrder"; + qCDebug(appLog) << "Function completed: initTabOrder"; } void CMainWindow::initEventFilter() { - qDebug() << "Function started: initEventFilter"; + qCDebug(appLog) << "Function started: initEventFilter"; /** * @brief windowMinBtn 最小化按钮 */ @@ -1049,12 +1051,12 @@ void CMainWindow::initEventFilter() if (m_videoPre) m_videoPre->installEventFilter(this); - qDebug() << "Function completed: initEventFilter"; + qCDebug(appLog) << "Function completed: initEventFilter"; } void CMainWindow::initShortcut() { - qDebug() << "Function started: initShortcut"; + qCDebug(appLog) << "Function started: initShortcut"; QShortcutEx *scViewShortcut = new QShortcutEx(QKeySequence("Ctrl+Shift+/"), this); QShortcutEx *scSpaceShortcut = new QShortcutEx(Qt::Key_Space, this); QShortcutEx *scEnterShortcut = new QShortcutEx(Qt::Key_Return, this); @@ -1072,7 +1074,7 @@ void CMainWindow::initShortcut() scSpaceShortcut->setObjectName(SHORTCUT_SPACE); connect(scViewShortcut, &QShortcut::activated, this, [=] { - qDebug() << "receive Ctrl+Shift+/"; + qCDebug(appLog) << "receive Ctrl+Shift+/"; QRect rect = window()->geometry(); QPoint pos(rect.x() + rect.width() / 2, rect.y() + rect.height() / 2); Shortcut sc; @@ -1128,12 +1130,12 @@ void CMainWindow::initShortcut() else return; }); - qDebug() << "Function completed: initShortcut"; + qCDebug(appLog) << "Function completed: initShortcut"; } void CMainWindow::settingDialog() { - qDebug() << "Function started: settingDialog"; + qCDebug(appLog) << "Function started: settingDialog"; m_SetDialog = new DSettingsDialog(this); m_SetDialog->setFixedSize(820, 600); m_SetDialog->widgetFactory()->registerWidget("selectableEditpic", createPicSelectableLineEditOptionHandle); @@ -1254,7 +1256,7 @@ void CMainWindow::settingDialog() QPushButton *resetbtn = m_SetDialog->findChild("SettingsContentReset"); resetbtn->setDefault(false); resetbtn->setAutoDefault(false); - qDebug() << "Function completed: settingDialog"; + qCDebug(appLog) << "Function completed: settingDialog"; } void CMainWindow::settingDialogDel() @@ -1270,7 +1272,7 @@ void CMainWindow::settingDialogDel() void CMainWindow::loadAfterShow() { - qDebug() << "Function started: loadAfterShow"; + qCDebug(appLog) << "Function started: loadAfterShow"; encodeenv = DataManager::instance()->encodeEnv(); initDynamicLibPath(); initShortcut(); @@ -1325,12 +1327,12 @@ void CMainWindow::loadAfterShow() {"camera_connected", DataManager::instance()->getdevStatus() ? true : false} }; EventLogUtils::get().writeLogs(obj); - qDebug() << "Function completed: loadAfterShow"; + qCDebug(appLog) << "Function completed: loadAfterShow"; } void CMainWindow::updateBlockSystem(bool bTrue) { - qDebug() << "Function started: updateBlockSystem"; + qCDebug(appLog) << "Function started: updateBlockSystem"; if (!CamApp->isPanelEnvironment()) { // qDebug() << "Condition check: !CamApp->isPanelEnvironment(), initBlockShutdown"; initBlockShutdown(); @@ -1340,7 +1342,7 @@ void CMainWindow::updateBlockSystem(bool bTrue) } else { QDBusReply tmp = m_reply; m_reply = QDBusReply(); - qDebug() << "Unblock shutdown."; + qCDebug(appLog) << "Unblock shutdown."; } } if (m_bWayland) { @@ -1352,25 +1354,25 @@ void CMainWindow::updateBlockSystem(bool bTrue) } else { QDBusReply tmp = m_replySleep; m_replySleep = QDBusReply(); - qDebug() << "Unblock sleep."; + qCDebug(appLog) << "Unblock sleep."; } } - qDebug() << "Function completed: updateBlockSystem"; + qCDebug(appLog) << "Function completed: updateBlockSystem"; } void CMainWindow::onNoCam() { - qDebug() << "Function started: onNoCam"; + qCDebug(appLog) << "Function started: onNoCam"; m_pTitlebar->titlebar()->setBackgroundTransparent(false); m_pTitlebar->slotThemeTypeChanged(); showChildWidget(); onEnableSettings(true); - qDebug() << "Function completed: onNoCam"; + qCDebug(appLog) << "Function completed: onNoCam"; } void CMainWindow::stopCancelContinuousRecording(bool bTrue) { - qDebug() << "Function started: stopCancelContinuousRecording"; + qCDebug(appLog) << "Function started: stopCancelContinuousRecording"; if (bTrue) { onStopPhotoAndRecord(); } @@ -1378,7 +1380,7 @@ void CMainWindow::stopCancelContinuousRecording(bool bTrue) void CMainWindow::onDirectoryChanged(const QString &filePath) { - qDebug() << "Function started: onDirectoryChanged"; + qCDebug(appLog) << "Function started: onDirectoryChanged"; Q_UNUSED(filePath); // 转为绝对路径进行比较 QString relativeHomePath = QString("~") + QDir::separator(); @@ -1390,7 +1392,7 @@ void CMainWindow::onDirectoryChanged(const QString &filePath) picPath.replace(0, 1, QDir::homePath()); QDir dir(videoPath); if (!dir.exists()) { - qInfo() << "Video directory does not exist, creating default path"; + qCInfo(appLog) << "Video directory does not exist, creating default path"; QString videoDefaultPath = lastOpenedPath(QStandardPaths::MoviesLocation); if (videoDefaultPath != videoPath) { QDir setVideoDir(videoDefaultPath); @@ -1420,7 +1422,7 @@ void CMainWindow::onDirectoryChanged(const QString &filePath) dir = QDir(picPath); if (!dir.exists()) { - qInfo() << "Picture directory does not exist, creating default path"; + qCInfo(appLog) << "Picture directory does not exist, creating default path"; QString picDefaultPath = lastOpenedPath(QStandardPaths::PicturesLocation); if (picDefaultPath != picPath) { QDir setPicDir(picDefaultPath); @@ -1449,12 +1451,12 @@ void CMainWindow::onDirectoryChanged(const QString &filePath) } reflushSnapshotLabel(); - qDebug() << "Function completed: onDirectoryChanged"; + qCDebug(appLog) << "Function completed: onDirectoryChanged"; } void CMainWindow::onSwitchCameraSuccess(const QString &cameraName) { - qDebug() << "Function started: onSwitchCameraSuccess"; + qCDebug(appLog) << "Function started: onSwitchCameraSuccess"; QStringList tmpList = cameraName.split(":"); if (!tmpList.isEmpty()) { m_labelCameraName->setText(tmpList[0]); @@ -1469,12 +1471,12 @@ void CMainWindow::onSwitchCameraSuccess(const QString &cameraName) m_filterName->hide(); m_showCameraNameTimer->start(); showChildWidget(); - qDebug() << "Function completed: onSwitchCameraSuccess"; + qCDebug(appLog) << "Function completed: onSwitchCameraSuccess"; } void CMainWindow::onTimeoutLock(const QString &serviceName, QVariantMap key2value, QStringList) { - qDebug() << serviceName << key2value; + qCDebug(appLog) << serviceName << key2value; //仅wayland需要锁屏结束录制并停止使用摄像头,从锁屏恢复重新开启摄像头 //wayland下只需要停止录像,不需要停止线程,需要在锁屏状态下继续处理摄像头状态 // if (m_bWayland) { @@ -1502,64 +1504,64 @@ void CMainWindow::onTimeoutLock(const QString &serviceName, QVariantMap key2valu // } // 锁屏时,停用摄像头,因为用户可能需要人脸解锁。解锁后,恢复使用摄像头。 m_videoPre->onLockedScreen(key2value.value("Locked").value()); - qDebug() << "Function completed: onTimeoutLock"; + qCDebug(appLog) << "Function completed: onTimeoutLock"; } void CMainWindow::onTrashFile(const QString &fileName) { - qDebug() << "Deleting file:" << fileName; + qCDebug(appLog) << "Deleting file:" << fileName; QFile file(fileName); if (!file.exists()) { - qWarning() << "File does not exist:" << fileName; + qCWarning(appLog) << "File does not exist:" << fileName; return; } if (!file.remove()) { - qWarning() << "Failed to delete file:" << fileName; + qCWarning(appLog) << "Failed to delete file:" << fileName; } //删除文件后,filewatcher会自动刷新缩略图 } void CMainWindow::onSwitchPhotoBtnClked() { - qDebug() << "Function started: onSwitchPhotoBtnClked"; + qCDebug(appLog) << "Function started: onSwitchPhotoBtnClked"; m_photoRecordBtn->setState(true); m_photoRecordBtn->setToolTip(tr("Photo")); m_takePhotoSettingArea->setState(true); m_videoPre->setState(true); locateRightButtons(); - qDebug() << "Function completed: onSwitchPhotoBtnClked"; + qCDebug(appLog) << "Function completed: onSwitchPhotoBtnClked"; } void CMainWindow::onSwitchRecordBtnClked() { - qDebug() << "Function started: onSwitchRecordBtnClked"; + qCDebug(appLog) << "Function started: onSwitchRecordBtnClked"; m_photoRecordBtn->setState(false); m_photoRecordBtn->setToolTip(tr("Video")); m_takePhotoSettingArea->setState(false); m_videoPre->setState(false); locateRightButtons(); - qDebug() << "Function completed: onSwitchRecordBtnClked"; + qCDebug(appLog) << "Function completed: onSwitchRecordBtnClked"; } void CMainWindow::onModeSwitchBoxValueChanged(int type) { - qDebug() << "Function started: onModeSwitchBoxValueChanged"; + qCDebug(appLog) << "Function started: onModeSwitchBoxValueChanged"; if (type == ActType::ActTakePic) { - qDebug() << "type is ActType::ActTakePic, onSwitchPhotoBtnClked"; + qCDebug(appLog) << "type is ActType::ActTakePic, onSwitchPhotoBtnClked"; onSwitchPhotoBtnClked(); } else if (type == ActType::ActTakeVideo) { - qDebug() << "type is ActType::ActTakeVideo, onSwitchRecordBtnClked"; + qCDebug(appLog) << "type is ActType::ActTakeVideo, onSwitchRecordBtnClked"; onSwitchRecordBtnClked(); } else { - qDebug() << "type is not ActType::ActTakePic or ActType::ActTakeVideo, return."; + qCDebug(appLog) << "type is not ActType::ActTakePic or ActType::ActTakeVideo, return."; return; } - qDebug() << "Function completed: onModeSwitchBoxValueChanged"; + qCDebug(appLog) << "Function completed: onModeSwitchBoxValueChanged"; } void CMainWindow::onPhotoRecordBtnClked() { - qDebug() << "Function started: onPhotoRecordBtnClked"; + qCDebug(appLog) << "Function started: onPhotoRecordBtnClked"; QJsonObject obj { { "tid", m_photoRecordBtn->photoState() ? EventLogUtils::StartPhoto : EventLogUtils::StartRecording }, { "version", VERSION }, @@ -1570,21 +1572,21 @@ void CMainWindow::onPhotoRecordBtnClked() //没有摄像机,不进行任何操作 if (NOCAM == DataManager::instance()->getdevStatus()) { - qWarning() << "No camera available, ignoring photo/record request"; + qCWarning(appLog) << "No camera available, ignoring photo/record request"; return; } //拍照模式下 if (true == m_photoRecordBtn->photoState()) { - qDebug() << "Photo mode activated"; + qCDebug(appLog) << "Photo mode activated"; //正在拍照 if (photoNormal != m_photoState) { - qDebug() << "Taking photo"; + qCDebug(appLog) << "Taking photo"; m_videoPre->onTakePic(false); } else { int nContinuous = Settings::get().getOption("photosetting.photosnumber.takephotos").toInt(); if (nContinuous > 1) { - qInfo() << "Starting continuous photo mode with" << nContinuous << "shots"; + qCInfo(appLog) << "Starting continuous photo mode with" << nContinuous << "shots"; // 仅在连拍模式下才开启窗口状态监听线程 if (!m_windowStateThread->isRunning() && !m_bWayland) { m_windowStateThread->start(); @@ -1594,38 +1596,38 @@ void CMainWindow::onPhotoRecordBtnClked() } } else { //录像模式下 if (true == m_bRecording) { - qDebug() << "Stopping video recording"; + qCDebug(appLog) << "Stopping video recording"; m_videoPre->onEndBtnClicked(); } else { QFileInfo fi(m_videoPath); if (!fi.isWritable()) { - qWarning() << "Video save path is not writable:" << m_videoPath; + qCWarning(appLog) << "Video save path is not writable:" << m_videoPath; return; } - qDebug() << "Starting video recording"; + qCDebug(appLog) << "Starting video recording"; m_videoPre->onTakeVideo(); if (!m_windowStateThread->isRunning() && !m_bWayland) { m_windowStateThread->start(); } } } - qDebug() << "Function completed: onPhotoRecordBtnClked"; + qCDebug(appLog) << "Function completed: onPhotoRecordBtnClked"; } void CMainWindow::onShowCameraNameTimer() { - qDebug() << "Function started: onShowCameraNameTimer"; + qCDebug(appLog) << "Function started: onShowCameraNameTimer"; m_showCameraNameTimer->stop(); m_labelCameraName->hide(); if (m_bShowFilterName) m_filterName->show(); - qDebug() << "Function completed: onShowCameraNameTimer"; + qCDebug(appLog) << "Function completed: onShowCameraNameTimer"; } void CMainWindow::onUpdateRecordState(int state) { - qDebug() << "Recording state changed to:" << state; + qCDebug(appLog) << "Recording state changed to:" << state; m_photoRecordBtn->setRecordState(state); m_bRecording = (photoRecordBtn::Normal != state); m_actionSettings->setEnabled(!m_bRecording); @@ -1634,12 +1636,12 @@ void CMainWindow::onUpdateRecordState(int state) && m_windowStateThread->isRunning() && !m_bWayland) { m_windowStateThread->requestInterruption(); } - qDebug() << "Function completed: onUpdateRecordState"; + qCDebug(appLog) << "Function completed: onUpdateRecordState"; } void CMainWindow::onUpdatePhotoState(int state) { - qDebug() << "Photo state changed to:" << state; + qCDebug(appLog) << "Photo state changed to:" << state; m_actionSettings->setEnabled(photoNormal == state); m_photoState = state; showChildWidget(); @@ -1651,7 +1653,7 @@ void CMainWindow::onUpdatePhotoState(int state) void CMainWindow::onStopPhotoAndRecord() { - qDebug() << "Stopping all photo and recording operations"; + qCDebug(appLog) << "Stopping all photo and recording operations"; if (photoNormal != m_photoState) { m_videoPre->onTakePic(false); } @@ -1662,17 +1664,17 @@ void CMainWindow::onStopPhotoAndRecord() void CMainWindow::onMirrorStateChanged(bool bMirror) { - qDebug() << "Function started: onMirrorStateChanged"; + qCDebug(appLog) << "Function started: onMirrorStateChanged"; if (m_videoPre) { - qDebug() << "Setting horizontal mirror to:" << bMirror; + qCDebug(appLog) << "Setting horizontal mirror to:" << bMirror; m_videoPre->setHorizontalMirror(bMirror); } - qDebug() << "Function completed: onMirrorStateChanged"; + qCDebug(appLog) << "Function completed: onMirrorStateChanged"; } void CMainWindow::onSetFlash(bool bFlashOn) { - qDebug() << "Function started: onSetFlash"; + qCDebug(appLog) << "Function started: onSetFlash"; if (m_videoPre) { m_videoPre->setFlash(bFlashOn); } @@ -1682,79 +1684,79 @@ void CMainWindow::onSetFlash(bool bFlashOn) if (bFlashOn != m_takePhotoSettingArea->flashLight()) { m_takePhotoSettingArea->setFlashlight(bFlashOn); } - qDebug() << "Function completed: onSetFlash"; + qCDebug(appLog) << "Function completed: onSetFlash"; } void CMainWindow::onKeyUp() { - qDebug() << "Function started: onKeyUp"; + qCDebug(appLog) << "Function started: onKeyUp"; QWidget *pWidget = focusWidget(); if (m_cameraSwitchBtn == pWidget || m_takePhotoSettingArea == pWidget) { - qDebug() << "m_cameraSwitchBtn == pWidget or m_takePhotoSettingArea == pWidget, set focus to m_windowoptionButton"; + qCDebug(appLog) << "m_cameraSwitchBtn == pWidget or m_takePhotoSettingArea == pWidget, set focus to m_windowoptionButton"; m_windowoptionButton->setFocus(); } else if (m_photoRecordBtn == pWidget) { if (m_cameraSwitchBtn->isHidden()) { - qDebug() << "m_cameraSwitchBtn->isHidden(), set focus to m_windowoptionButton"; + qCDebug(appLog) << "m_cameraSwitchBtn->isHidden(), set focus to m_windowoptionButton"; m_windowoptionButton->setFocus(); } else { - qDebug() << "m_cameraSwitchBtn->isHidden() is false, set focus to m_cameraSwitchBtn"; + qCDebug(appLog) << "m_cameraSwitchBtn->isHidden() is false, set focus to m_cameraSwitchBtn"; m_cameraSwitchBtn->setFocus(); } } - qDebug() << "Function completed: onKeyUp"; + qCDebug(appLog) << "Function completed: onKeyUp"; } void CMainWindow::onKeyDown() { - qDebug() << "Function started: onKeyDown"; + qCDebug(appLog) << "Function started: onKeyDown"; QWidget *pWidget = focusWidget(); if (m_windowMinBtn == pWidget || m_windowoptionButton == pWidget || m_windowMaxBtn == pWidget || m_windowCloseBtn == pWidget) { if (m_cameraSwitchBtn->isHidden()) { - qDebug() << "m_cameraSwitchBtn->isHidden(), set focus to m_photoRecordBtn"; + qCDebug(appLog) << "m_cameraSwitchBtn->isHidden(), set focus to m_photoRecordBtn"; m_photoRecordBtn->setFocus(); } else { - qDebug() << "m_cameraSwitchBtn->isHidden() is false, set focus to m_cameraSwitchBtn"; + qCDebug(appLog) << "m_cameraSwitchBtn->isHidden() is false, set focus to m_cameraSwitchBtn"; m_cameraSwitchBtn->setFocus(); } } else if (m_cameraSwitchBtn == pWidget) { - qDebug() << "m_cameraSwitchBtn == pWidget, set focus to m_photoRecordBtn"; + qCDebug(appLog) << "m_cameraSwitchBtn == pWidget, set focus to m_photoRecordBtn"; m_photoRecordBtn->setFocus(); } else if (m_photoRecordBtn == pWidget) { - qDebug() << "m_photoRecordBtn == pWidget, set focus to m_snapshotLabel"; + qCDebug(appLog) << "m_photoRecordBtn == pWidget, set focus to m_snapshotLabel"; m_snapshotLabel->setFocus(); } - qDebug() << "Function completed: onKeyDown"; + qCDebug(appLog) << "Function completed: onKeyDown"; } void CMainWindow::onKeyLeft() { - qDebug() << "Function started: onKeyLeft"; + qCDebug(appLog) << "Function started: onKeyLeft"; QWidget *pWidget = focusWidget(); if (m_cameraSwitchBtn == pWidget || m_photoRecordBtn == pWidget || m_snapshotLabel == pWidget) { - qDebug() << "m_cameraSwitchBtn == pWidget or m_photoRecordBtn == pWidget or m_snapshotLabel == pWidget, set focus to m_takePhotoSettingArea"; + qCDebug(appLog) << "m_cameraSwitchBtn == pWidget or m_photoRecordBtn == pWidget or m_snapshotLabel == pWidget, set focus to m_takePhotoSettingArea"; m_takePhotoSettingArea->setFocus(); } else if (m_windowCloseBtn == pWidget) { - qDebug() << "m_windowCloseBtn == pWidget, set focus to m_windowMaxBtn"; + qCDebug(appLog) << "m_windowCloseBtn == pWidget, set focus to m_windowMaxBtn"; m_windowMaxBtn->setFocus(); } else if (m_windowMaxBtn == pWidget) { - qDebug() << "m_windowMaxBtn == pWidget, set focus to m_windowMinBtn"; + qCDebug(appLog) << "m_windowMaxBtn == pWidget, set focus to m_windowMinBtn"; m_windowMinBtn->setFocus(); } else if (m_windowMinBtn == pWidget) { - qDebug() << "m_windowMinBtn == pWidget, set focus to m_windowoptionButton"; + qCDebug(appLog) << "m_windowMinBtn == pWidget, set focus to m_windowoptionButton"; m_windowoptionButton->setFocus(); } - qDebug() << "Function completed: onKeyLeft"; + qCDebug(appLog) << "Function completed: onKeyLeft"; } void CMainWindow::onkeyRight() { - qDebug() << "Function started: onkeyRight"; + qCDebug(appLog) << "Function started: onkeyRight"; QWidget *pWidget = focusWidget(); if (m_windowoptionButton == pWidget) { m_windowMinBtn->setFocus(); @@ -1764,42 +1766,42 @@ void CMainWindow::onkeyRight() m_windowCloseBtn->setFocus(); } else if (m_takePhotoSettingArea == pWidget) { if (m_cameraSwitchBtn->isHidden()) { - qDebug() << "m_cameraSwitchBtn->isHidden(), set focus to m_photoRecordBtn"; + qCDebug(appLog) << "m_cameraSwitchBtn->isHidden(), set focus to m_photoRecordBtn"; m_photoRecordBtn->setFocus(); } else { - qDebug() << "m_cameraSwitchBtn->isHidden() is false, set focus to m_cameraSwitchBtn"; + qCDebug(appLog) << "m_cameraSwitchBtn->isHidden() is false, set focus to m_cameraSwitchBtn"; m_cameraSwitchBtn->setFocus(); } } - qDebug() << "Function completed: onkeyRight"; + qCDebug(appLog) << "Function completed: onkeyRight"; } void CMainWindow::onFilterChanged(efilterType type) { - qDebug() << "Function started: onFilterChanged"; + qCDebug(appLog) << "Function started: onFilterChanged"; if (m_videoPre) { m_videoPre->setFilterType(type); } - qDebug() << "Function completed: onFilterChanged"; + qCDebug(appLog) << "Function completed: onFilterChanged"; } void CMainWindow::onShowFilterName(bool bShow) { - qDebug() << "Function started: onShowFilterName"; + qCDebug(appLog) << "Function started: onShowFilterName"; m_filterName->setVisible(bShow); m_bShowFilterName = bShow; - qDebug() << "Function completed: onShowFilterName"; + qCDebug(appLog) << "Function completed: onShowFilterName"; } void CMainWindow::onSetFilterName(const QString &name) { - qDebug() << "Function started: onSetFilterName"; + qCDebug(appLog) << "Function started: onSetFilterName"; m_filterName->setText(name); } void CMainWindow::initUI() { - qDebug() << "Initializing main window UI"; + qCDebug(appLog) << "Initializing main window UI"; m_videoPre = new videowidget(this); QPalette paletteTime = m_videoPre->palette(); m_videoPre->setObjectName(VIDEO_PREVIEW_WIDGET); @@ -1966,7 +1968,7 @@ void CMainWindow::initUI() #endif m_bUIinit = true; - qDebug() << "Main window UI initialization completed"; + qCDebug(appLog) << "Main window UI initialization completed"; } void CMainWindow::updateSizeMode() @@ -1993,24 +1995,24 @@ void CMainWindow::updateSizeMode() g_videospace->changeSize(0, 0); #endif } - qDebug() << "Function completed: updateSizeMode"; + qCDebug(appLog) << "Function completed: updateSizeMode"; } void CMainWindow::initTitleBar() { - qDebug() << "Function started: initTitleBar"; + qCDebug(appLog) << "Function started: initTitleBar"; m_pTitlebar->titlebar()->setIcon(QIcon::fromTheme("deepin-camera")); m_pTitlebar->raise(); m_pTitlebar->titlebar()->raise(); - qDebug() << "Function completed: initTitleBar"; + qCDebug(appLog) << "Function completed: initTitleBar"; } void CMainWindow::initConnection() { - qDebug() << "Initializing main window connections"; + qCDebug(appLog) << "Initializing main window connections"; connect(CamApp, &CApplication::popupConfirmDialog, this, [=] { if (m_videoPre->getCapStatus()) { - qDebug() << "Video recording in progress, showing close confirmation dialog"; + qCDebug(appLog) << "Video recording in progress, showing close confirmation dialog"; CloseDialog closeDlg(this, tr("Video recording is in progress. Close the window?")); #ifdef UNITTEST closeDlg.show(); @@ -2020,14 +2022,14 @@ void CMainWindow::initConnection() int ret = closeDlg.exec(); if (ret == 1) { - qDebug() << "User confirmed closing during recording, stopping recording"; + qCDebug(appLog) << "User confirmed closing during recording, stopping recording"; m_videoPre->onEndBtnClicked(); usleep(200); qApp->quit(); } #endif } else { - qDebug() << "No recording in progress, closing application"; + qCDebug(appLog) << "No recording in progress, closing application"; qApp->quit(); } }); @@ -2092,7 +2094,7 @@ void CMainWindow::initConnection() if (!QDBusConnection::sessionBus().connect(sessionManagerService, sessionManagerPath, "org.freedesktop.DBus.Properties", "PropertiesChanged", this, SLOT(onTimeoutLock(QString, QVariantMap, QStringList)))) { - qWarning() << "Failed to connect to session manager service"; + qCWarning(appLog) << "Failed to connect to session manager service"; } //控制中心更改了本地时间,及时更新当前时间 @@ -2100,7 +2102,7 @@ void CMainWindow::initConnection() if (!QDBusConnection::sessionBus().connect(timedateService, timedatePath, timedateInterface, "TimeUpdate", this, SLOT(onLocalTimeChanged()))) { - qWarning() << "Failed to connect to timedate service"; + qCWarning(appLog) << "Failed to connect to timedate service"; } QDBusConnection::systemBus().connect("org.freedesktop.login1", "/org/freedesktop/login1", @@ -2108,12 +2110,12 @@ void CMainWindow::initConnection() QDBusConnection::systemBus().connect("org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", "PrepareForShutdown", this, SLOT(stopCancelContinuousRecording(bool))); - qDebug() << "Main window connections initialized"; + qCDebug(appLog) << "Main window connections initialized"; } void CMainWindow::initCameraConnection() { - qDebug() << "Function started: initCameraConnection"; + qCDebug(appLog) << "Function started: initCameraConnection"; connect(m_devnumMonitor, &DevNumMonitor::existDevice, Camera::instance(), &Camera::refreshCamera); connect(Camera::instance(), SIGNAL(cameraSwitched(const QString &)), this, SLOT(onSwitchCameraSuccess(const QString &))); // 摄像头重连,刷新设置页分辨率下拉框内容 @@ -2138,12 +2140,12 @@ void CMainWindow::initCameraConnection() DataManager::instance()->setdevStatus(CAM_CANNOT_USE); m_videoPre->showCamUsed(); }); - qDebug() << "Function completed: initCameraConnection"; + qCDebug(appLog) << "Function completed: initCameraConnection"; } void CMainWindow::initRightButtons() { - qDebug() << "Function started: initRightButtons"; + qCDebug(appLog) << "Function started: initRightButtons"; m_cameraSwitchBtn = new SwitchCameraBtn(this); m_cameraSwitchBtn->setFixedSize(SwitchcameraDiam, SwitchcameraDiam); m_cameraSwitchBtn->setObjectName(CAMERA_SWITCH_BTN); @@ -2189,12 +2191,12 @@ void CMainWindow::initRightButtons() //摄像头切换成功信号 connect(m_videoPre, SIGNAL(switchCameraSuccess(const QString &)), this, SLOT(onSwitchCameraSuccess(const QString &))); locateRightButtons(); - qDebug() << "Function completed: initRightButtons"; + qCDebug(appLog) << "Function completed: initRightButtons"; } void CMainWindow::locateRightButtons() { - qDebug() << "Function started: locateRightButtons"; + qCDebug(appLog) << "Function started: locateRightButtons"; if (nullptr == m_photoRecordBtn) { return; } @@ -2217,28 +2219,28 @@ void CMainWindow::locateRightButtons() int snapLabelX = buttonCenterX - snapLabelDiam / 2; int snapLabelY = switchBtnY + switchBtnHeight * 2 + snapLabelOffset; m_snapshotLabel->move(snapLabelX, snapLabelY); - qDebug() << "Function completed: locateRightButtons"; + qCDebug(appLog) << "Function completed: locateRightButtons"; } void CMainWindow::setSelBtnHide() { - qDebug() << "Function started: setSelBtnHide"; + qCDebug(appLog) << "Function started: setSelBtnHide"; m_bSwitchCameraShowEnable = false; if (!m_cameraSwitchBtn->isHidden()) { showChildWidget(); } - qDebug() << "Function completed: setSelBtnHide"; + qCDebug(appLog) << "Function completed: setSelBtnHide"; } void CMainWindow::onLocalTimeChanged() { - qDebug() << "Function started: onLocalTimeChanged"; + qCDebug(appLog) << "Function started: onLocalTimeChanged"; m_SpaceKeyInterval = QDateTime::currentMSecsSinceEpoch(); } void CMainWindow::setSelBtnShow() { - qDebug() << "Function started: setSelBtnShow"; + qCDebug(appLog) << "Function started: setSelBtnShow"; // 有效设备个数小于等于1,不显示切换按钮 if (m_videoPre->getValidDeviceNum() <= 1) { return; @@ -2248,12 +2250,12 @@ void CMainWindow::setSelBtnShow() if (m_cameraSwitchBtn->isHidden()) { showChildWidget(); } - qDebug() << "Function completed: setSelBtnShow"; + qCDebug(appLog) << "Function completed: setSelBtnShow"; } void CMainWindow::setupTitlebar() { - qDebug() << "Function started: setupTitlebar"; + qCDebug(appLog) << "Function started: setupTitlebar"; m_pTitlebar = new Titlebar(this); m_titlemenu = new DMenu(this); m_actionSettings = new QAction(tr("Settings"), this); @@ -2271,7 +2273,7 @@ void CMainWindow::setupTitlebar() m_pTitlebar->move(0, 0); m_pTitlebar->setFixedHeight(50); - qDebug() << "Function completed: setupTitlebar"; + qCDebug(appLog) << "Function completed: setupTitlebar"; } void CMainWindow::resizeEvent(QResizeEvent *event) @@ -2344,14 +2346,14 @@ void CMainWindow::changeEvent(QEvent *event) void CMainWindow::onSettingsDlgClose() { - qDebug() << "Function started: onSettingsDlgClose"; + qCDebug(appLog) << "Function started: onSettingsDlgClose"; bool bPathChanged = false; QString setVideoPath = lastOpenedPath(QStandardPaths::MoviesLocation); QString setPicPath = lastOpenedPath(QStandardPaths::PicturesLocation); //判断图片路径是否改变 if (m_picPath != setPicPath) { //图片路径修改了 - qDebug() << "the picture path is changed"; + qCDebug(appLog) << "the picture path is changed"; QDir setPicDir(setPicPath); QDir lastPicDir(m_picPath); setPicDir.cdUp(); @@ -2373,7 +2375,7 @@ void CMainWindow::onSettingsDlgClose() } if (m_videoPath != setVideoPath) { - qDebug() << "the video path is changed"; + qCDebug(appLog) << "the video path is changed"; QDir setVideoDir(setVideoPath); QDir lastVideoDir(m_videoPath); setVideoDir.cdUp(); @@ -2439,30 +2441,30 @@ void CMainWindow::onSettingsDlgClose() void CMainWindow::onEnableSettings(bool bTrue) { - qDebug() << "Function started: onEnableSettings"; + qCDebug(appLog) << "Function started: onEnableSettings"; m_actionSettings->setEnabled(bTrue); } void CMainWindow::onTakePicDone() { - qDebug() << "Function started: onTakePicOnce"; + qCDebug(appLog) << "Function started: onTakePicOnce"; onEnableSettings(true); } void CMainWindow::onTakePicOnce() { - qDebug() << "onTakePicOnce"; + qCDebug(appLog) << "onTakePicOnce"; } void CMainWindow::onTakePicCancel() { - qDebug() << "Function started: onTakePicCancel"; + qCDebug(appLog) << "Function started: onTakePicCancel"; onEnableSettings(true); } void CMainWindow::onTakeVdDone() { - qDebug() << "Function started: onTakeVdDone"; + qCDebug(appLog) << "Function started: onTakeVdDone"; onEnableSettings(true); QTimer::singleShot(200, this, [=] { @@ -2472,14 +2474,14 @@ void CMainWindow::onTakeVdDone() if (!file.exists()) usleep(200000); }); - qDebug() << "Taking video completed!"; + qCDebug(appLog) << "Taking video completed!"; reflushSnapshotLabel(); - qDebug() << "Function completed: onTakeVdDone"; + qCDebug(appLog) << "Function completed: onTakeVdDone"; } void CMainWindow::onTakeVdCancel() //保存视频完成,通过已有的文件检测实现缩略图恢复,这里不需要额外处理 { - qDebug() << "Function started: onTakeVdCancel"; + qCDebug(appLog) << "Function started: onTakeVdCancel"; onEnableSettings(true); } @@ -2535,10 +2537,10 @@ bool CMainWindow::eventFilter(QObject *obj, QEvent *e) void CMainWindow::showChildWidget() { - qDebug() << "Function started: showChildWidget"; + qCDebug(appLog) << "Function started: showChildWidget"; //正在拍照过程中 if (photoNormal != m_photoState) { - qDebug() << "正在拍照过程中"; + qCDebug(appLog) << "正在拍照过程中"; showWidget(m_cameraSwitchBtn, false); showWidget(m_snapshotLabel, false); showWidget(m_modeSwitchBox, false); @@ -2548,7 +2550,7 @@ void CMainWindow::showChildWidget() return; } if (m_bRecording) { //正在录像 - qDebug() << "正在录像"; + qCDebug(appLog) << "正在录像"; showWidget(m_cameraSwitchBtn, false); showWidget(m_snapshotLabel, false); showWidget(m_modeSwitchBox, false); @@ -2565,14 +2567,14 @@ void CMainWindow::showChildWidget() showWidget(m_photoRecordBtn, true); showWidget(m_takePhotoSettingArea, true); showWidget(m_filterName, m_bShowFilterName); - qDebug() << "Function completed: showChildWidget"; + qCDebug(appLog) << "Function completed: showChildWidget"; } void CMainWindow::showWidget(DWidget *widget, bool bShow) { - qDebug() << "Function started: showWidget"; + qCDebug(appLog) << "Function started: showWidget"; if (widget) { - qDebug() << "widget"; + qCDebug(appLog) << "widget"; if (!bShow) { widget->hide(); } @@ -2581,7 +2583,7 @@ void CMainWindow::showWidget(DWidget *widget, bool bShow) widget->show(); } } - qDebug() << "Function completed: showWidget"; + qCDebug(appLog) << "Function completed: showWidget"; } bool CMainWindow::checkResolutionTooHigh() const @@ -2594,7 +2596,7 @@ bool CMainWindow::checkResolutionTooHigh() const currentHeight = v4l2core_get_frame_height(fd); } bool isTrue = currentWidth > MAX_WIDTH_LIMIT || currentHeight > MAX_HEIGHT_LIMIT; - qInfo() << __func__ << isTrue << currentWidth << "x" << currentHeight; + qCInfo(appLog) << __func__ << isTrue << currentWidth << "x" << currentHeight; return isTrue; } diff --git a/src/src/majorimageprocessingthread.cpp b/src/src/majorimageprocessingthread.cpp index 3ce4b53a..3dd1a920 100644 --- a/src/src/majorimageprocessingthread.cpp +++ b/src/src/majorimageprocessingthread.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. +// Copyright (C) 2020 - 2026 Uniontech Software Technology Co.,Ltd. // SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -6,6 +6,8 @@ #include "majorimageprocessingthread.h" #include "datamanager.h" #include "camera.h" +#include "ddlog.h" +using namespace DDLog; extern "C" { #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -23,7 +25,7 @@ DCORE_USE_NAMESPACE MajorImageProcessingThread::MajorImageProcessingThread():m_bHorizontalMirror(false) { - qDebug() << "Initializing MajorImageProcessingThread"; + qCDebug(appLog) << "Initializing MajorImageProcessingThread"; m_rgbPtr = nullptr; m_bRecording = false; m_nVdWidth = 0; @@ -38,13 +40,13 @@ MajorImageProcessingThread::MajorImageProcessingThread():m_bHorizontalMirror(fal void MajorImageProcessingThread::stop() { - qDebug() << __func__; + qCDebug(appLog) << __func__; m_stopped = 1; } void MajorImageProcessingThread::init() { - qDebug() << "Initializing thread state"; + qCDebug(appLog) << "Initializing thread state"; m_stopped = 0; m_majorindex = -1; m_frame = nullptr; @@ -75,7 +77,7 @@ int MajorImageProcessingThread::getRecCount() void MajorImageProcessingThread::ImageHorizontalMirror(const uint8_t* src, uint8_t* dst, int width, int height) { - qDebug() << "Function started: ImageHorizontalMirror"; + qCDebug(appLog) << "Function started: ImageHorizontalMirror"; /* yu12 y1 y2 y3 y4 y4 y3 y2 y1 @@ -99,18 +101,18 @@ void MajorImageProcessingThread::ImageHorizontalMirror(const uint8_t* src, uint8 uvLineStartIndex += width; } } - qDebug() << "Function completed: ImageHorizontalMirror"; + qCDebug(appLog) << "Function completed: ImageHorizontalMirror"; } void MajorImageProcessingThread::processingImage(QImage& img) { - qDebug() << "Processing image, size:" << img.size() << "format:" << img.format(); + qCDebug(appLog) << "Processing image, size:" << img.size() << "format:" << img.format(); // 镜像 if (!m_bHorizontalMirror) img = img.mirrored(true,false); if (m_bPhoto) { - qDebug() << "Processing image in photo mode"; + qCDebug(appLog) << "Processing image in photo mode"; img = img.convertToFormat(QImage::Format_RGB888); // 滤镜预览 @@ -118,7 +120,7 @@ void MajorImageProcessingThread::processingImage(QImage& img) emit SendFilterImageProcessing(&m_filterImg); if (!m_filter.isEmpty() || m_exposure) { - qDebug() << "Applying filter:" << m_filter << "and exposure:" << m_exposure; + qCDebug(appLog) << "Applying filter:" << m_filter << "and exposure:" << m_exposure; // 滤镜效果渲染 uint8_t *rgb = img.bits(); if (!m_filter.isEmpty()) @@ -130,18 +132,18 @@ void MajorImageProcessingThread::processingImage(QImage& img) /*拍照*/ if (m_bTake) { - qDebug() << "Processing photo in photo mode"; + qCDebug(appLog) << "Processing photo in photo mode"; int nRet = -1; if (!img.isNull()) { if (img.save(m_strPath, "JPG")) { nRet = 0; - qInfo() << "Successfully saved photo to:" << m_strPath; + qCInfo(appLog) << "Successfully saved photo to:" << m_strPath; emit sigReflushSnapshotLabel(m_strPath); } } if (nRet < 0) { - qWarning() << "Failed to save photo to:" << m_strPath; + qCWarning(appLog) << "Failed to save photo to:" << m_strPath; } m_bTake = false; @@ -150,14 +152,14 @@ void MajorImageProcessingThread::processingImage(QImage& img) } emit SendMajorImageProcessing(&img, 0); - qDebug() << "Function completed: processingImage"; + qCDebug(appLog) << "Function completed: processingImage"; } void MajorImageProcessingThread::run() { - qInfo() << "Starting MajorImageProcessingThread run loop"; + qCInfo(appLog) << "Starting MajorImageProcessingThread run loop"; if (m_eEncodeEnv != QCamera_Env) { - qDebug() << "Processing video frame in video mode"; + qCDebug(appLog) << "Processing video frame in video mode"; m_videoDevice = get_v4l2_device_handler(); v4l2core_start_stream(m_videoDevice); int framedely = 0; @@ -178,7 +180,7 @@ void MajorImageProcessingThread::run() int ret = v4l2core_update_current_format(m_videoDevice); if (ret != E_OK) { - qWarning() << "Failed to set defined stream format, trying first listed format"; + qCWarning(appLog) << "Failed to set defined stream format, trying first listed format"; fprintf(stderr, "camera: could not set the defined stream format\n"); fprintf(stderr, "camera: trying first listed stream format\n"); @@ -220,7 +222,7 @@ void MajorImageProcessingThread::run() if (decodeCount % LOGGING_INTERVAL == LOGGING_INTERVAL - 1) { decodeTimer.start(); m_frame = v4l2core_get_decoded_frame(m_videoDevice); - qDebug() << "v4l2 decoded time:" << decodeTimer.elapsed() << "ms"; + qCDebug(appLog) << "v4l2 decoded time:" << decodeTimer.elapsed() << "ms"; decodeCount = 0; } else { m_frame = v4l2core_get_decoded_frame(m_videoDevice); @@ -442,7 +444,7 @@ void MajorImageProcessingThread::run() // qDebug() << "Processing photo capture"; if (imgTmp->save(m_strPath, "JPG")) { nRet = 0; - qInfo() << "Successfully saved photo to:" << m_strPath; + qCInfo(appLog) << "Successfully saved photo to:" << m_strPath; emit sigReflushSnapshotLabel(m_strPath); } } else if (FFmpeg_Env == m_eEncodeEnv) { @@ -460,7 +462,7 @@ void MajorImageProcessingThread::run() saveImg = new QImage(rgbPtr, m_frame->width, m_frame->height, QImage::Format_RGB888); if (saveImg->save(m_strPath, "JPG")) { nRet = 0; - qInfo() << "Successfully saved photo to:" << m_strPath; + qCInfo(appLog) << "Successfully saved photo to:" << m_strPath; emit sigReflushSnapshotLabel(m_strPath); } if (saveImg) @@ -473,7 +475,7 @@ void MajorImageProcessingThread::run() } if (nRet < 0) { - qWarning() << "Failed to save photo to:" << m_strPath; + qCWarning(appLog) << "Failed to save photo to:" << m_strPath; } m_bTake = false; diff --git a/src/src/previewopenglwidget.cpp b/src/src/previewopenglwidget.cpp index 959c8807..6fe6d711 100644 --- a/src/src/previewopenglwidget.cpp +++ b/src/src/previewopenglwidget.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. +// Copyright (C) 2020 - 2026 Uniontech Software Technology Co.,Ltd. // SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -14,6 +14,8 @@ #endif #include +#include "ddlog.h" +using namespace DDLog; namespace { @@ -97,14 +99,14 @@ QByteArray makeModernFragmentShader() PreviewOpenglWidget::PreviewOpenglWidget(QWidget *parent) : QOpenGLWidget(parent) { - qDebug() << "Function started: PreviewOpenglWidget constructor"; + qCDebug(appLog) << "Function started: PreviewOpenglWidget constructor"; m_textureY = nullptr; m_textureU = nullptr; m_textureV = nullptr; m_program = nullptr; m_videoWidth = 0; m_videoHeight = 0; - qDebug() << "Function completed: PreviewOpenglWidget constructor"; + qCDebug(appLog) << "Function completed: PreviewOpenglWidget constructor"; } int PreviewOpenglWidget::getFrameHeight() @@ -137,7 +139,7 @@ void PreviewOpenglWidget::slotShowYuv(std::shared_ptr frame, uint width void PreviewOpenglWidget::initializeGL() { - qDebug() << "Function started: initializeGL"; + qCDebug(appLog) << "Function started: initializeGL"; makeCurrent(); initializeOpenGLFunctions(); @@ -182,7 +184,7 @@ void PreviewOpenglWidget::initializeGL() if (1 == is_forceGles()) { programOk = tryLink(kVsrcLegacy, makeLegacyFragmentShader(true)); if (!programOk) { - qWarning() << "PreviewOpenglWidget: GLES shader failed, fallback to legacy GLSL:" << m_program->log(); + qCWarning(appLog) << "PreviewOpenglWidget: GLES shader failed, fallback to legacy GLSL:" << m_program->log(); delete m_program; m_program = new QOpenGLShaderProgram(this); programOk = tryLink(kVsrcLegacy, makeLegacyFragmentShader(false)); @@ -190,14 +192,14 @@ void PreviewOpenglWidget::initializeGL() } else { programOk = tryLink(kVsrcModern, makeModernFragmentShader()); if (!programOk) { - qWarning() << "PreviewOpenglWidget: core-profile shader failed, fallback to legacy GLSL:" << m_program->log(); + qCWarning(appLog) << "PreviewOpenglWidget: core-profile shader failed, fallback to legacy GLSL:" << m_program->log(); delete m_program; m_program = new QOpenGLShaderProgram(this); programOk = tryLink(kVsrcLegacy, makeLegacyFragmentShader(false)); } } if (!programOk) { - qWarning() << "PreviewOpenglWidget: shader program link failed:" << m_program->log(); + qCWarning(appLog) << "PreviewOpenglWidget: shader program link failed:" << m_program->log(); } m_program->bind(); @@ -231,7 +233,7 @@ void PreviewOpenglWidget::initializeGL() glBindTexture(GL_TEXTURE_2D, 0); glClearColor(0.0, 0.0, 0.0, 1.0); - qDebug() << "Function completed: initializeGL"; + qCDebug(appLog) << "Function completed: initializeGL"; } void PreviewOpenglWidget::resizeGL(int w, int h) diff --git a/src/src/takephotosettingareawidget.cpp b/src/src/takephotosettingareawidget.cpp index eb344b0c..7a8563bf 100644 --- a/src/src/takephotosettingareawidget.cpp +++ b/src/src/takephotosettingareawidget.cpp @@ -1,5 +1,5 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// Copyright (C) 2020 - 2026 Uniontech Software Technology Co.,Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -18,6 +18,8 @@ #include #include #include +#include "ddlog.h" +using namespace DDLog; #define ANIMATION_DURATION 200 #define ANIMATION_FOLD_DURATION 200 @@ -48,18 +50,18 @@ takePhotoSettingAreaWidget::takePhotoSettingAreaWidget(QWidget *parent) : QWidge , m_bPhoto(true) , m_filterType(filter_Normal) { - qDebug() << "Initializing takePhotoSettingAreaWidget"; + qCDebug(appLog) << "Initializing takePhotoSettingAreaWidget"; m_delayGroupDisplay = false; m_flashGroupDisplay = false; m_bPhotoToVideState = false; m_isBtnsFold = true; m_buttonGroupColor.setRgb(0, 0, 0, 255 * 0.4); - qDebug() << "Function completed: takePhotoSettingAreaWidget constructor"; + qCDebug(appLog) << "Function completed: takePhotoSettingAreaWidget constructor"; } void takePhotoSettingAreaWidget::initButtons() { - qDebug() << "Initializing buttons"; + qCDebug(appLog) << "Initializing buttons"; this->setObjectName(LEFT_BTNS_BOX); this->setAccessibleName(LEFT_BTNS_BOX); @@ -221,12 +223,12 @@ void takePhotoSettingAreaWidget::initButtons() hideAll(); - qDebug() << "Created" << m_filterPreviewBtnList.size() << "filter preview buttons"; + qCDebug(appLog) << "Created" << m_filterPreviewBtnList.size() << "filter preview buttons"; } void takePhotoSettingAreaWidget::initLayout() { - qDebug() << "Initializing layout"; + qCDebug(appLog) << "Initializing layout"; QPoint pos = this->pos(); int btnHeight = m_filtersUnfoldBtn->height(); @@ -235,7 +237,7 @@ void takePhotoSettingAreaWidget::initLayout() void takePhotoSettingAreaWidget::init() { - qDebug() << "Initializing takePhotoSettingAreaWidget"; + qCDebug(appLog) << "Initializing takePhotoSettingAreaWidget"; initButtons(); initLayout(); @@ -285,7 +287,7 @@ void takePhotoSettingAreaWidget::init() void takePhotoSettingAreaWidget::showFold(bool bShow, bool isShortcut) { - qDebug() << "Showing fold state:" << bShow << "isShortcut:" << isShortcut; + qCDebug(appLog) << "Showing fold state:" << bShow << "isShortcut:" << isShortcut; Q_UNUSED(bShow); circlePushBtnList btnList; @@ -381,12 +383,12 @@ void takePhotoSettingAreaWidget::showFold(bool bShow, bool isShortcut) group->start(QAbstractAnimation::DeleteWhenStopped); }); - qDebug() << "Exiting showFold"; + qCDebug(appLog) << "Exiting showFold"; } void takePhotoSettingAreaWidget::showUnfold(bool bShow, circlePushButton *btn, bool isShortcut) { - qDebug() << "Entering showUnfold, bShow:" << bShow << "isShortcut:" << isShortcut; + qCDebug(appLog) << "Entering showUnfold, bShow:" << bShow << "isShortcut:" << isShortcut; circlePushBtnList btnList; btnList.push_back(m_flashlightUnfoldBtn); btnList.push_back(m_delayUnfoldBtn); @@ -479,12 +481,12 @@ void takePhotoSettingAreaWidget::showUnfold(bool bShow, circlePushButton *btn, b //折叠按钮与上一按钮间距比普通间距多10px 整体高度+10 回弹伸缩范围 +5 setFixedSize(QSize(originBtn->width(), 10 + 5 + originBtn->height() * nBtnCount + (nBtnCount - 1) * m_btnHeightOffset)); update(); - qDebug() << "Exiting showUnfold"; + qCDebug(appLog) << "Exiting showUnfold"; } void takePhotoSettingAreaWidget::showDelayButtons(bool bShow, bool isShortcut) { - qDebug() << "Showing delay buttons:" << bShow << "isShortcut:" << isShortcut; + qCDebug(appLog) << "Showing delay buttons:" << bShow << "isShortcut:" << isShortcut; //位移动画 QPropertyAnimation *position1 = new QPropertyAnimation(m_noDelayBtn, "pos", this); QPropertyAnimation *position2 = new QPropertyAnimation(m_delay3SecondBtn, "pos", this); @@ -606,12 +608,12 @@ void takePhotoSettingAreaWidget::showDelayButtons(bool bShow, bool isShortcut) setFixedSize(QSize(m_delayFoldBtn->width(), m_delayFoldBtn->height() * 4 + m_threeBtnOffset * 3 + 2)); update(); - qDebug() << "Exiting showDelayButtons"; + qCDebug(appLog) << "Exiting showDelayButtons"; } void takePhotoSettingAreaWidget::showFlashlights(bool bShow, bool isShortcut) { - qDebug() << "Showing flashlight buttons:" << bShow << "isShortcut:" << isShortcut; + qCDebug(appLog) << "Showing flashlight buttons:" << bShow << "isShortcut:" << isShortcut; QPropertyAnimation *position1 = new QPropertyAnimation(m_flashlightOnBtn, "pos", this); QPropertyAnimation *position2 = new QPropertyAnimation(m_flashlightOffBtn, "pos", this); @@ -626,7 +628,7 @@ void takePhotoSettingAreaWidget::showFlashlights(bool bShow, bool isShortcut) ec.setOvershoot(EASING_OVERSHOOT); if (bShow) { - qDebug() << "show flashlight is show"; + qCDebug(appLog) << "show flashlight is show"; position1->setDuration(ANIMATION_DURATION); position1->setStartValue(QPoint(0, 0)); position1->setEndValue(QPoint(0, m_delayFoldBtn->height() + m_threeBtnOffset)); @@ -660,7 +662,7 @@ void takePhotoSettingAreaWidget::showFlashlights(bool bShow, bool isShortcut) m_flashlightFoldBtn->setFocus(); }); } else { - qDebug() << "show flashlight is not show"; + qCDebug(appLog) << "show flashlight is not show"; position1->setDuration(ANIMATION_DURATION); position1->setStartValue(QPoint(0, m_delayFoldBtn->height() + m_threeBtnOffset)); position1->setEndValue(QPoint(0, 0)); @@ -702,12 +704,12 @@ void takePhotoSettingAreaWidget::showFlashlights(bool bShow, bool isShortcut) setFixedSize(QSize(m_flashlightFoldBtn->width(), m_flashlightFoldBtn->height() * 3 + m_threeBtnOffset * 2 + 2)); update(); - qDebug() << "Exiting showFlashlights"; + qCDebug(appLog) << "Exiting showFlashlights"; } void takePhotoSettingAreaWidget::showFilters(bool bShow, bool isShortcut) { - qDebug() << "Showing filter buttons:" << bShow << "isShortcut:" << isShortcut; + qCDebug(appLog) << "Showing filter buttons:" << bShow << "isShortcut:" << isShortcut; QPropertyAnimation *posClose = new QPropertyAnimation(m_filtersCloseBtn, "pos", this); QPropertyAnimation *opacityClose = new QPropertyAnimation(m_filtersCloseBtn, "opacity", this); QPropertyAnimation *iconOpacityClose = new QPropertyAnimation(m_filtersCloseBtn, "iconopacity", this); @@ -742,7 +744,7 @@ void takePhotoSettingAreaWidget::showFilters(bool bShow, bool isShortcut) endGeometry.setWidth(startGeometry.width()); if (bShow) { - qDebug() << "show filters is show"; + qCDebug(appLog) << "show filters is show"; posScroll->setDuration(ANIMATION_FILTER_DURATION); posScroll->setEasingCurve(ec); posScroll->setStartValue(startGeometry); @@ -795,13 +797,13 @@ void takePhotoSettingAreaWidget::showFilters(bool bShow, bool isShortcut) }); if (isShortcut) { - qDebug() << "is shortcut"; + qCDebug(appLog) << "is shortcut"; QTimer::singleShot(ANIMATION_FILTER_DURATION, this, [=] { m_filtersFoldBtn->setFocus(); }); } } else { - qDebug() << "show filters is not show"; + qCDebug(appLog) << "show filters is not show"; posClose->setDuration(ANIMATION_FILTER_DURATION); posClose->setEasingCurve(ec); posClose->setStartValue(QPoint(5, (m_filtersFoldBtn->height() + m_threeBtnOffset*2) + endGeometry.height())); @@ -867,19 +869,19 @@ void takePhotoSettingAreaWidget::showFilters(bool bShow, bool isShortcut) int height = (m_filtersFoldBtn->height() + m_threeBtnOffset*2 + 1) * 2 + endGeometry.height(); setFixedSize(QSize(m_filterPreviewBtnList.last()->width(), height)); update(); - qDebug() << "Exiting showFilters"; + qCDebug(appLog) << "Exiting showFilters"; } void takePhotoSettingAreaWidget::foldBtnClicked(bool isShortcut) { - qDebug() << "Fold button clicked, isShortcut:" << isShortcut; + qCDebug(appLog) << "Fold button clicked, isShortcut:" << isShortcut; //closeAllGroup(); showFold(true, isShortcut); } void takePhotoSettingAreaWidget::unfoldBtnClicked(bool isShortcut) { - qDebug() << "Unfold button clicked, isShortcut:" << isShortcut; + qCDebug(appLog) << "Unfold button clicked, isShortcut:" << isShortcut; QPropertyAnimation * opacity = new QPropertyAnimation(m_unfoldBtn, "opacity", this); opacity->setStartValue(102); opacity->setEndValue(0); @@ -909,13 +911,13 @@ void takePhotoSettingAreaWidget::unfoldBtnClicked(bool isShortcut) void takePhotoSettingAreaWidget::flashlightFoldBtnClicked(bool isShortcut) { - qDebug() << "Flashlight fold button clicked, isShortcut:" << isShortcut; + qCDebug(appLog) << "Flashlight fold button clicked, isShortcut:" << isShortcut; showFlashlights(false, isShortcut); } void takePhotoSettingAreaWidget::flashlightUnfoldBtnClicked(bool isShortcut) { - qDebug() << "Flashlight unfold button clicked, isShortcut:" << isShortcut; + qCDebug(appLog) << "Flashlight unfold button clicked, isShortcut:" << isShortcut; hideAll(); closeAllGroup(); showFlashlights(true, isShortcut); @@ -929,7 +931,7 @@ void takePhotoSettingAreaWidget::flashlightUnfoldBtnClicked(bool isShortcut) void takePhotoSettingAreaWidget::delayUnfoldBtnClicked(bool isShortcut) { - qDebug() << "Delay unfold button clicked, isShortcut:" << isShortcut; + qCDebug(appLog) << "Delay unfold button clicked, isShortcut:" << isShortcut; hideAll(); closeAllGroup(); showDelayButtons(true, isShortcut); @@ -938,13 +940,13 @@ void takePhotoSettingAreaWidget::delayUnfoldBtnClicked(bool isShortcut) void takePhotoSettingAreaWidget::delayfoldBtnClicked(bool isShortcut) { - qDebug() << "Delay fold button clicked, isShortcut:" << isShortcut; + qCDebug(appLog) << "Delay fold button clicked, isShortcut:" << isShortcut; showDelayButtons(false, isShortcut); } void takePhotoSettingAreaWidget::filtersUnfoldBtnClicked(bool isShortcut) { - qDebug() << "Filters unfold button clicked, isShortcut:" << isShortcut; + qCDebug(appLog) << "Filters unfold button clicked, isShortcut:" << isShortcut; hideAll(); closeAllGroup(); m_filtersGroupDislay = true; @@ -954,14 +956,14 @@ void takePhotoSettingAreaWidget::filtersUnfoldBtnClicked(bool isShortcut) void takePhotoSettingAreaWidget::filtersFoldBtnClicked(bool isShortcut) { - qDebug() << "Filters fold button clicked, isShortcut:" << isShortcut; + qCDebug(appLog) << "Filters fold button clicked, isShortcut:" << isShortcut; showFilters(false, isShortcut); emit sigFilterGroupDisplay(false); } void takePhotoSettingAreaWidget::hideAll() { - qDebug() << "Hiding all"; + qCDebug(appLog) << "Hiding all"; m_foldBtn->setVisible(false); m_unfoldBtn->setVisible(false); @@ -983,7 +985,7 @@ void takePhotoSettingAreaWidget::hideAll() m_filtersCloseBtn->setVisible(false); m_exposureBtn->setVisible(false); - qDebug() << "Exiting hideAll"; + qCDebug(appLog) << "Exiting hideAll"; } void takePhotoSettingAreaWidget::keyDownClick() @@ -1282,10 +1284,10 @@ void takePhotoSettingAreaWidget::paintEvent(QPaintEvent *event) void takePhotoSettingAreaWidget::onDelayBtnsClicked(bool isShortcut) { - qDebug() << "Delay button clicked, isShortcut:" << isShortcut; + qCDebug(appLog) << "Delay button clicked, isShortcut:" << isShortcut; circlePushButton *pBtn = static_cast(sender()); if (nullptr == pBtn) { - qWarning() << "Failed to get sender button"; + qCWarning(appLog) << "Failed to get sender button"; return; } pBtn == m_noDelayBtn ? m_noDelayBtn->setSelected(true) : m_noDelayBtn->setSelected(false); @@ -1307,22 +1309,22 @@ void takePhotoSettingAreaWidget::onDelayBtnsClicked(bool isShortcut) bCopyBtn = m_delay6SecondBtn; } - qDebug() << "Setting delay time to:" << delayTime << "seconds"; + qCDebug(appLog) << "Setting delay time to:" << delayTime << "seconds"; m_delayUnfoldBtn->copyPixmap(*bCopyBtn); m_delayFoldBtn->copyPixmap(*bCopyBtn); emit sngSetDelayTakePhoto(delayTime); update(); showDelayButtons(false, isShortcut); //三级菜单选中后跳转到上一级菜单 - qDebug() << "Exiting onDelayBtnsClicked"; + qCDebug(appLog) << "Exiting onDelayBtnsClicked"; } void takePhotoSettingAreaWidget::onFlashlightBtnsClicked(bool isShortcut) { - qDebug() << "Flashlight button clicked, isShortcut:" << isShortcut; + qCDebug(appLog) << "Flashlight button clicked, isShortcut:" << isShortcut; auto pBtn = static_cast(sender()); if (nullptr == pBtn) { - qWarning() << "Failed to get sender button"; + qCWarning(appLog) << "Failed to get sender button"; return; } @@ -1330,22 +1332,22 @@ void takePhotoSettingAreaWidget::onFlashlightBtnsClicked(bool isShortcut) pBtn == m_flashlightOffBtn ? m_flashlightOffBtn->setSelected(true) : m_flashlightOffBtn->setSelected(false); bool flashState = m_flashlightOnBtn->getButtonState(); - qDebug() << "Setting flashlight state to:" << flashState; + qCDebug(appLog) << "Setting flashlight state to:" << flashState; setFlashlight(flashState); emit sngSetFlashlight(flashState); showFlashlights(false, isShortcut); - qDebug() << "Exiting onFlashlightBtnsClicked"; + qCDebug(appLog) << "Exiting onFlashlightBtnsClicked"; } void takePhotoSettingAreaWidget::onFilterBtnsClicked(bool isShortcut) { - qDebug() << "Filter button clicked, isShortcut:" << isShortcut; + qCDebug(appLog) << "Filter button clicked, isShortcut:" << isShortcut; Q_UNUSED(isShortcut); auto pBtn = static_cast(sender()); if (!pBtn) { - qWarning() << "Failed to get sender button"; + qCWarning(appLog) << "Failed to get sender button"; return; } @@ -1355,19 +1357,19 @@ void takePhotoSettingAreaWidget::onFilterBtnsClicked(bool isShortcut) efilterType newFilterType = pBtn->getFiltertype(); if (m_filterType != newFilterType) { - qDebug() << "Changing filter type from" << m_filterType << "to" << newFilterType; + qCDebug(appLog) << "Changing filter type from" << m_filterType << "to" << newFilterType; emit sngFilterChanged(newFilterType); emit sngSetFilterName(filterPreviewButton::filterName(newFilterType)); m_filterType = newFilterType; } - qDebug() << "Exiting onFilterBtnsClicked"; + qCDebug(appLog) << "Exiting onFilterBtnsClicked"; } void takePhotoSettingAreaWidget::onUpdateFilterImage(QImage *img) { - qDebug() << "Entering onUpdateFilterImage"; + qCDebug(appLog) << "Entering onUpdateFilterImage"; if (!img) { - qWarning() << "Received null image for filter update"; + qCWarning(appLog) << "Received null image for filter update"; return; } for (auto btn : m_filterPreviewBtnList) { @@ -1386,12 +1388,12 @@ void takePhotoSettingAreaWidget::onUpdateFilterImage(QImage *img) if (m_scrollArea && m_scrollArea->isVisible()) { m_scrollAreaWidget->update(); } - qDebug() << "Exiting onUpdateFilterImage"; + qCDebug(appLog) << "Exiting onUpdateFilterImage"; } void takePhotoSettingAreaWidget::onExposureValueChanged(int value) { - qDebug() << "Exposure value changed to:" << value; + qCDebug(appLog) << "Exposure value changed to:" << value; if (value) m_exposureBtn->setNewNotification(true); else @@ -1412,7 +1414,7 @@ filterPreviewButton *takePhotoSettingAreaWidget::getFilterPreviewFocusBtn() void takePhotoSettingAreaWidget::exposureBtnClicked(bool isShortcut) { - qDebug() << "Entering exposureBtnClicked"; + qCDebug(appLog) << "Entering exposureBtnClicked"; if (QDateTime::currentMSecsSinceEpoch() - m_animationTime < 500) //防止上一次动画未完成 return; else @@ -1426,11 +1428,11 @@ void takePhotoSettingAreaWidget::exposureBtnClicked(bool isShortcut) end.setHeight(EXPOSURE_SLIDER_HEIGHT); if (m_exposureSliderDisplay) { - qDebug() << "is exposure slider display"; + qCDebug(appLog) << "is exposure slider display"; m_exposureSlider->showContent(false, isShortcut); connect(m_exposureSlider, &ExposureSlider::contentHided, this, [=](){ - qDebug() << "is exposure slider content hided"; + qCDebug(appLog) << "is exposure slider content hided"; QPropertyAnimation *opacity = new QPropertyAnimation(m_exposureSlider, "opacity", this); opacity->setStartValue(102); opacity->setEndValue(0); @@ -1447,7 +1449,7 @@ void takePhotoSettingAreaWidget::exposureBtnClicked(bool isShortcut) pGroup->addAnimation(opacity); pGroup->addAnimation(geometry); connect(pGroup, &QParallelAnimationGroup::finished, this, [=](){ - qDebug() << "is exposure slider content hided finished"; + qCDebug(appLog) << "is exposure slider content hided finished"; m_exposureSlider->hide(); if (isShortcut) //键盘触发,焦点设回到曝光按钮上 m_exposureBtn->setFocus(); @@ -1457,7 +1459,7 @@ void takePhotoSettingAreaWidget::exposureBtnClicked(bool isShortcut) showUnfold(true, m_exposureBtn, isShortcut); if (m_bPhoto && !m_isBtnsFold) { - qDebug() << "is exposure slider content hided finished and is photo"; + qCDebug(appLog) << "is exposure slider content hided finished and is photo"; m_flashlightUnfoldBtn->setVisible(true); m_filtersUnfoldBtn->setVisible(true); m_exposureBtn->setVisible(true); @@ -1466,7 +1468,7 @@ void takePhotoSettingAreaWidget::exposureBtnClicked(bool isShortcut) m_filtersUnfoldBtn->setOpacity(102); m_exposureBtn->setOpacity(102); } else { - qDebug() << "is exposure slider content hided finished and is not photo"; + qCDebug(appLog) << "is exposure slider content hided finished and is not photo"; m_flashlightUnfoldBtn->setVisible(false); m_filtersUnfoldBtn->setVisible(false); m_exposureBtn->setVisible(false); @@ -1479,7 +1481,7 @@ void takePhotoSettingAreaWidget::exposureBtnClicked(bool isShortcut) }); } else { - qDebug() << "is exposure slider not display"; + qCDebug(appLog) << "is exposure slider not display"; QPropertyAnimation *opacity = new QPropertyAnimation(m_exposureSlider, "opacity", this); opacity->setStartValue(0); opacity->setEndValue(102); @@ -1496,7 +1498,7 @@ void takePhotoSettingAreaWidget::exposureBtnClicked(bool isShortcut) pGroup->addAnimation(opacity); pGroup->addAnimation(geometry); connect(pGroup, &QParallelAnimationGroup::finished, this, [=](){ - qDebug() << "is exposure slider content hided finished"; + qCDebug(appLog) << "is exposure slider content hided finished"; m_exposureSlider->showContent(true, isShortcut); pGroup->deleteLater(); }); @@ -1507,18 +1509,18 @@ void takePhotoSettingAreaWidget::exposureBtnClicked(bool isShortcut) m_exposureSliderDisplay = !m_exposureSliderDisplay; m_exposureBtn->setSelected(m_exposureSliderDisplay); - qDebug() << "Exiting exposureBtnClicked"; + qCDebug(appLog) << "Exiting exposureBtnClicked"; } void takePhotoSettingAreaWidget::setDelayTime(int delayTime) { - qDebug() << "Setting delay time to:" << delayTime << "seconds"; + qCDebug(appLog) << "Setting delay time to:" << delayTime << "seconds"; m_noDelayBtn->setSelected(false); m_delay3SecondBtn->setSelected(false); m_delay6SecondBtn->setSelected(false); switch (delayTime) { case 0: - qDebug() << "set delay time to 0"; + qCDebug(appLog) << "set delay time to 0"; // emit m_noDelayBtn->clicked(); //不使用触发按钮点击方式实现,防止影响动画效果 m_noDelayBtn->setSelected(true); m_delayUnfoldBtn->copyPixmap(*m_noDelayBtn); @@ -1526,7 +1528,7 @@ void takePhotoSettingAreaWidget::setDelayTime(int delayTime) update(); break; case 3: - qDebug() << "set delay time to 3"; + qCDebug(appLog) << "set delay time to 3"; // emit m_delay3SecondBtn->clicked(); m_delay3SecondBtn->setSelected(true); m_delayUnfoldBtn->copyPixmap(*m_delay3SecondBtn); @@ -1534,7 +1536,7 @@ void takePhotoSettingAreaWidget::setDelayTime(int delayTime) update(); break; case 6: - qDebug() << "set delay time to 6"; + qCDebug(appLog) << "set delay time to 6"; // emit m_delay6SecondBtn->clicked(); m_delay6SecondBtn->setSelected(true); m_delayUnfoldBtn->copyPixmap(*m_delay6SecondBtn); @@ -1542,22 +1544,22 @@ void takePhotoSettingAreaWidget::setDelayTime(int delayTime) update(); break; default: - qDebug() << "set delay time to default"; + qCDebug(appLog) << "set delay time to default"; ; } - qDebug() << "Exiting setDelayTime"; + qCDebug(appLog) << "Exiting setDelayTime"; } void takePhotoSettingAreaWidget::setFlashlight(bool bFlashOn) { - qDebug() << "Setting flashlight state to:" << bFlashOn; + qCDebug(appLog) << "Setting flashlight state to:" << bFlashOn; m_flashlightOnBtn->setSelected(bFlashOn); m_flashlightOffBtn->setSelected(!bFlashOn); auto p = bFlashOn ? m_flashlightOnBtn : m_flashlightOffBtn; m_flashlightUnfoldBtn->copyPixmap(*p); m_flashlightFoldBtn->copyPixmap(*p); update(); - qDebug() << "Exiting setFlashlight"; + qCDebug(appLog) << "Exiting setFlashlight"; } bool takePhotoSettingAreaWidget::flashLight() @@ -1568,7 +1570,7 @@ bool takePhotoSettingAreaWidget::flashLight() void takePhotoSettingAreaWidget::setFilterType(efilterType type) { - qDebug() << "Setting filter type to:" << type; + qCDebug(appLog) << "Setting filter type to:" << type; for (auto pBtn : m_filterPreviewBtnList) { pBtn->setSelected(pBtn->getFiltertype() == type); } @@ -1669,7 +1671,7 @@ void takePhotoSettingAreaWidget::moveToParentLeft() void takePhotoSettingAreaWidget::closeAllGroup() { - qDebug() << "Closing all groups"; + qCDebug(appLog) << "Closing all groups"; //判断延迟拍照组是否显示 if (m_delayGroupDisplay) delayfoldBtnClicked(); @@ -1689,7 +1691,7 @@ void takePhotoSettingAreaWidget::closeAllGroup() void takePhotoSettingAreaWidget::setOpacity(int opacity) { - qDebug() << "Setting opacity to:" << opacity; + qCDebug(appLog) << "Setting opacity to:" << opacity; m_opacity = opacity; m_buttonGroupColor.setAlpha(opacity); update(); @@ -1697,9 +1699,9 @@ void takePhotoSettingAreaWidget::setOpacity(int opacity) void takePhotoSettingAreaWidget::setState(bool bPhoto) { - qDebug() << "Setting widget state to:" << (bPhoto ? "Photo" : "Video"); + qCDebug(appLog) << "Setting widget state to:" << (bPhoto ? "Photo" : "Video"); if (m_exposureSliderDisplay) { - qDebug() << "is exposure slider display"; + qCDebug(appLog) << "is exposure slider display"; //判断当前是否由拍照状态切换到录像状态 m_bPhotoToVideState = m_bPhoto && !bPhoto; exposureBtnClicked(); @@ -1709,12 +1711,12 @@ void takePhotoSettingAreaWidget::setState(bool bPhoto) // 若有功能按钮组处于展开状态,折叠之 if (m_delayGroupDisplay || m_flashGroupDisplay || m_filtersGroupDislay || m_exposureSliderDisplay) { - qDebug() << "close all group"; + qCDebug(appLog) << "close all group"; closeAllGroup(); } // 按钮总开关处于展开状态 else if (!m_isBtnsFold){ - qDebug() << "not any group display"; + qCDebug(appLog) << "not any group display"; // 功能按钮组未处于展开状态,重新设置各个按钮位置 circlePushBtnList btnList; btnList.push_back(m_flashlightUnfoldBtn); @@ -1743,7 +1745,7 @@ void takePhotoSettingAreaWidget::setState(bool bPhoto) m_bPhoto = bPhoto; if (bPhoto && !m_isBtnsFold) { - qDebug() << "is photo and is not fold"; + qCDebug(appLog) << "is photo and is not fold"; m_flashlightUnfoldBtn->setVisible(true); m_filtersUnfoldBtn->setVisible(true); m_exposureBtn->setVisible(true); @@ -1752,18 +1754,18 @@ void takePhotoSettingAreaWidget::setState(bool bPhoto) m_filtersUnfoldBtn->setOpacity(102); m_exposureBtn->setOpacity(102); } else { - qDebug() << "is not photo or is fold"; + qCDebug(appLog) << "is not photo or is fold"; m_flashlightUnfoldBtn->setVisible(false); m_filtersUnfoldBtn->setVisible(false); m_exposureBtn->setVisible(false); } update(); - qDebug() << "Exiting setState"; + qCDebug(appLog) << "Exiting setState"; } void takePhotoSettingAreaWidget::resizeScrollHeight(int height) { - qDebug() << "Resizing scroll height to:" << height; + qCDebug(appLog) << "Resizing scroll height to:" << height; m_scrollHeight = (m_filtersFoldBtn->height() + m_threeBtnOffset * 2) * 6 + height + 15; //Add a offset here if (m_scrollHeight > m_scrollArea->widget()->height()) m_scrollHeight = m_scrollArea->widget()->height(); diff --git a/src/src/titlebar.cpp b/src/src/titlebar.cpp index e5e20d47..408ac646 100644 --- a/src/src/titlebar.cpp +++ b/src/src/titlebar.cpp @@ -1,10 +1,12 @@ -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later #include "titlebar.h" #include "datamanager.h" #include +#include "ddlog.h" +using namespace DDLog; class TitlebarPrivate { @@ -27,7 +29,7 @@ class TitlebarPrivate Titlebar::Titlebar(QWidget *parent) : DBlurEffectWidget(parent), d_ptr(new TitlebarPrivate(this)) { Q_D(Titlebar); - qDebug() << "Initializing Titlebar"; + qCDebug(appLog) << "Initializing Titlebar"; // 设置DBlurEffectWidget为完全透明 setBlurEnabled(false); // 关闭模糊效果 @@ -52,7 +54,7 @@ Titlebar::Titlebar(QWidget *parent) : DBlurEffectWidget(parent), d_ptr(new Title this->setGraphicsEffect(d->m_shadowEffect); connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &Titlebar::slotThemeTypeChanged); - qDebug() << "Titlebar initialization complete"; + qCDebug(appLog) << "Titlebar initialization complete"; } DTitlebar *Titlebar::titlebar() diff --git a/src/src/videowidget.cpp b/src/src/videowidget.cpp index 96059df5..78fc8fd7 100644 --- a/src/src/videowidget.cpp +++ b/src/src/videowidget.cpp @@ -43,6 +43,8 @@ #endif #include +#include "ddlog.h" +using namespace DDLog; #define COUNTDOWN_WIDTH 32 #define COUNTDOWN_HEIGHT 61 @@ -98,12 +100,12 @@ videowidget::videowidget(DWidget *parent) m_exposure(0), m_videoFormat("mp4") { - qDebug() << "Initializing VideoWidget"; + qCDebug(appLog) << "Initializing VideoWidget"; #ifndef __mips__ if (!get_wayland_status()) { m_openglwidget = new PreviewOpenglWidget(this); m_openglwidget->setFocusPolicy(Qt::ClickFocus); - qDebug() << "Created OpenGL widget for non-Wayland environment"; + qCDebug(appLog) << "Created OpenGL widget for non-Wayland environment"; } #endif m_pNormalItem = new QGraphicsPixmapItem; @@ -215,7 +217,7 @@ videowidget::videowidget(DWidget *parent) //wayland平台设置背景色为黑色 if (get_wayland_status() == true) { - qDebug() << "wayland platform"; + qCDebug(appLog) << "wayland platform"; QPalette pal(palette()); pal.setColor(QPalette::Window, Qt::black); setAutoFillBackground(true); @@ -264,23 +266,23 @@ videowidget::videowidget(DWidget *parent) setGridType(Grid_None); if (DataManager::instance()->encodeEnv() != FFmpeg_Env || !DataManager::instance()->encExists() || GlobalUtils::isLowPerformanceBoard()) { - qDebug() << "Unsupported environment or encoding error"; + qCDebug(appLog) << "Unsupported environment or encoding error"; m_videoFormat = "webm"; } if (dc::Settings::get().getOption("outsetting.outformat.vidformat").toInt()) { - qDebug() << "Video format setting detected"; + qCDebug(appLog) << "Video format setting detected"; if (!GlobalUtils::isLowPerformanceBoard()) m_videoFormat = "webm"; else m_videoFormat = "mp4"; } - qDebug() << "VideoWidget initialization complete"; + qCDebug(appLog) << "VideoWidget initialization complete"; } //延迟加载 void videowidget::delayInit() { - qDebug() << "Starting delayed initialization of VideoWidget"; + qCDebug(appLog) << "Starting delayed initialization of VideoWidget"; m_imgPrcThread = new MajorImageProcessingThread; m_imgPrcThread->setParent(this); m_imgPrcThread->setObjectName("MajorThread"); @@ -290,11 +292,11 @@ void videowidget::delayInit() setCapStatus(false); m_imgPrcThread->m_bTake = false; if (get_wayland_status() == true) { - qDebug() << "Wayland detected"; + qCDebug(appLog) << "Wayland detected"; connect(m_imgPrcThread, SIGNAL(SendMajorImageProcessing(QImage *, int)), this, SLOT(ReceiveMajorImage(QImage *, int))); } else { - qDebug() << "X11 detected"; + qCDebug(appLog) << "X11 detected"; connect(m_imgPrcThread, SIGNAL(SendMajorImageProcessing(QImage *, int)), this, SLOT(ReceiveMajorImage(QImage *, int))); connect(m_imgPrcThread, SIGNAL(sigRenderYuv(bool)), this, SLOT(ReceiveOpenGLstatus(bool))); @@ -334,21 +336,21 @@ void videowidget::delayInit() updateValidDevices(); if (!isDeviceValidByDevice(device)) { QString validDevice = getFirstValidDevice(); - qWarning() << "INVALID device from config:" << device << ", found first valid device:" << validDevice; + qCWarning(appLog) << "INVALID device from config:" << device << ", found first valid device:" << validDevice; switchCamera(validDevice.toStdString().c_str(), ""); } else { - qInfo() << "VALID device from config:" << device; + qCInfo(appLog) << "VALID device from config:" << device; switchCamera(device.toStdString().c_str(), ""); // 走默认逻辑 } QObject::connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &videowidget::onThemeTypeChanged); - qDebug() << "Delayed initialization complete"; + qCDebug(appLog) << "Delayed initialization complete"; } void videowidget::showNocam() { - qDebug() << "Showing no camera state"; + qCDebug(appLog) << "Showing no camera state"; if (!m_pNormalView->isVisible()) m_pNormalView->show(); @@ -366,7 +368,7 @@ void videowidget::showNocam() m_openglwidget->hide(); if (m_GridType != Grid_None) { - qDebug() << "Grid detected"; + qCDebug(appLog) << "Grid detected"; // 提示界面不显示井字格 if (m_pGridLineItem->isVisible()) { m_pGridLineItem->hide(); @@ -379,7 +381,7 @@ void videowidget::showNocam() QString strsub; if (DGuiApplicationHelper::LightType == DGuiApplicationHelper::instance()->themeType()) { - qDebug() << "Light theme detected"; + qCDebug(appLog) << "Light theme detected"; if (DataManager::instance()->isSupportCameraSwitch()) { m_pSvgItem->setSharedRenderer(new QSvgRenderer(QString(":/images/icons/light/camera_switch_not_on.svg"), this)); strsub = tr("Your camera might not be turned on. If you need to use it, please check whether the hardware switch of the camera or the camera hotkey on the keyboard is enabled"); @@ -391,7 +393,7 @@ void videowidget::showNocam() m_pCamErrItem->setDefaultTextColor(clr); m_pCamErrItemSub->setDefaultTextColor(clr); } else { - qDebug() << "Dark theme detected"; + qCDebug(appLog) << "Dark theme detected"; if (DataManager::instance()->isSupportCameraSwitch()) { m_pSvgItem->setSharedRenderer(new QSvgRenderer(QString(":/images/icons/dark/camera_switch_not_on_dark.svg"), this)); strsub = tr("Your camera might not be turned on. If you need to use it, please check whether the hardware switch of the camera or the camera hotkey on the keyboard is enabled"); @@ -424,16 +426,16 @@ void videowidget::showNocam() m_pSvgItem->show(); emit noCam(); - qDebug() << "No camera state displayed"; + qCDebug(appLog) << "No camera state displayed"; if (getCapStatus()) //录制完成处理 onEndBtnClicked(); - qDebug() << "End button clicked"; + qCDebug(appLog) << "End button clicked"; } void videowidget::showCamUsed() { - qDebug() << "Showing camera in use state"; + qCDebug(appLog) << "Showing camera in use state"; if (!m_pNormalView->isVisible()) m_pNormalView->show(); @@ -444,7 +446,7 @@ void videowidget::showCamUsed() m_openglwidget->hide(); if (m_GridType != Grid_None) { - qDebug() << "Grid type is not Grid_None"; + qCDebug(appLog) << "Grid type is not Grid_None"; // 提示界面不显示井字格 if (m_pGridLineItem->isVisible()) { m_pGridLineItem->hide(); @@ -456,7 +458,7 @@ void videowidget::showCamUsed() emit sigDeviceChange(); QString str(tr("The webcam is in use"));//摄像头已被占用 if (DGuiApplicationHelper::LightType == DGuiApplicationHelper::instance()->themeType()) { - qDebug() << "Light theme"; + qCDebug(appLog) << "Light theme"; m_pSvgItem->setSharedRenderer(new QSvgRenderer(QString(":/images/icons/light/Take up.svg"), this)); QColor clrText(Qt::white); clrText.setAlphaF(0.8); @@ -465,7 +467,7 @@ void videowidget::showCamUsed() m_pCamErrItemSub->setDefaultTextColor(clrText); m_pCamErrItemSub->setPlainText(QString()); } else { - qDebug() << "Dark theme"; + qCDebug(appLog) << "Dark theme"; m_pSvgItem->setSharedRenderer(new QSvgRenderer(QString(":/images/icons/dark/Take up_dark.svg"), this)); QColor clrText(Qt::white); clrText.setAlphaF(0.2); @@ -491,7 +493,7 @@ void videowidget::showCamUsed() m_pCamErrItemSub->show(); m_pSvgItem->show(); emit noCamAvailable(); - qDebug() << "Camera in use state displayed"; + qCDebug(appLog) << "Camera in use state displayed"; if (getCapStatus())//录制完成处理 onEndBtnClicked(); @@ -499,9 +501,9 @@ void videowidget::showCamUsed() #ifndef __mips__ void videowidget::ReceiveOpenGLstatus(bool result) { - qDebug() << "OpenGL status received"; + qCDebug(appLog) << "OpenGL status received"; if (result && m_openglwidget) { - qDebug() << "OpenGL status received"; + qCDebug(appLog) << "OpenGL status received"; //Success if (m_pCamErrItem->isVisible()) { m_pCamErrItem->hide(); @@ -515,7 +517,7 @@ void videowidget::ReceiveOpenGLstatus(bool result) m_pNormalView->hide(); if (m_GridType != Grid_None) { - qDebug() << "Grid status received"; + qCDebug(appLog) << "Grid status received"; if (m_pGridLineItem->isVisible()) m_pGridLineItem->hide(); @@ -534,16 +536,16 @@ void videowidget::ReceiveOpenGLstatus(bool result) int widgetwidth = width(); int widgetheight = height(); if (!framewidth && !frameheight) { - qDebug() << "Frame size not available"; + qCDebug(appLog) << "Frame size not available"; m_openglwidget->resize(widgetwidth, widgetheight); } else { - qDebug() << "Frame size available"; + qCDebug(appLog) << "Frame size available"; if ((framewidth * 100 / frameheight) > (widgetwidth * 100 / widgetheight)) { - qDebug() << "Frame width is larger than widget width"; + qCDebug(appLog) << "Frame width is larger than widget width"; m_openglwidget->resize(widgetwidth, widgetwidth * frameheight / framewidth); m_openglwidget->move(0, (widgetheight - widgetwidth * frameheight / framewidth) / 2); } else { - qDebug() << "Frame height is larger than widget height"; + qCDebug(appLog) << "Frame height is larger than widget height"; m_openglwidget->resize(widgetheight * framewidth / frameheight, widgetheight); m_openglwidget->move((widgetwidth - widgetheight * framewidth / frameheight) / 2, 0); } @@ -555,24 +557,24 @@ void videowidget::ReceiveOpenGLstatus(bool result) malloc_trim(0); emit camAvailable(); } - qDebug() << "OpenGL status received"; + qCDebug(appLog) << "OpenGL status received"; } #endif void videowidget::ReceiveMajorImage(QImage *image, int result) { - qDebug() << "Received major image"; + qCDebug(appLog) << "Received major image"; // 若窗口高度改变,需要刷新整个窗口,防止上一帧图像出现在其它区域 static int height = this->height(); if (height != this->height()) { - qDebug() << "Window height changed"; + qCDebug(appLog) << "Window height changed"; update(); height = this->height(); } if (!image->isNull()) { - qDebug() << "Image is not null"; + qCDebug(appLog) << "Image is not null"; switch (result) { case 0: //Success if (!m_isFlash) @@ -624,12 +626,12 @@ void videowidget::ReceiveMajorImage(QImage *image, int result) } break; default: - qWarning() << "Received invalid image with result code:" << result; + qCWarning(appLog) << "Received invalid image with result code:" << result; break; } emit camAvailable(); } - qDebug() << "Received major image"; + qCDebug(appLog) << "Received major image"; } void videowidget::onLockedScreen(bool bLocked) @@ -643,7 +645,7 @@ void videowidget::onLockedScreen(bool bLocked) void videowidget::onReachMaxDelayedFrames() { - qWarning() << "Reached maximum delayed frames, stopping camera"; + qCWarning(appLog) << "Reached maximum delayed frames, stopping camera"; check_device_list_events(get_v4l2_device_handler()); v4l2_dev_t *videoDevHand = get_v4l2_device_handler(); @@ -663,7 +665,7 @@ void videowidget::onReachMaxDelayedFrames() m_pNormalItem->hide() ; if (m_openglwidget) m_openglwidget->hide(); - qDebug() << "Camera stopped due to maximum delayed frames"; + qCDebug(appLog) << "Camera stopped due to maximum delayed frames"; } void videowidget::showCountDownLabel(PREVIEW_ENUM_STATE state) @@ -780,9 +782,9 @@ void videowidget::resizeEvent(QResizeEvent *size) void videowidget::showCountdown() { - qDebug() << "Entering showCountdown"; + qCDebug(appLog) << "Entering showCountdown"; if (DataManager::instance()->getdevStatus() == NOCAM) { - qDebug() << "No camera available, stopping countdown"; + qCDebug(appLog) << "No camera available, stopping countdown"; if (m_flashTimer->isActive()) m_flashTimer->stop(); @@ -796,10 +798,10 @@ void videowidget::showCountdown() //显示倒数,m_nMaxInterval秒后结束,并拍照 if (m_nInterval == 0 && DataManager::instance()->getdevStatus() == CAM_CANUSE) { //倒数到最后一次,隐藏计数器 - qDebug() << "Countdown complete, current state:" << (g_Enum_Camera_State == VIDEO ? "Video" : "Photo"); + qCDebug(appLog) << "Countdown complete, current state:" << (g_Enum_Camera_State == VIDEO ? "Video" : "Photo"); m_dLabel->hide(); if (g_Enum_Camera_State == VIDEO) { - qDebug() << "Showing countdown label for video"; + qCDebug(appLog) << "Showing countdown label for video"; if (!getCapStatus()) { if (DataManager::instance()->encodeEnv() != QCamera_Env) { /*m_bActive录制状态判断 @@ -817,7 +819,7 @@ void videowidget::showCountdown() } if (g_Enum_Camera_State == PICTURE) { - qDebug() << "Showing countdown label for photo"; + qCDebug(appLog) << "Showing countdown label for photo"; if (m_nInterval == 0 && m_curTakePicTime >= 0) { if (m_flashEnable && 1 == m_nMaxContinuous) { #if QT_VERSION_MAJOR > 5 @@ -832,7 +834,7 @@ void videowidget::showCountdown() m_flashLabel->show(); } m_flashTimer->start(500); - qDebug() << "flashTimer->start();"; + qCDebug(appLog) << "flashTimer->start();"; if (m_pNormalView) { m_isFlash = true; @@ -849,10 +851,10 @@ void videowidget::showCountdown() emit updatePhotoState(CMainWindow::Photoing); if (QDir(m_savePicFolder).exists() == false) { - qDebug() << "Creating default picture folder"; + qCDebug(appLog) << "Creating default picture folder"; QString strDefaultPath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation) + QDir::separator() + "Camera"; if (QDir(strDefaultPath).exists() == false) { - qDebug() << "Creating default picture folder"; + qCDebug(appLog) << "Creating default picture folder"; QDir dir; dir.mkdir(strDefaultPath); } @@ -868,14 +870,14 @@ void videowidget::showCountdown() m_curTakePicTime -= 1; if (m_curTakePicTime == 0) { - qDebug() << "Taking picture"; + qCDebug(appLog) << "Taking picture"; //拍照结束,恢复按钮状态和缩略图标志位 QThread *thread = QThread::create([ = ]() { int nCount = 0; while (true) { if (nCount > 50) { - qWarning() << "too long to emit takePicDone"; + qCWarning(appLog) << "too long to emit takePicDone"; break; } @@ -892,13 +894,13 @@ void videowidget::showCountdown() connect(thread, &QThread::finished, thread, &QObject::deleteLater); thread->start(); } else { - qDebug() << "Taking picture once"; + qCDebug(appLog) << "Taking picture once"; QThread *thread = QThread::create([ = ]() { int nCount = 0; while (true) { if (nCount > 50) { - qWarning() << "too long to emit takePicOnce"; + qCWarning(appLog) << "too long to emit takePicOnce"; break; } @@ -926,18 +928,18 @@ void videowidget::showCountdown() } } else { - qDebug() << "Showing countdown label for photo"; + qCDebug(appLog) << "Showing countdown label for photo"; m_dLabel->setText(QString::number(m_nInterval)); m_dLabel->show(); showCountDownLabel(PICTURE); //拍照录像都要显示倒计时 m_nInterval--; - qInfo() << "m_nInterval:" << m_nInterval; + qCInfo(appLog) << "m_nInterval:" << m_nInterval; } } void videowidget::showRecTime() { - qDebug() << "Updating recording time display"; + qCDebug(appLog) << "Updating recording time display"; //获取写video的时间 if (DataManager::instance()->encodeEnv() == FFmpeg_Env) { /** On the equipment with poor performance, the coding time is long, @@ -959,11 +961,11 @@ void videowidget::showRecTime() // return; // } } else if (DataManager::instance()->encodeEnv() == QCamera_Env) { - qDebug() << "Getting recording time from camera"; + qCDebug(appLog) << "Getting recording time from camera"; m_nCount = Camera::instance()->getRecoderTime() / 1000; m_nCount += 2; } else if (DataManager::instance()->encodeEnv() == GStreamer_Env) { - qDebug() << "Getting recording time from gstreamer"; + qCDebug(appLog) << "Getting recording time from gstreamer"; m_nCount = m_videoWriter->getRecrodTime(); } @@ -1010,12 +1012,12 @@ void videowidget::showRecTime() } m_recordingTime->setText(strTime); - qDebug() << "Recording time updated:" << strTime; + qCDebug(appLog) << "Recording time updated:" << strTime; } void videowidget::flash() { - qDebug() << "Entering flash"; + qCDebug(appLog) << "Entering flash"; if (get_sound_of_takeing_photo()) { #if QT_VERSION_MAJOR > 5 m_player->play(); @@ -1040,15 +1042,15 @@ void videowidget::flash() //最后一次拍照完成,设置状态恢复 if (0 == m_curTakePicTime) { - qDebug() << "Setting photo state to normal"; + qCDebug(appLog) << "Setting photo state to normal"; emit updatePhotoState(CMainWindow::photoNormal); } - qDebug() << "Exiting flash"; + qCDebug(appLog) << "Exiting flash"; } void videowidget::slotresolutionchanged(const QString &resolution) { - qDebug() << "Entering slotresolutionchanged"; + qCDebug(appLog) << "Entering slotresolutionchanged"; if (DataManager::instance()->getdevStatus() != CAM_CANUSE) return ; @@ -1062,7 +1064,7 @@ void videowidget::slotresolutionchanged(const QString &resolution) int newheight = ResStr[1].toInt();//新的高度 if (DataManager::instance()->encodeEnv() == QCamera_Env) { - qDebug() << "Getting camera resolution"; + qCDebug(appLog) << "Getting camera resolution"; QSize resolution = Camera::instance()->getCameraResolution(); if (resolution.width() != newwidth || resolution.height() != newheight) { QSize size(newwidth, newheight); @@ -1070,7 +1072,7 @@ void videowidget::slotresolutionchanged(const QString &resolution) } } else { - qDebug() << "Getting v4l2 resolution"; + qCDebug(appLog) << "Getting v4l2 resolution"; int nWidth = v4l2core_get_frame_width(get_v4l2_device_handler()); int nHeight = v4l2core_get_frame_height(get_v4l2_device_handler()); @@ -1082,7 +1084,7 @@ void videowidget::slotresolutionchanged(const QString &resolution) request_format_update(1); } } - qDebug() << "Exiting slotresolutionchanged"; + qCDebug(appLog) << "Exiting slotresolutionchanged"; } void videowidget::slotGridTypeChanged(int type) @@ -1113,7 +1115,7 @@ void videowidget::onRecordAudio(uchar *data, uint size) void videowidget::onEndBtnClicked() { - qDebug() << "End button clicked, stopping recording"; + qCDebug(appLog) << "End button clicked, stopping recording"; if (m_countTimer->isActive()) m_countTimer->stop(); @@ -1162,7 +1164,7 @@ void videowidget::onEndBtnClicked() time.start(); int duration = 0; if (getCapStatus()) { //录制完成处理 - qDebug() << "stop takeVideo"; + qCDebug(appLog) << "stop takeVideo"; if (DataManager::instance()->encodeEnv() == FFmpeg_Env) { if (video_capture_get_save_video() == 1) { @@ -1191,7 +1193,7 @@ void videowidget::onEndBtnClicked() emit takeVdDone(); } - qInfo() << QString("-------------------stop record cost[%1]ms..----------------\n").arg(time.elapsed()); + qCInfo(appLog) << QString("-------------------stop record cost[%1]ms..----------------\n").arg(time.elapsed()); QJsonObject obj { {"tid", EventLogUtils::EndRecording}, @@ -1206,23 +1208,23 @@ void videowidget::onEndBtnClicked() if (recordBtn) recordBtn->blockSignals(false); #endif - qDebug() << "Recording stopped, duration:" << duration << "ms"; + qCDebug(appLog) << "Recording stopped, duration:" << duration << "ms"; } void videowidget::onRestartDevices() { - qDebug() << "Entering onRestartDevices"; + qCDebug(appLog) << "Entering onRestartDevices"; if (m_isLockedScreen) { - qDebug() << __func__ << "bypass reason(locked screen)"; + qCDebug(appLog) << __func__ << "bypass reason(locked screen)"; return; } if (DataManager::instance()->getdevStatus() != CAM_CANUSE) { - qDebug() << "Device status is not CAM_CANUSE"; + qCDebug(appLog) << "Device status is not CAM_CANUSE"; onChangeDev(); if (DataManager::instance()->getdevStatus() == CAM_CANUSE) { - qDebug() << "Device status is changed to CAM_CANUSE"; + qCDebug(appLog) << "Device status is changed to CAM_CANUSE"; emit sigDeviceChange(); QPalette plt = palette(); plt.setColor(QPalette::Window, Qt::white); @@ -1233,12 +1235,12 @@ void videowidget::onRestartDevices() } } - qDebug() << "Exiting onRestartDevices"; + qCDebug(appLog) << "Exiting onRestartDevices"; } void videowidget::onChangeDev() { - qDebug() << "Changing camera device"; + qCDebug(appLog) << "Changing camera device"; v4l2_dev_t *devicehandler = get_v4l2_device_handler(); if (m_imgPrcThread != nullptr) @@ -1248,14 +1250,14 @@ void videowidget::onChangeDev() QString str; if (devicehandler != nullptr) { - qDebug() << "Closing v4l2 device handler"; + qCDebug(appLog) << "Closing v4l2 device handler"; str = QString(devicehandler->videodevice); close_v4l2_device_handler(); } v4l2_device_list_t *devlist = get_device_list(); if (devlist == nullptr) { - qWarning() << "get device list FAILED"; + qCWarning(appLog) << "get device list FAILED"; return; } @@ -1269,7 +1271,7 @@ void videowidget::onChangeDev() // 如果 devlist 在 vGroupData 使用完毕前被释放,将导致悬空指针,引发崩溃。 // 好在 vGroupData 只在本函数中使用,不会在其他地方被引用,所以不会导致悬空指针问题。 groupNum = getUSBCameraGroup(devlist, vGroupData); - qInfo() << __func__ << "groupNum:" << groupNum; + qCInfo(appLog) << __func__ << "groupNum:" << groupNum; } // 如果摄像头设备个数为0,分组情况就不用考虑了,直接显示无摄像头提示 if (devlist->num_devices == 0) { @@ -1323,26 +1325,26 @@ void videowidget::onChangeDev() } } } - qDebug() << "Camera device change complete"; + qCDebug(appLog) << "Camera device change complete"; } int videowidget::switchCamera(const char *device, const char *devName) { - qDebug() << "Switching camera to device:" << (device ? device : "null"); + qCDebug(appLog) << "Switching camera to device:" << (device ? device : "null"); if (NULL == device) { return -1; } int ret = -1; if (DataManager::instance()->encodeEnv() != QCamera_Env) { - qDebug() << "encodeEnv is not QCamera_Env"; + qCDebug(appLog) << "encodeEnv is not QCamera_Env"; ret = camInit(device); } else { - qDebug() << "encodeEnv is QCamera_Env"; + qCDebug(appLog) << "encodeEnv is QCamera_Env"; ret = 0; } - qInfo() << "Camera init:" << ret; + qCInfo(appLog) << "Camera init:" << ret; if (ret == E_OK) { - qDebug() << "ret is E_OK"; + qCDebug(appLog) << "ret is E_OK"; m_imgPrcThread->init(); m_imgPrcThread->start(); DataManager::instance()->setdevStatus(CAM_CANUSE); @@ -1351,23 +1353,23 @@ int videowidget::switchCamera(const char *device, const char *devName) emit switchCameraSuccess(devName); } dc::Settings::get().setBackOption("device", device); - qDebug() << "Camera switch successful to device:" << (devName ? devName : "unknown"); + qCDebug(appLog) << "Camera switch successful to device:" << (devName ? devName : "unknown"); } else if (ret == E_FORMAT_ERR) { - qDebug() << "ret is E_FORMAT_ERR"; + qCDebug(appLog) << "ret is E_FORMAT_ERR"; v4l2_dev_t *vd = get_v4l2_device_handler(); if (vd != nullptr) close_v4l2_device_handler(); - qWarning() << "camInit failed"; + qCWarning(appLog) << "camInit failed"; if (DataManager::instance()->getdevStatus() != CAM_CANNOT_USE) showCamUsed(); DataManager::instance()->setdevStatus(CAM_CANNOT_USE); - qWarning() << "Camera switch failed - Format error"; + qCWarning(appLog) << "Camera switch failed - Format error"; } else { - qDebug() << "ret is not E_OK or E_FORMAT_ERR"; + qCDebug(appLog) << "ret is not E_OK or E_FORMAT_ERR"; v4l2_dev_t *vd = get_v4l2_device_handler(); if (vd != nullptr) @@ -1375,9 +1377,9 @@ int videowidget::switchCamera(const char *device, const char *devName) DataManager::instance()->setdevStatus(NOCAM); showNocam(); - qWarning() << "Camera switch failed - Unknown error"; + qCWarning(appLog) << "Camera switch failed - Unknown error"; } - qDebug() << "Exiting switchCamera, ret: " << ret; + qCDebug(appLog) << "Exiting switchCamera, ret: " << ret; return ret; } @@ -1387,7 +1389,7 @@ int videowidget::getUSBCameraGroup(v4l2_device_list_t *devlist, QVector> 来存储分组数据,但我们担心影响现有代码逻辑, // 所以暂时保留 QVector>> 来存储分组数据。 if (devlist == nullptr || devlist->list_devices == nullptr || devlist->num_devices == 0) { - qWarning() << __func__ << "devlist is NULL!"; + qCWarning(appLog) << __func__ << "devlist is NULL!"; return 0; } @@ -1418,7 +1420,7 @@ int videowidget::getUSBCameraGroup(v4l2_device_list_t *devlist, QVector QString { @@ -1442,17 +1444,17 @@ QString videowidget::getSaveFilePrefix() QString prefix = getDistroIdFromDBus(DBUS_SYSTEM_INFO_SERVICE_V1, DBUS_SYSTEM_INFO_PATH_V1, DBUS_SYSTEM_INFO_IFACE_V1); if (!prefix.isEmpty()) { - qDebug() << "Got DistroID from V1:" << prefix; + qCDebug(appLog) << "Got DistroID from V1:" << prefix; return prefix; } prefix = getDistroIdFromDBus(DBUS_SYSTEM_INFO_SERVICE, DBUS_SYSTEM_INFO_PATH, DBUS_SYSTEM_INFO_IFACE); if (!prefix.isEmpty()) { - qDebug() << "Got DistroID from V0:" << prefix; + qCDebug(appLog) << "Got DistroID from V0:" << prefix; return prefix; } - qDebug() << "Exiting getSaveFilePrefix"; + qCDebug(appLog) << "Exiting getSaveFilePrefix"; return filePrefix; } @@ -1463,11 +1465,11 @@ QString videowidget::getSaveVdFolder() const void videowidget::onTakePic(bool bTrue) { - qDebug() << "Take photo triggered:" << bTrue; + qCDebug(appLog) << "Take photo triggered:" << bTrue; g_Enum_Camera_State = PICTURE; if (bTrue) { - qDebug() << "Taking photo"; + qCDebug(appLog) << "Taking photo"; //1、重置状态 if (m_countTimer->isActive()) m_countTimer->stop(); @@ -1490,7 +1492,7 @@ void videowidget::onTakePic(bool bTrue) m_countTimer->start(1000); } } else { - qDebug() << "Taking photo"; + qCDebug(appLog) << "Taking photo"; emit updatePhotoState(CMainWindow::photoNormal); emit takePicCancel(); emit updateBlockSystem(false);//连拍取消时,取消阻止关机 @@ -1515,14 +1517,14 @@ void videowidget::onTakePic(bool bTrue) #endif } - qDebug() << "Photo operation complete"; + qCDebug(appLog) << "Photo operation complete"; } void videowidget::onTakeVideo() //点一次开,再点一次关 { - qDebug() << "Entering onTakeVideo"; + qCDebug(appLog) << "Entering onTakeVideo"; if (m_nInterval >= 0 && m_countTimer->isActive()) { //倒计时期间的处理 - qDebug() << "m_nInterval >= 0 && m_countTimer->isActive()"; + qCDebug(appLog) << "m_nInterval >= 0 && m_countTimer->isActive()"; //向mainwindow 发送录像状态通知信号 emit updateRecordState(photoRecordBtn::Normal); m_nInterval = 0; //下次可开启 @@ -1543,7 +1545,7 @@ void videowidget::onTakeVideo() //点一次开,再点一次关 } if (getCapStatus()) { //录制完成处理 - qDebug() << "stop takeVideo"; + qCDebug(appLog) << "stop takeVideo"; //向mainwindow 发送录像状态通知信号 emit updateRecordState(photoRecordBtn::Normal); if (DataManager::instance()->encodeEnv() == FFmpeg_Env) { @@ -1584,12 +1586,12 @@ void videowidget::onTakeVideo() //点一次开,再点一次关 //向mainwindow 发送录像倒计时状态 emit updateRecordState(photoRecordBtn::preRecord); } - qDebug() << "Video operation complete"; + qCDebug(appLog) << "Video operation complete"; } void videowidget::forbidScrollBar(QGraphicsView *view) { - qDebug() << "Entering forbidScrollBar"; + qCDebug(appLog) << "Entering forbidScrollBar"; view->horizontalScrollBar()->blockSignals(true); view->verticalScrollBar()->blockSignals(true); view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -1598,10 +1600,10 @@ void videowidget::forbidScrollBar(QGraphicsView *view) void videowidget::startTakeVideo() { - qDebug() << "Starting video capture"; + qCDebug(appLog) << "Starting video capture"; #ifdef __sw_64__ if (video_capture_get_save_video() == 1) { - qInfo() << "-------------------------takeVideo reclicked..----------------------"; + qCInfo(appLog) << "-------------------------takeVideo reclicked..----------------------"; return; } #endif @@ -1613,7 +1615,7 @@ void videowidget::startTakeVideo() dir.mkdir(strDefaultVdPath); if (getCapStatus()) { - qDebug() << "stop takeVideo"; + qCDebug(appLog) << "stop takeVideo"; if (DataManager::instance()->encodeEnv() == FFmpeg_Env) stop_encoder_thread(); else if (DataManager::instance()->encodeEnv() == GStreamer_Env) { @@ -1629,9 +1631,9 @@ void videowidget::startTakeVideo() reset_video_timer(); emit updateBlockSystem(false); } else { - qDebug() << "GetCapStatus is false"; + qCDebug(appLog) << "GetCapStatus is false"; if (DataManager::instance()->getdevStatus() == CAM_CANUSE) { - qDebug() << "start takeVideo"; + qCDebug(appLog) << "start takeVideo"; DataManager::instance()->getstrFileName() = getSaveFilePrefix() + QDateTime::currentDateTime().toString("yyyyMMddHHmmss") + "_" + QString::number(m_nFileID) + "." + m_videoFormat; emit filename(DataManager::instance()->getstrFileName()); @@ -1679,12 +1681,12 @@ void videowidget::startTakeVideo() m_recordingTimeWidget->move((nWidth - m_recordingTimeWidget->width() - 10) / 2, nHeight - m_recordingTimeWidget->height() - 15); } - qDebug() << "Video capture started with format:" << m_videoFormat; + qCDebug(appLog) << "Video capture started with format:" << m_videoFormat; } void videowidget::startCaptureVideo() { - qDebug() << "Starting video capture with QCamera"; + qCDebug(appLog) << "Starting video capture with QCamera"; QDir dir; QString strDefaultVdPath = QStandardPaths::writableLocation(QStandardPaths::MoviesLocation) + QDir::separator() + "Camera"; @@ -1692,14 +1694,14 @@ void videowidget::startCaptureVideo() dir.mkdir(strDefaultVdPath); if (getCapStatus()) { - qDebug() << "stop takeVideo"; + qCDebug(appLog) << "stop takeVideo"; Camera::instance()->stopRecoder(); setCapStatus(false); reset_video_timer(); emit updateBlockSystem(false); } else { if (DataManager::instance()->getdevStatus() == CAM_CANUSE) { - qDebug() << "start Gstreamer takeVideo"; + qCDebug(appLog) << "start Gstreamer takeVideo"; DataManager::instance()->getstrFileName() = getSaveFilePrefix() + QDateTime::currentDateTime().toString("yyyyMMddHHmmss") + "_" + QString::number(m_nFileID); emit filename(DataManager::instance()->getstrFileName()); m_nFileID ++; @@ -1734,12 +1736,12 @@ void videowidget::startCaptureVideo() m_recordingTimeWidget->move((nWidth - m_recordingTimeWidget->width() - 10) / 2, nHeight - m_recordingTimeWidget->height() - 15); } - qDebug() << "QCamera video capture started"; + qCDebug(appLog) << "QCamera video capture started"; } void videowidget::itemPosChange() { - qDebug() << "Entering itemPosChange"; + qCDebug(appLog) << "Entering itemPosChange"; m_pCamErrItem->setPos((m_pSvgItem->boundingRect().width() - static_cast(m_pCamErrItem->boundingRect().width())) / 2, m_pSvgItem->boundingRect().height()); // x轴布局居中,y轴在一级提示控件的下方 m_pCamErrItemSub->setPos((m_pSvgItem->boundingRect().width() - static_cast(m_pCamErrItemSub->boundingRect().width())) / 2, m_pSvgItem->boundingRect().height() + m_pCamErrItem->boundingRect().height()); @@ -1751,7 +1753,7 @@ void videowidget::itemPosChange() void videowidget::stopEverything() { - qDebug() << "Entering stopEverything"; + qCDebug(appLog) << "Entering stopEverything"; if (m_countTimer->isActive()) m_countTimer->stop(); @@ -1774,19 +1776,19 @@ void videowidget::stopEverything() if (!m_openglwidget->isVisible()) m_openglwidget->show(); #endif - qDebug() << "Exiting stopEverything"; + qCDebug(appLog) << "Exiting stopEverything"; } void videowidget::onThemeTypeChanged(DGuiApplicationHelper::ColorType themeType) { - qDebug() << "Entering onThemeTypeChanged"; + qCDebug(appLog) << "Entering onThemeTypeChanged"; if (m_pSvgItem->isVisible()) { - qDebug() << "m_pSvgItem is visible"; + qCDebug(appLog) << "m_pSvgItem is visible"; QString str, strsub; if (themeType == DGuiApplicationHelper::LightType) { - qDebug() << "themeType is LightType"; + qCDebug(appLog) << "themeType is LightType"; if (DataManager::instance()->getdevStatus() == NOCAM) { - qDebug() << "DataManager::instance()->getdevStatus() == NOCAM"; + qCDebug(appLog) << "DataManager::instance()->getdevStatus() == NOCAM"; if (DataManager::instance()->isSupportCameraSwitch()) { m_pSvgItem->setSharedRenderer(new QSvgRenderer(QString(":/images/icons/light/camera_switch_not_on.svg"), this)); strsub = tr("Your camera might not be turned on. If you need to use it, please check whether the hardware switch of the camera or the camera hotkey on the keyboard is enabled"); @@ -1806,9 +1808,9 @@ void videowidget::onThemeTypeChanged(DGuiApplicationHelper::ColorType themeType) m_pCamErrItemSub->setDefaultTextColor(clrText); m_pCamErrItemSub->setPlainText(strsub); } else if (themeType == DGuiApplicationHelper::DarkType) { - qDebug() << "themeType is DarkType"; + qCDebug(appLog) << "themeType is DarkType"; if (DataManager::instance()->getdevStatus() == NOCAM) { - qDebug() << "changed theme 3"; + qCDebug(appLog) << "changed theme 3"; if (DataManager::instance()->isSupportCameraSwitch()) { m_pSvgItem->setSharedRenderer(new QSvgRenderer(QString(":/images/icons/dark/camera_switch_not_on_dark.svg"), this)); strsub = tr("Your camera might not be turned on. If you need to use it, please check whether the hardware switch of the camera or the camera hotkey on the keyboard is enabled"); @@ -1817,7 +1819,7 @@ void videowidget::onThemeTypeChanged(DGuiApplicationHelper::ColorType themeType) } str = tr("No webcam found");//未连接摄像头 } else {//仅CAM_CANNOT_USE - qDebug() << "changed theme 4"; + qCDebug(appLog) << "changed theme 4"; m_pSvgItem->setSharedRenderer(new QSvgRenderer(QString(":/images/icons/dark/Take up_dark.svg"), this)); str = tr("The webcam is in use");//摄像头已被占用 } @@ -1838,11 +1840,11 @@ void videowidget::onThemeTypeChanged(DGuiApplicationHelper::ColorType themeType) ftsub.setPixelSize(12); m_pCamErrItemSub->setFont(ftsub); if (DataManager::instance()->getdevStatus() == NOCAM) { - qDebug() << "DataManager::instance()->getdevStatus() == NOCAM"; + qCDebug(appLog) << "DataManager::instance()->getdevStatus() == NOCAM"; m_pNormalScene->setSceneRect(m_pSvgItem->boundingRect()); itemPosChange(); } else { - qDebug() << "DataManager::instance()->getdevStatus() != NOCAM"; + qCDebug(appLog) << "DataManager::instance()->getdevStatus() != NOCAM"; m_pNormalScene->setSceneRect(m_pSvgItem->boundingRect()); itemPosChange(); } @@ -1850,22 +1852,22 @@ void videowidget::onThemeTypeChanged(DGuiApplicationHelper::ColorType themeType) if (m_flashLabel->isVisible()) m_flashLabel->hide(); } - qDebug() << "Exiting onThemeTypeChanged"; + qCDebug(appLog) << "Exiting onThemeTypeChanged"; } void videowidget::setHorizontalMirror(bool bMirror) { - qDebug() << "Entering setHorizontalMirror"; + qCDebug(appLog) << "Entering setHorizontalMirror"; if (nullptr != m_imgPrcThread) { - qDebug() << "m_imgPrcThread is not nullptr"; + qCDebug(appLog) << "m_imgPrcThread is not nullptr"; m_imgPrcThread->setHorizontalMirror(bMirror); } - qDebug() << "Exiting setHorizontalMirror"; + qCDebug(appLog) << "Exiting setHorizontalMirror"; } void videowidget::setCapStatus(bool status) { - qDebug() << "Entering setCapStatus"; + qCDebug(appLog) << "Entering setCapStatus"; m_bActive = status; if (DataManager::instance()->encodeEnv() == GStreamer_Env) m_imgPrcThread->setRecording(status); @@ -1885,7 +1887,7 @@ void videowidget::setMaxRecTime(int hour) void videowidget::setFilterType(efilterType type) { - qDebug() << "Entering setFilterType"; + qCDebug(appLog) << "Entering setFilterType"; m_filterType = type; if (m_imgPrcThread) m_imgPrcThread->setFilter(filterPreviewButton::filterName_CUBE(type)); @@ -1893,7 +1895,7 @@ void videowidget::setFilterType(efilterType type) void videowidget::setState(bool bPhoto) { - qDebug() << "Entering setState"; + qCDebug(appLog) << "Entering setState"; m_bPhoto = bPhoto; if (m_imgPrcThread) m_imgPrcThread->setState(bPhoto); @@ -1901,13 +1903,13 @@ void videowidget::setState(bool bPhoto) QRect videowidget::getFrameRect() { - qDebug() << "Entering getFrameRect"; + qCDebug(appLog) << "Entering getFrameRect"; QRect rect; if (m_openglwidget && m_openglwidget->isVisible()) { - qDebug() << "m_openglwidget is visible"; + qCDebug(appLog) << "m_openglwidget is visible"; rect = m_openglwidget->geometry(); } else if (m_pNormalView && m_pNormalView->isVisible()) { - qDebug() << "m_pNormalView is visible"; + qCDebug(appLog) << "m_pNormalView is visible"; if (m_pNormalItem && m_pNormalItem->isVisible()) rect = QRect(m_pNormalView->mapFromScene(0,0), m_pNormalView->mapFromScene(m_pNormalView->sceneRect().bottomRight())); } @@ -1917,7 +1919,7 @@ QRect videowidget::getFrameRect() void videowidget::setGridType(GridType type) { - qDebug() << "Setting grid type:" << type; + qCDebug(appLog) << "Setting grid type:" << type; if (type == m_GridType) return; @@ -1941,12 +1943,12 @@ void videowidget::setGridType(GridType type) } } } - qDebug() << "Grid type updated"; + qCDebug(appLog) << "Grid type updated"; } void videowidget::onExposureChanged(int exposure) { - qDebug() << "Exposure changed to:" << exposure; + qCDebug(appLog) << "Exposure changed to:" << exposure; m_exposure = exposure; if (m_imgPrcThread) m_imgPrcThread->setExposure(exposure); @@ -1954,7 +1956,7 @@ void videowidget::onExposureChanged(int exposure) void videowidget::onFilterDisplayChanged(int bDisplay) { - qDebug() << "Filter display changed:" << bDisplay; + qCDebug(appLog) << "Filter display changed:" << bDisplay; if (m_imgPrcThread) m_imgPrcThread->setFilterGroupState(bDisplay); } @@ -1964,32 +1966,32 @@ QString videowidget::getFirstValidDevice() // 加锁,确保线程安全 QReadLocker locker(&m_mutexValidDevices); if (m_validDevices.isEmpty()) { - qWarning() << __func__ << "no valid device!"; + qCWarning(appLog) << __func__ << "no valid device!"; return ""; } // 返回第一个有效相机设备的设备节点路径 const ValidDevice &dev = m_validDevices.first(); - qInfo() << __func__ << dev.getVid() << dev.getPid() << dev.getName() << dev.getDevice(); + qCInfo(appLog) << __func__ << dev.getVid() << dev.getPid() << dev.getName() << dev.getDevice(); return dev.getDevice(); } void videowidget::updateValidDevices() { - qInfo() << __func__; + qCInfo(appLog) << __func__; // 加锁,确保线程安全 QWriteLocker locker(&m_mutexValidDevices); m_validDevices.clear(); // 清空有效相机设备列表 v4l2_device_list_t *devList = get_device_list(); if (!devList) { - qWarning() << __func__ << "get device list FAILED!"; + qCWarning(appLog) << __func__ << "get device list FAILED!"; return; } v4l2_dev_sys_data_t *v4l2_devices = devList->list_devices; if (!v4l2_devices) { - qWarning() << __func__ << "get device list FAILED!"; + qCWarning(appLog) << __func__ << "get device list FAILED!"; return; } @@ -1998,13 +2000,13 @@ void videowidget::updateValidDevices() QString vid = formatDeviceId(v4l2_devices[i].vendor); QString pid = formatDeviceId(v4l2_devices[i].product); if (DataManager::instance()->isDeviceValid(vid, pid, v4l2_devices[i].name)) { - qInfo() << __func__ << "found valid device:" << vid << pid << v4l2_devices[i].name << v4l2_devices[i].device; + qCInfo(appLog) << __func__ << "found valid device:" << vid << pid << v4l2_devices[i].name << v4l2_devices[i].device; // 添加有效相机设备 m_validDevices.push_back(ValidDevice(vid, pid, v4l2_devices[i].name, v4l2_devices[i].device)); continue; } - qInfo() << __func__ << "found invalid device(blacklist):" << vid << pid << v4l2_devices[i].name << v4l2_devices[i].device; + qCInfo(appLog) << __func__ << "found invalid device(blacklist):" << vid << pid << v4l2_devices[i].name << v4l2_devices[i].device; } } @@ -2034,7 +2036,7 @@ int videowidget::getValidDeviceNum() videowidget::~videowidget() { - qDebug() << "Cleaning up VideoWidget"; + qCDebug(appLog) << "Cleaning up VideoWidget"; m_imgPrcThread->stop(); m_imgPrcThread->wait(); delete m_imgPrcThread; @@ -2093,5 +2095,5 @@ videowidget::~videowidget() m_videoWriter = nullptr; camUnInit(); - qDebug() << "VideoWidget cleanup complete"; + qCDebug(appLog) << "VideoWidget cleanup complete"; } diff --git a/src/src/windowstatethread.cpp b/src/src/windowstatethread.cpp index 05ad40ec..c9fa8210 100644 --- a/src/src/windowstatethread.cpp +++ b/src/src/windowstatethread.cpp @@ -1,5 +1,5 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// Copyright (C) 2020 - 2026 Uniontech Software Technology Co.,Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -8,22 +8,24 @@ #include #include +#include "ddlog.h" +using namespace DDLog; windowStateThread::windowStateThread(bool isWayland, QObject *parent /*= nullptr*/) : QThread (parent) { setObjectName("windowStateThread"); - qDebug() << "Initializing window state monitoring thread, Wayland:" << isWayland; + qCDebug(appLog) << "Initializing window state monitoring thread, Wayland:" << isWayland; } windowStateThread::~windowStateThread() { - qDebug() << "Cleaning up window state monitoring thread"; + qCDebug(appLog) << "Cleaning up window state monitoring thread"; } void windowStateThread::run() { - qDebug() << "Starting window state monitoring loop"; + qCDebug(appLog) << "Starting window state monitoring loop"; while (!isInterruptionRequested()) { #ifdef UNITTEST // 单元测试环境下跳过 workspaceWindows(), @@ -32,11 +34,11 @@ void windowStateThread::run() #endif //获取当前工作区域内所有的窗口 auto list = workspaceWindows(); - qDebug() << "Found" << list.size() << "windows in workspace"; + qCDebug(appLog) << "Found" << list.size() << "windows in workspace"; foreach(DForeignWindow *window, list) { if (window && window->windowState() == Qt::WindowState::WindowFullScreen) { - qDebug() << "Detected fullscreen window:" << window->title(); + qCDebug(appLog) << "Detected fullscreen window:" << window->title(); //去掉全屏的窗口信号处理 //emit someWindowFullScreen(); } @@ -44,22 +46,22 @@ void windowStateThread::run() //线程休眠1秒 std::this_thread::sleep_for(std::chrono::seconds(1)); } - qInfo() << "Window state monitoring thread ended"; + qCInfo(appLog) << "Window state monitoring thread ended"; } QList windowStateThread::workspaceWindows() const { - qDebug() << "Getting workspace windows list"; + qCDebug(appLog) << "Getting workspace windows list"; QList windowList; QList currentApplicationWindowList; const QWindowList &list = qApp->allWindows(); currentApplicationWindowList.reserve(list.size()); - qDebug() << "Total application windows:" << list.size(); + qCDebug(appLog) << "Total application windows:" << list.size(); for (auto window : list) { if (window->property("_q_foreignWinId").isValid()) { - qDebug() << "Skipping foreign window"; + qCDebug(appLog) << "Skipping foreign window"; continue; } @@ -67,13 +69,13 @@ QList windowStateThread::workspaceWindows() const } QVector wmClientList = DWindowManagerHelper::instance()->currentWorkspaceWindowIdList(); - qDebug() << "Window manager client list size:" << wmClientList.size(); + qCDebug(appLog) << "Window manager client list size:" << wmClientList.size(); bool currentWindow = false; for (WId wid : wmClientList) { if (currentApplicationWindowList.contains(wid)){ currentWindow = true; - qDebug() << "Found current application window:" << wid; + qCDebug(appLog) << "Found current application window:" << wid; continue; } if (false == currentWindow){ @@ -81,10 +83,10 @@ QList windowStateThread::workspaceWindows() const } if (DForeignWindow *w = DForeignWindow::fromWinId(wid)) { windowList << w; - qDebug() << "Added foreign window to list:" << w->title(); + qCDebug(appLog) << "Added foreign window to list:" << w->title(); } } - qDebug() << "Returning" << windowList.size() << "workspace windows"; + qCDebug(appLog) << "Returning" << windowList.size() << "workspace windows"; return windowList; }