Skip to content
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

[DO NOT MERGE] Testing recent changes #279

Closed
wants to merge 15 commits into from
Closed
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
36 changes: 35 additions & 1 deletion src/qml/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,26 @@ void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, cons
LogPrintf("GUI: %s\n", msg.toStdString());
}
}

bool ConfigurationFileExists(ArgsManager& argsman)
{
fs::path settings_path;
if (!argsman.GetSettingsPath(&settings_path)) {
// settings file is disabled
return true;
}
if (fs::exists(settings_path)) {
return true;
}

const fs::path rel_config_path = argsman.GetPathArg("-conf", BITCOIN_CONF_FILENAME);
const fs::path abs_config_path = AbsPathForConfigVal(rel_config_path, true);
if (fs::exists(abs_config_path)) {
return true;
}

return false;
}
} // namespace


Expand Down Expand Up @@ -146,11 +166,24 @@ int QmlGuiMain(int argc, char* argv[])
}

/// Read and parse settings.json file.
if (!gArgs.InitSettings(error)) {
std::vector<std::string> errors;
if (!gArgs.ReadSettingsFile(&errors)) {
error = strprintf("Failed loading settings file:\n%s\n", MakeUnorderedList(errors));
InitError(Untranslated(error));
return EXIT_FAILURE;
}

QVariant need_onboarding(true);
if (gArgs.IsArgSet("-datadir") && !gArgs.GetPathArg("-datadir").empty()) {
need_onboarding.setValue(false);
} else if (ConfigurationFileExists(gArgs)) {
need_onboarding.setValue(false);
}

if (gArgs.IsArgSet("-resetguisettings")) {
need_onboarding.setValue(true);
}

// Default printtoconsole to false for the GUI. GUI programs should not
// print to the console unnecessarily.
gArgs.SoftSetBoolArg("-printtoconsole", false);
Expand Down Expand Up @@ -208,6 +241,7 @@ int QmlGuiMain(int argc, char* argv[])
OptionsQmlModel options_model{*node};
engine.rootContext()->setContextProperty("optionsModel", &options_model);

engine.rootContext()->setContextProperty("needOnboarding", need_onboarding);
#ifdef __ANDROID__
AppMode app_mode(AppMode::MOBILE);
#else
Expand Down
7 changes: 7 additions & 0 deletions src/qml/chainmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef BITCOIN_QML_CHAINMODEL_H
#define BITCOIN_QML_CHAINMODEL_H

#include <chainparams.h>
#include <interfaces/chain.h>

#include <QObject>
Expand All @@ -23,13 +24,17 @@ class ChainModel : public QObject
{
Q_OBJECT
Q_PROPERTY(QString currentNetworkName READ currentNetworkName WRITE setCurrentNetworkName NOTIFY currentNetworkNameChanged)
Q_PROPERTY(quint64 assumedBlockchainSize READ assumedBlockchainSize CONSTANT)
Q_PROPERTY(quint64 assumedChainstateSize READ assumedChainstateSize CONSTANT)
Q_PROPERTY(QVariantList timeRatioList READ timeRatioList NOTIFY timeRatioListChanged)

public:
explicit ChainModel(interfaces::Chain& chain);

QString currentNetworkName() const { return m_current_network_name; };
void setCurrentNetworkName(QString network_name);
quint64 assumedBlockchainSize() const { return m_assumed_blockchain_size; };
quint64 assumedChainstateSize() const { return m_assumed_chainstate_size; };
QVariantList timeRatioList() const { return m_time_ratio_list; };

int timestampAtMeridian();
Expand All @@ -46,6 +51,8 @@ public Q_SLOTS:

private:
QString m_current_network_name;
quint64 m_assumed_blockchain_size{ Params().AssumedBlockchainSize() };
quint64 m_assumed_chainstate_size{ Params().AssumedChainStateSize() };
/* time_ratio: Ratio between the time at which an event
* happened and 12 hours. So, for example, if a block is
* found at 4 am or pm, the time_ratio would be 0.3.
Expand Down
15 changes: 14 additions & 1 deletion src/qml/components/BlockClock.qml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Item {
timeRatioList: chainModel.timeRatioList
verificationProgress: nodeModel.verificationProgress
paused: root.paused
connected: root.connected
synced: nodeModel.verificationProgress > 0.999
backgroundColor: Theme.color.neutral2
timeTickColor: Theme.color.neutral5
Expand Down Expand Up @@ -93,7 +94,7 @@ Item {
name: "IBD"; when: !synced && !paused && connected
PropertyChanges {
target: root
header: Math.round(nodeModel.verificationProgress * 100) + "%"
header: formatProgressPercentage(nodeModel.verificationProgress * 100)
subText: formatRemainingSyncTime(nodeModel.remainingSyncTime)
}
},
Expand Down Expand Up @@ -144,6 +145,18 @@ Item {
}
]

function formatProgressPercentage(progress) {
if (progress >= 1) {
return Math.round(progress) + "%"
} else if (progress >= 0.1) {
return progress.toFixed(1) + "%"
} else if (progress >= 0.01) {
return progress.toFixed(2) + "%"
} else {
return "0%"
}
}

function formatRemainingSyncTime(milliseconds) {
var minutes = Math.floor(milliseconds / 60000);
var seconds = Math.floor((milliseconds % 60000) / 1000);
Expand Down
22 changes: 18 additions & 4 deletions src/qml/components/DeveloperOptions.qml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,19 @@ ColumnLayout {
id: dbcacheSetting
Layout.fillWidth: true
header: qsTr("Database cache size (MiB)")
errorText: qsTr("This is not a valid cache size. Please choose a value between %1 and %2 MiB.").arg(optionsModel.minDbcacheSizeMiB).arg(optionsModel.maxDbcacheSizeMiB)
showErrorText: false
actionItem: ValueInput {
parentState: dbcacheSetting.state
description: optionsModel.dbcacheSizeMiB
onEditingFinished: {
optionsModel.dbcacheSizeMiB = parseInt(text)
dbcacheSetting.forceActiveFocus()
if (checkValidity(optionsModel.minDbcacheSizeMiB, optionsModel.maxDbcacheSizeMiB, parseInt(text))) {
optionsModel.dbcacheSizeMiB = parseInt(text)
dbcacheSetting.forceActiveFocus()
dbcacheSetting.showErrorText = false
} else {
dbcacheSetting.showErrorText = true
}
}
}
onClicked: {
Expand All @@ -45,12 +52,19 @@ ColumnLayout {
id: parSetting
Layout.fillWidth: true
header: qsTr("Script verification threads")
errorText: qsTr("This is not a valid thread count. Please choose a value between %1 and %2 threads.").arg(optionsModel.minScriptThreads).arg(optionsModel.maxScriptThreads)
showErrorText: !loadedItem.acceptableInput && loadedItem.length > 0
actionItem: ValueInput {
parentState: parSetting.state
description: optionsModel.scriptThreads
onEditingFinished: {
optionsModel.scriptThreads = parseInt(text)
parSetting.forceActiveFocus()
if (checkValidity(optionsModel.minScriptThreads, optionsModel.maxScriptThreads, parseInt(text))) {
optionsModel.scriptThreads = parseInt(text)
parSetting.forceActiveFocus()
parSetting.showErrorText = false
} else {
parSetting.showErrorText = true
}
}
}
onClicked: {
Expand Down
4 changes: 4 additions & 0 deletions src/qml/components/PeersIndicator.qml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ RowLayout {
SmoothedAnimation { to: 0; velocity: 2.2 }
SmoothedAnimation { to: 1; velocity: 2.2 }
}

Behavior on color {
ColorAnimation { duration: 150 }
}
}
}
}
4 changes: 4 additions & 0 deletions src/qml/components/Separator.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ import "../controls"
Rectangle {
height: 1
color: Theme.color.neutral5

Behavior on color {
ColorAnimation { duration: 150 }
}
}
33 changes: 30 additions & 3 deletions src/qml/components/StorageOptions.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15

import org.bitcoincore.qt 1.0

import "../controls"

ColumnLayout {
id: root
property bool customStorage: false
property int customStorageAmount
ButtonGroup {
id: group
}
Expand All @@ -16,21 +22,42 @@ ColumnLayout {
Layout.fillWidth: true
ButtonGroup.group: group
text: qsTr("Reduce storage")
description: qsTr("Uses about 2GB. For simple wallet use.")
description: qsTr("Uses about %1GB. For simple wallet use.").arg(chainModel.assumedChainstateSize + 2)
recommended: true
checked: true
checked: !root.customStorage && optionsModel.prune
onClicked: {
optionsModel.prune = true
optionsModel.pruneSizeGB = 2
}
Component.onCompleted: {
optionsModel.prune = true
optionsModel.pruneSizeGB = 2
}
}
OptionButton {
Layout.fillWidth: true
ButtonGroup.group: group
text: qsTr("Store all data")
description: qsTr("Uses about 550GB. Support the network.")
checked: !optionsModel.prune
description: qsTr("Uses about %1GB. Support the network.").arg(
chainModel.assumedBlockchainSize + chainModel.assumedChainstateSize)
onClicked: {
optionsModel.prune = false
}
}
Loader {
Layout.fillWidth: true
active: root.customStorage
visible: active
sourceComponent: OptionButton {
ButtonGroup.group: group
checked: root.customStorage && optionsModel.prune
text: qsTr("Custom")
description: qsTr("Storing about %1GB of data.").arg(root.customStorageAmount + chainModel.assumedChainstateSize)
onClicked: {
optionsModel.prune = true
optionsModel.pruneSizeGB = root.customStorageAmount
}
}
}
}
18 changes: 15 additions & 3 deletions src/qml/components/StorageSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import QtQuick.Layouts 1.15
import "../controls"

ColumnLayout {
id: root
property bool customStorage: false
property int customStorageAmount
spacing: 4
Setting {
Layout.fillWidth: true
Expand All @@ -32,13 +35,22 @@ ColumnLayout {
Setting {
id: pruneTargetSetting
Layout.fillWidth: true
header: qsTr("Storage limit (GB)")
header: qsTr("Block Storage limit (GB)")
errorText: qsTr("This is not a valid prune target. Please choose a value that is equal to or larger than 1GB")
showErrorText: false
actionItem: ValueInput {
parentState: pruneTargetSetting.state
description: optionsModel.pruneSizeGB
onEditingFinished: {
optionsModel.pruneSizeGB = parseInt(text)
pruneTargetSetting.forceActiveFocus()
if (parseInt(text) < 1) {
pruneTargetSetting.showErrorText = true
} else {
root.customStorage = true
root.customStorageAmount = parseInt(text)
optionsModel.pruneSizeGB = parseInt(text)
pruneTargetSetting.forceActiveFocus()
pruneTargetSetting.showErrorText = false
}
}
}
onClicked: {
Expand Down
Loading