Merge pull request #2014

d6f8834 mining: fix layout issues (mmbyday)
This commit is contained in:
luigi1111 2019-03-21 16:13:46 -04:00
commit 38788aab43
No known key found for this signature in database
GPG Key ID: F4ACA0183641E010

View File

@ -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 {
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.StandardButton { ColumnLayout {
id: autoSetMaxThreadsButton Layout.fillWidth: true
small: true spacing: 16 * scaleRatio
text: qsTr("Use all threads") + translationManager.emptyString
enabled: startSoloMinerButton.enabled MoneroComponents.LineEdit {
onClicked: { id: soloMinerThreadsLine
soloMinerThreadsLine.text = idealThreadCount Layout.minimumWidth: 200 * scaleRatio
appWindow.showStatusMessage(qsTr("Set to use all threads"),3) text: "1"
validator: IntValidator { bottom: 1; top: idealThreadCount }
} }
}
}
RowLayout { Text {
Layout.leftMargin: 125 * scaleRatio id: numAvailableThreadsText
MoneroComponents.CheckBox { text: qsTr("Max # of CPU threads available for mining: ") + idealThreadCount + translationManager.emptyString
id: backgroundMining wrapMode: Text.WordWrap
enabled: startSoloMinerButton.enabled font.family: MoneroComponents.Style.fontRegular.name
checked: persistentSettings.allow_background_mining font.pixelSize: 14 * scaleRatio
onClicked: {persistentSettings.allow_background_mining = checked} color: MoneroComponents.Style.defaultFontColor
text: qsTr("Background mining (experimental)") + translationManager.emptyString }
}
}
RowLayout { RowLayout {
// Disable this option until stable MoneroComponents.StandardButton {
visible: false id: autoRecommendedThreadsButton
Layout.leftMargin: 125 * scaleRatio small: true
MoneroComponents.CheckBox { text: qsTr("Use recommended # of threads") + translationManager.emptyString
id: ignoreBattery enabled: startSoloMinerButton.enabled
enabled: startSoloMinerButton.enabled onClicked: {
checked: !persistentSettings.miningIgnoreBattery soloMinerThreadsLine.text = Math.floor(idealThreadCount / 2);
onClicked: {persistentSettings.miningIgnoreBattery = !checked} appWindow.showStatusMessage(qsTr("Set to use recommended # of threads"),3)
text: qsTr("Enable mining when running on battery") + translationManager.emptyString }
} }
}
RowLayout { MoneroComponents.StandardButton {
MoneroComponents.Label { id: autoSetMaxThreadsButton
id: manageSoloMinerLabel small: true
color: MoneroComponents.Style.defaultFontColor text: qsTr("Use all threads") + translationManager.emptyString
text: qsTr("Manage miner") + translationManager.emptyString enabled: startSoloMinerButton.enabled
fontSize: 16 * scaleRatio onClicked: {
Layout.preferredWidth: 120 * scaleRatio soloMinerThreadsLine.text = idealThreadCount
} appWindow.showStatusMessage(qsTr("Set to use all threads"),3)
}
}
}
MoneroComponents.StandardButton { RowLayout {
visible: true MoneroComponents.CheckBox {
id: startSoloMinerButton id: backgroundMining
width: 110 * scaleRatio enabled: startSoloMinerButton.enabled
small: true checked: persistentSettings.allow_background_mining
text: qsTr("Start mining") + translationManager.emptyString onClicked: {persistentSettings.allow_background_mining = checked}
onClicked: { text: qsTr("Background mining (experimental)") + translationManager.emptyString
var success = walletManager.startMining(appWindow.currentWallet.address(0, 0), soloMinerThreadsLine.text, persistentSettings.allow_background_mining, persistentSettings.miningIgnoreBattery) }
if (success) { }
update()
} else { RowLayout {
errorPopup.title = qsTr("Error starting mining") + translationManager.emptyString; // Disable this option until stable
errorPopup.text = qsTr("Couldn't start mining.<br>") visible: false
if (!walletManager.isDaemonLocal(appWindow.currentDaemonAddress)) MoneroComponents.CheckBox {
errorPopup.text += qsTr("Mining is only available on local daemons. Run a local daemon to be able to mine.<br>") id: ignoreBattery
errorPopup.icon = StandardIcon.Critical enabled: startSoloMinerButton.enabled
errorPopup.open() checked: !persistentSettings.miningIgnoreBattery
onClicked: {persistentSettings.miningIgnoreBattery = !checked}
text: qsTr("Enable mining when running on battery") + translationManager.emptyString
} }
} }
} }
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
MoneroComponents.Label { RowLayout {
id: statusLabel MoneroComponents.StandardButton {
color: MoneroComponents.Style.defaultFontColor visible: true
text: qsTr("Status") + translationManager.emptyString id: startSoloMinerButton
fontSize: 16 * scaleRatio small: true
Layout.preferredWidth: 120 * scaleRatio 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 { 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 {