testing new feature with autostart backup option
This commit is contained in:
parent
e23cbe67ad
commit
5d3a122ebf
2 changed files with 47 additions and 0 deletions
|
|
@ -140,6 +140,12 @@ void SettingsController::restoreAppConfigFromData(const QByteArray &data)
|
|||
{
|
||||
bool ok = m_settings->restoreAppConfig(data);
|
||||
if (ok) {
|
||||
#if defined(Q_OS_WINDOWS) || defined(Q_OS_LINUX) || defined(Q_OS_MACX)
|
||||
bool autoStartEnabled = m_settings->isAutoStart();
|
||||
if (autoStartEnabled != isAutoStartEnabled()) {
|
||||
toggleAutoStart(autoStartEnabled);
|
||||
}
|
||||
#endif
|
||||
m_serversModel->resetModel();
|
||||
m_languageModel->changeLanguage(
|
||||
static_cast<LanguageSettings::AvailableLanguageEnum>(m_languageModel->getCurrentLanguageIndex()));
|
||||
|
|
@ -191,6 +197,38 @@ bool SettingsController::isAutoStartEnabled()
|
|||
|
||||
void SettingsController::toggleAutoStart(bool enable)
|
||||
{
|
||||
/*#ifdef Q_OS_WINDOWS
|
||||
if (enable) {
|
||||
QString exePath = QCoreApplication::applicationFilePath();
|
||||
QString shortcutName = "AmneziaVPN.lnk";
|
||||
|
||||
QString startupFolder = QDir::homePath() +
|
||||
"/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup";
|
||||
|
||||
QString shortcutPath = QDir::toNativeSeparators(startupFolder + "/" + shortcutName);
|
||||
QString targetPath = QDir::toNativeSeparators(exePath);
|
||||
|
||||
QProcess::execute("powershell", {
|
||||
"-Command",
|
||||
QString(""
|
||||
"$WshShell = New-Object -ComObject WScript.Shell; "
|
||||
"$Shortcut = $WshShell.CreateShortcut('%1'); "
|
||||
"$Shortcut.TargetPath = '%2'; "
|
||||
"$Shortcut.WorkingDirectory = '%3'; "
|
||||
"$Shortcut.Save()"
|
||||
).arg(shortcutPath, targetPath, QFileInfo(targetPath).absolutePath())
|
||||
});
|
||||
} else {
|
||||
QString startupFolder = QDir::homePath()
|
||||
+ "/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup";
|
||||
QString shortcutPath = QDir::toNativeSeparators(startupFolder + "/AmneziaVPN.lnk");
|
||||
QFile::remove(shortcutPath);
|
||||
QSettings runKey("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
|
||||
runKey.remove("AmneziaVPN");
|
||||
}
|
||||
#else
|
||||
Autostart::setAutostart(enable);
|
||||
#endif*/
|
||||
Autostart::setAutostart(enable);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue