-
Notifications
You must be signed in to change notification settings - Fork 771
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
Mining: add buttons/mouse scroll to CPU threads; improve button labels; set "Start mining" button as primary #3742
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
rating89us
commented
Nov 21, 2021
selsta
reviewed
Nov 21, 2021
rating89us
force-pushed
the
patch-117
branch
from
November 21, 2021 18:30
bb90c77
to
2086fcc
Compare
selsta
reviewed
Nov 22, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
diff --git a/pages/Mining.qml b/pages/Mining.qml
index 78a31854..42b54721 100644
--- a/pages/Mining.qml
+++ b/pages/Mining.qml
@@ -37,6 +37,7 @@ Rectangle {
color: "transparent"
property alias miningHeight: mainLayout.height
property double currentHashRate: 0
+ property int threads: idealThreadCount / 2
ColumnLayout {
id: mainLayout
@@ -111,19 +112,16 @@ Rectangle {
id: removeThreadButton
small: true
primary: false
- text: qsTr("-") + translationManager.emptyString
- enabled: soloMinerThreadsLine.text > 1
- onClicked: {
- soloMinerThreadsLine.text = Number(soloMinerThreadsLine.text) - 1
- }
+ text: qsTr("−") + translationManager.emptyString
+ enabled: threads > 1
+ onClicked: threads--
}
MoneroComponents.TextPlain {
- id: soloMinerThreadsLine
Layout.bottomMargin: 1
Layout.minimumWidth: 45
color: MoneroComponents.Style.defaultFontColor
- text: idealThreadCount / 2
+ text: threads
horizontalAlignment: Text.AlignHCenter
font.pixelSize: 16
@@ -131,11 +129,10 @@ Rectangle {
anchors.fill: parent
scrollGestureEnabled: false
onWheel: {
- if (wheel.angleDelta.y > 0 && Number(soloMinerThreadsLine.text) < idealThreadCount) {
- return soloMinerThreadsLine.text = Number(soloMinerThreadsLine.text) + 1
- }
- else if (wheel.angleDelta.y < 0 && Number(soloMinerThreadsLine.text) > 1) {
- return soloMinerThreadsLine.text = Number(soloMinerThreadsLine.text) - 1
+ if (wheel.angleDelta.y > 0 && threads < idealThreadCount) {
+ return threads++
+ } else if (wheel.angleDelta.y < 0 && threads > 1) {
+ return threads--
}
}
}
@@ -146,9 +143,9 @@ Rectangle {
small: true
primary: false
text: qsTr("+") + translationManager.emptyString
- enabled: soloMinerThreadsLine.text < idealThreadCount
+ enabled: threads < idealThreadCount
onClicked: {
- soloMinerThreadsLine.text = Number(soloMinerThreadsLine.text) + 1
+ threads++
}
}
}
@@ -161,7 +158,7 @@ Rectangle {
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)
}
}
@@ -173,7 +170,7 @@ Rectangle {
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)
}
}
@@ -215,7 +212,7 @@ Rectangle {
id: backgroundMining
enabled: startSoloMinerButton.enabled
checked: persistentSettings.allow_background_mining
- onClicked: {persistentSettings.allow_background_mining = checked}
+ onClicked: persistentSettings.allow_background_mining = checked
text: qsTr("Background mining (experimental)") + translationManager.emptyString
}
}
@@ -246,7 +243,7 @@ Rectangle {
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 {
I would recommend to use a property int
for the threadCount. Otherwise you keep using strings for numbers, which isn't nice.
…s; set start mining button as primary
rating89us
force-pushed
the
patch-117
branch
from
November 22, 2021 18:46
58bcfad
to
e390b43
Compare
selsta
approved these changes
Nov 23, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.