Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions assets/configs/org.deepin.picker.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"magic": "dsg.config.meta",
"version": "1.0",
"contents": {
"log_rules": {
"value": "org.deepin.picker*.debug=false;org.deepin.picker*.info=false;org.deepin.picker*.warning=true",
"serial": 0,
"flags": [
"global"
],
"name": "log rules",
"name[zh_CN]": "日志规则",
"description": "log rules",
"description[zh_CN]": "日志规则",
"permissions": "readwrite",
"visibility": "public"
}
}
}
11 changes: 9 additions & 2 deletions deepin-picker.pro
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ HEADERS += \
src/animation.h \
src/dbusnotify.h \
src/settings.h \
src/utils.h
src/utils.h \
src/logger.h \
src/ddlog.h
SOURCES += \
src/cpickermanager.cpp \
src/desktopinfo.cpp \
Expand All @@ -51,6 +53,7 @@ SOURCES += \
src/dbusnotify.cpp \
src/settings.cpp \
src/utils.cpp \
src/logger.cpp \
src/main.cpp

# 移除不必要的注释
Expand Down Expand Up @@ -82,7 +85,11 @@ manual.files = manual/*
dbus_service.files = $$PWD/com.deepin.Picker.service
dbus_service.path = $$PREFIX/share/dbus-1/services

INSTALLS += target icon desktop manual dbus_service
# DConfig 元数据(调试模式动态日志级别读取的默认规则)
dconfig_meta.files = $$PWD/assets/configs/org.deepin.picker.json
dconfig_meta.path = $$PREFIX/share/dsg/configs/org.deepin.picker

INSTALLS += target icon desktop manual dbus_service dconfig_meta

isEmpty(TRANSLATIONS) {
include(translations.pri)
Expand Down
14 changes: 7 additions & 7 deletions src/animation.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// SPDX-FileCopyrightText: 2011-2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2011-2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "animation.h"
#include "utils.h"
#include <QApplication>

Check warning on line 7 in src/animation.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QColor>

Check warning on line 8 in src/animation.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QColor> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QPainter>

Check warning on line 9 in src/animation.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QPainter> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDebug>
#include "ddlog.h"
#include <QPainterPath>

Check warning on line 11 in src/animation.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QPainterPath> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Animation::Animation(int x, int y, QPixmap pixmap, QColor color, QWidget *parent) : QWidget(parent)
{
qDebug() << "Initializing animation at position:" << x << y << "with color:" << color.name();
qCDebug(appLog) << "Initializing animation at position:" << x << y << "with color:" << color.name();

// Init window flags to make window transparent and get correctly behavior.
setWindowFlags(Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint);
Expand Down Expand Up @@ -42,12 +42,12 @@
renderTimer = new QTimer();
connect(renderTimer, &QTimer::timeout, this, &Animation::renderAnimation);
renderTimer->start(animationDuration);
qDebug() << "Animation timer started with duration:" << animationDuration << "ms";
qCDebug(appLog) << "Animation timer started with duration:" << animationDuration << "ms";
}

Animation::~Animation()
{
qDebug() << "Destroying animation instance";
qCDebug(appLog) << "Destroying animation instance";
delete renderTimer;
}

Expand Down Expand Up @@ -79,11 +79,11 @@
{
if (renderTicker < animationFrames) {
renderTicker++;
qDebug() << "Animation frame:" << renderTicker << "/" << animationFrames;
qCDebug(appLog) << "Animation frame:" << renderTicker << "/" << animationFrames;
repaint();
} else {
renderTimer->stop();
qInfo() << "Animation completed, hiding window";
qCInfo(appLog) << "Animation completed, hiding window";
hide(); // hide window when animation finish

emit finish();
Expand Down
12 changes: 6 additions & 6 deletions src/colormenu.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2011-2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2011-2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand All @@ -9,14 +9,14 @@
#include <QPoint>
#include <QPen>
#include <QTimer>
#include <QClipboard>

Check warning on line 12 in src/colormenu.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QClipboard> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QPainter>

Check warning on line 13 in src/colormenu.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QPainter> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QApplication>

Check warning on line 14 in src/colormenu.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDebug>
#include "ddlog.h"

ColorMenu::ColorMenu(int x, int y, int size, QColor color, QWidget *parent) : QWidget(parent)
{
qDebug() << "Initializing color menu at position:" << x << y << "with size:" << size << "and color:" << color.name();
qCDebug(appLog) << "Initializing color menu at position:" << x << y << "with size:" << size << "and color:" << color.name();

// Init window flags.
setWindowFlags(Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint);
Expand Down Expand Up @@ -49,7 +49,7 @@
connect(colorMenu, &QMenu::aboutToHide, this, [&]() {
QTimer::singleShot(200, this, [&]() {
if (!clickMenuItem) {
qDebug() << "Menu closed without selection, exiting";
qCDebug(appLog) << "Menu closed without selection, exiting";
exit();
}
});
Expand Down Expand Up @@ -94,7 +94,7 @@
// Set menu action check status with color type.
Settings *settings = new Settings();
QString colorType = settings->getOption("color_type", "HEX").toString();
qDebug() << "Loading saved color type preference:" << colorType;
qCDebug(appLog) << "Loading saved color type preference:" << colorType;

if (colorType == "HEX") {
hexAction->setChecked(true);
Expand All @@ -119,7 +119,7 @@

ColorMenu::~ColorMenu()
{
qDebug() << "Destroying color menu instance";
qCDebug(appLog) << "Destroying color menu instance";
delete hexAction;
delete rgbAction;
delete rgbFloatAction;
Expand Down
42 changes: 21 additions & 21 deletions src/cpickermanager.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2022-2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand All @@ -6,10 +6,10 @@
#include <QWindow>
#include <QPainter>
#include <QScreen>
#include <QApplication>

Check warning on line 9 in src/cpickermanager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QKeyEvent>

Check warning on line 10 in src/cpickermanager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QKeyEvent> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <DRegionMonitor>

Check warning on line 11 in src/cpickermanager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DRegionMonitor> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDebug>
#include "ddlog.h"
#include <QDBusInterface>
#include <QDBusReply>
#include <QPainterPath>
Expand All @@ -25,7 +25,7 @@
CScreenshotWidget::CScreenshotWidget(CPickerManager *parent): QWidget(nullptr),
_parentManager(parent)
{
qDebug() << "Initializing screenshot widget";
qCDebug(appLog) << "Initializing screenshot widget";
//为顶层窗口
this->setWindowFlags(this->windowFlags() | Qt::Window | Qt::FramelessWindowHint
| Qt::X11BypassWindowManagerHint | Qt::WindowStaysOnTopHint);
Expand Down Expand Up @@ -59,7 +59,7 @@
{
//wayland下 DRegionMonitor::keyPress会失效,这里会响应
if (event->matches(QKeySequence::Cancel)) {
qDebug() << "Escape key pressed, exiting application";
qCDebug(appLog) << "Escape key pressed, exiting application";
QApplication::quit();
}
QWidget::keyPressEvent(event);
Expand All @@ -83,13 +83,13 @@

CPickerManager::CPickerManager(): QObject(nullptr)
{
qDebug() << "Initializing color picker manager";
qCDebug(appLog) << "Initializing color picker manager";
const int windowHeight = 236;
const int windowWidth = 236;
qreal radio = qApp->devicePixelRatio();
_shadowPixmap = QPixmap(Utils::getQrcPath("shadow.png"));
if (isWaylandPlatform()) {
qDebug() << "Running on Wayland platform";
qCDebug(appLog) << "Running on Wayland platform";
_shadowPixmap = _shadowPixmap.scaled(windowWidth, windowHeight);
} else {
_shadowPixmap = _shadowPixmap.scaled(windowWidth / radio, windowHeight / radio, Qt::KeepAspectRatio, Qt::SmoothTransformation);
Expand All @@ -103,7 +103,7 @@

QObject::connect(eventMonitor, &DRegionMonitor::keyPress, this, [ = ](const QString & name) {
if (name == "Escape") {
qDebug() << "Escape key detected from region monitor, exiting application";
qCDebug(appLog) << "Escape key detected from region monitor, exiting application";
QApplication::quit();
}
});
Expand All @@ -120,7 +120,7 @@
eventMonitor->registerRegion();

if (!eventMonitor->registered()) {
qWarning() << "Failed to register region monitor, exiting application";
qCWarning(appLog) << "Failed to register region monitor, exiting application";
QApplication::quit();
}
ensureDeskTopPixmap();
Expand All @@ -136,12 +136,12 @@

CPickerManager::~CPickerManager()
{
qDebug() << "Destroying color picker manager";
qCDebug(appLog) << "Destroying color picker manager";
}

void CPickerManager::setLanchFlag(CPickerManager::ELanchType tp, const QString &appName)
{
qDebug() << "Setting launch flag:" << tp << "for application:" << appName;
qCDebug(appLog) << "Setting launch flag:" << tp << "for application:" << appName;
_isLaunchByDBus = tp;
if (_isLaunchByDBus == ELanchedByOtherApp)
_appid = appName;
Expand All @@ -159,7 +159,7 @@

void CPickerManager::StartPick(const QString &id)
{
qDebug() << "Starting color pick with ID:" << id;
qCDebug(appLog) << "Starting color pick with ID:" << id;
_appid = id;
}

Expand All @@ -181,12 +181,12 @@
//wayland触摸屏下的点击是DRegionMonitor::Button_Middle,鼠标左键点击DRegionMonitor::Button_Left。无法区分是鼠标左键还是触摸屏,故支持中键点击
//最佳方案是TDK将触摸屏点击修改成左键点击。。。。。。。
if (button != DRegionMonitor::Button_Left && button != DRegionMonitor::Button_Middle) {
qDebug() << "Ignoring non-left/middle button press on Wayland";
qCDebug(appLog) << "Ignoring non-left/middle button press on Wayland";
return;
}
} else {
if (button != DRegionMonitor::Button_Left) {
qDebug() << "Ignoring non-left button press";
qCDebug(appLog) << "Ignoring non-left button press";
return;
}
}
Expand All @@ -205,14 +205,14 @@
// Rest color type to hex if config file not exist.
Settings settings;
QString colorType = settings.getOption("color_type", "HEX").toString();
qDebug() << "Color picked:" << _curColor.name() << "in format:" << colorType;
qCDebug(appLog) << "Color picked:" << _curColor.name() << "in format:" << colorType;

// Emit copyColor signal to copy color to system clipboard.
copyColor(_curColor, colorType);

// Send colorPicked signal when call by DBus and no empty appid.
if (_appid != "") {
qDebug() << "Sending color picked signal to application:" << _appid;
qCDebug(appLog) << "Sending color picked signal to application:" << _appid;
colorPicked(_appid, Utils::colorToHex(_curColor));
}
}
Expand All @@ -226,15 +226,15 @@

void CPickerManager::initShotScreenWidgets()
{
qDebug() << "Initializing screen shot widgets";
qCDebug(appLog) << "Initializing screen shot widgets";
ensureDeskTopPixmap();
auto screens = QApplication::screens();
//去出复制屏
int i = 0;
while (i < screens.size()) {
for (int j = screens.size() - 1; j > i; j--) {
if (screens.at(i)->geometry().topLeft() == screens.at(j)->geometry().topLeft()) {
qDebug() << "Removing duplicate screen at index:" << j;
qCDebug(appLog) << "Removing duplicate screen at index:" << j;
screens.removeAt(j);
}
}
Expand All @@ -259,7 +259,7 @@

// 解决 wayland 下调出取色器后点击 Esc 无法退出取色器
if (isWaylandPlatform()) {
qDebug() << "Setting up Wayland-specific window activation";
qCDebug(appLog) << "Setting up Wayland-specific window activation";
// 延迟 200ms 后取得当前背景窗口的焦点,用以捕获 Esc 按键退出
QTimer::singleShot(200, this, [ = ]() {
auto currentWidget = _widgets.value(qApp->screenAt(QCursor::pos()));
Expand Down Expand Up @@ -348,7 +348,7 @@
void CPickerManager::ensureDeskTopPixmap()
{
if (_desktopPixmapDirty) {
qDebug() << "Updating desktop pixmap";
qCDebug(appLog) << "Updating desktop pixmap";
_desktopPixmap = getDesktopPixmap();
_desktopPixmapDirty = false;
}
Expand Down Expand Up @@ -384,7 +384,7 @@
QPixmap result;
bool iswayLand = isWaylandPlatform();
if (iswayLand) {
qDebug() << "Getting desktop pixmap via KWin DBus interface";
qCDebug(appLog) << "Getting desktop pixmap via KWin DBus interface";
QPixmap res;
QDBusInterface kwinInterface(QStringLiteral("org.kde.KWin"),
QStringLiteral("/Screenshot"),
Expand All @@ -397,7 +397,7 @@
}
result = res;
} else {
qDebug() << "Getting desktop pixmap via screen grab";
qCDebug(appLog) << "Getting desktop pixmap via screen grab";
QPixmap pixs(getDeskTopRect().size());
pixs.fill(Qt::transparent);
QPainter painter(&pixs);
Expand Down
15 changes: 15 additions & 0 deletions src/ddlog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef DDLOG_H
#define DDLOG_H

#include <QDebug>
#include <QLoggingCategory>

// 全项目统一的日志分类,便于 DConfig 调试模式(deepin-debug-config)按应用统一过滤。
// deepin-picker 为单进程应用,仅一个分类;如需子分类,按 org.deepin.picker.<子模块> 命名。
inline Q_LOGGING_CATEGORY(appLog, "org.deepin.picker")

#endif // DDLOG_H
Loading
Loading