mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-04 22:21:23 +12:00
Save all settings before export, Load all settings and update controls after import
This commit is contained in:
parent
eb0539a941
commit
cf38ce1b93
|
@ -45,9 +45,12 @@ public TabControl MainTabControl
|
|||
}
|
||||
set
|
||||
{
|
||||
mainTabControl = value;
|
||||
FillTreeView(tvMain.Nodes, mainTabControl);
|
||||
tvMain.ExpandAll();
|
||||
if (mainTabControl != value)
|
||||
{
|
||||
mainTabControl = value;
|
||||
FillTreeView(tvMain.Nodes, mainTabControl);
|
||||
tvMain.ExpandAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -118,6 +118,7 @@ private void UpdateSettings()
|
|||
cbExportSettings.Checked = Program.Settings.ExportSettings;
|
||||
cbExportHistory.Checked = Program.Settings.ExportHistory;
|
||||
cbExportLogs.Checked = Program.Settings.ExportLogs;
|
||||
UpdateExportButton();
|
||||
|
||||
// Proxy
|
||||
if (firstLoad)
|
||||
|
@ -285,6 +286,11 @@ private void UpdatePersonalFolderPathPreview()
|
|||
lblPreviewPersonalFolderPath.Text = personalPath;
|
||||
}
|
||||
|
||||
private void UpdateExportButton()
|
||||
{
|
||||
btnExport.Enabled = Program.Settings.ExportSettings || Program.Settings.ExportHistory || Program.Settings.ExportLogs;
|
||||
}
|
||||
|
||||
#region General
|
||||
|
||||
private void llTranslators_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
|
@ -429,16 +435,19 @@ private void btnOpenScreenshotsFolder_Click(object sender, EventArgs e)
|
|||
private void cbExportSettings_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
Program.Settings.ExportSettings = cbExportSettings.Checked;
|
||||
UpdateExportButton();
|
||||
}
|
||||
|
||||
private void cbExportHistory_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
Program.Settings.ExportHistory = cbExportHistory.Checked;
|
||||
UpdateExportButton();
|
||||
}
|
||||
|
||||
private void cbExportLogs_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
Program.Settings.ExportLogs = cbExportLogs.Checked;
|
||||
UpdateExportButton();
|
||||
}
|
||||
|
||||
private void btnExport_Click(object sender, EventArgs e)
|
||||
|
@ -455,7 +464,12 @@ private void btnExport_Click(object sender, EventArgs e)
|
|||
btnImport.Enabled = false;
|
||||
pbExportImport.Visible = true;
|
||||
|
||||
TaskEx.Run(() => ExportImportManager.Export(sfd.FileName), () =>
|
||||
TaskEx.Run(() =>
|
||||
{
|
||||
Program.SaveAllSettings();
|
||||
ExportImportManager.Export(sfd.FileName);
|
||||
},
|
||||
() =>
|
||||
{
|
||||
pbExportImport.Visible = false;
|
||||
btnExport.Enabled = true;
|
||||
|
@ -477,8 +491,14 @@ private void btnImport_Click(object sender, EventArgs e)
|
|||
btnImport.Enabled = false;
|
||||
pbExportImport.Visible = true;
|
||||
|
||||
TaskEx.Run(() => ExportImportManager.Import(ofd.FileName), () =>
|
||||
TaskEx.Run(() =>
|
||||
{
|
||||
ExportImportManager.Import(ofd.FileName);
|
||||
Program.LoadAllSettings();
|
||||
},
|
||||
() =>
|
||||
{
|
||||
UpdateSettings();
|
||||
pbExportImport.Visible = false;
|
||||
btnExport.Enabled = true;
|
||||
btnImport.Enabled = true;
|
||||
|
|
|
@ -951,7 +951,7 @@ private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
|||
{
|
||||
e.Cancel = true;
|
||||
Hide();
|
||||
Program.SaveSettingsAsync();
|
||||
Program.SaveAllSettingsAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -315,7 +315,7 @@ private static void Run()
|
|||
Application.Run(MainForm);
|
||||
|
||||
if (WatchFolderManager != null) WatchFolderManager.Dispose();
|
||||
SaveSettings();
|
||||
SaveAllSettings();
|
||||
BackupSettings();
|
||||
|
||||
DebugHelper.Logger.Async = false;
|
||||
|
@ -399,14 +399,21 @@ public static void LoadHotkeySettings()
|
|||
HotkeysConfig = HotkeysConfig.Load(HotkeysConfigFilePath);
|
||||
}
|
||||
|
||||
public static void SaveSettings()
|
||||
public static void LoadAllSettings()
|
||||
{
|
||||
LoadProgramSettings();
|
||||
LoadUploadersConfig();
|
||||
LoadHotkeySettings();
|
||||
}
|
||||
|
||||
public static void SaveAllSettings()
|
||||
{
|
||||
if (Settings != null) Settings.Save(ApplicationConfigFilePath);
|
||||
if (UploadersConfig != null) UploadersConfig.Save(UploadersConfigFilePath);
|
||||
if (HotkeysConfig != null) HotkeysConfig.Save(HotkeysConfigFilePath);
|
||||
}
|
||||
|
||||
public static void SaveSettingsAsync()
|
||||
public static void SaveAllSettingsAsync()
|
||||
{
|
||||
if (Settings != null) Settings.SaveAsync(ApplicationConfigFilePath);
|
||||
UploadersConfigSaveAsync();
|
||||
|
|
Loading…
Reference in a new issue