You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
3.4 KiB
QML

5 years ago
import QtQuick 2.15
import QtQuick.Window 2.15
5 years ago
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
5 years ago
import FishUI 1.0 as FishUI
FishUI.Window {
width: 640
height: 480
visible: true
5 years ago
title: qsTr("Text Editor")
5 years ago
5 years ago
headerItem: Item {
TabBar {
anchors.fill: parent
currentIndex : _container.currentIndex
Repeater {
id: _repeater
model: _container.count
TabButton {
text: _container.contentModel.get(index).fileName
implicitHeight: parent.height
implicitWidth: Math.max(parent.width / _repeater.count, 200)
ToolTip.delay: 1000
ToolTip.timeout: 5000
hoverEnabled: true
ToolTip.visible: hovered
ToolTip.text: _container.contentModel.get(index).fileUrl
leftPadding: FishUI.Units.smallSpacing
rightPadding: FishUI.Units.smallSpacing
onClicked: {
_container.currentIndex = index
_container.currentItem.forceActiveFocus()
}
}
}
}
}
ColumnLayout {
5 years ago
anchors.fill: parent
5 years ago
spacing: 0
Container {
id: _container
Layout.fillWidth: true
Layout.fillHeight: true
contentItem: ColumnLayout {
spacing: 0
ListView {
id: _view
Layout.fillWidth: true
Layout.fillHeight: true
interactive: false
orientation: ListView.Horizontal
snapMode: ListView.SnapOneItem
currentIndex: _container.currentIndex
model: _container.contentModel
boundsBehavior: Flickable.StopAtBounds
boundsMovement :Flickable.StopAtBounds
spacing: 0
preferredHighlightBegin: 0
preferredHighlightEnd: width
highlightRangeMode: ListView.StrictlyEnforceRange
highlightMoveDuration: 0
highlightFollowsCurrentItem: true
highlightResizeDuration: 0
highlightMoveVelocity: -1
highlightResizeVelocity: -1
maximumFlickVelocity: 4 * width
cacheBuffer: _view.count * width
keyNavigationEnabled : false
keyNavigationWraps : false
}
}
}
Item {
Layout.fillWidth: true
Layout.preferredHeight: 20
ColumnLayout {
anchors.fill: parent
}
}
}
function addTab() {
const component = textEditorCompeont
const object = component.createObject(_container.contentModel)
_container.addItem(object)
_container.currentIndex = Math.max(_container.count - 1, 0)
object.forceActiveFocus()
}
Component {
id: textEditorCompeont
TextEditor {
fileUrl: "file:///home/reion/Cutefish/core/notificationd/view.cpp"
}
}
Component.onCompleted: {
addTab()
addTab()
addTab()
5 years ago
}
}