Rework Mining UI

This commit is contained in:
tobtoht 2021-10-12 14:45:06 +02:00
parent 0eb4592f87
commit 3fec15e4aa
No known key found for this signature in database
GPG key ID: 1CADD27F41F45C3C
7 changed files with 503 additions and 398 deletions

View file

@ -49,8 +49,13 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
{Config::showSearchbar,{QS("showSearchbar"), true}}, {Config::showSearchbar,{QS("showSearchbar"), true}},
// Mining // Mining
{Config::miningMode,{QS("miningMode"), Config::MiningMode::Pool}},
{Config::xmrigPath,{QS("xmrigPath"), ""}}, {Config::xmrigPath,{QS("xmrigPath"), ""}},
{Config::xmrigElevated,{QS("xmrigElevated"), false}},
{Config::xmrigThreads,{QS("xmrigThreads"), 1}},
{Config::xmrigPool,{QS("xmrigPool"), "pool.xmr.pt:9000"}}, {Config::xmrigPool,{QS("xmrigPool"), "pool.xmr.pt:9000"}},
{Config::xmrigNetworkTLS,{QS("xmrigNetworkTLS"), true}},
{Config::xmrigNetworkTor,{QS("xmrigNetworkTor"), false}},
{Config::pools,{QS("pools"), {}}}, {Config::pools,{QS("pools"), {}}},
// Settings // Settings

View file

@ -53,8 +53,13 @@ public:
showSearchbar, showSearchbar,
// Mining // Mining
miningMode,
xmrigPath, xmrigPath,
xmrigElevated,
xmrigThreads,
xmrigPool, xmrigPool,
xmrigNetworkTLS,
xmrigNetworkTor,
pools, pools,
// Settings // Settings
@ -98,6 +103,11 @@ public:
spendable spendable
}; };
enum MiningMode {
Pool = 0,
Solo
};
~Config() override; ~Config() override;
QVariant get(ConfigKey key); QVariant get(ConfigKey key);
QString getFileName(); QString getFileName();

View file

@ -13,49 +13,58 @@
XmRig::XmRig(const QString &configDir, QObject *parent) XmRig::XmRig(const QString &configDir, QObject *parent)
: QObject(parent) : QObject(parent)
{ {
this->rigDir = QDir(configDir).filePath("xmrig");
m_process.setProcessChannelMode(QProcess::MergedChannels); m_process.setProcessChannelMode(QProcess::MergedChannels);
connect(&m_process, &QProcess::readyReadStandardOutput, this, &XmRig::handleProcessOutput); connect(&m_process, &QProcess::readyReadStandardOutput, this, &XmRig::handleProcessOutput);
connect(&m_process, &QProcess::errorOccurred, this, &XmRig::handleProcessError); connect(&m_process, &QProcess::errorOccurred, this, &XmRig::handleProcessError);
connect(&m_process, &QProcess::stateChanged, this, &XmRig::stateChanged); connect(&m_process, &QProcess::stateChanged, this, &XmRig::onStateChanged);
} }
void XmRig::stop() { void XmRig::stop() {
if(m_process.state() == QProcess::Running) { qDebug() << m_process.processId();
if (m_process.state() == QProcess::Running) {
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
m_process.kill(); // https://doc.qt.io/qt-5/qprocess.html#terminate m_process.kill(); // https://doc.qt.io/qt-5/qprocess.html#terminate
#else #elif defined(Q_OS_LINUX)
m_process.terminate(); if (m_elevated) {
m_killProcess.start("pkexec", QStringList() << "kill" << QString::number(m_process.processId()));
return;
}
#endif #endif
m_process.terminate();
} }
} }
void XmRig::start(const QString &path, int threads, const QString &address, const QString &username, void XmRig::start(const QString &path, int threads, const QString &address, const QString &username,
const QString &password, bool tor, bool tls) const QString &password, bool tor, bool tls, bool elevated)
{ {
m_elevated = elevated;
auto state = m_process.state(); auto state = m_process.state();
if (state == QProcess::ProcessState::Running || state == QProcess::ProcessState::Starting) { if (state == QProcess::ProcessState::Running || state == QProcess::ProcessState::Starting) {
emit error("Can't start XMRig, already running or starting"); emit error("Can't start XMRig, already running or starting");
return; return;
} }
if(path.isEmpty()) { if (path.isEmpty()) {
emit error("XmRig->Start path parameter missing."); emit error("XmRig->Start path parameter missing.");
return; return;
} }
if(!Utils::fileExists(path)) { if (!Utils::fileExists(path)) {
emit error(QString("Path to XMRig binary invalid; file does not exist: %1").arg(path)); emit error(QString("Path to XMRig binary invalid; file does not exist: %1").arg(path));
return; return;
} }
QStringList arguments; QStringList arguments;
if (m_elevated) {
arguments << path;
}
arguments << "-o" << address; arguments << "-o" << address;
arguments << "-a" << "rx/0"; arguments << "-a" << "rx/0";
arguments << "-u" << username; arguments << "-u" << username;
if(!password.isEmpty()) if (!password.isEmpty()) {
arguments << "-p" << password; arguments << "-p" << password;
}
arguments << "--no-color"; arguments << "--no-color";
arguments << "-t" << QString::number(threads); arguments << "-t" << QString::number(threads);
if (tor) { if (tor) {
@ -67,20 +76,30 @@ void XmRig::start(const QString &path, int threads, const QString &address, cons
} }
arguments << "-x" << QString("%1:%2").arg(host, port); arguments << "-x" << QString("%1:%2").arg(host, port);
} }
if (tls) {
if(tls)
arguments << "--tls"; arguments << "--tls";
}
arguments << "--donate-level" << "1"; arguments << "--donate-level" << "1";
QString cmd = QString("%1 %2").arg(path, arguments.join(" ")); QString cmd = QString("%1 %2").arg(path, arguments.join(" "));
emit output(cmd.toUtf8()); emit output(cmd.toUtf8());
m_process.start(path, arguments);
if (m_elevated) {
m_process.start("pkexec", arguments);
} else {
m_process.start(path, arguments);
}
} }
void XmRig::stateChanged(QProcess::ProcessState state) { void XmRig::onStateChanged(QProcess::ProcessState state) {
if(state == QProcess::ProcessState::Running) emit stateChanged(state);
if (state == QProcess::ProcessState::Running) {
emit output("XMRig started"); emit output("XMRig started");
else if (state == QProcess::ProcessState::NotRunning) }
else if (state == QProcess::ProcessState::NotRunning) {
emit output("XMRig stopped"); emit output("XMRig stopped");
}
} }
void XmRig::handleProcessOutput() { void XmRig::handleProcessOutput() {

View file

@ -21,24 +21,24 @@ Q_OBJECT
public: public:
explicit XmRig(const QString &configDir, QObject *parent = nullptr); explicit XmRig(const QString &configDir, QObject *parent = nullptr);
void start(const QString &path, int threads, const QString &address, const QString &username, const QString &password, bool tor = false, bool tls = true); void start(const QString &path, int threads, const QString &address, const QString &username, const QString &password, bool tor = false, bool tls = true, bool elevated = false);
void stop(); void stop();
QString rigDir;
QString rigPath;
signals: signals:
void error(const QString &msg); void error(const QString &msg);
void output(const QByteArray &data); void output(const QByteArray &data);
void hashrate(const QString &rate); void hashrate(const QString &rate);
void stateChanged(QProcess::ProcessState state);
private slots: private slots:
void stateChanged(QProcess::ProcessState); void onStateChanged(QProcess::ProcessState);
void handleProcessOutput(); void handleProcessOutput();
void handleProcessError(QProcess::ProcessError error); void handleProcessError(QProcess::ProcessError error);
private: private:
ChildProcess m_process; ChildProcess m_process;
QProcess m_killProcess;
bool m_elevated;
}; };
#endif //FEATHER_XMRIG_H #endif //FEATHER_XMRIG_H

View file

@ -24,52 +24,54 @@ XMRigWidget::XMRigWidget(QSharedPointer<AppContext> ctx, QWidget *parent)
{ {
ui->setupUi(this); ui->setupUi(this);
QPixmap p(":assets/images/xmrig.svg"); connect(m_XMRig, &XmRig::stateChanged, this, &XMRigWidget::onXMRigStateChanged);
ui->lbl_logo->setPixmap(p.scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation));
connect(m_XMRig, &XmRig::output, this, &XMRigWidget::onProcessOutput); connect(m_XMRig, &XmRig::output, this, &XMRigWidget::onProcessOutput);
connect(m_XMRig, &XmRig::error, this, &XMRigWidget::onProcessError); connect(m_XMRig, &XmRig::error, this, &XMRigWidget::onProcessError);
connect(m_XMRig, &XmRig::hashrate, this, &XMRigWidget::onHashrate); connect(m_XMRig, &XmRig::hashrate, this, &XMRigWidget::onHashrate);
// table // [Downloads] tab
ui->tableView->setModel(this->m_model); ui->tableView->setModel(m_model);
m_contextMenu->addAction(icons()->icon("network.png"), "Download file", this, &XMRigWidget::linkClicked); m_contextMenu->addAction(icons()->icon("network.png"), "Download file", this, &XMRigWidget::linkClicked);
connect(ui->tableView, &QHeaderView::customContextMenuRequested, this, &XMRigWidget::showContextMenu); connect(ui->tableView, &QHeaderView::customContextMenuRequested, this, &XMRigWidget::showContextMenu);
connect(ui->tableView, &QTableView::doubleClicked, this, &XMRigWidget::linkClicked); connect(ui->tableView, &QTableView::doubleClicked, this, &XMRigWidget::linkClicked);
// threads // [Settings] tab
ui->poolFrame->show();
ui->soloFrame->hide();
// XMRig executable
connect(ui->btn_browse, &QPushButton::clicked, this, &XMRigWidget::onBrowseClicked);
ui->lineEdit_path->setText(config()->get(Config::xmrigPath).toString());
// Run as admin/root
bool elevated = config()->get(Config::xmrigElevated).toBool();
if (elevated) {
ui->radio_elevateYes->setChecked(true);
} else {
ui->radio_elevateNo->setChecked(true);
}
connect(ui->radio_elevateYes, &QRadioButton::toggled, this, &XMRigWidget::onXMRigElevationChanged);
#if defined(Q_OS_WIN)
ui->radio_elevateYes->setToolTip("Not supported on Windows, yet.");
ui->radio_elevateYes->setEnabled(false);
ui->radio_elevateNo->setChecked(true);
#endif
// CPU threads
ui->threadSlider->setMinimum(1); ui->threadSlider->setMinimum(1);
int threads = QThread::idealThreadCount(); ui->threadSlider->setMaximum(QThread::idealThreadCount());
m_threads = threads / 2;
ui->threadSlider->setMaximum(threads); int threads = config()->get(Config::xmrigThreads).toInt();
ui->threadSlider->setValue(m_threads); ui->threadSlider->setValue(threads);
ui->label_threads->setText(QString("CPU threads: %1").arg(m_threads)); ui->label_threads->setText(QString("CPU threads: %1").arg(threads));
connect(ui->threadSlider, &QSlider::valueChanged, this, &XMRigWidget::onThreadsValueChanged); connect(ui->threadSlider, &QSlider::valueChanged, this, &XMRigWidget::onThreadsValueChanged);
// buttons // Mining mode
connect(ui->btn_start, &QPushButton::clicked, this, &XMRigWidget::onStartClicked); connect(ui->combo_miningMode, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &XMRigWidget::onMiningModeChanged);
connect(ui->btn_stop, &QPushButton::clicked, this, &XMRigWidget::onStopClicked); ui->combo_miningMode->setCurrentIndex(config()->get(Config::miningMode).toInt());
connect(ui->btn_browse, &QPushButton::clicked, this, &XMRigWidget::onBrowseClicked);
connect(ui->btn_clear, &QPushButton::clicked, this, &XMRigWidget::onClearClicked);
// defaults // Pool/node address
ui->btn_stop->setEnabled(false);
ui->check_autoscroll->setChecked(true);
ui->relayTor->setChecked(false);
ui->check_tls->setChecked(true);
ui->label_status->setTextInteractionFlags(Qt::TextSelectableByMouse);
ui->label_status->hide();
ui->soloFrame->hide();
ui->poolFrame->hide();
// XMRig binary
auto path = config()->get(Config::xmrigPath).toString();
if(!path.isEmpty()) {
ui->lineEdit_path->setText(path);
}
// pools
ui->poolFrame->show();
this->updatePools(); this->updatePools();
connect(ui->combo_pools, &QComboBox::currentTextChanged, this, &XMRigWidget::onPoolChanged); connect(ui->combo_pools, &QComboBox::currentTextChanged, this, &XMRigWidget::onPoolChanged);
@ -87,41 +89,45 @@ XMRigWidget::XMRigWidget(QSharedPointer<AppContext> ctx, QWidget *parent)
this->updatePools(); this->updatePools();
}); });
// info // Network settings
ui->console->appendPlainText(QString("Detected %1 CPU threads.").arg(threads)); connect(ui->check_tls, &QCheckBox::toggled, this, &XMRigWidget::onNetworkTLSToggled);
if(!path.isEmpty() && !Utils::fileExists(path)) connect(ui->relayTor, &QCheckBox::toggled, this, &XMRigWidget::onNetworkTorToggled);
ui->console->appendPlainText("Invalid path to XMRig binary detected. Please reconfigure on the Settings tab."); ui->check_tls->setChecked(config()->get(Config::xmrigNetworkTLS).toBool());
else ui->relayTor->setChecked(config()->get(Config::xmrigNetworkTor).toBool());
ui->console->appendPlainText(QString("XMRig path set to %1").arg(path));
ui->console->appendPlainText("Ready to mine."); // Receiving address
// username/password
connect(ui->lineEdit_password, &QLineEdit::editingFinished, [=]() {
m_ctx->wallet->setCacheAttribute("feather.xmrig_password", ui->lineEdit_password->text());
m_ctx->storeWallet();
});
connect(ui->lineEdit_address, &QLineEdit::editingFinished, [=]() {
m_ctx->wallet->setCacheAttribute("feather.xmrig_username", ui->lineEdit_address->text());
m_ctx->storeWallet();
});
// checkbox connects
connect(ui->check_solo, &QCheckBox::stateChanged, this, &XMRigWidget::onSoloChecked);
// Xmrig username
auto username = m_ctx->wallet->getCacheAttribute("feather.xmrig_username"); auto username = m_ctx->wallet->getCacheAttribute("feather.xmrig_username");
if(!username.isEmpty()) if (!username.isEmpty()) {
ui->lineEdit_address->setText(username); ui->lineEdit_address->setText(username);
}
connect(ui->lineEdit_address, &QLineEdit::textChanged, [=]() {
m_ctx->wallet->setCacheAttribute("feather.xmrig_username", ui->lineEdit_address->text());
});
connect(ui->btn_fillPrimaryAddress, &QPushButton::clicked, this, &XMRigWidget::onUsePrimaryAddressClicked);
// Xmrig passwd // Password
auto password = m_ctx->wallet->getCacheAttribute("feather.xmrig_password"); auto password = m_ctx->wallet->getCacheAttribute("feather.xmrig_password");
if(!password.isEmpty()) { if (!password.isEmpty()) {
ui->lineEdit_password->setText(password); ui->lineEdit_password->setText(password);
} else { } else {
ui->lineEdit_password->setText("featherwallet"); ui->lineEdit_password->setText("featherwallet");
m_ctx->wallet->setCacheAttribute("feather.xmrig_password", ui->lineEdit_password->text()); m_ctx->wallet->setCacheAttribute("feather.xmrig_password", ui->lineEdit_password->text());
} }
connect(ui->lineEdit_password, &QLineEdit::textChanged, [=]() {
m_ctx->wallet->setCacheAttribute("feather.xmrig_password", ui->lineEdit_password->text());
});
// [Status] tab
connect(ui->btn_start, &QPushButton::clicked, this, &XMRigWidget::onStartClicked);
connect(ui->btn_stop, &QPushButton::clicked, this, &XMRigWidget::onStopClicked);
connect(ui->btn_clear, &QPushButton::clicked, this, &XMRigWidget::onClearClicked);
ui->btn_stop->setEnabled(false);
ui->check_autoscroll->setChecked(true);
ui->label_status->setTextInteractionFlags(Qt::TextSelectableByMouse);
ui->label_status->hide();
this->printConsoleInfo();
} }
bool XMRigWidget::isMining() { bool XMRigWidget::isMining() {
@ -130,14 +136,11 @@ bool XMRigWidget::isMining() {
void XMRigWidget::onWalletClosed() { void XMRigWidget::onWalletClosed() {
this->onStopClicked(); this->onStopClicked();
this->onClearClicked();
ui->lineEdit_password->setText("");
ui->lineEdit_address->setText("");
} }
void XMRigWidget::onThreadsValueChanged(int threads) { void XMRigWidget::onThreadsValueChanged(int threads) {
m_threads = threads; config()->set(Config::xmrigThreads, threads);
ui->label_threads->setText(QString("CPU threads: %1").arg(m_threads)); ui->label_threads->setText(QString("CPU threads: %1").arg(threads));
} }
void XMRigWidget::onPoolChanged(const QString &pool) { void XMRigWidget::onPoolChanged(const QString &pool) {
@ -146,10 +149,15 @@ void XMRigWidget::onPoolChanged(const QString &pool) {
} }
} }
void XMRigWidget::onXMRigElevationChanged(bool elevated) {
config()->set(Config::xmrigElevated, elevated);
}
void XMRigWidget::onBrowseClicked() { void XMRigWidget::onBrowseClicked() {
QString fileName = QFileDialog::getOpenFileName( QString fileName = QFileDialog::getOpenFileName(this, "Path to XMRig executable", QDir::homePath());
this, "Path to XMRig executable", QDir::homePath()); if (fileName.isEmpty()) {
if (fileName.isEmpty()) return; return;
}
config()->set(Config::xmrigPath, fileName); config()->set(Config::xmrigPath, fileName);
ui->lineEdit_path->setText(fileName); ui->lineEdit_path->setText(fileName);
} }
@ -158,47 +166,50 @@ void XMRigWidget::onClearClicked() {
ui->console->clear(); ui->console->clear();
} }
void XMRigWidget::onUsePrimaryAddressClicked() {
ui->lineEdit_address->setText(m_ctx->wallet->address(0, 0));
}
void XMRigWidget::onStartClicked() { void XMRigWidget::onStartClicked() {
QString xmrigPath; QString xmrigPath = config()->get(Config::xmrigPath).toString();
bool solo = ui->check_solo->isChecked(); if (!this->checkXMRigPath()) {
xmrigPath = config()->get(Config::xmrigPath).toString(); return;
}
QString address = [this](){
if (ui->combo_miningMode->currentIndex() == Config::MiningMode::Pool) {
return config()->get(Config::xmrigPool).toString();
} else {
return ui->lineEdit_solo->text().trimmed();
}
}();
if (address.isEmpty()) {
ui->console->appendPlainText("No pool or node address set. Please configure on the Settings tab.");
return;
}
// username is receiving address usually // username is receiving address usually
auto username = m_ctx->wallet->getCacheAttribute("feather.xmrig_username"); auto username = m_ctx->wallet->getCacheAttribute("feather.xmrig_username");
auto password = m_ctx->wallet->getCacheAttribute("feather.xmrig_password"); auto password = m_ctx->wallet->getCacheAttribute("feather.xmrig_password");
if(username.isEmpty()) { if (username.isEmpty()) {
QString err = "Please specify a receiving address on the Settings screen"; ui->console->appendPlainText("Please specify a receiving address on the Settings screen.");
ui->console->appendPlainText(err);
QMessageBox::warning(this, "Error", err);
return; return;
} }
QString address; if (address.contains("cryptonote.social") && !username.contains(".")) {
if(solo)
address = ui->lineEdit_solo->text().trimmed();
else
address = config()->get(Config::xmrigPool).toString();
if(address.contains("cryptonote.social") && !username.contains(".")) {
// cryptonote social requires <addr>.<username>, we'll just grab a few chars from primary addy // cryptonote social requires <addr>.<username>, we'll just grab a few chars from primary addy
username = QString("%1.%2").arg(username, m_ctx->wallet->address(0, 0).mid(0, 6)); username = QString("%1.%2").arg(username, m_ctx->wallet->address(0, 0).mid(0, 6));
} }
m_XMRig->start(xmrigPath, m_threads, address, username, password, ui->relayTor->isChecked(), ui->check_tls->isChecked()); int threads = ui->threadSlider->value();
ui->btn_start->setEnabled(false);
ui->btn_stop->setEnabled(true); m_XMRig->start(xmrigPath, threads, address, username, password, ui->relayTor->isChecked(), ui->check_tls->isChecked(),
m_isMining = true; ui->radio_elevateYes->isChecked());
emit miningStarted();
} }
void XMRigWidget::onStopClicked() { void XMRigWidget::onStopClicked() {
m_XMRig->stop(); m_XMRig->stop();
ui->btn_start->setEnabled(true);
ui->btn_stop->setEnabled(false);
ui->label_status->hide();
m_isMining = false;
emit miningEnded();
} }
void XMRigWidget::onProcessOutput(const QByteArray &data) { void XMRigWidget::onProcessOutput(const QByteArray &data) {
@ -216,9 +227,7 @@ void XMRigWidget::onProcessError(const QString &msg) {
ui->console->appendPlainText("\n" + msg); ui->console->appendPlainText("\n" + msg);
ui->btn_start->setEnabled(true); ui->btn_start->setEnabled(true);
ui->btn_stop->setEnabled(false); ui->btn_stop->setEnabled(false);
ui->label_status->hide(); this->setMiningStopped();
m_isMining = false;
emit miningEnded();
} }
void XMRigWidget::onHashrate(const QString &hashrate) { void XMRigWidget::onHashrate(const QString &hashrate) {
@ -307,15 +316,78 @@ void XMRigWidget::updatePools() {
} }
} }
void XMRigWidget::onSoloChecked(int state) { void XMRigWidget::printConsoleInfo() {
if(state == 2) { ui->console->appendPlainText(QString("Detected %1 CPU threads.").arg(QThread::idealThreadCount()));
ui->poolFrame->hide(); if (this->checkXMRigPath()) {
ui->soloFrame->show(); QString path = config()->get(Config::xmrigPath).toString();
ui->check_tls->setChecked(false); ui->console->appendPlainText(QString("XMRig path set to %1").arg(path));
} }
else { }
void XMRigWidget::onMiningModeChanged(int mode) {
config()->set(Config::miningMode, mode);
if (mode == Config::MiningMode::Pool) {
ui->poolFrame->show(); ui->poolFrame->show();
ui->soloFrame->hide(); ui->soloFrame->hide();
ui->label_poolNodeAddress->setText("Pool address:");
ui->check_tls->setChecked(true);
} else { // Solo mining
ui->poolFrame->hide();
ui->soloFrame->show();
ui->label_poolNodeAddress->setText("Node address:");
ui->check_tls->setChecked(false);
}
}
void XMRigWidget::onNetworkTLSToggled(bool checked) {
config()->set(Config::xmrigNetworkTLS, checked);
}
void XMRigWidget::onNetworkTorToggled(bool checked) {
config()->set(Config::xmrigNetworkTor, checked);
}
void XMRigWidget::onXMRigStateChanged(QProcess::ProcessState state) {
if (state == QProcess::ProcessState::Starting) {
ui->btn_start->setEnabled(false);
ui->btn_stop->setEnabled(false);
this->setMiningStarted();
}
else if (state == QProcess::ProcessState::Running) {
ui->btn_start->setEnabled(false);
ui->btn_stop->setEnabled(true);
this->setMiningStarted();
}
else if (state == QProcess::ProcessState::NotRunning) {
ui->btn_start->setEnabled(true); // todo
ui->btn_stop->setEnabled(false);
ui->label_status->hide();
this->setMiningStopped();
}
}
void XMRigWidget::setMiningStopped() {
m_isMining = false;
emit miningEnded();
}
void XMRigWidget::setMiningStarted() {
m_isMining = true;
emit miningStarted();
}
bool XMRigWidget::checkXMRigPath() {
QString path = config()->get(Config::xmrigPath).toString();
if (path.isEmpty()) {
ui->console->appendPlainText("No XMRig executable is set. Please configure on the Settings tab.");
return false;
} else if (!Utils::fileExists(path)) {
ui->console->appendPlainText("Invalid path to XMRig executable detected. Please reconfigure on the Settings tab.");
return false;
} else {
return true;
} }
} }

View file

@ -32,17 +32,22 @@ public slots:
void onStartClicked(); void onStartClicked();
void onStopClicked(); void onStopClicked();
void onClearClicked(); void onClearClicked();
void onUsePrimaryAddressClicked();
void onDownloads(const QJsonObject &data); void onDownloads(const QJsonObject &data);
void linkClicked(); void linkClicked();
void onProcessError(const QString &msg); void onProcessError(const QString &msg);
void onProcessOutput(const QByteArray &msg); void onProcessOutput(const QByteArray &msg);
void onHashrate(const QString &hashrate); void onHashrate(const QString &hashrate);
void onSoloChecked(int state); void onMiningModeChanged(int mode);
void onNetworkTLSToggled(bool checked);
void onNetworkTorToggled(bool checked);
void onXMRigStateChanged(QProcess::ProcessState state);
private slots: private slots:
void onBrowseClicked(); void onBrowseClicked();
void onThreadsValueChanged(int date); void onThreadsValueChanged(int date);
void onPoolChanged(const QString &pool); void onPoolChanged(const QString &pool);
void onXMRigElevationChanged(bool elevated);
signals: signals:
void miningStarted(); void miningStarted();
@ -51,15 +56,18 @@ signals:
private: private:
void showContextMenu(const QPoint &pos); void showContextMenu(const QPoint &pos);
void updatePools(); void updatePools();
void printConsoleInfo();
void setMiningStopped();
void setMiningStarted();
bool checkXMRigPath();
QScopedPointer<Ui::XMRigWidget> ui; QScopedPointer<Ui::XMRigWidget> ui;
QSharedPointer<AppContext> m_ctx; QSharedPointer<AppContext> m_ctx;
XmRig * m_XMRig; XmRig *m_XMRig;
QStandardItemModel *m_model; QStandardItemModel *m_model;
QMenu *m_contextMenu; QMenu *m_contextMenu;
bool m_isMining = false; bool m_isMining = false;
int m_threads;
QStringList m_urls; QStringList m_urls;
QStringList m_defaultPools{"pool.xmr.pt:9000", "pool.supportxmr.com:9000", "mine.xmrpool.net:443", "xmrpool.eu:9999", "xmr-eu1.nanopool.org:14433", "pool.minexmr.com:6666", "us-west.minexmr.com:6666", "monerohash.com:9999", "cryptonote.social:5555", "cryptonote.social:5556"}; QStringList m_defaultPools{"pool.xmr.pt:9000", "pool.supportxmr.com:9000", "mine.xmrpool.net:443", "xmrpool.eu:9999", "xmr-eu1.nanopool.org:14433", "pool.minexmr.com:6666", "us-west.minexmr.com:6666", "monerohash.com:9999", "cryptonote.social:5555", "cryptonote.social:5556"};
}; };

View file

@ -33,7 +33,7 @@
</property> </property>
<widget class="QWidget" name="tabMining"> <widget class="QWidget" name="tabMining">
<attribute name="title"> <attribute name="title">
<string>Mining</string> <string>Status</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
@ -130,247 +130,16 @@
<layout class="QHBoxLayout" name="horizontalLayout_6"> <layout class="QHBoxLayout" name="horizontalLayout_6">
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_6"> <layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<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>
</layout>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QFrame" name="pathFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<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>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="check_tls">
<property name="text">
<string>TLS</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="relayTor">
<property name="text">
<string>Tor</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="check_solo">
<property name="text">
<string>Solo mine</string>
</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>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QFrame" name="poolFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Pool</string>
</property>
</widget>
</item>
<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>
<widget class="QPushButton" name="btn_poolConfig">
<property name="text">
<string>Configure</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>414</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="soloFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Node address</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_solo">
<property name="text">
<string>127.0.0.1:18081</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>173</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item> <item>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>Receiving address</string> <string>XMRig executable:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_address"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Password (optional)</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_password"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>XMRig executable</string>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_5"> <layout class="QHBoxLayout" name="horizontalLayout_5">
<item> <item>
<widget class="QLineEdit" name="lineEdit_path"> <widget class="QLineEdit" name="lineEdit_path">
@ -388,50 +157,272 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Run as admin/root:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QRadioButton" name="radio_elevateYes">
<property name="text">
<string>Yes</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radio_elevateNo">
<property name="text">
<string>No</string>
</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>
<item row="2" column="0">
<widget class="QLabel" name="label_threads">
<property name="text">
<string>CPU threads: </string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSlider" name="threadSlider">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Mining mode:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QComboBox" name="combo_miningMode">
<item>
<property name="text">
<string>Pool mining</string>
</property>
</item>
<item>
<property name="text">
<string>Solo mining</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_7">
<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 row="4" column="0">
<widget class="QLabel" name="label_poolNodeAddress">
<property name="text">
<string>Pool/node address:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_13">
<item>
<widget class="QFrame" name="poolFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<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>
<widget class="QPushButton" name="btn_poolConfig">
<property name="text">
<string>Configure</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>414</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="soloFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="lineEdit_solo">
<property name="text">
<string>127.0.0.1:18081</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>173</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Network settings:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QCheckBox" name="check_tls">
<property name="text">
<string>Secure connection (TLS)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="relayTor">
<property name="text">
<string>Connect via Tor</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<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 row="6" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Receiving address:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="lineEdit_address"/>
</item>
<item>
<widget class="QPushButton" name="btn_fillPrimaryAddress">
<property name="text">
<string>Use primary address</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Password (optional):</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="lineEdit_password"/>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>
</item> </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> </layout>
</item> </item>
<item> <item>