Skip to content

Commit

Permalink
Move "clear clipboard" option to settings
Browse files Browse the repository at this point in the history
  • Loading branch information
eltos committed Jan 31, 2024
1 parent 5a74325 commit 646c1b9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 27 deletions.
16 changes: 0 additions & 16 deletions PasteIntoFile/Dialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 3 additions & 11 deletions PasteIntoFile/Dialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ public Dialog(string location = null, string filename = null, bool? showDialogOv
if (saveIntoSubdir) location += @"\" + formatFilenameTemplate(Settings.Default.subdirTemplate);
txtCurrentLocation.Text = location;
updateUiFromSettings();
chkClrClipboard.Checked = clearClipboardOverwrite ?? chkClrClipboard.Checked;
Settings.Default.PropertyChanged += (sender, args) => updateUiFromSettings();


Expand All @@ -114,7 +113,7 @@ public Dialog(string location = null, string filename = null, bool? showDialogOv
// directly save without showing a dialog
Opacity = 0; // prevent dialog from showing up for a fraction of a second

var file = clipRead ? save(overwriteIfExists) : null;
var file = clipRead ? save(overwriteIfExists, clearClipboardOverwrite) : null;
if (file != null) {
Environment.ExitCode = 0;

Expand Down Expand Up @@ -161,7 +160,6 @@ private void CloseAsSoonAsPossible() {

private void updateUiFromSettings() {
disableUiEvents = true;
chkClrClipboard.Checked = Settings.Default.clrClipboard;
chkContinuousMode.Checked = Settings.Default.continuousMode;
chkAutoSave.Checked = Settings.Default.autoSave;
updateSavebutton();
Expand Down Expand Up @@ -341,7 +339,7 @@ private void btnSave_Click(object sender, EventArgs e) {
}
}

string save(bool overwriteIfExists = false) {
string save(bool overwriteIfExists = false, bool? clearClipboardOverwrite = false) {
try {
string dirname = Path.GetFullPath(txtCurrentLocation.Text);
string ext = comExt.Text.ToLowerInvariant().Trim();
Expand Down Expand Up @@ -382,7 +380,7 @@ string save(bool overwriteIfExists = false) {
return null;
}

if (chkClrClipboard.Checked) {
if (clearClipboardOverwrite ?? Settings.Default.clrClipboard) {
clipMonitor.MonitorClipboard = false; // to prevent callback during batch mode
Clipboard.Clear();
clipMonitor.MonitorClipboard = true;
Expand Down Expand Up @@ -431,12 +429,6 @@ private void Main_KeyPress(object sender, KeyPressEventArgs e) {
}
}

private void ChkClrClipboard_CheckedChanged(object sender, EventArgs e) {
if (disableUiEvents) return;
Settings.Default.clrClipboard = chkClrClipboard.Checked;
Settings.Default.Save();
}

private void chkContinuousMode_CheckedChanged(object sender, EventArgs e) {
if (disableUiEvents) return;
if (chkContinuousMode.Checked) {
Expand Down
7 changes: 7 additions & 0 deletions PasteIntoFile/Wizard.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions PasteIntoFile/Wizard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ private void ChkPatching_CheckedChanged(object sender, EventArgs e) {
private void settingsButton_Click(object sender, EventArgs e) {
// update
settingsMenuUpdateChecks.Checked = Settings.Default.updateChecksEnabled;
settingsMenuClearClipboard.Checked = Settings.Default.clrClipboard;
// show it
Point ptLowerLeft = new Point(4, settingsButton.Height);
ptLowerLeft = settingsButton.PointToScreen(ptLowerLeft);
Expand All @@ -156,6 +157,13 @@ private void menuUpdateChecks_CheckedChanged(object sender, EventArgs e) {
}
}

private void menuClearClipboard_CheckedChanged(object sender, EventArgs e) {
if (Settings.Default.clrClipboard != settingsMenuClearClipboard.Checked) {
Settings.Default.clrClipboard = settingsMenuClearClipboard.Checked;
Settings.Default.Save();
}
}

private void finish_Click(object sender, EventArgs e) {
Settings.Default.firstLaunch = false;
Settings.Default.Save();
Expand Down

0 comments on commit 646c1b9

Please sign in to comment.