Skip to content

Commit

Permalink
Merge pull request #43 from Issung/feature/#40-save-thumbnails-setting
Browse files Browse the repository at this point in the history
#40 Add setting to save thumbnails with thread html
  • Loading branch information
Issung authored Mar 3, 2024
2 parents 004b9a7 + bb8771c commit 1867ad9
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 41 deletions.
5 changes: 4 additions & 1 deletion GChan/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<setting name="ScanTimer" serializeAs="String">
<value>60000</value>
</setting>
<setting name="SaveHTML" serializeAs="String">
<setting name="SaveHtml" serializeAs="String">
<value>False</value>
</setting>
<setting name="IsFirstStart" serializeAs="String">
Expand Down Expand Up @@ -55,6 +55,9 @@
<setting name="MaximumConcurrentDownloads" serializeAs="String">
<value>35</value>
</setting>
<setting name="SaveThumbnails" serializeAs="String">
<value>False</value>
</setting>
</GChan.Properties.Settings>
</userSettings>
<runtime>
Expand Down
2 changes: 1 addition & 1 deletion GChan/Controllers/MainController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ private void ScanRoutine()
var links = thread.GetImageLinks();
imageDownloader.Queue(links);

if (Settings.Default.SaveHTML)
if (Settings.Default.SaveHtml)
{
threadHtmlDownloader.Queue(thread);
}
Expand Down
21 changes: 13 additions & 8 deletions GChan/Forms/SettingsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ private void Settings_Shown(object sender, EventArgs e)
imageFilenameFormatComboBox.SelectedIndex = Settings.Default.ImageFilenameFormat;
threadFolderNameFormatComboBox.SelectedIndex = Settings.Default.ThreadFolderNameFormat;

chkHTML.Checked = Settings.Default.SaveHTML;
chkSaveHtml.Checked = Settings.Default.SaveHtml;
chkSaveThumbnails.Checked = Settings.Default.SaveThumbnails;
chkSave.Checked = Settings.Default.SaveListsOnClose;
chkTray.Checked = Settings.Default.MinimizeToTray;
chkWarn.Checked = Settings.Default.WarnOnClose;
Expand All @@ -91,17 +92,15 @@ private void buttonSave_Click(object sender, EventArgs e)
MessageBox.Show(reason, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}

if (timerNumeric.Value < 5)
{
MessageBox.Show("Timer has to be higher than 5 seconds");
MessageBox.Show("Timer must be greater than 5 seconds.");
return;
}
else
{
SaveSettings();

Close();
}
SaveSettings();
Close();
}

private void buttonCancel_Click(object sender, EventArgs e)
Expand All @@ -116,7 +115,8 @@ private void SaveSettings()
Settings.Default.MaximumConcurrentDownloads = (int)concurrentDownloadsNumeric.Value;
Settings.Default.ImageFilenameFormat = (byte)imageFilenameFormatComboBox.SelectedIndex;
Settings.Default.ThreadFolderNameFormat = (byte)threadFolderNameFormatComboBox.SelectedIndex;
Settings.Default.SaveHTML = chkHTML.Checked;
Settings.Default.SaveHtml = chkSaveHtml.Checked;
Settings.Default.SaveThumbnails = chkSaveThumbnails.Checked;
Settings.Default.SaveListsOnClose = chkSave.Checked;
Settings.Default.MinimizeToTray = chkTray.Checked;
Settings.Default.WarnOnClose = chkWarn.Checked;
Expand Down Expand Up @@ -204,5 +204,10 @@ private void renameThreadFolderCheckBox_CheckedChanged(object sender, EventArgs
threadFolderNameFormatLabel.Enabled = renameThreadFolderCheckBox.Checked;
threadFolderNameFormatComboBox.Enabled = renameThreadFolderCheckBox.Checked;
}

private void chkHTML_CheckedChanged(object sender, EventArgs e)
{
chkSaveThumbnails.Enabled = chkSaveHtml.Checked;
}
}
}
57 changes: 37 additions & 20 deletions GChan/Forms/SettingsForm.designer.cs

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

4 changes: 4 additions & 0 deletions GChan/Helpers/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ private static string GetFilenameFromUrl(string hrefLink)
return fileName;
}

/// <summary>
/// Creates <paramref name="directory"/> if it doesn't already exist.
/// </summary>
/// <param name="directory">Directory path, exlcluding filename.</param>
/// <returns>True if file was downloaded or already existed, false for error occured.</returns>
public static bool DownloadFile(string url, string directory)
{
Expand Down
4 changes: 2 additions & 2 deletions GChan/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("5.2.0")]
[assembly: AssemblyFileVersion("5.2.0")]
[assembly: AssemblyVersion("5.3.0")]
[assembly: AssemblyFileVersion("5.3.0")]
18 changes: 15 additions & 3 deletions GChan/Properties/Settings.Designer.cs

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

5 changes: 4 additions & 1 deletion GChan/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<Setting Name="ScanTimer" Type="System.Int32" Scope="User">
<Value Profile="(Default)">60000</Value>
</Setting>
<Setting Name="SaveHTML" Type="System.Boolean" Scope="User">
<Setting Name="SaveHtml" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="IsFirstStart" Type="System.Boolean" Scope="User">
Expand Down Expand Up @@ -47,5 +47,8 @@
<Setting Name="MaximumConcurrentDownloads" Type="System.Int32" Scope="User">
<Value Profile="(Default)">35</Value>
</Setting>
<Setting Name="SaveThumbnails" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
9 changes: 6 additions & 3 deletions GChan/Trackers/Sites/Thread_4Chan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,13 @@ public override void DownloadHtmlImpl()

htmlPage = htmlPage.Replace("=\"//", "=\"http://");

//Save thumbs for files that need it
for (int i = 0; i < thumbs.Count; i++)
if (Settings.Default.SaveThumbnails)
{
Utils.DownloadFile(thumbs[i], SaveTo + "\\thumb");
//Save thumbs for files that need it
for (int i = 0; i < thumbs.Count; i++)
{
Utils.DownloadFile(thumbs[i], SaveTo + "\\thumb");
}
}

if (!string.IsNullOrWhiteSpace(htmlPage))
Expand Down
7 changes: 5 additions & 2 deletions GChan/Trackers/Sites/Thread_8Kun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,12 @@ public override void DownloadHtmlImpl()

htmlPage = htmlPage.Replace("=\"/", "=\"https://8kun.top/");

for (int i = 0; i < thumbs.Count; i++)
if (Settings.Default.SaveThumbnails)
{
Utils.DownloadFile(thumbs[i], SaveTo + "\\thumb");
for (int i = 0; i < thumbs.Count; i++)
{
Utils.DownloadFile(thumbs[i], SaveTo + "\\thumb");
}
}

if (!string.IsNullOrWhiteSpace(htmlPage))
Expand Down

0 comments on commit 1867ad9

Please sign in to comment.