20#include "core/layouting/Item_p.h"
22#include "core/DockRegistry_p.h"
23#include "core/Utils_p.h"
24#include "core/DragController_p.h"
29#include "core/Logging_p.h"
41 return platform->createDefaultViewFactory();
43 KDDW_ERROR(
"No Platform found. Forgot to call KDDockWidgets::initFrontend(<platform>) ?");
72 double m_draggedWindowOpacity = std::numeric_limits<double>::quiet_NaN();
73 bool m_transparencyOnlyOverDropIndicator =
false;
74 int m_mdiPopupThreshold = 250;
75 int m_startDragDistance = -1;
76 bool m_dropIndicatorsInhibited =
false;
77 bool m_layoutSaverStrictMode =
false;
78 bool m_onlyProgrammaticDrag =
false;
98Config::Flags Config::flags()
const
103void Config::setFlags(Flags f)
109 static const Flags mutableFlags = Flag::Flag_AutoHideAsTabGroups;
110 const Flags changedFlags = f ^ d->m_flags;
111 const bool nonMutableFlagsChanged = (changedFlags & ~mutableFlags);
113 if (nonMutableFlagsChanged) {
114 auto dr = DockRegistry::self();
115 if (!dr->isEmpty(
true)) {
117 <<
"Config::setFlags: "
118 <<
"Only use this function at startup before creating any DockWidget or MainWindow"
119 <<
"; These are already created: " << dr->mainWindowsNames().size() << dr->dockWidgetNames().size()
120 << dr->floatingWindows().size() <<
"\n";
132 return (Config::self().flags() & flag) == flag;
135void Config::setDockWidgetFactoryFunc(DockWidgetFactoryFunc func)
137 d->m_dockWidgetFactoryFunc = func;
142 return d->m_dockWidgetFactoryFunc;
145void Config::setMainWindowFactoryFunc(MainWindowFactoryFunc func)
147 d->m_mainWindowFactoryFunc = func;
152 return d->m_mainWindowFactoryFunc;
158 delete d->m_viewFactory;
159 d->m_viewFactory = wf;
164 return d->m_viewFactory;
167int Config::separatorThickness()
const
169 return Item::separatorThickness;
172void Config::setSeparatorThickness(
int value)
174 if (!DockRegistry::self()->isEmpty(
true)) {
176 <<
"Config::setSeparatorThickness: Only use this function at startup before creating any DockWidget or MainWindow\n";
180 if (value < 0 || value >= 100) {
181 std::cerr <<
"Config::setSeparatorThickness: Invalid value" << value <<
"\n";
185 Item::separatorThickness = value;
188void Config::setDraggedWindowOpacity(
double opacity)
190 d->m_draggedWindowOpacity = opacity;
193void Config::setTransparencyOnlyOverDropIndicator(
bool only)
195 d->m_transparencyOnlyOverDropIndicator = only;
198double Config::draggedWindowOpacity()
const
200 return d->m_draggedWindowOpacity;
203bool Config::transparencyOnlyOverDropIndicator()
const
205 return d->m_transparencyOnlyOverDropIndicator;
208void Config::setDropIndicatorAllowedFunc(DropIndicatorAllowedFunc func)
210 d->m_dropIndicatorAllowedFunc = func;
215 return d->m_dropIndicatorAllowedFunc;
218void Config::setDragAboutToStartFunc(DragAboutToStartFunc func)
220 d->m_dragAboutToStartFunc = func;
225 return d->m_dragAboutToStartFunc;
228void Config::setDragEndedFunc(DragEndedFunc func)
230 d->m_dragEndedFunc = func;
235 return d->m_dragEndedFunc;
238void Config::setAbsoluteWidgetMinSize(Size size)
240 if (!DockRegistry::self()->isEmpty(
false)) {
242 <<
"Config::setAbsoluteWidgetMinSize: Only use this function at startup before creating any DockWidget or MainWindow\n";
246 Item::hardcodedMinimumSize = size;
249Size Config::absoluteWidgetMinSize()
const
251 return Item::hardcodedMinimumSize;
254void Config::setAbsoluteWidgetMaxSize(Size size)
256 if (!DockRegistry::self()->isEmpty(
false)) {
258 <<
"Config::setAbsoluteWidgetMinSize: Only use this function at startup before creating any DockWidget or MainWindow\n";
262 Item::hardcodedMaximumSize = size;
265Size Config::absoluteWidgetMaxSize()
const
267 return Item::hardcodedMaximumSize;
270Config::InternalFlags Config::internalFlags()
const
272 return d->m_internalFlags;
275void Config::setInternalFlags(InternalFlags flags)
277 d->m_internalFlags = flags;
280void Config::Private::fixFlags()
284 m_flags |= Flag_AeroSnapWithClientDecos;
286 m_flags = m_flags & ~Flag_AeroSnapWithClientDecos;
290 if ((m_flags & Flag_AeroSnapWithClientDecos) && (m_flags & Flag_NativeTitleBar)) {
292 m_flags = m_flags & ~Flag_AeroSnapWithClientDecos;
295#if defined(Q_OS_LINUX)
296 if (KDDockWidgets::isWayland()) {
299 m_flags |= Flag_NativeTitleBar;
304 m_flags = m_flags & ~Flag_NativeTitleBar;
308#if (!defined(KDDW_FRONTEND_QT_WINDOWS) && !defined(Q_OS_MACOS))
311 m_flags = m_flags & ~Flag_AeroSnapWithClientDecos;
315#if defined(DOCKS_DEVELOPER_MODE)
317 if (m_internalFlags & InternalFlag_NoAeroSnap) {
319 m_flags = m_flags & ~Flag_AeroSnapWithClientDecos;
323 if (m_flags & Flag_DontUseUtilityFloatingWindows) {
324 m_internalFlags |= InternalFlag_DontUseParentForFloatingWindows;
325 m_internalFlags |= InternalFlag_DontUseQtToolWindowsForFloatingWindows;
328 if (m_flags & Flag_ShowButtonsOnTabBarIfTitleBarHidden) {
330 m_flags |= Flag_HideTitleBarWhenTabsVisible;
334void Config::setDisabledPaintEvents(CustomizableWidgets widgets)
336 d->m_disabledPaintEvents = widgets;
339Config::CustomizableWidgets Config::disabledPaintEvents()
const
341 return d->m_disabledPaintEvents;
344void Config::setMDIPopupThreshold(
int threshold)
346 d->m_mdiPopupThreshold = threshold;
349int Config::mdiPopupThreshold()
const
351 return d->m_mdiPopupThreshold;
354void Config::setDropIndicatorsInhibited(
bool inhibit)
const
356 if (d->m_dropIndicatorsInhibited != inhibit) {
357 d->m_dropIndicatorsInhibited = inhibit;
358 DockRegistry::self()->dptr()->dropIndicatorsInhibitedChanged.emit(inhibit);
362bool Config::dropIndicatorsInhibited()
const
364 return d->m_dropIndicatorsInhibited;
367void Config::setStartDragDistance(
int pixels)
369 d->m_startDragDistance = pixels;
372int Config::startDragDistance()
const
374 return d->m_startDragDistance;
377void Config::printDebug()
379 std::cerr <<
"Flags: " << d->m_flags << d->m_internalFlags <<
"\n";
382void Config::setLayoutSaverStrictMode(
bool is)
384 d->m_layoutSaverStrictMode = is;
387bool Config::layoutSaverUsesStrictMode()
const
389 return d->m_layoutSaverStrictMode;
392void Config::setOnlyProgrammaticDrag(
bool only)
394 d->m_onlyProgrammaticDrag = only;
397bool Config::onlyProgrammaticDrag()
const
399 return d->m_onlyProgrammaticDrag;
Application-wide config to tune certain behaviours of the framework.