Skip to content

Commit

Permalink
Save Checkbox for SQZ Settings. English translation.
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippDex authored and fabiante committed Sep 19, 2024
1 parent 251d133 commit e097154
Show file tree
Hide file tree
Showing 12 changed files with 568 additions and 318 deletions.
2 changes: 2 additions & 0 deletions NAPS2.Lib/Config/CommonConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,6 @@ public class CommonConfig
[Common]
public bool DisableScannerSharing { get; set; }

[User]
public bool KeepSettings { get; set; }
}
6 changes: 6 additions & 0 deletions NAPS2.Lib/Config/ConfigSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ private ConfigStorage<CommonConfig> AppConfigV0ToCommonConfigDefault(AppConfigV0
storage.Set(x => x.OcrAfterScanning, c.OcrDefaultAfterScanning);
storage.Set(x => x.EventLogging, c.EventLogging);
storage.Set(x => x.KeyboardShortcuts, c.KeyboardShortcuts ?? new KeyboardShortcuts());
// Squeeze Storage
storage.Set(x => x.KeepSettings, c.KeepSettings);

return storage;
}

Expand Down Expand Up @@ -167,6 +170,9 @@ void SetIfLocked<T>(Expression<Func<CommonConfig, T>> accessor, T value, string
SetIfLocked(x => x.KeepSession, c.KeepSession, nameof(c.KeepSession));
SetIfLocked(x => x.SingleInstance, c.SingleInstance, nameof(c.SingleInstance));

//Squeeze cahnge
SetIfLocked(x => x.KeepSettings, c.KeepSettings, nameof(c.KeepSettings));

return storage;
}

Expand Down
1 change: 1 addition & 0 deletions NAPS2.Lib/Config/InternalDefaults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public static CommonConfig GetCommonConfig() =>
DesktopToolStripDock = DockStyle.Top,
EventLogging = EventType.None,
ShowPageNumbers = false,
KeepSettings = false,
PdfSettings = new PdfSettings
{
Metadata = new PdfMetadata
Expand Down
4 changes: 4 additions & 0 deletions NAPS2.Lib/Config/ObsoleteTypes/AppConfigV0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,8 @@ public class AppConfigV0
public EventType EventLogging { get; set; }

public KeyboardShortcuts? KeyboardShortcuts { get; set; }

// Squeeze changes

public bool KeepSettings { get; set; }
}
19 changes: 18 additions & 1 deletion NAPS2.Lib/EtoForms/Ui/SqueezeSettingsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@ namespace NAPS2.EtoForms.Ui
// TODO: Squeeze Konfigurationsfenster bauen
internal class SqueezeSettingsForm : EtoDialogBase
{
private readonly DesktopFormProvider _desktopFormProvider;
private readonly TextBox _server = new();
private readonly TextBox _client = new();
private readonly TextBox _user = new();
private readonly PasswordBoxWithToggle _ownerPassword = new();
private readonly TextBox _classID = new();
private readonly CheckBox _keepSettings = C.CheckBox(UiStrings.KeepSettings);

public SqueezeSettingsForm(Naps2Config config) : base(config)
public SqueezeSettingsForm(Naps2Config config, DesktopSubFormController desktopSubFormController,
DesktopFormProvider desktopFormProvider) : base(config)

{
_desktopFormProvider = desktopFormProvider;
UpdateValues(Config);
}

protected override void BuildLayout()
Expand Down Expand Up @@ -57,6 +61,14 @@ protected override void BuildLayout()

private void UpdateValues(Naps2Config config)
{
void UpdateCheckbox(CheckBox checkBox, Expression<Func<CommonConfig, bool>> accessor)
{
checkBox.Checked = config.Get(accessor);
checkBox.Enabled = !config.AppLocked.Has(accessor);
}

UpdateCheckbox(_keepSettings, c => c.KeepSettings);

void UpdateTextbox(TextBox textBox, Expression<Func<CommonConfig, bool>> accessor)
{

Expand All @@ -75,6 +87,11 @@ void SetIfChanged<T>(Expression<Func<CommonConfig, T>> accessor, T value)
transact.Set(accessor, value);
}
}
SetIfChanged(c => c.KeepSettings, _keepSettings.IsChecked());
transact.Commit();

_desktopFormProvider.DesktopForm.Invalidate();
_desktopFormProvider.DesktopForm.PlaceProfilesToolbar();

}

Expand Down
5 changes: 5 additions & 0 deletions NAPS2.Lib/EtoForms/Widgets/ImageListViewBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,9 @@ public override byte[] MergeCustomDragData(byte[][] dataItems)
}
return mergedObj.ToByteArray();
}


public override bool KeepSettings => _config.Get(c => c.KeepSettings);


}
4 changes: 4 additions & 0 deletions NAPS2.Lib/EtoForms/Widgets/ListViewBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ protected ListViewBehavior(ColorScheme colorScheme)
public virtual byte[] MergeCustomDragData(byte[][] dataItems) => throw new NotSupportedException();

public virtual DragEffects GetCustomDragEffect(byte[] data) => throw new NotSupportedException();

// Squeeze change

public virtual bool KeepSettings => false;
}
Loading

0 comments on commit e097154

Please sign in to comment.