Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solved Quitting after reverting to default settings does not ask to c onfirm. #201

Open
wants to merge 1 commit into
base: 3.1
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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