Libplasma

plasmawindow.h
1/*
2 SPDX-FileCopyrightText: 2023 David Edmundson <davidedmundson@kde.org>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5
6#ifndef PLASMAWINDOW_H
7#define PLASMAWINDOW_H
8
9#include <QQuickWindow>
10
11#include <plasmaquick/plasmaquick_export.h>
12
13namespace Plasma
14{
15class FrameSvgItem;
16}
17
18namespace PlasmaQuick
19{
20class PlasmaWindowPrivate;
21
22/*
23 * Creates a QQuickWindow themed in a Plasma style with background
24 */
25class PLASMAQUICK_EXPORT PlasmaWindow : public QQuickWindow
26{
27 Q_OBJECT
28
29 /**
30 * The main QML item that will be displayed in the Dialog
31 */
32 Q_PROPERTY(QQuickItem *mainItem READ mainItem WRITE setMainItem NOTIFY mainItemChanged)
33
34 /**
35 * Defines the background used for the window
36 */
37 Q_PROPERTY(BackgroundHints backgroundHints READ backgroundHints WRITE setBackgroundHints NOTIFY backgroundHintsChanged)
38
39 /**
40 * Tells what borders are enabled of its background
41 */
42 Q_PROPERTY(Qt::Edges borders READ borders NOTIFY bordersChanged)
43
44 Q_PROPERTY(qreal topPadding READ topPadding NOTIFY paddingChanged)
45 Q_PROPERTY(qreal bottomPadding READ bottomPadding NOTIFY paddingChanged)
46 Q_PROPERTY(qreal leftPadding READ leftPadding NOTIFY paddingChanged)
47 Q_PROPERTY(qreal rightPadding READ rightPadding NOTIFY paddingChanged)
48
49public:
50 enum BackgroundHints {
51 StandardBackground = 0, /**< The standard background from the theme is drawn */
52 SolidBackground = 1, /**< The solid version of the background is preferred */
53 };
54 Q_ENUM(BackgroundHints)
55
56 PlasmaWindow(const QString &svgPrefix = QStringLiteral("dialogs/background"));
57 ~PlasmaWindow() override;
58
59 /**
60 * The main QML item that will be displayed in the Dialog
61 */
62 void setMainItem(QQuickItem *mainItem);
63
64 QQuickItem *mainItem() const;
65
66 /**
67 * Changes which rounded corners are shown on the window.
68 * Margins remain the same
69 * The default is all borders
70 */
71 void setBorders(Qt::Edges bordersToShow);
72
73 Qt::Edges borders();
74
75 /**
76 * Returns the padding that are placed around the mainItem
77 * When setting size hints on the window this should be factored in.
78 */
79 QMargins padding() const;
80
81 BackgroundHints backgroundHints() const;
82 void setBackgroundHints(BackgroundHints hints);
83
84 qreal topPadding() const;
85 qreal bottomPadding() const;
86 qreal leftPadding() const;
87 qreal rightPadding() const;
88
89Q_SIGNALS:
90 void mainItemChanged();
91 void bordersChanged();
92 void backgroundHintsChanged();
93 void paddingChanged();
94
95protected:
96 void showEvent(QShowEvent *e) override;
97 void resizeEvent(QResizeEvent *e) override;
98
99private:
100 const std::unique_ptr<PlasmaWindowPrivate> d;
101};
102}
103
104#endif
The EdgeEventForwarder class This class forwards edge events to be replayed within the given margin T...
Definition action.h:20
Namespace for everything in libplasma.
typedef Edges
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 13 2024 11:54:24 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.