Skip to content

Commit

Permalink
Remove createStartMenuShortcut function and its usage
Browse files Browse the repository at this point in the history
  • Loading branch information
nicola02nb committed Dec 12, 2024
1 parent 141fe31 commit cd1e2df
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 55 deletions.
1 change: 0 additions & 1 deletion src/UI/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ MainWindow::MainWindow(QWidget *parent)
qDebug();

QDir().mkpath(PROGRAM_CONFIG_PATH);
createStartMenuShortcut();
settings = loadSettingsFromFile(PROGRAM_SETTINGS_FILEPATH);
defaultStyle = styleSheet();

Expand Down
52 changes: 0 additions & 52 deletions src/Utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,55 +93,3 @@ 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
}
2 changes: 0 additions & 2 deletions src/Utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ bool openFileExplorer(const QString &path);

bool setOSRunOnStartup(bool enable);

bool createStartMenuShortcut();

#endif // UTILS_H

0 comments on commit cd1e2df

Please sign in to comment.