mirror of
https://github.com/monero-project/monero-gui.git
synced 2025-01-22 02:34:36 +00:00
Navbar: reimplement as a reusable component, drop redundant code
This commit is contained in:
parent
e94ac7c75d
commit
34d3f6575a
4 changed files with 213 additions and 353 deletions
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2014-2018, The Monero Project
|
||||
// Copyright (c) 2014-2021, The Monero Project
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -27,18 +27,12 @@
|
|||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import QtQuick 2.9
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
import QtQuick.Layouts 1.1
|
||||
import QtQuick.Dialogs 1.2
|
||||
import "../../js/Windows.js" as Windows
|
||||
import "../../js/Utils.js" as Utils
|
||||
import "../../components" as MoneroComponents
|
||||
import "../../pages"
|
||||
import "."
|
||||
import moneroComponents.Clipboard 1.0
|
||||
import "." as MoneroComponents
|
||||
|
||||
Rectangle {
|
||||
default property list<MoneroComponents.NavbarItem> items
|
||||
|
||||
color: "transparent"
|
||||
height: grid.height
|
||||
width: grid.width
|
||||
|
@ -66,7 +60,6 @@ Rectangle {
|
|||
Rectangle {
|
||||
// navbar left side border
|
||||
id: navBarLeft
|
||||
property bool isActive: settingsStateView.state === "Wallet"
|
||||
Layout.preferredWidth: 2
|
||||
Layout.preferredHeight: 32
|
||||
color: "transparent"
|
||||
|
@ -95,7 +88,7 @@ Rectangle {
|
|||
Rectangle {
|
||||
Layout.fillHeight: true
|
||||
width: 1
|
||||
color: navBarLeft.isActive ? grid.borderColor : "transparent"
|
||||
color: items.length > 0 && items[0].active ? grid.borderColor : "transparent";
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
|
@ -106,66 +99,25 @@ Rectangle {
|
|||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
// WALLET
|
||||
id: navWallet
|
||||
property bool isActive: settingsStateView.state === "Wallet"
|
||||
Layout.preferredWidth: navWalletText.width + grid.textMargin
|
||||
Layout.minimumWidth: 72
|
||||
Layout.preferredHeight: 32
|
||||
Repeater {
|
||||
model: items.length
|
||||
|
||||
RowLayout {
|
||||
spacing: 0
|
||||
|
||||
Rectangle {
|
||||
color: grid.borderColor
|
||||
Layout.preferredHeight: 1
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
color: parent.isActive ? grid.borderColor : "transparent"
|
||||
height: 30
|
||||
Layout.fillWidth: true
|
||||
|
||||
MoneroComponents.TextPlain {
|
||||
id: navWalletText
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
font.family: grid.fontFamily
|
||||
font.pixelSize: grid.fontSize
|
||||
font.bold: grid.fontBold
|
||||
text: qsTr("Wallet") + translationManager.emptyString
|
||||
color: navWallet.isActive ? grid.fontColorActive : grid.fontColorInActive
|
||||
themeTransition: false
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
|
||||
onClicked: { settingsStateView.state = "Wallet" }
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
color: grid.borderColor
|
||||
Layout.preferredHeight: 1
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
Layout.preferredWidth: 1
|
||||
Layout.preferredHeight: 32
|
||||
color: grid.borderColor
|
||||
visible: index > 0 && items[index - 1].visible
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
// UI
|
||||
id: navUI
|
||||
property bool isActive: settingsStateView.state === "UI"
|
||||
Layout.preferredWidth: navUIText.width + grid.textMargin
|
||||
Layout.preferredHeight: 32
|
||||
Layout.minimumWidth: 72
|
||||
Layout.preferredHeight: 32
|
||||
Layout.fillWidth: true
|
||||
spacing: 0
|
||||
visible: items[index].visible
|
||||
|
||||
Rectangle {
|
||||
color: grid.borderColor
|
||||
|
@ -174,19 +126,20 @@ Rectangle {
|
|||
}
|
||||
|
||||
Rectangle {
|
||||
color: parent.isActive ? grid.borderColor : "transparent"
|
||||
height: 30
|
||||
Layout.fillWidth: true
|
||||
Layout.minimumHeight: 30
|
||||
color: items[index].active ? grid.borderColor : "transparent"
|
||||
height: children[0].height
|
||||
width: children[0].width
|
||||
|
||||
MoneroComponents.TextPlain {
|
||||
id: navUIText
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
font.family: grid.fontFamily
|
||||
font.pixelSize: grid.fontSize
|
||||
font.bold: grid.fontBold
|
||||
text: qsTr("Interface") + translationManager.emptyString
|
||||
color: navUI.isActive ? grid.fontColorActive : grid.fontColorInActive
|
||||
leftPadding: grid.textMargin / 2
|
||||
rightPadding: grid.textMargin / 2
|
||||
text: items[index].text
|
||||
color: items[index].active ? grid.fontColorActive : grid.fontColorInActive
|
||||
themeTransition: false
|
||||
}
|
||||
|
||||
|
@ -195,7 +148,7 @@ Rectangle {
|
|||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
|
||||
onClicked: { settingsStateView.state = "UI" }
|
||||
onClicked: items[index].selected()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -205,170 +158,12 @@ Rectangle {
|
|||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
Rectangle{
|
||||
Layout.preferredWidth: 1
|
||||
Layout.preferredHeight: 32
|
||||
color: grid.borderColor
|
||||
}
|
||||
ColumnLayout {
|
||||
// NODE
|
||||
id: navNode
|
||||
property bool isActive: settingsStateView.state === "Node"
|
||||
visible: appWindow.walletMode >= 2
|
||||
Layout.preferredWidth: navNodeText.width + grid.textMargin
|
||||
Layout.preferredHeight: 32
|
||||
Layout.minimumWidth: 72
|
||||
spacing: 0
|
||||
|
||||
Rectangle {
|
||||
color: grid.borderColor
|
||||
Layout.preferredHeight: 1
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
color: parent.isActive ? grid.borderColor : "transparent"
|
||||
height: 30
|
||||
Layout.fillWidth: true
|
||||
|
||||
MoneroComponents.TextPlain {
|
||||
id: navNodeText
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
font.family: grid.fontFamily
|
||||
font.pixelSize: grid.fontSize
|
||||
font.bold: grid.fontBold
|
||||
text: qsTr("Node") + translationManager.emptyString
|
||||
color: navNode.isActive ? grid.fontColorActive : grid.fontColorInActive
|
||||
themeTransition: false
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
|
||||
onClicked: { settingsStateView.state = "Node" }
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
color: grid.borderColor
|
||||
Layout.preferredHeight: 1
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
Rectangle{
|
||||
visible: appWindow.walletMode >= 2
|
||||
Layout.preferredWidth: 1
|
||||
Layout.preferredHeight: 32
|
||||
color: grid.borderColor
|
||||
}
|
||||
ColumnLayout {
|
||||
// LOG
|
||||
id: navLog
|
||||
property bool isActive: settingsStateView.state === "Log"
|
||||
Layout.preferredWidth: navLogText.width + grid.textMargin
|
||||
Layout.preferredHeight: 32
|
||||
Layout.minimumWidth: 72
|
||||
spacing: 0
|
||||
|
||||
Rectangle {
|
||||
color: grid.borderColor
|
||||
Layout.preferredHeight: 1
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
color: parent.isActive ? grid.borderColor : "transparent"
|
||||
height: 30
|
||||
Layout.fillWidth: true
|
||||
|
||||
MoneroComponents.TextPlain {
|
||||
id: navLogText
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
font.family: grid.fontFamily
|
||||
font.pixelSize: grid.fontSize
|
||||
font.bold: grid.fontBold
|
||||
text: qsTr("Log") + translationManager.emptyString
|
||||
color: navLog.isActive ? grid.fontColorActive : grid.fontColorInActive
|
||||
themeTransition: false
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
|
||||
onClicked: { settingsStateView.state = "Log" }
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
color: grid.borderColor
|
||||
Layout.preferredHeight: 1
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
Rectangle{
|
||||
visible: appWindow.walletMode >= 2
|
||||
Layout.preferredWidth: 1
|
||||
Layout.preferredHeight: 32
|
||||
color: grid.borderColor
|
||||
}
|
||||
ColumnLayout {
|
||||
// INFO
|
||||
id: navInfo
|
||||
property bool isActive: settingsStateView.state === "Info"
|
||||
Layout.preferredWidth: navInfoText.width + grid.textMargin
|
||||
Layout.preferredHeight: 32
|
||||
Layout.minimumWidth: 72
|
||||
spacing: 0
|
||||
|
||||
Rectangle {
|
||||
color: grid.borderColor
|
||||
Layout.preferredHeight: 1
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
color: parent.isActive ? grid.borderColor : "transparent"
|
||||
height: 30
|
||||
Layout.fillWidth: true
|
||||
|
||||
MoneroComponents.TextPlain {
|
||||
id: navInfoText
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
font.family: grid.fontFamily
|
||||
font.pixelSize: grid.fontSize
|
||||
font.bold: grid.fontBold
|
||||
text: qsTr("Info") + translationManager.emptyString
|
||||
color: navInfo.isActive ? grid.fontColorActive : grid.fontColorInActive
|
||||
themeTransition: false
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
|
||||
onClicked: { settingsStateView.state = "Info" }
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
color: grid.borderColor
|
||||
Layout.preferredHeight: 1
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
// navbar right side border
|
||||
id: navBarRight
|
||||
property bool isActive: settingsStateView.state === "Info"
|
||||
Layout.preferredWidth: 2
|
||||
Layout.preferredHeight: 32
|
||||
color: "transparent"
|
||||
|
@ -398,7 +193,7 @@ Rectangle {
|
|||
Rectangle {
|
||||
Layout.fillHeight: true
|
||||
width: 1
|
||||
color: navBarRight.isActive ? grid.borderColor : "transparent"
|
||||
color: items.length > 0 && items[items.length - 1].active ? grid.borderColor : "transparent"
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
|
|
37
components/NavbarItem.qml
Normal file
37
components/NavbarItem.qml
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Copyright (c) 2021, The Monero Project
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other
|
||||
// materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
||||
// used to endorse or promote products derived from this software without specific
|
||||
// prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import QtQuick 2.9
|
||||
|
||||
QtObject {
|
||||
property bool active: false
|
||||
property string text
|
||||
property bool visible: true
|
||||
|
||||
signal selected()
|
||||
}
|
|
@ -48,10 +48,37 @@ ColumnLayout {
|
|||
property int settingsHeight: 900
|
||||
property alias settingsStateViewState: settingsStateView.state
|
||||
|
||||
Navbar {
|
||||
MoneroComponents.Navbar {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
Layout.topMargin: height
|
||||
Layout.bottomMargin: height
|
||||
|
||||
MoneroComponents.NavbarItem {
|
||||
active: settingsStateView.state == "Wallet"
|
||||
text: qsTr("Wallet") + translationManager.emptyString
|
||||
onSelected: settingsStateView.state = "Wallet"
|
||||
}
|
||||
MoneroComponents.NavbarItem {
|
||||
active: settingsStateView.state == "UI"
|
||||
text: qsTr("Interface") + translationManager.emptyString
|
||||
onSelected: settingsStateView.state = "UI"
|
||||
}
|
||||
MoneroComponents.NavbarItem {
|
||||
active: settingsStateView.state == "Node"
|
||||
text: qsTr("Node") + translationManager.emptyString
|
||||
visible: appWindow.walletMode >= 2
|
||||
onSelected: settingsStateView.state = "Node"
|
||||
}
|
||||
MoneroComponents.NavbarItem {
|
||||
active: settingsStateView.state == "Log"
|
||||
text: qsTr("Log") + translationManager.emptyString
|
||||
onSelected: settingsStateView.state = "Log"
|
||||
}
|
||||
MoneroComponents.NavbarItem {
|
||||
active: settingsStateView.state == "Info"
|
||||
text: qsTr("Info") + translationManager.emptyString
|
||||
onSelected: settingsStateView.state = "Info"
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle{
|
||||
|
|
3
qml.qrc
3
qml.qrc
|
@ -5,6 +5,8 @@
|
|||
<file>MiddlePanel.qml</file>
|
||||
<file>components/Label.qml</file>
|
||||
<file>components/LanguageButton.qml</file>
|
||||
<file>components/Navbar.qml</file>
|
||||
<file>components/NavbarItem.qml</file>
|
||||
<file>components/SettingsListItem.qml</file>
|
||||
<file>components/Slider.qml</file>
|
||||
<file>components/UpdateDialog.qml</file>
|
||||
|
@ -162,7 +164,6 @@
|
|||
<file>pages/settings/SettingsLog.qml</file>
|
||||
<file>pages/settings/SettingsLayout.qml</file>
|
||||
<file>pages/settings/SettingsInfo.qml</file>
|
||||
<file>pages/settings/Navbar.qml</file>
|
||||
<file>components/WarningBox.qml</file>
|
||||
<file>images/miningxmr.png</file>
|
||||
<file>images/miningxmr@2x.png</file>
|
||||
|
|
Loading…
Reference in a new issue