mirror of
https://github.com/monero-project/monero-gui
synced 2024-11-24 11:17:15 +01:00
commit
38788aab43
274
pages/Mining.qml
274
pages/Mining.qml
@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2014-2018, The Monero Project
|
||||
// Copyright (c) 2014-2019, The Monero Project
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
@ -59,10 +59,8 @@ Rectangle {
|
||||
visible: !walletManager.isDaemonLocal(appWindow.currentDaemonAddress)
|
||||
}
|
||||
|
||||
MoneroComponents.Label {
|
||||
id: soloSyncedLabel
|
||||
fontSize: 18 * scaleRatio
|
||||
color: "#D02020"
|
||||
MoneroComponents.WarningBox {
|
||||
Layout.bottomMargin: 8 * scaleRatio
|
||||
text: qsTr("Your daemon must be synchronized before you can start mining") + translationManager.emptyString
|
||||
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
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
id: soloMinerThreadsRow
|
||||
GridLayout {
|
||||
columns: 2
|
||||
Layout.fillWidth: true
|
||||
columnSpacing: 20 * scaleRatio
|
||||
rowSpacing: 16 * scaleRatio
|
||||
|
||||
MoneroComponents.Label {
|
||||
id: soloMinerThreadsLabel
|
||||
color: MoneroComponents.Style.defaultFontColor
|
||||
text: qsTr("CPU threads") + translationManager.emptyString
|
||||
fontSize: 16 * scaleRatio
|
||||
Layout.preferredWidth: 120 * scaleRatio
|
||||
}
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment : Qt.AlignTop | Qt.AlignLeft
|
||||
|
||||
MoneroComponents.LineEdit {
|
||||
id: soloMinerThreadsLine
|
||||
Layout.preferredWidth: 200 * scaleRatio
|
||||
text: "1"
|
||||
validator: IntValidator { bottom: 1; top: idealThreadCount }
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
id: numAvailableThreadsText
|
||||
text: qsTr("Max # of CPU threads available for mining: ") + idealThreadCount + translationManager.emptyString
|
||||
wrapMode: Text.WordWrap
|
||||
Layout.leftMargin: 125 * scaleRatio
|
||||
font.family: MoneroComponents.Style.fontRegular.name
|
||||
font.pixelSize: 14 * scaleRatio
|
||||
color: MoneroComponents.Style.defaultFontColor
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.leftMargin: 125 * scaleRatio
|
||||
|
||||
MoneroComponents.StandardButton {
|
||||
id: autoRecommendedThreadsButton
|
||||
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.Label {
|
||||
id: soloMinerThreadsLabel
|
||||
color: MoneroComponents.Style.defaultFontColor
|
||||
text: qsTr("CPU threads") + translationManager.emptyString
|
||||
fontSize: 16 * scaleRatio
|
||||
wrapMode: Text.WordWrap
|
||||
}
|
||||
}
|
||||
|
||||
MoneroComponents.StandardButton {
|
||||
id: autoSetMaxThreadsButton
|
||||
small: true
|
||||
text: qsTr("Use all threads") + translationManager.emptyString
|
||||
enabled: startSoloMinerButton.enabled
|
||||
onClicked: {
|
||||
soloMinerThreadsLine.text = idealThreadCount
|
||||
appWindow.showStatusMessage(qsTr("Set to use all threads"),3)
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
spacing: 16 * scaleRatio
|
||||
|
||||
MoneroComponents.LineEdit {
|
||||
id: soloMinerThreadsLine
|
||||
Layout.minimumWidth: 200 * scaleRatio
|
||||
text: "1"
|
||||
validator: IntValidator { bottom: 1; top: idealThreadCount }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.leftMargin: 125 * scaleRatio
|
||||
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
|
||||
}
|
||||
}
|
||||
Text {
|
||||
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 * scaleRatio
|
||||
color: MoneroComponents.Style.defaultFontColor
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
// Disable this option until stable
|
||||
visible: false
|
||||
Layout.leftMargin: 125 * scaleRatio
|
||||
MoneroComponents.CheckBox {
|
||||
id: ignoreBattery
|
||||
enabled: startSoloMinerButton.enabled
|
||||
checked: !persistentSettings.miningIgnoreBattery
|
||||
onClicked: {persistentSettings.miningIgnoreBattery = !checked}
|
||||
text: qsTr("Enable mining when running on battery") + translationManager.emptyString
|
||||
}
|
||||
}
|
||||
RowLayout {
|
||||
MoneroComponents.StandardButton {
|
||||
id: autoRecommendedThreadsButton
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
MoneroComponents.Label {
|
||||
id: manageSoloMinerLabel
|
||||
color: MoneroComponents.Style.defaultFontColor
|
||||
text: qsTr("Manage miner") + translationManager.emptyString
|
||||
fontSize: 16 * scaleRatio
|
||||
Layout.preferredWidth: 120 * scaleRatio
|
||||
}
|
||||
MoneroComponents.StandardButton {
|
||||
id: autoSetMaxThreadsButton
|
||||
small: true
|
||||
text: qsTr("Use all threads") + translationManager.emptyString
|
||||
enabled: startSoloMinerButton.enabled
|
||||
onClicked: {
|
||||
soloMinerThreadsLine.text = idealThreadCount
|
||||
appWindow.showStatusMessage(qsTr("Set to use all threads"),3)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MoneroComponents.StandardButton {
|
||||
visible: true
|
||||
id: startSoloMinerButton
|
||||
width: 110 * scaleRatio
|
||||
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()
|
||||
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
|
||||
MoneroComponents.CheckBox {
|
||||
id: ignoreBattery
|
||||
enabled: startSoloMinerButton.enabled
|
||||
checked: !persistentSettings.miningIgnoreBattery
|
||||
onClicked: {persistentSettings.miningIgnoreBattery = !checked}
|
||||
text: qsTr("Enable mining when running on battery") + translationManager.emptyString
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MoneroComponents.StandardButton {
|
||||
visible: true
|
||||
id: stopSoloMinerButton
|
||||
width: 110 * scaleRatio
|
||||
small: true
|
||||
text: qsTr("Stop mining") + translationManager.emptyString
|
||||
onClicked: {
|
||||
walletManager.stopMining()
|
||||
update()
|
||||
ColumnLayout {
|
||||
Layout.alignment : Qt.AlignTop | Qt.AlignLeft
|
||||
|
||||
MoneroComponents.Label {
|
||||
id: manageSoloMinerLabel
|
||||
color: MoneroComponents.Style.defaultFontColor
|
||||
text: qsTr("Manage miner") + translationManager.emptyString
|
||||
fontSize: 16 * scaleRatio
|
||||
wrapMode: Text.Wrap
|
||||
Layout.preferredWidth: manageSoloMinerLabel.textWidth
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
id: statusRow
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
spacing: 16 * scaleRatio
|
||||
|
||||
MoneroComponents.Label {
|
||||
id: statusLabel
|
||||
color: MoneroComponents.Style.defaultFontColor
|
||||
text: qsTr("Status") + translationManager.emptyString
|
||||
fontSize: 16 * scaleRatio
|
||||
Layout.preferredWidth: 120 * 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.StandardButton {
|
||||
visible: true
|
||||
id: stopSoloMinerButton
|
||||
small: true
|
||||
text: qsTr("Stop mining") + translationManager.emptyString
|
||||
onClicked: {
|
||||
walletManager.stopMining()
|
||||
update()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MoneroComponents.LineEdit {
|
||||
id: statusText
|
||||
Layout.preferredWidth: 200 * scaleRatio
|
||||
text: qsTr("Not mining") + translationManager.emptyString
|
||||
borderDisabled: true
|
||||
readOnly: true
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment : Qt.AlignTop | Qt.AlignLeft
|
||||
|
||||
MoneroComponents.Label {
|
||||
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() {
|
||||
var daemonReady = walletManager.isDaemonLocal(appWindow.currentDaemonAddress) && appWindow.daemonSynced
|
||||
appWindow.isMining = walletManager.isMining()
|
||||
updateStatusText()
|
||||
startSoloMinerButton.enabled = !appWindow.isMining
|
||||
stopSoloMinerButton.enabled = !startSoloMinerButton.enabled
|
||||
startSoloMinerButton.enabled = !appWindow.isMining && daemonReady
|
||||
stopSoloMinerButton.enabled = !startSoloMinerButton.enabled && daemonReady
|
||||
}
|
||||
|
||||
MoneroComponents.StandardDialog {
|
||||
|
Loading…
Reference in New Issue
Block a user