XMRig tab - Simple mining GUI to download and run XMRig releases.

This commit is contained in:
dsc 2020-10-14 22:12:32 +02:00 committed by rm
parent 61a135e1c2
commit d0260ce018
16 changed files with 884 additions and 3 deletions

View file

@ -11,6 +11,7 @@ set(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION}")
option(FETCH_DEPS "Download dependencies if they are not found" ON)
option(XMRTO "Include Xmr.To module" ON)
option(XMRig "Include XMRig module" ON)
option(BUILD_TOR "Build Tor" OFF)
option(STATIC "Link libraries statically, requires static Qt")
option(USE_DEVICE_TREZOR "Trezor support compilation" OFF)

View file

@ -130,6 +130,10 @@ if(XMRTO)
target_compile_definitions(feather PRIVATE XMRTO=1)
endif()
if(XMRig)
target_compile_definitions(feather PRIVATE MINING=1)
endif()
if(HAVE_SYS_PRCTL_H)
target_compile_definitions(feather PRIVATE HAVE_SYS_PRCTL_H=1)
endif()

View file

@ -317,6 +317,7 @@ void AppContext::onWalletOpened(Wallet *wallet) {
this->currentWallet = wallet;
this->walletPath = this->currentWallet->path() + ".keys";
this->walletViewOnly = this->currentWallet->viewOnly();
config()->set(Config::walletPath, this->walletPath);
connect(this->currentWallet, &Wallet::moneySpent, this, &AppContext::onMoneySpent);
@ -341,12 +342,17 @@ void AppContext::onWalletOpened(Wallet *wallet) {
// force trigger preferredFiat signal for history model
this->onPreferredFiatCurrencyChanged(config()->get(Config::preferredFiatCurrency).toString());
this->setWindowTitle();
}
// (window) title
void AppContext::setWindowTitle(bool mining) {
QFileInfo fileInfo(this->walletPath);
auto title = QString("Feather - [%1]").arg(fileInfo.fileName());
if(this->currentWallet->viewOnly())
if(this->walletViewOnly)
title += " [view-only]";
if(mining)
title += " [mining]";
emit setTitle(title);
}
@ -387,7 +393,11 @@ void AppContext::onWSMessage(const QJsonObject &msg) {
else if(cmd == "nodes") {
this->onWSNodes(msg.value("data").toArray());
}
#if defined(MINING)
else if(cmd == "xmrig") {
this->XMRigDownloads(msg.value("data").toObject());
}
#endif
else if(cmd == "crypto_rates") {
QJsonArray crypto_rates = msg.value("data").toArray();
AppContext::prices->cryptoPricesReceived(crypto_rates);

View file

@ -56,6 +56,7 @@ public:
QString walletPath;
QString walletPassword = "";
bool walletViewOnly = false;
NetworkType::Type networkType;
QString applicationPath;
@ -101,6 +102,7 @@ public:
void walletClose(bool emitClosedSignal = true);
void storeWallet();
void refreshModels();
void setWindowTitle(bool mining = false);
public slots:
void onOpenWallet(const QString& path, const QString &password);
@ -152,6 +154,7 @@ signals:
void nodesUpdated(QList<QSharedPointer<FeatherNode>> &nodes);
void ccsUpdated(QList<QSharedPointer<CCSEntry>> &entries);
void nodeSourceChanged(NodeSource nodeSource);
void XMRigDownloads(const QJsonObject &data);
void setCustomNodes(QList<FeatherNode> nodes);
void ccsEmpty();
void openAliasResolveError(const QString &msg);

View file

@ -96,6 +96,8 @@
<file>assets/images/warning.png</file>
<file>assets/images/xmrto_big.png</file>
<file>assets/images/xmrto.png</file>
<file>assets/images/xmrig.ico</file>
<file>assets/images/xmrig.svg</file>
<file>assets/images/zoom.png</file>
<file>assets/mnemonic_25_english.txt</file>
<file>assets/restore_heights_monero_mainnet.txt</file>

BIN
src/assets/images/xmrig.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 496.06 496.06"><title>XMRig</title><defs><style>.a{fill:none;}.b{clip-path:url(#a);}.c{fill:#ec671a;}.d{fill:#575756;}.e{fill:#fff;}</style><clipPath id="a" transform="translate(-106.3 -106.3)"><circle class="a" cx="354.33" cy="354.33" r="248.03"/></clipPath></defs><title>Xr_icon</title><g class="b"><rect class="c" width="496.06" height="496.06"/><polygon class="d" points="496.06 496.06 0 496.06 0 387.21 124.02 387.55 189.12 291.44 254.23 387.55 496.06 387.55 496.06 496.06"/><path class="e" d="M481.44,441.14c0-13.18,0-27,0-37.32,0-54.11,22.15-77.57,55.82-52.71-0.39.07,27.9-43.41,27.9-43.41-35.68-24.09-67.09-10.17-86.81,19.45V295.42H428.74V441.14H391.12l-61-91.46,89.91-134.87H351.85L296,298.52l-55.81-83.71H172l89.91,134.87-61,91.46H106.3v52.37l59.65,0.16-0.12.18H234l62-93,62,93H602.36V441.14H481.44Z" transform="translate(-106.3 -106.3)"/></g></svg>

After

Width:  |  Height:  |  Size: 955 B

View file

@ -12,6 +12,7 @@
#include "mainwindow.h"
#include "widgets/ccswidget.h"
#include "widgets/redditwidget.h"
#include "widgets/xmrigwidget.h"
#include "dialog/txconfdialog.h"
#include "dialog/debuginfodialog.h"
#include "dialog/walletinfodialog.h"
@ -166,6 +167,13 @@ MainWindow::MainWindow(AppContext *ctx, QWidget *parent) :
connect(m_ctx->nodes, &Nodes::nodeExhausted, this, &MainWindow::showNodeExhaustedMessage);
connect(m_ctx->nodes, &Nodes::WSNodeExhausted, this, &MainWindow::showWSNodeExhaustedMessage);
// XMRig
connect(m_ctx, &AppContext::XMRigDownloads, ui->xmrigWidget, &XMRigWidget::onDownloads);
connect(m_ctx, &AppContext::walletClosed, ui->xmrigWidget, &XMRigWidget::onStopClicked);
connect(m_ctx, &AppContext::walletClosed, ui->xmrigWidget, &XMRigWidget::onClearClicked);
connect(ui->xmrigWidget, &XMRigWidget::miningStarted, [=]{ m_ctx->setWindowTitle(true); });
connect(ui->xmrigWidget, &XMRigWidget::miningEnded, [=]{ m_ctx->setWindowTitle(false); });
// CCS/Reddit widget
m_ccsWidget = new CCSWidget(this);
m_redditWidget = new RedditWidget(this);
@ -378,6 +386,14 @@ void MainWindow::initMenu() {
#else
ui->actionShow_xmr_to->setVisible(false);
#endif
#if defined(MINING)
connect(ui->actionShow_XMRig, &QAction::triggered, m_tabShowHideSignalMapper, QOverload<>::of(&QSignalMapper::map));
m_tabShowHideMapper["XMRig"] = new ToggleTab(ui->tabXmrRig, "XMRig", "XMRig", ui->actionShow_XMRig, Config::showTabXMRig);
m_tabShowHideSignalMapper->setMapping(ui->actionShow_XMRig, "XMRig");
#else
ui->actionShow_XMRig->setVisible(false);
#endif
connect(ui->actionShow_calc, &QAction::triggered, m_tabShowHideSignalMapper, QOverload<>::of(&QSignalMapper::map));
m_tabShowHideMapper["Calc"] = new ToggleTab(ui->tabCalc, "Calc", "Calc", ui->actionShow_calc, Config::showTabCalc);
m_tabShowHideSignalMapper->setMapping(ui->actionShow_calc, "Calc");

View file

@ -280,6 +280,20 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tabXmrRig">
<attribute name="icon">
<iconset resource="assets.qrc">
<normaloff>:/assets/images/xmrig.ico</normaloff>:/assets/images/xmrig.ico</iconset>
</attribute>
<attribute name="title">
<string>XmrRig</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="XMRigWidget" name="xmrigWidget" native="true"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
@ -386,6 +400,7 @@
<addaction name="actionShow_Coins"/>
<addaction name="actionShow_xmr_to"/>
<addaction name="actionShow_calc"/>
<addaction name="actionShow_XMRig"/>
</widget>
<addaction name="menuFile"/>
<addaction name="menuWallet"/>
@ -591,6 +606,11 @@
<string>Outputs</string>
</property>
</action>
<action name="actionShow_XMRig">
<property name="text">
<string>Show XMRig</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
@ -635,6 +655,12 @@
<header>calcwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>XMRigWidget</class>
<extends>QWidget</extends>
<header>widgets/xmrigwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="assets.qrc"/>

View file

@ -34,12 +34,15 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
{Config::walletDirectory,{QS("walletDirectory"), ""}},
{Config::autoOpenWalletPath,{QS("autoOpenWalletPath"), ""}},
{Config::walletPath,{QS("walletPath"), ""}},
{Config::xmrigPath,{QS("xmrigPath"), ""}},
{Config::xmrigPool,{QS("xmrigPool"), "pool.xmr.pt:5555"}},
{Config::nodes,{QS("nodes"), "{}"}},
{Config::websocketEnabled,{QS("websocketEnabled"), true}},
{Config::nodeSource,{QS("nodeSource"), 0}},
{Config::useOnionNodes,{QS("useOnionNodes"), false}},
{Config::showTabCoins,{QS("showTabCoins"), false}},
{Config::showTabXMRto,{QS("showTabXMRto"), true}},
{Config::showTabXMRig,{QS("showTabXMRig"), false}},
{Config::showTabCalc,{QS("showTabCalc"), true}},
{Config::geometry, {QS("geometry"), {}}},
{Config::windowState, {QS("windowState"), {}}},

View file

@ -32,6 +32,8 @@ public:
blockExplorer,
walletDirectory,
walletPath,
xmrigPath,
xmrigPool,
nodes,
websocketEnabled,
nodeSource,
@ -39,6 +41,7 @@ public:
showTabCoins,
showTabXMRto,
showTabCalc,
showTabXMRig,
geometry,
windowState,
firstRun

98
src/utils/xmrig.cpp Normal file
View file

@ -0,0 +1,98 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2020, The Monero Project.
#include <QtCore>
#include <QScreen>
#include <QDesktopWidget>
#include <QProcess>
#include <QDesktopServices>
#include "utils/utils.h"
#include "utils/xmrig.h"
#include "appcontext.h"
XMRig::XMRig(QObject *parent) : QObject(parent)
{
qDebug() << "Using embedded tor instance";
m_process.setProcessChannelMode(QProcess::MergedChannels);
connect(&m_process, &QProcess::readyReadStandardOutput, this, &XMRig::handleProcessOutput);
connect(&m_process, &QProcess::errorOccurred, this, &XMRig::handleProcessError);
connect(&m_process, &QProcess::stateChanged, this, &XMRig::stateChanged);
}
void XMRig::stop() {
if(m_process.state() == QProcess::Running)
m_process.kill();
}
void XMRig::terminate() {
if(m_process.state() == QProcess::Running)
m_process.terminate();
}
void XMRig::start(unsigned int threads, const QString &pool_name, const QString &receiving_address, bool tor) {
auto state = m_process.state();
if (state == QProcess::ProcessState::Running || state == QProcess::ProcessState::Starting) {
emit error("Can't start XMRig, already running or starting");
return;
}
auto path = config()->get(Config::xmrigPath).toString();
if(path.isEmpty()) {
emit error("Please set path to XMRig binary before starting.");
return;
}
if(!Utils::fileExists(path)) {
emit error("Path to XMRig binary invalid; file does not exist.");
return;
}
QStringList arguments;
arguments << "-o" << pool_name;
arguments << "-a" << "rx/0";
arguments << "-u" << receiving_address;
arguments << "-p" << "featherwallet";
arguments << "--no-color";
arguments << "-t" << QString::number(threads);
if(tor)
arguments << "-x" << QString("%1:%2").arg(Tor::torHost).arg(Tor::torPort);
QString cmd = QString("%1 %2").arg(path, arguments.join(" "));
emit output(cmd.toUtf8());
m_process.start(path, arguments);
}
void XMRig::stateChanged(QProcess::ProcessState state) {
if(state == QProcess::ProcessState::Running)
emit output("XMRig started");
else if (state == QProcess::ProcessState::NotRunning)
emit output("XMRig stopped");
}
void XMRig::handleProcessOutput() {
QByteArray _output = m_process.readAllStandardOutput();
if(_output.contains("miner") && _output.contains("speed")) {
// detect hashrate
auto str = Utils::barrayToString(_output);
auto spl = str.mid(str.indexOf("speed")).split(" ");
auto rate = spl.at(2) + "H/s";
qDebug() << "mining hashrate: " << rate;
emit hashrate(rate);
}
emit output(_output);
}
void XMRig::handleProcessError(QProcess::ProcessError err) {
if (err == QProcess::ProcessError::Crashed)
emit error("XMRig crashed or killed");
else if (err == QProcess::ProcessError::FailedToStart) {
auto path = config()->get(Config::xmrigPath).toString();
emit error(QString("XMRig binary failed to start: %1").arg(path));
}
}

43
src/utils/xmrig.h Normal file
View file

@ -0,0 +1,43 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2020, The Monero Project.
#ifndef FEATHER_XMRIG_H
#define FEATHER_XMRIG_H
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <QtCore>
#include <QRegExp>
#include <QtNetwork>
#include <QApplication>
#include <QMainWindow>
#include "utils/childproc.h"
class XMRig : public QObject
{
Q_OBJECT
public:
explicit XMRig(QObject *parent = nullptr);
void start(unsigned int threads, const QString &pool_name, const QString &receiving_address, bool tor = false);
void stop();
void terminate();
signals:
void error(const QString &msg);
void output(const QByteArray &data);
void hashrate(const QString &rate);
private slots:
void stateChanged(QProcess::ProcessState);
void handleProcessOutput();
void handleProcessError(QProcess::ProcessError error);
private:
ChildProcess m_process;
};
#endif //FEATHER_XMRIG_H

226
src/widgets/xmrigwidget.cpp Normal file
View file

@ -0,0 +1,226 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2020, The Monero Project.
#include <QStandardItemModel>
#include <QTableWidget>
#include <QProgressBar>
#include <QMessageBox>
#include <QDesktopServices>
#include <QSysInfo>
#include <QScrollBar>
#include <QFileDialog>
#include <QStandardPaths>
#include "xmrigwidget.h"
#include "ui_xmrigwidget.h"
#include "utils/utils.h"
XMRigWidget::XMRigWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::XMRigWidget),
m_model(new QStandardItemModel(this)),
m_contextMenu(new QMenu(this))
{
ui->setupUi(this);
QPixmap p(":assets/images/xmrig.svg");
ui->lbl_logo->setPixmap(p.scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation));
// table
ui->tableView->setModel(this->m_model);
m_contextMenu->addAction(QIcon(":/assets/images/network.png"), "Download file", this, &XMRigWidget::linkClicked);
connect(ui->tableView, &QHeaderView::customContextMenuRequested, this, &XMRigWidget::showContextMenu);
connect(ui->tableView, &QTableView::doubleClicked, this, &XMRigWidget::linkClicked);
// XMRig core
m_rig = new XMRig(this);
connect(m_rig, &XMRig::output, this, &XMRigWidget::onProcessOutput);
connect(m_rig, &XMRig::error, this, &XMRigWidget::onProcessError);
connect(m_rig, &XMRig::hashrate, this, &XMRigWidget::onHashrate);
// threads
ui->threadSlider->setMinimum(1);
int threads = QThread::idealThreadCount();
m_threads = (unsigned int) threads / 2;
ui->threadSlider->setMaximum(threads);
ui->threadSlider->setValue(m_threads);
ui->label_threads->setText(QString("CPU threads: %1").arg(m_threads));
connect(ui->threadSlider, &QSlider::valueChanged, this, &XMRigWidget::onThreadsValueChanged);
// buttons
connect(ui->btn_start, &QPushButton::clicked, this, &XMRigWidget::onStartClicked);
connect(ui->btn_stop, &QPushButton::clicked, this, &XMRigWidget::onStopClicked);
connect(ui->btn_browse, &QPushButton::clicked, this, &XMRigWidget::onBrowseClicked);
connect(ui->btn_clear, &QPushButton::clicked, this, &XMRigWidget::onClearClicked);
// defaults
ui->btn_stop->setEnabled(false);
ui->check_autoscroll->setChecked(true);
ui->relayTor->setChecked(true);
ui->label_status->setTextInteractionFlags(Qt::TextSelectableByMouse);
// XMRig binary
auto path = config()->get(Config::xmrigPath).toString();
ui->lineEdit_path->setText(path);
ui->label_status->hide();
if(path.isEmpty())
ui->tabWidget->setCurrentIndex(1);
// pools
ui->combo_pools->insertItems(0, m_pools);
auto preferredPool = config()->get(Config::xmrigPool).toString();
if (m_pools.contains(preferredPool))
ui->combo_pools->setCurrentIndex(m_pools.indexOf(preferredPool));
connect(ui->combo_pools, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &XMRigWidget::onPoolChanged);
// info
ui->console->appendPlainText(QString("Detected %1 CPU threads.").arg(threads));
if(!path.isEmpty() && !Utils::fileExists(path))
ui->console->appendPlainText("Invalid path to XMRig binary detected. Please reconfigure on the Settings tab.");
else
ui->console->appendPlainText(QString("XMRig path set to %1").arg(path));
ui->console->appendPlainText("Ready to mine.");
}
void XMRigWidget::onThreadsValueChanged(int threads) {
m_threads = (unsigned int) threads;
ui->label_threads->setText(QString("CPU threads: %1").arg(m_threads));
}
void XMRigWidget::onPoolChanged(int pos) {
config()->set(Config::xmrigPool, m_pools.at(pos));
}
void XMRigWidget::onBrowseClicked() {
QString fileName = QFileDialog::getOpenFileName(
this, "Path to XMRig executable", QDir::homePath());
if (fileName.isEmpty()) return;
config()->set(Config::xmrigPath, fileName);
ui->lineEdit_path->setText(fileName);
}
void XMRigWidget::onClearClicked() {
ui->console->clear();
}
void XMRigWidget::onStartClicked() {
auto pool_name = config()->get(Config::xmrigPool).toString();
auto addy = ui->lineEdit_address->text();
if(addy.isEmpty()) {
Utils::showMessageBox("Error", "Please specify a receiving address on the Settings screen", true);
return;
}
m_rig->start(m_threads, pool_name, addy, ui->relayTor->isChecked());
ui->btn_start->setEnabled(false);
ui->btn_stop->setEnabled(true);
emit miningStarted();
}
void XMRigWidget::onStopClicked() {
m_rig->terminate();
ui->btn_start->setEnabled(true);
ui->btn_stop->setEnabled(false);
ui->label_status->hide();
emit miningEnded();
}
void XMRigWidget::onProcessOutput(const QByteArray &data) {
auto output = Utils::barrayToString(data);
if(output.endsWith("\n"))
output = output.trimmed();
ui->console->appendPlainText(output);
if(ui->check_autoscroll->isChecked())
ui->console->verticalScrollBar()->setValue(ui->console->verticalScrollBar()->maximum());
}
void XMRigWidget::onProcessError(const QString &msg) {
ui->console->appendPlainText("\n" + msg);
ui->btn_start->setEnabled(true);
ui->btn_stop->setEnabled(false);
ui->label_status->hide();
emit miningEnded();
}
void XMRigWidget::onHashrate(const QString &hashrate) {
ui->label_status->show();
ui->label_status->setText(QString("Mining at %1").arg(hashrate));
}
void XMRigWidget::onDownloads(const QJsonObject &data) {
// For the downloads table we'll manually update the table
// with items once, as opposed to creating a class in
// src/models/. Saves effort; full-blown model
// is unnecessary in this case.
m_model->clear();
m_urls.clear();
auto version = data.value("version").toString();
ui->label_latest_version->setText(QString("Latest version: %1").arg(version));
QJsonObject assets = data.value("assets").toObject();
const auto _linux = assets.value("linux").toArray();
const auto macos = assets.value("macos").toArray();
const auto windows = assets.value("windows").toArray();
auto info = QSysInfo::productType();
QJsonArray *os_assets;
if(info == "osx") {
os_assets = const_cast<QJsonArray *>(&macos);
} else if (info == "windows") {
os_assets = const_cast<QJsonArray *>(&windows);
} else {
// assume linux
os_assets = const_cast<QJsonArray *>(&_linux);
}
unsigned int i = 0;
for(const auto &entry: *os_assets) {
auto _obj = entry.toObject();
auto _name = _obj.value("name").toString();
auto _url = _obj.value("url").toString();
auto _created_at = _obj.value("created_at").toString();
m_urls.append(_url);
auto download_count = _obj.value("download_count").toInt();
m_model->setItem(i, 0, Utils::qStandardItem(_name));
m_model->setItem(i, 1, Utils::qStandardItem(_created_at));
m_model->setItem(i, 2, Utils::qStandardItem(QString::number(download_count)));
i++;
}
m_model->setHeaderData(0, Qt::Horizontal, tr("Filename"), Qt::DisplayRole);
m_model->setHeaderData(1, Qt::Horizontal, tr("Date"), Qt::DisplayRole);
m_model->setHeaderData(2, Qt::Horizontal, tr("Downloads"), Qt::DisplayRole);
ui->tableView->verticalHeader()->setVisible(false);
ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
ui->tableView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
ui->tableView->setColumnWidth(2, 100);
}
void XMRigWidget::showContextMenu(const QPoint &pos) {
QModelIndex index = ui->tableView->indexAt(pos);
if (!index.isValid()) {
return;
}
m_contextMenu->exec(ui->tableView->viewport()->mapToGlobal(pos));
}
void XMRigWidget::linkClicked() {
QModelIndex index = ui->tableView->currentIndex();
auto download_link = m_urls.at(index.row());
Utils::externalLinkWarning(download_link);
}
QStandardItemModel *XMRigWidget::model() {
return m_model;
}
XMRigWidget::~XMRigWidget() {
delete ui;
}

58
src/widgets/xmrigwidget.h Normal file
View file

@ -0,0 +1,58 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2020, The Monero Project.
#ifndef XMRIGWIDGET_H
#define XMRIGWIDGET_H
#include <QMenu>
#include <QWidget>
#include <QItemSelection>
#include "utils/xmrig.h"
#include "utils/config.h"
namespace Ui {
class XMRigWidget;
}
class XMRigWidget : public QWidget
{
Q_OBJECT
public:
explicit XMRigWidget(QWidget *parent = nullptr);
~XMRigWidget();
QStandardItemModel *model();
public slots:
void onStartClicked();
void onStopClicked();
void onClearClicked();
void onDownloads(const QJsonObject &data);
void linkClicked();
private slots:
void onBrowseClicked();
void onProcessError(const QString &msg);
void onProcessOutput(const QByteArray &msg);
void onThreadsValueChanged(int date);
void onPoolChanged(int pos);
void onHashrate(const QString &hashrate);
signals:
void miningStarted();
void miningEnded();
private:
void showContextMenu(const QPoint &pos);
Ui::XMRigWidget *ui;
QStandardItemModel *m_model;
QMenu *m_contextMenu;
unsigned int m_threads;
QStringList m_urls;
QStringList m_pools{"pool.xmr.pt:5555", "pool.supportxmr.com:3333", "mine.xmrpool.net:3333", "xmrpool.eu:5555", "xmr-eu1.nanopool.org:14444", "pool.minexmr.com:4444", "monerohash.com:2222"};
XMRig *m_rig;
};
#endif // REDDITWIDGET_H

387
src/widgets/xmrigwidget.ui Normal file
View file

@ -0,0 +1,387 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>XMRigWidget</class>
<widget class="QWidget" name="XMRigWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>556</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Mining</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QFrame" name="outputFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPlainTextEdit" name="console">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="btn_clear">
<property name="text">
<string>Clear</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="check_autoscroll">
<property name="text">
<string>auto-scroll</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_status">
<property name="text">
<string>Mining at</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_stop">
<property name="text">
<string>Stop</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_start">
<property name="text">
<string>Start mining</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Settings</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Path to XMRig executable</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLineEdit" name="lineEdit_path"/>
</item>
<item>
<widget class="QPushButton" name="btn_browse">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Receiving address</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_address"/>
</item>
<item>
<widget class="QLabel" name="label_threads">
<property name="text">
<string>Threads: </string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QSlider" name="threadSlider">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Pool</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QComboBox" name="combo_pools">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="relayTor">
<property name="text">
<string>Relay over Tor</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Maximum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>24</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QLabel" name="lbl_logo">
<property name="text">
<string>logoimg</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>2000</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Downloads</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_latest_version">
<property name="text">
<string>Latest version:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_version">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>(right-click to download)</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QTableView" name="tableView">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="sortingEnabled">
<bool>false</bool>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>false</bool>
</attribute>
</widget>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Powered by Github API v3</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
<slots>
<slot>linkClicked()</slot>
</slots>
</ui>