toolbars will now use the size of the content to determine their minimum size
This commit is contained in:
parent
1f39be6422
commit
83fc41b248
18 changed files with 191 additions and 281 deletions
|
@ -94,6 +94,8 @@ void StartupScenario::run()
|
|||
|
||||
std::string StartupScenario::startupPageUri(StartupSessionType sessionType) const
|
||||
{
|
||||
return NOTATION_URI;
|
||||
|
||||
switch (sessionType) {
|
||||
case StartupSessionType::StartEmpty:
|
||||
case StartupSessionType::StartWithNewScore:
|
||||
|
|
|
@ -29,6 +29,8 @@ import MuseScore.AppShell 1.0
|
|||
ApplicationWindow {
|
||||
id: root
|
||||
|
||||
objectName: "ApplicationWindow"
|
||||
|
||||
width: 1150
|
||||
height: 800
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ import MuseScore.UiComponents 1.0
|
|||
Item {
|
||||
id: root
|
||||
|
||||
width: radioButtonList.contentWidth
|
||||
height: radioButtonList.contentHeight
|
||||
width: radioButtonList.width
|
||||
height: radioButtonList.height
|
||||
|
||||
property alias navigation: navCtrl
|
||||
|
||||
|
@ -72,6 +72,9 @@ Item {
|
|||
|
||||
model: root.items
|
||||
|
||||
width: contentItem.childrenRect.width
|
||||
height: contentItem.childrenRect.height
|
||||
|
||||
delegate: GradientTabButton {
|
||||
id: radioButtonDelegate
|
||||
|
||||
|
|
|
@ -75,7 +75,6 @@ DockPage {
|
|||
}
|
||||
|
||||
readonly property int defaultPanelWidth: 300
|
||||
readonly property int toolBarHeight: 48
|
||||
|
||||
mainToolBars: [
|
||||
DockToolBar {
|
||||
|
@ -84,9 +83,9 @@ DockPage {
|
|||
objectName: "notationToolBar"
|
||||
title: qsTrc("appshell", "Notation toolbar")
|
||||
|
||||
minimumWidth: 198
|
||||
movable: false
|
||||
|
||||
contentComponent: NotationToolBar {
|
||||
NotationToolBar {
|
||||
navigation.section: root.topToolKeyNavSec
|
||||
navigation.order: 2
|
||||
|
||||
|
@ -104,11 +103,7 @@ DockPage {
|
|||
objectName: pageModel.playbackToolBarName()
|
||||
title: qsTrc("appshell", "Playback controls")
|
||||
|
||||
width: root.width / 3
|
||||
minimumWidth: floating ? 526 : 452
|
||||
minimumHeight: floating ? 56 : root.toolBarHeight
|
||||
|
||||
contentComponent: PlaybackToolBar {
|
||||
PlaybackToolBar {
|
||||
navigation.section: root.topToolKeyNavSec
|
||||
navigation.order: 3
|
||||
|
||||
|
@ -120,12 +115,9 @@ DockPage {
|
|||
objectName: pageModel.undoRedoToolBarName()
|
||||
title: qsTrc("appshell", "Undo/redo toolbar")
|
||||
|
||||
minimumWidth: 74
|
||||
maximumWidth: 74
|
||||
|
||||
movable: false
|
||||
|
||||
contentComponent: UndoRedoToolBar {
|
||||
UndoRedoToolBar {
|
||||
navigation.section: root.topToolKeyNavSec
|
||||
navigation.order: 4
|
||||
}
|
||||
|
@ -139,12 +131,9 @@ DockPage {
|
|||
objectName: pageModel.noteInputBarName()
|
||||
title: qsTrc("appshell", "Note input")
|
||||
|
||||
horizontalPreferredSize: Qt.size(720, root.toolBarHeight)
|
||||
verticalPreferredSize: Qt.size(root.toolBarHeight, 400)
|
||||
|
||||
allowedAreas: { Qt.AllDockWidgetAreas }
|
||||
|
||||
contentComponent: NoteInputBar {
|
||||
NoteInputBar {
|
||||
orientation: noteInputBar.orientation
|
||||
|
||||
navigation.section: root.noteInputKeyNavSec
|
||||
|
|
|
@ -55,9 +55,7 @@ DockPage {
|
|||
objectName: root.objectName + "_notationToolBar"
|
||||
title: qsTrc("appshell", "Notation toolbar")
|
||||
|
||||
minimumWidth: 198
|
||||
|
||||
contentComponent: NotationToolBar {
|
||||
NotationToolBar {
|
||||
navigation.section: root.topToolKeyNavSec
|
||||
navigation.order: 2
|
||||
|
||||
|
@ -75,11 +73,7 @@ DockPage {
|
|||
objectName: root.objectName + "_playbackToolBar"
|
||||
title: qsTrc("appshell", "Playback controls")
|
||||
|
||||
width: root.width / 3
|
||||
minimumWidth: floating ? 526 : 476
|
||||
minimumHeight: floating ? 56 : 48
|
||||
|
||||
contentComponent: PlaybackToolBar {
|
||||
PlaybackToolBar {
|
||||
navigation.section: root.topToolKeyNavSec
|
||||
navigation.order: 3
|
||||
|
||||
|
@ -93,12 +87,9 @@ DockPage {
|
|||
objectName: root.objectName + "_undoRedoToolBar"
|
||||
title: qsTrc("appshell", "Undo/redo toolbar")
|
||||
|
||||
minimumWidth: 74
|
||||
maximumWidth: 74
|
||||
|
||||
movable: false
|
||||
|
||||
contentComponent: UndoRedoToolBar {
|
||||
UndoRedoToolBar {
|
||||
navigation.section: root.topToolKeyNavSec
|
||||
navigation.order: 4
|
||||
}
|
||||
|
@ -109,7 +100,7 @@ DockPage {
|
|||
DockToolBar {
|
||||
objectName: "publishToolBar"
|
||||
|
||||
contentComponent: PublishToolBar {
|
||||
PublishToolBar {
|
||||
navigation.section: root.publishToolBarKeyNavSec
|
||||
navigation.order: 1
|
||||
}
|
||||
|
|
|
@ -59,12 +59,9 @@ DockWindow {
|
|||
objectName: "mainToolBar"
|
||||
title: qsTrc("appshell", "Main toolbar")
|
||||
|
||||
width: root.width / 2
|
||||
minimumWidth: 304
|
||||
|
||||
movable: false
|
||||
|
||||
contentComponent: MainToolBar {
|
||||
MainToolBar {
|
||||
navigation.section: root.topToolKeyNavSec
|
||||
navigation.order: 1
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import MuseScore.Dock 1.0
|
|||
DockPanelView {
|
||||
id: root
|
||||
|
||||
default property alias content : contentLoader.sourceComponent
|
||||
default property alias contentComponent : contentLoader.sourceComponent
|
||||
|
||||
Loader {
|
||||
id: contentLoader
|
||||
|
|
|
@ -29,83 +29,129 @@ import MuseScore.Dock 1.0
|
|||
DockToolBarView {
|
||||
id: root
|
||||
|
||||
property Component contentComponent
|
||||
default property alias contentComponent: contentLoader.sourceComponent
|
||||
property alias movable: gripButton.visible
|
||||
|
||||
onOrientationChanged: {
|
||||
contentBackground.printInfo()
|
||||
}
|
||||
|
||||
onFloatingChanged: {
|
||||
contentBackground.printInfo()
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
id: contentBackground
|
||||
|
||||
color: ui.theme.backgroundPrimaryColor
|
||||
|
||||
Loader {
|
||||
id: loader
|
||||
anchors.fill: parent
|
||||
|
||||
sourceComponent: root.orientation === Qt.Horizontal ? horizontalView : verticalView
|
||||
onLoaded: {
|
||||
root.setDraggableMouseArea(loader.item.gripMouseArea)
|
||||
}
|
||||
function printInfo() {
|
||||
console.debug("------------------------------")
|
||||
console.debug("obj: " + objectName)
|
||||
console.debug("contentSize: " + Qt.size(contentLoader.width, contentLoader.height))
|
||||
console.debug("bakgroundSize: " + Qt.size(contentBackground.width, contentBackground.height))
|
||||
console.debug("------------------------------\n")
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: horizontalView
|
||||
Component.onCompleted: {
|
||||
Qt.callLater(printInfo)
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
spacing: 0
|
||||
Item {
|
||||
id: contentRect
|
||||
|
||||
property alias gripMouseArea: gripButton.mouseArea
|
||||
readonly property int margins: 2
|
||||
readonly property int gripButtonWidth: gripButton.visible ? gripButton.width : 0
|
||||
readonly property int gripButtonHeight: gripButton.visible ? gripButton.height : 0
|
||||
|
||||
FlatButton {
|
||||
id: gripButton
|
||||
|
||||
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
|
||||
Layout.margins: 2
|
||||
|
||||
mouseArea.objectName: root.objectName + "_toolBarMouseAreaHorizontal"
|
||||
mouseArea.objectName: root.objectName + "_gripButton"
|
||||
|
||||
transparent: true
|
||||
icon: IconCode.TOOLBAR_GRIP
|
||||
|
||||
visible: root.movable
|
||||
Component.onCompleted: {
|
||||
root.setDraggableMouseArea(mouseArea)
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
sourceComponent: root.contentComponent
|
||||
id: contentLoader
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: verticalView
|
||||
states: [
|
||||
State {
|
||||
name: "HORIZONTAL"
|
||||
when: root.orientation === Qt.Horizontal
|
||||
|
||||
ColumnLayout {
|
||||
spacing: 0
|
||||
PropertyChanges {
|
||||
target: root
|
||||
|
||||
property alias gripMouseArea: gripButton.mouseArea
|
||||
minimumWidth: contentLoader.item ? 2 * contentRect.margins + contentRect.gripButtonWidth + contentLoader.width : 0
|
||||
minimumHeight: contentLoader.item ? 2 * contentRect.margins + contentLoader.height : 0
|
||||
}
|
||||
|
||||
FlatButton {
|
||||
id: gripButton
|
||||
PropertyChanges {
|
||||
target: gripButton
|
||||
|
||||
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
|
||||
Layout.margins: 2
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: contentRect.margins
|
||||
anchors.top: undefined
|
||||
|
||||
mouseArea.objectName: root.objectName + "_toolBarMouseAreaVertical"
|
||||
x: 0
|
||||
y: (contentBackground.height - gripButton.height) / 2
|
||||
}
|
||||
|
||||
PropertyChanges {
|
||||
target: contentLoader
|
||||
|
||||
anchors.left: gripButton.visible ? gripButton.right : parent.left
|
||||
anchors.leftMargin: contentRect.margins
|
||||
anchors.top: undefined
|
||||
|
||||
x: 0
|
||||
y: (contentBackground.height - contentLoader.height) / 2
|
||||
}
|
||||
},
|
||||
|
||||
State {
|
||||
name: "VERTICAL"
|
||||
when: root.orientation === Qt.Vertical
|
||||
|
||||
PropertyChanges {
|
||||
target: root
|
||||
|
||||
minimumWidth: contentLoader.item ? 2 * contentRect.margins + contentLoader.width : 0
|
||||
minimumHeight: contentLoader.item ? 2 * contentRect.margins + contentRect.gripButtonHeight + contentLoader.height : 0
|
||||
}
|
||||
|
||||
PropertyChanges {
|
||||
target: gripButton
|
||||
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: contentRect.margins
|
||||
anchors.left: undefined
|
||||
|
||||
x: (contentBackground.width - gripButton.width) / 2
|
||||
y: 0
|
||||
|
||||
transparent: true
|
||||
icon: IconCode.TOOLBAR_GRIP
|
||||
rotation: 90
|
||||
|
||||
visible: root.movable
|
||||
}
|
||||
|
||||
Loader {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
PropertyChanges {
|
||||
target: contentLoader
|
||||
|
||||
sourceComponent: root.contentComponent
|
||||
anchors.top: gripButton.bottom
|
||||
anchors.topMargin: contentRect.margins
|
||||
anchors.left: undefined
|
||||
|
||||
x: (contentBackground.width - contentLoader.width) / 2
|
||||
y: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ DockToolBarHolder::DockToolBarHolder(QQuickItem* parent)
|
|||
: DockToolBarView(parent)
|
||||
{
|
||||
setVisible(false);
|
||||
setMovable(false);
|
||||
}
|
||||
|
||||
void DockToolBarHolder::componentComplete()
|
||||
|
|
|
@ -22,8 +22,6 @@
|
|||
|
||||
#include "docktoolbarview.h"
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
#include "thirdparty/KDDockWidgets/src/DockWidgetQuick.h"
|
||||
#include "thirdparty/KDDockWidgets/src/private/TitleBar_p.h"
|
||||
#include "thirdparty/KDDockWidgets/src/private/DragController_p.h"
|
||||
|
@ -32,10 +30,6 @@
|
|||
|
||||
using namespace mu::dock;
|
||||
|
||||
static constexpr qreal TOOLBAR_GRIP_MARGIN = 4;
|
||||
static constexpr qreal TOOLBAR_GRIP_WIDTH = 28;
|
||||
static constexpr qreal TOOLBAR_GRIP_HEIGHT = 36;
|
||||
|
||||
const int DockToolBarView::MIN_SIDE_SIZE = 48;
|
||||
const int DockToolBarView::MAX_SIDE_SIZE = std::numeric_limits<int>::max();
|
||||
|
||||
|
@ -94,7 +88,12 @@ public:
|
|||
|
||||
void setDockWidget(KDDockWidgets::DockWidgetBase* dockWidget)
|
||||
{
|
||||
IF_ASSERT_FAILED(dockWidget) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_dockWidget = dockWidget;
|
||||
setObjectName(dockWidget->objectName() + "_draggableArea");
|
||||
}
|
||||
|
||||
void setMouseArea(QQuickItem* mouseArea)
|
||||
|
@ -115,19 +114,6 @@ DockToolBarView::DockToolBarView(QQuickItem* parent)
|
|||
{
|
||||
setAllowedAreas(Qt::TopDockWidgetArea);
|
||||
setLocation(DockLocation::Top);
|
||||
|
||||
setMinimumWidth(MIN_SIDE_SIZE);
|
||||
setMaximumWidth(MAX_SIDE_SIZE);
|
||||
setMinimumHeight(MIN_SIDE_SIZE);
|
||||
setMaximumHeight(MIN_SIDE_SIZE);
|
||||
|
||||
setWidth(MAX_SIDE_SIZE);
|
||||
setHeight(MIN_SIDE_SIZE);
|
||||
}
|
||||
|
||||
bool DockToolBarView::movable() const
|
||||
{
|
||||
return m_movable;
|
||||
}
|
||||
|
||||
Qt::Orientation DockToolBarView::orientation() const
|
||||
|
@ -135,78 +121,6 @@ Qt::Orientation DockToolBarView::orientation() const
|
|||
return m_orientation;
|
||||
}
|
||||
|
||||
void DockToolBarView::setDraggableMouseArea(QQuickItem* mouseArea)
|
||||
{
|
||||
IF_ASSERT_FAILED(m_draggableArea) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_draggableArea->setParent(mouseArea);
|
||||
m_draggableArea->setMouseArea(mouseArea);
|
||||
}
|
||||
|
||||
QSize DockToolBarView::horizontalPreferredSize() const
|
||||
{
|
||||
return m_horizontalPreferredSize;
|
||||
}
|
||||
|
||||
QSize DockToolBarView::verticalPreferredSize() const
|
||||
{
|
||||
return m_verticalPreferredSize;
|
||||
}
|
||||
|
||||
void DockToolBarView::setMinimumWidth(int width)
|
||||
{
|
||||
if (movable() && orientation() == Qt::Horizontal) {
|
||||
width += TOOLBAR_GRIP_WIDTH + TOOLBAR_GRIP_MARGIN;
|
||||
}
|
||||
|
||||
DockBase::setMinimumWidth(width);
|
||||
}
|
||||
|
||||
void DockToolBarView::setMinimumHeight(int height)
|
||||
{
|
||||
if (movable() && orientation() == Qt::Vertical) {
|
||||
height += TOOLBAR_GRIP_HEIGHT + TOOLBAR_GRIP_MARGIN;
|
||||
}
|
||||
|
||||
DockBase::setMinimumHeight(height);
|
||||
}
|
||||
|
||||
void DockToolBarView::setMaximumWidth(int width)
|
||||
{
|
||||
int preferredWidth = this->width();
|
||||
|
||||
if (movable() && orientation() == Qt::Horizontal) {
|
||||
preferredWidth = TOOLBAR_GRIP_WIDTH + TOOLBAR_GRIP_MARGIN;
|
||||
}
|
||||
|
||||
width = std::max(width, preferredWidth);
|
||||
DockBase::setMaximumWidth(width);
|
||||
}
|
||||
|
||||
void DockToolBarView::setMaximumHeight(int height)
|
||||
{
|
||||
int preferredHeight = this->height();
|
||||
|
||||
if (movable() && orientation() == Qt::Horizontal) {
|
||||
preferredHeight = TOOLBAR_GRIP_HEIGHT + TOOLBAR_GRIP_MARGIN;
|
||||
}
|
||||
|
||||
height = std::max(height, preferredHeight);
|
||||
DockBase::setMaximumHeight(height);
|
||||
}
|
||||
|
||||
void DockToolBarView::setMovable(bool movable)
|
||||
{
|
||||
if (m_movable == movable) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_movable = movable;
|
||||
emit movableChanged(m_movable);
|
||||
}
|
||||
|
||||
void DockToolBarView::setOrientation(Qt::Orientation orientation)
|
||||
{
|
||||
bool isChangingAllowed = isOrientationChangingAllowed();
|
||||
|
@ -218,34 +132,24 @@ void DockToolBarView::setOrientation(Qt::Orientation orientation)
|
|||
m_orientation = orientation;
|
||||
emit orientationChanged(orientation);
|
||||
|
||||
updateSizeConstraints();
|
||||
applySizeConstraintsByOrientation();
|
||||
}
|
||||
|
||||
void DockToolBarView::setHorizontalPreferredSize(QSize horizontalPreferredSize)
|
||||
void DockToolBarView::setDraggableMouseArea(QQuickItem* mouseArea)
|
||||
{
|
||||
if (m_horizontalPreferredSize == horizontalPreferredSize) {
|
||||
IF_ASSERT_FAILED(m_draggableArea) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_horizontalPreferredSize = horizontalPreferredSize;
|
||||
emit horizontalPreferredSizeChanged(m_horizontalPreferredSize);
|
||||
}
|
||||
|
||||
void DockToolBarView::setVerticalPreferredSize(QSize verticalPreferredSize)
|
||||
{
|
||||
if (m_verticalPreferredSize == verticalPreferredSize) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_verticalPreferredSize = verticalPreferredSize;
|
||||
emit verticalPreferredSizeChanged(m_verticalPreferredSize);
|
||||
m_draggableArea->setParent(mouseArea);
|
||||
m_draggableArea->setMouseArea(mouseArea);
|
||||
}
|
||||
|
||||
void DockToolBarView::componentComplete()
|
||||
{
|
||||
DockBase::componentComplete();
|
||||
|
||||
updateSizeConstraints();
|
||||
applySizeConstraintsByOrientation();
|
||||
|
||||
m_draggableArea->setDockWidget(dockWidget());
|
||||
}
|
||||
|
@ -255,36 +159,25 @@ DockType DockToolBarView::type() const
|
|||
return DockType::ToolBar;
|
||||
}
|
||||
|
||||
void DockToolBarView::updateSizeConstraints()
|
||||
{
|
||||
bool isHorizontal = m_orientation == Qt::Horizontal;
|
||||
QSize preferredSize = isHorizontal ? horizontalPreferredSize() : verticalPreferredSize();
|
||||
|
||||
if (preferredSize.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isHorizontal) {
|
||||
setHeight(MIN_SIDE_SIZE);
|
||||
setWidth(preferredSize.width());
|
||||
|
||||
setMinimumWidth(preferredSize.width());
|
||||
setMinimumHeight(MIN_SIDE_SIZE);
|
||||
setMaximumWidth(MAX_SIDE_SIZE);
|
||||
setMaximumHeight(MIN_SIDE_SIZE);
|
||||
} else {
|
||||
setWidth(MIN_SIDE_SIZE);
|
||||
setHeight(preferredSize.height());
|
||||
|
||||
setMinimumWidth(MIN_SIDE_SIZE);
|
||||
setMinimumHeight(preferredSize.height());
|
||||
setMaximumWidth(MIN_SIDE_SIZE);
|
||||
setMaximumHeight(MAX_SIDE_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
bool DockToolBarView::isOrientationChangingAllowed() const
|
||||
{
|
||||
return allowedAreas().testFlag(Qt::LeftDockWidgetArea)
|
||||
|| allowedAreas().testFlag(Qt::RightDockWidgetArea);
|
||||
}
|
||||
|
||||
void DockToolBarView::applySizeConstraintsByOrientation()
|
||||
{
|
||||
if (m_orientation == Qt::Horizontal) {
|
||||
setMinimumWidth(MIN_SIDE_SIZE);
|
||||
setMinimumHeight(MIN_SIDE_SIZE);
|
||||
|
||||
setMaximumWidth(MAX_SIDE_SIZE);
|
||||
setMaximumHeight(MIN_SIDE_SIZE);
|
||||
} else {
|
||||
setMinimumWidth(MIN_SIDE_SIZE);
|
||||
setMinimumHeight(MIN_SIDE_SIZE);
|
||||
|
||||
setMaximumWidth(MIN_SIDE_SIZE);
|
||||
setMaximumHeight(MAX_SIDE_SIZE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,40 +30,20 @@ class DockToolBarView : public DockBase
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(bool movable READ movable WRITE setMovable NOTIFY movableChanged)
|
||||
Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
|
||||
|
||||
Q_PROPERTY(
|
||||
QSize horizontalPreferredSize READ horizontalPreferredSize WRITE setHorizontalPreferredSize NOTIFY horizontalPreferredSizeChanged)
|
||||
Q_PROPERTY(QSize verticalPreferredSize READ verticalPreferredSize WRITE setVerticalPreferredSize NOTIFY verticalPreferredSizeChanged)
|
||||
|
||||
public:
|
||||
explicit DockToolBarView(QQuickItem* parent = nullptr);
|
||||
|
||||
bool movable() const;
|
||||
Qt::Orientation orientation() const;
|
||||
|
||||
Q_INVOKABLE void setDraggableMouseArea(QQuickItem* mouseArea);
|
||||
|
||||
QSize horizontalPreferredSize() const;
|
||||
QSize verticalPreferredSize() const;
|
||||
|
||||
public slots:
|
||||
void setMinimumWidth(int width) override;
|
||||
void setMinimumHeight(int height) override;
|
||||
void setMaximumWidth(int width) override;
|
||||
void setMaximumHeight(int height) override;
|
||||
|
||||
void setMovable(bool movable);
|
||||
void setOrientation(Qt::Orientation orientation);
|
||||
void setHorizontalPreferredSize(QSize horizontalPreferredSize);
|
||||
void setVerticalPreferredSize(QSize verticalPreferredSize);
|
||||
|
||||
signals:
|
||||
void movableChanged(bool movable);
|
||||
void orientationChanged(Qt::Orientation orientation);
|
||||
void horizontalPreferredSizeChanged(QSize horizontalPreferredSize);
|
||||
void verticalPreferredSizeChanged(QSize verticalPreferredSize);
|
||||
|
||||
protected:
|
||||
void componentComplete() override;
|
||||
|
@ -74,17 +54,15 @@ protected:
|
|||
static const int MAX_SIDE_SIZE;
|
||||
|
||||
private:
|
||||
void updateSizeConstraints();
|
||||
|
||||
bool isOrientationChangingAllowed() const;
|
||||
|
||||
void applySizeConstraintsByOrientation();
|
||||
|
||||
class DraggableArea;
|
||||
DraggableArea* m_draggableArea = nullptr;
|
||||
|
||||
bool m_movable = true;
|
||||
Qt::Orientation m_orientation = Qt::Horizontal;
|
||||
QSize m_horizontalPreferredSize;
|
||||
QSize m_verticalPreferredSize;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -189,11 +189,6 @@ DockType DockBase::type() const
|
|||
return DockType::Undefined;
|
||||
}
|
||||
|
||||
void DockBase::resize()
|
||||
{
|
||||
applySizeConstraints();
|
||||
}
|
||||
|
||||
void DockBase::init()
|
||||
{
|
||||
applySizeConstraints();
|
||||
|
@ -263,8 +258,8 @@ void DockBase::componentComplete()
|
|||
|
||||
listenFloatingChanges();
|
||||
|
||||
connect(this, &DockBase::minimumSizeChanged, this, &DockBase::resize);
|
||||
connect(this, &DockBase::maximumSizeChanged, this, &DockBase::resize);
|
||||
connect(this, &DockBase::minimumSizeChanged, this, &DockBase::applySizeConstraints);
|
||||
connect(this, &DockBase::maximumSizeChanged, this, &DockBase::applySizeConstraints);
|
||||
}
|
||||
|
||||
void DockBase::applySizeConstraints()
|
||||
|
@ -293,7 +288,10 @@ void DockBase::applySizeConstraints()
|
|||
|
||||
if (auto floatingWindow = m_dockWidget->floatingWindow()) {
|
||||
QRect rect(floatingWindow->dragRect().topLeft(), minimumSize);
|
||||
|
||||
floatingWindow->setGeometry(rect);
|
||||
floatingWindow->setMinimumSize(minimumSize);
|
||||
floatingWindow->setMaximumSize(maximumSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -315,6 +313,7 @@ void DockBase::listenFloatingChanges()
|
|||
|
||||
connect(frame, &KDDockWidgets::Frame::isInMainWindowChanged, this, [=]() {
|
||||
doSetFloating(!frame->isInMainWindow());
|
||||
applySizeConstraints();
|
||||
}, Qt::UniqueConnection);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -84,10 +84,10 @@ public:
|
|||
public slots:
|
||||
void setTitle(const QString& title);
|
||||
|
||||
virtual void setMinimumWidth(int width);
|
||||
virtual void setMinimumHeight(int height);
|
||||
virtual void setMaximumWidth(int width);
|
||||
virtual void setMaximumHeight(int height);
|
||||
void setMinimumWidth(int width);
|
||||
void setMinimumHeight(int height);
|
||||
void setMaximumWidth(int width);
|
||||
void setMaximumHeight(int height);
|
||||
|
||||
void setAllowedAreas(Qt::DockWidgetAreas areas);
|
||||
|
||||
|
@ -115,10 +115,9 @@ protected:
|
|||
KDDockWidgets::DockWidgetQuick* dockWidget() const;
|
||||
|
||||
private slots:
|
||||
void resize();
|
||||
void applySizeConstraints();
|
||||
|
||||
private:
|
||||
void applySizeConstraints();
|
||||
void listenFloatingChanges();
|
||||
|
||||
void doSetFloating(bool floating);
|
||||
|
|
|
@ -33,6 +33,9 @@ Item {
|
|||
property Component sectionDelegate: Item {}
|
||||
property Component itemDelegate: Item {}
|
||||
|
||||
property alias contentWidth: loader.width
|
||||
property alias contentHeight: loader.height
|
||||
|
||||
property int cellWidth: 0
|
||||
property int cellHeight: 0
|
||||
|
||||
|
@ -69,7 +72,8 @@ Item {
|
|||
}
|
||||
|
||||
Loader {
|
||||
anchors.fill: parent
|
||||
id: loader
|
||||
|
||||
sourceComponent: isHorizontal ? horizontalView : verticalView
|
||||
}
|
||||
|
||||
|
@ -79,16 +83,17 @@ Item {
|
|||
Row {
|
||||
spacing: privateProperties.spacingBeforeSection
|
||||
|
||||
height: childrenRect.height
|
||||
|
||||
Repeater {
|
||||
model: Boolean(root.model) ? privateProperties.modelSections() : []
|
||||
|
||||
Row {
|
||||
spacing: privateProperties.spacingAfterSection
|
||||
height: parent.height
|
||||
|
||||
height: childrenRect.height
|
||||
|
||||
GridViewSection {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
width: root.sectionWidth
|
||||
height: root.sectionHeight
|
||||
|
||||
|
@ -96,8 +101,6 @@ Item {
|
|||
}
|
||||
|
||||
GridViewDelegate {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
model: Boolean(root.model) ? root.model : null
|
||||
|
||||
itemDelegate: root.itemDelegate
|
||||
|
@ -122,16 +125,17 @@ Item {
|
|||
Column {
|
||||
spacing: privateProperties.spacingBeforeSection
|
||||
|
||||
width: childrenRect.width
|
||||
|
||||
Repeater {
|
||||
model: Boolean(root.model) ? privateProperties.modelSections() : []
|
||||
|
||||
Column {
|
||||
spacing: privateProperties.spacingAfterSection
|
||||
width: parent.width
|
||||
|
||||
width: childrenRect.width
|
||||
|
||||
GridViewSection {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
width: root.sectionWidth
|
||||
height: root.sectionHeight
|
||||
|
||||
|
@ -139,8 +143,6 @@ Item {
|
|||
}
|
||||
|
||||
GridViewDelegate {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
model: Boolean(root.model) ? root.model : null
|
||||
|
||||
itemDelegate: root.itemDelegate
|
||||
|
|
|
@ -31,6 +31,9 @@ Rectangle {
|
|||
|
||||
signal activeFocusRequested()
|
||||
|
||||
width: view.width
|
||||
height: view.height
|
||||
|
||||
color: ui.theme.backgroundPrimaryColor
|
||||
|
||||
Component.onCompleted: {
|
||||
|
@ -57,9 +60,7 @@ Rectangle {
|
|||
ListView {
|
||||
id: view
|
||||
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
width: contentWidth
|
||||
width: contentItem.childrenRect.width
|
||||
height: contentItem.childrenRect.height
|
||||
|
||||
orientation: Qt.Horizontal
|
||||
|
|
|
@ -37,6 +37,9 @@ Rectangle {
|
|||
|
||||
property bool floating: false
|
||||
|
||||
width: gridView.width
|
||||
height: gridView.height
|
||||
|
||||
color: ui.theme.backgroundPrimaryColor
|
||||
|
||||
QtObject {
|
||||
|
@ -62,7 +65,9 @@ Rectangle {
|
|||
|
||||
GridViewSectional {
|
||||
id: gridView
|
||||
anchors.fill: parent
|
||||
|
||||
width: contentWidth
|
||||
height: contentHeight
|
||||
|
||||
sectionRole: "section"
|
||||
|
||||
|
@ -193,7 +198,7 @@ Rectangle {
|
|||
width: gridView.cellWidth
|
||||
height: gridView.cellHeight
|
||||
|
||||
icon: IconCode.CONFIGURE
|
||||
icon: IconCode.SETTINGS_COG
|
||||
iconFont: ui.theme.toolbarIconsFont
|
||||
transparent: true
|
||||
navigation.panel: keynavSub
|
||||
|
@ -218,22 +223,21 @@ Rectangle {
|
|||
PropertyChanges {
|
||||
target: gridView
|
||||
sectionWidth: 1
|
||||
sectionHeight: root.height
|
||||
sectionHeight: gridView.height
|
||||
rows: 1
|
||||
columns: gridView.noLimit
|
||||
}
|
||||
|
||||
AnchorChanges {
|
||||
target: customizeButton
|
||||
anchors.right: root.right
|
||||
anchors.verticalCenter: root.verticalCenter
|
||||
anchors.left: gridView.right
|
||||
}
|
||||
},
|
||||
State {
|
||||
when: !privatesProperties.isHorizontal
|
||||
PropertyChanges {
|
||||
target: gridView
|
||||
sectionWidth: root.width
|
||||
sectionWidth: gridView.width
|
||||
sectionHeight: 1
|
||||
rows: gridView.noLimit
|
||||
columns: 2
|
||||
|
@ -241,8 +245,7 @@ Rectangle {
|
|||
|
||||
AnchorChanges {
|
||||
target: customizeButton
|
||||
anchors.bottom: root.bottom
|
||||
anchors.right: root.right
|
||||
anchors.top: gridView.bottom
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -30,6 +30,9 @@ Rectangle {
|
|||
|
||||
property alias navigation: navPanel
|
||||
|
||||
width: content.width
|
||||
height: content.height
|
||||
|
||||
color: ui.theme.backgroundPrimaryColor
|
||||
|
||||
Component.onCompleted: {
|
||||
|
@ -48,7 +51,7 @@ Rectangle {
|
|||
}
|
||||
|
||||
Row {
|
||||
anchors.centerIn: parent
|
||||
id: content
|
||||
|
||||
height: childrenRect.height
|
||||
spacing: 2
|
||||
|
|
|
@ -36,6 +36,9 @@ Rectangle {
|
|||
property alias navigation: navPanel
|
||||
property bool floating: false
|
||||
|
||||
width: content.width
|
||||
height: content.height
|
||||
|
||||
color: ui.theme.backgroundPrimaryColor
|
||||
|
||||
NavigationPanel {
|
||||
|
@ -55,10 +58,11 @@ Rectangle {
|
|||
}
|
||||
|
||||
Column {
|
||||
id: content
|
||||
|
||||
spacing: 14
|
||||
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: parent.width
|
||||
width: childrenRect.width
|
||||
|
||||
enabled: playbackModel.isPlayAllowed
|
||||
|
||||
|
@ -68,8 +72,8 @@ Rectangle {
|
|||
spacing: 0
|
||||
|
||||
ListView {
|
||||
Layout.preferredWidth: childrenRect.width
|
||||
Layout.preferredHeight: childrenRect.height
|
||||
Layout.preferredWidth: contentItem.childrenRect.width
|
||||
Layout.preferredHeight: contentItem.childrenRect.height
|
||||
|
||||
contentHeight: root.floating ? 32 : 48
|
||||
spacing: 4
|
||||
|
@ -81,7 +85,6 @@ Rectangle {
|
|||
|
||||
delegate: Loader {
|
||||
id: itemLoader
|
||||
anchors.verticalCenter: parent ? parent.verticalCenter : undefined
|
||||
|
||||
sourceComponent: Boolean(model.code) || model.subitems.length !== 0 ? menuItemComp : separatorComp
|
||||
|
||||
|
|
Loading…
Reference in a new issue