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
14 changes: 13 additions & 1 deletion dtkgui.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ option(DTK_DISABLE_EX_IMAGE_FORMAT "Disable libraw and freeimage" OFF)

set(CMAKE_CXX_STANDARD 17)

if(NOT LINUX)
add_definitions(-DD_DISABLE_DCONFIG)
endif()

if("${QT_VERSION_MAJOR}" STREQUAL "5")
set (BUILD_DOCS ON CACHE BOOL "Generate doxygen-based documentation")
else()
Expand Down Expand Up @@ -113,7 +117,9 @@ find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Gui DBus Network)
find_package(PkgConfig REQUIRED)
find_package(Dtk${DTK_NAME_SUFFIX} REQUIRED Core Tools)
find_package(DtkBuildHelper REQUIRED)
pkg_check_modules(librsvg REQUIRED IMPORTED_TARGET librsvg-2.0)
if(NOT DTK_DISABLE_LIBRSVG)
pkg_check_modules(librsvg REQUIRED IMPORTED_TARGET librsvg-2.0)
endif()

if(NOT DTK_DISABLE_LIBXDG)
if (${QT_VERSION_MAJOR} STREQUAL "5")
Expand All @@ -138,6 +144,12 @@ if(FreeImage_FOUND AND libraw_FOUND)
set(EX_IMAGE_FORMAT_LIBS_FOUND ON)
endif()

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

set(OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
add_subdirectory(src ${OUTPUT_DIR}/src)
if(BUILD_TESTING)
Expand Down
10 changes: 9 additions & 1 deletion include/global/dtkgui_global.h
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 @@ -16,4 +16,12 @@
#define DGUI_END_NAMESPACE }}
#define DGUI_USE_NAMESPACE using namespace DTK_GUI_NAMESPACE;

#if defined(DTK_STATIC_LIB)
# define LIBDTKGUISHARED_EXPORT
#elif defined(LIBDTKGUI_LIBRARY)
# define LIBDTKGUISHARED_EXPORT Q_DECL_EXPORT
#else
# define LIBDTKGUISHARED_EXPORT Q_DECL_IMPORT
#endif
Comment on lines +19 to +25

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我觉得不block本PR,不过这个是不是后续用CMake的generate_export_header好一点?


#endif // DTKGUI_GLOBAL_H
10 changes: 5 additions & 5 deletions include/kernel/dpalette.h
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 @@ -76,7 +76,7 @@ class DPalette : public QPalette
protected:
QScopedPointer<DPalettePrivate> d;

friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &s, const DPalette &p);
friend LIBDTKGUISHARED_EXPORT QDataStream &operator<<(QDataStream &s, const DPalette &p);
};

DGUI_END_NAMESPACE
Expand All @@ -86,12 +86,12 @@ QT_BEGIN_NAMESPACE
DPalette stream functions
*****************************************************************************/
#ifndef QT_NO_DATASTREAM
Q_GUI_EXPORT QDataStream &operator<<(QDataStream &ds, const DTK_GUI_NAMESPACE::DPalette &p);
Q_GUI_EXPORT QDataStream &operator>>(QDataStream &ds, DTK_GUI_NAMESPACE::DPalette &p);
LIBDTKGUISHARED_EXPORT QDataStream &operator<<(QDataStream &ds, const DTK_GUI_NAMESPACE::DPalette &p);
LIBDTKGUISHARED_EXPORT QDataStream &operator>>(QDataStream &ds, DTK_GUI_NAMESPACE::DPalette &p);
#endif // QT_NO_DATASTREAM

#ifndef QT_NO_DEBUG_STREAM
Q_GUI_EXPORT QDebug operator<<(QDebug, const DTK_GUI_NAMESPACE::DPalette &);
LIBDTKGUISHARED_EXPORT QDebug operator<<(QDebug, const DTK_GUI_NAMESPACE::DPalette &);
#endif

QT_END_NAMESPACE
Expand Down
4 changes: 2 additions & 2 deletions include/util/ddciiconpalette.h
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 @@ -63,7 +63,7 @@ DGUI_END_NAMESPACE

QT_BEGIN_NAMESPACE
#ifndef QT_NO_DEBUG_STREAM
Q_GUI_EXPORT QDebug operator<<(QDebug, const DTK_GUI_NAMESPACE::DDciIconPalette &);
LIBDTKGUISHARED_EXPORT QDebug operator<<(QDebug, const DTK_GUI_NAMESPACE::DDciIconPalette &);
#endif
QT_END_NAMESPACE
#endif // DDCIICONPALETTE_H
14 changes: 11 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
if("${QT_VERSION_MAJOR}" STREQUAL "6")
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets WaylandClient)
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
if(LINUX)
find_package(Qt6 REQUIRED COMPONENTS WaylandClient)
endif()

if (${Qt6Core_VERSION} VERSION_GREATER_EQUAL "6.10.0")
set(QT_NO_PRIVATE_MODULE_WARNING ON)
find_package(Qt6 REQUIRED COMPONENTS CorePrivate GuiPrivate WaylandClientPrivate)
find_package(Qt6 REQUIRED COMPONENTS CorePrivate GuiPrivate)
if(LINUX)
find_package(Qt6 REQUIRED COMPONENTS WaylandClientPrivate)
endif()
endif()
else()
find_package(Qt5 REQUIRED COMPONENTS WaylandClient XkbCommonSupport)
Expand Down Expand Up @@ -49,8 +55,10 @@ PRIVATE
Qt${QT_VERSION_MAJOR}::GuiPrivate
Qt${QT_VERSION_MAJOR}::CorePrivate
Qt${QT_VERSION_MAJOR}::DBus
Qt${QT_VERSION_MAJOR}::WaylandClientPrivate
)
if(LINUX)
target_link_libraries(${LIB_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::WaylandClientPrivate)
endif()

if("${QT_VERSION_MAJOR}" STREQUAL "5")
target_link_libraries(${LIB_NAME}
Expand Down
55 changes: 29 additions & 26 deletions src/kernel/dguiapplicationhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
#include "private/dguiapplicationhelper_p.h"
#include "dplatformhandle.h"

#include <DFontManager>

Check warning on line 9 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 9 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

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

Check warning on line 10 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 10 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

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

Check warning on line 11 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 11 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

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

Check warning on line 12 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 12 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

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

#include <QHash>

Check warning on line 14 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 14 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

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

Check warning on line 15 in src/kernel/dguiapplicationhelper.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.

Check warning on line 15 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QColor> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QPalette>
#include <QWindow>
#include <QGuiApplication>
Expand All @@ -34,27 +35,12 @@
#include <QDBusInterface>
#include <QDBusPendingCall>
#include <QDBusConnection>
#include <QDBusConnectionInterface>

Check warning on line 38 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 38 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

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

Check warning on line 39 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 39 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QProcess> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#endif
#include <QDir>
#include <QLockFile>
#include <QDirIterator>
#include <QDesktopServices>

#ifdef Q_OS_UNIX
#include <QDBusError>
#include <QDBusReply>
#include <QDBusInterface>
#include <QDBusPendingCall>
#include <QDBusConnection>
#include <QDBusConnectionInterface>
#include <QProcess>
#include <DPathBuf>
#endif

#include <private/qguiapplication_p.h>

Check warning on line 42 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 42 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

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

Check warning on line 43 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 43 in src/kernel/dguiapplicationhelper.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

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

Expand Down Expand Up @@ -125,8 +111,14 @@

#define DTK_ANIMATIONS_ENV "D_DTK_DISABLE_ANIMATIONS"
#define DTK_DISABLE_INWINDOWBLUR_ENV "D_DTK_DISABLE_INWINDOWBLUR"
#ifndef D_DISABLE_DCONFIG
Q_GLOBAL_STATIC_WITH_ARGS(OrgDeepinDTKPreference, _d_dconfig, (DTK_CORE_NAMESPACE::DConfig::globalThread(), nullptr,
"org.deepin.dtk.preference", DTK_CORE_NAMESPACE::DSGApplication::id(), {}, false, nullptr))
#define DTK_DCONFIG_PTR _d_dconfig
#else
static OrgDeepinDTKPreference* _d_dconfig_instance = nullptr;
#define DTK_DCONFIG_PTR _d_dconfig_instance
#endif

// Keys allowed to be forwarded between single-instance client and server.
static const QStringList s_singleInstanceForwardEnvKeys = {
Expand Down Expand Up @@ -210,9 +202,11 @@

void LoadManualServiceWorker::run()
{
#ifdef Q_OS_UNIX
QDBusInterface("com.deepin.Manual.Search",
"/com/deepin/Manual/Search",
"com.deepin.Manual.Search");
#endif
}

void LoadManualServiceWorker::checkManualServiceWakeUp()
Expand Down Expand Up @@ -478,21 +472,30 @@
const_cast<DGuiApplicationHelperPrivate *>(this)->paletteTypeInited = true;

auto applyThemeType = [this](bool emitSignal){
int ct = _d_dconfig->themeType();
if (ct > DGuiApplicationHelper::DarkType || ct < DGuiApplicationHelper::UnknownType)
ct = DGuiApplicationHelper::UnknownType;

int ct = DGuiApplicationHelper::UnknownType;
if (DTK_DCONFIG_PTR) {
ct = DTK_DCONFIG_PTR->themeType();
if (ct > DGuiApplicationHelper::DarkType || ct < DGuiApplicationHelper::UnknownType)
ct = DGuiApplicationHelper::UnknownType;
}
const_cast<DGuiApplicationHelperPrivate *>(this)->setPaletteType(DGuiApplicationHelper::ColorType(ct), emitSignal);
};

// 读取配置文件中的主题类型并立即应用
#ifndef D_DISABLE_DCONFIG
DTK_CORE_NAMESPACE::DConfig dconfig("org.deepin.dtk.preference");
int ct = dconfig.value("themeType", DGuiApplicationHelper::UnknownType).toInt();
const_cast<DGuiApplicationHelperPrivate *>(this)->setPaletteType(DGuiApplicationHelper::ColorType(ct), false);
#else
int ct = DGuiApplicationHelper::UnknownType;
const_cast<DGuiApplicationHelperPrivate *>(this)->setPaletteType(DGuiApplicationHelper::ColorType(ct), false);
#endif

QObject::connect(_d_dconfig.operator ()(), &OrgDeepinDTKPreference::themeTypeChanged, q_func(), [applyThemeType] {
applyThemeType(true);
});
if (DTK_DCONFIG_PTR) {
QObject::connect(DTK_DCONFIG_PTR, &OrgDeepinDTKPreference::themeTypeChanged, q_func(), [applyThemeType] {
applyThemeType(true);
});
}
}

void DGuiApplicationHelperPrivate::_q_sizeModeChanged(int mode)
Expand Down Expand Up @@ -1886,14 +1889,14 @@
if (isDisable)
return false;

return _d_dconfig->enableDtkAnimations();
return DTK_DCONFIG_PTR ? DTK_DCONFIG_PTR->enableDtkAnimations() : false;
}
case HasInWindowBlur: {
static bool isDisable = qEnvironmentVariableIsSet(DTK_DISABLE_INWINDOWBLUR_ENV);
if (isDisable)
return false;

return !_d_dconfig->disableInWindowBlur();
return DTK_DCONFIG_PTR ? !DTK_DCONFIG_PTR->disableInWindowBlur() : false;
}
default:
return DGuiApplicationHelperPrivate::attributes.testFlag(attribute);
Expand Down Expand Up @@ -1934,8 +1937,8 @@

d->initPaletteType();
d->setPaletteType(paletteType, true);
if (!DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::DontSaveApplicationTheme))
_d_dconfig->setThemeType(static_cast<int>(paletteType));
if (!DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::DontSaveApplicationTheme) && DTK_DCONFIG_PTR)
DTK_DCONFIG_PTR->setThemeType(static_cast<int>(paletteType));
}

/*!
Expand Down
9 changes: 7 additions & 2 deletions src/kernel/dwindowmanagerhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
#include <DGuiApplicationHelper>
#include <QGuiApplication>


#ifdef Q_OS_LINUX
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <qpa/qplatformwindow_p.h>
#define D_XCB_WINDOW_TYPE QNativeInterface::Private::QXcbWindow::WindowType
#else
#include <QtPlatformHeaders/QXcbWindowFunctions>
#define D_XCB_WINDOW_TYPE QXcbWindowFunctions::WmWindowType
#endif

#endif

#include <qpa/qplatformwindow.h>
#include <qpa/qplatformnativeinterface.h>
Expand Down Expand Up @@ -492,6 +492,7 @@ DWindowManagerHelper::MotifDecorations DWindowManagerHelper::getMotifDecorations
*/
void DWindowManagerHelper::setWmWindowTypes(QWindow *window, WmWindowTypes types)
{
#ifdef Q_OS_LINUX
const int _types = static_cast<int>(types);

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
Expand All @@ -504,6 +505,10 @@ void DWindowManagerHelper::setWmWindowTypes(QWindow *window, WmWindowTypes types
#else
QXcbWindowFunctions::setWmWindowType(window, static_cast<D_XCB_WINDOW_TYPE>(_types));
#endif
#else
Q_UNUSED(window)
Q_UNUSED(types)
#endif
}

/*!
Expand Down
8 changes: 7 additions & 1 deletion src/kernel/kernel.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ set(kernel_SRC
${KERNEL_SOURCE}
)

dtk_add_config_to_cpp(kernel_SRC /usr/share/dsg/configs/org.deepin.dtk.preference.json
if(LINUX)
set(_PREF_CONFIG_JSON /usr/share/dsg/configs/org.deepin.dtk.preference.json)
else()
set(_PREF_CONFIG_JSON ${CMAKE_INSTALL_PREFIX}/share/dsg/configs/org.deepin.dtk.preference.json)
endif()

dtk_add_config_to_cpp(kernel_SRC ${_PREF_CONFIG_JSON}
OUTPUT_FILE_NAME orgdeepindtkpreference.hpp
CLASS_NAME OrgDeepinDTKPreference
)
47 changes: 46 additions & 1 deletion src/plugins/dplatformwindowinterface.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

Expand Down Expand Up @@ -28,18 +28,30 @@ void DPlatformWindowInterface::setEnabled(bool enabled)

bool DPlatformWindowInterface::isEnabled() const
{
#ifdef Q_OS_WIN
return true;
#else
return false;
#endif
}

bool DPlatformWindowInterface::isEnabledNoTitlebar() const
{
#ifdef Q_OS_WIN
return true;
#else
return {};
#endif
}

bool DPlatformWindowInterface::setEnabledNoTitlebar(bool enable)
{
Q_UNUSED(enable)
#ifdef Q_OS_WIN
return true;
#else
return {};
#endif
}

void DPlatformWindowInterface::setDisableWindowOverrideCursor(bool disable)
Expand Down Expand Up @@ -184,12 +196,45 @@ void DPlatformWindowInterface::setEnableSystemMove(bool enableSystemMove)

bool DPlatformWindowInterface::enableBlurWindow() const
{
#ifdef Q_OS_WIN
return m_enableBlurWindow;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

咦?windows下支持这个的吗?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

其实我也不太懂 反正能编译通过就是了

#else
return {};
#endif
}

void DPlatformWindowInterface::setEnableBlurWindow(bool enableBlurWindow)
{
#ifdef Q_OS_WIN
if (m_enableBlurWindow == enableBlurWindow)
return;
m_enableBlurWindow = enableBlurWindow;
if (m_platformHandle) {
Q_EMIT m_platformHandle->enableBlurWindowChanged();
}
#else
Q_UNUSED(enableBlurWindow)
#endif
}

bool DPlatformWindowInterface::setWindowBlurArea(const QVector<DPlatformHandle::WMBlurArea> &area)
{
Q_UNUSED(area)
#ifdef Q_OS_WIN
return true;
#else
return false;
#endif
}

bool DPlatformWindowInterface::setWindowBlurArea(const QList<QPainterPath> &paths)
{
Q_UNUSED(paths)
#ifdef Q_OS_WIN
return true;
#else
return false;
#endif
}

DGUI_END_NAMESPACE
Expand Down
Loading
Loading