From d003a8dc1f0e274b87a7478af6306cb7a231851a Mon Sep 17 00:00:00 2001 From: reionwong Date: Sat, 11 Sep 2021 14:41:22 +0800 Subject: [PATCH] Improved desktop margins --- desktop/desktop.cpp | 9 +++++++++ qml/Desktop/Main.qml | 3 +++ qml/FolderGridItem.qml | 6 +++--- qml/FolderGridView.qml | 2 +- qml/FolderPage.qml | 1 + qml/main.qml | 3 +++ 6 files changed, 20 insertions(+), 4 deletions(-) diff --git a/desktop/desktop.cpp b/desktop/desktop.cpp index 4ee39fc..c46e272 100644 --- a/desktop/desktop.cpp +++ b/desktop/desktop.cpp @@ -37,6 +37,7 @@ Desktop::Desktop(QObject *parent) updateMargins(); connect(&m_dockInterface, SIGNAL(primaryGeometryChanged()), this, SLOT(updateMargins())); connect(&m_dockInterface, SIGNAL(directionChanged()), this, SLOT(updateMargins())); + connect(&m_dockInterface, SIGNAL(visibilityChanged()), this, SLOT(updateMargins())); } else { QDBusServiceWatcher *watcher = new QDBusServiceWatcher("org.cutefish.Dock", QDBusConnection::sessionBus(), @@ -46,6 +47,7 @@ Desktop::Desktop(QObject *parent) updateMargins(); connect(&m_dockInterface, SIGNAL(primaryGeometryChanged()), this, SLOT(updateMargins())); connect(&m_dockInterface, SIGNAL(directionChanged()), this, SLOT(updateMargins())); + connect(&m_dockInterface, SIGNAL(visibilityChanged()), this, SLOT(updateMargins())); }); } @@ -96,11 +98,18 @@ void Desktop::updateMargins() { QRect dockGeometry = m_dockInterface.property("primaryGeometry").toRect(); int dockDirection = m_dockInterface.property("direction").toInt(); + int visibility = m_dockInterface.property("visibility").toInt(); m_leftMargin = 0; m_rightMargin = 0; m_bottomMargin = 0; + // AlwaysHide + if (visibility == 1) { + emit marginsChanged(); + return; + } + if (dockDirection == 0) { m_leftMargin = dockGeometry.width(); } else if (dockDirection == 1) { diff --git a/qml/Desktop/Main.qml b/qml/Desktop/Main.qml index 5597e76..832258f 100644 --- a/qml/Desktop/Main.qml +++ b/qml/Desktop/Main.qml @@ -30,6 +30,9 @@ import "../" Item { id: rootItem + LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft + LayoutMirroring.childrenInherit: true + GlobalSettings { id: globalSettings } diff --git a/qml/FolderGridItem.qml b/qml/FolderGridItem.qml index b4214a1..a04f53c 100644 --- a/qml/FolderGridItem.qml +++ b/qml/FolderGridItem.qml @@ -79,8 +79,8 @@ Item { id: _iconItem anchors.top: parent.top anchors.horizontalCenter: parent.horizontalCenter - anchors.topMargin: FishUI.Units.largeSpacing - anchors.bottomMargin: FishUI.Units.largeSpacing + anchors.topMargin: FishUI.Units.smallSpacing + anchors.bottomMargin: FishUI.Units.smallSpacing z: 2 width: parent.width - FishUI.Units.largeSpacing * 2 @@ -189,7 +189,7 @@ Item { anchors.top: _iconItem.bottom anchors.horizontalCenter: parent.horizontalCenter anchors.topMargin: FishUI.Units.smallSpacing - maximumLineCount: 2 + maximumLineCount: control.selected ? 3 : 2 horizontalAlignment: Text.AlignHCenter width: parent.width - FishUI.Units.largeSpacing * 2 - FishUI.Units.smallSpacing textFormat: Text.PlainText diff --git a/qml/FolderGridView.qml b/qml/FolderGridView.qml index 4253a7a..8682883 100644 --- a/qml/FolderGridView.qml +++ b/qml/FolderGridView.qml @@ -221,7 +221,7 @@ GridView { } cellHeight: { - var iconHeight = iconSize + (FishUI.Units.fontMetrics.height * 2) + FishUI.Units.largeSpacing * 2 + var iconHeight = iconSize + (FishUI.Units.fontMetrics.height * 3) + FishUI.Units.largeSpacing if (isDesktopView) { var extraHeight = calcExtraSpacing(iconHeight, control.height - topMargin - bottomMargin) return iconHeight + extraHeight diff --git a/qml/FolderPage.qml b/qml/FolderPage.qml index f5368be..a90f618 100644 --- a/qml/FolderPage.qml +++ b/qml/FolderPage.qml @@ -107,6 +107,7 @@ Item { Rectangle { id: _background anchors.fill: parent + anchors.rightMargin: 1 radius: FishUI.Theme.smallRadius color: FishUI.Theme.secondBackgroundColor diff --git a/qml/main.qml b/qml/main.qml index dfa4db0..af3634a 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -37,6 +37,9 @@ FishUI.Window { header.height: 36 + FishUI.Units.largeSpacing background.opacity: root.compositing ? 0.9 : 1.0 + LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft + LayoutMirroring.childrenInherit: true + FishUI.WindowBlur { view: root geometry: Qt.rect(root.x, root.y, root.width, root.height)