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>) ?");
73 double m_draggedWindowOpacity = std::numeric_limits<double>::quiet_NaN();
74 bool m_transparencyOnlyOverDropIndicator =
false;
75 int m_mdiPopupThreshold = 250;
76 int m_startDragDistance = -1;
77 bool m_dropIndicatorsInhibited =
false;
78 bool m_layoutSaverStrictMode =
false;
79 bool m_onlyProgrammaticDrag =
false;
102Config::Flags Config::flags()
const
107Config::MDIFlags Config::mdiFlags()
const
109 return d->m_mdiFlags;
112void Config::setMDIFlags(MDIFlags flags)
114 d->m_mdiFlags = flags;
117void Config::setFlags(Flags f)
123 static const Flags mutableFlags = Flag::Flag_AutoHideAsTabGroups;
124 const Flags changedFlags = f ^ d->m_flags;
125 const bool nonMutableFlagsChanged = (changedFlags & ~mutableFlags);
127 if (nonMutableFlagsChanged) {
128 auto dr = DockRegistry::self();
129 if (!dr->isEmpty(
true)) {
131 <<
"Config::setFlags: "
132 <<
"Only use this function at startup before creating any DockWidget or MainWindow"
133 <<
"; These are already created: " << dr->mainWindowsNames().size() << dr->dockWidgetNames().size()
134 << dr->floatingWindows().size() <<
"\n";
146 return (Config::self().flags() & flag) == flag;
152 return (Config::self().mdiFlags() & flag) == flag;
155void Config::setDockWidgetFactoryFunc(DockWidgetFactoryFunc func)
157 d->m_dockWidgetFactoryFunc = func;
162 return d->m_dockWidgetFactoryFunc;
165void Config::setMainWindowFactoryFunc(MainWindowFactoryFunc func)
167 d->m_mainWindowFactoryFunc = func;
172 return d->m_mainWindowFactoryFunc;
178 delete d->m_viewFactory;
179 d->m_viewFactory = wf;
184 return d->m_viewFactory;
187int Config::separatorThickness()
const
189 return Item::separatorThickness;
192int Config::layoutSpacing()
const
194 return Item::layoutSpacing;
197void Config::setSeparatorThickness(
int value)
199 if (!DockRegistry::self()->isEmpty(
true)) {
201 <<
"Config::setSeparatorThickness: Only use this function at startup before creating any DockWidget or MainWindow\n";
205 if (value < 0 || value >= 100) {
206 std::cerr <<
"Config::setSeparatorThickness: Invalid value" << value <<
"\n";
210 Item::separatorThickness = value;
211 Item::layoutSpacing = value;
214void Config::setLayoutSpacing(
int value)
216 if (!DockRegistry::self()->isEmpty(
true)) {
218 <<
"Config::setLayoutSpacing: Only use this function at startup before creating any DockWidget or MainWindow\n";
222 if (value < 0 || value >= 100) {
223 std::cerr <<
"Config::setLayoutSpacing: Invalid value" << value <<
"\n";
227 Item::layoutSpacing = value;
230void Config::setDraggedWindowOpacity(
double opacity)
232 d->m_draggedWindowOpacity = opacity;
235void Config::setTransparencyOnlyOverDropIndicator(
bool only)
237 d->m_transparencyOnlyOverDropIndicator = only;
240double Config::draggedWindowOpacity()
const
242 return d->m_draggedWindowOpacity;
245bool Config::transparencyOnlyOverDropIndicator()
const
247 return d->m_transparencyOnlyOverDropIndicator;
250void Config::setDropIndicatorAllowedFunc(DropIndicatorAllowedFunc func)
252 d->m_dropIndicatorAllowedFunc = func;
257 return d->m_dropIndicatorAllowedFunc;
260void Config::setDragAboutToStartFunc(DragAboutToStartFunc func)
262 d->m_dragAboutToStartFunc = func;
267 return d->m_dragAboutToStartFunc;
270void Config::setDragEndedFunc(DragEndedFunc func)
272 d->m_dragEndedFunc = func;
277 return d->m_dragEndedFunc;
280void Config::setAbsoluteWidgetMinSize(Size size)
282 if (!DockRegistry::self()->isEmpty(
false)) {
284 <<
"Config::setAbsoluteWidgetMinSize: Only use this function at startup before creating any DockWidget or MainWindow\n";
288 Item::hardcodedMinimumSize = size;
291Size Config::absoluteWidgetMinSize()
const
293 return Item::hardcodedMinimumSize;
296void Config::setAbsoluteWidgetMaxSize(Size size)
298 if (!DockRegistry::self()->isEmpty(
false)) {
300 <<
"Config::setAbsoluteWidgetMinSize: Only use this function at startup before creating any DockWidget or MainWindow\n";
304 Item::hardcodedMaximumSize = size;
307Size Config::absoluteWidgetMaxSize()
const
309 return Item::hardcodedMaximumSize;
312Config::InternalFlags Config::internalFlags()
const
314 return d->m_internalFlags;
317void Config::setInternalFlags(InternalFlags flags)
319 d->m_internalFlags = flags;
322void Config::Private::fixFlags()
326 m_flags |= Flag_AeroSnapWithClientDecos;
328 m_flags = m_flags & ~Flag_AeroSnapWithClientDecos;
332 if ((m_flags & Flag_AeroSnapWithClientDecos) && (m_flags & Flag_NativeTitleBar)) {
334 m_flags = m_flags & ~Flag_AeroSnapWithClientDecos;
337#if defined(Q_OS_LINUX)
338 if (KDDockWidgets::isWayland()) {
341 m_flags |= Flag_NativeTitleBar;
346 m_flags = m_flags & ~Flag_NativeTitleBar;
350#if (!defined(KDDW_FRONTEND_QT_WINDOWS) && !defined(Q_OS_MACOS))
353 m_flags = m_flags & ~Flag_AeroSnapWithClientDecos;
357#if defined(DOCKS_DEVELOPER_MODE)
359 if (m_internalFlags & InternalFlag_NoAeroSnap) {
361 m_flags = m_flags & ~Flag_AeroSnapWithClientDecos;
365 if (m_flags & Flag_DontUseUtilityFloatingWindows) {
366 m_internalFlags |= InternalFlag_DontUseParentForFloatingWindows;
367 m_internalFlags |= InternalFlag_DontUseQtToolWindowsForFloatingWindows;
370 if (m_flags & Flag_ShowButtonsOnTabBarIfTitleBarHidden) {
372 m_flags |= Flag_HideTitleBarWhenTabsVisible;
376void Config::setDisabledPaintEvents(CustomizableWidgets widgets)
378 d->m_disabledPaintEvents = widgets;
381Config::CustomizableWidgets Config::disabledPaintEvents()
const
383 return d->m_disabledPaintEvents;
386void Config::setMDIPopupThreshold(
int threshold)
388 d->m_mdiPopupThreshold = threshold;
391int Config::mdiPopupThreshold()
const
393 return d->m_mdiPopupThreshold;
396void Config::setDropIndicatorsInhibited(
bool inhibit)
const
398 if (d->m_dropIndicatorsInhibited != inhibit) {
399 d->m_dropIndicatorsInhibited = inhibit;
400 DockRegistry::self()->dptr()->dropIndicatorsInhibitedChanged.emit(inhibit);
404bool Config::dropIndicatorsInhibited()
const
406 return d->m_dropIndicatorsInhibited;
409void Config::setStartDragDistance(
int pixels)
411 d->m_startDragDistance = pixels;
414int Config::startDragDistance()
const
416 return d->m_startDragDistance;
419void Config::printDebug()
421 std::cerr <<
"Flags: " << d->m_flags << d->m_internalFlags <<
"\n";
424void Config::setLayoutSaverStrictMode(
bool is)
426 d->m_layoutSaverStrictMode = is;
429bool Config::layoutSaverUsesStrictMode()
const
431 return d->m_layoutSaverStrictMode;
434void Config::setOnlyProgrammaticDrag(
bool only)
436 d->m_onlyProgrammaticDrag = only;
439bool Config::onlyProgrammaticDrag()
const
441 return d->m_onlyProgrammaticDrag;
Application-wide config to tune certain behaviours of the framework.