QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskWindow.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_WINDOW_H
7#define QSK_WINDOW_H
8
9#include "QskGlobal.h"
10#include <qquickwindow.h>
11
12class QskWindowPrivate;
13class QskObjectAttributes;
14class QskSkin;
15
16class QSK_EXPORT QskWindow : public QQuickWindow
17{
18 Q_OBJECT
19
20 Q_PROPERTY( bool deleteOnClose READ deleteOnClose
21 WRITE setDeleteOnClose NOTIFY deleteOnCloseChanged FINAL )
22
23 Q_PROPERTY( bool autoLayoutChildren READ autoLayoutChildren
24 WRITE setAutoLayoutChildren NOTIFY autoLayoutChildrenChanged FINAL )
25
26 Q_PROPERTY( QLocale locale READ locale
27 WRITE setLocale RESET resetLocale NOTIFY localeChanged FINAL )
28
29 using Inherited = QQuickWindow;
30
31 public:
32 enum EventAcceptance
33 {
34 EventProcessed = 0,
35 EventPropagationStopped = 1
36 };
37
38 QskWindow( QWindow* parent = nullptr );
39 QskWindow( QQuickRenderControl* renderControl, QWindow* parent = nullptr );
40
41 ~QskWindow() override;
42
43 using Inherited::setScreen;
44 void setScreen( const QString& );
45
46 bool deleteOnClose() const;
47 void setDeleteOnClose( bool );
48
49 void setAutoLayoutChildren( bool );
50 bool autoLayoutChildren() const;
51
52 Q_INVOKABLE void addItem( QQuickItem* );
53
54 QLocale locale() const;
55 void resetLocale();
56
57 Q_INVOKABLE void setPreferredSize( const QSize& );
58 Q_INVOKABLE QSize preferredSize() const;
59
60 Q_INVOKABLE QSize sizeConstraint() const;
61
62 Q_INVOKABLE void setFixedSize( const QSize& );
63
64 void polishItems();
65
66 void setCustomRenderMode( const char* mode );
67 const char* customRenderMode() const;
68
69 // extra flag to interprete accepted events
70 void setEventAcceptance( EventAcceptance );
71 EventAcceptance eventAcceptance() const;
72
73 // each window might have its own skin
74 void setSkin( QskSkin* );
75 void setSkin( const QString& );
76 QskSkin* skin() const;
77
78 Q_SIGNALS:
79 void localeChanged( const QLocale& );
80 void autoLayoutChildrenChanged();
81 void deleteOnCloseChanged();
82
83 public Q_SLOTS:
84 void setLocale( const QLocale& );
85 void resizeF( const QSizeF& );
86
87 protected:
88 bool event( QEvent* ) override;
89 void resizeEvent( QResizeEvent* ) override;
90 void exposeEvent( QExposeEvent* ) override;
91 void keyPressEvent( QKeyEvent* ) override;
92 void keyReleaseEvent( QKeyEvent* ) override;
93
94 virtual void layoutItems();
95 virtual void ensureFocus( Qt::FocusReason );
96
97 private:
98 void enforceSkin();
99
100 Q_DECLARE_PRIVATE( QskWindow )
101};
102
103QSK_EXPORT QskSkin* qskEffectiveSkin( const QQuickWindow* );
104
105#endif