Skip to content

Commit ceb5ae8

Browse files
committed
Slider and switch connection
1 parent 2a5f5a6 commit ceb5ae8

File tree

2 files changed

+22
-26
lines changed

2 files changed

+22
-26
lines changed

src/qt/miningpage.cpp

+20-24
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ MiningPage::MiningPage(const PlatformStyle* platformStyle, QWidget* parent) : QW
4343
ui->labelNCPUCores->setText(QString("%1").arg(nCPUMaxUseThreads));
4444
}
4545

46-
ui->sliderCPUCores->setMinimum(1);
46+
ui->sliderCPUCores->setMinimum(0);
4747
ui->sliderCPUCores->setMaximum(nCPUMaxUseThreads);
4848
ui->sliderCPUCores->setValue(nCPUMaxUseThreads);
4949

@@ -56,7 +56,7 @@ MiningPage::MiningPage(const PlatformStyle* platformStyle, QWidget* parent) : QW
5656
ui->labelNGPUCores->setText(QString("%1").arg(nGPUMaxUseThreads));
5757
}
5858

59-
ui->sliderGPUCores->setMinimum(1);
59+
ui->sliderGPUCores->setMinimum(0);
6060
ui->sliderGPUCores->setMaximum(nGPUMaxUseThreads);
6161
ui->sliderGPUCores->setValue(nGPUMaxUseThreads);
6262
ui->pushSwitchGPUMining->setVisible(true);
@@ -233,15 +233,15 @@ void MiningPage::StopCPUMiner()
233233
{
234234
LogPrintf("StopCPUMiner %d (%s)", ui->sliderCPUCores->value(), fCPUMinerOn);
235235
fCPUMinerOn = false;
236-
changeNumberOfCPUThreads(ui->sliderCPUCores->value());
236+
changeNumberOfCPUThreads(0, true);
237237
ShutdownCPUMiners();
238238
updateUI();
239239
}
240240

241241
void MiningPage::StopGPUMiner()
242242
{
243243
fGPUMinerOn = false;
244-
changeNumberOfGPUThreads(ui->sliderGPUCores->value());
244+
changeNumberOfGPUThreads(0, true);
245245
ShutdownGPUMiners();
246246
updateUI();
247247
}
@@ -255,22 +255,26 @@ bool MiningPage::isMinerOn()
255255
#endif
256256
}
257257

258-
void MiningPage::changeNumberOfCPUThreads(int i)
258+
void MiningPage::changeNumberOfCPUThreads(int i, bool shutdown)
259259
{
260-
ui->labelNCPUCores->setText(QString("%1").arg(i));
260+
if (!shutdown)
261+
ui->labelNCPUCores->setText(QString("%1").arg(i));
261262
ForceSetArg("-gen", isMinerOn() ? "1" : "0");
262263
ForceSetArg("-genproclimit-cpu", isMinerOn() ? i : 0);
264+
InitMiners(Params(), *g_connman);
263265
SetCPUMinerThreads(i);
264266
if (fCPUMinerOn)
265267
StartMiners();
266268
}
267269

268270
#ifdef ENABLE_GPU
269-
void MiningPage::changeNumberOfGPUThreads(int i)
271+
void MiningPage::changeNumberOfGPUThreads(int i, bool shutdown)
270272
{
271-
ui->labelNGPUCores->setText(QString("%1").arg(i));
273+
if (!shutdown)
274+
ui->labelNGPUCores->setText(QString("%1").arg(i));
272275
ForceSetArg("-gen", isMinerOn() ? "1" : "0");
273276
ForceSetArg("-genproclimit-gpu", isMinerOn() ? i : 0);
277+
InitMiners(Params(), *g_connman);
274278
SetGPUMinerThreads(i);
275279
if (fGPUMinerOn)
276280
StartMiners();
@@ -279,32 +283,24 @@ void MiningPage::changeNumberOfGPUThreads(int i)
279283

280284
void MiningPage::switchCPUMining()
281285
{
282-
int nThreads = (int)ui->sliderCPUCores->value();
286+
fCPUMinerOn = !fCPUMinerOn;
287+
updateCPUPushSwitch();
283288
if (fCPUMinerOn) {
284-
ui->sliderCPUCores->setValue(0);
285-
ui->pushSwitchCPUMining->setText(tr("Stopping"));
286-
StopCPUMiner();
287-
} else {
288-
if (nThreads == 0)
289-
ui->sliderCPUCores->setValue(1);
290-
ui->pushSwitchCPUMining->setText(tr("Starting"));
291289
StartCPUMiner();
290+
} else {
291+
StopCPUMiner();
292292
}
293293
}
294294

295295
#ifdef ENABLE_GPU
296296
void MiningPage::switchGPUMining()
297297
{
298-
int nThreads = (int)ui->sliderGPUCores->value();
298+
fGPUMinerOn = !fGPUMinerOn;
299+
updateGPUPushSwitch();
299300
if (fGPUMinerOn) {
300-
ui->sliderGPUCores->setValue(0);
301-
ui->pushSwitchGPUMining->setText(tr("Stopping"));
302-
StopGPUMiner();
303-
} else {
304-
if (nThreads == 0)
305-
ui->sliderGPUCores->setValue(1);
306-
ui->pushSwitchGPUMining->setText(tr("Starting"));
307301
StartGPUMiner();
302+
} else {
303+
StopGPUMiner();
308304
}
309305
}
310306
#endif

src/qt/miningpage.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ class MiningPage : public QWidget
5858

5959
private Q_SLOTS:
6060

61-
void changeNumberOfCPUThreads(int i);
61+
void changeNumberOfCPUThreads(int i, bool shutdown = false);
6262
void switchCPUMining();
6363
void showCPUHashRate(int i);
6464
void changeCPUSampleTime(int i);
6565
void clearCPUHashRateData();
6666

6767

6868
#ifdef ENABLE_GPU
69-
void changeNumberOfGPUThreads(int i);
69+
void changeNumberOfGPUThreads(int i, bool shutdown = false);
7070
void switchGPUMining();
7171
void showGPUHashRate(int i);
7272
void changeGPUSampleTime(int i);

0 commit comments

Comments
 (0)