From 5dab713d83e4174499e55c7c5437843021ccb45d Mon Sep 17 00:00:00 2001 From: Odizinne Date: Sun, 15 Sep 2024 09:49:50 +0200 Subject: [PATCH] init shortcut variables inside functions --- src/ShortcutManager/shortcutmanager.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/ShortcutManager/shortcutmanager.cpp b/src/ShortcutManager/shortcutmanager.cpp index 964d97e..611f8c9 100644 --- a/src/ShortcutManager/shortcutmanager.cpp +++ b/src/ShortcutManager/shortcutmanager.cpp @@ -9,13 +9,13 @@ #include #ifdef _WIN32 -const QString shortcutName = "HeadsetControl-Qt.lnk"; -const QString applicationPath = QCoreApplication::applicationFilePath(); -const QString startupPath = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation) + QDir::separator() + "Startup"; -const QString shortcutPath = startupPath + QDir::separator() + shortcutName; - void manageShortcut(bool state) { + QString shortcutName = "HeadsetControl-Qt.lnk"; + QString applicationPath = QCoreApplication::applicationFilePath(); + QString startupPath = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation) + QDir::separator() + "Startup"; + QString shortcutPath = startupPath + QDir::separator() + shortcutName; + if (state) { QFile::link(applicationPath, shortcutPath); } else { @@ -25,6 +25,10 @@ void manageShortcut(bool state) bool isShortcutPresent() { + QString shortcutName = "HeadsetControl-Qt.lnk"; + QString startupPath = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation) + QDir::separator() + "Startup"; + QString shortcutPath = startupPath + QDir::separator() + shortcutName; + return QFile::exists(shortcutPath); }