2020-10-21 18:49:49 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls.Styles 1.0
|
2021-09-30 09:43:29 +00:00
|
|
|
import "../../../../../shared"
|
|
|
|
import "../../../../../shared/status"
|
|
|
|
import "../"
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2020-10-21 18:49:49 +00:00
|
|
|
|
|
|
|
TabViewStyle {
|
2021-09-30 09:43:29 +00:00
|
|
|
id: tabViewStyle
|
|
|
|
|
2020-10-21 18:49:49 +00:00
|
|
|
property color fillColor: Style.current.background
|
|
|
|
property color nonSelectedColor: Qt.darker(Style.current.background, 1.2)
|
2021-09-30 09:43:29 +00:00
|
|
|
|
2020-10-21 18:49:49 +00:00
|
|
|
frameOverlap: 1
|
|
|
|
tabsMovable: true
|
|
|
|
|
|
|
|
frame: Rectangle {
|
|
|
|
color: Style.current.transparent
|
|
|
|
border.width: 0
|
|
|
|
}
|
|
|
|
|
|
|
|
tab: Item {
|
|
|
|
implicitWidth: tabRectangle.implicitWidth + 5 + (newTabloader.active ? newTabloader.width + Style.current.halfPadding : 0)
|
|
|
|
implicitHeight: tabRectangle.implicitHeight
|
|
|
|
Rectangle {
|
|
|
|
id: tabRectangle
|
|
|
|
color: styleData.selected ? fillColor : nonSelectedColor
|
|
|
|
border.width: 0
|
|
|
|
implicitWidth: 240
|
2021-09-30 09:43:29 +00:00
|
|
|
implicitHeight: control.tabHeight
|
2020-10-21 18:49:49 +00:00
|
|
|
radius: Style.current.radius
|
|
|
|
|
|
|
|
// This rectangle is to hide the bottom radius
|
|
|
|
Rectangle {
|
|
|
|
width: parent.implicitWidth
|
|
|
|
height: 5
|
|
|
|
color: parent.color
|
|
|
|
border.width: 0
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
}
|
|
|
|
|
|
|
|
FaviconImage {
|
|
|
|
id: faviconImage
|
2021-09-30 09:43:29 +00:00
|
|
|
currentTab: control.getTab(styleData.index) && control.getTab(styleData.index).item
|
2020-10-21 18:49:49 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter;
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: Style.current.halfPadding
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: text
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.left: faviconImage.right
|
|
|
|
anchors.leftMargin: Style.current.halfPadding
|
|
|
|
anchors.right: closeTabBtn.left
|
|
|
|
anchors.rightMargin: Style.current.halfPadding
|
|
|
|
text: styleData.title
|
|
|
|
// TODO the elide probably doesn't work. Set a Max width
|
|
|
|
elide: Text.ElideRight
|
|
|
|
color: Style.current.textColor
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
StatusIconButton {
|
|
|
|
id: closeTabBtn
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Start Page"
|
2021-09-30 09:43:29 +00:00
|
|
|
visible: control.count > 1 || styleData.title !== qsTrId("start-page")
|
2020-10-21 18:49:49 +00:00
|
|
|
enabled: visible
|
|
|
|
icon.name: "browser/close"
|
|
|
|
iconColor: Style.current.textColor
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Style.current.halfPadding
|
2021-09-30 09:43:29 +00:00
|
|
|
onClicked: control.closeButtonClicked(styleData.index)
|
2020-10-21 18:49:49 +00:00
|
|
|
width: 16
|
|
|
|
height: 16
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: newTabloader
|
2021-09-30 09:43:29 +00:00
|
|
|
active: styleData.index === control.count - 1
|
2020-10-21 18:49:49 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
|
|
|
sourceComponent: Component {
|
|
|
|
StatusIconButton {
|
|
|
|
icon.name: "browser/close"
|
|
|
|
iconColor: Style.current.textColor
|
|
|
|
iconRotation: 45
|
2021-09-30 09:43:29 +00:00
|
|
|
onClicked: control.openNewTabClicked()
|
2020-10-21 18:49:49 +00:00
|
|
|
width: 16
|
|
|
|
height: 16
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|