void MainWindow::setAutostart(bool autostart)
{
#ifdef Q_OS_WIN32
QSettings reg("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run",
QSettings::NativeFormat);
if (autostart) {
QString app_fname = QString("\"%1\"").arg( QCoreApplication::applicationFilePath() );
app_fname.replace("/", "\\");
reg.setValue(QCoreApplication::applicationName(), app_fname);
}
else {
reg.remove(QCoreApplication::applicationName());
}
reg.sync();
#else
// this is for Linux
QString app_fname = QFileInfo(QCoreApplication::applicationFilePath()).baseName();
QString lnk(QDir::homePath()+"/.config/autostart/"+"goldendict.desktop");
if (autostart) {
QFile f("/usr/share/applications/goldendict.desktop");
f.link(lnk);
} else {
QFile::remove(lnk);
}
#endif
}
Users browsing this forum: No registered users and 1 guest