diff --git a/CMakeLists.txt b/CMakeLists.txt index a21b17b..3371a99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,10 @@ include(KDEInstallDirs) set(KDE_SKIP_NULLPTR_WARNINGS_SETTINGS TRUE) include(KDECompilerSettings NO_POLICY_SCOPE) +## Enable keywords such as emit: +# TODO: Replace keywords such as emit with Q_EMIT +remove_definitions(-DQT_NO_KEYWORDS) + ## CMake settings: include(KDECMakeSettings) @@ -40,7 +44,7 @@ include(features.cmake) ## Add subdirectories: if(FEATURE_qtintegration_material_decoration) -# add_subdirectory(src/plugins/decorations/material) + add_subdirectory(src/plugins/decorations/material) endif() if(FEATURE_qtintegration_platformtheme) add_subdirectory(src/plugins/platformtheme) diff --git a/features.cmake b/features.cmake index 077f238..be53b99 100644 --- a/features.cmake +++ b/features.cmake @@ -9,6 +9,7 @@ find_package(Qt6 "6.6.0" Gui Widgets QuickControls2 + WaylandClient ) #### Features diff --git a/src/plugins/decorations/material/CMakeLists.txt b/src/plugins/decorations/material/CMakeLists.txt index 1243f4b..91b0ac0 100644 --- a/src/plugins/decorations/material/CMakeLists.txt +++ b/src/plugins/decorations/material/CMakeLists.txt @@ -1,21 +1,35 @@ find_package(Wayland REQUIRED) find_package(XkbCommon REQUIRED) -find_package(Qt5XkbCommonSupport REQUIRED PRIVATE) +#find_package(Qt6XkbCommonSupport REQUIRED PRIVATE) -liri_add_plugin(materialdecoration - TYPE - wayland-decoration-client - SOURCES - materialdecoration.cpp - materialdecoration.h - plugin.cpp - LIBRARIES - Qt5::XkbCommonSupport - Qt5::XkbCommonSupportPrivate - Qt5::WaylandClient - Qt5::WaylandClientPrivate +qt6_add_plugin(MaterialQtWaylandDecoration + SHARED + CLASS_NAME QWaylandMaterialDecorationPlugin + MANUAL_FINALIZATION + materialdecoration.cpp materialdecoration.h + plugin.cpp +) + +set_target_properties(MaterialQtWaylandDecoration + PROPERTIES OUTPUT_NAME liri-material +) + +target_link_libraries(MaterialQtWaylandDecoration + PUBLIC + Qt6::Core + Qt6::Gui + Qt6::WaylandClient + PRIVATE Wayland::Client XkbCommon::XkbCommon + #Qt6::XkbCommonSupport + #Qt6::XkbCommonSupportPrivate + Qt6::WaylandClientPrivate ) -liri_finalize_plugin(materialdecoration) +qt6_finalize_target(MaterialQtWaylandDecoration) + +install( + TARGETS MaterialQtWaylandDecoration + DESTINATION ${KDE_INSTALL_PLUGINDIR}/wayland-decoration-client +) diff --git a/src/plugins/decorations/material/materialdecoration.cpp b/src/plugins/decorations/material/materialdecoration.cpp index 32efeb4..a81e83e 100644 --- a/src/plugins/decorations/material/materialdecoration.cpp +++ b/src/plugins/decorations/material/materialdecoration.cpp @@ -10,6 +10,8 @@ #include "materialdecoration.h" +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE namespace QtWaylandClient { @@ -95,8 +97,11 @@ QRectF QWaylandMaterialDecoration::minimizeButtonRect() const (margins().top() - BUTTON_WIDTH) / 2, BUTTON_WIDTH, BUTTON_WIDTH); } -QMargins QWaylandMaterialDecoration::margins() const +QMargins QWaylandMaterialDecoration::margins(MarginsType marginsType) const { + if (marginsType == ShadowsOnly) + return QMargins(); + // Title bar is 32dp plus borders if (window() && window()->type() == Qt::Popup) return QMargins(0, 0, 0, 0); @@ -171,7 +176,7 @@ void QWaylandMaterialDecoration::paint(QPaintDevice *device) int dy = qFloor((top.height() - TITLE_FONT_SIZE) / 2); QFont font = p.font(); font.setBold(true); - font.setFamily("Roboto"); + font.setFamily("Roboto"_L1); font.setPixelSize(TITLE_FONT_SIZE); p.setFont(font); QPoint windowTitlePoint(dx, dy - WINDOW_BORDER / 2); @@ -295,15 +300,13 @@ bool QWaylandMaterialDecoration::handleMouse(QWaylandInputDevice *inputDevice, c return true; } -bool QWaylandMaterialDecoration::handleTouch(QWaylandInputDevice *inputDevice, const QPointF &local, - const QPointF &global, Qt::TouchPointState state, - Qt::KeyboardModifiers mods) +bool QWaylandMaterialDecoration::handleTouch(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, QEventPoint::State state, Qt::KeyboardModifiers mods) { Q_UNUSED(inputDevice); Q_UNUSED(global); Q_UNUSED(mods); - bool handled = state == Qt::TouchPointPressed; + bool handled = state == QEventPoint::Pressed; if (handled) { if (closeButtonRect().contains(local)) QWindowSystemInterface::handleCloseEvent(window()); diff --git a/src/plugins/decorations/material/materialdecoration.h b/src/plugins/decorations/material/materialdecoration.h index f4c6744..f9821e8 100644 --- a/src/plugins/decorations/material/materialdecoration.h +++ b/src/plugins/decorations/material/materialdecoration.h @@ -31,7 +31,7 @@ enum Button Minimize }; -class Q_WAYLAND_CLIENT_EXPORT QWaylandMaterialDecoration : public QWaylandAbstractDecoration +class Q_WAYLANDCLIENT_EXPORT QWaylandMaterialDecoration : public QWaylandAbstractDecoration { Q_OBJECT Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) @@ -55,12 +55,14 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandMaterialDecoration : public QWaylandAbstra void iconColorChanged(); protected: - QMargins margins() const override; + QMargins margins(MarginsType marginsType = Full) const override; + void paint(QPaintDevice *device) override; + bool handleMouse(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override; bool handleTouch(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, - Qt::TouchPointState state, Qt::KeyboardModifiers mods) override; + QEventPoint::State state, Qt::KeyboardModifiers mods) override; private: void processMouseTop(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b,