TopBar.qml (3311B)
1 import QtQuick 2 import QtQuick.Layouts 3 import "../styles" 4 5 Rectangle { 6 id: root 7 height: TelegramStyle.topBarHeight 8 color: TelegramStyle.primaryColor 9 10 property string title: "" 11 property bool showBackButton: false 12 property bool showMenuButton: false 13 property bool showAddButton: false 14 15 signal backClicked() 16 signal menuClicked() 17 signal addClicked() 18 19 RowLayout { 20 anchors.fill: parent 21 anchors.leftMargin: TelegramStyle.smallMargin 22 anchors.rightMargin: TelegramStyle.smallMargin 23 spacing: TelegramStyle.smallMargin 24 25 // Back button 26 Rectangle { 27 id: backButton 28 visible: showBackButton 29 Layout.preferredWidth: 40 30 Layout.fillHeight: true 31 color: activeFocus ? Qt.darker(TelegramStyle.primaryColor, 1.2) : "transparent" 32 radius: 4 33 activeFocusOnTab: true 34 35 Keys.onReturnPressed: root.backClicked() 36 Keys.onSpacePressed: root.backClicked() 37 38 Text { 39 anchors.centerIn: parent 40 text: "\u2190" // Left arrow 41 color: "white" 42 font.pixelSize: 24 43 } 44 45 MouseArea { 46 anchors.fill: parent 47 cursorShape: Qt.PointingHandCursor 48 onClicked: root.backClicked() 49 } 50 } 51 52 // Title 53 Text { 54 Layout.fillWidth: true 55 text: root.title 56 color: "white" 57 font.pixelSize: TelegramStyle.fontSizeLarge 58 font.bold: true 59 elide: Text.ElideRight 60 verticalAlignment: Text.AlignVCenter 61 } 62 63 // Add button 64 Rectangle { 65 id: addButton 66 visible: showAddButton 67 Layout.preferredWidth: 40 68 Layout.fillHeight: true 69 color: activeFocus ? Qt.darker(TelegramStyle.primaryColor, 1.2) : "transparent" 70 radius: 4 71 activeFocusOnTab: true 72 73 Keys.onReturnPressed: root.addClicked() 74 Keys.onSpacePressed: root.addClicked() 75 76 Text { 77 anchors.centerIn: parent 78 text: "\u002B" // Plus sign 79 color: "white" 80 font.pixelSize: 24 81 } 82 83 MouseArea { 84 anchors.fill: parent 85 cursorShape: Qt.PointingHandCursor 86 onClicked: root.addClicked() 87 } 88 } 89 90 // Menu button 91 Rectangle { 92 id: menuButton 93 visible: showMenuButton 94 Layout.preferredWidth: 40 95 Layout.fillHeight: true 96 color: activeFocus ? Qt.darker(TelegramStyle.primaryColor, 1.2) : "transparent" 97 radius: 4 98 activeFocusOnTab: true 99 100 Keys.onReturnPressed: root.menuClicked() 101 Keys.onSpacePressed: root.menuClicked() 102 103 Text { 104 anchors.centerIn: parent 105 text: "\u22ee" // Vertical ellipsis 106 color: "white" 107 font.pixelSize: 24 108 } 109 110 MouseArea { 111 anchors.fill: parent 112 cursorShape: Qt.PointingHandCursor 113 onClicked: root.menuClicked() 114 } 115 } 116 } 117 }