diff --git a/CMakeLists.txt b/CMakeLists.txt index 8403b6c87..79fc5964f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,7 +52,7 @@ include(DDEShellPackageMacros) include(KDEClangFormat) include(KDEGitCommitHooks) -find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui Concurrent Quick WaylandClient WaylandCompositor DBus LinguistTools Sql) +find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui Concurrent Quick QuickTemplates2 WaylandClient WaylandCompositor DBus LinguistTools Sql) if(Qt${QT_VERSION_MAJOR}_VERSION VERSION_GREATER_EQUAL 6.10) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS WaylandClientPrivate WaylandCompositorPrivate REQUIRED) endif() diff --git a/frame/CMakeLists.txt b/frame/CMakeLists.txt index 69ece6b19..4b6727a51 100644 --- a/frame/CMakeLists.txt +++ b/frame/CMakeLists.txt @@ -101,6 +101,7 @@ PUBLIC Qt${QT_VERSION_MAJOR}::Quick PRIVATE Qt${QT_VERSION_MAJOR}::QuickPrivate + Qt${QT_VERSION_MAJOR}::QuickTemplates2Private Qt${QT_VERSION_MAJOR}::Concurrent Qt${QT_VERSION_MAJOR}::GuiPrivate Qt${QT_VERSION_MAJOR}::WaylandClientPrivate diff --git a/frame/popupwindow.cpp b/frame/popupwindow.cpp index 8d8c5844e..a594b45c4 100644 --- a/frame/popupwindow.cpp +++ b/frame/popupwindow.cpp @@ -4,6 +4,9 @@ #include "popupwindow.h" +#include +#include + DS_BEGIN_NAMESPACE PopupWindow::PopupWindow(QWindow *parent) : QQuickWindowQmlImpl(parent) @@ -49,4 +52,37 @@ void PopupWindow::mouseMoveEvent(QMouseEvent *event) return QQuickWindowQmlImpl::mouseMoveEvent(event); } +QFont PopupWindow::font() const +{ + return m_font; +} + +void PopupWindow::setFont(const QFont &font) +{ + m_hasExplicitFont = true; + QFont resolved = font.resolve(QGuiApplication::font()); + if (m_font.resolveMask() == resolved.resolveMask() && m_font == resolved) + return; + m_font = resolved; + propagateFontToContentItem(m_font); + emit fontChanged(); +} + +void PopupWindow::resetFont() +{ + m_hasExplicitFont = false; + QFont defaultFont; + if (m_font == defaultFont) + return; + m_font = defaultFont; + propagateFontToContentItem(m_font); + emit fontChanged(); +} + +void PopupWindow::propagateFontToContentItem(const QFont &font) +{ + if (QQuickItem *ci = contentItem()) + QQuickControlPrivate::updateFontRecur(ci, font); +} + DS_END_NAMESPACE diff --git a/frame/popupwindow.h b/frame/popupwindow.h index d9eb1f451..3744f29fc 100644 --- a/frame/popupwindow.h +++ b/frame/popupwindow.h @@ -5,6 +5,7 @@ #pragma once #include "dsglobal.h" +#include #include DS_BEGIN_NAMESPACE @@ -12,18 +13,30 @@ class PopupWindow : public QQuickWindowQmlImpl { Q_OBJECT Q_PROPERTY(QWindow *transientParent READ transientParent WRITE setTransientParent NOTIFY transientParentChanged) + Q_PROPERTY(QFont font READ font WRITE setFont RESET resetFont NOTIFY fontChanged FINAL) QML_NAMED_ELEMENT(PopupWindow) public: PopupWindow(QWindow *parent = nullptr); + QFont font() const; + void setFont(const QFont &font); + void resetFont(); + +Q_SIGNALS: + void fontChanged(); + protected: void mouseReleaseEvent(QMouseEvent *event) override; void mousePressEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; private: + void propagateFontToContentItem(const QFont &font); + bool m_dragging; bool m_pressing; + QFont m_font; + bool m_hasExplicitFont = false; }; DS_END_NAMESPACE diff --git a/frame/qml/PanelPopupWindow.qml b/frame/qml/PanelPopupWindow.qml index 29c0f3795..05efeb87d 100644 --- a/frame/qml/PanelPopupWindow.qml +++ b/frame/qml/PanelPopupWindow.qml @@ -68,6 +68,8 @@ PopupWindow { width: 10 height: 10 flags: (Qt.platform.pluginName === "xcb" ? (Qt.Tool | Qt.WindowStaysOnTopHint) : Qt.Popup) + font.family: D.DTK.fontManager.t6.family + font.pixelSize: D.DTK.fontManager.t6.pixelSize // WM_NAME, used for kwin. title: "dde-shell/panelpopup" D.DWindow.enabled: true @@ -152,4 +154,4 @@ PopupWindow { DStyle.Style.behindWindowBlur.darkNoBlurColor) } } -} +} \ No newline at end of file