### Paint title bar outline Source: https://github.com/kde/kdecoration/blob/master/doc/KDecoration 3 porting guide.md Examples of painting a 1px wide outline, comparing incorrect integer-based clipping with the recommended floating-point approach. ```cpp painter->setClipRect(titleBarRect.x(), titleBarRect.y(), titleBarRect.width(), titleBarRect.height(), Qt::IntersectClip) painter->setBrush(QPen(QColor::red, 1)); painter->paintRect(rect()); ``` ```cpp painter->setClipRect(titleBarRect, Qt::IntersectClip); const qreal width = KDecoration3::pixelSize(window()->scale()); painter->setBrush(QPen(QColor::red, width)); painter->paintRect(rect().adjusted(width / 2, width / 2, -width / 2, -width / 2)); ``` -------------------------------- ### Configure Decoration Shadow Test Source: https://github.com/kde/kdecoration/blob/master/autotests/CMakeLists.txt Defines the decorationShadowTest executable and registers it as a test using ECM. ```cmake set(decorationShadowTest_SRCS shadowtest.cpp ) add_executable(decorationShadowTest ${decorationShadowTest_SRCS}) target_link_libraries(decorationShadowTest kdecorations3 Qt::Test) add_test(NAME kdecoration3-decorationShadowTest COMMAND decorationShadowTest) ecm_mark_as_test(decorationShadowTest) ``` -------------------------------- ### Configure Decoration Button Test Source: https://github.com/kde/kdecoration/blob/master/autotests/CMakeLists.txt Defines the decorationButtonTest executable and registers it as a test using ECM. ```cmake set(decorationButtonTest_SRCS mockbridge.cpp mockbridge.h mockbutton.cpp mockbutton.h mockwindow.cpp mockwindow.h mockdecoration.cpp mockdecoration.h mocksettings.cpp mocksettings.h decorationbuttontest.cpp ) add_executable(decorationButtonTest ${decorationButtonTest_SRCS}) target_link_libraries(decorationButtonTest kdecorations3 kdecorations3private Qt::Test) add_test(NAME kdecoration3-decorationButtonTest COMMAND decorationButtonTest) ecm_mark_as_test(decorationButtonTest) ``` -------------------------------- ### Snap geometry to pixel grid Source: https://github.com/kde/kdecoration/blob/master/doc/KDecoration 3 porting guide.md Use these helpers to ensure geometry values align with the pixel grid based on the window scale factor. ```cpp KDecoration3::snapToPixelGrid(value, scale) ``` ```cpp std::max(KDecoration3::snapToPixelGrid(value, scale), KDecoration3::pixelSize(scale)) ``` -------------------------------- ### Register KDecoration3 Plugin Factory Source: https://github.com/kde/kdecoration/blob/master/README.md Macro usage to register the decoration implementation using the KCoreAddons framework. ```cpp K_PLUGIN_FACTORY_WITH_JSON( MyAwesomeDecorationFactory, "deco.json", registerPlugin(); ) ``` -------------------------------- ### Configure Decoration Test Source: https://github.com/kde/kdecoration/blob/master/autotests/CMakeLists.txt Defines the decorationTest executable and registers it as a test using ECM. ```cmake set(decorationTest_SRCS mockbridge.cpp mockbridge.h mockbutton.cpp mockbutton.h mockwindow.cpp mockwindow.h mockdecoration.cpp mockdecoration.h mocksettings.cpp mocksettings.h decorationtest.cpp ) add_executable(decorationTest ${decorationTest_SRCS}) target_link_libraries(decorationTest kdecorations3 kdecorations3private Qt::Test) add_test(NAME kdecoration3-decorationTest COMMAND decorationTest) ecm_mark_as_test(decorationTest) ``` -------------------------------- ### Define KDecoration3 Plugin Metadata Source: https://github.com/kde/kdecoration/blob/master/README.md JSON metadata file required for the framework to discover and load the decoration plugin. ```json { "KPlugin": { "Id": "org.kde.myAweseomeDecoration", "ServiceTypes": [ "org.kde.kdecoration3" ] }, "X-KDE-ConfigModule": "kcm_name", /* comes with a configuration module */ "org.kde.kdecoration3": { "blur": false, /* blur behind not needed */ } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.