Skip to content

Commit

Permalink
#2: Fixed autostart feature
Browse files Browse the repository at this point in the history
  • Loading branch information
OOPMan committed Oct 31, 2019
1 parent 850bfb4 commit 60ca49d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions XBOFS.win.qt5/XBOFSWinQT5GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#include <qevent.h>
#include <QtWidgets/QCheckBox>
#include <qdesktopservices.h>
#include <qstandardpaths.h>
#include <qdir.h>
#include <qfile.h>
#include <qnetworkconfiguration.h>
#include <qsslsocket.h>
#include <fmt/core.h>
Expand Down Expand Up @@ -311,9 +314,11 @@ void XBOFSWinQT5GUI::showEvent(QShowEvent *event) {
void XBOFSWinQT5GUI::handleAutostartCheckboxStateChanged(const quint16 state) {
autostart = state == Qt::Checked;
settings->setValue(SETTINGS_AUTOSTART, autostart);
auto autostartSettings = QSettings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
if (autostart) autostartSettings.setValue("XBOFS.win", "\"" + QApplication::applicationFilePath().replace("/", "\\") + "\"");
else autostartSettings.remove("XBOFS.win");
auto applicationFilePath = QApplication::applicationFilePath();
auto applicationsLocation = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation);
auto linkPath = applicationsLocation + QDir::separator() + "Startup" + QDir::separator() + "XBOFS.win.qt5.lnk";
if (autostart) QFile::link(applicationFilePath, linkPath);
else QFile::remove(linkPath);
}

void XBOFSWinQT5GUI::handleStartMinimizedCheckboxStateChanged(const quint16 state) {
Expand Down

0 comments on commit 60ca49d

Please sign in to comment.