Add project files
This commit is contained in:
parent
792005520d
commit
9a5a7d5564
|
@ -0,0 +1,140 @@
|
|||
### C++ template
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
*.smod
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
*.lib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
|
||||
### C template
|
||||
# Prerequisites
|
||||
|
||||
# Object files
|
||||
*.ko
|
||||
*.elf
|
||||
|
||||
# Linker output
|
||||
*.ilk
|
||||
*.map
|
||||
*.exp
|
||||
|
||||
# Precompiled Headers
|
||||
|
||||
# Libraries
|
||||
|
||||
# Shared objects (inc. Windows DLLs)
|
||||
*.so.*
|
||||
|
||||
# Executables
|
||||
*.i*86
|
||||
*.x86_64
|
||||
*.hex
|
||||
|
||||
# Debug files
|
||||
*.dSYM/
|
||||
*.su
|
||||
*.idb
|
||||
*.pdb
|
||||
|
||||
# Kernel Module Compile Results
|
||||
*.mod*
|
||||
*.cmd
|
||||
.tmp_versions/
|
||||
modules.order
|
||||
Module.symvers
|
||||
Mkfile.old
|
||||
dkms.conf
|
||||
|
||||
### Qt template
|
||||
# C++ objects and libs
|
||||
|
||||
# Qt-es
|
||||
object_script.*.Release
|
||||
object_script.*.Debug
|
||||
*_plugin_import.cpp
|
||||
/.qmake.cache
|
||||
/.qmake.stash
|
||||
*.pro.user
|
||||
*.pro.user.*
|
||||
*.qbs.user
|
||||
*.qbs.user.*
|
||||
*.moc
|
||||
moc_*.cpp
|
||||
moc_*.h
|
||||
qrc_*.cpp
|
||||
ui_*.h
|
||||
*.qmlc
|
||||
*.jsc
|
||||
Makefile*
|
||||
*build-*
|
||||
*.qm
|
||||
*.prl
|
||||
|
||||
# Qt unit tests
|
||||
target_wrapper.*
|
||||
|
||||
# QtCreator
|
||||
*.autosave
|
||||
|
||||
# QtCreator Qml
|
||||
*.qmlproject.user
|
||||
*.qmlproject.user.*
|
||||
|
||||
# QtCreator CMake
|
||||
CMakeLists.txt.user*
|
||||
|
||||
# QtCreator 4.8< compilation database
|
||||
compile_commands.json
|
||||
|
||||
# QtCreator local machine specific files for imported projects
|
||||
*creator.user*
|
||||
|
||||
*_qmlcache.qrc
|
||||
|
||||
### CMake template
|
||||
CMakeLists.txt.user
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
CMakeScripts
|
||||
Testing
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
CTestTestfile.cmake
|
||||
_deps
|
||||
cmake-build*
|
||||
|
||||
### Example user template template
|
||||
### Example user template
|
||||
|
||||
# IntelliJ project files
|
||||
.idea
|
||||
*.iml
|
||||
out
|
||||
gen
|
|
@ -0,0 +1,26 @@
|
|||
cmake_minimum_required(VERSION 3.27)
|
||||
project(nvidia_profiles)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
|
||||
|
||||
find_package(Qt5 COMPONENTS
|
||||
Core
|
||||
Gui
|
||||
Widgets
|
||||
REQUIRED)
|
||||
|
||||
add_executable(nvidia_profiles src/main.cpp
|
||||
src/interfaces.h
|
||||
src/ui/MainWindow.cpp
|
||||
src/ui/MainWindow.h
|
||||
src/ui/MainWindow.ui)
|
||||
target_link_libraries(nvidia_profiles
|
||||
Qt5::Core
|
||||
Qt5::Gui
|
||||
Qt5::Widgets
|
||||
)
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
//
|
||||
// Created by nicolas on 18/11/23.
|
||||
//
|
||||
#ifndef INTERFACES_H
|
||||
#define INTERFACES_H
|
||||
|
||||
#include <qstring.h>
|
||||
|
||||
struct PerformanceProfile {
|
||||
QString name;
|
||||
int minFrequency;
|
||||
int maxFrequency;
|
||||
};
|
||||
|
||||
#endif //INTERFACES_H
|
|
@ -0,0 +1,11 @@
|
|||
#include <QApplication>
|
||||
#include "ui/MainWindow.h"
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
QApplication a(argc, argv);
|
||||
|
||||
MainWindow window;
|
||||
window.show();
|
||||
|
||||
return QApplication::exec();
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
//
|
||||
// Created by nicolas on 17/11/23.
|
||||
//
|
||||
|
||||
// You may need to build the project (run Qt uic code generator) to get "ui_MainWindow.h" resolved
|
||||
|
||||
#include <QProcess>
|
||||
#include <QMessageBox>
|
||||
#include <ui_MainWindow.h>
|
||||
#include "MainWindow.h"
|
||||
#include "../interfaces.h"
|
||||
|
||||
MainWindow::MainWindow(QMainWindow *parent) :
|
||||
QMainWindow(parent), ui(new Ui::MainWindow), items(new QList<PerformanceProfile>) {
|
||||
ui->setupUi(this);
|
||||
|
||||
// Initialize porfiles combo box
|
||||
initProfilesList();
|
||||
|
||||
// Connect combo box
|
||||
//connect(ui->profilesComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &MainWindow::onSelectionChange);
|
||||
|
||||
// Connect buttons
|
||||
connect(ui->confirmBtn, &QPushButton::clicked, this, &MainWindow::onConfirm);
|
||||
connect(ui->cancelBtn, &QPushButton::clicked, this, &MainWindow::onCancel);
|
||||
|
||||
// Set window title
|
||||
this->setWindowTitle("Nvidia Settings");
|
||||
}
|
||||
|
||||
void MainWindow::initProfilesList() {
|
||||
// Generate items
|
||||
items->append({ "Eco", 210, 1600});
|
||||
items->append({"Low", 210, 1650});
|
||||
items->append({ "Normal", 210, 1710 });
|
||||
items->append({ "High", 210, 1800 });
|
||||
items->append({ "Extreme", 210, 1905 });
|
||||
|
||||
// Add items to combo box
|
||||
for (const PerformanceProfile& item : *items) {
|
||||
ui->profilesComboBox->addItem(item.name + " \t [" + QString::number(item.maxFrequency) + " MHz]");
|
||||
}
|
||||
// Set selected item
|
||||
ui->profilesComboBox->setCurrentIndex(2);
|
||||
}
|
||||
|
||||
int MainWindow::setPerformanceProfile(const PerformanceProfile *profile) {
|
||||
const QString frequencies = QString::number(profile->minFrequency) + "," + QString::number(profile->maxFrequency);
|
||||
return QProcess::execute("/usr/bin/sudo", QStringList() << "nvidia-smi" << "-lgc" << frequencies);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
delete ui;
|
||||
delete items;
|
||||
}
|
||||
|
||||
void MainWindow::onConfirm() {
|
||||
const PerformanceProfile profile = items->at(ui->profilesComboBox->currentIndex());
|
||||
if (setPerformanceProfile(&profile) != 0) {
|
||||
QMessageBox::critical(this, "Error", "Unable to update Nvidia GPU clocks !");
|
||||
}
|
||||
QApplication::exit();
|
||||
}
|
||||
|
||||
void MainWindow::onCancel() {
|
||||
this->close();
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
//
|
||||
// Created by nicolas on 17/11/23.
|
||||
//
|
||||
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include "../interfaces.h"
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class MainWindow; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class MainWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QMainWindow *parent = nullptr);
|
||||
~MainWindow() override;
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
QList<PerformanceProfile> *items;
|
||||
void onConfirm();
|
||||
void onCancel();
|
||||
void initProfilesList();
|
||||
static int setPerformanceProfile(const PerformanceProfile *profile);
|
||||
};
|
||||
|
||||
|
||||
#endif //MAINWINDOW_H
|
|
@ -0,0 +1,141 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>425</width>
|
||||
<height>145</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>425</width>
|
||||
<height>145</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>425</width>
|
||||
<height>145</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>15</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item alignment="Qt::AlignVCenter">
|
||||
<widget class="QWidget" name="content" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Performance profile:</string>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="indent">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="profilesComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="footer" native="true">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item alignment="Qt::AlignRight|Qt::AlignVCenter">
|
||||
<widget class="QWidget" name="buttons" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="spacing">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cancelBtn">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: #666666;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Ignore</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="confirmBtn">
|
||||
<property name="text">
|
||||
<string>Let's Play!</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in New Issue