Zren / plasma-applet-tiledmenu

https://store.kde.org/p/2142716/
138 stars 35 forks source link

Show desktop wallpaper in fullscreen mode #44

Open Zren opened 5 years ago

Zren commented 5 years ago

It's posible to access the default PlasmaCore.Dialog { id: popupWindow } by calling Window.window in the Plasmoid.fullRepesentation's onParentChanged signal.

We can then set the backgroundHints to PlasmaCore.Types.NoBackground to get rid of the frame around it.

// CompactApplet's popupWindow isn't available until the parent is attached.
// https://github.com/KDE/plasma-desktop/blob/master/desktoppackage/contents/applet/CompactApplet.qml#L94
onParentChanged: {
    var popupWindow = Window.window
    if (typeof popupWindow.backgroundHints !== "undefined") { // Make sure it's a PlasmaCore.Dialog
        popupWindow.backgroundHints = Qt.binding(function(){
            return plasmoid.configuration.fullscreen ? PlasmaCore.Types.NoBackground : PlasmaCore.Types.DefaultBackground
        })
        popupWindow.location = Qt.binding(function(){
            return plasmoid.configuration.fullscreen ? PlasmaCore.Types.Floating : plasmoid.location
        })
    }
}
Zren commented 3 years ago

Quick note, the only reason why the example above worked is probably because Dialog enum used the same values.

https://invent.kde.org/frameworks/plasma-framework/-/blame/master/src/plasma/plasma.h#L298

enum BackgroundHints {
        NoBackground = 0, /**< Not drawing a background under the applet, the applet has its own implementation */
        StandardBackground = 1, /**< The standard background from the theme is drawn */
        TranslucentBackground = 2, /**< An alternate version of the background is drawn, usually more translucent */
        ShadowBackground = 4, /**< The applet won't have a svg background but a drop shadow of its content done via a shader */
        ConfigurableBackground = 8, /** If the hint has this flag, the user is able to configure this background */
        DefaultBackground = StandardBackground, /**< Default settings: both standard background */
    };

https://invent.kde.org/frameworks/plasma-framework/-/blob/master/src/plasmaquick/dialog.h#L159

enum BackgroundHints {
        NoBackground = 0, /**< Not drawing a background under the applet, the dialog has its own implementation */
        StandardBackground = 1, /**< The standard background from the theme is drawn */
        SolidBackground = 2, /**< The solid version of the background is preferred */
    };