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"
property alias miningHeight: mainLayout.height
property double currentHashRate: 0
property int threads: idealThreadCount / 2
ColumnLayout {
id: mainLayout
@ -106,30 +107,56 @@ Rectangle {
Layout.fillWidth: true
spacing: 16
MoneroComponents.LineEdit {
id: soloMinerThreadsLine
Layout.minimumWidth: 200
text: "1"
validator: IntValidator { bottom: 1; top: idealThreadCount }
}
RowLayout {
MoneroComponents.StandardButton {
id: removeThreadButton
small: true
primary: false
text: ""
enabled: threads > 1
onClicked: threads--
}
MoneroComponents.TextPlain {
id: numAvailableThreadsText
text: qsTr("Max # of CPU threads available for mining: ") + idealThreadCount + translationManager.emptyString
wrapMode: Text.WordWrap
font.family: MoneroComponents.Style.fontRegular.name
font.pixelSize: 14
color: MoneroComponents.Style.defaultFontColor
MoneroComponents.TextPlain {
Layout.bottomMargin: 1
Layout.minimumWidth: 45
color: MoneroComponents.Style.defaultFontColor
text: threads
horizontalAlignment: Text.AlignHCenter
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 {
MoneroComponents.StandardButton {
id: autoRecommendedThreadsButton
small: true
text: qsTr("Use recommended # of threads") + translationManager.emptyString
primary: false
text: qsTr("Use half (recommended)") + translationManager.emptyString
enabled: startSoloMinerButton.enabled
onClicked: {
soloMinerThreadsLine.text = Math.floor(idealThreadCount / 2);
threads = idealThreadCount / 2
appWindow.showStatusMessage(qsTr("Set to use recommended # of threads"),3)
}
}
@ -137,25 +164,16 @@ Rectangle {
MoneroComponents.StandardButton {
id: autoSetMaxThreadsButton
small: true
text: qsTr("Use all threads") + translationManager.emptyString
primary: false
text: qsTr("Use all threads") + " (" + idealThreadCount + ")" + translationManager.emptyString
enabled: startSoloMinerButton.enabled
onClicked: {
soloMinerThreadsLine.text = idealThreadCount
threads = idealThreadCount
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 {
// Disable this option until stable
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 {
Layout.alignment : Qt.AlignTop | Qt.AlignLeft
@ -191,9 +238,10 @@ Rectangle {
visible: true
id: startSoloMinerButton
small: true
primary: !stopSoloMinerButton.enabled
text: qsTr("Start mining") + translationManager.emptyString
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) {
update()
} else {
@ -211,6 +259,7 @@ Rectangle {
visible: true
id: stopSoloMinerButton
small: true
primary: stopSoloMinerButton.enabled
text: qsTr("Stop mining") + translationManager.emptyString
onClicked: {
walletManager.stopMining()