QtCanpool 3.3.0
载入中...
搜索中...
未找到
dockutils.h
浏览该文件的文档.
1
5#pragma once
6
7#include "qxdock_global.h"
8
9#include <QStyle>
10#include <QAbstractButton>
11#include <QMouseEvent>
12
13#if QX_DOCK_X11
14#include <xcb/xcb.h>
15#endif
16
17// #define QX_DOCK_DEBUG
18// #define QX_DOCK_DEBUG_PRINT
19
20// Define QX_DOCK_DEBUG_PRINT to enable a lot of debug output
21#ifdef QX_DOCK_DEBUG_PRINT
22#define QX_DOCK_PRINT(s) qDebug() << __FUNCTION__ << s
23#else
24#define QX_DOCK_PRINT(s)
25#endif
26
27class QSplitter;
28
30
31class DockSplitter;
32
33namespace internal
34{
35extern const int FloatingWidgetDragStartEvent;
36extern const int DockedWidgetDragStartEvent;
37static const char *const LocationProperty = "Location";
38static const char *const DirtyProperty = "dirty";
39static const char *const ClosedProperty = "close";
40static const bool RestoreTesting = true;
41static const bool Restore = false;
42
43template <class T> void setFlag(T &flags, typename T::enum_type flag, bool on = true)
44{
45#if QT_VERSION >= 0x050700
46 flags.setFlag(flag, on);
47#else
48 if (on) {
49 flags |= flag;
50 } else {
51 flags &= ~flag;
52 }
53#endif
54}
55
56template <class QObjectPtr> void setToolTip(QObjectPtr obj, const QString &tip)
57{
58#ifndef QT_NO_TOOLTIP
59 obj->setToolTip(tip);
60#else
61 Q_UNUSED(obj);
62 Q_UNUSED(tip);
63#endif
64}
65
75template <class T> T findParent(const QWidget *w)
76{
77 QWidget *pw = w->parentWidget();
78 while (pw) {
79 T parentImpl = qobject_cast<T>(pw);
80 if (parentImpl) {
81 return parentImpl;
82 }
83 pw = pw->parentWidget();
84 }
85 return nullptr;
86}
87
88inline QPoint globalPositionOf(QMouseEvent *e)
89{
90#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
91 return e->globalPosition().toPoint();
92#else
93 return e->globalPos();
94#endif
95}
96
97QPixmap createTransparentPixmap(const QPixmap &source, qreal opacity);
98
99void setButtonIcon(QAbstractButton *b, QStyle::StandardPixmap pixmap, Qx::DockIcon iconId);
100
101void replaceSplitterWidget(QSplitter *splitter, QWidget *from, QWidget *to);
102
103void hideEmptyParentSplitters(DockSplitter *firstParentSplitter);
104
105class DockInsertParam : public QPair<Qt::Orientation, bool>
106{
107public:
108 using QPair<Qt::Orientation, bool>::QPair;
109 Qt::Orientation orientation() const
110 {
111 return this->first;
112 }
113 bool append() const
114 {
115 return this->second;
116 }
117 int insertOffset() const
118 {
119 return append() ? 1 : 0;
120 }
121};
122
123DockInsertParam dockAreaInsertParameters(Qx::DockWidgetArea area);
124
125Qx::DockSideBarArea toSideBarArea(Qx::DockWidgetArea area);
126bool isHorizontalSideBarArea(Qx::DockSideBarArea area);
127bool isSideBarArea(Qx::DockWidgetArea area);
128
134
139void repolishStyle(QWidget *w, RepolishChildOptions options = RepolishIgnoreChildren);
140
141#if QX_DOCK_X11
142// Utils to directly communicate with the X server
146xcb_atom_t xcb_get_atom(const char *name);
147
151void xcb_add_prop(bool state, WId window, const char *type, const char *prop);
155void xcb_update_prop(bool set, WId window, const char *type, const char *prop, const char *prop2 = nullptr);
159bool xcb_dump_props(WId window, const char *type);
165QString windowManager();
166#endif
167
168#ifdef QX_DOCK_DEBUG
169void setBackgroudColor(QWidget *w);
170#define QXDOCK_SET_BGCOLOR(w) internal::setBackgroudColor(w)
171#else
172#define QXDOCK_SET_BGCOLOR(w)
173#endif // QX_DOCK_DEBUG
174
175} // internal
176
Qt::Orientation orientation() const
Definition dockutils.h:109
@ RepolishChildrenRecursively
Definition dockutils.h:132
QPoint globalPositionOf(QMouseEvent *e)
Definition dockutils.h:88
T findParent(const QWidget *w)
Searches for the parent widget of the given type.
Definition dockutils.h:75
void setToolTip(QObjectPtr obj, const QString &tip)
Definition dockutils.h:56
void setFlag(T &flags, typename T::enum_type flag, bool on=true)
Definition dockutils.h:43
DockSideBarArea
DockWidgetArea
#define QX_DOCK_END_NAMESPACE
#define QX_DOCK_BEGIN_NAMESPACE
QxLogger::Options options
Definition qxlogger.cpp:24
const char * name
Definition qxtheme.cpp:25
QColor window