From fd33abe63100277c84d347cd5d34828287a66ae9 Mon Sep 17 00:00:00 2001 From: kateleet Date: Tue, 21 Dec 2021 05:21:05 +0800 Subject: [PATCH] refactor: fishui tabbar --- src/controls/TabBar.qml | 79 ++++++++++++++++-------------------- src/controls/Window.qml | 8 +++- src/fish-style/TabButton.qml | 2 +- 3 files changed, 41 insertions(+), 48 deletions(-) diff --git a/src/controls/TabBar.qml b/src/controls/TabBar.qml index 9475086..7dce635 100644 --- a/src/controls/TabBar.qml +++ b/src/controls/TabBar.qml @@ -24,62 +24,51 @@ import QtQuick.Controls 2.15 import QtQuick.Layouts 1.15 import FishUI 1.0 as FishUI -TabBar { +Item { id: control - implicitWidth: _content.width - - default property alias content : _content.data property bool newTabVisibile: true + property alias model: _listView.model + property alias delegate: _listView.delegate + property alias count: _listView.count + property alias currentIndex: _listView.currentIndex signal newTabClicked() - background: Rectangle { - color: "transparent" - } - - contentItem: Item { - RowLayout { - anchors.fill: parent - spacing: FishUI.Units.smallSpacing - - ScrollView { - id: _scrollView - - Layout.fillWidth: true - Layout.fillHeight: true - - ScrollBar.horizontal.policy: ScrollBar.AlwaysOff - ScrollBar.vertical.policy: ScrollBar.AlwaysOff + RowLayout { + anchors.fill: parent + spacing: FishUI.Units.smallSpacing / 2 + + ListView { + id: _listView + Layout.fillHeight: true + Layout.preferredWidth: _listView.childrenRect.width + Layout.alignment: Qt.AlignLeft + orientation: ListView.Horizontal + highlightMoveDuration: 0 + highlightResizeDuration: 0 + clip: true + } - clip: true + Loader { + active: control.newTabVisibile + visible: active + asynchronous: true - Flickable { - id: _flickable + // Layout.fillHeight: true + Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft + Layout.preferredHeight: 31 + Layout.preferredWidth: visible ? height : 0 - Row { - id: _content - width: _scrollView.width - height: _scrollView.height - } - } + sourceComponent: FishUI.RoundImageButton { + source: "qrc:/images/" + (FishUI.Theme.darkMode ? "dark/" : "light/") + "add.svg" + onClicked: control.newTabClicked() + iconMargins: 2 } + } - Loader { - active: control.newTabVisibile - visible: active - asynchronous: true - - // Layout.fillHeight: true - Layout.alignment: Qt.AlignVCenter - Layout.preferredHeight: 31 - Layout.preferredWidth: visible ? height : 0 - - sourceComponent: FishUI.RoundImageButton { - source: "qrc:/images/" + (FishUI.Theme.darkMode ? "dark/" : "light/") + "add.svg" - onClicked: control.newTabClicked() - } - } + Item { + Layout.fillWidth: true } } } diff --git a/src/controls/Window.qml b/src/controls/Window.qml index 115e3ee..e8d7c8d 100644 --- a/src/controls/Window.qml +++ b/src/controls/Window.qml @@ -227,12 +227,16 @@ Window { // Border line Rectangle { - property var borderColor: compositing ? FishUI.Theme.darkMode ? Qt.rgba(255, 255, 255, 0.05) : Qt.rgba(0, 0, 0, 0.05) : FishUI.Theme.darkMode ? Qt.rgba(255, 255, 255, 0.15) : Qt.rgba(0, 0, 0, 0.15) - anchors.fill: parent + + property var borderColor: compositing ? FishUI.Theme.darkMode ? Qt.rgba(255, 255, 255, 0.3) + : Qt.rgba(0, 0, 0, 0.2) : FishUI.Theme.darkMode ? Qt.rgba(255, 255, 255, 0.15) + : Qt.rgba(0, 0, 0, 0.15) color: "transparent" radius: control.windowRadius border.color: borderColor + border.width: 1 / Screen.devicePixelRatio + border.pixelAligned: Screen.devicePixelRatio > 1 ? false : true antialiasing: true visible: !isMaximized && !isFullScreen z: 999 diff --git a/src/fish-style/TabButton.qml b/src/fish-style/TabButton.qml index 637e760..b7fdbea 100644 --- a/src/fish-style/TabButton.qml +++ b/src/fish-style/TabButton.qml @@ -26,4 +26,4 @@ T.TabButton { font: control.font color: !control.enabled ? FishUI.Theme.disabledTextColor : control.pressed ? pressedColor : control.checked ? FishUI.Theme.textColor : FishUI.Theme.textColor } -} \ No newline at end of file +}