Allow keeping existing autostart entry in wizard
This commit is contained in:
parent
9f2e2819c6
commit
bc736214dd
|
@ -152,7 +152,8 @@ QVariant SyncthingDeviceModel::data(const QModelIndex &index, int role) const
|
|||
}
|
||||
case 2:
|
||||
if (!dev.connectionType.isEmpty()) {
|
||||
return QVariant(dev.connectionType % QStringLiteral(" (") % (dev.connectionLocal ? tr("local") : tr("remote")) % QStringLiteral(")"));
|
||||
return QVariant(
|
||||
dev.connectionType % QStringLiteral(" (") % (dev.connectionLocal ? tr("local") : tr("remote")) % QStringLiteral(")"));
|
||||
} else {
|
||||
return QVariant();
|
||||
}
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
<normaloff>:/icons/hicolor/scalable/apps/internet-web-browser.svg</normaloff>:/icons/hicolor/scalable/apps/internet-web-browser.svg</iconset>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="keepExistingCheckBox"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="enableAutostartCheckBox">
|
||||
<property name="text">
|
||||
|
@ -92,5 +95,22 @@
|
|||
<resources>
|
||||
<include location="../resources/syncthingwidgetsicons.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>keepExistingCheckBox</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>enableAutostartCheckBox</receiver>
|
||||
<slot>setDisabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>202</x>
|
||||
<y>19</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>202</x>
|
||||
<y>46</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
|
|
@ -190,7 +190,7 @@ bool Wizard::changeSettings()
|
|||
|
||||
// enable/disable auto start
|
||||
#ifdef SETTINGS_WIZARD_AUTOSTART
|
||||
if (!settings.isPlasmoid) {
|
||||
if (!settings.isPlasmoid && !keepExistingAutoStartEntry()) {
|
||||
setAutostartEnabled(autoStart(), true);
|
||||
}
|
||||
#endif
|
||||
|
@ -343,10 +343,11 @@ void Wizard::handleConfigurationSelected(MainConfiguration mainConfig, ExtraConf
|
|||
m_extraConfig = extraConfig;
|
||||
}
|
||||
|
||||
void Wizard::handleAutostartSelected(bool autostartEnabled)
|
||||
void Wizard::handleAutostartSelected(bool autostartEnabled, bool keepExisting)
|
||||
{
|
||||
m_configApplied = false;
|
||||
m_autoStart = autostartEnabled;
|
||||
m_autoStartKeepExisting = keepExisting;
|
||||
}
|
||||
|
||||
void Wizard::pollForSyncthingConfig()
|
||||
|
@ -878,7 +879,17 @@ void AutostartWizardPage::initializePage()
|
|||
break;
|
||||
}
|
||||
|
||||
m_ui->enableAutostartCheckBox->setChecked(wizard->setupDetection().autostartEnabled);
|
||||
const auto &detection = wizard->setupDetection();
|
||||
const auto hasExistingEntry = detection.autostartConfiguredPath.has_value() && !detection.autostartConfiguredPath.value().isEmpty()
|
||||
&& detection.autostartConfiguredPath.value() != detection.autostartSupposedPath;
|
||||
m_ui->keepExistingCheckBox->setVisible(hasExistingEntry);
|
||||
if (hasExistingEntry) {
|
||||
m_ui->keepExistingCheckBox->setText(
|
||||
tr("Do not modify the existing autostart entry for\n\"%1\"").arg(detection.autostartConfiguredPath.value()));
|
||||
} else {
|
||||
m_ui->keepExistingCheckBox->setChecked(false);
|
||||
}
|
||||
m_ui->enableAutostartCheckBox->setChecked(detection.autostartEnabled);
|
||||
}
|
||||
|
||||
void AutostartWizardPage::cleanupPage()
|
||||
|
@ -887,7 +898,7 @@ void AutostartWizardPage::cleanupPage()
|
|||
|
||||
bool AutostartWizardPage::validatePage()
|
||||
{
|
||||
emit autostartSelected(m_ui->enableAutostartCheckBox->isChecked());
|
||||
emit autostartSelected(m_ui->enableAutostartCheckBox->isChecked(), m_ui->keepExistingCheckBox->isChecked());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -979,14 +990,18 @@ void ApplyWizardPage::initializePage()
|
|||
#endif
|
||||
#ifdef SETTINGS_WIZARD_AUTOSTART
|
||||
if (!currentSettings.isPlasmoid) {
|
||||
auto remark = QString();
|
||||
auto action = QString();
|
||||
if (detection.autostartConfiguredPath.has_value() && !detection.autostartConfiguredPath.value().isEmpty()
|
||||
&& detection.autostartConfiguredPath.value() != detection.autostartSupposedPath) {
|
||||
action = wizard->autoStart() ? tr("Override") : tr("Delete");
|
||||
remark = tr("%1 existing autostart entry for \"%2\"").arg(action, detection.autostartConfiguredPath.value());
|
||||
if (wizard->keepExistingAutoStartEntry()) {
|
||||
addListItem(tr("Preserve existing autostart entry for \"%1\"").arg(detection.autostartConfiguredPath.value_or(QStringLiteral("?"))));
|
||||
} else {
|
||||
auto remark = QString();
|
||||
auto action = QString();
|
||||
if (detection.autostartConfiguredPath.has_value() && !detection.autostartConfiguredPath.value().isEmpty()
|
||||
&& detection.autostartConfiguredPath.value() != detection.autostartSupposedPath) {
|
||||
action = wizard->autoStart() ? tr("Override") : tr("Delete");
|
||||
remark = tr("%1 existing autostart entry for \"%2\"").arg(action, detection.autostartConfiguredPath.value());
|
||||
}
|
||||
logFeature(tr("autostart of Syncthing Tray"), wizard->autoStart(), detection.autostartEnabled, remark);
|
||||
}
|
||||
logFeature(tr("autostart of Syncthing Tray"), wizard->autoStart(), detection.autostartEnabled, remark);
|
||||
}
|
||||
#endif
|
||||
html.append(QStringLiteral("</ul><p><b>%1</b></p><ul><li>%2</li><li>%3</li><li>%4</li></ul>")
|
||||
|
|
|
@ -58,6 +58,7 @@ public:
|
|||
MainConfiguration mainConfig() const;
|
||||
ExtraConfiguration extraConfig() const;
|
||||
bool autoStart() const;
|
||||
bool keepExistingAutoStartEntry() const;
|
||||
bool isConfigApplied() const;
|
||||
const QString &configError() const;
|
||||
Data::SyncthingConnection *appliedConnection();
|
||||
|
@ -76,7 +77,7 @@ Q_SIGNALS:
|
|||
private Q_SLOTS:
|
||||
void showDetailsFromSetupDetection();
|
||||
void handleConfigurationSelected(QtGui::MainConfiguration mainConfig, QtGui::ExtraConfiguration extraConfig);
|
||||
void handleAutostartSelected(bool autostartEnabled);
|
||||
void handleAutostartSelected(bool autostartEnabled, bool keepExisting);
|
||||
void pollForSyncthingConfig();
|
||||
|
||||
private:
|
||||
|
@ -87,6 +88,7 @@ private:
|
|||
MainConfiguration m_mainConfig = MainConfiguration::None;
|
||||
ExtraConfiguration m_extraConfig = ExtraConfiguration::None;
|
||||
bool m_autoStart = false;
|
||||
bool m_autoStartKeepExisting = false;
|
||||
bool m_configApplied = false;
|
||||
QString m_configError;
|
||||
Data::SyncthingConnection *m_appliedConnection = nullptr;
|
||||
|
@ -113,6 +115,11 @@ inline bool Wizard::autoStart() const
|
|||
return m_autoStart;
|
||||
}
|
||||
|
||||
inline bool Wizard::keepExistingAutoStartEntry() const
|
||||
{
|
||||
return m_autoStartKeepExisting;
|
||||
}
|
||||
|
||||
inline bool Wizard::isConfigApplied() const
|
||||
{
|
||||
return m_configApplied;
|
||||
|
@ -200,7 +207,7 @@ public:
|
|||
bool validatePage() override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void autostartSelected(bool autostartEnabled);
|
||||
void autostartSelected(bool autostartEnabled, bool keepExisting);
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui::AutostartWizardPage> m_ui;
|
||||
|
|
Loading…
Reference in New Issue