Improve tabbar

pull/4/head
reionwong 4 years ago
parent ab3a5de5e1
commit 9f05fb681a

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="16"
height="16"
enable-background="new"
version="1.1"
id="svg6"
sodipodi:docname="add.svg"
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)">
<metadata
id="metadata12">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs10" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1652"
inkscape:window-height="997"
id="namedview8"
showgrid="false"
inkscape:zoom="45.9375"
inkscape:cx="8"
inkscape:cy="8"
inkscape:window-x="290"
inkscape:window-y="564"
inkscape:window-maximized="0"
inkscape:current-layer="svg6"
inkscape:document-rotation="0" />
<rect
style="opacity:0.95;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.597918;stroke-miterlimit:4;stroke-dasharray:none"
id="rect832"
width="8.2469997"
height="0.5"
x="3.8765001"
y="7.75" />
<rect
style="opacity:0.95;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.597918;stroke-miterlimit:4;stroke-dasharray:none"
id="rect832-3"
width="8.2469997"
height="0.5"
x="3.8765001"
y="-8.25"
transform="rotate(90)" />
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
sodipodi:docname="close.svg"
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"
id="svg8"
version="1.1"
viewBox="0 0 7.9374997 7.9375002"
height="30"
width="30">
<defs
id="defs2" />
<sodipodi:namedview
inkscape:document-rotation="0"
inkscape:pagecheckerboard="false"
inkscape:window-maximized="1"
inkscape:window-y="0"
inkscape:window-x="0"
inkscape:window-height="1304"
inkscape:window-width="2160"
units="px"
showgrid="false"
inkscape:current-layer="layer1"
inkscape:document-units="mm"
inkscape:cy="18.272706"
inkscape:cx="9.8768456"
inkscape:zoom="22.4"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
borderopacity="1.0"
bordercolor="#666666"
pagecolor="#ffffff"
id="base">
<inkscape:grid
id="grid2560"
type="xygrid" />
</sodipodi:namedview>
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
<cc:license
rdf:resource="" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
transform="translate(0,-289.06248)"
id="layer1"
inkscape:groupmode="layer"
inkscape:label="Layer 1">
<g
transform="matrix(0.26458333,0,0,0.26458333,11.895874,2.9564196)"
inkscape:label="#g3842"
id="4" />
<g
transform="matrix(0.26458333,0,0,0.26458333,8.2578527,2.6020669)"
inkscape:label="#g3842"
id="4-7" />
<rect
style="opacity:0;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.18433414;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill"
id="rect1569-36"
width="6.2093525"
height="6.2267418"
x="0.86407435"
y="289.91785"
ry="6.5889685e-06" />
<g
id="g6"
transform="matrix(0.0065117,0,0,0.00651172,2.3017515,291.36422)"
style="fill:#ffffff;fill-opacity:1">
<g
id="g4"
style="fill:#ffffff;fill-opacity:1">
<path
d="M 284.286,256.002 506.143,34.144 c 7.811,-7.811 7.811,-20.475 0,-28.285 -7.811,-7.81 -20.475,-7.811 -28.285,0 L 256,227.717 34.143,5.859 c -7.811,-7.811 -20.475,-7.811 -28.285,0 -7.81,7.811 -7.811,20.475 0,28.285 L 227.715,256.001 5.858,477.859 c -7.811,7.811 -7.811,20.475 0,28.285 3.905,3.905 9.024,5.857 14.143,5.857 5.119,0 10.237,-1.952 14.143,-5.857 L 256,284.287 477.857,506.144 c 3.905,3.905 9.024,5.857 14.143,5.857 5.119,0 10.237,-1.952 14.143,-5.857 7.811,-7.811 7.811,-20.475 0,-28.285 z"
id="path2-3"
style="fill:#ffffff;fill-opacity:1" />
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.2 KiB

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="16"
height="16"
enable-background="new"
version="1.1"
id="svg6"
sodipodi:docname="add.svg"
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)">
<metadata
id="metadata12">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs10" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="2160"
inkscape:window-height="1304"
id="namedview8"
showgrid="false"
inkscape:zoom="45.9375"
inkscape:cx="8"
inkscape:cy="8"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg6"
inkscape:document-rotation="0" />
<rect
style="opacity:0.95;fill:#363636;fill-opacity:1;stroke:none;stroke-width:0.597918;stroke-miterlimit:4;stroke-dasharray:none"
id="rect832"
width="8.2469997"
height="0.5"
x="3.8765001"
y="7.75" />
<rect
style="opacity:0.95;fill:#363636;fill-opacity:1;stroke:none;stroke-width:0.597918;stroke-miterlimit:4;stroke-dasharray:none"
id="rect832-3"
width="8.2469997"
height="0.5"
x="3.8765001"
y="-8.25"
transform="rotate(90)" />
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
sodipodi:docname="close.svg"
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"
id="svg8"
version="1.1"
viewBox="0 0 7.9374997 7.9375002"
height="30"
width="30">
<defs
id="defs2" />
<sodipodi:namedview
inkscape:document-rotation="0"
inkscape:pagecheckerboard="false"
inkscape:window-maximized="1"
inkscape:window-y="0"
inkscape:window-x="0"
inkscape:window-height="1304"
inkscape:window-width="2160"
units="px"
showgrid="false"
inkscape:current-layer="layer1"
inkscape:document-units="mm"
inkscape:cy="18.272706"
inkscape:cx="9.8768456"
inkscape:zoom="22.4"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
borderopacity="1.0"
bordercolor="#666666"
pagecolor="#ffffff"
id="base">
<inkscape:grid
id="grid2560"
type="xygrid" />
</sodipodi:namedview>
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
<cc:license
rdf:resource="" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
transform="translate(0,-289.06248)"
id="layer1"
inkscape:groupmode="layer"
inkscape:label="Layer 1">
<g
transform="matrix(0.26458333,0,0,0.26458333,11.895874,2.9564196)"
inkscape:label="#g3842"
id="4" />
<g
transform="matrix(0.26458333,0,0,0.26458333,8.2578527,2.6020669)"
inkscape:label="#g3842"
id="4-7" />
<rect
style="opacity:0;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.18433414;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill"
id="rect1569-36"
width="6.2093525"
height="6.2267418"
x="0.86407435"
y="289.91785"
ry="6.5889685e-06" />
<g
id="g6"
transform="matrix(0.0065117,0,0,0.00651172,2.3017515,291.36422)"
style="fill:#383838;fill-opacity:1">
<g
id="g4"
style="fill:#383838;fill-opacity:1">
<path
d="M 284.286,256.002 506.143,34.144 c 7.811,-7.811 7.811,-20.475 0,-28.285 -7.811,-7.81 -20.475,-7.811 -28.285,0 L 256,227.717 34.143,5.859 c -7.811,-7.811 -20.475,-7.811 -28.285,0 -7.81,7.811 -7.811,20.475 0,28.285 L 227.715,256.001 5.858,477.859 c -7.811,7.811 -7.811,20.475 0,28.285 3.905,3.905 9.024,5.857 14.143,5.857 5.119,0 10.237,-1.952 14.143,-5.857 L 256,284.287 477.857,506.144 c 3.905,3.905 9.024,5.857 14.143,5.857 5.119,0 10.237,-1.952 14.143,-5.857 7.811,-7.811 7.811,-20.475 0,-28.285 z"
id="path2-3"
style="fill:#383838;fill-opacity:1" />
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.2 KiB

@ -3,5 +3,11 @@
<file>qml/main.qml</file>
<file>qml/TextEditor.qml</file>
<file>qml/TabView.qml</file>
<file>qml/CTabBar.qml</file>
<file>qml/CTabButton.qml</file>
<file>images/dark/add.svg</file>
<file>images/dark/close.svg</file>
<file>images/light/add.svg</file>
<file>images/light/close.svg</file>
</qresource>
</RCC>

@ -0,0 +1,65 @@
import QtQuick 2.15
import QtQml 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import FishUI 1.0 as FishUI
TabBar {
id: control
// property var model
implicitWidth: _content.width
default property alias content : _content.data
property bool newTabVisibile: true
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
clip: true
Flickable {
id: _flickable
Row {
id: _content
width: _scrollView.width
height: _scrollView.height
}
}
}
Loader {
active: control.newTabVisibile
visible: active
asynchronous: true
Layout.fillHeight: true
Layout.preferredWidth: visible ? height : 0
sourceComponent: FishUI.RoundImageButton {
source: "qrc:/images/" + (FishUI.Theme.darkMode ? "dark/" : "light/") + "add.svg"
onClicked: control.newTabClicked()
}
}
}
}
}

@ -0,0 +1,78 @@
import QtQuick 2.15
import QtQml 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import FishUI 1.0 as FishUI
Item {
id: control
property bool checked: false
property bool hovered: _mouseArea.containsMouse
property string text: ""
signal clicked()
signal closeClicked()
MouseArea {
id: _mouseArea
anchors.fill: parent
hoverEnabled: true
onClicked: control.clicked()
}
Rectangle {
id: hoveredRect
anchors.fill: parent
anchors.leftMargin: FishUI.Units.smallSpacing / 2
anchors.rightMargin: FishUI.Units.smallSpacing / 2
anchors.topMargin: FishUI.Units.smallSpacing / 2
color: _mouseArea.containsMouse ? FishUI.Theme.textColor : "transparent"
opacity: _mouseArea.pressed ? 0.1 : 0.05
border.width: 0
radius: FishUI.Theme.smallRadius
}
Rectangle {
id: checkedRect
anchors.leftMargin: FishUI.Units.smallSpacing / 2
anchors.rightMargin: FishUI.Units.smallSpacing / 2
anchors.topMargin: FishUI.Units.smallSpacing / 2
anchors.fill: parent
color: FishUI.Theme.highlightColor
opacity: _mouseArea.pressed ? 0.9 : 1
border.width: 0
visible: checked
radius: FishUI.Theme.smallRadius
}
RowLayout {
anchors.fill: parent
anchors.leftMargin: FishUI.Units.smallSpacing / 2
anchors.rightMargin: FishUI.Units.smallSpacing / 2
anchors.topMargin: FishUI.Units.smallSpacing / 2
spacing: 0
Label {
text: control.text
Layout.fillWidth: true
Layout.fillHeight: true
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
color: control.checked ? FishUI.Theme.highlightedTextColor
: FishUI.Theme.textColor
elide: Text.ElideMiddle
wrapMode: Text.NoWrap
}
FishUI.RoundImageButton {
visible: control.checked
Layout.preferredHeight: 24
Layout.preferredWidth: 24
size: 24
source: "qrc:/images/" + (FishUI.Theme.darkMode || control.checked ? "dark/" : "light/") + "close.svg"
onClicked: control.closeClicked()
}
}
}

@ -47,6 +47,10 @@ Item {
boundsBehavior: Flickable.StopAtBounds
boundsMovement: Flickable.StopAtBounds
ScrollBar.vertical: ScrollBar {
policy: ScrollBar.AlwaysOff
}
TextArea.flickable: TextArea {
id: body
text: document.text
@ -74,12 +78,11 @@ Item {
active: control.showLineNumbers && !document.isRich
asynchronous: true
anchors.left: parent.left
anchors.top: parent.top
anchors.left: body.left
anchors.top: body.top
anchors.topMargin: body.topPadding + body.textMargin
height: _flickable.contentHeight
// height: Math.max(_flickable.contentHeight, control.height)
width: active ? 32 : 0
sourceComponent: _linesCounterComponent
@ -93,8 +96,8 @@ Item {
ListView {
id: _linesCounterList
anchors.fill: parent
anchors.topMargin: body.topPadding + body.textMargin
// anchors.fill: parent
// anchors.topMargin: body.topPadding + body.textMargin
model: document.lineCount
clip: true
@ -143,9 +146,8 @@ Item {
// property bool foldable : control.document.isFoldable(line)
width: ListView.view.width
height: Math.max(fontSize, document.lineHeight(line))
height: document.lineHeight(line)
readonly property real fontSize: 11//control.body.font.pointSize
readonly property bool isCurrentItem: ListView.isCurrentItem
// Connections {

@ -13,35 +13,42 @@ FishUI.Window {
title: qsTr("Text Editor")
headerItem: Item {
TabBar {
CTabBar {
anchors.fill: parent
anchors.margins: FishUI.Units.smallSpacing / 2
anchors.rightMargin: FishUI.Units.largeSpacing * 2
currentIndex : _tabView.currentIndex
onNewTabClicked: {
addTab()
}
Repeater {
id: _repeater
model: _tabView.count
TabButton {
CTabButton {
text: _tabView.contentModel.get(index).fileName
implicitHeight: parent.height
implicitWidth: Math.max(parent.width / _repeater.count, 200)
implicitWidth: parent.width / _repeater.count
ToolTip.delay: 1000
ToolTip.timeout: 5000
hoverEnabled: true
checked: _tabView.currentIndex == index
ToolTip.visible: hovered
ToolTip.text: _tabView.contentModel.get(index).fileUrl
leftPadding: FishUI.Units.smallSpacing
rightPadding: FishUI.Units.smallSpacing
onClicked: {
_tabView.currentIndex = index
_tabView.currentItem.forceActiveFocus()
}
onCloseClicked: {
_tabView.closeTab(index)
}
}
}
}

Loading…
Cancel
Save