Skip to content

Commit 1867ad9

Browse files
authored
Merge pull request #43 from Issung/feature/#40-save-thumbnails-setting
#40 Add setting to save thumbnails with thread html
2 parents 004b9a7 + bb8771c commit 1867ad9

10 files changed

+91
-41
lines changed

GChan/App.config

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<setting name="ScanTimer" serializeAs="String">
1717
<value>60000</value>
1818
</setting>
19-
<setting name="SaveHTML" serializeAs="String">
19+
<setting name="SaveHtml" serializeAs="String">
2020
<value>False</value>
2121
</setting>
2222
<setting name="IsFirstStart" serializeAs="String">
@@ -55,6 +55,9 @@
5555
<setting name="MaximumConcurrentDownloads" serializeAs="String">
5656
<value>35</value>
5757
</setting>
58+
<setting name="SaveThumbnails" serializeAs="String">
59+
<value>False</value>
60+
</setting>
5861
</GChan.Properties.Settings>
5962
</userSettings>
6063
<runtime>

GChan/Controllers/MainController.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ private void ScanRoutine()
337337
var links = thread.GetImageLinks();
338338
imageDownloader.Queue(links);
339339

340-
if (Settings.Default.SaveHTML)
340+
if (Settings.Default.SaveHtml)
341341
{
342342
threadHtmlDownloader.Queue(thread);
343343
}

GChan/Forms/SettingsForm.cs

+13-8
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ private void Settings_Shown(object sender, EventArgs e)
6969
imageFilenameFormatComboBox.SelectedIndex = Settings.Default.ImageFilenameFormat;
7070
threadFolderNameFormatComboBox.SelectedIndex = Settings.Default.ThreadFolderNameFormat;
7171

72-
chkHTML.Checked = Settings.Default.SaveHTML;
72+
chkSaveHtml.Checked = Settings.Default.SaveHtml;
73+
chkSaveThumbnails.Checked = Settings.Default.SaveThumbnails;
7374
chkSave.Checked = Settings.Default.SaveListsOnClose;
7475
chkTray.Checked = Settings.Default.MinimizeToTray;
7576
chkWarn.Checked = Settings.Default.WarnOnClose;
@@ -91,17 +92,15 @@ private void buttonSave_Click(object sender, EventArgs e)
9192
MessageBox.Show(reason, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
9293
return;
9394
}
95+
9496
if (timerNumeric.Value < 5)
9597
{
96-
MessageBox.Show("Timer has to be higher than 5 seconds");
98+
MessageBox.Show("Timer must be greater than 5 seconds.");
9799
return;
98100
}
99-
else
100-
{
101-
SaveSettings();
102101

103-
Close();
104-
}
102+
SaveSettings();
103+
Close();
105104
}
106105

107106
private void buttonCancel_Click(object sender, EventArgs e)
@@ -116,7 +115,8 @@ private void SaveSettings()
116115
Settings.Default.MaximumConcurrentDownloads = (int)concurrentDownloadsNumeric.Value;
117116
Settings.Default.ImageFilenameFormat = (byte)imageFilenameFormatComboBox.SelectedIndex;
118117
Settings.Default.ThreadFolderNameFormat = (byte)threadFolderNameFormatComboBox.SelectedIndex;
119-
Settings.Default.SaveHTML = chkHTML.Checked;
118+
Settings.Default.SaveHtml = chkSaveHtml.Checked;
119+
Settings.Default.SaveThumbnails = chkSaveThumbnails.Checked;
120120
Settings.Default.SaveListsOnClose = chkSave.Checked;
121121
Settings.Default.MinimizeToTray = chkTray.Checked;
122122
Settings.Default.WarnOnClose = chkWarn.Checked;
@@ -204,5 +204,10 @@ private void renameThreadFolderCheckBox_CheckedChanged(object sender, EventArgs
204204
threadFolderNameFormatLabel.Enabled = renameThreadFolderCheckBox.Checked;
205205
threadFolderNameFormatComboBox.Enabled = renameThreadFolderCheckBox.Checked;
206206
}
207+
208+
private void chkHTML_CheckedChanged(object sender, EventArgs e)
209+
{
210+
chkSaveThumbnails.Enabled = chkSaveHtml.Checked;
211+
}
207212
}
208213
}

GChan/Forms/SettingsForm.designer.cs

+37-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

GChan/Helpers/Utils.cs

+4
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ private static string GetFilenameFromUrl(string hrefLink)
112112
return fileName;
113113
}
114114

115+
/// <summary>
116+
/// Creates <paramref name="directory"/> if it doesn't already exist.
117+
/// </summary>
118+
/// <param name="directory">Directory path, exlcluding filename.</param>
115119
/// <returns>True if file was downloaded or already existed, false for error occured.</returns>
116120
public static bool DownloadFile(string url, string directory)
117121
{

GChan/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
3232
// übernehmen, indem Sie "*" eingeben:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("5.2.0")]
35-
[assembly: AssemblyFileVersion("5.2.0")]
34+
[assembly: AssemblyVersion("5.3.0")]
35+
[assembly: AssemblyFileVersion("5.3.0")]

GChan/Properties/Settings.Designer.cs

+15-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

GChan/Properties/Settings.settings

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<Setting Name="ScanTimer" Type="System.Int32" Scope="User">
99
<Value Profile="(Default)">60000</Value>
1010
</Setting>
11-
<Setting Name="SaveHTML" Type="System.Boolean" Scope="User">
11+
<Setting Name="SaveHtml" Type="System.Boolean" Scope="User">
1212
<Value Profile="(Default)">False</Value>
1313
</Setting>
1414
<Setting Name="IsFirstStart" Type="System.Boolean" Scope="User">
@@ -47,5 +47,8 @@
4747
<Setting Name="MaximumConcurrentDownloads" Type="System.Int32" Scope="User">
4848
<Value Profile="(Default)">35</Value>
4949
</Setting>
50+
<Setting Name="SaveThumbnails" Type="System.Boolean" Scope="User">
51+
<Value Profile="(Default)">False</Value>
52+
</Setting>
5053
</Settings>
5154
</SettingsFile>

GChan/Trackers/Sites/Thread_4Chan.cs

+6-3
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,13 @@ public override void DownloadHtmlImpl()
140140

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

143-
//Save thumbs for files that need it
144-
for (int i = 0; i < thumbs.Count; i++)
143+
if (Settings.Default.SaveThumbnails)
145144
{
146-
Utils.DownloadFile(thumbs[i], SaveTo + "\\thumb");
145+
//Save thumbs for files that need it
146+
for (int i = 0; i < thumbs.Count; i++)
147+
{
148+
Utils.DownloadFile(thumbs[i], SaveTo + "\\thumb");
149+
}
147150
}
148151

149152
if (!string.IsNullOrWhiteSpace(htmlPage))

GChan/Trackers/Sites/Thread_8Kun.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,12 @@ public override void DownloadHtmlImpl()
144144

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

147-
for (int i = 0; i < thumbs.Count; i++)
147+
if (Settings.Default.SaveThumbnails)
148148
{
149-
Utils.DownloadFile(thumbs[i], SaveTo + "\\thumb");
149+
for (int i = 0; i < thumbs.Count; i++)
150+
{
151+
Utils.DownloadFile(thumbs[i], SaveTo + "\\thumb");
152+
}
150153
}
151154

152155
if (!string.IsNullOrWhiteSpace(htmlPage))

0 commit comments

Comments
 (0)