tuxclocker/mainwindow.cpp

1055 lines
39 KiB
C++
Raw Normal View History

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "editprofile.h"
#include "ui_editprofile.h"
2018-12-21 14:55:35 -06:00
#include "newprofile.h"
2018-12-30 01:17:12 -06:00
#include "monitor.h"
2019-01-18 07:48:34 -06:00
#include "plotwidget.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
checkForProfiles();
2018-12-21 14:55:35 -06:00
queryGPUSettings();
2018-12-24 12:42:36 -06:00
loadProfileSettings();
queryDriverSettings();
2019-01-13 10:51:19 -06:00
//getGPUName();
queryGPUs();
2018-12-30 01:17:12 -06:00
setupMonitorTab();
2019-01-03 10:27:30 -06:00
setupGraphMonitorTab();
2018-12-30 01:17:12 -06:00
tabHandler(ui->tabWidget->currentIndex());
2018-12-21 14:55:35 -06:00
2018-12-30 01:17:12 -06:00
ui->frequencySlider->setRange(minCoreClkOfsInt, maxCoreClkOfsInt);
ui->frequencySpinBox->setRange(minCoreClkOfsInt, maxCoreClkOfsInt);
ui->frequencySlider->setValue(coreFreqOfsInt);
ui->frequencySpinBox->setValue(coreFreqOfsInt);
2018-12-21 14:55:35 -06:00
ui->powerLimSlider->setRange(minPowerLimInt, maxPowerLimInt);
ui->powerLimSpinBox->setRange(minPowerLimInt, maxPowerLimInt);
ui->powerLimSlider->setValue(curPowerLimInt);
ui->powerLimSpinBox->setValue(curPowerLimInt);
2018-12-30 01:17:12 -06:00
ui->memClkSlider->setRange(minMemClkOfsInt, maxMemClkOfsInt);
ui->memClkSpinBox->setRange(minMemClkOfsInt, maxMemClkOfsInt);
ui->memClkSlider->setValue(memClkOfsInt);
ui->memClkSpinBox->setValue(memClkOfsInt);
2018-12-21 14:55:35 -06:00
2018-12-24 12:42:36 -06:00
ui->voltageSlider->setRange(minVoltOfsInt, maxVoltOfsInt);
ui->voltageSpinBox->setRange(minVoltOfsInt, maxVoltOfsInt);
ui->voltageSlider->setValue(voltOfsInt);
ui->voltageSpinBox->setValue(voltOfsInt);
2018-12-21 14:55:35 -06:00
ui->fanSlider->setValue(fanSpeed);
ui->fanSpinBox->setValue(fanSpeed);
ui->fanSlider->setRange(0, 100);
ui->fanSpinBox->setRange(0, 100);
2018-12-24 12:42:36 -06:00
//QTimer *fanUpdateTimer = new QTimer(this);
2018-12-21 14:55:35 -06:00
connect(fanUpdateTimer, SIGNAL(timeout()), this, SLOT(fanSpeedUpdater()));
2018-12-22 11:11:45 -06:00
//connect(fanUpdateTimer, SIGNAL(timeout()), this, SLOT(tempUpdater()));
2018-12-21 14:55:35 -06:00
fanUpdateTimer->start(2000);
2018-12-22 11:11:45 -06:00
connect(ui->frequencySpinBox, SIGNAL(valueChanged(int)), SLOT(resetTimer()));
connect(ui->powerLimSpinBox, SIGNAL(valueChanged(int)), SLOT(resetTimer()));
connect(ui->memClkSpinBox, SIGNAL(valueChanged(int)), SLOT(resetTimer()));
connect(ui->voltageSpinBox, SIGNAL(valueChanged(int)), SLOT(resetTimer()));
2018-12-30 01:17:12 -06:00
connect(ui->tabWidget, SIGNAL(currentChanged(int)), SLOT(tabHandler(int)));
connect(monitorUpdater, SIGNAL(timeout()), SLOT(updateMonitor()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_actionEdit_current_profile_triggered(bool)
{
editProfile *editprof = new editProfile(this);
editprof->show();
}
void MainWindow::on_pushButton_clicked()
{
2018-12-24 12:42:36 -06:00
qDebug() << xCurvePoints;
}
2018-12-21 14:55:35 -06:00
void MainWindow::checkForRoot()
{
QProcess process;
process.start("/bin/sh -c \"echo $EUID\"");
process.waitForFinished();
QString EUID = process.readLine();
if (EUID.toInt() == 0) {
isRoot = true;
2019-01-18 07:48:34 -06:00
qDebug() << "Running as root";
} else {
qDebug() << "Running as normal user";
2018-12-21 14:55:35 -06:00
}
}
2018-12-30 01:17:12 -06:00
void MainWindow::tabHandler(int index)
{
// Disconnect the monitor updater when the tab is not visible
// Maybe do this with ifs if the tabs can be moved
switch (index) {
case 2:
2019-01-18 07:48:34 -06:00
monitorUpdater->start(1000);
2018-12-30 01:17:12 -06:00
break;
2019-01-07 13:45:42 -06:00
case 1:
monitorUpdater->start(1000);
break;
2018-12-30 01:17:12 -06:00
default:
monitorUpdater->stop();
break;
}
}
void MainWindow::setupMonitorTab()
{
// Set the behavior of the tree view
ui->monitorTree->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
ui->monitorTree->setIndentation(0);
// Add the items
gputemp->setText(0, "Core Temperature");
powerdraw->setText(0, "Power Draw");
voltage->setText(0, "Core Voltage");
coreclock->setText(0, "Core Clock Frequency");
memclock->setText(0, "Memory Clock Frequency");
coreutil->setText(0, "Core Utilization");
memutil->setText(0, "Memory Utilization");
fanspeed->setText(0, "Fan Speed");
memusage->setText(0, "Used Memory/Total Memory");
curmaxclk->setText(0, "Maximum Core Clock Frequency");
curmaxmemclk->setText(0, "Maximum Memory Clock Frequency");
ui->monitorTree->addTopLevelItem(gputemp);
ui->monitorTree->addTopLevelItem(powerdraw);
ui->monitorTree->addTopLevelItem(voltage);
ui->monitorTree->addTopLevelItem(coreclock);
ui->monitorTree->addTopLevelItem(memclock);
ui->monitorTree->addTopLevelItem(coreutil);
ui->monitorTree->addTopLevelItem(memutil);
ui->monitorTree->addTopLevelItem(fanspeed);
ui->monitorTree->addTopLevelItem(memusage);
ui->monitorTree->addTopLevelItem(curmaxclk);
ui->monitorTree->addTopLevelItem(curmaxmemclk);
// These values only change when the apply button has been pressed
QString curMaxClk = QString::number(defCoreClk + latestClkOfs) + " MHz";
curmaxclk->setText(1, curMaxClk);
QString curMaxMemClk = QString::number(defMemClk + latestMemClkOfs) + " MHz";
curmaxmemclk->setText(1, curMaxMemClk);
}
2019-01-03 10:27:30 -06:00
void MainWindow::setupGraphMonitorTab()
{
2019-01-07 13:45:42 -06:00
monitor mon;
mon.queryValues();
fanSpeedUpdater();
2019-01-07 13:45:42 -06:00
plotCmdsList.append(powerdrawplot);
plotCmdsList.append(tempplot);
plotCmdsList.append(coreclkplot);
plotCmdsList.append(memclkplot);
plotCmdsList.append(coreutilplot);
2019-01-07 19:02:36 -06:00
plotCmdsList.append(memutilplot);
plotCmdsList.append(voltageplot);
plotCmdsList.append(fanspeedplot);
2019-01-03 10:27:30 -06:00
// Layout for the plots
2019-01-07 13:45:42 -06:00
plotWidget->setLayout(plotLayout);
// Define the structs
plotCmdsList[0].plot = tempPlot;
plotCmdsList[0].vector = qv_temp;
plotCmdsList[0].layout = tempLayout;
2019-01-18 07:48:34 -06:00
//plotCmdsList[0].widget = tempWidget;
2019-01-07 13:45:42 -06:00
plotCmdsList[1].plot = powerDrawPlot;
plotCmdsList[1].vector = qv_powerDraw;
plotCmdsList[1].layout = powerDrawLayout;
2019-01-18 07:48:34 -06:00
//plotCmdsList[1].widget = powerDrawWidget;
2019-01-07 13:45:42 -06:00
plotCmdsList[2].plot = coreClkPlot;
plotCmdsList[2].vector = qv_coreClk;
plotCmdsList[2].layout = coreClkLayout;
2019-01-18 07:48:34 -06:00
//plotCmdsList[2].widget = coreClkWidget;
2019-01-07 13:45:42 -06:00
plotCmdsList[3].plot = memClkPlot;
plotCmdsList[3].vector = qv_memClk;
plotCmdsList[3].layout = memClkLayout;
2019-01-18 07:48:34 -06:00
//plotCmdsList[3].widget = memClkWidget;
2019-01-07 13:45:42 -06:00
plotCmdsList[4].plot = coreUtilPlot;
plotCmdsList[4].vector = qv_coreUtil;
plotCmdsList[4].layout = coreUtilLayout;
2019-01-18 07:48:34 -06:00
//plotCmdsList[4].widget = coreUtilWidget;
2019-01-07 13:45:42 -06:00
2019-01-07 19:02:36 -06:00
plotCmdsList[5].plot = memUtilPlot;
plotCmdsList[5].vector = qv_memUtil;
plotCmdsList[5].layout = memUtilLayout;
2019-01-18 07:48:34 -06:00
//plotCmdsList[5].widget = memUtilWidget;
2019-01-07 19:02:36 -06:00
plotCmdsList[6].plot = voltagePlot;
plotCmdsList[6].vector = qv_voltage;
plotCmdsList[6].layout = voltageLayout;
2019-01-18 07:48:34 -06:00
//plotCmdsList[6].widget = voltageWidget;
plotCmdsList[7].plot = fanSpeedPlot;
plotCmdsList[7].vector = qv_fanSpeed;
plotCmdsList[7].layout = fanSpeedLayout;
2019-01-18 07:48:34 -06:00
//plotCmdsList[7].widget = fanSpeedWidget;
2019-01-07 19:02:36 -06:00
2019-01-07 13:45:42 -06:00
plotCmdsList[0].valueq = mon.temp.toDouble();
plotCmdsList[1].valueq = mon.powerdraw.toDouble();
plotCmdsList[2].valueq = mon.coreclock.toDouble();
plotCmdsList[3].valueq = mon.memclock.toDouble();
plotCmdsList[4].valueq = mon.coreutil.toDouble();
2019-01-07 19:02:36 -06:00
plotCmdsList[5].valueq = mon.memutil.toDouble();
plotCmdsList[6].valueq = mon.voltage.toDouble();
plotCmdsList[7].valueq = fanSpeed;
2019-01-10 08:30:52 -06:00
// Get the main widget palette and use it for the graphs
2019-01-07 13:45:42 -06:00
QPalette palette;
palette.setCurrentColorGroup(QPalette::Active);
QColor color = palette.color(QPalette::Background);
QColor textColor = palette.color(QPalette::Text);
QColor graphColor = palette.color(QPalette::Highlight);
QPen graphPen;
graphPen.setWidth(2);
graphPen.setColor(graphColor);
QPen tickPen;
tickPen.setWidthF(0.5);
tickPen.setColor(textColor);
2019-01-18 07:48:34 -06:00
// Button to reset extreme values
QPushButton *resetButton = new QPushButton(this);
resetButton->setMaximumWidth(150);
resetButton->setText("Reset min/max");
connect(resetButton, SIGNAL(clicked()), SLOT(clearExtremeValues()));
plotLayout->addWidget(resetButton);
2019-01-07 13:45:42 -06:00
// Define features common to all plots
for (int i=0; i<plotCmdsList.size(); i++) {
plotCmdsList[i].plot->setMinimumHeight(220);
plotCmdsList[i].plot->setMaximumHeight(220);
2019-01-07 13:45:42 -06:00
plotCmdsList[i].plot->setMinimumWidth(200);
plotCmdsList[i].plot->addGraph();
plotCmdsList[i].plot->xAxis->setRange(-plotVectorSize +1, 0);
2019-01-07 13:45:42 -06:00
plotCmdsList[i].plot->xAxis->setLabel("Time (s)");
2019-01-18 07:48:34 -06:00
plotCmdsList[i].plot->installEventFilter(this);
2019-01-07 13:45:42 -06:00
// Add the widget to the main layout
2019-01-18 07:48:34 -06:00
QWidget *widget = new PlotWidget(this);
plotCmdsList[i].widget = widget;
connect(plotCmdsList[i].widget, SIGNAL(leftPlot()), SLOT(clearPlots()));
2019-01-07 13:45:42 -06:00
plotCmdsList[i].widget->setLayout(plotCmdsList[i].layout);
plotCmdsList[i].layout->addWidget(plotCmdsList[i].plot);
plotLayout->addWidget(plotCmdsList[i].widget);
plotCmdsList[i].plot->setBackground(color);
plotCmdsList[i].plot->xAxis->setLabelColor(textColor);
plotCmdsList[i].plot->yAxis->setLabelColor(textColor);
plotCmdsList[i].plot->xAxis->setTickLabelColor(textColor);
plotCmdsList[i].plot->yAxis->setTickLabelColor(textColor);
plotCmdsList[i].plot->graph(0)->setPen(graphPen);
plotCmdsList[i].plot->xAxis->setTickPen(tickPen);
plotCmdsList[i].plot->yAxis->setTickPen(tickPen);
plotCmdsList[i].plot->xAxis->setSubTickPen(tickPen);
plotCmdsList[i].plot->yAxis->setSubTickPen(tickPen);
plotCmdsList[i].plot->xAxis->setBasePen(tickPen);
plotCmdsList[i].plot->yAxis->setBasePen(tickPen);
QCPTextElement *minelem = new QCPTextElement(plotCmdsList[i].plot);
plotCmdsList[i].mintext = minelem;
minelem->setText("Min: " + QString::number(plotCmdsList[i].valueq));
minelem->setTextColor(textColor);
QCPTextElement *maxelem = new QCPTextElement(plotCmdsList[i].plot);
plotCmdsList[i].maxtext = maxelem;
maxelem->setText("Max: " + QString::number(plotCmdsList[i].valueq));
maxelem->setTextColor(textColor);
2019-01-18 07:48:34 -06:00
QCPTextElement *curelem = new QCPTextElement(plotCmdsList[i].plot);
plotCmdsList[i].curtext = curelem;
curelem->setText("Cur: " + QString::number(plotCmdsList[i].valueq));
curelem->setTextColor(textColor);
plotCmdsList[i].plot->plotLayout()->insertRow(0);
QCPLayoutGrid *sublo = new QCPLayoutGrid;
plotCmdsList[i].plot->plotLayout()->addElement(0, 0, sublo);
sublo->setMargins(QMargins(5 ,5, 5, 5));
sublo->addElement(plotCmdsList[i].mintext);
sublo->addElement(plotCmdsList[i].maxtext);
2019-01-18 07:48:34 -06:00
sublo->addElement(plotCmdsList[i].curtext);
2019-01-10 08:30:52 -06:00
QCPItemText *text = new QCPItemText(plotCmdsList[i].plot);
text->setColor(textColor);
plotCmdsList[i].valText = text;
2019-01-07 13:45:42 -06:00
// Set the y-range
plotCmdsList[i].plot->yAxis->setRange(plotCmdsList[i].valueq -plotCmdsList[i].valueq*0.1, plotCmdsList[i].valueq + plotCmdsList[i].valueq*0.1);
// Add the tracers
QCPItemTracer *mouseTracer = new QCPItemTracer(plotCmdsList[i].plot);
plotCmdsList[i].tracer = mouseTracer;
mouseTracer->setStyle(QCPItemTracer::tsCrosshair);
QPen tracerPen = graphPen;
tracerPen.setWidthF(0.5);
mouseTracer->setPen(tracerPen);
connect(plotCmdsList[i].plot, SIGNAL(mouseMove(QMouseEvent*)), SLOT(plotHovered(QMouseEvent*)));
2019-01-10 08:30:52 -06:00
2019-01-18 07:48:34 -06:00
plotCmdsList[i].maxval = plotCmdsList[i].valueq;
plotCmdsList[i].minval = plotCmdsList[i].valueq;
2019-01-07 13:45:42 -06:00
}
2019-01-03 10:27:30 -06:00
2019-01-07 13:45:42 -06:00
tempPlot->yAxis->setLabel("Temperature (°C)");
powerDrawPlot->yAxis->setLabel("Power Draw (W)");
coreClkPlot->yAxis->setLabel("Core Clock Frequency (MHz)");
memClkPlot->yAxis->setLabel("Memory Clock Frequency (MHz)");
coreUtilPlot->yAxis->setLabel("Core Utilization (%)");
2019-01-07 19:02:36 -06:00
memUtilPlot->yAxis->setLabel("Memory Utilization (%)");
voltagePlot->yAxis->setLabel("Core Voltage (mV)");
fanSpeedPlot->yAxis->setLabel("Fan Speed (%)");
2019-01-03 10:27:30 -06:00
plotScrollArea->setWidget(plotWidget);
plotScrollArea->setWidgetResizable(true);
// Add scroll area to a layout so we can set it as the widget for the tab
lo->addWidget(plotScrollArea);
ui->monitorTab->setLayout(lo);
2019-01-07 19:02:36 -06:00
2019-01-10 08:30:52 -06:00
//connect(plotHoverUpdater, SIGNAL(timeout()), SLOT(plotHovered()));
2019-01-03 10:27:30 -06:00
}
2018-12-30 01:17:12 -06:00
void MainWindow::updateMonitor()
{
2019-01-18 07:48:34 -06:00
// This function takes around 300ms to complete, so it would be smoother to execute it in another thread
2018-12-30 01:17:12 -06:00
monitor mon;
2019-01-18 07:48:34 -06:00
//QThread *thread = new QThread(this);
//mon.moveToThread(thread);
//thread->start();
2018-12-30 01:17:12 -06:00
mon.queryValues();
fanSpeedUpdater();
2018-12-30 01:17:12 -06:00
gputemp->setText(1, mon.temp + "°C");
powerdraw->setText(1, mon.powerdraw + "W");
voltage->setText(1, mon.voltage + "mV");
2019-01-07 13:45:42 -06:00
coreclock->setText(1, mon.coreclock + " MHz");
memclock->setText(1, mon.memclock + " MHz");
coreutil->setText(1, mon.coreutil + " %");
2019-01-07 19:02:36 -06:00
memutil->setText(1, mon.memutil + " %");
2018-12-30 01:17:12 -06:00
fanspeed->setText(1, QString::number(fanSpeed) + " %");
memusage->setText(1, mon.usedmem + "/" + mon.totalmem);
2019-01-07 13:45:42 -06:00
// Decrement all time values by one
for (int i=0; i<qv_time.length(); i++) {
qv_time[i]--;
}
// Add current time (0)
if (qv_time.size() < plotVectorSize) {
2019-01-07 13:45:42 -06:00
qv_time.append(0);
} else {
qv_time.insert(plotVectorSize, 0);
2019-01-07 13:45:42 -06:00
}
// Remove the first elements if there are more elements than the x-range
if (qv_time.size() > plotVectorSize) {
2019-01-07 13:45:42 -06:00
qv_time.removeFirst();
}
// Update the values for plots
plotCmdsList[0].valueq = mon.temp.toDouble();
plotCmdsList[1].valueq = mon.powerdraw.toDouble();
plotCmdsList[2].valueq = mon.coreclock.toDouble();
plotCmdsList[3].valueq = mon.memclock.toDouble();
plotCmdsList[4].valueq = mon.coreutil.toDouble();
2019-01-07 19:02:36 -06:00
plotCmdsList[5].valueq = mon.memutil.toDouble();
plotCmdsList[6].valueq = mon.voltage.toDouble();
plotCmdsList[7].valueq = fanSpeed;
2019-01-18 07:48:34 -06:00
2019-01-07 13:45:42 -06:00
for (int i=0; i<plotCmdsList.size(); i++) {
// Check if the max/min values need to be updated
if (!plotCmdsList[i].vector.isEmpty()) {
2019-01-18 07:48:34 -06:00
plotCmdsList[i].curtext->setText("Cur: " + QString::number(plotCmdsList[i].valueq));
//double lowestval = plotCmdsList[i].vector[0];
//double largestval = plotCmdsList[i].vector[0];
2019-01-13 10:51:19 -06:00
/*for (int j=0; j<plotCmdsList[i].vector.size(); j++) {
if (plotCmdsList[i].vector[j] < lowestval) {
lowestval = plotCmdsList[i].vector[j];
}
if (plotCmdsList[i].vector[j] > largestval) {
largestval = plotCmdsList[i].vector[j];
}
2019-01-13 10:51:19 -06:00
}*/
2019-01-18 07:48:34 -06:00
if (plotCmdsList[i].maxval < plotCmdsList[i].valueq) {
plotCmdsList[i].maxtext->setText("Max: " + QString::number(plotCmdsList[i].valueq));
2019-01-18 07:48:34 -06:00
plotCmdsList[i].maxval = plotCmdsList[i].valueq;
}
2019-01-18 07:48:34 -06:00
if (plotCmdsList[i].minval > plotCmdsList[i].valueq) {
plotCmdsList[i].mintext->setText("Min: " + QString::number(plotCmdsList[i].valueq));
2019-01-18 07:48:34 -06:00
plotCmdsList[i].minval = plotCmdsList[i].valueq;
}
}
if (plotCmdsList[i].vector.size() < plotVectorSize) {
2019-01-07 13:45:42 -06:00
plotCmdsList[i].vector.append(plotCmdsList[i].valueq);
} else {
plotCmdsList[i].vector.insert(plotVectorSize, plotCmdsList[i].valueq);
2019-01-07 13:45:42 -06:00
}
// Remove the first element if there are more elements than the x-range
if (plotCmdsList[i].vector.size() > plotVectorSize) {
2019-01-07 13:45:42 -06:00
plotCmdsList[i].vector.removeFirst();
}
plotCmdsList[i].plot->graph(0)->setData(qv_time, plotCmdsList[i].vector);
// If the newest value is out of bounds, resize the y-range
if (plotCmdsList[i].valueq > plotCmdsList[i].plot->yAxis->range().upper) {
plotCmdsList[i].plot->yAxis->setRangeUpper(plotCmdsList[i].valueq + plotCmdsList[i].valueq*0.1);
}
if (plotCmdsList[i].valueq < plotCmdsList[i].plot->yAxis->range().lower) {
plotCmdsList[i].plot->yAxis->setRangeLower(plotCmdsList[i].valueq - plotCmdsList[i].valueq*0.1);
}
plotCmdsList[i].plot->replot();
plotCmdsList[i].plot->update();
2019-01-07 19:02:36 -06:00
}
2019-01-18 07:48:34 -06:00
//qDebug() << monitorUpdater->remainingTime();
2019-01-07 19:02:36 -06:00
// If the largest/smallest value is too far from the range end, this resizes them every 10th iteration of this function
2019-01-07 13:45:42 -06:00
if (counter >= 10) {
for (int i=0; i<plotCmdsList.size(); i++) {
double lowestval = plotCmdsList[i].vector[0];
double largestval = plotCmdsList[i].vector[0];
for (int j=0; j<plotCmdsList[i].vector.size(); j++) {
if (plotCmdsList[i].vector[j] < lowestval) {
lowestval = plotCmdsList[i].vector[j];
}
if (plotCmdsList[i].vector[j] > largestval) {
largestval = plotCmdsList[i].vector[j];
}
}
2019-01-18 07:48:34 -06:00
if (plotCmdsList[i].plot->yAxis->range().upper - largestval*0.1 > largestval) {
2019-01-07 13:45:42 -06:00
plotCmdsList[i].plot->yAxis->setRange(lowestval - lowestval*0.1, largestval + largestval*0.1);
}
2019-01-18 07:48:34 -06:00
if (plotCmdsList[i].plot->yAxis->range().lower + lowestval*0.1 < lowestval) {
2019-01-07 13:45:42 -06:00
// Don't set the lower range to under 0
if (lowestval - lowestval*0.1 < 0) {
plotCmdsList[i].plot->yAxis->setRangeLower(0);
} else {
plotCmdsList[i].plot->yAxis->setRange(lowestval - lowestval*0.1, largestval + largestval*0.1);
}
}
}
counter = 0;
}
counter++;
}
void MainWindow::plotHovered(QMouseEvent *event)
{
2019-01-07 19:02:36 -06:00
//plotHoverUpdater->start(1000);
2019-01-07 13:45:42 -06:00
QPoint cursor = event->pos();
//qDebug() << childAt(cursor);
//QWidget *widget = childAt(cursor);
//QCustomPlot *plot = widget->findChild<QCustomPlot*>(QString(), Qt::FindDirectChildrenOnly);
//plot->xAxis->setRange(-15, 0);
2019-01-07 19:02:36 -06:00
int plotIndex = 0;
for (int i=0; i<plotCmdsList.size(); i++) {
if (plotCmdsList[i].widget->underMouse()) {
plotIndex = i;
break;
}
}
double pointerxcoord = plotCmdsList[plotIndex].plot->xAxis->pixelToCoord(cursor.x());
2019-01-13 10:51:19 -06:00
//qDebug() << pointerxcoord << plotVectorSize;
plotCmdsList[plotIndex].tracer->position->setCoords(pointerxcoord, plotCmdsList[plotIndex].plot->yAxis->range().upper);
2019-01-07 19:02:36 -06:00
// Find the y-value for the corresponding coordinate
int valIndex = 0;
2019-01-10 08:30:52 -06:00
if (!qv_time.isEmpty() && pointerxcoord > -plotVectorSize*1.01 && pointerxcoord <= 0 + plotVectorSize*0.01) {
double deltax = abs(qv_time[0] - pointerxcoord);
for (int i=0; i<plotCmdsList[plotIndex].vector.size(); i++) {
if (abs(qv_time[i] - pointerxcoord) < deltax) {
2019-01-10 08:30:52 -06:00
deltax = abs(qv_time[i] - pointerxcoord);
valIndex = i;
}
}
2019-01-10 08:30:52 -06:00
//qDebug() << plotCmdsList[plotIndex].vector[valIndex];
//QCPItemText *text = new QCPItemText(plotCmdsList[plotIndex].plot);
plotCmdsList[plotIndex].valText->setText(QString::number(plotCmdsList[plotIndex].vector[valIndex]));
// Make the text stay inside the plot
if (pointerxcoord > -plotVectorSize*0.06) {
plotCmdsList[plotIndex].valText->position->setCoords(-plotVectorSize*0.06, plotCmdsList[plotIndex].plot->yAxis->range().upper - plotCmdsList[plotIndex].plot->yAxis->range().size()*0.05);
} else if (pointerxcoord < -plotVectorSize*0.94) {
plotCmdsList[plotIndex].valText->position->setCoords(-plotVectorSize*0.94, plotCmdsList[plotIndex].plot->yAxis->range().upper - plotCmdsList[plotIndex].plot->yAxis->range().size()*0.05);
} else {
plotCmdsList[plotIndex].valText->position->setCoords(pointerxcoord, plotCmdsList[plotIndex].plot->yAxis->range().upper - plotCmdsList[plotIndex].plot->yAxis->range().size()*0.05);
}
2019-01-18 07:48:34 -06:00
//QThread::msleep(10);
2019-01-10 08:30:52 -06:00
} else {
// If the cursor is not within the x-range, clear the text
plotCmdsList[plotIndex].valText->setText("");
}
plotCmdsList[plotIndex].plot->update();
plotCmdsList[plotIndex].plot->replot();
2018-12-30 01:17:12 -06:00
}
2019-01-18 07:48:34 -06:00
void MainWindow::clearPlots()
{
for (int i=0; i<plotCmdsList.size(); i++) {
plotCmdsList[i].valText->setText("");
plotCmdsList[i].tracer->position->setCoords(1, plotCmdsList[i].plot->yAxis->range().upper);
plotCmdsList[i].plot->replot();
plotCmdsList[i].plot->update();
}
}
void MainWindow::clearExtremeValues()
{
for (int i=0; i<plotCmdsList.size(); i++) {
plotCmdsList[i].minval = plotCmdsList[i].valueq;
plotCmdsList[i].maxval = plotCmdsList[i].valueq;
plotCmdsList[i].mintext->setText("Min: " + QString::number(plotCmdsList[i].valueq));
plotCmdsList[i].maxtext->setText("Max: " + QString::number(plotCmdsList[i].valueq));
}
}
void MainWindow::checkForProfiles()
{
// If there are no profiles, create one, then list all the entries whose isProfile is true in the profile selection combo box
QSettings settings("nvfancurve");
QStringList groups = settings.childGroups();
QString isProfile = "/isProfile";
for (int i=0; i<groups.length(); i++) {
// Make a query $profile/isProfile
QString group = groups[i];
QString query = group.append(isProfile);
if (settings.value(query).toBool()) {
noProfiles = false;
break;
}
}
if (noProfiles) {
settings.setValue("New Profile/isProfile", true);
2018-12-21 14:55:35 -06:00
settings.setValue("General/currentProfile", "New Profile");
currentProfile = "New Profile";
}
// Redefine child groups so it contains the newly created profile if it was made
QStringList newgroups = settings.childGroups();
for (int i=0; i<newgroups.length(); i++) {
// Make a query $profile/isProfile
QString group = newgroups[i];
QString query = group.append(isProfile);
if (settings.value(query).toBool()) {
ui->profileComboBox->addItem(newgroups[i]);
}
}
}
void MainWindow::on_profileComboBox_activated(const QString &arg1)
{
// Change currentProfile to combobox selection
currentProfile = arg1;
}
2018-12-21 14:55:35 -06:00
void MainWindow::getGPUDriver()
{
QProcess process;
process.start(queryForNvidiaProp);
process.waitForFinished(-1);
if (process.readAllStandardOutput().toInt() >= 1) {
gpuDriver = "nvidia";
}
}
2019-01-13 10:51:19 -06:00
void MainWindow::queryGPUs()
{
QProcess process;
process.start(nvGPUCountQ);
process.waitForFinished();
for (int i=0; i<process.readLine().toInt(); i++) {
process.start(nvUUIDQ + " -i " + QString::number(i));
process.waitForFinished();
2019-01-18 07:48:34 -06:00
QString UUID = process.readLine();
UUID.chop(1);
UUIDList.append(UUID);
2019-01-13 10:51:19 -06:00
process.start(queryGPUName + " -i " + QString::number(i));
process.waitForFinished();
QString GPUName = process.readLine();
GPUName.chop(1);
2019-01-18 07:48:34 -06:00
//ui->GPUComboBox->addItem("GPU-" + QString::number(i) + ": " + GPUName);
ui->GPUNameLabel->setText(GPUName);
2019-01-13 10:51:19 -06:00
}
}
2018-12-21 14:55:35 -06:00
void MainWindow::fanSpeedUpdater()
{
QProcess process;
process.start(nvFanQ);
process.waitForFinished(-1);
fanSpeed = process.readLine().toInt();
ui->fanSlider->setValue(fanSpeed);
ui->fanSpinBox->setValue(fanSpeed);
}
void MainWindow::tempUpdater()
{
QProcess process;
process.start(nvTempQ);
process.waitForFinished(-1);
temp = process.readLine().toInt();
if (xCurvePoints.size() != 0) {
generateFanPoint();
}
}
2018-12-22 11:11:45 -06:00
void MainWindow::resetTimer()
{
// If a value has been changed this timer will start. When the apply button has been pressed, this gets cancelled
connect(resettimer, SIGNAL(timeout()), SLOT(resetChanges()));
resettimer->stop();
resettimer->setSingleShot(true);
resettimer->start(10000);
}
void MainWindow::resetChanges()
{
// If the settings haven't been applied in 10 seconds, reset all values to their latest values
2018-12-30 01:17:12 -06:00
ui->frequencySlider->setValue(latestClkOfs);
ui->frequencySpinBox->setValue(latestClkOfs);
2018-12-22 11:11:45 -06:00
ui->powerLimSlider->setValue(latestPowerLim);
ui->powerLimSpinBox->setValue(latestPowerLim);
2018-12-24 12:42:36 -06:00
ui->voltageSlider->setValue(latestVoltOfs);
ui->voltageSpinBox->setValue(latestVoltOfs);
2018-12-22 11:11:45 -06:00
2018-12-30 01:17:12 -06:00
ui->memClkSlider->setValue(latestMemClkOfs);
ui->memClkSpinBox->setValue(latestMemClkOfs);
2018-12-22 11:11:45 -06:00
}
2018-12-24 12:42:36 -06:00
void MainWindow::queryDriverSettings()
{
QProcess process;
process.start(nvFanCtlStateQ);
process.waitForFinished(-1);
if (process.readLine().toInt() == 1) {
manualFanCtl = true;
ui->fanModeComboBox->setCurrentIndex(1);
} else {
manualFanCtl = false;
ui->fanModeComboBox->setCurrentIndex(0);
}
}
void MainWindow::applyFanMode()
{
QProcess process;
2018-12-30 01:17:12 -06:00
switch (fanControlMode) {
2018-12-24 12:42:36 -06:00
case 0:
// Driver controlled mode
process.start(nvFanCtlStateSet + "0");
process.waitForFinished(-1);
ui->fanSlider->setEnabled(false);
ui->fanSpinBox->setEnabled(false);
break;
case 1:
// Static mode
process.start(nvFanCtlStateSet + "1");
process.waitForFinished(-1);
disconnect(fanUpdateTimer, SIGNAL(timeout()), this, SLOT(tempUpdater()));
process.start(nvFanSpeedSet + QString::number(ui->fanSlider->value()));
process.waitForFinished(-1);
ui->fanSlider->setEnabled(true);
ui->fanSpinBox->setEnabled(true);
break;
case 2:
// Custom mode
process.start(nvFanCtlStateSet + "1");
process.waitForFinished(-1);
connect(fanUpdateTimer, SIGNAL(timeout()), this, SLOT(tempUpdater()));
ui->fanSlider->setEnabled(false);
ui->fanSpinBox->setEnabled(false);
break;
}
}
void MainWindow::queryGPUSettings()
{
QProcess process;
process.start(nvVoltQ);
process.waitForFinished(-1);
2018-12-22 11:11:45 -06:00
voltInt = process.readLine().toInt()/1000;
process.start(nvVoltOfsQ);
process.waitForFinished(-1);
2018-12-22 11:11:45 -06:00
voltOfsInt = process.readLine().toInt()/1000;
latestVoltOfs = voltOfsInt;
2018-12-21 14:55:35 -06:00
defVolt = voltInt - voltOfsInt;
process.start(nvVoltOfsLimQ);
process.waitForFinished(-1);
for (int i=0; i<process.size(); i++) {
if (process.readLine().toInt()/1000 > maxVoltOfsInt) {
maxVoltOfsInt = process.readLine().toInt()/1000;
}
}
process.start(nvCoreClkOfsQ);
process.waitForFinished(-1);
2018-12-22 14:30:14 -06:00
coreFreqOfsInt = process.readLine().toInt();
2018-12-22 11:11:45 -06:00
latestClkOfs = coreFreqOfsInt;
2018-12-21 14:55:35 -06:00
process.start(nvCurMaxClkQ);
process.waitForFinished(-1);
curMaxClkInt = process.readLine().toInt();
process.start(nvMaxPowerLimQ);
process.waitForFinished(-1);
2018-12-22 11:11:45 -06:00
maxPowerLimInt = process.readLine().toInt();
2018-12-21 14:55:35 -06:00
process.start(nvMinPowerLimQ);
process.waitForFinished(-1);
2018-12-22 11:11:45 -06:00
minPowerLimInt = process.readLine().toInt();
2018-12-21 14:55:35 -06:00
process.start(nvCurPowerLimQ);
process.waitForFinished(-1);
2018-12-22 11:11:45 -06:00
curPowerLimInt = process.readLine().toInt();
latestPowerLim = curPowerLimInt;
2018-12-21 14:55:35 -06:00
process.start(nvClockLimQ);
process.waitForFinished(-1);
2018-12-22 14:30:14 -06:00
for (int i=0; i<process.size(); i++) {
2018-12-21 14:55:35 -06:00
QString line = process.readLine();
2018-12-24 12:42:36 -06:00
if (line.toInt() > maxCoreClkOfsInt) {
maxCoreClkOfsInt = line.toInt();
2018-12-22 14:30:14 -06:00
}
2018-12-24 12:42:36 -06:00
if (line.toInt() <= minCoreClkOfsInt) {
minCoreClkOfsInt = line.toInt();
2018-12-21 14:55:35 -06:00
}
}
// This gets the transfer rate, the clock speed is rate/2
process.start(nvMemClkLimQ);
process.waitForFinished(-1);
2018-12-22 14:30:14 -06:00
for (int i=0; i<process.size(); i++) {
2018-12-21 14:55:35 -06:00
QString line = process.readLine();
2018-12-22 14:30:14 -06:00
if (line.toInt()/2 > maxMemClkOfsInt) {
2018-12-21 14:55:35 -06:00
maxMemClkOfsInt = line.toInt()/2;
}
2018-12-22 14:30:14 -06:00
if (line.toInt()/2 <= minMemClkOfsInt) {
minMemClkOfsInt = line.toInt()/2;
}
2018-12-21 14:55:35 -06:00
}
process.start(nvCurMaxMemClkQ);
process.waitForFinished(-1);
curMaxMemClkInt = process.readLine().toInt();
process.start(nvCurMemClkOfsQ);
process.waitForFinished(-1);
memClkOfsInt = process.readLine().toInt()/2;
2018-12-22 11:11:45 -06:00
latestMemClkOfs = memClkOfsInt;
2018-12-21 14:55:35 -06:00
// Since the maximum core clock reported is the same on negative offsets as on 0 offset add a check here
if (0 >= coreFreqOfsInt) {
defCoreClk = curMaxClkInt;
} else {
defCoreClk = curMaxClkInt - coreFreqOfsInt;
}
defMemClk = curMaxMemClkInt - memClkOfsInt;
2018-12-30 01:17:12 -06:00
2018-12-21 14:55:35 -06:00
}
void MainWindow::applyGPUSettings()
{
QProcess process;
2018-12-22 11:11:45 -06:00
int offsetValue;
int powerLimit;
2018-12-30 01:17:12 -06:00
bool hadErrors = false;
errorText = "Failed to apply these settings: ";
2018-12-21 14:55:35 -06:00
QString input = nvCoreClkSet;
2018-12-30 01:17:12 -06:00
if (latestClkOfs != ui->frequencySlider->value()) {
offsetValue = ui->frequencySlider->value();
2018-12-22 11:11:45 -06:00
QString input = nvCoreClkSet;
input.append(QString::number(offsetValue));
2018-12-21 14:55:35 -06:00
process.start(input);
process.waitForFinished(-1);
2018-12-30 01:17:12 -06:00
// Check if the setting got applied by querying nvidia-settings (very inefficient unfortunately)
process.start(nvCoreClkOfsQ);
process.waitForFinished();
if (process.readLine().toInt() == ui->frequencySlider->value()) {
latestClkOfs = ui->frequencySlider->value();
} else {
errorText.append("- Core Clock Offset ");
hadErrors = true;
}
2018-12-22 11:11:45 -06:00
}
2018-12-30 01:17:12 -06:00
if (latestMemClkOfs != ui->memClkSlider->value()) {
offsetValue = ui->memClkSlider->value();
2018-12-22 11:11:45 -06:00
input = nvMemClkSet;
input.append(QString::number(offsetValue*2));
2018-12-21 14:55:35 -06:00
process.start(input);
process.waitForFinished(-1);
2018-12-30 01:17:12 -06:00
process.start(nvCurMemClkOfsQ);
process.waitForFinished(-1);
if (process.readLine().toInt()/2 == ui->memClkSlider->value()) {
latestMemClkOfs = ui->memClkSlider->value();
} else {
errorText.append("- Memory Clock Offset");
hadErrors = true;
}
2018-12-21 14:55:35 -06:00
}
2018-12-22 11:11:45 -06:00
if (latestPowerLim != ui->powerLimSlider->value()) {
powerLimit = ui->powerLimSlider->value();
input = nvPowerLimSet;
if (!isRoot) {
2018-12-30 01:17:12 -06:00
input = "/bin/sh -c \"pkexec " + input + QString::number(powerLimit) + "\"";
2018-12-22 11:11:45 -06:00
process.start(input);
process.waitForFinished(-1);
2018-12-30 01:17:12 -06:00
if (process.exitCode() != 0) {
errorText.append("- Power Limit ");
hadErrors = true;
ui->powerLimSlider->setValue(latestPowerLim);
} else {
latestPowerLim = ui->powerLimSlider->value();
}
2018-12-22 11:11:45 -06:00
} else {
input.append(QString::number(powerLimit));
process.start(input);
process.waitForFinished(-1);
}
}
2018-12-24 12:42:36 -06:00
if (latestVoltOfs != ui->voltageSlider->value()) {
offsetValue = ui->voltageSlider->value();
2018-12-22 11:11:45 -06:00
input = nvVoltageSet;
input.append(QString::number(offsetValue*1000));
process.start(input);
process.waitForFinished(-1);
2018-12-30 01:17:12 -06:00
process.start(nvVoltOfsQ);
process.waitForFinished(-1);
if (process.readLine().toInt()/1000 == ui->voltageSlider->value()) {
latestVoltOfs = ui->voltageSlider->value();
} else {
errorText.append("- Voltage Offset");
hadErrors = true;
}
2018-12-22 11:11:45 -06:00
}
2018-12-30 01:17:12 -06:00
if (hadErrors) {
2019-01-10 08:30:52 -06:00
ui->statusBar->showMessage(errorText, 5000);
2018-12-30 01:17:12 -06:00
} else {
2019-01-10 08:30:52 -06:00
ui->statusBar->showMessage("Settings applied", 5000);
2018-12-30 01:17:12 -06:00
}
2018-12-22 11:11:45 -06:00
resettimer->stop();
2018-12-21 14:55:35 -06:00
}
2018-12-30 01:17:12 -06:00
2018-12-21 14:55:35 -06:00
void MainWindow::loadProfileSettings()
{
QSettings settings("nvfancurve");
currentProfile = settings.value("General/currentProfile").toString();
2019-01-18 07:48:34 -06:00
latestUUID = settings.value("General/latestUUID").toString();
2018-12-21 14:55:35 -06:00
settings.beginGroup(currentProfile);
2019-01-18 07:48:34 -06:00
settings.beginGroup(latestUUID);
2018-12-21 14:55:35 -06:00
// Check for existance of the setting so zeroes don't get appended to curve point vectors
if (settings.contains("xpoints")) {
2018-12-24 12:42:36 -06:00
QString xPointStr = "/bin/sh -c \"echo " + settings.value("xpoints").toString() + grepStringToInt;
2019-01-03 10:27:30 -06:00
QString yPointStr = "/bin/sh -c \"echo " + settings.value("ypoints").toString() + grepStringToInt;
2018-12-21 14:55:35 -06:00
QProcess process;
process.start(xPointStr);
process.waitForFinished(-1);
for (int i=0; i<process.size() +1; i++) {
xCurvePoints.append(process.readLine().toInt());
}
process.start(yPointStr);
process.waitForFinished(-1);
for (int i=0; i<process.size() +1; i++) {
yCurvePoints.append(process.readLine().toInt());
}
2018-12-24 12:42:36 -06:00
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(ui->fanModeComboBox->model());
QModelIndex customModeIndex = model->index(2, ui->fanModeComboBox->modelColumn());
QStandardItem *customMode = model->itemFromIndex(customModeIndex);
customMode->setEnabled(true);
customMode->setToolTip("Use your own fan curve");
} else {
// Set fan mode "Custom" unselectable if there are no custom curve points
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(ui->fanModeComboBox->model());
QModelIndex customModeIndex = model->index(2, ui->fanModeComboBox->modelColumn());
QStandardItem *customMode = model->itemFromIndex(customModeIndex);
customMode->setEnabled(false);
customMode->setToolTip("To use this mode you must make a fan curve first");
}
if (settings.contains("voltageOffset")) {
latestVoltOfs = settings.value("voltageOffset").toInt();
}
if (settings.contains("powerLimit")) {
latestPowerLim = settings.value("powerLimit").toInt();
2018-12-21 14:55:35 -06:00
}
2018-12-24 12:42:36 -06:00
if (settings.contains("clockFrequencyOffset")) {
latestClkOfs = settings.value("clockFrequencyOffset").toInt();
}
if (settings.contains("memoryClockOffset")) {
latestMemClkOfs=settings.value("memoryClockOffset").toInt();
}
2018-12-30 01:17:12 -06:00
if (settings.contains("fanControlMode")) {
fanControlMode = settings.value("fanControlMode").toInt();
ui->fanModeComboBox->setCurrentIndex(fanControlMode);
}
2019-01-18 07:48:34 -06:00
// Check which GPU index corresponds to the UUID and set the combo box selection to it
//ui->GPUComboBox->setCurrentIndex(UUIDList.indexOf(latestUUID));
2019-01-10 08:30:52 -06:00
ui->statusBar->showMessage("Profile settings loaded.", 7000);
}
2018-12-21 14:55:35 -06:00
void MainWindow::on_newProfile_closed()
{
2019-01-18 07:48:34 -06:00
// If currentProfile doesn't exist anymore the first profile will be the first entry
QSettings settings("nvfancurve");
QStringList groups = settings.childGroups();
if (!groups.contains(currentProfile)) {
for (int i=0; i<groups.size(); i++) {
settings.beginGroup(groups[i]);
if (settings.value("isProfile").toBool()) {
settings.endGroup();
currentProfile = groups[i];
break;
}
settings.endGroup();
2018-12-21 14:55:35 -06:00
}
}
2019-01-18 07:48:34 -06:00
//settings.endGroup();
settings.setValue("General/currentProfile", currentProfile);
ui->profileComboBox->clear();
//ui->GPUComboBox->clear();
checkForProfiles();
loadProfileSettings();
queryGPUs();
2018-12-21 14:55:35 -06:00
}
void MainWindow::saveProfileSettings()
{
2018-12-22 11:11:45 -06:00
QSettings settings("nvfancurve");
2019-01-18 07:48:34 -06:00
settings.beginGroup("General");
settings.setValue("latestUUID", UUIDList[0]);
settings.endGroup();
2018-12-22 11:11:45 -06:00
settings.beginGroup(currentProfile);
2019-01-18 07:48:34 -06:00
settings.beginGroup(UUIDList[0]);
2018-12-24 12:42:36 -06:00
settings.setValue("voltageOffset", latestVoltOfs);
settings.setValue("powerLimit", latestPowerLim);
settings.setValue("clockFrequencyOffset", latestClkOfs);
settings.setValue("memoryClockOffset", latestMemClkOfs);
2018-12-30 01:17:12 -06:00
settings.setValue("fanControlMode", fanControlMode);
2018-12-21 14:55:35 -06:00
}
void MainWindow::generateFanPoint()
{
// Calculate the value for fan speed based on temperature
// First check if the fan speed should be y[0] or y[final]
int index = 0;
if (temp <= xCurvePoints[0]) {
targetFanSpeed = yCurvePoints[0];
}
if (temp >= xCurvePoints[xCurvePoints.size()-1]) {
targetFanSpeed = yCurvePoints[yCurvePoints.size()-1];
} else {
// Get the index of the leftmost point of the interpolated interval by comparing it to temperature
for (int i=0; i<xCurvePoints.size(); i++) {
if (temp >= xCurvePoints[i] && temp <= xCurvePoints[i+1]) {
index = i;
break;
}
}
// Check if the change in x is zero to avoid dividing by it
if (xCurvePoints[index] - xCurvePoints[index + 1] == 0) {
targetFanSpeed = yCurvePoints[index+1];
} else {
targetFanSpeed = (((yCurvePoints[index + 1] - yCurvePoints[index]) * (temp - xCurvePoints[index])) / (xCurvePoints[index + 1] - xCurvePoints[index])) + yCurvePoints[index];
}
}
QProcess process;
QString input = nvFanSpeedSet;
input.append(QString::number(targetFanSpeed));
process.start(input);
process.waitForFinished(-1);
}
void MainWindow::on_frequencySlider_valueChanged(int value)
{
// Sets the input field value to slider value
QString freqText = QString::number(value);
ui->frequencySpinBox->setValue(value);
}
void MainWindow::on_frequencySpinBox_valueChanged(int arg1)
{
ui->frequencySlider->setValue(arg1);
}
2018-12-21 14:55:35 -06:00
void MainWindow::on_newProfile_clicked()
{
newProfile *newprof = new newProfile(this);
newprof->setAttribute(Qt::WA_DeleteOnClose);
connect(newprof, SIGNAL(destroyed(QObject*)), SLOT(on_newProfile_closed()));
newprof->setModal(true);
newprof->exec();
}
void MainWindow::on_powerLimSlider_valueChanged(int value)
{
ui->powerLimSpinBox->setValue(value);
}
void MainWindow::on_powerLimSpinBox_valueChanged(int arg1)
{
ui->powerLimSlider->setValue(arg1);
}
void MainWindow::on_memClkSlider_valueChanged(int value)
{
ui->memClkSpinBox->setValue(value);
}
void MainWindow::on_memClkSpinBox_valueChanged(int arg1)
{
ui->memClkSlider->setValue(arg1);
}
void MainWindow::on_voltageSlider_valueChanged(int value)
{
ui->voltageSpinBox->setValue(value);
}
void MainWindow::on_voltageSpinBox_valueChanged(int arg1)
{
ui->voltageSlider->setValue(arg1);
}
void MainWindow::on_fanSlider_valueChanged(int value)
{
ui->fanSpinBox->setValue(value);
2018-12-30 01:17:12 -06:00
fanUpdaterDisablerTimer->start(5000);
fanUpdaterDisablerTimer->setSingleShot(true);
disconnect(fanUpdateTimer, SIGNAL(timeout()), this, SLOT(fanSpeedUpdater()));
connect(fanUpdaterDisablerTimer, SIGNAL(timeout()), this, SLOT(enableFanUpdater()));
2018-12-21 14:55:35 -06:00
}
void MainWindow::on_fanSpinBox_valueChanged(int arg1)
{
ui->fanSlider->setValue(arg1);
}
2018-12-30 01:17:12 -06:00
void MainWindow::enableFanUpdater()
{
connect(fanUpdateTimer, SIGNAL(timeout()), this, SLOT(fanSpeedUpdater()));
}
2018-12-21 14:55:35 -06:00
void MainWindow::on_applyButton_clicked()
{
2019-01-18 07:48:34 -06:00
QSettings settings;
settings.beginGroup("General");
settings.setValue("currentProfile", currentProfile);
2018-12-21 14:55:35 -06:00
applyGPUSettings();
2018-12-24 12:42:36 -06:00
saveProfileSettings();
applyFanMode();
2018-12-30 01:17:12 -06:00
setupMonitorTab();
2018-12-21 14:55:35 -06:00
}
2018-12-24 12:42:36 -06:00
void MainWindow::on_editFanCurveButton_pressed()
2018-12-22 14:30:14 -06:00
{
2018-12-24 12:42:36 -06:00
editProfile *editProf = new editProfile(this);
editProf->setAttribute(Qt::WA_DeleteOnClose);
connect(editProf, SIGNAL(destroyed(QObject*)), SLOT(on_editProfile_closed()));
editProf->setModal(true);
editProf->exec();
2019-01-07 19:02:36 -06:00
2018-12-24 12:42:36 -06:00
}
void MainWindow::on_editProfile_closed()
{
// Clear the existing curve points and load the new ones
xCurvePoints.clear();
yCurvePoints.clear();
loadProfileSettings();
2018-12-22 14:30:14 -06:00
}
2018-12-30 01:17:12 -06:00
void MainWindow::on_fanModeComboBox_currentIndexChanged(int index)
{
fanControlMode = index;
}