Skip to content

Commit

Permalink
[Header] Cleanup header
Browse files Browse the repository at this point in the history
  • Loading branch information
neochapay committed Oct 25, 2023
1 parent 07e6f7f commit ed84292
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 46 deletions.
69 changes: 28 additions & 41 deletions src/controls/qml/HeaderToolsLayout.qml
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,30 @@ Item {
property bool showBackButton: false
property int toolMeasure: Theme.itemHeightSmall
height: toolMeasure
Rectangle {
Item {
id: backButton
width: opacity ? Theme.itemHeightHuge : 0
anchors.leftMargin: Theme.itemSpacingLarge
width: opacity ? backButton.height : 0
height: toolsLayoutItem.height

anchors{
leftMargin: Theme.itemSpacingLarge
//check if Stack.view has already been initialized as well
anchors.verticalCenter: parent.verticalCenter
antialiasing: true
height: width
radius: Theme.itemSpacingExtraSmall / 2
color: backmouse.pressed ? "#222" : "transparent"
verticalCenter: parent.verticalCenter
}

rotation: isUiPortrait ? 0 : 90

visible: showBackButton && applicationWindow.pageStack.depth > 1

NemoIcon {
Rectangle{
id: background
width: parent.height*0.9
height: parent.height*0.9
anchors.centerIn: parent
color: backmouse.pressed ? Theme.fillDarkColor : "transparent"
radius: width
}

Image {
anchors.centerIn: parent
height: toolMeasure
width: height
Expand All @@ -82,51 +90,30 @@ Item {
right: toolButtonsContainer.left
left: backButton.visible ? backButton.right : parent.left
verticalCenter: parent.verticalCenter
leftMargin: Theme.itemSpacingLarge
rightMargin: Theme.itemSpacingLarge
leftMargin: backButton.visible ? 0 : Theme.itemSpacingLarge
}
clip: true
font.family: Theme.fontFamily
color: Theme.textColor
font.pixelSize: Theme.fontSizeLarge
font.weight: Font.ExtraBold
// @todo: need port qt6
/*LinearGradient {
anchors.right: parent.right
width: Theme.itemHeightMedium
height: parent.paintedHeight
visible: titleTxt.paintedWidth > titleTxt.width
start: Qt.point(0,0)
end: Qt.point(width,0)
gradient: Gradient { GradientStop { position: 0; color: "transparent"}
GradientStop {position: 0.9; color: Theme.backgroundColor } }
}*/
font.weight: Font.Bold
}


Item {
id: toolButtonsContainer
anchors.right: dots.visible ? dots.left : parent.right
anchors.rightMargin: Theme.itemSpacingLarge
anchors.verticalCenter: parent.verticalCenter
anchors{
right: dots.visible ? dots.left : parent.right
verticalCenter: parent.verticalCenter
}

width: tools ? (Theme.itemHeightMedium * Math.min(maxNumberOfToolButtons, tools.length)) : 0
height: toolsLayoutItem.height

property int maxNumberOfToolButtons: 3

Row {
id: toolsRow
anchors.centerIn: parent
height: toolMeasure
function assignRotationBindings() {
for (var i=0; i<children.length; ++i) {
children[i].rotation = Qt.binding(function() { return isUiPortrait ? 0 : 90 })
}
}

//TODO: THIS IS STUPID :D This is run once every added item (i.e. EVEN IF you add 3 items at the same time)
//but it's not critical since it will always have a very limited amount of children
onChildrenChanged: {
assignRotationBindings()
}
height: toolButtonsContainer.height
children: tools
}
}
Expand Down
19 changes: 14 additions & 5 deletions src/controls/qml/ToolButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,26 @@ import QtQuick.Controls

import Nemo.Controls

Button {
Item {
id: toolButton
property alias iconSource: iconImage.source
property bool showCounter: false
property bool showZeroCounter: false
property bool active: false
property int counterValue: 0

backgrounded: true
signal clicked()

width: height
height: parent.height

NemoIcon {
id: iconImage
anchors.fill: parent
width: Theme.itemHeightExtraSmall
height: Theme.itemHeightExtraSmall
color: Theme.accentColor
anchors.centerIn: parent
fillMode: Image.PreserveAspectFit
anchors.margins: Theme.itemSpacingExtraSmall
color: active ? Theme.accentColor : Theme.textColor
}

Rectangle{
Expand Down Expand Up @@ -79,4 +82,10 @@ Button {
font.pixelSize: counter.height*0.8
}
}

MouseArea{
id: bMouseArea
anchors.fill: parent
onClicked: toolButton.clicked()
}
}

0 comments on commit ed84292

Please sign in to comment.