ads_globals.h
Go to the documentation of this file.
1 #ifndef ads_globalsH
2 #define ads_globalsH
3 /*******************************************************************************
4 ** Qt Advanced Docking System
5 ** Copyright (C) 2017 Uwe Kindler
6 **
7 ** This library is free software; you can redistribute it and/or
8 ** modify it under the terms of the GNU Lesser General Public
9 ** License as published by the Free Software Foundation; either
10 ** version 2.1 of the License, or (at your option) any later version.
11 **
12 ** This library is distributed in the hope that it will be useful,
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ** Lesser General Public License for more details.
16 **
17 ** You should have received a copy of the GNU Lesser General Public
18 ** License along with this library; If not, see <http://www.gnu.org/licenses/>.
19 ******************************************************************************/
20 
21 
22 //============================================================================
27 //============================================================================
28 
29 
30 //============================================================================
31 // INCLUDES
32 //============================================================================
33 #include <QPair>
34 #include <QtCore/QtGlobal>
35 #include <QPixmap>
36 #include <QWidget>
37 #include <QDebug>
38 #include <QStyle>
39 
40 #ifdef Q_OS_LINUX
41 #include <xcb/xcb.h>
42 #endif
43 
44 QT_FORWARD_DECLARE_CLASS(QAbstractButton)
45 
46 #ifndef ADS_STATIC
47 #ifdef ADS_SHARED_EXPORT
48 #define ADS_EXPORT Q_DECL_EXPORT
49 #else
50 #define ADS_EXPORT Q_DECL_IMPORT
51 #endif
52 #else
53 #define ADS_EXPORT
54 #endif
55 
56 // Define ADS_DEBUG_PRINT to enable a lot of debug output
57 #ifdef ADS_DEBUG_PRINT
58 #define ADS_PRINT(s) qDebug() << s
59 #else
60 #define ADS_PRINT(s)
61 #endif
62 
63 // Set ADS_DEBUG_LEVEL to enable additional debug output and to enable layout
64 // dumps to qDebug and std::cout after layout changes
65 #define ADS_DEBUG_LEVEL 0
66 
67 QT_FORWARD_DECLARE_CLASS(QSplitter)
68 
69 namespace ads
70 {
71 class CDockSplitter;
72 
74 {
81 
85 };
86 Q_DECLARE_FLAGS(DockWidgetAreas, DockWidgetArea)
87 
88 
90 {
94 };
95 
100 {
105 };
106 
110 enum eIcon
111 {
116 
118 };
119 
124 {
127 };
128 
129 
130 namespace internal
131 {
132 static const bool RestoreTesting = true;
133 static const bool Restore = false;
134 static const char* const ClosedProperty = "close";
135 static const char* const DirtyProperty = "dirty";
136 
137 #ifdef Q_OS_LINUX
138 // Utils to directly communicate with the X server
142 xcb_atom_t xcb_get_atom(const char *name);
143 
147 void xcb_add_prop(bool state, WId window, const char *type, const char *prop);
151 void xcb_update_prop(bool set, WId window, const char *type, const char *prop, const char *prop2 = nullptr);
155 bool xcb_dump_props(WId window, const char *type);
161 QString windowManager();
162 #endif
163 
167 void replaceSplitterWidget(QSplitter* Splitter, QWidget* From, QWidget* To);
168 
173 void hideEmptyParentSplitters(CDockSplitter* FirstParentSplitter);
174 
179 class CDockInsertParam : public QPair<Qt::Orientation, bool>
180 {
181 public:
182  using QPair::QPair;
183  Qt::Orientation orientation() const {return this->first;}
184  bool append() const {return this->second;}
185  int insertOffset() const {return append() ? 1 : 0;}
186 };
187 
192 
202 template <class T>
203 T findParent(const QWidget* w)
204 {
205  QWidget* parentWidget = w->parentWidget();
206  while (parentWidget)
207  {
208  T ParentImpl = qobject_cast<T>(parentWidget);
209  if (ParentImpl)
210  {
211  return ParentImpl;
212  }
213  parentWidget = parentWidget->parentWidget();
214  }
215  return 0;
216 }
217 
223 QPixmap createTransparentPixmap(const QPixmap& Source, qreal Opacity);
224 
225 
229 template <class T>
230 void setFlag(T& Flags, typename T::enum_type flag, bool on = true)
231 {
232 #if QT_VERSION >= 0x050700
233  Flags.setFlag(flag, on);
234 #else
235  if(on)
236  {
237  Flags |= flag;
238  }
239  else
240  {
241  Flags &= ~flag;
242  }
243 #endif
244 }
245 
246 
251 template <class QObjectPtr>
252 void setToolTip(QObjectPtr obj, const QString &tip)
253 {
254 #ifndef QT_NO_TOOLTIP
255  obj->setToolTip(tip);
256 #else
257  Q_UNUSED(obj);
258  Q_UNUSED(tip);
259 #endif
260 }
261 
262 
276 void setButtonIcon(QAbstractButton* Button, QStyle::StandardPixmap StandarPixmap,
277  ads::eIcon CustomIconId);
278 
279 
281 {
285 };
286 
292 
293 
294 } // namespace internal
295 } // namespace ads
296 
297 //---------------------------------------------------------------------------
298 #endif // ads_globalsH
static const bool RestoreTesting
Definition: ads_globals.h:132
void setToolTip(QObjectPtr obj, const QString &tip)
Definition: ads_globals.h:252
static heap_info state
Definition: Heap.c:58
DockWidgetArea
Definition: ads_globals.h:73
TitleBarButton
Definition: ads_globals.h:89
DockAreaMenuIcon.
Definition: ads_globals.h:113
void replaceSplitterWidget(QSplitter *Splitter, QWidget *From, QWidget *To)
DraggingFloatingWidget.
Definition: ads_globals.h:104
void repolishStyle(QWidget *w, eRepolishChildOptions Options=RepolishIgnoreChildren)
TabCloseIcon.
Definition: ads_globals.h:112
DockAreaCloseIcon.
Definition: ads_globals.h:115
DraggingTab.
Definition: ads_globals.h:103
static const char *const DirtyProperty
Definition: ads_globals.h:135
T findParent(const QWidget *w)
Definition: ads_globals.h:203
void setFlag(T &Flags, typename T::enum_type flag, bool on=true)
Definition: ads_globals.h:230
const char * name
DraggingInactive.
Definition: ads_globals.h:101
DraggingMousePressed.
Definition: ads_globals.h:102
static void setButtonIcon(QPushButton *button, QIcon icon)
just a delimiter for range checks
Definition: ads_globals.h:117
void hideEmptyParentSplitters(CDockSplitter *FirstParentSplitter)
DockAreaUndockIcon.
Definition: ads_globals.h:114
static const bool Restore
Definition: ads_globals.h:133
eBitwiseOperator
Definition: ads_globals.h:123
CDockInsertParam dockAreaInsertParameters(DockWidgetArea Area)
Qt::Orientation orientation() const
Definition: ads_globals.h:183
eDragState
Definition: ads_globals.h:99
QPixmap createTransparentPixmap(const QPixmap &Source, qreal Opacity)
static const char *const ClosedProperty
Definition: ads_globals.h:134


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 03:47:33