From 21189759dda6e3fa1be265d18cdef3860da6154e Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Wed, 28 Jun 2023 07:32:49 +0200 Subject: [PATCH] Removed drop icons for sidebar drops --- src/DockOverlay.cpp | 121 +++++++----------------------------- src/FloatingDragPreview.cpp | 2 + src/ads_globals.h | 1 + src/src.pro | 2 +- 4 files changed, 28 insertions(+), 98 deletions(-) diff --git a/src/DockOverlay.cpp b/src/DockOverlay.cpp index 123df0a..4f30705 100644 --- a/src/DockOverlay.cpp +++ b/src/DockOverlay.cpp @@ -282,10 +282,7 @@ struct DockOverlayCrossPrivate baseRect = areaRect; } - //if (!internal::isSideBarArea(DockWidgetArea)) - //{ - p.fillRect(baseRect, backgroundColor); - //} + p.fillRect(baseRect, backgroundColor); if (areaRect.isValid()) { @@ -304,23 +301,22 @@ struct DockOverlayCrossPrivate } p.restore(); - //if (!internal::isSideBarArea(DockWidgetArea)) - //{ - p.save(); - // Draw outer border - pen = p.pen(); - pen.setColor(borderColor); - pen.setWidth(1); - p.setBrush(Qt::NoBrush); - p.setPen(pen); - p.drawRect(baseRect); - // draw window title bar - p.setBrush(borderColor); - QRectF FrameRect(baseRect.topLeft(), QSizeF(baseRect.width(), baseSize.height() / 10)); - p.drawRect(FrameRect); - p.restore(); - //} + p.save(); + // Draw outer border + pen = p.pen(); + pen.setColor(borderColor); + pen.setWidth(1); + p.setBrush(Qt::NoBrush); + p.setPen(pen); + p.drawRect(baseRect); + + // draw window title bar + p.setBrush(borderColor); + QRectF FrameRect(baseRect.topLeft(), QSizeF(baseRect.width(), baseSize.height() / 10)); + p.drawRect(FrameRect); + p.restore(); + // Draw arrow for outer container drop indicators if (IsOuterContainerArea) @@ -359,36 +355,6 @@ struct DockOverlayCrossPrivate p.drawPolygon(Arrow); } - // Draw the pin icons - if (internal::isSideBarArea(DockWidgetArea)) - { - static QIcon PinIcon; - if (PinIcon.isNull()) - { - std::cout << "Initializing pin icon" << std::endl; - QFile file(":/ads/images/vs-pin-button.svg"); - file.open(QIODevice::ReadOnly); - QByteArray baData = file.readAll(); - baData.replace("#000000", borderColor.name(QColor::HexRgb).toLatin1()); - //baData.replace("#ffffff", overlayColor.name(QColor::HexArgb).toLatin1()); - //std::cout << borderColor.name(QColor::HexRgb) << std::endl; - QSvgRenderer svgRenderer(baData); - QPixmap pix(svgRenderer.defaultSize()); - pix.fill(Qt::transparent); - // create painter to act over pixmap - QPainter pixPainter(&pix); - svgRenderer.render(&pixPainter); - PinIcon = QIcon(pix); - } - //p.drawPixmap(0, PinIcon.paint(painter, rect, alignment, mode, state)); - auto Rect = QRect(0, 0, 16, 16); - //Rect.setSize(baseRect.size() * 0.8); - Rect.moveCenter(baseRect.center().toPoint()); - PinIcon.paint(&p, Rect, Qt::AlignCenter); - //auto Pixmap = PinIcon.pixmap(_this->windowHandle(), QSize(16, 16)); - //p.drawPixmap(QPoint(0, 0), Pixmap); - } - pm.setDevicePixelRatio(DevicePixelRatio); return pm; } @@ -489,10 +455,12 @@ DockWidgetArea CDockOverlay::dropAreaUnderCursor() const } auto DockArea = qobject_cast(d->TargetWidget.data()); - if (!DockArea) + if (!DockArea && CDockManager::autoHideConfigFlags().testFlag(CDockManager::AutoHideFeatureEnabled)) { auto Rect = rect(); const QPoint pos = mapFromGlobal(QCursor::pos()); + + std::cout << "pos.y: " << pos.y() << " d->sideBarMouseZone(SideBarTop) " << d->sideBarMouseZone(SideBarTop) << std::endl; if (pos.x() < d->sideBarMouseZone(SideBarLeft)) { return LeftAutoHideArea; @@ -515,6 +483,10 @@ DockWidgetArea CDockOverlay::dropAreaUnderCursor() const } return Result; } + else if (!DockArea) + { + return Result; + } if (DockArea->allowedAreas().testFlag(CenterDockWidgetArea) && !DockArea->titleBar()->isHidden() @@ -612,6 +584,7 @@ void CDockOverlay::paintEvent(QPaintEvent* event) double Factor = (CDockOverlay::ModeContainerOverlay == d->Mode) ? 3 : 2; + std::cout << "paint: da: " << da << std::endl; switch (da) { case TopDockWidgetArea: r.setHeight(r.height() / Factor); break; @@ -707,23 +680,6 @@ QPoint DockOverlayCrossPrivate::areaGridPosition(const DockWidgetArea area) default: return QPoint(); } } - else if (CDockManager::autoHideConfigFlags().testFlag(CDockManager::AutoHideFeatureEnabled)) - { - switch (area) - { - case TopDockWidgetArea: return QPoint(1, 3); - case RightDockWidgetArea: return QPoint(3, 5); - case BottomDockWidgetArea: return QPoint(5, 3); - case LeftDockWidgetArea: return QPoint(3, 1); - case CenterDockWidgetArea: return QPoint(3, 3); - - case TopAutoHideArea: return QPoint(0, 3); - case RightAutoHideArea: return QPoint(3, 6); - case BottomAutoHideArea: return QPoint(6, 3); - case LeftAutoHideArea: return QPoint(3, 0); - default: return QPoint(); - } - } else { switch (area) @@ -778,15 +734,6 @@ void CDockOverlayCross::setupOverlayCross(CDockOverlay::eMode Mode) areaWidgets.insert(LeftDockWidgetArea, d->createDropIndicatorWidget(LeftDockWidgetArea, Mode)); areaWidgets.insert(CenterDockWidgetArea, d->createDropIndicatorWidget(CenterDockWidgetArea, Mode)); - if (CDockManager::autoHideConfigFlags().testFlag(CDockManager::AutoHideFeatureEnabled) - && CDockOverlay::ModeContainerOverlay == Mode) - { - areaWidgets.insert(TopAutoHideArea, d->createDropIndicatorWidget(TopAutoHideArea, Mode)); - areaWidgets.insert(RightAutoHideArea, d->createDropIndicatorWidget(RightAutoHideArea, Mode)); - areaWidgets.insert(BottomAutoHideArea, d->createDropIndicatorWidget(BottomAutoHideArea, Mode)); - areaWidgets.insert(LeftAutoHideArea, d->createDropIndicatorWidget(LeftAutoHideArea, Mode)); - } - #if QT_VERSION >= 0x050600 d->LastDevicePixelRatio = devicePixelRatioF(); #else @@ -873,26 +820,6 @@ void CDockOverlayCross::setAreaWidgets(const QHash& wi d->GridLayout->setColumnStretch(3, 0); d->GridLayout->setColumnStretch(4, 1); } - else if (CDockManager::autoHideConfigFlags().testFlag(CDockManager::AutoHideFeatureEnabled)) - { - d->GridLayout->setContentsMargins(4, 4, 4, 4); - d->GridLayout->setSpacing(4); - d->GridLayout->setRowStretch(0, 0); - d->GridLayout->setRowStretch(1, 0); - d->GridLayout->setRowStretch(2, 1); - d->GridLayout->setRowStretch(3, 1); - d->GridLayout->setRowStretch(4, 1); - d->GridLayout->setRowStretch(5, 0); - d->GridLayout->setRowStretch(6, 0); - - d->GridLayout->setColumnStretch(0, 0); - d->GridLayout->setColumnStretch(1, 0); - d->GridLayout->setColumnStretch(2, 1); - d->GridLayout->setColumnStretch(3, 1); - d->GridLayout->setColumnStretch(4, 1); - d->GridLayout->setColumnStretch(5, 0); - d->GridLayout->setColumnStretch(6, 0); - } else { d->GridLayout->setContentsMargins(4, 4, 4, 4); diff --git a/src/FloatingDragPreview.cpp b/src/FloatingDragPreview.cpp index 4758853..987577e 100644 --- a/src/FloatingDragPreview.cpp +++ b/src/FloatingDragPreview.cpp @@ -128,6 +128,8 @@ void FloatingDragPreviewPrivate::updateDropOverlays(const QPoint &GlobalPos) auto DockAreaOverlay = DockManager->dockAreaOverlay(); auto DockDropArea = DockAreaOverlay->dropAreaUnderCursor(); auto ContainerDropArea = ContainerOverlay->dropAreaUnderCursor(); + std::cout << "ContainerDropArea " << ContainerDropArea << std::endl; + std::cout << "DockDropArea " << DockDropArea << std::endl; if (!TopContainer) { diff --git a/src/ads_globals.h b/src/ads_globals.h index 20c341e..e331576 100644 --- a/src/ads_globals.h +++ b/src/ads_globals.h @@ -89,6 +89,7 @@ enum DockWidgetArea InvalidDockWidgetArea = NoDockWidgetArea, OuterDockAreas = TopDockWidgetArea | LeftDockWidgetArea | RightDockWidgetArea | BottomDockWidgetArea, + AutoHideDockAreas = LeftAutoHideArea | RightAutoHideArea | TopAutoHideArea | BottomAutoHideArea, AllDockAreas = OuterDockAreas | CenterDockWidgetArea }; Q_DECLARE_FLAGS(DockWidgetAreas, DockWidgetArea) diff --git a/src/src.pro b/src/src.pro index c134dc4..79344b1 100644 --- a/src/src.pro +++ b/src/src.pro @@ -5,7 +5,7 @@ TARGET = $$qtLibraryTarget(qtadvanceddocking) DEFINES += QT_DEPRECATED_WARNINGS TEMPLATE = lib DESTDIR = $${ADS_OUT_ROOT}/lib -QT += core gui widgets svg +QT += core gui widgets !adsBuildStatic { CONFIG += shared