Merge pull request #3742

e390b43 Mining: add buttons/scroll to CPU threads input; improve button labels; set start mining button as primary (rating89us)
This commit is contained in:
luigi1111 2021-11-26 22:56:26 -06:00
commit 917d6d4243
No known key found for this signature in database
GPG key ID: F4ACA0183641E010

View file

@ -37,6 +37,7 @@ Rectangle {
color: "transparent" color: "transparent"
property alias miningHeight: mainLayout.height property alias miningHeight: mainLayout.height
property double currentHashRate: 0 property double currentHashRate: 0
property int threads: idealThreadCount / 2
ColumnLayout { ColumnLayout {
id: mainLayout id: mainLayout
@ -106,30 +107,56 @@ Rectangle {
Layout.fillWidth: true Layout.fillWidth: true
spacing: 16 spacing: 16
MoneroComponents.LineEdit { RowLayout {
id: soloMinerThreadsLine MoneroComponents.StandardButton {
Layout.minimumWidth: 200 id: removeThreadButton
text: "1" small: true
validator: IntValidator { bottom: 1; top: idealThreadCount } primary: false
} text: ""
enabled: threads > 1
onClicked: threads--
}
MoneroComponents.TextPlain { MoneroComponents.TextPlain {
id: numAvailableThreadsText Layout.bottomMargin: 1
text: qsTr("Max # of CPU threads available for mining: ") + idealThreadCount + translationManager.emptyString Layout.minimumWidth: 45
wrapMode: Text.WordWrap color: MoneroComponents.Style.defaultFontColor
font.family: MoneroComponents.Style.fontRegular.name text: threads
font.pixelSize: 14 horizontalAlignment: Text.AlignHCenter
color: MoneroComponents.Style.defaultFontColor font.pixelSize: 16
MouseArea {
anchors.fill: parent
scrollGestureEnabled: false
onWheel: {
if (wheel.angleDelta.y > 0 && threads < idealThreadCount) {
return threads++
} else if (wheel.angleDelta.y < 0 && threads > 1) {
return threads--
}
}
}
}
MoneroComponents.StandardButton {
id: addThreadButton
small: true
primary: false
text: "+"
enabled: threads < idealThreadCount
onClicked: threads++
}
} }
RowLayout { RowLayout {
MoneroComponents.StandardButton { MoneroComponents.StandardButton {
id: autoRecommendedThreadsButton id: autoRecommendedThreadsButton
small: true small: true
text: qsTr("Use recommended # of threads") + translationManager.emptyString primary: false
text: qsTr("Use half (recommended)") + translationManager.emptyString
enabled: startSoloMinerButton.enabled enabled: startSoloMinerButton.enabled
onClicked: { onClicked: {
soloMinerThreadsLine.text = Math.floor(idealThreadCount / 2); threads = idealThreadCount / 2
appWindow.showStatusMessage(qsTr("Set to use recommended # of threads"),3) appWindow.showStatusMessage(qsTr("Set to use recommended # of threads"),3)
} }
} }
@ -137,25 +164,16 @@ Rectangle {
MoneroComponents.StandardButton { MoneroComponents.StandardButton {
id: autoSetMaxThreadsButton id: autoSetMaxThreadsButton
small: true small: true
text: qsTr("Use all threads") + translationManager.emptyString primary: false
text: qsTr("Use all threads") + " (" + idealThreadCount + ")" + translationManager.emptyString
enabled: startSoloMinerButton.enabled enabled: startSoloMinerButton.enabled
onClicked: { onClicked: {
soloMinerThreadsLine.text = idealThreadCount threads = idealThreadCount
appWindow.showStatusMessage(qsTr("Set to use all threads") + translationManager.emptyString,3) appWindow.showStatusMessage(qsTr("Set to use all threads") + translationManager.emptyString,3)
} }
} }
} }
RowLayout {
MoneroComponents.CheckBox {
id: backgroundMining
enabled: startSoloMinerButton.enabled
checked: persistentSettings.allow_background_mining
onClicked: {persistentSettings.allow_background_mining = checked}
text: qsTr("Background mining (experimental)") + translationManager.emptyString
}
}
RowLayout { RowLayout {
// Disable this option until stable // Disable this option until stable
visible: false visible: false
@ -169,6 +187,35 @@ Rectangle {
} }
} }
ColumnLayout {
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
Layout.minimumWidth: 140
MoneroComponents.Label {
id: optionsLabel
color: MoneroComponents.Style.defaultFontColor
text: qsTr("Options") + translationManager.emptyString
fontSize: 16
wrapMode: Text.Wrap
Layout.preferredWidth: manageSoloMinerLabel.textWidth
}
}
ColumnLayout {
Layout.fillWidth: true
spacing: 16
RowLayout {
MoneroComponents.CheckBox {
id: backgroundMining
enabled: startSoloMinerButton.enabled
checked: persistentSettings.allow_background_mining
onClicked: persistentSettings.allow_background_mining = checked
text: qsTr("Background mining (experimental)") + translationManager.emptyString
}
}
}
ColumnLayout { ColumnLayout {
Layout.alignment : Qt.AlignTop | Qt.AlignLeft Layout.alignment : Qt.AlignTop | Qt.AlignLeft
@ -191,9 +238,10 @@ Rectangle {
visible: true visible: true
id: startSoloMinerButton id: startSoloMinerButton
small: true small: true
primary: !stopSoloMinerButton.enabled
text: qsTr("Start mining") + translationManager.emptyString text: qsTr("Start mining") + translationManager.emptyString
onClicked: { onClicked: {
var success = walletManager.startMining(appWindow.currentWallet.address(0, 0), soloMinerThreadsLine.text, persistentSettings.allow_background_mining, persistentSettings.miningIgnoreBattery) var success = walletManager.startMining(appWindow.currentWallet.address(0, 0), threads, persistentSettings.allow_background_mining, persistentSettings.miningIgnoreBattery)
if (success) { if (success) {
update() update()
} else { } else {
@ -211,6 +259,7 @@ Rectangle {
visible: true visible: true
id: stopSoloMinerButton id: stopSoloMinerButton
small: true small: true
primary: stopSoloMinerButton.enabled
text: qsTr("Stop mining") + translationManager.emptyString text: qsTr("Stop mining") + translationManager.emptyString
onClicked: { onClicked: {
walletManager.stopMining() walletManager.stopMining()