diff --git a/README.md b/README.md index 8c57f726..04a27f83 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ If the program finds the transgui.ini file in the same folder as the binary file ## Advanced parameters There are some parameters in the `transgui.ini file`, that can not be modified via the GUI. -More info on: [#924](https://github.com/transmission-remote-gui/transgui/issues/924) (File Manager & Shortcuts) and [#1020](https://github.com/transmission-remote-gui/transgui/issues/1020) (User Defined Menu *Windows Only*) +More info on: [#924](https://github.com/transmission-remote-gui/transgui/issues/924) (File Manager & Shortcuts) , [#1020](https://github.com/transmission-remote-gui/transgui/issues/1020) (User Defined Menu *Windows Only*) and [#1070](https://github.com/transmission-remote-gui/transgui/issues/1070) (.torrent Auto Opening) ```ini [Interface] @@ -153,6 +153,11 @@ FileManagerDefaultParam={Alternate parameters, could be left blank} GlobalHotkey={Virtual Key Code} full list here http://docwiki.embarcadero.com/RADStudio/Seattle/en/Virtual_Key_Codes (Plus VK_A...VK_Z and VK_0..VK_9) GlobalHotkeyMod={Modifier Key} [MOD_SHIFT , MOD_CONTROL , MOD_ALT , MOD_WIN alone or combined with + sign] +[Interface] +WatchLocalFolder= {LOCAL Folder to watch for torrent files} +WatchDestinationFolder= {REMOTE destination where the data would be saved if missing or empty last destination folder is used} +WatchInterval=1 {Time period in MINUTES between folder scans for torrents, may be fractional values 0,50 = 30 seconds} + [Shortcuts] ;Modify all the shortcuts of the GUI here diff --git a/main.lfm b/main.lfm index 71282432..d5712734 100644 --- a/main.lfm +++ b/main.lfm @@ -1164,7 +1164,6 @@ inherited MainForm: TMainForm AutoSize = True BorderSpacing.Bottom = 2 ButtonHeight = 23 - ButtonWidth = 23 Caption = 'MainToolBar' Images = ImageList16 Indent = 4 @@ -1185,6 +1184,7 @@ inherited MainForm: TMainForm Left = 225 Height = 23 Top = 2 + Width = 5 Caption = 'ToolButton2' Style = tbsDivider end @@ -1213,6 +1213,7 @@ inherited MainForm: TMainForm Left = 174 Height = 23 Top = 2 + Width = 5 Caption = 'ToolButton6' Style = tbsDivider end @@ -1220,6 +1221,7 @@ inherited MainForm: TMainForm Left = 378 Height = 23 Top = 2 + Width = 5 Caption = 'ToolButton7' Style = tbsDivider end @@ -1256,6 +1258,7 @@ inherited MainForm: TMainForm Left = 350 Height = 23 Top = 2 + Width = 5 Caption = 'sepAltSpeed' Style = tbsDivider end @@ -1263,6 +1266,7 @@ inherited MainForm: TMainForm Left = 299 Height = 23 Top = 2 + Width = 5 Caption = 'sepQueue' Style = tbsDivider end @@ -10618,4 +10622,11 @@ inherited MainForm: TMainForm 0000000000000000000000000000 } end + object LocalWatchTimer: TTimer[31] + Enabled = False + Interval = 60000 + OnTimer = LocalWatchTimerTimer + left = 40 + top = 136 + end end diff --git a/main.pas b/main.pas index 891b7d43..7d1e5c60 100644 --- a/main.pas +++ b/main.pas @@ -245,6 +245,7 @@ TMainForm = class(TBaseForm) MenuItem502: TMenuItem; SearchToolbar: TToolBar; tbSearchCancel: TToolButton; + LocalWatchTimer: TTimer; txMagLabel: TLabel; txMagnetLink: TEdit; MenuItem101: TMenuItem; @@ -558,6 +559,7 @@ TMainForm = class(TBaseForm) Y: Integer); procedure gTorrentsMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); + procedure LocalWatchTimerTimer(Sender: TObject); procedure lvFilesMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure MenuShowExecute(Sender: TObject); @@ -652,6 +654,9 @@ TMainForm = class(TBaseForm) FLastClipboardLink: string; FLinuxOpenDoc: integer; FFromNow: boolean; + FWatchLocalFolder: string; + FWatchDestinationFolder: string; + FWatchDownloading: boolean; FRow: integer; FCol: integer; {$ifdef windows} @@ -729,6 +734,7 @@ TMainForm = class(TBaseForm) procedure CheckAddTorrents; procedure CheckClipboardLink; procedure CenterDetailsWait; + procedure ReadLocalFolderWatch; function GetPageInfoType(pg: TTabSheet): TAdvInfoType; procedure DetailsUpdated; function RenameTorrent(TorrentId: integer; const OldPath, NewName: string): boolean; @@ -930,7 +936,19 @@ function WndCallback(Ahwnd: HWND; uMsg: UINT; wParam: WParam; lParam: LParam):LR {$endif windows} - +procedure TMainForm.ReadLocalFolderWatch; +var + sr: TSearchRec; +begin + if FPendingTorrents.Count = 0 then + begin + if FindFirstUTF8(FWatchLocalFolder+'*.torrent',faAnyFile,sr)=0 then + repeat + FPendingTorrents.Add(FWatchLocalFolder+sr.Name); + until FindNextUTF8(sr)<>0; + FindCloseUTF8(sr); + end; +end; function GetHumanSize(sz: double; RoundTo: integer; const EmptyStr: string): string; var @@ -1560,6 +1578,15 @@ procedure TMainForm.FormCreate(Sender: TObject); acBigToolbar.Execute; FFromNow := Ini.ReadBool('MainForm','FromNow',false); + FWatchLocalFolder := Ini.ReadString('Interface','WatchLocalFolder',''); + if FWatchLocalFolder <> '' then + if DirPathExists(FWatchLocalFolder) and DirectoryIsWritable(FWatchLocalFolder) then + begin + FWatchLocalFolder := AppendPathDelim(FWatchLocalFolder); + FWatchDestinationFolder := Ini.ReadString('Interface','WatchDestinationFolder',''); + LocalWatchTimer.Interval:=trunc(Ini.ReadFloat('Interface','WatchInterval',1)*60000); + LocalWatchTimer.Enabled := true; + end; LoadColumns(gTorrents, 'TorrentsList'); TorrentColumnsChanged; LoadColumns(lvFiles, 'FilesList'); @@ -2489,6 +2516,7 @@ function TMainForm.DoAddTorrent(const FileName: Utf8String): boolean; IniSec:='AddTorrent.' + FCurConn; FillDownloadDirs(cbDestFolder, 'LastDownloadDir'); + if (FWatchDownloading) and (FWatchDestinationFolder <> '') then cbDestFolder.Text:=FWatchDestinationFolder; req:=TJSONObject.Create; try @@ -2597,6 +2625,7 @@ function TMainForm.DoAddTorrent(const FileName: Utf8String): boolean; AppNormal; ok:=not Ini.ReadBool('Interface', 'ShowAddTorrentWindow', True); + if FWatchDownloading then ok:= true; if ok then btSelectAllClick(nil) else begin @@ -2692,7 +2721,7 @@ function TMainForm.DoAddTorrent(const FileName: Utf8String): boolean; SelectTorrent(id, 2000); id:=0; - if Ini.ReadBool('Interface', 'DeleteTorrentFile', False) and not IsProtocolSupported(FileName) then + if (Ini.ReadBool('Interface', 'DeleteTorrentFile', False) and not IsProtocolSupported(FileName)) or (FWatchDownloading) then DeleteFileUTF8(FileName); Ini.WriteInteger(IniSec, 'PeerLimit', edPeerLimit.Value); @@ -3677,6 +3706,17 @@ procedure TMainForm.gTorrentsMouseUp(Sender: TObject; Button: TMouseButton; if Button = mbRight then pmTorrents.PopUp; end; +procedure TMainForm.LocalWatchTimerTimer(Sender: TObject); +begin + ReadLocalFolderWatch; + if FPendingTorrents.Count > 0 then + begin + FWatchDownloading := true; + TickTimerTimer(nil); + end; +end; + + procedure TMainForm.lvFilesMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin @@ -7527,6 +7567,7 @@ procedure TMainForm.CheckAddTorrents; finally if WasHidden then HideTaskbarButton; + FWatchDownloading := false; end; end; finally diff --git a/readme.txt b/readme.txt index b95dd637..e7bf5778 100644 --- a/readme.txt +++ b/readme.txt @@ -82,7 +82,8 @@ ADVANCED PARAMETERS There are some parameters in the transgui.ini file, that can not be modified via the GUI. More info on: https://github.com/transmission-remote-gui/transgui/issues/924 (File Manager & Shortcuts) -and https://github.com/transmission-remote-gui/transgui/issues/1020 (User Defined Menu -Windows Only-) +, https://github.com/transmission-remote-gui/transgui/issues/1020 (User Defined Menu -Windows Only-) +and https://github.com/transmission-remote-gui/transgui/issues/1070 (.torrent Auto Opening) [Interface] ; Maximum number of elements in the folder history list @@ -102,6 +103,12 @@ FileManagerDefaultParam={Alternate parameters, could be left blank} GlobalHotkey={Virtual Key Code} full list here http://docwiki.embarcadero.com/RADStudio/Seattle/en/Virtual_Key_Codes (Plus VK_A...VK_Z and VK_0..VK_9) GlobalHotkeyMod={Modifier Key} [MOD_SHIFT , MOD_CONTROL , MOD_ALT , MOD_WIN alone or combined with + sign] +[Interface] +WatchLocalFolder= {LOCAL Folder to watch for torrent files} +WatchDestinationFolder= {REMOTE destination where the data would be saved if missing or empty last destination folder is used} +WatchInterval=1 {Time period in MINUTES between folder scans for torrents, may be fractional values 0,50 = 30 seconds} + + [Shortcuts] ;Modify all the shortcuts of the GUI here diff --git a/transgui.lpi b/transgui.lpi index aebfb168..dda3cbac 100644 --- a/transgui.lpi +++ b/transgui.lpi @@ -1,7 +1,7 @@ - +