Skip to content

Commit f952ba9

Browse files
Merge pull request #5 from martinstoeckli/feature/hash-calculator
Implemented hash calculator for selected files.
2 parents d55bf69 + 276abb5 commit f952ba9

21 files changed

+586
-51
lines changed

design/ExplorerGenie.svg

Lines changed: 21 additions & 9 deletions
Loading

design/hash32.png

1.56 KB
Loading

src/ExplorerGenieExt/Images.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ icoOptions ICON "img\options.ico"
55
icoCmd ICON "img\cmd.ico"
66
icoPowershell ICON "img\powershell.ico"
77
icoExplorer ICON "img\explorer.ico"
8+
icoHash ICON "img\hash.ico"

src/ExplorerGenieExt/UnitActions.pas

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ TActions = class(TObject)
5656

5757
class function FindExplorerGenieCmdPath: String;
5858
class function FindExplorerGenieOptionsPath: String;
59+
class function ContainsFiles(filenames: TStrings): Boolean;
5960
public
6061
/// <summary>
6162
/// Action for menu item "copy file"
@@ -72,7 +73,8 @@ TActions = class(TObject)
7273
/// <summary>
7374
/// Action for menu item "copy options"
7475
/// </summary>
75-
class procedure OnCopyOptionsClicked();
76+
/// <param name="filenames">List with paths of selected files.</param>
77+
class procedure OnCopyOptionsClicked(filenames: TStrings);
7678

7779
/// <summary>
7880
/// Action for menu item "open cmd"
@@ -95,7 +97,14 @@ TActions = class(TObject)
9597
/// <summary>
9698
/// Action for menu item "Go to options"
9799
/// </summary>
98-
class procedure OnGotoOptionsClicked();
100+
/// <param name="filenames">List with paths of selected files.</param>
101+
class procedure OnGotoOptionsClicked(filenames: TStrings);
102+
103+
/// <summary>
104+
/// Action for menu item "Hash"
105+
/// </summary>
106+
/// <param name="filenames">List with paths of selected files.</param>
107+
class procedure OnHashClicked(filenames: TStrings);
99108
end;
100109

101110
implementation
@@ -120,13 +129,13 @@ class procedure TActions.OnCopyEmailClicked(filenames: TStrings);
120129
ExecuteCommand(exePath, params, false);
121130
end;
122131

123-
class procedure TActions.OnCopyOptionsClicked();
132+
class procedure TActions.OnCopyOptionsClicked(filenames: TStrings);
124133
var
125134
exePath: String;
126135
params: String;
127136
begin
128137
exePath := FindExplorerGenieOptionsPath();
129-
params := BuildCommandLine('-OpenedFromCopy', nil);
138+
params := BuildCommandLine('-OpenedFromCopy', filenames);
130139
ExecuteCommand(exePath, params, true);
131140
end;
132141

@@ -178,13 +187,23 @@ class procedure TActions.OnGotoExplorerClicked(filenames: TStrings; asAdmin: Boo
178187
end;
179188
end;
180189

181-
class procedure TActions.OnGotoOptionsClicked;
190+
class procedure TActions.OnGotoOptionsClicked(filenames: TStrings);
182191
var
183192
exePath: String;
184193
params: String;
185194
begin
186195
exePath := FindExplorerGenieOptionsPath();
187-
params := BuildCommandLine('-OpenedFromGoto', nil);
196+
params := BuildCommandLine('-OpenedFromGoto', filenames);
197+
ExecuteCommand(exePath, params, true);
198+
end;
199+
200+
class procedure TActions.OnHashClicked(filenames: TStrings);
201+
var
202+
exePath: String;
203+
params: String;
204+
begin
205+
exePath := FindExplorerGenieOptionsPath();
206+
params := BuildCommandLine('-OpenedFromHash', filenames);
188207
ExecuteCommand(exePath, params, true);
189208
end;
190209

@@ -272,6 +291,19 @@ class function TActions.GetShellExecuteOperation(asAdmin: Boolean): String;
272291
Result := 'open';
273292
end;
274293

294+
class function TActions.ContainsFiles(filenames: TStrings): Boolean;
295+
var
296+
index: Integer;
297+
begin
298+
Result := false;
299+
index := 0;
300+
while (not Result) and (index < filenames.Count) do
301+
begin
302+
Result := TFile.Exists(filenames[index]);
303+
Inc(index);
304+
end;
305+
end;
306+
275307
class procedure TActions.ExecuteCommand(const cmd, params: String; visible: Boolean);
276308
var
277309
applicationName: WideString;

src/ExplorerGenieExt/UnitApp.pas

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ function TApp.CreateMenuModels(settingsService: TSettingsService; languageServic
112112
submenuGotoExplorer: TMenuModel;
113113
submenuGotoExplorerAdmin: TMenuModel;
114114
submenuGotoOptions: TMenuModel;
115+
menuHash: TMenuModel;
115116
begin
116117
Result := TMenuModelList.Create(true);
117118
settings := TSettingsModel.Create();
@@ -153,7 +154,7 @@ function TApp.CreateMenuModels(settingsService: TSettingsService; languageServic
153154
submenuCopyOptions.OnClicked :=
154155
procedure
155156
begin
156-
TActions.OnCopyOptionsClicked();
157+
TActions.OnCopyOptionsClicked(FFilenames);
157158
end;
158159
menuClipboard.Children.Add(submenuCopyOptions);
159160
end;
@@ -168,7 +169,7 @@ function TApp.CreateMenuModels(settingsService: TSettingsService; languageServic
168169
if (settings.GotoCommandPrompt) then
169170
begin
170171
submenuGotoCmd := TMenuModel.Create;
171-
submenuGotoCmd.Title := languageService.LoadText('menuGotoCmd', 'Open in Command Prompt');
172+
submenuGotoCmd.Title := languageService.LoadText('submenuGotoCmd', 'Open in Command Prompt');
172173
submenuGotoCmd.Icon := TMenuIcon.Create('icoCmd', iconSize);
173174
submenuGotoCmd.OnClicked :=
174175
procedure
@@ -178,7 +179,7 @@ function TApp.CreateMenuModels(settingsService: TSettingsService; languageServic
178179
menuGoto.Children.Add(submenuGotoCmd);
179180

180181
submenuGotoCmdAdmin := TMenuModel.Create;
181-
submenuGotoCmdAdmin.Title := languageService.LoadText('menuGotoCmdAdmin', 'Open in Command Prompt as admin');
182+
submenuGotoCmdAdmin.Title := languageService.LoadText('submenuGotoCmdAdmin', 'Open in Command Prompt as admin');
182183
submenuGotoCmdAdmin.Icon := TMenuIcon.Create('icoCmd', iconSize);
183184
submenuGotoCmdAdmin.OnClicked :=
184185
procedure
@@ -191,7 +192,7 @@ function TApp.CreateMenuModels(settingsService: TSettingsService; languageServic
191192
if (settings.GotoPowerShell) then
192193
begin
193194
submenuGotoPowershell := TMenuModel.Create;
194-
submenuGotoPowershell.Title := languageService.LoadText('menuGotoPowershell', 'Open in Power Shell');
195+
submenuGotoPowershell.Title := languageService.LoadText('submenuGotoPowershell', 'Open in Power Shell');
195196
submenuGotoPowershell.Icon := TMenuIcon.Create('icoPowershell', iconSize);
196197
submenuGotoPowershell.OnClicked :=
197198
procedure
@@ -201,7 +202,7 @@ function TApp.CreateMenuModels(settingsService: TSettingsService; languageServic
201202
menuGoto.Children.Add(submenuGotoPowershell);
202203

203204
submenuGotoPowershellAdmin := TMenuModel.Create;
204-
submenuGotoPowershellAdmin.Title := languageService.LoadText('menuGotoPowershellAdmin', 'Open in Power Shell as admin');
205+
submenuGotoPowershellAdmin.Title := languageService.LoadText('submenuGotoPowershellAdmin', 'Open in Power Shell as admin');
205206
submenuGotoPowershellAdmin.Icon := TMenuIcon.Create('icoPowershell', iconSize);
206207
submenuGotoPowershellAdmin.OnClicked :=
207208
procedure
@@ -214,7 +215,7 @@ function TApp.CreateMenuModels(settingsService: TSettingsService; languageServic
214215
if (settings.GotoExplorer) then
215216
begin
216217
submenuGotoExplorer := TMenuModel.Create;
217-
submenuGotoExplorer.Title := languageService.LoadText('menuGotoExplorer', 'Open in Explorer');
218+
submenuGotoExplorer.Title := languageService.LoadText('submenuGotoExplorer', 'Open in Explorer');
218219
submenuGotoExplorer.Icon := TMenuIcon.Create('icoExplorer', iconSize);
219220
submenuGotoExplorer.OnClicked :=
220221
procedure
@@ -224,7 +225,7 @@ function TApp.CreateMenuModels(settingsService: TSettingsService; languageServic
224225
menuGoto.Children.Add(submenuGotoExplorer);
225226

226227
submenuGotoExplorerAdmin := TMenuModel.Create;
227-
submenuGotoExplorerAdmin.Title := languageService.LoadText('menuGotoExplorerAdmin', 'Open in Explorer as admin');
228+
submenuGotoExplorerAdmin.Title := languageService.LoadText('submenuGotoExplorerAdmin', 'Open in Explorer as admin');
228229
submenuGotoExplorerAdmin.Icon := TMenuIcon.Create('icoExplorer', iconSize);
229230
submenuGotoExplorerAdmin.OnClicked :=
230231
procedure
@@ -240,10 +241,23 @@ function TApp.CreateMenuModels(settingsService: TSettingsService; languageServic
240241
submenuGotoOptions.OnClicked :=
241242
procedure
242243
begin
243-
TActions.OnGotoOptionsClicked();
244+
TActions.OnGotoOptionsClicked(FFilenames);
244245
end;
245246
menuGoto.Children.Add(submenuGotoOptions);
246247
end;
248+
249+
if (settings.HashShowMenu) then
250+
begin
251+
menuHash := TMenuModel.Create;
252+
menuHash.Title := languageService.LoadText('menuHash', 'Calculate hash');
253+
menuHash.Icon := TMenuIcon.Create('icoHash', iconSize);
254+
menuHash.OnClicked :=
255+
procedure
256+
begin
257+
TActions.OnHashClicked(FFilenames);
258+
end;
259+
Result.Add(menuHash);
260+
end;
247261
finally
248262
settings.Free();
249263
end;

src/ExplorerGenieExt/UnitSettingsModel.pas

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ TSettingsModel = class(TObject)
1717
FGotoCommandPrompt: Boolean;
1818
FGotoPowerShell: Boolean;
1919
FGotoExplorer: Boolean;
20+
FHashShowMenu: Boolean;
2021
public
2122
constructor Create();
2223
procedure SetToDefault();
@@ -25,6 +26,7 @@ TSettingsModel = class(TObject)
2526
property GotoCommandPrompt: Boolean read FGotoCommandPrompt write FGotoCommandPrompt;
2627
property GotoPowerShell: Boolean read FGotoPowerShell write FGotoPowerShell;
2728
property GotoExplorer: Boolean read FGotoExplorer write FGotoExplorer;
29+
property HashShowMenu: Boolean read FHashShowMenu write FHashShowMenu;
2830
end;
2931

3032
implementation
@@ -41,6 +43,7 @@ procedure TSettingsModel.SetToDefault;
4143
GotoCommandPrompt := true;
4244
GotoPowerShell := true;
4345
GotoExplorer := true;
46+
HashShowMenu := true;
4447
end;
4548

4649
end.

src/ExplorerGenieExt/UnitSettingsService.pas

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ procedure TSettingsService.LoadSettingsOrDefault(settings: TSettingsModel);
5555
settings.GotoPowerShell := StrToBoolDef(registry.ReadString('GotoPowerShell'), settings.GotoPowerShell);
5656
if (registry.ValueExists('GotoExplorer')) then
5757
settings.GotoExplorer := StrToBoolDef(registry.ReadString('GotoExplorer'), settings.GotoExplorer);
58+
if (registry.ValueExists('HashShowMenu')) then
59+
settings.HashShowMenu := StrToBoolDef(registry.ReadString('HashShowMenu'), settings.HashShowMenu);
5860
end;
5961
except
6062
// keep default values

src/ExplorerGenieExt/img/hash.ico

3.19 KB
Binary file not shown.

src/ExplorerGenieOptions/Lng.ExplorerGenie.de

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ submenuCopyFile Dateiname(n) kopieren
33
submenuCopyEmail Als E-Mail Link kopieren
44
submenuOptions Optionen
55
menuGoto Gehe zu Tool
6-
menuGotoCmd Öffne in Command Prompt
7-
menuGotoCmdAdmin Öffne in Command Prompt als Admin
8-
menuGotoPowershell Öffne in Power Shell
9-
menuGotoPowershellAdmin Öffne in Power Shell als Admin
10-
menuGotoExplorer Öffne in Explorer
11-
menuGotoExplorerAdmin Öffne in Explorer als Admin
6+
submenuGotoCmd Öffne in Command Prompt
7+
submenuGotoCmdAdmin Öffne in Command Prompt als Admin
8+
submenuGotoPowershell Öffne in Power Shell
9+
submenuGotoPowershellAdmin Öffne in Power Shell als Admin
10+
submenuGotoExplorer Öffne in Explorer
11+
submenuGotoExplorerAdmin Öffne in Explorer als Admin
12+
menuHash Hash berechnen
1213

14+
guiCopy Kopieren
15+
guiPaste Einfügen
1316
guiClose Schliessen
1417
guiInfo Information
1518
guiShowMenu Kontextmenu anzeigen
@@ -22,6 +25,10 @@ guiAsThunderbird Thunderbird und andere
2225
guiUnc Für verbundene Laufwerke den Netzwerkpfad (UNC) einsetzen
2326
guiOnlyFile Nur Dateiname ohne Pfad
2427
guiApplications Anwendungen
28+
guiHashValues Hashwerte
29+
guiHashValue Hashwert
30+
guiAlgorithm Algorithmus
31+
guiHashVerification Verifiziere Hashwert durch Eintippen oder Einfügen in die Textbox.
2532
guiVersion Version
2633
guiCopyright Copyright
2734
guiWebsite Webseite

src/ExplorerGenieOptions/Lng.ExplorerGenie.en

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ submenuCopyFile Copy filename(s)
33
submenuCopyEmail Copy as email link
44
submenuOptions Options
55
menuGoto Go to tool
6-
menuGotoCmd Open in Command Prompt
7-
menuGotoCmdAdmin Open in Command Prompt as admin
8-
menuGotoPowershell Open in Power Shell
9-
menuGotoPowershellAdmin Open in Power Shell as admin
10-
menuGotoExplorer Open in Explorer
11-
menuGotoExplorerAdmin Open in Explorer as admin
6+
submenuGotoCmd Open in Command Prompt
7+
submenuGotoCmdAdmin Open in Command Prompt as admin
8+
submenuGotoPowershell Open in Power Shell
9+
submenuGotoPowershellAdmin Open in Power Shell as admin
10+
submenuGotoExplorer Open in Explorer
11+
submenuGotoExplorerAdmin Open in Explorer as admin
12+
menuHash Calculate hash
1213

14+
guiCopy Copy
15+
guiPaste Paste
1316
guiClose Close
1417
guiInfo Information
1518
guiShowMenu Show context menu
@@ -22,6 +25,10 @@ guiAsThunderbird Thunderbird and others
2225
guiUnc Get network path (UNC) for mapped drives
2326
guiOnlyFile Only filename without path
2427
guiApplications Tools
28+
guiHashValues Hash values
29+
guiHashValue Hash value
30+
guiAlgorithm Algorithm
31+
guiHashVerification Verify a hash by typing or pasting it to the text box.
2532
guiVersion Version
2633
guiCopyright Copyright
2734
guiWebsite Website

0 commit comments

Comments
 (0)