Allow disabling autostart settings

This is useful when the target platform/packaging is not actually supported, e.g.
currently the code does not work when Syncthing Tray is packaged as Flatpak.
This commit is contained in:
Martchus 2024-05-18 14:13:38 +02:00
parent 4b405a1723
commit 1ca2eecbf1
2 changed files with 15 additions and 4 deletions

View File

@ -110,6 +110,17 @@ if (USE_LIBSYNCTHING)
list(APPEND META_PUBLIC_COMPILE_DEFINITIONS SYNCTHINGWIDGETS_USE_LIBSYNCTHING) list(APPEND META_PUBLIC_COMPILE_DEFINITIONS SYNCTHINGWIDGETS_USE_LIBSYNCTHING)
endif () endif ()
# allow disabling autostart configuration
option(NO_AUTOSTART_SETTINGS
"whether autostart settings should be disabled - useful if it would not work anyway on the target platform/packaging"
OFF)
if (NO_AUTOSTART_SETTINGS)
set_property(
SOURCE settings/settingsdialog.cpp
APPEND
PROPERTY COMPILE_DEFINITIONS SYNCTHINGWIDGETS_AUTOSTART_DISABLED)
endif ()
# configure autostart .desktop file exec path # configure autostart .desktop file exec path
set(AUTOSTART_EXEC_PATH set(AUTOSTART_EXEC_PATH
"" ""

View File

@ -818,14 +818,14 @@ QWidget *AutostartOptionPage::setupWidget()
setAutostartPath(QString()); setAutostartPath(QString());
reset(); reset();
}); });
#if defined(PLATFORM_LINUX) && !defined(PLATFORM_ANDROID) #if !defined(SYNCTHINGWIDGETS_AUTOSTART_DISABLED) && defined(PLATFORM_LINUX) && !defined(PLATFORM_ANDROID)
ui()->platformNoteLabel->setText(QCoreApplication::translate("QtGui::AutostartOptionPage", ui()->platformNoteLabel->setText(QCoreApplication::translate("QtGui::AutostartOptionPage",
"This is achieved by adding a *.desktop file under <i>~/.config/autostart</i> so the setting only affects the current user.")); "This is achieved by adding a *.desktop file under <i>~/.config/autostart</i> so the setting only affects the current user."));
#elif defined(PLATFORM_WINDOWS) #elif !defined(SYNCTHINGWIDGETS_AUTOSTART_DISABLED) && defined(PLATFORM_WINDOWS)
ui()->platformNoteLabel->setText(QCoreApplication::translate("QtGui::AutostartOptionPage", ui()->platformNoteLabel->setText(QCoreApplication::translate("QtGui::AutostartOptionPage",
"This is achieved by adding a registry key under <i>HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run</i> so the setting " "This is achieved by adding a registry key under <i>HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run</i> so the setting "
"only affects the current user. Note that the startup entry is invalidated when moving <i>syncthingtray.exe</i>.")); "only affects the current user. Note that the startup entry is invalidated when moving <i>syncthingtray.exe</i>."));
#elif defined(PLATFORM_MAC) #elif !defined(SYNCTHINGWIDGETS_AUTOSTART_DISABLED) && defined(PLATFORM_MAC)
ui()->platformNoteLabel->setText(QCoreApplication::translate("QtGui::AutostartOptionPage", ui()->platformNoteLabel->setText(QCoreApplication::translate("QtGui::AutostartOptionPage",
"This is achieved by adding a *.plist file under <i>~/Library/LaunchAgents</i> so the setting only affects the current user.")); "This is achieved by adding a *.plist file under <i>~/Library/LaunchAgents</i> so the setting only affects the current user."));
#else #else
@ -833,7 +833,7 @@ QWidget *AutostartOptionPage::setupWidget()
QCoreApplication::translate("QtGui::AutostartOptionPage", "This feature has not been implemented for your platform (yet).")); QCoreApplication::translate("QtGui::AutostartOptionPage", "This feature has not been implemented for your platform (yet)."));
m_unsupported = true; m_unsupported = true;
ui()->pathWidget->setVisible(false); ui()->pathWidget->setVisible(false);
ui()->autostartCheckBox->setEnabled(false); ui()->autostartCheckBox->setVisible(false);
#endif #endif
return widget; return widget;
} }