mirror of
https://github.com/feather-wallet/feather.git
synced 2024-12-23 03:59:29 +00:00
Rework Mining UI
This commit is contained in:
parent
0eb4592f87
commit
3fec15e4aa
7 changed files with 503 additions and 398 deletions
|
@ -49,8 +49,13 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
|
|||
{Config::showSearchbar,{QS("showSearchbar"), true}},
|
||||
|
||||
// Mining
|
||||
{Config::miningMode,{QS("miningMode"), Config::MiningMode::Pool}},
|
||||
{Config::xmrigPath,{QS("xmrigPath"), ""}},
|
||||
{Config::xmrigElevated,{QS("xmrigElevated"), false}},
|
||||
{Config::xmrigThreads,{QS("xmrigThreads"), 1}},
|
||||
{Config::xmrigPool,{QS("xmrigPool"), "pool.xmr.pt:9000"}},
|
||||
{Config::xmrigNetworkTLS,{QS("xmrigNetworkTLS"), true}},
|
||||
{Config::xmrigNetworkTor,{QS("xmrigNetworkTor"), false}},
|
||||
{Config::pools,{QS("pools"), {}}},
|
||||
|
||||
// Settings
|
||||
|
|
|
@ -53,8 +53,13 @@ public:
|
|||
showSearchbar,
|
||||
|
||||
// Mining
|
||||
miningMode,
|
||||
xmrigPath,
|
||||
xmrigElevated,
|
||||
xmrigThreads,
|
||||
xmrigPool,
|
||||
xmrigNetworkTLS,
|
||||
xmrigNetworkTor,
|
||||
pools,
|
||||
|
||||
// Settings
|
||||
|
@ -98,6 +103,11 @@ public:
|
|||
spendable
|
||||
};
|
||||
|
||||
enum MiningMode {
|
||||
Pool = 0,
|
||||
Solo
|
||||
};
|
||||
|
||||
~Config() override;
|
||||
QVariant get(ConfigKey key);
|
||||
QString getFileName();
|
||||
|
|
|
@ -13,49 +13,58 @@
|
|||
XmRig::XmRig(const QString &configDir, QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
this->rigDir = QDir(configDir).filePath("xmrig");
|
||||
|
||||
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);
|
||||
connect(&m_process, &QProcess::stateChanged, this, &XmRig::onStateChanged);
|
||||
}
|
||||
|
||||
void XmRig::stop() {
|
||||
if(m_process.state() == QProcess::Running) {
|
||||
qDebug() << m_process.processId();
|
||||
if (m_process.state() == QProcess::Running) {
|
||||
#if defined(Q_OS_WIN)
|
||||
m_process.kill(); // https://doc.qt.io/qt-5/qprocess.html#terminate
|
||||
#else
|
||||
m_process.terminate();
|
||||
#elif defined(Q_OS_LINUX)
|
||||
if (m_elevated) {
|
||||
m_killProcess.start("pkexec", QStringList() << "kill" << QString::number(m_process.processId()));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
m_process.terminate();
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
if (state == QProcess::ProcessState::Running || state == QProcess::ProcessState::Starting) {
|
||||
emit error("Can't start XMRig, already running or starting");
|
||||
return;
|
||||
}
|
||||
|
||||
if(path.isEmpty()) {
|
||||
if (path.isEmpty()) {
|
||||
emit error("XmRig->Start path parameter missing.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!Utils::fileExists(path)) {
|
||||
if (!Utils::fileExists(path)) {
|
||||
emit error(QString("Path to XMRig binary invalid; file does not exist: %1").arg(path));
|
||||
return;
|
||||
}
|
||||
|
||||
QStringList arguments;
|
||||
if (m_elevated) {
|
||||
arguments << path;
|
||||
}
|
||||
arguments << "-o" << address;
|
||||
arguments << "-a" << "rx/0";
|
||||
arguments << "-u" << username;
|
||||
if(!password.isEmpty())
|
||||
if (!password.isEmpty()) {
|
||||
arguments << "-p" << password;
|
||||
}
|
||||
arguments << "--no-color";
|
||||
arguments << "-t" << QString::number(threads);
|
||||
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);
|
||||
}
|
||||
|
||||
if(tls)
|
||||
if (tls) {
|
||||
arguments << "--tls";
|
||||
}
|
||||
arguments << "--donate-level" << "1";
|
||||
QString cmd = QString("%1 %2").arg(path, arguments.join(" "));
|
||||
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) {
|
||||
if(state == QProcess::ProcessState::Running)
|
||||
void XmRig::onStateChanged(QProcess::ProcessState state) {
|
||||
emit stateChanged(state);
|
||||
|
||||
if (state == QProcess::ProcessState::Running) {
|
||||
emit output("XMRig started");
|
||||
else if (state == QProcess::ProcessState::NotRunning)
|
||||
}
|
||||
|
||||
else if (state == QProcess::ProcessState::NotRunning) {
|
||||
emit output("XMRig stopped");
|
||||
}
|
||||
}
|
||||
|
||||
void XmRig::handleProcessOutput() {
|
||||
|
|
|
@ -21,24 +21,24 @@ Q_OBJECT
|
|||
public:
|
||||
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();
|
||||
|
||||
QString rigDir;
|
||||
QString rigPath;
|
||||
|
||||
signals:
|
||||
void error(const QString &msg);
|
||||
void output(const QByteArray &data);
|
||||
void hashrate(const QString &rate);
|
||||
void stateChanged(QProcess::ProcessState state);
|
||||
|
||||
private slots:
|
||||
void stateChanged(QProcess::ProcessState);
|
||||
void onStateChanged(QProcess::ProcessState);
|
||||
void handleProcessOutput();
|
||||
void handleProcessError(QProcess::ProcessError error);
|
||||
|
||||
private:
|
||||
ChildProcess m_process;
|
||||
QProcess m_killProcess;
|
||||
bool m_elevated;
|
||||
};
|
||||
|
||||
#endif //FEATHER_XMRIG_H
|
||||
|
|
|
@ -24,52 +24,54 @@ XMRigWidget::XMRigWidget(QSharedPointer<AppContext> ctx, QWidget *parent)
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
QPixmap p(":assets/images/xmrig.svg");
|
||||
ui->lbl_logo->setPixmap(p.scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||
|
||||
connect(m_XMRig, &XmRig::stateChanged, this, &XMRigWidget::onXMRigStateChanged);
|
||||
connect(m_XMRig, &XmRig::output, this, &XMRigWidget::onProcessOutput);
|
||||
connect(m_XMRig, &XmRig::error, this, &XMRigWidget::onProcessError);
|
||||
connect(m_XMRig, &XmRig::hashrate, this, &XMRigWidget::onHashrate);
|
||||
|
||||
// table
|
||||
ui->tableView->setModel(this->m_model);
|
||||
// [Downloads] tab
|
||||
ui->tableView->setModel(m_model);
|
||||
m_contextMenu->addAction(icons()->icon("network.png"), "Download file", this, &XMRigWidget::linkClicked);
|
||||
connect(ui->tableView, &QHeaderView::customContextMenuRequested, this, &XMRigWidget::showContextMenu);
|
||||
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);
|
||||
int threads = QThread::idealThreadCount();
|
||||
m_threads = threads / 2;
|
||||
ui->threadSlider->setMaximum(threads);
|
||||
ui->threadSlider->setValue(m_threads);
|
||||
ui->label_threads->setText(QString("CPU threads: %1").arg(m_threads));
|
||||
ui->threadSlider->setMaximum(QThread::idealThreadCount());
|
||||
|
||||
int threads = config()->get(Config::xmrigThreads).toInt();
|
||||
ui->threadSlider->setValue(threads);
|
||||
ui->label_threads->setText(QString("CPU threads: %1").arg(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);
|
||||
// Mining mode
|
||||
connect(ui->combo_miningMode, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &XMRigWidget::onMiningModeChanged);
|
||||
ui->combo_miningMode->setCurrentIndex(config()->get(Config::miningMode).toInt());
|
||||
|
||||
// defaults
|
||||
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();
|
||||
// Pool/node address
|
||||
this->updatePools();
|
||||
connect(ui->combo_pools, &QComboBox::currentTextChanged, this, &XMRigWidget::onPoolChanged);
|
||||
|
||||
|
@ -87,41 +89,45 @@ XMRigWidget::XMRigWidget(QSharedPointer<AppContext> ctx, QWidget *parent)
|
|||
this->updatePools();
|
||||
});
|
||||
|
||||
// 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));
|
||||
// Network settings
|
||||
connect(ui->check_tls, &QCheckBox::toggled, this, &XMRigWidget::onNetworkTLSToggled);
|
||||
connect(ui->relayTor, &QCheckBox::toggled, this, &XMRigWidget::onNetworkTorToggled);
|
||||
ui->check_tls->setChecked(config()->get(Config::xmrigNetworkTLS).toBool());
|
||||
ui->relayTor->setChecked(config()->get(Config::xmrigNetworkTor).toBool());
|
||||
|
||||
ui->console->appendPlainText("Ready to mine.");
|
||||
|
||||
// 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
|
||||
// Receiving address
|
||||
auto username = m_ctx->wallet->getCacheAttribute("feather.xmrig_username");
|
||||
if(!username.isEmpty())
|
||||
if (!username.isEmpty()) {
|
||||
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");
|
||||
if(!password.isEmpty()) {
|
||||
if (!password.isEmpty()) {
|
||||
ui->lineEdit_password->setText(password);
|
||||
} else {
|
||||
ui->lineEdit_password->setText("featherwallet");
|
||||
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() {
|
||||
|
@ -130,14 +136,11 @@ bool XMRigWidget::isMining() {
|
|||
|
||||
void XMRigWidget::onWalletClosed() {
|
||||
this->onStopClicked();
|
||||
this->onClearClicked();
|
||||
ui->lineEdit_password->setText("");
|
||||
ui->lineEdit_address->setText("");
|
||||
}
|
||||
|
||||
void XMRigWidget::onThreadsValueChanged(int threads) {
|
||||
m_threads = threads;
|
||||
ui->label_threads->setText(QString("CPU threads: %1").arg(m_threads));
|
||||
config()->set(Config::xmrigThreads, threads);
|
||||
ui->label_threads->setText(QString("CPU threads: %1").arg(threads));
|
||||
}
|
||||
|
||||
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() {
|
||||
QString fileName = QFileDialog::getOpenFileName(
|
||||
this, "Path to XMRig executable", QDir::homePath());
|
||||
if (fileName.isEmpty()) return;
|
||||
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);
|
||||
}
|
||||
|
@ -158,47 +166,50 @@ void XMRigWidget::onClearClicked() {
|
|||
ui->console->clear();
|
||||
}
|
||||
|
||||
void XMRigWidget::onUsePrimaryAddressClicked() {
|
||||
ui->lineEdit_address->setText(m_ctx->wallet->address(0, 0));
|
||||
}
|
||||
|
||||
void XMRigWidget::onStartClicked() {
|
||||
QString xmrigPath;
|
||||
bool solo = ui->check_solo->isChecked();
|
||||
xmrigPath = config()->get(Config::xmrigPath).toString();
|
||||
QString xmrigPath = config()->get(Config::xmrigPath).toString();
|
||||
if (!this->checkXMRigPath()) {
|
||||
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
|
||||
auto username = m_ctx->wallet->getCacheAttribute("feather.xmrig_username");
|
||||
auto password = m_ctx->wallet->getCacheAttribute("feather.xmrig_password");
|
||||
|
||||
if(username.isEmpty()) {
|
||||
QString err = "Please specify a receiving address on the Settings screen";
|
||||
ui->console->appendPlainText(err);
|
||||
QMessageBox::warning(this, "Error", err);
|
||||
if (username.isEmpty()) {
|
||||
ui->console->appendPlainText("Please specify a receiving address on the Settings screen.");
|
||||
return;
|
||||
}
|
||||
|
||||
QString address;
|
||||
if(solo)
|
||||
address = ui->lineEdit_solo->text().trimmed();
|
||||
else
|
||||
address = config()->get(Config::xmrigPool).toString();
|
||||
|
||||
if(address.contains("cryptonote.social") && !username.contains(".")) {
|
||||
if (address.contains("cryptonote.social") && !username.contains(".")) {
|
||||
// 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));
|
||||
}
|
||||
|
||||
m_XMRig->start(xmrigPath, m_threads, address, username, password, ui->relayTor->isChecked(), ui->check_tls->isChecked());
|
||||
ui->btn_start->setEnabled(false);
|
||||
ui->btn_stop->setEnabled(true);
|
||||
m_isMining = true;
|
||||
emit miningStarted();
|
||||
int threads = ui->threadSlider->value();
|
||||
|
||||
m_XMRig->start(xmrigPath, threads, address, username, password, ui->relayTor->isChecked(), ui->check_tls->isChecked(),
|
||||
ui->radio_elevateYes->isChecked());
|
||||
}
|
||||
|
||||
void XMRigWidget::onStopClicked() {
|
||||
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) {
|
||||
|
@ -216,9 +227,7 @@ 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();
|
||||
m_isMining = false;
|
||||
emit miningEnded();
|
||||
this->setMiningStopped();
|
||||
}
|
||||
|
||||
void XMRigWidget::onHashrate(const QString &hashrate) {
|
||||
|
@ -307,15 +316,78 @@ void XMRigWidget::updatePools() {
|
|||
}
|
||||
}
|
||||
|
||||
void XMRigWidget::onSoloChecked(int state) {
|
||||
if(state == 2) {
|
||||
ui->poolFrame->hide();
|
||||
ui->soloFrame->show();
|
||||
ui->check_tls->setChecked(false);
|
||||
void XMRigWidget::printConsoleInfo() {
|
||||
ui->console->appendPlainText(QString("Detected %1 CPU threads.").arg(QThread::idealThreadCount()));
|
||||
if (this->checkXMRigPath()) {
|
||||
QString path = config()->get(Config::xmrigPath).toString();
|
||||
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->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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,17 +32,22 @@ public slots:
|
|||
void onStartClicked();
|
||||
void onStopClicked();
|
||||
void onClearClicked();
|
||||
void onUsePrimaryAddressClicked();
|
||||
void onDownloads(const QJsonObject &data);
|
||||
void linkClicked();
|
||||
void onProcessError(const QString &msg);
|
||||
void onProcessOutput(const QByteArray &msg);
|
||||
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:
|
||||
void onBrowseClicked();
|
||||
void onThreadsValueChanged(int date);
|
||||
void onPoolChanged(const QString &pool);
|
||||
void onXMRigElevationChanged(bool elevated);
|
||||
|
||||
signals:
|
||||
void miningStarted();
|
||||
|
@ -51,15 +56,18 @@ signals:
|
|||
private:
|
||||
void showContextMenu(const QPoint &pos);
|
||||
void updatePools();
|
||||
void printConsoleInfo();
|
||||
void setMiningStopped();
|
||||
void setMiningStarted();
|
||||
bool checkXMRigPath();
|
||||
|
||||
QScopedPointer<Ui::XMRigWidget> ui;
|
||||
QSharedPointer<AppContext> m_ctx;
|
||||
XmRig * m_XMRig;
|
||||
XmRig *m_XMRig;
|
||||
QStandardItemModel *m_model;
|
||||
QMenu *m_contextMenu;
|
||||
|
||||
bool m_isMining = false;
|
||||
int m_threads;
|
||||
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"};
|
||||
};
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
</property>
|
||||
<widget class="QWidget" name="tabMining">
|
||||
<attribute name="title">
|
||||
<string>Mining</string>
|
||||
<string>Status</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
|
@ -130,247 +130,16 @@
|
|||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<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>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Receiving address</string>
|
||||
<string>XMRig executable:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<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">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_path">
|
||||
|
@ -388,50 +157,272 @@
|
|||
</item>
|
||||
</layout>
|
||||
</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>
|
||||
</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>
|
||||
|
|
Loading…
Reference in a new issue