Skip to content
Open
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
8 changes: 7 additions & 1 deletion dtkwidget.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

# Export all symbols on Windows
if(WIN32 AND NOT MSVC)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--export-all-symbols")
endif()

message(STATUS "Current Qt Version: ${QT_VERSION_MAJOR}")
message(STATUS "Current Dtk Version: ${DTK_VERSION_MAJOR}")

Expand Down Expand Up @@ -44,7 +49,8 @@ find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core
Widgets
PrintSupport
LinguistTools
DBus)
DBus
Svg)
find_package(PkgConfig REQUIRED)

if("${QT_VERSION_MAJOR}" STREQUAL "5")
Expand Down
28 changes: 18 additions & 10 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
if("${QT_VERSION_MAJOR}" STREQUAL "5")
pkg_check_modules(QGSettings REQUIRED IMPORTED_TARGET gsettings-qt) #Dtk6 removed.
endif()
pkg_check_modules(XcbUtil REQUIRED IMPORTED_TARGET xcb-util)
pkg_check_modules(StartupNotification REQUIRED IMPORTED_TARGET libstartup-notification-1.0)
pkg_check_modules(Xext REQUIRED IMPORTED_TARGET xext)
pkg_check_modules(Xi REQUIRED IMPORTED_TARGET xi)
pkg_check_modules(X11 REQUIRED IMPORTED_TARGET x11)
if(LINUX)
pkg_check_modules(XcbUtil REQUIRED IMPORTED_TARGET xcb-util)
pkg_check_modules(StartupNotification REQUIRED IMPORTED_TARGET libstartup-notification-1.0)
pkg_check_modules(Xext REQUIRED IMPORTED_TARGET xext)
pkg_check_modules(Xi REQUIRED IMPORTED_TARGET xi)
pkg_check_modules(X11 REQUIRED IMPORTED_TARGET x11)
endif()

include(util/util.cmake)
include(widgets/widgets.cmake)
Expand Down Expand Up @@ -69,19 +71,25 @@ PUBLIC
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::DBus
Qt${QT_VERSION_MAJOR}::PrintSupport
Qt${QT_VERSION_MAJOR}::Svg
Dtk${DTK_NAME_SUFFIX}::Gui
Dtk${DTK_NAME_SUFFIX}::Core
PRIVATE
Qt${QT_VERSION_MAJOR}::Concurrent
Qt${QT_VERSION_MAJOR}::GuiPrivate
Qt${QT_VERSION_MAJOR}::WidgetsPrivate
Qt${QT_VERSION_MAJOR}::PrintSupportPrivate
PkgConfig::StartupNotification
PkgConfig::Xext
PkgConfig::Xi
PkgConfig::X11
PkgConfig::XcbUtil
)
if(LINUX)
target_link_libraries(${LIB_NAME}
PRIVATE
PkgConfig::StartupNotification
PkgConfig::Xext
PkgConfig::Xi
PkgConfig::X11
PkgConfig::XcbUtil
)
endif()

if("${QT_VERSION_MAJOR}" STREQUAL "5")
target_link_libraries(${LIB_NAME} PRIVATE
Expand Down
14 changes: 12 additions & 2 deletions src/widgets/dimageviewer.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: LGPL-3.0-or-later

Expand Down Expand Up @@ -175,7 +175,17 @@ QImage DImageViewerPrivate::loadImage(const QString &fileName, ImageType type) c
case ImageTypeSvg: {
DSvgRenderer render(fileName);
if (render.isValid()) {
#ifdef Q_OS_LINUX
image = render.toImage(render.defaultSize());
#else
QSize sz = render.defaultSize();
if (!sz.isEmpty()) {
image = QImage(sz, QImage::Format_ARGB32);
image.fill(Qt::transparent);
QPainter painter(&image);
render.render(&painter);
}
#endif
}
break;
}
Expand Down Expand Up @@ -224,7 +234,7 @@ qreal DImageViewerPrivate::validRotateAngle(qreal angle) const
{
// From Qt help doc: A rotation transformation of 180 degrees
// and/or 360 degrees is treated as a scaling transformation.
if (qFuzzyCompare(abs(angle), 180)) {
if (qFuzzyCompare(qreal(abs(angle)), qreal(180))) {
// 180 degrees needs adjustment to avoid transformation errors.
return angle + (angle < 0 ? -0.00001 : 0.0001);
} else {
Expand Down
12 changes: 11 additions & 1 deletion src/widgets/dprintpreviewdialog.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 - 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

Expand Down Expand Up @@ -46,13 +46,15 @@
#include <QStandardPaths>
#include <QTimer>
#include <QKeyEvent>
#include <QWindow>

Check warning on line 49 in src/widgets/dprintpreviewdialog.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 49 in src/widgets/dprintpreviewdialog.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

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

Check warning on line 50 in src/widgets/dprintpreviewdialog.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 50 in src/widgets/dprintpreviewdialog.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QLoggingCategory> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <private/qprint_p.h>

Check warning on line 51 in src/widgets/dprintpreviewdialog.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 51 in src/widgets/dprintpreviewdialog.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <private/qprint_p.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#ifdef Q_OS_LINUX
#include <private/qcups_p.h>

Check warning on line 53 in src/widgets/dprintpreviewdialog.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 53 in src/widgets/dprintpreviewdialog.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <private/qcups_p.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#endif
#include <private/qprintdevice_p.h>

Check warning on line 55 in src/widgets/dprintpreviewdialog.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 55 in src/widgets/dprintpreviewdialog.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <private/qprintdevice_p.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <qpa/qplatformprintplugin.h>

Check warning on line 56 in src/widgets/dprintpreviewdialog.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 56 in src/widgets/dprintpreviewdialog.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <qpa/qplatformprintplugin.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <qpa/qplatformprintersupport.h>

Check warning on line 57 in src/widgets/dprintpreviewdialog.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 57 in src/widgets/dprintpreviewdialog.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

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

#define NORMAL_LEFT_RIGHT 31.8
#define NORMAL_MODERATE_TOP_BOTTRM 25.4
Expand Down Expand Up @@ -1350,10 +1352,18 @@
}
//设置色彩打印
if (supportedColorMode) {
#ifdef Q_OS_LINUX
QByteArray currentColorModel = pview->printerColorModel().isEmpty() ? QByteArrayLiteral("RGB") : pview->printerColorModel();
QCUPSSupport::setCupsOption(printer, "ColorModel", currentColorModel);
#else
Q_UNUSED(pview)
#endif
} else {
#ifdef Q_OS_LINUX
QCUPSSupport::setCupsOption(printer, "ColorModel", "Gray");
#else
Q_UNUSED(printer)
#endif
}
//设置纸张打印边距
printer->setPageMargins(QMarginsF(marginLeftSpin->value(), marginTopSpin->value(), marginRightSpin->value(), marginBottomSpin->value()), QPageLayout::Millimeter);
Expand Down
11 changes: 10 additions & 1 deletion src/widgets/dprintpreviewwidget.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: LGPL-3.0-or-later

Expand All @@ -10,11 +10,13 @@
#include <QtConcurrent>
#include <QtAlgorithms>
#include <QPaintEngine>
#include <DWidgetUtil>

Check warning on line 13 in src/widgets/dprintpreviewwidget.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 13 in src/widgets/dprintpreviewwidget.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

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

Check warning on line 14 in src/widgets/dprintpreviewwidget.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 14 in src/widgets/dprintpreviewwidget.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

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

#ifdef Q_OS_LINUX
#include <cups/cups.h>

Check warning on line 17 in src/widgets/dprintpreviewwidget.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 17 in src/widgets/dprintpreviewwidget.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <cups/cups.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <cups/ppd.h>
#endif


#define FIRST_PAGE 1
Expand Down Expand Up @@ -798,6 +800,7 @@

void DPrintPreviewWidgetPrivate::printByCups()
{
#ifdef Q_OS_LINUX
// libcups2-dev libcups2
QLibrary cupsLibrary("cups", "2");
if (!cupsLibrary.isLoaded()) {
Expand Down Expand Up @@ -834,6 +837,9 @@

cupsPrintFile(printerName.toLocal8Bit().constData(), printFromPath.toLocal8Bit().constData(),
previewPrinter->docName().toLocal8Bit().constData(), numOptions, optPtr);
#else
qWarning() << "CUPS printing not supported on this platform";
#endif
}

void DPrintPreviewWidgetPrivate::generatePreviewPicture()
Expand Down Expand Up @@ -965,6 +971,7 @@

QByteArray DPrintPreviewWidgetPrivate::foundColorModelByCups() const
{
#ifdef Q_OS_LINUX
const auto parts = previewPrinter->printerName().split(QLatin1Char('/'));
const auto printerOriginalName = parts.at(0);

Expand Down Expand Up @@ -1072,6 +1079,8 @@
}
}

return {};
#endif
return {};
}

Expand Down
48 changes: 47 additions & 1 deletion src/widgets/private/keyboardmonitor/dkeyboardmonitor.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// SPDX-FileCopyrightText: 2011 - 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2011 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "dkeyboardmonitor.h"

#ifdef Q_OS_LINUX
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QX11Info>
#else
Expand Down Expand Up @@ -206,3 +207,48 @@ void DKeyboardMonitor::run()
}

DWIDGET_END_NAMESPACE

#else

// Stub implementation for non-Linux platforms
DWIDGET_BEGIN_NAMESPACE

DKeyboardMonitor::DKeyboardMonitor() :
QThread()
{
}

DKeyboardMonitor *DKeyboardMonitor::instance()
{
static DKeyboardMonitor *KeyboardMonitorInstance = nullptr;

if (!KeyboardMonitorInstance) {
KeyboardMonitorInstance = new DKeyboardMonitor;
}

return KeyboardMonitorInstance;
}

bool DKeyboardMonitor::isCapslockOn()
{
return false;
}

bool DKeyboardMonitor::isNumlockOn()
{
return false;
}

bool DKeyboardMonitor::setNumlockStatus(const bool &on)
{
Q_UNUSED(on)
return false;
}

void DKeyboardMonitor::run()
{
}

DWIDGET_END_NAMESPACE

#endif
7 changes: 5 additions & 2 deletions src/widgets/private/keyboardmonitor/dkeyboardmonitor.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
// SPDX-FileCopyrightText: 2011 - 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2011 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#ifndef KEYBOARDMONITOR_H
#define KEYBOARDMONITOR_H

#include <QThread>
#ifdef Q_OS_LINUX
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QX11Info>
#else
#include <QtGui/private/qtx11extras_p.h>
#endif
#endif
#include <dtkwidget_global.h>

DWIDGET_BEGIN_NAMESPACE
Expand All @@ -35,8 +37,9 @@ class DKeyboardMonitor : public QThread

private:
DKeyboardMonitor();

#ifdef Q_OS_LINUX
int listen(Display *display);
#endif
};

DWIDGET_END_NAMESPACE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,41 @@
// SPDX-FileCopyrightText: 2017 - 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2017 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#ifdef _WIN32

// Stub implementation for Windows
#include "startupnotificationmonitor.h"

class StartupNotificationMonitorSub : public StartupNotificationMonitor
{
};

Q_GLOBAL_STATIC(StartupNotificationMonitorSub, StartupNotificationMonitorInstance)

StartupNotificationMonitor::StartupNotificationMonitor() :
QObject()
{
}

StartupNotificationMonitor* StartupNotificationMonitor::instance()
{
return StartupNotificationMonitorInstance;
}

StartupNotificationMonitor::~StartupNotificationMonitor()
{
}

bool StartupNotificationMonitor::nativeEventFilter(const QByteArray &eventType, void *message, qintptr *)
{
Q_UNUSED(eventType)
Q_UNUSED(message)
return false;
}

#else // !_WIN32 — Linux/X11 implementation

#include <QtWidgets>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QX11Info>
Expand Down Expand Up @@ -129,3 +163,5 @@ bool StartupNotificationMonitor::nativeEventFilter(const QByteArray &eventType,

return false;
}

#endif // !_WIN32
Loading