File indexing completed on 2025-02-09 06:41:28
0001 /* 0002 SPDX-FileCopyrightText: 2023 David Edmundson <davidedmundson@kde.org> 0003 SPDX-License-Identifier: LGPL-2.0-or-later 0004 */ 0005 0006 #ifndef PLASMAWINDOW_H 0007 #define PLASMAWINDOW_H 0008 0009 #include <QQuickWindow> 0010 0011 #include <plasmaquick/plasmaquick_export.h> 0012 0013 namespace Plasma 0014 { 0015 class FrameSvgItem; 0016 } 0017 0018 namespace PlasmaQuick 0019 { 0020 class PlasmaWindowPrivate; 0021 0022 /* 0023 * Creates a QQuickWindow themed in a Plasma style with background 0024 */ 0025 class PLASMAQUICK_EXPORT PlasmaWindow : public QQuickWindow 0026 { 0027 Q_OBJECT 0028 0029 /** 0030 * The main QML item that will be displayed in the Dialog 0031 */ 0032 Q_PROPERTY(QQuickItem *mainItem READ mainItem WRITE setMainItem NOTIFY mainItemChanged) 0033 0034 /** 0035 * Defines the background used for the window 0036 */ 0037 Q_PROPERTY(BackgroundHints backgroundHints READ backgroundHints WRITE setBackgroundHints NOTIFY backgroundHintsChanged) 0038 0039 /** 0040 * Tells what borders are enabled of its background 0041 */ 0042 Q_PROPERTY(Qt::Edges borders READ borders NOTIFY bordersChanged) 0043 0044 Q_PROPERTY(qreal topPadding READ topPadding NOTIFY paddingChanged) 0045 Q_PROPERTY(qreal bottomPadding READ bottomPadding NOTIFY paddingChanged) 0046 Q_PROPERTY(qreal leftPadding READ leftPadding NOTIFY paddingChanged) 0047 Q_PROPERTY(qreal rightPadding READ rightPadding NOTIFY paddingChanged) 0048 0049 public: 0050 enum BackgroundHints { 0051 StandardBackground = 0, /**< The standard background from the theme is drawn */ 0052 SolidBackground = 1, /**< The solid version of the background is preferred */ 0053 }; 0054 Q_ENUM(BackgroundHints) 0055 0056 PlasmaWindow(const QString &svgPrefix = QStringLiteral("dialogs/background")); 0057 ~PlasmaWindow() override; 0058 0059 /** 0060 * The main QML item that will be displayed in the Dialog 0061 */ 0062 void setMainItem(QQuickItem *mainItem); 0063 0064 QQuickItem *mainItem() const; 0065 0066 /** 0067 * Changes which rounded corners are shown on the window. 0068 * Margins remain the same 0069 * The default is all borders 0070 */ 0071 void setBorders(Qt::Edges bordersToShow); 0072 0073 Qt::Edges borders(); 0074 0075 /** 0076 * Returns the padding that are placed around the mainItem 0077 * When setting size hints on the window this should be factored in. 0078 */ 0079 QMargins padding() const; 0080 0081 BackgroundHints backgroundHints() const; 0082 void setBackgroundHints(BackgroundHints hints); 0083 0084 qreal topPadding() const; 0085 qreal bottomPadding() const; 0086 qreal leftPadding() const; 0087 qreal rightPadding() const; 0088 0089 Q_SIGNALS: 0090 void mainItemChanged(); 0091 void bordersChanged(); 0092 void backgroundHintsChanged(); 0093 void paddingChanged(); 0094 0095 protected: 0096 void showEvent(QShowEvent *e) override; 0097 void resizeEvent(QResizeEvent *e) override; 0098 0099 private: 0100 const std::unique_ptr<PlasmaWindowPrivate> d; 0101 }; 0102 } 0103 0104 #endif