Skip to content

Commit

Permalink
Solved Quitting after reverting to default settings does not ask to c…
Browse files Browse the repository at this point in the history
…onfirm.
  • Loading branch information
GerhardAM committed Mar 22, 2022
1 parent 0a317b6 commit dfcd130
Showing 1 changed file with 34 additions and 36 deletions.
70 changes: 34 additions & 36 deletions Classes/Preferences/PreferencesWindow/PreferencesController.m
Original file line number Diff line number Diff line change
Expand Up @@ -739,26 +739,7 @@ - (IBAction) restartSEB:(id)sender {
}

// If settings changed since before opening preferences:
if ([self settingsChanged]) {
// Ask if edited settings should be applied or previously active settings restored
SEBApplySettingsAnswers answer = [self askToApplySettingsAlert];
switch(answer)
{
case SEBApplySettingsAnswerDontApply:
{
// Don't apply edited settings and restart SEB
break;
}

case SEBApplySettingsAnswerCancel:
{
// Cancel: Don't restart, restore possibly changed setting keys
[oldSettings restoreSettings];

return;
}
}
}
[self handlSettingsChanged:oldSettings];

// If opening the preferences window isn't allowed in these settings,
// which is dangerous when being applied, we confirm the user knows what he's doing
Expand Down Expand Up @@ -840,25 +821,15 @@ - (IBAction) quitSEB:(id)sender
}
}

} else if (!NSUserDefaults.userDefaultsPrivate) {
}

// If settings changed since before opening preferences:
[self handlSettingsChanged:oldSettings];

if (!NSUserDefaults.userDefaultsPrivate) {

/// Local client settings are active
DDLogInfo(@"Client settings are active");
// If settings changed:
if ([self settingsChanged]) {
DDLogInfo(@"Client settings have been changed, ask if they should be applied.");
// Ask if edited settings should be applied or previously active settings restored
SEBApplySettingsAnswers answer = [self askToApplySettingsAlert];
switch(answer)
{
case SEBApplySettingsAnswerCancel:
{
// Cancel: Don't quit
DDLogInfo(@"User selected to cancel applying changed client settings, also abort quitting SEB.");
return;
}
}
}

// If opening the preferences window isn't allowed in these settings,
// which is dangerous when being applied, we confirm the user knows what he's doing
Expand Down Expand Up @@ -889,6 +860,33 @@ - (IBAction) quitSEB:(id)sender
}


- (void) handlSettingsChanged:(SEBEncapsulatedSettings *)oldSettings {
// If settings changed since before opening preferences:
if ([self settingsChanged]) {
DDLogInfo(@"Client settings have been changed, ask if they should be applied.");
// Ask if edited settings should be applied or previously active settings restored
SEBApplySettingsAnswers answer = [self askToApplySettingsAlert];
switch(answer)
{
case SEBApplySettingsAnswerDontApply:
{
// Don't apply edited settings and restart SEB
break;
}

case SEBApplySettingsAnswerCancel:
{
// Cancel: Don't restart, restore possibly changed setting keys
DDLogInfo(@"User selected to cancel applying changed client settings, also abort quitting SEB.");
[oldSettings restoreSettings];

return;
}
}
}
}


- (IBAction) openSEBPrefs:(id)sender
{
// Check if passwords are confirmed and save them if yes
Expand Down

0 comments on commit dfcd130

Please sign in to comment.