Skip to content

Add and demo ConnectionSettings and ContinueButton components #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,13 @@ QML_QRC = qml/bitcoin_qml.qrc
QML_RES_QML = \
qml/components/BlockCounter.qml \
qml/components/ConnectionOptions.qml \
qml/components/ConnectionSettings.qml \
qml/controls/ContinueButton.qml \
qml/controls/Header.qml \
qml/controls/OptionButton.qml \
qml/controls/OptionSwitch.qml \
qml/controls/ProgressIndicator.qml \
qml/controls/Setting.qml \
qml/pages/initerrormessage.qml \
qml/pages/stub.qml

Expand Down
4 changes: 4 additions & 0 deletions src/qml/bitcoin_qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
<qresource prefix="/qml">
<file>components/BlockCounter.qml</file>
<file>components/ConnectionOptions.qml</file>
<file>components/ConnectionSettings.qml</file>
<file>controls/ContinueButton.qml</file>
<file>controls/Header.qml</file>
<file>controls/OptionButton.qml</file>
<file>controls/OptionSwitch.qml</file>
<file>controls/ProgressIndicator.qml</file>
<file>controls/Setting.qml</file>
<file>pages/initerrormessage.qml</file>
<file>pages/stub.qml</file>
</qresource>
Expand Down
35 changes: 35 additions & 0 deletions src/qml/components/ConnectionSettings.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) 2022 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import "../controls"

ColumnLayout {
spacing: 20
Setting {
Layout.fillWidth: true
header: "Use cellular data"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget about translations? Use qsTr()?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in #111

}
Setting {
Layout.fillWidth: true
header: "Daily upload limit"
}
Setting {
Layout.fillWidth: true
header: "Connection limit"
}
Setting {
Layout.fillWidth: true
header: "Listening enabled"
description: "Reduces data usage."
}
Setting {
last: true
Layout.fillWidth: true
header: "Blocks Only"
description: "Do not transfer unconfirmed transactions. Also disabled listening."
}
}
25 changes: 25 additions & 0 deletions src/qml/controls/ContinueButton.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) 2022 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

import QtQuick 2.15
import QtQuick.Controls 2.15

Button {
font.family: "Inter"
font.styleName: "Semi Bold"
font.pointSize: 18
contentItem: Text {
text: parent.text
font: parent.font
color: "white"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
background: Rectangle {
implicitHeight: 46
implicitWidth: 300
color: "#F7931A"
radius: 5
}
}
27 changes: 27 additions & 0 deletions src/qml/controls/OptionSwitch.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) 2022 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

import QtQuick 2.15
import QtQuick.Controls 2.15

Switch {
id: root
indicator: Rectangle {
implicitWidth: 45
implicitHeight: 28
x: root.leftPadding
y: parent.height / 2 - height / 2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Math.round((parent.height - height) / 2)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in #111

radius: 18
color: root.checked ? "#F7931A" : "#DDDDDD"
Rectangle {
id: indicatorButton
y: parent.height / 2 - height / 2
x: root.checked ? parent.width - width - 4 : 0 + 4
width: 20
height: 20
radius: 18
color: "#ffffff"
}
}
}
41 changes: 41 additions & 0 deletions src/qml/controls/Setting.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) 2022 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15

Control {
id: root
property bool last: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be automatic, here's a simple approach that doesn't take into account if visible property:

property bool last: parent && root == parent.children[parent.children.length - 1]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in #111

property string header
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want these required?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in #111

property string description
contentItem: GridLayout {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not really a grid.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be a more appropriate Layout for it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A ColumnLayout with a nested RowLayout

columns: 2
rowSpacing: 20
width: parent.width
Header {
Layout.fillWidth: true
center: false
header: root.header
headerSize: 18
description: root.description
descriptionSize: 15
descriptionMargin: 0
}
OptionSwitch {
Layout.alignment: Qt.AlignRight
}
Loader {
Layout.fillWidth:true
Layout.columnSpan: 2
active: !last
visible: active
sourceComponent: Rectangle {
height: 1
color: "#777777"
}
}
}
}