Skip to content

Commit

Permalink
Clean up logic when setting up auto start for user.
Browse files Browse the repository at this point in the history
Signed-off-by: Camila Ayres <[email protected]>
  • Loading branch information
Camila San Martin Ayres authored and Camila San Martin Ayres committed Jan 14, 2024
1 parent 8798335 commit c7917d9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
10 changes: 1 addition & 9 deletions src/gui/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,15 +639,7 @@ void Application::slotownCloudWizardDone(int res)
_checkConnectionTimer.start();
slotCheckConnection();

bool shouldSetAutoStart = true;

#ifdef Q_OS_MAC
// Don't auto start when not being 'installed'
shouldSetAutoStart = shouldSetAutoStart
&& QCoreApplication::applicationDirPath().startsWith("/Applications/");
#endif

Utility::setLaunchOnStartup(_theme->appName(), _theme->appNameGUI(), shouldSetAutoStart);
Utility::setLaunchOnStartup(_theme->appName(), _theme->appNameGUI(), true);

Systray::instance()->showWindow();
}
Expand Down
14 changes: 6 additions & 8 deletions src/gui/generalsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,14 @@ GeneralSettings::GeneralSettings(QWidget *parent)
_ui->showInExplorerNavigationPaneCheckBox->setText(txt);
#endif

if(Utility::hasSystemLaunchOnStartup(Theme::instance()->appName())) {
_ui->autostartCheckBox->setChecked(true);
_ui->autostartCheckBox->setDisabled(true);
if(const auto hasSystemAutoStart = Utility::hasSystemLaunchOnStartup(Theme::instance()->appName())) {
_ui->autostartCheckBox->setChecked(hasSystemAutoStart);
_ui->autostartCheckBox->setDisabled(hasSystemAutoStart);
_ui->autostartCheckBox->setToolTip(tr("You cannot disable autostart because system-wide autostart is enabled."));
} else {
const bool hasAutoStart = Utility::hasLaunchOnStartup(Theme::instance()->appName());
// make sure the binary location is correctly set
slotToggleLaunchOnStartup(hasAutoStart);
_ui->autostartCheckBox->setChecked(hasAutoStart);
const auto hasAutoStart = Utility::hasLaunchOnStartup(Theme::instance()->appName());
connect(_ui->autostartCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::slotToggleLaunchOnStartup);
_ui->autostartCheckBox->setChecked(hasAutoStart);
}

// setup about section
Expand Down Expand Up @@ -456,7 +454,7 @@ void GeneralSettings::saveMiscSettings()

void GeneralSettings::slotToggleLaunchOnStartup(bool enable)
{
Theme *theme = Theme::instance();
const auto theme = Theme::instance();
Utility::setLaunchOnStartup(theme->appName(), theme->appNameGUI(), enable);
}

Expand Down

0 comments on commit c7917d9

Please sign in to comment.