Autoupdate config menu after config changes

This commit is contained in:
lupoDharkael
2017-07-31 22:41:08 +02:00
parent 3e7e6d1652
commit d9c6b603bb
9 changed files with 34 additions and 8 deletions

View File

@@ -22,10 +22,13 @@
#include "src/config/geneneralconf.h"
#include "src/config/filenameeditor.h"
#include "src/config/strftimechooserwidget.h"
#include "src/utils/confighandler.h"
#include <QIcon>
#include <QVBoxLayout>
#include <QLabel>
#include <QKeyEvent>
#include <QFileSystemWatcher>
#include <QDebug>
// ConfigWindow contains the menus where you can configure the application
@@ -35,6 +38,19 @@ ConfigWindow::ConfigWindow(QWidget *parent) : QTabWidget(parent) {
setWindowIcon(QIcon(":img/flameshot.png"));
setWindowTitle(tr("Configuration"));
auto changedSlot = [this](QString s){
Q_UNUSED(s);
this->m_configWatcher->removePath(s);
this->m_configWatcher->addPath(s);
if(!this->hasFocus()) {
Q_EMIT updateComponents();
}
};
m_configWatcher = new QFileSystemWatcher(this);
m_configWatcher->addPath(ConfigHandler().getConfigFilePath());
connect(m_configWatcher, &QFileSystemWatcher::fileChanged,
this, changedSlot);
QColor background = this->palette().background().color();
bool isWhite = CaptureButton::iconIsWhiteByColor(background);
QString modifier = isWhite ? ":img/configWhite/" : ":img/configBlack/";