Skip to content

Commit

Permalink
Add pool mining screen
Browse files Browse the repository at this point in the history
Wa want to make it easy for people to mine
  • Loading branch information
moneromooo.monero committed Dec 28, 2016
1 parent d8f9e73 commit 8197388
Show file tree
Hide file tree
Showing 10 changed files with 649 additions and 23 deletions.
36 changes: 18 additions & 18 deletions LeftPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -316,50 +316,50 @@ Rectangle {
height: 1
}

/* // ------------- Mining tab ---------------
// ------------- Advanced tab ---------------
MenuButton {
id: miningButton
id: advancedButton
anchors.left: parent.left
anchors.right: parent.right
text: qsTr("Mining") + translationManager.emptyString
symbol: qsTr("M") + translationManager.emptyString
dotColor: "#FFD781"
text: qsTr("Advanced") + translationManager.emptyString
symbol: qsTr("A") + translationManager.emptyString
dotColor: "#AAFFBB"
onClicked: {
parent.previousButton.checked = false
parent.previousButton = miningButton
panel.miningClicked()
parent.previousButton = advancedButton
}
}
Rectangle {
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 16
color: miningButton.checked || settingsButton.checked ? "#1C1C1C" : "#505050"
color: "#505050"
height: 1
}
*/
// ------------- Advanced tab ---------------

// ------------- Mining tab ---------------
MenuButton {
id: advancedButton
id: miningButton
anchors.left: parent.left
anchors.right: parent.right
text: qsTr("Advanced") + translationManager.emptyString
symbol: qsTr("A") + translationManager.emptyString
dotColor: "#AAFFBB"
text: qsTr("Pool mining") + translationManager.emptyString
symbol: qsTr("M") + translationManager.emptyString
dotColor: "#FFD781"
under: advancedButton
onClicked: {
parent.previousButton.checked = false
parent.previousButton = advancedButton
parent.previousButton = miningButton
panel.miningClicked()
}
}

Rectangle {
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 16
color: "#505050"
color: miningButton.checked || settingsButton.checked ? "#1C1C1C" : "#505050"
height: 1
}

// ------------- TxKey tab ---------------
MenuButton {
id: txkeyButton
Expand Down
3 changes: 2 additions & 1 deletion MiddlePanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Rectangle {
property History historyView: History { }
property Sign signView: Sign { }
property Settings settingsView: Settings { }
property Mining miningView: Mining { }
property AddressBook addressBookView: AddressBook { }


Expand Down Expand Up @@ -143,7 +144,7 @@ Rectangle {
PropertyChanges { target: root; currentView: settingsView }
}, State {
name: "Mining"
PropertyChanges { /*TODO*/ }
PropertyChanges { target: root; currentView: miningView }
}
]

Expand Down
138 changes: 138 additions & 0 deletions components/PoolMinerManagerDialog.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
// Copyright (c) 2014-2015, The Monero Project
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import QtQuick 2.0
import QtQuick.Controls 1.4
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.4
import QtQuick.Window 2.0

import "../components" as MoneroComponents

Window {
id: root
modality: Qt.ApplicationModal
flags: Qt.Window | Qt.FramelessWindowHint

signal rejected()
signal started();

function open() {
show()
}

// TODO: implement without hardcoding sizes
width: 480
height: 200

ColumnLayout {
id: mainLayout
spacing: 10
anchors { fill: parent; margins: 35 }

ColumnLayout {
id: column
//anchors {fill: parent; margins: 16 }
Layout.alignment: Qt.AlignHCenter

Label {
text: qsTr("Pool miner doesn't appear to be running")
Layout.alignment: Qt.AlignHCenter
Layout.columnSpan: 2
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
font.pixelSize: 24
font.family: "Arial"
color: "#555555"
}

}

RowLayout {
id: buttons
spacing: 60
Layout.alignment: Qt.AlignHCenter

MoneroComponents.StandardButton {
id: okButton
width: 120
fontSize: 14
shadowReleasedColor: "#FF4304"
shadowPressedColor: "#B32D00"
releasedColor: "#FF6C3C"
pressedColor: "#FF4304"
text: qsTr("Start pool miner")
KeyNavigation.tab: cancelButton
onClicked: {
root.close()
appWindow.startPoolMiner(poolMinerFlags.text);
root.started()
}
}

MoneroComponents.StandardButton {
id: cancelButton
width: 120
fontSize: 14
shadowReleasedColor: "#FF4304"
shadowPressedColor: "#B32D00"
releasedColor: "#FF6C3C"
pressedColor: "#FF4304"
text: qsTr("Cancel")

onClicked: {
root.close()
root.rejected()
}
}
}
RowLayout {
id: advancedRow
MoneroComponents.Label {
id: poolMinerFlagsLabel
color: "#4A4949"
text: qsTr("Pool miner startup flags") + translationManager.emptyString
fontSize: 16
}

MoneroComponents.LineEdit {
id: poolMinerFlags
Layout.preferredWidth: 200
Layout.fillWidth: true
text: appWindow.persistentSettings.poolMinerFlags;
placeholderText: qsTr("(optional)")
}

}
}

}



7 changes: 7 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "model/TransactionHistoryModel.h"
#include "model/TransactionHistorySortFilterModel.h"
#include "daemon/DaemonManager.h"
#include "poolminer/PoolMinerManager.h"
#include "AddressBook.h"
#include "model/AddressBookModel.h"

Expand Down Expand Up @@ -95,6 +96,9 @@ int main(int argc, char *argv[])
qmlRegisterUncreatableType<DaemonManager>("moneroComponents.DaemonManager", 1, 0, "DaemonManager",
"DaemonManager can't be instantiated directly");

qmlRegisterUncreatableType<PoolMinerManager>("moneroComponents.PoolMinerManager", 1, 0, "PoolMinerManager",
"PoolMinerManager can't be instantiated directly");

qmlRegisterUncreatableType<AddressBookModel>("moneroComponents.AddressBookModel", 1, 0, "AddressBookModel",
"AddressBookModel can't be instantiated directly");

Expand All @@ -121,6 +125,9 @@ int main(int argc, char *argv[])
DaemonManager * daemonManager = DaemonManager::instance(&arguments);
QObject::connect(&app, SIGNAL(aboutToQuit()), daemonManager, SLOT(closing()));
engine.rootContext()->setContextProperty("daemonManager", daemonManager);
PoolMinerManager * poolMinerManager = PoolMinerManager::instance(&arguments);
QObject::connect(&app, SIGNAL(aboutToQuit()), poolMinerManager, SLOT(closing()));
engine.rootContext()->setContextProperty("poolMinerManager", poolMinerManager);

// export to QML monero accounts root directory
// wizard is talking about where
Expand Down
35 changes: 33 additions & 2 deletions main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ ApplicationWindow {
property bool daemonSynced: false
property int maxWindowHeight: (Screen.height < 900)? 720 : 800;
property bool daemonRunning: false
property bool poolMinerRunning: false
property alias toolTip: toolTip

// true if wallet ever synchronized
Expand Down Expand Up @@ -362,6 +363,27 @@ ApplicationWindow {
daemonRunning = false;
}

function startPoolMiner(flags){
appWindow.showProcessingSplash(qsTr("Waiting for pool miner to start..."))
poolMinerManager.start(flags);
persistentSettings.poolMinerFlags = flags
}

function stopPoolMiner(){
appWindow.showProcessingSplash(qsTr("Waiting for pool miner to stop..."))
poolMinerManager.stop();
}

function onPoolMinerStarted(){
console.log("pool miner started");
poolMinerRunning = true;
}
function onPoolMinerStopped(){
console.log("pool miner stopped");
hideProcessingSplash();
poolMinerRunning = false;
}


function onWalletNewBlock(blockHeight) {

Expand Down Expand Up @@ -684,6 +706,9 @@ ApplicationWindow {
daemonManager.daemonStarted.connect(onDaemonStarted);
daemonManager.daemonStopped.connect(onDaemonStopped);

poolMinerManager.poolMinerStarted.connect(onPoolMinerStarted);
poolMinerManager.poolMinerStopped.connect(onPoolMinerStopped);

if(!walletsFound()) {
rootItem.state = "wizard"
} else {
Expand Down Expand Up @@ -716,6 +741,7 @@ ApplicationWindow {
property bool is_recovering : false
property bool customDecorations : true
property string daemonFlags
property string poolMinerFlags
}

// Information dialog
Expand Down Expand Up @@ -776,6 +802,10 @@ ApplicationWindow {

}

PoolMinerManagerDialog {
id: poolMinerManagerDialog
}

ProcessingSplash {
id: splash
width: appWindow.width / 1.5
Expand Down Expand Up @@ -838,7 +868,7 @@ ApplicationWindow {
onTxkeyClicked: middlePanel.state = "TxKey"
onHistoryClicked: middlePanel.state = "History"
onAddressBookClicked: middlePanel.state = "AddressBook"
onMiningClicked: middlePanel.state = "Minning"
onMiningClicked: middlePanel.state = "Mining"
onSignClicked: middlePanel.state = "Sign"
onSettingsClicked: middlePanel.state = "Settings"
}
Expand Down Expand Up @@ -1120,7 +1150,8 @@ ApplicationWindow {
onClosing: {
// Close wallet non async on exit
walletManager.closeWallet();
// Stop daemon
// Stop daemon and pool miner
daemonManager.stop();
poolMinerManager.stop();
}
}
2 changes: 2 additions & 0 deletions monero-wallet-gui.pro
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ HEADERS += \
src/QR-Code-generator/QrCode.hpp \
src/QR-Code-generator/QrSegment.hpp \
src/daemon/DaemonManager.h \
src/poolminer/PoolMinerManager.h \
src/model/AddressBookModel.h \
src/libwalletqt/AddressBook.h \
src/zxcvbn-c/zxcvbn.h
Expand All @@ -56,6 +57,7 @@ SOURCES += main.cpp \
src/QR-Code-generator/QrCode.cpp \
src/QR-Code-generator/QrSegment.cpp \
src/daemon/DaemonManager.cpp \
src/poolminer/PoolMinerManager.cpp \
src/model/AddressBookModel.cpp \
src/libwalletqt/AddressBook.cpp \
src/zxcvbn-c/zxcvbn.c
Expand Down
Loading

0 comments on commit 8197388

Please sign in to comment.