mirror of
https://github.com/quickshell-mirror/quickshell.git
synced 2026-11-04 03:36:32 +00:00
refactor: move settings to their own object
This commit is contained in:
8 files changed
+107
-78
No files matched your search
@@ -27,6 +27,10 @@ RootWrapper::RootWrapper(QString rootPath)
|
||||
QObject::connect(&this->engine, &QQmlEngine::quit, app, &QCoreApplication::quit);
|
||||
QObject::connect(&this->engine, &QQmlEngine::exit, app, &QCoreApplication::exit);
|
||||
|
||||
// clang-format off
|
||||
QObject::connect(QuickshellSettings::instance(), &QuickshellSettings::watchFilesChanged, this, &RootWrapper::onWatchFilesChanged);
|
||||
// clang-format on
|
||||
|
||||
this->reloadGraph(true);
|
||||
|
||||
if (this->root == nullptr) {
|
||||
@@ -37,13 +41,12 @@ RootWrapper::RootWrapper(QString rootPath)
|
||||
|
||||
RootWrapper::~RootWrapper() {
|
||||
// event loop may no longer be running so deleteLater is not an option
|
||||
QuickshellGlobal::deleteInstance();
|
||||
delete this->root;
|
||||
}
|
||||
|
||||
void RootWrapper::reloadGraph(bool hard) {
|
||||
if (this->root != nullptr) {
|
||||
QuickshellGlobal::deleteInstance();
|
||||
QuickshellSettings::reset();
|
||||
this->engine.clearComponentCache();
|
||||
}
|
||||
|
||||
@@ -87,25 +90,23 @@ void RootWrapper::reloadGraph(bool hard) {
|
||||
QuickshellPlugin::runOnReload();
|
||||
}
|
||||
|
||||
this->onConfigChanged();
|
||||
this->onWatchFilesChanged();
|
||||
}
|
||||
|
||||
void RootWrapper::onConfigChanged() {
|
||||
auto config = this->root->config();
|
||||
void RootWrapper::onWatchFilesChanged() {
|
||||
auto watchFiles = QuickshellSettings::instance()->watchFiles();
|
||||
|
||||
if (config.mWatchFiles && this->configWatcher == nullptr) {
|
||||
if (watchFiles && this->configWatcher == nullptr) {
|
||||
this->configWatcher = new FiletreeWatcher();
|
||||
this->configWatcher->addPath(QFileInfo(this->rootPath).dir().path());
|
||||
|
||||
QObject::connect(this->root, &ShellRoot::configChanged, this, &RootWrapper::onConfigChanged);
|
||||
|
||||
QObject::connect(
|
||||
this->configWatcher,
|
||||
&FiletreeWatcher::fileChanged,
|
||||
this,
|
||||
&RootWrapper::onWatchedFilesChanged
|
||||
);
|
||||
} else if (!config.mWatchFiles && this->configWatcher != nullptr) {
|
||||
} else if (!watchFiles && this->configWatcher != nullptr) {
|
||||
this->configWatcher->deleteLater();
|
||||
this->configWatcher = nullptr;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user