Add watcher for .show file in config directory
Draw attention when the .show file is created. It is created when attempting to open another instance of Mirage with the same configuration.
This commit is contained in:
parent
56ad0b9975
commit
9ee4b14aa2
@ -3,6 +3,7 @@
|
|||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
import QtQuick.Controls 2.12
|
import QtQuick.Controls 2.12
|
||||||
import Qt.labs.platform 1.1
|
import Qt.labs.platform 1.1
|
||||||
|
import Qt.labs.folderlistmodel 2.12
|
||||||
import "Base"
|
import "Base"
|
||||||
import "PythonBridge"
|
import "PythonBridge"
|
||||||
|
|
||||||
@ -23,7 +24,7 @@ ApplicationWindow {
|
|||||||
property var uiState: ({})
|
property var uiState: ({})
|
||||||
property var history: ({})
|
property var history: ({})
|
||||||
property var theme: null
|
property var theme: null
|
||||||
property bool closing: false
|
property string configDir
|
||||||
|
|
||||||
readonly property var visibleMenus: ({})
|
readonly property var visibleMenus: ({})
|
||||||
readonly property var visiblePopups: ({})
|
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")])
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
23
src/main.cpp
23
src/main.cpp
@ -93,14 +93,9 @@ void onExitSignal(int signum) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool setLockFile() {
|
bool setLockFile(QString configPath) {
|
||||||
QString customConfigDir(qEnvironmentVariable("MIRAGE_CONFIG_DIR"));
|
|
||||||
QDir configDir(
|
QDir configDir(configPath);
|
||||||
customConfigDir.isEmpty() ?
|
|
||||||
QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation)
|
|
||||||
+ "/" + QCoreApplication::applicationName() :
|
|
||||||
customConfigDir
|
|
||||||
);
|
|
||||||
|
|
||||||
if (! configDir.mkpath(".")) {
|
if (! configDir.mkpath(".")) {
|
||||||
qFatal("Could not create config file.");
|
qFatal("Could not create config file.");
|
||||||
@ -139,7 +134,15 @@ int main(int argc, char *argv[]) {
|
|||||||
QApplication::setApplicationVersion("0.6.2");
|
QApplication::setApplicationVersion("0.6.2");
|
||||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
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);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
// Register handlers for quit signals, e.g. SIGINT/Ctrl-C in unix terminals
|
// 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);
|
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.
|
// Finally, execute the app. Return its exit code after clearing the lock.
|
||||||
int exit_code = app.exec();
|
int exit_code = app.exec();
|
||||||
|
Loading…
Reference in New Issue
Block a user