Merge pull request #2014

d6f8834 mining: fix layout issues (mmbyday)
pull/2/head
luigi1111 5 years ago
commit 38788aab43
No known key found for this signature in database
GPG Key ID: F4ACA0183641E010

@ -1,4 +1,4 @@
// Copyright (c) 2014-2018, The Monero Project // Copyright (c) 2014-2019, The Monero Project
// //
// All rights reserved. // All rights reserved.
// //
@ -59,10 +59,8 @@ Rectangle {
visible: !walletManager.isDaemonLocal(appWindow.currentDaemonAddress) visible: !walletManager.isDaemonLocal(appWindow.currentDaemonAddress)
} }
MoneroComponents.Label { MoneroComponents.WarningBox {
id: soloSyncedLabel Layout.bottomMargin: 8 * scaleRatio
fontSize: 18 * scaleRatio
color: "#D02020"
text: qsTr("Your daemon must be synchronized before you can start mining") + translationManager.emptyString text: qsTr("Your daemon must be synchronized before you can start mining") + translationManager.emptyString
visible: walletManager.isDaemonLocal(appWindow.currentDaemonAddress) && !appWindow.daemonSynced visible: walletManager.isDaemonLocal(appWindow.currentDaemonAddress) && !appWindow.daemonSynced
} }
@ -84,145 +82,168 @@ Rectangle {
text: qsTr("Mining may reduce the performance of other running applications and processes.") + translationManager.emptyString text: qsTr("Mining may reduce the performance of other running applications and processes.") + translationManager.emptyString
} }
RowLayout { GridLayout {
id: soloMinerThreadsRow columns: 2
Layout.fillWidth: true
columnSpacing: 20 * scaleRatio
rowSpacing: 16 * scaleRatio
MoneroComponents.Label { ColumnLayout {
id: soloMinerThreadsLabel Layout.fillWidth: true
color: MoneroComponents.Style.defaultFontColor Layout.alignment : Qt.AlignTop | Qt.AlignLeft
text: qsTr("CPU threads") + translationManager.emptyString
fontSize: 16 * scaleRatio
Layout.preferredWidth: 120 * scaleRatio
}
MoneroComponents.LineEdit { MoneroComponents.Label {
id: soloMinerThreadsLine id: soloMinerThreadsLabel
Layout.preferredWidth: 200 * scaleRatio color: MoneroComponents.Style.defaultFontColor
text: "1" text: qsTr("CPU threads") + translationManager.emptyString
validator: IntValidator { bottom: 1; top: idealThreadCount } fontSize: 16 * scaleRatio
wrapMode: Text.WordWrap
}
} }
}
Text { ColumnLayout {
id: numAvailableThreadsText Layout.fillWidth: true
text: qsTr("Max # of CPU threads available for mining: ") + idealThreadCount + translationManager.emptyString spacing: 16 * scaleRatio
wrapMode: Text.WordWrap
Layout.leftMargin: 125 * scaleRatio
font.family: MoneroComponents.Style.fontRegular.name
font.pixelSize: 14 * scaleRatio
color: MoneroComponents.Style.defaultFontColor
}
RowLayout { MoneroComponents.LineEdit {
Layout.leftMargin: 125 * scaleRatio id: soloMinerThreadsLine
Layout.minimumWidth: 200 * scaleRatio
MoneroComponents.StandardButton { text: "1"
id: autoRecommendedThreadsButton validator: IntValidator { bottom: 1; top: idealThreadCount }
small: true
text: qsTr("Use recommended # of threads") + translationManager.emptyString
enabled: startSoloMinerButton.enabled
onClicked: {
soloMinerThreadsLine.text = Math.floor(idealThreadCount / 2);
appWindow.showStatusMessage(qsTr("Set to use recommended # of threads"),3)
} }
}
MoneroComponents.StandardButton { Text {
id: autoSetMaxThreadsButton id: numAvailableThreadsText
small: true text: qsTr("Max # of CPU threads available for mining: ") + idealThreadCount + translationManager.emptyString
text: qsTr("Use all threads") + translationManager.emptyString wrapMode: Text.WordWrap
enabled: startSoloMinerButton.enabled font.family: MoneroComponents.Style.fontRegular.name
onClicked: { font.pixelSize: 14 * scaleRatio
soloMinerThreadsLine.text = idealThreadCount color: MoneroComponents.Style.defaultFontColor
appWindow.showStatusMessage(qsTr("Set to use all threads"),3)
} }
}
}
RowLayout { RowLayout {
Layout.leftMargin: 125 * scaleRatio MoneroComponents.StandardButton {
MoneroComponents.CheckBox { id: autoRecommendedThreadsButton
id: backgroundMining small: true
enabled: startSoloMinerButton.enabled text: qsTr("Use recommended # of threads") + translationManager.emptyString
checked: persistentSettings.allow_background_mining enabled: startSoloMinerButton.enabled
onClicked: {persistentSettings.allow_background_mining = checked} onClicked: {
text: qsTr("Background mining (experimental)") + translationManager.emptyString soloMinerThreadsLine.text = Math.floor(idealThreadCount / 2);
} appWindow.showStatusMessage(qsTr("Set to use recommended # of threads"),3)
} }
}
RowLayout { MoneroComponents.StandardButton {
// Disable this option until stable id: autoSetMaxThreadsButton
visible: false small: true
Layout.leftMargin: 125 * scaleRatio text: qsTr("Use all threads") + translationManager.emptyString
MoneroComponents.CheckBox { enabled: startSoloMinerButton.enabled
id: ignoreBattery onClicked: {
enabled: startSoloMinerButton.enabled soloMinerThreadsLine.text = idealThreadCount
checked: !persistentSettings.miningIgnoreBattery appWindow.showStatusMessage(qsTr("Set to use all threads"),3)
onClicked: {persistentSettings.miningIgnoreBattery = !checked} }
text: qsTr("Enable mining when running on battery") + translationManager.emptyString }
} }
}
RowLayout { RowLayout {
MoneroComponents.Label { MoneroComponents.CheckBox {
id: manageSoloMinerLabel id: backgroundMining
color: MoneroComponents.Style.defaultFontColor enabled: startSoloMinerButton.enabled
text: qsTr("Manage miner") + translationManager.emptyString checked: persistentSettings.allow_background_mining
fontSize: 16 * scaleRatio onClicked: {persistentSettings.allow_background_mining = checked}
Layout.preferredWidth: 120 * scaleRatio text: qsTr("Background mining (experimental)") + translationManager.emptyString
} }
}
MoneroComponents.StandardButton { RowLayout {
visible: true // Disable this option until stable
id: startSoloMinerButton visible: false
width: 110 * scaleRatio MoneroComponents.CheckBox {
small: true id: ignoreBattery
text: qsTr("Start mining") + translationManager.emptyString enabled: startSoloMinerButton.enabled
onClicked: { checked: !persistentSettings.miningIgnoreBattery
var success = walletManager.startMining(appWindow.currentWallet.address(0, 0), soloMinerThreadsLine.text, persistentSettings.allow_background_mining, persistentSettings.miningIgnoreBattery) onClicked: {persistentSettings.miningIgnoreBattery = !checked}
if (success) { text: qsTr("Enable mining when running on battery") + translationManager.emptyString
update()
} else {
errorPopup.title = qsTr("Error starting mining") + translationManager.emptyString;
errorPopup.text = qsTr("Couldn't start mining.<br>")
if (!walletManager.isDaemonLocal(appWindow.currentDaemonAddress))
errorPopup.text += qsTr("Mining is only available on local daemons. Run a local daemon to be able to mine.<br>")
errorPopup.icon = StandardIcon.Critical
errorPopup.open()
} }
} }
} }
MoneroComponents.StandardButton { ColumnLayout {
visible: true Layout.alignment : Qt.AlignTop | Qt.AlignLeft
id: stopSoloMinerButton
width: 110 * scaleRatio MoneroComponents.Label {
small: true id: manageSoloMinerLabel
text: qsTr("Stop mining") + translationManager.emptyString color: MoneroComponents.Style.defaultFontColor
onClicked: { text: qsTr("Manage miner") + translationManager.emptyString
walletManager.stopMining() fontSize: 16 * scaleRatio
update() wrapMode: Text.Wrap
Layout.preferredWidth: manageSoloMinerLabel.textWidth
} }
} }
}
RowLayout { ColumnLayout {
id: statusRow Layout.fillWidth: true
spacing: 16 * scaleRatio
RowLayout {
MoneroComponents.StandardButton {
visible: true
id: startSoloMinerButton
small: true
text: qsTr("Start mining") + translationManager.emptyString
onClicked: {
var success = walletManager.startMining(appWindow.currentWallet.address(0, 0), soloMinerThreadsLine.text, persistentSettings.allow_background_mining, persistentSettings.miningIgnoreBattery)
if (success) {
update()
} else {
errorPopup.title = qsTr("Error starting mining") + translationManager.emptyString;
errorPopup.text = qsTr("Couldn't start mining.<br>")
if (!walletManager.isDaemonLocal(appWindow.currentDaemonAddress))
errorPopup.text += qsTr("Mining is only available on local daemons. Run a local daemon to be able to mine.<br>")
errorPopup.icon = StandardIcon.Critical
errorPopup.open()
}
}
}
MoneroComponents.Label { MoneroComponents.StandardButton {
id: statusLabel visible: true
color: MoneroComponents.Style.defaultFontColor id: stopSoloMinerButton
text: qsTr("Status") + translationManager.emptyString small: true
fontSize: 16 * scaleRatio text: qsTr("Stop mining") + translationManager.emptyString
Layout.preferredWidth: 120 * scaleRatio onClicked: {
walletManager.stopMining()
update()
}
}
}
} }
MoneroComponents.LineEdit { ColumnLayout {
id: statusText Layout.fillWidth: true
Layout.preferredWidth: 200 * scaleRatio Layout.alignment : Qt.AlignTop | Qt.AlignLeft
text: qsTr("Not mining") + translationManager.emptyString
borderDisabled: true MoneroComponents.Label {
readOnly: true id: statusLabel
color: MoneroComponents.Style.defaultFontColor
text: qsTr("Status") + translationManager.emptyString
fontSize: 16 * scaleRatio
}
}
ColumnLayout {
Layout.fillWidth: true
spacing: 16 * scaleRatio
MoneroComponents.LineEditMulti {
id: statusText
Layout.minimumWidth: 300 * scaleRatio
text: qsTr("Not mining") + translationManager.emptyString
borderDisabled: true
readOnly: true
wrapMode: Text.Wrap
inputPaddingLeft: 0
}
} }
} }
} }
@ -237,10 +258,11 @@ Rectangle {
} }
function update() { function update() {
var daemonReady = walletManager.isDaemonLocal(appWindow.currentDaemonAddress) && appWindow.daemonSynced
appWindow.isMining = walletManager.isMining() appWindow.isMining = walletManager.isMining()
updateStatusText() updateStatusText()
startSoloMinerButton.enabled = !appWindow.isMining startSoloMinerButton.enabled = !appWindow.isMining && daemonReady
stopSoloMinerButton.enabled = !startSoloMinerButton.enabled stopSoloMinerButton.enabled = !startSoloMinerButton.enabled && daemonReady
} }
MoneroComponents.StandardDialog { MoneroComponents.StandardDialog {