QtCanpool 3.3.0
载入中...
搜索中...
未找到
windowagentwidget.cpp
浏览该文件的文档.
1
5#include "windowagentwidget.h"
8#include <QtCore/QDebug>
9#include <QtGui/QPainter>
10#include <QtGui/QtEvents>
11
13
22WindowAgentWidgetPrivate::WindowAgentWidgetPrivate() = default;
23
24WindowAgentWidgetPrivate::~WindowAgentWidgetPrivate() = default;
25
26void WindowAgentWidgetPrivate::init()
27{
28}
29
33WindowAgentWidget::WindowAgentWidget(QObject *parent)
35{
36}
37
42
48{
49 Q_ASSERT(w);
50 if (!w) {
51 return false;
52 }
53
55 if (d->m_hostWidget) {
56 QWK_WARNING << "This window agent has already agent other widget";
57 return false;
58 }
59
60 w->setAttribute(Qt::WA_DontCreateNativeAncestors);
61 w->setAttribute(Qt::WA_NativeWindow);
62
63 d->setup(w, new WidgetItemDelegate());
64 d->m_hostWidget = w;
65
66#if defined(Q_OS_WINDOWS) && defined(QX_WINDOW_ENABLE_SYSTEM_BORDERS) && defined(QX_WINDOW_NATIVE)
67 d->setupWindows10BorderWorkaround();
68#endif
69 return true;
70}
71
76{
77 Q_D(const WindowAgentWidget);
78 return static_cast<QWidget *>(d->m_context->titleBar());
79}
80
86{
88 if (!d->m_context->setTitleBar(w)) {
89 return;
90 }
91#ifdef Q_OS_MAC
92 setSystemButtonArea(nullptr);
93#endif
94 Q_EMIT titleBarChanged(w);
95}
96
101{
102 Q_D(const WindowAgentWidget);
103 return static_cast<QWidget *>(d->m_context->systemButton(button));
104}
105
111{
113 if (!d->m_context->setSystemButton(button, w)) {
114 return;
115 }
116 Q_EMIT systemButtonChanged(button, w);
117}
118
120{
122 d->m_context->removeSystemButton(button);
123}
124
128bool WindowAgentWidget::isHitTestVisible(const QWidget *w) const
129{
130 Q_D(const WindowAgentWidget);
131 return d->m_context->isHitTestVisible(w);
132}
133
139void WindowAgentWidget::setHitTestVisible(const QWidget *w, bool visible)
140{
142 d->m_context->setHitTestVisible(w, visible);
143}
144
146{
148 d->m_context->addCaptionClassName(name);
149}
150
155 : WindowAgentBase(d, parent)
156{
157 d.init();
158}
159
WindowAgentBase is the base class of the specifiy window agent for QtWidgets and QtQuick.
WindowAgentBase is the window agent for QtWidgets.
void systemButtonChanged(SystemButton button, const QWidget *w)
This signal is emitted when a system button is replaced.
QWidget * systemButton(SystemButton button) const
Returns the system button of the given type.
void setHitTestVisible(const QWidget *w, bool visible=true)
Makes the widget able to receive mouse events on title bar if visible is true.
void addCaptionClassName(const QString &name)
void titleBarChanged(const QWidget *w)
This signal is emitted when the title bar widget is replaced.
void removeSystemButton(SystemButton button)
bool setup(QWidget *w)
Installs the window agent on the widget.
void setTitleBar(QWidget *w)
Sets the title bar widget, all system button and hit-test visible widget references that have been se...
void setSystemButtonArea(QWidget *widget)
Sets the widget that acts as the system button area.
QWidget * titleBar() const
Returns the title bar widget.
~WindowAgentWidget() override
Destructor.
WindowAgentWidget(QObject *parent=nullptr)
Constructs a widget agent, it's better to set the widget to setup as parent.
bool isHitTestVisible(const QWidget *w) const
Returns true if the widget can receive mouse events on title bar.
void setSystemButton(SystemButton button, QWidget *w)
Sets the system button of the given type, the system buttons always receive mouse events so you don't...
const char * name
Definition qxtheme.cpp:25
QColor button
#define QX_WINDOW_END_NAMESPACE
#define QX_WINDOW_BEGIN_NAMESPACE
#define QWK_WARNING
Definition windowkit_p.h:26