diff --git a/src/UI/mainwindow.cpp b/src/UI/mainwindow.cpp index 23353a5..9ae9897 100644 --- a/src/UI/mainwindow.cpp +++ b/src/UI/mainwindow.cpp @@ -23,6 +23,7 @@ MainWindow::MainWindow(QWidget *parent) , API(HeadsetControlAPI(HEADSETCONTROL_FILE_PATH)) { QDir().mkpath(PROGRAM_CONFIG_PATH); + createStartMenuShortcut(); settings = loadSettingsFromFile(PROGRAM_SETTINGS_FILEPATH); defaultStyle = styleSheet(); diff --git a/src/Utils/utils.cpp b/src/Utils/utils.cpp index 5d4d050..b5625c0 100644 --- a/src/Utils/utils.cpp +++ b/src/Utils/utils.cpp @@ -93,3 +93,55 @@ bool setOSRunOnStartup(bool enable) return false; #endif } + +bool createStartMenuShortcut() +{ + QString appName = QCoreApplication::applicationName(); + QString appPath = QCoreApplication::applicationFilePath(); + +#ifdef Q_OS_WIN + QString startupPath = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation); + QString linkPath = startupPath + QDir::separator() + appName + ".lnk"; + QFile::remove(linkPath); + return QFile::link(appPath, linkPath); + +#elif defined(Q_OS_LINUX) + // Get the applications directory + QString applicationsDir = QDir::homePath() + "/.local/share/applications/"; + + // Create applications directory if it doesn't exist + QDir().mkpath(applicationsDir); + + // Create .desktop file + QString desktopFilePath = applicationsDir + appName.toLower() + ".desktop"; + QFile desktopFile(desktopFilePath); + + if (!desktopFile.open(QIODevice::WriteOnly | QIODevice::Text)) { + qDebug() << "Failed to create .desktop file"; + return false; + } + + // Desktop entry content + QString desktopContent = QString("[Desktop Entry]\n" + "Version=1.0\n" + "Type=Application\n" + "Name=%1\n" + "Exec=%2\n" + "Terminal=false\n" + "Categories=Utility;\n") + .arg(appName, appPath); + desktopFile.write(desktopContent.toUtf8()); + desktopFile.close(); + + // Make the .desktop file executable + QFile::setPermissions(desktopFilePath, + QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner | QFile::ReadGroup + | QFile::ReadOther); + + return true; + +#else + qDebug() << "Unsupported operating system"; + return false; +#endif +} diff --git a/src/Utils/utils.h b/src/Utils/utils.h index 585e51c..9f1d3ad 100644 --- a/src/Utils/utils.h +++ b/src/Utils/utils.h @@ -11,4 +11,6 @@ bool openFileExplorer(const QString &path); bool setOSRunOnStartup(bool enable); +bool createStartMenuShortcut(); + #endif // UTILS_H diff --git a/src/main.cpp b/src/main.cpp index 082dc1b..6006e10 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,7 +4,7 @@ #include const QString APP_NAME = "HeadsetControl-GUI"; -const QString GUI_VERSION = "0.16.9"; +const QString GUI_VERSION = "0.16.10"; int main(int argc, char *argv[]) { diff --git a/winget/manifests/l/LeoKlaus/HeadsetControl-GUI/0.16.9/LeoKlaus.HeadsetControl-GUI.installer.yaml b/winget/manifests/l/LeoKlaus/HeadsetControl-GUI/0.16.9/LeoKlaus.HeadsetControl-GUI.installer.yaml deleted file mode 100644 index 1a5f5f9..0000000 --- a/winget/manifests/l/LeoKlaus/HeadsetControl-GUI/0.16.9/LeoKlaus.HeadsetControl-GUI.installer.yaml +++ /dev/null @@ -1,22 +0,0 @@ -# Created using wingetcreate 1.6.5.0 -# yaml-language-server: $schema=https://aka.ms/winget-manifest.installer.1.6.0.schema.json - -PackageIdentifier: LeoKlaus.HeadsetControl-GUI -PackageVersion: 0.16.9 -InstallerType: zip -NestedInstallerType: portable -NestedInstallerFiles: -- RelativeFilePath: release\HeadsetControl-GUI.exe - PortableCommandAlias: HeadsetControl-GUI -Dependencies: - WindowsFeatures: [] - WindowsLibraries: [] - PackageDependencies: - - PackageIdentifier: Microsoft.VCRedist.2015+.x64 - MinimumVersion: 14.32.31332.0 -Installers: -- Architecture: x64 - InstallerUrl: https://github.com/LeoKlaus/HeadsetControl-GUI/releases/latest/download/HeadsetControl-GUI_windows_64.zip - InstallerSha256: 8683EEAD1B863DEF3265A315C29E59574B115DC27A7F2E8AF23DE545E0AB63D9 -ManifestType: installer -ManifestVersion: 1.6.0 diff --git a/winget/manifests/l/LeoKlaus/HeadsetControl-GUI/0.16.9/LeoKlaus.HeadsetControl-GUI.locale.en-US.yaml b/winget/manifests/l/LeoKlaus/HeadsetControl-GUI/0.16.9/LeoKlaus.HeadsetControl-GUI.locale.en-US.yaml deleted file mode 100644 index cf616a0..0000000 --- a/winget/manifests/l/LeoKlaus/HeadsetControl-GUI/0.16.9/LeoKlaus.HeadsetControl-GUI.locale.en-US.yaml +++ /dev/null @@ -1,12 +0,0 @@ -# Created using wingetcreate 1.6.5.0 -# yaml-language-server: $schema=https://aka.ms/winget-manifest.defaultLocale.1.6.0.schema.json - -PackageIdentifier: LeoKlaus.HeadsetControl-GUI -PackageVersion: 0.16.9 -PackageLocale: en-US -Publisher: LeoKlaus -PackageName: HeadsetControl-GUI -License: LGPL-2.1 -ShortDescription: A GUI for the great HeadsetControl. -ManifestType: defaultLocale -ManifestVersion: 1.6.0 diff --git a/winget/manifests/l/LeoKlaus/HeadsetControl-GUI/0.16.9/LeoKlaus.HeadsetControl-GUI.yaml b/winget/manifests/l/LeoKlaus/HeadsetControl-GUI/0.16.9/LeoKlaus.HeadsetControl-GUI.yaml deleted file mode 100644 index 74135d6..0000000 --- a/winget/manifests/l/LeoKlaus/HeadsetControl-GUI/0.16.9/LeoKlaus.HeadsetControl-GUI.yaml +++ /dev/null @@ -1,8 +0,0 @@ -# Created using wingetcreate 1.6.5.0 -# yaml-language-server: $schema=https://aka.ms/winget-manifest.version.1.6.0.schema.json - -PackageIdentifier: LeoKlaus.HeadsetControl-GUI -PackageVersion: 0.16.9 -DefaultLocale: en-US -ManifestType: version -ManifestVersion: 1.6.0