Implemented temporary solution for horizontal DockPanels

Needed to start working on the Mixer and Piano Roll.
This commit is contained in:
Casper Jeukendrup 2021-06-06 23:39:28 +02:00
parent 2012ed4b87
commit 49497d8856
17 changed files with 431 additions and 29 deletions

View file

@ -23,6 +23,7 @@ import QtQuick 2.15
import QtQuick.Controls 2.15
import MuseScore.Ui 1.0
import MuseScore.UiComponents 1.0
import MuseScore.Dock 1.0
import MuseScore.AppShell 1.0
@ -213,6 +214,58 @@ DockPage {
}
InspectorForm {}
},
// =============================================
// Horizontal Panels
// =============================================
DockPanel {
id: mixerPanel
objectName: "mixerPanel"
title: qsTrc("appshell", "Mixer")
allowedAreas: Qt.TopDockWidgetArea | Qt.BottomDockWidgetArea
height: root.defaultPanelWidth
minimumHeight: root.defaultPanelWidth
maximumHeight: root.defaultPanelWidth
tabifyPanel: pianoRollPanel
Rectangle {
anchors.fill: parent
color: ui.theme.backgroundPrimaryColor
StyledTextLabel {
anchors.centerIn: parent
text: mixerPanel.title
}
}
},
DockPanel {
id: pianoRollPanel
objectName: "pianoRollPanel"
title: qsTrc("appshell", "Piano Roll")
allowedAreas: Qt.TopDockWidgetArea | Qt.BottomDockWidgetArea
height: root.defaultPanelWidth
minimumHeight: root.defaultPanelWidth
maximumHeight: root.defaultPanelWidth
Rectangle {
anchors.fill: parent
color: ui.theme.backgroundPrimaryColor
StyledTextLabel {
anchors.centerIn: parent
text: pianoRollPanel.title
}
}
}
]

View file

@ -64,4 +64,31 @@ Dock.DockPage {
Rectangle { color: ui.theme.backgroundPrimaryColor }
}
]
panelsDockingHolders: [
Dock.DockPanelHolder {
objectName: root.objectName + "_panelsDockingHolderLeft"
location: Dock.DockBase.Left
Rectangle { color: ui.theme.backgroundPrimaryColor }
},
Dock.DockPanelHolder {
objectName: root.objectName + "_panelsDockingHolderRight"
location: Dock.DockBase.Right
Rectangle { color: ui.theme.backgroundPrimaryColor }
},
Dock.DockPanelHolder {
objectName: root.objectName + "_panelsDockingHolderTop"
location: Dock.DockBase.Top
Rectangle { color: ui.theme.backgroundPrimaryColor }
},
Dock.DockPanelHolder {
objectName: root.objectName + "_panelsDockingHolderBottom"
location: Dock.DockBase.Bottom
Rectangle { color: ui.theme.backgroundPrimaryColor }
}
]
}

View file

@ -25,6 +25,7 @@
#include "docktoolbar.h"
#include "dockcentral.h"
#include "dockpanel.h"
#include "dockpanelholder.h"
#include "dockstatusbar.h"
#include "log.h"
@ -36,7 +37,8 @@ DockPage::DockPage(QQuickItem* parent)
m_mainToolBars(this),
m_toolBars(this),
m_toolBarsDockingHolders(this),
m_panels(this)
m_panels(this),
m_panelsDockingHolders(this)
{
}
@ -72,6 +74,11 @@ QQmlListProperty<DockToolBarHolder> DockPage::toolBarsDockingHoldersProperty()
return m_toolBarsDockingHolders.property();
}
QQmlListProperty<DockPanelHolder> DockPage::panelsDockingHoldersProperty()
{
return m_panelsDockingHolders.property();
}
QList<DockToolBar*> DockPage::mainToolBars() const
{
return m_mainToolBars.list();
@ -82,22 +89,22 @@ QList<DockToolBar*> DockPage::toolBars() const
//! NOTE: Order is important for correct drawing
auto list = m_toolBars.list();
DockToolBarHolder* leftHolder = holderByLocation(DockBase::DockLocation::Left);
DockToolBarHolder* leftHolder = toolBarHolderByLocation(DockBase::DockLocation::Left);
if (leftHolder) {
list.prepend(leftHolder);
}
DockToolBarHolder* rightHolder = holderByLocation(DockBase::DockLocation::Right);
DockToolBarHolder* rightHolder = toolBarHolderByLocation(DockBase::DockLocation::Right);
if (rightHolder) {
list.append(rightHolder);
}
DockToolBarHolder* bottomHolder = holderByLocation(DockBase::DockLocation::Bottom);
DockToolBarHolder* bottomHolder = toolBarHolderByLocation(DockBase::DockLocation::Bottom);
if (bottomHolder) {
list.prepend(bottomHolder);
}
DockToolBarHolder* topHolder = holderByLocation(DockBase::DockLocation::Top);
DockToolBarHolder* topHolder = toolBarHolderByLocation(DockBase::DockLocation::Top);
if (topHolder) {
list.append(topHolder);
}
@ -122,7 +129,35 @@ DockStatusBar* DockPage::statusBar() const
QList<DockPanel*> DockPage::panels() const
{
return m_panels.list();
//! NOTE: Order is important for correct drawing
auto list = m_panels.list();
DockPanelHolder* leftHolder = panelHolderByLocation(DockBase::DockLocation::Left);
if (leftHolder) {
list.prepend(leftHolder);
}
DockPanelHolder* rightHolder = panelHolderByLocation(DockBase::DockLocation::Right);
if (rightHolder) {
list.append(rightHolder);
}
DockPanelHolder* bottomHolder = panelHolderByLocation(DockBase::DockLocation::Bottom);
if (bottomHolder) {
list.prepend(bottomHolder);
}
DockPanelHolder* topHolder = panelHolderByLocation(DockBase::DockLocation::Top);
if (topHolder) {
list.append(topHolder);
}
return list;
}
QList<DockPanelHolder*> DockPage::panelsHolders() const
{
return m_panelsDockingHolders.list();
}
DockBase* DockPage::dockByName(const QString& dockName) const
@ -136,7 +171,7 @@ DockBase* DockPage::dockByName(const QString& dockName) const
return nullptr;
}
DockToolBarHolder* DockPage::holderByLocation(DockBase::DockLocation location) const
DockToolBarHolder* DockPage::toolBarHolderByLocation(DockBase::DockLocation location) const
{
for (DockToolBarHolder* holder : m_toolBarsDockingHolders.list()) {
if (holder->location() == location) {
@ -147,6 +182,17 @@ DockToolBarHolder* DockPage::holderByLocation(DockBase::DockLocation location) c
return nullptr;
}
DockPanelHolder* DockPage::panelHolderByLocation(DockBase::DockLocation location) const
{
for (DockPanelHolder* holder : m_panelsDockingHolders.list()) {
if (holder->location() == location) {
return holder;
}
}
return nullptr;
}
void DockPage::setUri(const QString& uri)
{
if (uri == m_uri) {

View file

@ -36,6 +36,7 @@ class DockPanel;
class DockCentral;
class DockStatusBar;
class DockToolBarHolder;
class DockPanelHolder;
class DockPage : public QQuickItem
{
Q_OBJECT
@ -45,6 +46,7 @@ class DockPage : public QQuickItem
Q_PROPERTY(QQmlListProperty<mu::dock::DockToolBar> toolBars READ toolBarsProperty)
Q_PROPERTY(QQmlListProperty<mu::dock::DockToolBarHolder> toolBarsDockingHolders READ toolBarsDockingHoldersProperty)
Q_PROPERTY(QQmlListProperty<mu::dock::DockPanel> panels READ panelsProperty)
Q_PROPERTY(QQmlListProperty<mu::dock::DockPanelHolder> panelsDockingHolders READ panelsDockingHoldersProperty)
Q_PROPERTY(mu::dock::DockCentral* centralDock READ centralDock WRITE setCentralDock NOTIFY centralDockChanged)
Q_PROPERTY(mu::dock::DockStatusBar* statusBar READ statusBar WRITE setStatusBar NOTIFY statusBarChanged)
@ -58,8 +60,9 @@ public:
QQmlListProperty<DockToolBar> mainToolBarsProperty();
QQmlListProperty<DockToolBar> toolBarsProperty();
QQmlListProperty<DockPanel> panelsProperty();
QQmlListProperty<DockToolBarHolder> toolBarsDockingHoldersProperty();
QQmlListProperty<DockPanel> panelsProperty();
QQmlListProperty<DockPanelHolder> panelsDockingHoldersProperty();
QList<DockToolBar*> mainToolBars() const;
QList<DockToolBar*> toolBars() const;
@ -67,10 +70,12 @@ public:
DockCentral* centralDock() const;
DockStatusBar* statusBar() const;
QList<DockPanel*> panels() const;
QList<DockPanelHolder*> panelsHolders() const;
QList<DockBase*> allDocks() const;
DockBase* dockByName(const QString& dockName) const;
DockToolBarHolder* holderByLocation(DockBase::DockLocation location) const;
DockToolBarHolder* toolBarHolderByLocation(DockBase::DockLocation location) const;
DockPanelHolder* panelHolderByLocation(DockBase::DockLocation location) const;
public slots:
void setUri(const QString& uri);
@ -90,6 +95,7 @@ private:
uicomponents::QmlListProperty<DockToolBar> m_toolBars;
uicomponents::QmlListProperty<DockToolBarHolder> m_toolBarsDockingHolders;
uicomponents::QmlListProperty<DockPanel> m_panels;
uicomponents::QmlListProperty<DockPanelHolder> m_panelsDockingHolders;
DockCentral* m_central = nullptr;
DockStatusBar* m_statusBar = nullptr;
};

View file

@ -47,7 +47,6 @@ signals:
private:
DockType type() const override;
DockPanel* m_tabifyPanel = nullptr;
};
}

View file

@ -0,0 +1,37 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2021 MuseScore BVBA and others
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "dockpanelholder.h"
using namespace mu::dock;
DockPanelHolder::DockPanelHolder(QQuickItem* parent)
: DockPanel(parent)
{
setVisible(false);
//setMovable(false);
}
DockType DockPanelHolder::type() const
{
return DockType::PanelDockingHolder;
}

View file

@ -0,0 +1,41 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2021 MuseScore BVBA and others
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef MU_DOCK_DOCKPANELHOLDER_H
#define MU_DOCK_DOCKPANELHOLDER_H
#include "dockpanel.h"
namespace mu::dock {
class DockPanelHolder : public DockPanel
{
Q_OBJECT
public:
explicit DockPanelHolder(QQuickItem* parent = nullptr);
private:
DockType type() const override;
};
}
#endif // MU_DOCK_DOCKPANELHOLDER_H

View file

@ -28,6 +28,7 @@
#include "dockwindow.h"
#include "dockpanel.h"
#include "dockpanelholder.h"
#include "dockstatusbar.h"
#include "docktoolbarholder.h"
#include "dockcentral.h"
@ -86,6 +87,7 @@ void DockSetup::registerQmlTypes()
{
qmlRegisterType<DockWindow>("MuseScore.Dock", 1, 0, "DockWindow");
qmlRegisterType<DockPanel>("MuseScore.Dock", 1, 0, "DockPanel");
qmlRegisterType<DockPanelHolder>("MuseScore.Dock", 1, 0, "DockPanelHolder");
qmlRegisterType<DockStatusBar>("MuseScore.Dock", 1, 0, "DockStatusBar");
qmlRegisterType<DockToolBar>("MuseScore.Dock", 1, 0, "DockToolBar");
qmlRegisterType<DockToolBarHolder>("MuseScore.Dock", 1, 0, "DockToolBarHolder");

View file

@ -30,6 +30,7 @@ namespace mu::dock {
enum class DockType {
Undefined = -1,
Panel,
PanelDockingHolder,
ToolBar,
ToolBarDockingHolder,
StatusBar,

View file

@ -43,6 +43,8 @@ set (DOCKWINDOW_SRC
${CMAKE_CURRENT_LIST_DIR}/dockpage.h
${CMAKE_CURRENT_LIST_DIR}/dockpanel.cpp
${CMAKE_CURRENT_LIST_DIR}/dockpanel.h
${CMAKE_CURRENT_LIST_DIR}/dockpanelholder.cpp
${CMAKE_CURRENT_LIST_DIR}/dockpanelholder.h
${CMAKE_CURRENT_LIST_DIR}/dockstatusbar.cpp
${CMAKE_CURRENT_LIST_DIR}/dockstatusbar.h
${CMAKE_CURRENT_LIST_DIR}/docktoolbar.cpp

View file

@ -33,6 +33,7 @@
#include "docktoolbarholder.h"
#include "dockcentral.h"
#include "dockpanel.h"
#include "dockpanelholder.h"
using namespace mu::dock;
@ -70,6 +71,7 @@ void DockWindow::componentComplete()
mainWindow()->hideAllDockingHoldersRequested().onNotify(this, [this]() {
hideCurrentToolBarDockingHolder();
hideCurrentPanelDockingHolder();
});
mainWindow()->showToolBarDockingHolderRequested().onReceive(this, [this](const QPoint& mouseGlobalPos) {
@ -96,6 +98,32 @@ void DockWindow::componentComplete()
m_currentToolBarDockingHolder = holder;
});
mainWindow()->showPanelDockingHolderRequested().onReceive(this, [this](const QPoint& mouseGlobalPos) {
QPoint localPos = m_mainWindow->mapFromGlobal(mouseGlobalPos);
QRect mainFrameGeometry = m_mainWindow->rect();
if (!mainFrameGeometry.contains(localPos)) {
return;
}
if (isMouseOverCurrentPanelDockingHolder(localPos)) {
return;
}
DockPanelHolder* holder = resolvePanelDockingHolder(localPos);
if (holder != m_currentPanelDockingHolder) {
hideCurrentPanelDockingHolder();
if (holder) {
qDebug() << holder->location();
holder->show();
}
}
m_currentPanelDockingHolder = holder;
});
}
void DockWindow::onQuit()
@ -186,10 +214,7 @@ void DockWindow::loadPageContent(const DockPage* page)
addDock(page->centralDock(), KDDockWidgets::Location_OnRight);
for (DockPanel* panel : page->panels()) {
//! TODO: add an ability to change location of panels
addDock(panel, KDDockWidgets::Location_OnLeft);
}
loadPagePanels(page);
loadPageToolbars(page);
@ -277,6 +302,55 @@ void DockWindow::loadPageToolbars(const DockPage* page)
}
}
void DockWindow::loadPagePanels(const DockPage* page)
{
QList<DockPanel*> leftSidePanels;
QList<DockPanel*> rightSidePanels;
QList<DockPanel*> topSidePanels;
QList<DockPanel*> bottomSidePanels;
QList<DockPanel*> pagePanels = page->panels();
for (DockPanel* panel : pagePanels) {
switch (panel->location()) {
case DockBase::DockLocation::Left:
leftSidePanels << panel;
break;
case DockBase::DockLocation::Right:
rightSidePanels << panel;
break;
case DockBase::DockLocation::Top:
topSidePanels << panel;
break;
case DockBase::DockLocation::Bottom:
bottomSidePanels << panel;
break;
default:
if (panel->allowedAreas() & Qt::BottomDockWidgetArea) {
bottomSidePanels << panel;
} else {
leftSidePanels << panel;
}
break;
}
}
for (int i = leftSidePanels.size() - 1; i >= 0; --i) {
addDock(leftSidePanels[i], KDDockWidgets::Location_OnLeft);
}
for (int i = 0; i < rightSidePanels.size(); ++i) {
addDock(rightSidePanels[i], KDDockWidgets::Location_OnRight);
}
for (int i = 0; i < bottomSidePanels.size(); ++i) {
addDock(bottomSidePanels[i], KDDockWidgets::Location_OnBottom);
}
for (int i = topSidePanels.size() - 1; i >= 0; --i) {
addDock(topSidePanels[i], KDDockWidgets::Location_OnTop);
}
}
void DockWindow::addDock(DockBase* dock, KDDockWidgets::Location location, const DockBase* relativeTo)
{
IF_ASSERT_FAILED(dock) {
@ -403,15 +477,49 @@ DockToolBarHolder* DockWindow::resolveToolbarDockingHolder(const QPoint& localPo
newHolder = m_mainToolBarDockingHolder;
} else if (localPos.y() > centralFrameGeometry.top()
&& localPos.y() < centralFrameGeometry.top() + MAX_DISTANCE_TO_HOLDER) { // page top toolbar holder
newHolder = page->holderByLocation(DockBase::DockLocation::Top);
newHolder = page->toolBarHolderByLocation(DockBase::DockLocation::Top);
} else if (localPos.y() < centralFrameGeometry.bottom()) { // page left toolbar holder
if (localPos.x() < MAX_DISTANCE_TO_HOLDER) {
newHolder = page->holderByLocation(DockBase::DockLocation::Left);
newHolder = page->toolBarHolderByLocation(DockBase::DockLocation::Left);
} else if (localPos.x() > mainFrameGeometry.right() - MAX_DISTANCE_TO_HOLDER) { // page right toolbar holder
newHolder = page->holderByLocation(DockBase::DockLocation::Right);
newHolder = page->toolBarHolderByLocation(DockBase::DockLocation::Right);
}
} else if (localPos.y() < mainFrameGeometry.bottom()) { // page bottom toolbar holder
newHolder = page->holderByLocation(DockBase::DockLocation::Bottom);
newHolder = page->toolBarHolderByLocation(DockBase::DockLocation::Bottom);
}
return newHolder;
}
DockPanelHolder* DockWindow::resolvePanelDockingHolder(const QPoint& localPos) const
{
const DockPage* page = currentPage();
if (!page) {
return nullptr;
}
const KDDockWidgets::DockWidgetBase* centralDock = page->centralDock()->dockWidget();
if (!centralDock) {
return nullptr;
}
QRect centralFrameGeometry = centralDock->frameGeometry();
centralFrameGeometry.setTopLeft(m_mainWindow->mapFromGlobal(centralDock->mapToGlobal({ centralDock->x(), centralDock->y() })));
QRect mainFrameGeometry = m_mainWindow->rect();
DockPanelHolder* newHolder = nullptr;
if (localPos.y() > centralFrameGeometry.top()
&& localPos.y() < centralFrameGeometry.top() + MAX_DISTANCE_TO_HOLDER) { // page top panel holder
newHolder = page->panelHolderByLocation(DockBase::DockLocation::Top);
} else if (localPos.y() < centralFrameGeometry.bottom()) { // page left panel holder
if (localPos.x() < MAX_DISTANCE_TO_HOLDER) {
newHolder = page->panelHolderByLocation(DockBase::DockLocation::Left);
} else if (localPos.x() > mainFrameGeometry.right() - MAX_DISTANCE_TO_HOLDER) { // page right panel holder
newHolder = page->panelHolderByLocation(DockBase::DockLocation::Right);
}
} else if (localPos.y() < mainFrameGeometry.bottom()) { // page bottom panel holder
newHolder = page->panelHolderByLocation(DockBase::DockLocation::Bottom);
}
return newHolder;
@ -427,6 +535,16 @@ void DockWindow::hideCurrentToolBarDockingHolder()
m_currentToolBarDockingHolder = nullptr;
}
void DockWindow::hideCurrentPanelDockingHolder()
{
if (!m_currentPanelDockingHolder) {
return;
}
m_currentPanelDockingHolder->hide();
m_currentPanelDockingHolder = nullptr;
}
bool DockWindow::isMouseOverCurrentToolBarDockingHolder(const QPoint& mouseLocalPos) const
{
if (!m_currentToolBarDockingHolder || !m_mainWindow) {
@ -442,3 +560,19 @@ bool DockWindow::isMouseOverCurrentToolBarDockingHolder(const QPoint& mouseLocal
holderFrameGeometry.setTopLeft(m_mainWindow->mapFromGlobal(holderDock->mapToGlobal({ holderDock->x(), holderDock->y() })));
return holderFrameGeometry.contains(mouseLocalPos);
}
bool DockWindow::isMouseOverCurrentPanelDockingHolder(const QPoint& mouseLocalPos) const
{
if (!m_currentPanelDockingHolder || !m_mainWindow) {
return false;
}
const KDDockWidgets::DockWidgetBase* holderDock = m_currentPanelDockingHolder->dockWidget();
if (!holderDock) {
return false;
}
QRect holderFrameGeometry = holderDock->frameGeometry();
holderFrameGeometry.setTopLeft(m_mainWindow->mapFromGlobal(holderDock->mapToGlobal({ holderDock->x(), holderDock->y() })));
return holderFrameGeometry.contains(mouseLocalPos);
}

View file

@ -43,6 +43,7 @@ class LayoutSaver;
namespace mu::dock {
class DockToolBar;
class DockToolBarHolder;
class DockPanelHolder;
class DockPage;
class DockBase;
class DockWindow : public QQuickItem, public async::Asyncable
@ -91,6 +92,7 @@ private:
void loadPageContent(const DockPage* page);
void unitePanelsToTabs(const DockPage* page);
void loadPageToolbars(const DockPage* page);
void loadPagePanels(const DockPage* page);
void addDock(DockBase* dock, KDDockWidgets::Location location, const DockBase* relativeTo = nullptr);
@ -107,16 +109,20 @@ private:
void initDocks(DockPage* page);
DockToolBarHolder* resolveToolbarDockingHolder(const QPoint& localPos) const;
void hideCurrentToolBarDockingHolder();
bool isMouseOverCurrentToolBarDockingHolder(const QPoint& mouseLocalPos) const;
DockPanelHolder* resolvePanelDockingHolder(const QPoint& localPos) const;
void hideCurrentPanelDockingHolder();
bool isMouseOverCurrentPanelDockingHolder(const QPoint& mouseLocalPos) const;
KDDockWidgets::MainWindowBase* m_mainWindow = nullptr;
QString m_currentPageUri;
uicomponents::QmlListProperty<DockToolBar> m_toolBars;
DockToolBarHolder* m_mainToolBarDockingHolder = nullptr;
uicomponents::QmlListProperty<DockPage> m_pages;
DockToolBarHolder* m_currentToolBarDockingHolder = nullptr;
DockPanelHolder* m_currentPanelDockingHolder = nullptr;
};
}

View file

@ -108,6 +108,10 @@ KDDockWidgets::DropIndicatorOverlayInterface::DropLocation DropIndicators::hover
mainWindow()->requestShowToolBarDockingHolder(globalPos);
}
if (needShowPanelHolders()) {
mainWindow()->requestShowPanelDockingHolder(globalPos);
}
if (isDropAllowed(dropLocation)) {
setCurrentDropLocation(dropLocation);
showDropAreaIfNeed(dropRect);
@ -251,20 +255,29 @@ bool DropIndicators::isDropAllowed(DropLocation location) const
return isAreaAllowed;
}
bool DropIndicators::isHoveredDockAllowedForDrop() const
bool DropIndicators::isDropOnHoveredDockAllowed() const
{
DockType hoveredDockType = readPropertiesFromObject(hoveredDock()).type;
DockType hoveredDockType = dockType(hoveredDock());
if (isDraggedDockToolBar()) {
return hoveredDockType == DockType::ToolBar || hoveredDockType == DockType::ToolBarDockingHolder;
}
if (isDraggedDockPanel()) {
return hoveredDockType == DockType::Panel || hoveredDockType == DockType::PanelDockingHolder;
}
return true;
}
bool DropIndicators::isDraggedDockToolBar() const
{
return readPropertiesFromObject(draggedDock()).type == DockType::ToolBar;
return dockType(draggedDock()) == DockType::ToolBar;
}
bool DropIndicators::isDraggedDockPanel() const
{
return dockType(draggedDock()) == DockType::Panel;
}
bool DropIndicators::needShowToolBarHolders() const
@ -277,6 +290,16 @@ bool DropIndicators::needShowToolBarHolders() const
return areas.testFlag(Qt::LeftDockWidgetArea) || areas.testFlag(Qt::RightDockWidgetArea);
}
bool DropIndicators::needShowPanelHolders() const
{
if (!isDraggedDockPanel()) {
return false;
}
Qt::DockWidgetAreas areas = readPropertiesFromObject(draggedDock()).allowedAreas;
return areas.testFlag(Qt::TopDockWidgetArea) || areas.testFlag(Qt::BottomDockWidgetArea);
}
const KDDockWidgets::DockWidgetBase* DropIndicators::draggedDock() const
{
auto windowBeingDragged = KDDockWidgets::DragController::instance()->windowBeingDragged();
@ -307,9 +330,14 @@ mu::framework::Orientation DropIndicators::dockOrientation(const KDDockWidgets::
return dock.width() < dock.height() ? framework::Orientation::Vertical : framework::Orientation::Horizontal;
}
DockType DropIndicators::dockType(const KDDockWidgets::DockWidgetBase* dock) const
{
return readPropertiesFromObject(dock).type;
}
DropIndicators::DropLocation DropIndicators::dropLocationForToolBar(const QPoint& hoveredGlobalPos) const
{
if (!isHoveredDockAllowedForDrop()) {
if (!isDropOnHoveredDockAllowed()) {
return DropLocation_None;
}
@ -383,7 +411,7 @@ QRect DropIndicators::dropAreaRectForPanel(DropLocation location) const
void DropIndicators::showDropAreaIfNeed(const QRect& dropRect)
{
if (dropRect.isValid() && isHoveredDockAllowedForDrop()) {
if (dropRect.isValid() && isDropOnHoveredDockAllowed()) {
m_rubberBand->setGeometry(dropRect);
m_rubberBand->setVisible(true);
}
@ -407,7 +435,7 @@ void DropIndicators::updateToolBarOrientation()
framework::Orientation newOrientation = framework::Orientation::Horizontal;
bool isHoveredDockVertical = dockOrientation(*hoveredDock) == framework::Orientation::Vertical;
if (isHoveredDockAllowedForDrop() && isHoveredDockVertical) {
if (isDropOnHoveredDockAllowed() && isHoveredDockVertical) {
newOrientation = framework::Orientation::Vertical;
}

View file

@ -80,13 +80,16 @@ private:
bool isIndicatorVisible(DropLocation location) const;
bool isDropAllowed(DropLocation location) const;
bool isHoveredDockAllowedForDrop() const;
bool isDropOnHoveredDockAllowed() const;
bool isDraggedDockToolBar() const;
bool isDraggedDockPanel() const;
bool needShowToolBarHolders() const;
bool needShowPanelHolders() const;
const KDDockWidgets::DockWidgetBase* hoveredDock() const;
const KDDockWidgets::DockWidgetBase* draggedDock() const;
DockType dockType(const KDDockWidgets::DockWidgetBase* dock) const;
framework::Orientation dockOrientation(const KDDockWidgets::DockWidgetBase& dock) const;
DropLocation dropLocationForToolBar(const QPoint& hoveredGlobalPos) const;

View file

@ -90,12 +90,22 @@ Channel<QString, mu::framework::Orientation> MainWindowProvider::changeToolBarOr
void MainWindowProvider::requestShowToolBarDockingHolder(const QPoint& globalPos)
{
m_showDockingHolderRequested.send(globalPos);
m_showToolBarDockingHolderRequested.send(globalPos);
}
mu::async::Channel<QPoint> MainWindowProvider::showToolBarDockingHolderRequested() const
{
return m_showDockingHolderRequested;
return m_showToolBarDockingHolderRequested;
}
void MainWindowProvider::requestShowPanelDockingHolder(const QPoint& globalPos)
{
m_showPanelDockingHolderRequested.send(globalPos);
}
mu::async::Channel<QPoint> MainWindowProvider::showPanelDockingHolderRequested() const
{
return m_showPanelDockingHolderRequested;
}
void MainWindowProvider::requestHideAllDockingHolders()

View file

@ -42,12 +42,16 @@ public:
void requestShowToolBarDockingHolder(const QPoint& globalPos) override;
async::Channel<QPoint> showToolBarDockingHolderRequested() const override;
void requestShowPanelDockingHolder(const QPoint& globalPos) override;
async::Channel<QPoint> showPanelDockingHolderRequested() const override;
void requestHideAllDockingHolders() override;
async::Notification hideAllDockingHoldersRequested() const override;
private:
async::Channel<QString, framework::Orientation> m_dockOrientationChanged;
async::Channel<QPoint> m_showDockingHolderRequested;
async::Channel<QPoint> m_showToolBarDockingHolderRequested;
async::Channel<QPoint> m_showPanelDockingHolderRequested;
async::Notification m_hideAllHoldersRequested;
};
}

View file

@ -54,6 +54,9 @@ public:
virtual void requestShowToolBarDockingHolder(const QPoint& globalPos) = 0;
virtual async::Channel<QPoint> showToolBarDockingHolderRequested() const = 0;
virtual void requestShowPanelDockingHolder(const QPoint& globalPos) = 0;
virtual async::Channel<QPoint> showPanelDockingHolderRequested() const = 0;
virtual void requestHideAllDockingHolders() = 0;
virtual async::Notification hideAllDockingHoldersRequested() const = 0;
};