buttonmanager Ctrl+S

This commit is contained in:
mrbesen 2021-12-25 15:04:00 +01:00
parent 018ff05990
commit c8ce6cc0d1
Signed by untrusted user: MrBesen
GPG Key ID: 596B2350DCD67504
2 changed files with 14 additions and 9 deletions

View File

@ -36,6 +36,7 @@ private slots:
void itemChanged(QTreeWidgetItem* item, int column);
void itemDoubleClicked(QTreeWidgetItem* item);
void dialogButtonPressed(QAbstractButton* btn);
void saveChanges();
private:
Ui::ButtonManager *ui;
@ -45,7 +46,6 @@ private:
Config::RootConfig workingConfig;
void loadConfig();
void saveChanges();
void select(QTreeWidgetItem* item);

View File

@ -6,6 +6,7 @@
#include "sound.h"
#include <QFileDialog>
#include <QShortcut>
#include <Log.h>
@ -21,6 +22,10 @@ ButtonManager::ButtonManager(Config& conf, MainWindow* parent) : QDialog(parent)
labels.push_back("File");
ui->buttonTreeWidget->setHeaderLabels(labels);
QShortcut* sc = new QShortcut(QKeySequence(QKeySequence::Save), this);
QObject::connect(sc, SIGNAL( activated() ), this, SLOT( saveChanges() ));
}
ButtonManager::~ButtonManager() {
@ -203,6 +208,14 @@ void ButtonManager::dialogButtonPressed(QAbstractButton* btn) {
}
}
void ButtonManager::saveChanges() {
// store working config to main config and save
mainConfig.rootConfig = workingConfig;
mainConfig.save();
mainW->reloadButtonConfig();
}
void ButtonManager::loadConfig() {
workingConfig = mainConfig.rootConfig;
@ -218,14 +231,6 @@ void ButtonManager::loadConfig() {
}
}
void ButtonManager::saveChanges() {
// store working config to main config and save
mainConfig.rootConfig = workingConfig;
mainConfig.save();
mainW->reloadButtonConfig();
}
void ButtonManager::select(QTreeWidgetItem* item) {
QList<QTreeWidgetItem*> selected = ui->buttonTreeWidget->selectedItems();
for(QTreeWidgetItem* selectedItem : selected) {