Input settings WIP

This commit is contained in:
Simone
2024-01-24 10:06:04 +01:00
parent 4d76f66faa
commit ef49954f41
7 changed files with 257 additions and 37 deletions

View File

@@ -14,10 +14,13 @@ SettingsWindow::SettingsWindow() : QWidget(nullptr) {
cpuSettings = new CPUSettings(settings);
audioSettings = new AudioSettings(settings);
inputSettings = new InputSettings(settings);
keyMap = inputSettings->GetMappedKeys();
auto* tabs = new QTabWidget;
tabs->addTab(cpuSettings, tr("CPU"));
tabs->addTab(audioSettings, tr("Audio"));
tabs->addTab(inputSettings, tr("Input"));
apply->setEnabled(false);
@@ -29,7 +32,16 @@ SettingsWindow::SettingsWindow() : QWidget(nullptr) {
apply->setEnabled(true);
});
connect(inputSettings, &InputSettings::modified, this, [&]() {
apply->setEnabled(true);
});
connect(apply, &QPushButton::pressed, this, [&]() {
auto newMap = inputSettings->GetMappedKeys();
if (!std::equal(keyMap.begin(), keyMap.end(), newMap.begin(), newMap.end())) {
keyMap = newMap;
emit regrabKeyboard();
}
apply->setEnabled(false);
std::ofstream file("resources/settings.json");
file << settings;