diff --git a/src/gui/Window.qml b/src/gui/Window.qml index 66df915c..3887b98c 100644 --- a/src/gui/Window.qml +++ b/src/gui/Window.qml @@ -3,6 +3,7 @@ import QtQuick 2.12 import QtQuick.Controls 2.12 import Qt.labs.platform 1.1 +import Qt.labs.folderlistmodel 2.12 import "Base" import "PythonBridge" @@ -23,7 +24,7 @@ ApplicationWindow { property var uiState: ({}) property var history: ({}) property var theme: null - property bool closing: false + property string configDir readonly property var visibleMenus: ({}) readonly property var visiblePopups: ({}) @@ -142,4 +143,21 @@ ApplicationWindow { } } } + + FolderListModel { + id: showUpWatcher + folder: window.configDir + showDirs: false + showHidden: true + nameFilters: [".show"] + + onCountChanged: { + if (count) { + window.drawAttention() + py.importModule("os", () => { + py.call("os.remove", [get(0, "filePath")]) + }) + } + } + } } diff --git a/src/main.cpp b/src/main.cpp index fddfbeaa..12edee29 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -93,14 +93,9 @@ void onExitSignal(int signum) { } -bool setLockFile() { - QString customConfigDir(qEnvironmentVariable("MIRAGE_CONFIG_DIR")); - QDir configDir( - customConfigDir.isEmpty() ? - QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) - + "/" + QCoreApplication::applicationName() : - customConfigDir - ); +bool setLockFile(QString configPath) { + + QDir configDir(configPath); if (! configDir.mkpath(".")) { qFatal("Could not create config file."); @@ -139,7 +134,15 @@ int main(int argc, char *argv[]) { QApplication::setApplicationVersion("0.6.2"); QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - if (! setLockFile()) return EXIT_SUCCESS; + QString customConfigDir(qEnvironmentVariable("MIRAGE_CONFIG_DIR")); + QString configDir( + customConfigDir.isEmpty() ? + QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + + "/" + QCoreApplication::applicationName() : + customConfigDir + ); + + if (! setLockFile(configDir)) return EXIT_SUCCESS; QApplication app(argc, argv); // Register handlers for quit signals, e.g. SIGINT/Ctrl-C in unix terminals @@ -243,7 +246,7 @@ int main(int argc, char *argv[]) { app.exit(EXIT_FAILURE); } - component.create(objectContext); + component.create(objectContext)->setProperty("configDir", configDir); // Finally, execute the app. Return its exit code after clearing the lock. int exit_code = app.exec();