Skip to content

Commit 9efc906

Browse files
committed
Add "open raw" option
1 parent 4f16178 commit 9efc906

File tree

5 files changed

+56
-6
lines changed

5 files changed

+56
-6
lines changed

SmartImage 3/ShellMain.Dialog.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,24 @@ void ReloadDialog()
219219
cbContextMenu.Checked = Integration.IsContextMenuAdded;
220220
cbOnTop.Checked = Config.OnTop;
221221

222+
CheckBox cbOpenRaw = new(R1.S_OpenRaw)
223+
{
224+
X = Pos.Right(cbAutoSearch) + 1,
225+
Y = Pos.Y(cbAutoSearch),
226+
// Width = WIDTH,
227+
Height = 1,
228+
AutoSize = true,
229+
ColorScheme = UI.Cs_Btn3
230+
231+
};
232+
233+
cbOpenRaw.Toggled += b =>
234+
{
235+
Config.OpenRaw = b;
236+
ReloadDialog();
237+
};
238+
cbOpenRaw.Checked = Config.OpenRaw;
239+
222240
/*============================================================================*\
223241
Eh username/password
224242
\*============================================================================*/
@@ -286,7 +304,8 @@ Eh username/password
286304

287305
dlCfg.Add(tvConfig, lvSearchEngines, lvPriorityEngines,
288306
cbContextMenu, cbOnTop, lbConfig, lbSearchEngines, lbPriorityEngines,
289-
lbHelp, cbAutoSearch, lbEhUsername, tfEhUsername, lbEhPassword, tfEhPassword);
307+
lbHelp, cbAutoSearch, lbEhUsername, tfEhUsername, lbEhPassword, tfEhPassword,
308+
cbOpenRaw);
290309

291310
dlCfg.AddButton(btnRefresh);
292311
dlCfg.AddButton(btnOk);

SmartImage.Lib 3/Resources.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SmartImage.Lib 3/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,7 @@
141141
<data name="S_EhUsername" xml:space="preserve">
142142
<value>Eh Username</value>
143143
</data>
144+
<data name="S_OpenRaw" xml:space="preserve">
145+
<value>Open raw</value>
146+
</data>
144147
</root>

SmartImage.Lib 3/SearchClient.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,23 @@ public async Task<SearchResult[]> RunSearchAsync(SearchQuery query, Cancellation
155155
return results;
156156
}
157157

158-
private static void OpenResult(SearchResult result)
158+
private void OpenResult(SearchResult result)
159159
{
160160
#if DEBUG
161161
Logger.LogDebug("Not opening result {result}", result);
162162
return;
163163
#else
164-
var url1 = result.Best?.Url ?? result.RawUrl;
164+
Url url1;
165+
166+
if (Config.OpenRaw) {
167+
url1 = result.RawUrl;
168+
}
169+
else {
170+
url1 = result.Best?.Url ?? result.RawUrl;
171+
}
172+
173+
Logger.LogInformation("Opening {Url}", url1);
174+
165175
HttpUtilities.TryOpenUrl(url1);
166176
#endif
167177
}
@@ -252,5 +262,4 @@ public void Dispose()
252262
ConfigApplied = false;
253263
IsComplete = false;
254264
}
255-
}
256-
265+
}

SmartImage.Lib 3/SearchConfig.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ public string EhPassword
9696
}
9797
}
9898

99+
public bool OpenRaw
100+
{
101+
get { return Configuration.ReadSetting(nameof(OpenRaw), false); }
102+
set
103+
{
104+
Configuration.AddUpdateSetting(nameof(OpenRaw), value.ToString());
105+
OnPropertyChanged();
106+
}
107+
}
108+
99109
public static readonly SearchConfig Default = new();
100110

101111
public SearchConfig()
@@ -129,6 +139,7 @@ public DataTable ToTable()
129139
table.Rows.Add(Resources.S_SearchEngines, SearchEngines);
130140
table.Rows.Add(Resources.S_PriorityEngines, PriorityEngines);
131141
table.Rows.Add(Resources.S_OnTop, OnTop);
142+
table.Rows.Add(Resources.S_OpenRaw, OpenRaw);
132143
table.Rows.Add(Resources.S_EhUsername, EhUsername);
133144
table.Rows.Add(Resources.S_EhPassword, EhPassword);
134145

@@ -151,5 +162,4 @@ private bool SetField<T>(ref T field, T value, [CallerMemberName] string propert
151162
OnPropertyChanged(propertyName);
152163
return true;
153164
}
154-
155165
}

0 commit comments

Comments
 (0)