1
0
mirror of https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git synced 2025-04-01 02:42:39 +08:00

Replaced configFlags().testFlag() with testConfigFlag() to improve code readibility

This commit is contained in:
Uwe Kindler 2020-06-11 08:06:37 +02:00
parent d04c386948
commit e71884b23d
11 changed files with 29 additions and 27 deletions

View File

@ -424,7 +424,7 @@ void MainWindowPrivate::createContent()
DockWidget->connect(Action, SIGNAL(triggered()), SLOT(raise())); DockWidget->connect(Action, SIGNAL(triggered()), SLOT(raise()));
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
if (!DockManager->configFlags().testFlag(ads::CDockManager::OpaqueUndocking)) if (!ads::CDockManager::testConfigFlag(ads::CDockManager::OpaqueUndocking))
{ {
DockManager->addDockWidget(ads::CenterDockWidgetArea, createActiveXWidget(ViewMenu), RighDockArea); DockManager->addDockWidget(ads::CenterDockWidgetArea, createActiveXWidget(ViewMenu), RighDockArea);
} }

View File

@ -103,10 +103,11 @@ struct DockAreaTitleBarPrivate
/** /**
* Returns true if the given config flag is set * Returns true if the given config flag is set
* Convenience function to ease config flag testing
*/ */
static bool testConfigFlag(CDockManager::eConfigFlag Flag) static bool testConfigFlag(CDockManager::eConfigFlag Flag)
{ {
return CDockManager::configFlags().testFlag(Flag); return CDockManager::testConfigFlag(Flag);
} }
/** /**
@ -212,7 +213,7 @@ IFloatingWidget* DockAreaTitleBarPrivate::makeAreaFloating(const QPoint& Offset,
{ {
QSize Size = DockArea->size(); QSize Size = DockArea->size();
this->DragState = DragState; this->DragState = DragState;
bool OpaqueUndocking = CDockManager::configFlags().testFlag(CDockManager::OpaqueUndocking) || bool OpaqueUndocking = CDockManager::testConfigFlag(CDockManager::OpaqueUndocking) ||
(DraggingFloatingWidget != DragState); (DraggingFloatingWidget != DragState);
CFloatingDockContainer* FloatingDockContainer = nullptr; CFloatingDockContainer* FloatingDockContainer = nullptr;
IFloatingWidget* FloatingWidget; IFloatingWidget* FloatingWidget;
@ -466,7 +467,7 @@ void CDockAreaTitleBar::mousePressEvent(QMouseEvent* ev)
d->DragStartMousePos = ev->pos(); d->DragStartMousePos = ev->pos();
d->DragState = DraggingMousePressed; d->DragState = DraggingMousePressed;
if (CDockManager::configFlags().testFlag(CDockManager::FocusHighlighting)) if (CDockManager::testConfigFlag(CDockManager::FocusHighlighting))
{ {
d->TabBar->currentTab()->setFocus(Qt::OtherFocusReason); d->TabBar->currentTab()->setFocus(Qt::OtherFocusReason);
} }
@ -600,9 +601,10 @@ int CDockAreaTitleBar::indexOf(QWidget *widget) const
} }
//============================================================================ //============================================================================
CTitleBarButton::CTitleBarButton(bool visible /*= true*/, QWidget* parent /*= nullptr*/) : tTitleBarButton(parent), CTitleBarButton::CTitleBarButton(bool visible, QWidget* parent)
Visible(visible), : tTitleBarButton(parent),
HideWhenDisabled(DockAreaTitleBarPrivate::testConfigFlag(CDockManager::DockAreaHideDisabledButtons)) Visible(visible),
HideWhenDisabled(CDockManager::testConfigFlag(CDockManager::DockAreaHideDisabledButtons))
{ {
} }

View File

@ -731,7 +731,7 @@ void CDockAreaWidget::updateTitleBarVisibility()
return; return;
} }
if (CDockManager::configFlags().testFlag(CDockManager::AlwaysShowTabs)) if (CDockManager::testConfigFlag(CDockManager::AlwaysShowTabs))
{ {
return; return;
} }
@ -739,7 +739,7 @@ void CDockAreaWidget::updateTitleBarVisibility()
if (d->TitleBar) if (d->TitleBar)
{ {
bool Hidden = Container->hasTopLevelDockWidget() && (Container->isFloating() bool Hidden = Container->hasTopLevelDockWidget() && (Container->isFloating()
|| CDockManager::configFlags().testFlag(CDockManager::HideSingleCentralWidgetTitleBar)); || CDockManager::testConfigFlag(CDockManager::HideSingleCentralWidgetTitleBar));
d->TitleBar->setVisible(!Hidden); d->TitleBar->setVisible(!Hidden);
} }
} }

View File

@ -299,7 +299,7 @@ public:
CDockSplitter* newSplitter(Qt::Orientation orientation, QWidget* parent = nullptr) CDockSplitter* newSplitter(Qt::Orientation orientation, QWidget* parent = nullptr)
{ {
CDockSplitter* s = new CDockSplitter(orientation, parent); CDockSplitter* s = new CDockSplitter(orientation, parent);
s->setOpaqueResize(CDockManager::configFlags().testFlag(CDockManager::OpaqueSplitterResize)); s->setOpaqueResize(CDockManager::testConfigFlag(CDockManager::OpaqueSplitterResize));
s->setChildrenCollapsible(false); s->setChildrenCollapsible(false);
return s; return s;
} }

View File

@ -54,7 +54,7 @@ public:
template <class QWidgetPtr> template <class QWidgetPtr>
static void setWidgetFocus(QWidgetPtr widget) static void setWidgetFocus(QWidgetPtr widget)
{ {
if (!CDockManager::configFlags().testFlag(CDockManager::FocusHighlighting)) if (!CDockManager::testConfigFlag(CDockManager::FocusHighlighting))
{ {
return; return;
} }

View File

@ -470,7 +470,7 @@ CDockManager::CDockManager(QWidget *parent) :
d->Containers.append(this); d->Containers.append(this);
d->loadStylesheet(); d->loadStylesheet();
if (CDockManager::configFlags().testFlag(CDockManager::FocusHighlighting)) if (CDockManager::testConfigFlag(CDockManager::FocusHighlighting))
{ {
d->FocusController = new CDockFocusController(this); d->FocusController = new CDockFocusController(this);
} }

View File

@ -434,7 +434,7 @@ public:
template <class QWidgetPtr> template <class QWidgetPtr>
static void setWidgetFocus(QWidgetPtr widget) static void setWidgetFocus(QWidgetPtr widget)
{ {
if (!CDockManager::configFlags().testFlag(CDockManager::FocusHighlighting)) if (!CDockManager::testConfigFlag(CDockManager::FocusHighlighting))
{ {
return; return;
} }

View File

@ -237,7 +237,7 @@ CDockWidget::CDockWidget(const QString &title, QWidget *parent) :
SLOT(toggleView(bool))); SLOT(toggleView(bool)));
setToolbarFloatingStyle(false); setToolbarFloatingStyle(false);
if (CDockManager::configFlags().testFlag(CDockManager::FocusHighlighting)) if (CDockManager::testConfigFlag(CDockManager::FocusHighlighting))
{ {
setFocusPolicy(Qt::ClickFocus); setFocusPolicy(Qt::ClickFocus);
} }

View File

@ -114,7 +114,7 @@ struct DockWidgetTabPrivate
*/ */
bool testConfigFlag(CDockManager::eConfigFlag Flag) const bool testConfigFlag(CDockManager::eConfigFlag Flag) const
{ {
return CDockManager::configFlags().testFlag(Flag); return CDockManager::testConfigFlag(Flag);
} }
/** /**
@ -243,7 +243,7 @@ bool DockWidgetTabPrivate::startFloating(eDragState DraggingState)
ADS_PRINT("startFloating"); ADS_PRINT("startFloating");
DragState = DraggingState; DragState = DraggingState;
IFloatingWidget* FloatingWidget = nullptr; IFloatingWidget* FloatingWidget = nullptr;
bool OpaqueUndocking = CDockManager::configFlags().testFlag(CDockManager::OpaqueUndocking) || bool OpaqueUndocking = CDockManager::testConfigFlag(CDockManager::OpaqueUndocking) ||
(DraggingFloatingWidget != DraggingState); (DraggingFloatingWidget != DraggingState);
// If section widget has multiple tabs, we take only one tab // If section widget has multiple tabs, we take only one tab
@ -285,7 +285,7 @@ CDockWidgetTab::CDockWidgetTab(CDockWidget* DockWidget, QWidget *parent) :
setAttribute(Qt::WA_NoMousePropagation, true); setAttribute(Qt::WA_NoMousePropagation, true);
d->DockWidget = DockWidget; d->DockWidget = DockWidget;
d->createLayout(); d->createLayout();
if (CDockManager::configFlags().testFlag(CDockManager::FocusHighlighting)) if (CDockManager::testConfigFlag(CDockManager::FocusHighlighting))
{ {
setFocusPolicy(Qt::ClickFocus); setFocusPolicy(Qt::ClickFocus);
} }
@ -399,7 +399,7 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
{ {
// If we undock, we need to restore the initial position of this // If we undock, we need to restore the initial position of this
// tab because it looks strange if it remains on its dragged position // tab because it looks strange if it remains on its dragged position
if (d->isDraggingState(DraggingTab) && !CDockManager::configFlags().testFlag(CDockManager::OpaqueUndocking)) if (d->isDraggingState(DraggingTab) && !CDockManager::testConfigFlag(CDockManager::OpaqueUndocking))
{ {
parentWidget()->layout()->update(); parentWidget()->layout()->update();
} }
@ -468,7 +468,7 @@ void CDockWidgetTab::setActiveTab(bool active)
d->CloseButton->setVisible(DockWidgetClosable && TabHasCloseButton); d->CloseButton->setVisible(DockWidgetClosable && TabHasCloseButton);
// Focus related stuff // Focus related stuff
if (CDockManager::configFlags().testFlag(CDockManager::FocusHighlighting) && !d->DockWidget->dockManager()->isRestoringState()) if (CDockManager::testConfigFlag(CDockManager::FocusHighlighting) && !d->DockWidget->dockManager()->isRestoringState())
{ {
bool UpdateFocusStyle = false; bool UpdateFocusStyle = false;
if (active && !hasFocus()) if (active && !hasFocus())

View File

@ -391,7 +391,7 @@ struct FloatingDockContainerPrivate
*/ */
static bool testConfigFlag(CDockManager::eConfigFlag Flag) static bool testConfigFlag(CDockManager::eConfigFlag Flag)
{ {
return CDockManager::configFlags().testFlag(Flag); return CDockManager::testConfigFlag(Flag);
} }
/** /**

View File

@ -112,7 +112,7 @@ void FloatingDragPreviewPrivate::updateDropOverlays(const QPoint &GlobalPos)
{ {
ContainerOverlay->hideOverlay(); ContainerOverlay->hideOverlay();
DockAreaOverlay->hideOverlay(); DockAreaOverlay->hideOverlay();
if (CDockManager::configFlags().testFlag(CDockManager::DragPreviewIsDynamic)) if (CDockManager::testConfigFlag(CDockManager::DragPreviewIsDynamic))
{ {
setHidden(false); setHidden(false);
} }
@ -167,7 +167,7 @@ void FloatingDragPreviewPrivate::updateDropOverlays(const QPoint &GlobalPos)
} }
} }
if (CDockManager::configFlags().testFlag(CDockManager::DragPreviewIsDynamic)) if (CDockManager::testConfigFlag(CDockManager::DragPreviewIsDynamic))
{ {
setHidden(DockDropArea != InvalidDockWidgetArea || ContainerDropArea != InvalidDockWidgetArea); setHidden(DockDropArea != InvalidDockWidgetArea || ContainerDropArea != InvalidDockWidgetArea);
} }
@ -203,7 +203,7 @@ void FloatingDragPreviewPrivate::createFloatingWidget()
{ {
FloatingWidget->setGeometry(_this->geometry()); FloatingWidget->setGeometry(_this->geometry());
FloatingWidget->show(); FloatingWidget->show();
if (!CDockManager::configFlags().testFlag(CDockManager::DragPreviewHasWindowFrame)) if (!CDockManager::testConfigFlag(CDockManager::DragPreviewHasWindowFrame))
{ {
QApplication::processEvents(); QApplication::processEvents();
int FrameHeight = FloatingWidget->frameGeometry().height() - FloatingWidget->geometry().height(); int FrameHeight = FloatingWidget->frameGeometry().height() - FloatingWidget->geometry().height();
@ -222,7 +222,7 @@ CFloatingDragPreview::CFloatingDragPreview(QWidget* Content, QWidget* parent) :
{ {
d->Content = Content; d->Content = Content;
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
if (CDockManager::configFlags().testFlag(CDockManager::DragPreviewHasWindowFrame)) if (CDockManager::testConfigFlag(CDockManager::DragPreviewHasWindowFrame))
{ {
setWindowFlags( setWindowFlags(
Qt::Window | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint); Qt::Window | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint);
@ -245,7 +245,7 @@ CFloatingDragPreview::CFloatingDragPreview(QWidget* Content, QWidget* parent) :
// Create a static image of the widget that should get undocked // Create a static image of the widget that should get undocked
// This is like some kind preview image like it is uses in drag and drop // This is like some kind preview image like it is uses in drag and drop
// operations // operations
if (CDockManager::configFlags().testFlag(CDockManager::DragPreviewShowsContentPixmap)) if (CDockManager::testConfigFlag(CDockManager::DragPreviewShowsContentPixmap))
{ {
d->ContentPreviewPixmap = QPixmap(Content->size()); d->ContentPreviewPixmap = QPixmap(Content->size());
Content->render(&d->ContentPreviewPixmap); Content->render(&d->ContentPreviewPixmap);
@ -363,14 +363,14 @@ void CFloatingDragPreview::paintEvent(QPaintEvent* event)
} }
QPainter painter(this); QPainter painter(this);
if (CDockManager::configFlags().testFlag(CDockManager::DragPreviewShowsContentPixmap)) if (CDockManager::testConfigFlag(CDockManager::DragPreviewShowsContentPixmap))
{ {
painter.drawPixmap(QPoint(0, 0), d->ContentPreviewPixmap); painter.drawPixmap(QPoint(0, 0), d->ContentPreviewPixmap);
} }
// If we do not have a window frame then we paint a QRubberBand like // If we do not have a window frame then we paint a QRubberBand like
// frameless window // frameless window
if (!CDockManager::configFlags().testFlag(CDockManager::DragPreviewHasWindowFrame)) if (!CDockManager::testConfigFlag(CDockManager::DragPreviewHasWindowFrame))
{ {
QColor Color = palette().color(QPalette::Active, QPalette::Highlight); QColor Color = palette().color(QPalette::Active, QPalette::Highlight);
QPen Pen = painter.pen(); QPen Pen = painter.pen();