From da78f2540ceb11f95f4669ab0975849a0817fade Mon Sep 17 00:00:00 2001 From: Jure Date: Thu, 21 May 2020 20:37:47 +0200 Subject: [PATCH] feature for adding multiple magnet links --- addlink.lfm | 42 ++++++++-------- addlink.pas | 20 ++++++-- addtorrent.lfm | 26 ++++++---- addtorrent.pas | 2 + main.lfm | 130 +++++++++++++++++-------------------------------- main.pas | 26 +++++++--- transgui.lpi | 16 +++--- 7 files changed, 131 insertions(+), 131 deletions(-) diff --git a/addlink.lfm b/addlink.lfm index dbc11f9e..4ced9dda 100644 --- a/addlink.lfm +++ b/addlink.lfm @@ -1,21 +1,20 @@ inherited AddLinkForm: TAddLinkForm - Left = 354 - Height = 93 - Top = 193 - Width = 574 + Left = 502 + Height = 186 + Top = 373 + Width = 438 AutoSize = True BorderIcons = [biSystemMenu] - BorderStyle = bsDialog Caption = 'Add torrent link' - ClientHeight = 93 - ClientWidth = 574 + ClientHeight = 186 + ClientWidth = 438 OnCreate = FormCreate Position = poMainFormCenter object Buttons: TButtonPanel[0] Left = 8 Height = 26 - Top = 59 - Width = 558 + Top = 152 + Width = 422 BorderSpacing.Left = 8 BorderSpacing.Right = 8 BorderSpacing.Bottom = 8 @@ -35,30 +34,31 @@ inherited AddLinkForm: TAddLinkForm end object Panel1: TPanel[1] Left = 8 - Height = 43 + Height = 136 Top = 8 - Width = 558 + Width = 422 Align = alClient BorderSpacing.Around = 8 BevelOuter = bvNone - ClientHeight = 43 - ClientWidth = 558 + ClientHeight = 136 + ClientWidth = 422 TabOrder = 0 object txLink: TLabel Left = 0 - Height = 14 + Height = 15 Top = 0 - Width = 183 - Caption = 'URL of a .torrent file or a magnet link:' + Width = 267 + Caption = 'URL of a .torrent file or a magnet link(one per line):' ParentColor = False end - object edLink: TEdit + object meLink: TMemo Left = 0 - Height = 21 - Top = 20 - Width = 558 - Anchors = [akTop, akLeft, akRight] + Height = 115 + Top = 21 + Width = 422 + Anchors = [akTop, akLeft, akRight, akBottom] TabOrder = 0 + WordWrap = False end end end diff --git a/addlink.pas b/addlink.pas index 6aa08f25..2f70b7c4 100644 --- a/addlink.pas +++ b/addlink.pas @@ -16,7 +16,7 @@ along with Transmission Remote GUI; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - In addition, as a special exception, the copyright holders give permission to + In addition, as a special exception, the copyright holders give permission to link the code of portions of this program with the OpenSSL library under certain conditions as described in each individual source file, and distribute linked combinations including the two. @@ -48,7 +48,7 @@ interface TAddLinkForm = class(TBaseForm) Buttons: TButtonPanel; - edLink: TEdit; + meLink: TMemo; Panel1: TPanel; txLink: TLabel; procedure btOKClick(Sender: TObject); @@ -66,10 +66,20 @@ implementation { TAddLinkForm } procedure TAddLinkForm.btOKClick(Sender: TObject); +var + i: integer; + ok: Boolean = false; begin - edLink.Text:=Trim(edLink.Text); - if edLink.Text = '' then begin - edLink.SetFocus; + for i := meLink.Lines.Count - 1 downto 0 do + begin + meLink.Lines[i]:=Trim(meLink.Lines[i]); + if meLink.Lines[i] <> '' then ok := true // have at least one link + else meLink.Lines.Delete(i); // remove empty lines + end; + + if not ok then + begin + meLink.SetFocus; MessageDlg(SNoLink, mtError, [mbOK], 0); exit; end; diff --git a/addtorrent.lfm b/addtorrent.lfm index 3221e8e7..40ffbda7 100644 --- a/addtorrent.lfm +++ b/addtorrent.lfm @@ -1,7 +1,7 @@ inherited AddTorrentForm: TAddTorrentForm - Left = 494 + Left = 1165 Height = 457 - Top = 276 + Top = 360 Width = 508 HorzScrollBar.Page = 505 VertScrollBar.Page = 404 @@ -75,7 +75,7 @@ inherited AddTorrentForm: TAddTorrentForm Height = 26 Hint = 'Browse folder' Top = 13 - Width = 91 + Width = 88 Anchors = [akTop, akRight] Caption = 'Browse...' OnClick = btBrowseClick @@ -95,17 +95,17 @@ inherited AddTorrentForm: TAddTorrentForm Left = 10 Height = 23 Top = 96 - Width = 467 + Width = 465 Anchors = [akTop, akLeft, akRight] OnChange = edSaveAsChange TabOrder = 2 end object edExtension: TEdit - Left = 8 + Left = 10 Height = 23 Hint = 'for example: *.avi *.mkv tom*jerry*.avi' Top = 56 - Width = 467 + Width = 465 Anchors = [akTop, akLeft, akRight] OnChange = edSaveAsChange ParentShowHint = False @@ -117,7 +117,7 @@ inherited AddTorrentForm: TAddTorrentForm Height = 15 Hint = 'for example: *.avi *.mkv tom*jerry*.avi' Top = 40 - Width = 59 + Width = 57 Caption = 'Template: ' ParentColor = False ParentShowHint = False @@ -201,6 +201,14 @@ inherited AddTorrentForm: TAddTorrentForm ShowHint = True TabOrder = 5 end + object cbApplyAll: TCheckBox + Left = 10 + Height = 19 + Top = 127 + Width = 80 + Caption = 'Apply to all' + TabOrder = 6 + end end object gbContents: TGroupBox[1] Left = 8 @@ -237,12 +245,12 @@ inherited AddTorrentForm: TAddTorrentForm Top = 40 Width = 467 Anchors = [akTop, akLeft, akRight, akBottom] - Columns = < + Columns = < item ReadOnly = True Title.Caption = 'File name' Width = 350 - end + end item ReadOnly = True Title.Caption = 'Size' diff --git a/addtorrent.pas b/addtorrent.pas index 0a4b2b23..1f90742f 100644 --- a/addtorrent.pas +++ b/addtorrent.pas @@ -52,6 +52,7 @@ TFilesTree = class; { TAddTorrentForm } TAddTorrentForm = class(TBaseForm) + cbApplyAll: TCheckBox; DelButton: TBitBtn; btSelectAll: TButton; btSelectNone: TButton; @@ -95,6 +96,7 @@ TAddTorrentForm = class(TBaseForm) procedure TreeStateChanged(Sender: TObject); procedure UpdateSize; public + ApplyToAll: boolean; OrigCaption: string; Extension : string; property FilesTree: TFilesTree read FTree; diff --git a/main.lfm b/main.lfm index 836df801..567bc4e8 100644 --- a/main.lfm +++ b/main.lfm @@ -1,7 +1,7 @@ inherited MainForm: TMainForm - Left = 1468 + Left = 2020 Height = 702 - Top = 126 + Top = 314 Width = 984 HorzScrollBar.Page = 740 VertScrollBar.Page = 420 @@ -301,7 +301,7 @@ inherited MainForm: TMainForm Height = 272 Top = 26 Width = 976 - HorzScrollBar.Page = 721 + HorzScrollBar.Page = 722 VertScrollBar.Page = 268 Align = alClient ClientHeight = 268 @@ -354,7 +354,7 @@ inherited MainForm: TMainForm Left = 578 Height = 15 Top = 4 - Width = 50 + Width = 51 Caption = 'txCreated' ParentColor = False end @@ -362,7 +362,7 @@ inherited MainForm: TMainForm Left = 4 Height = 15 Top = 22 - Width = 51 + Width = 50 Caption = 'Total size:' ParentColor = False end @@ -386,7 +386,7 @@ inherited MainForm: TMainForm Left = 578 Height = 15 Top = 22 - Width = 42 + Width = 43 Caption = 'txPieces' ParentColor = False end @@ -402,7 +402,7 @@ inherited MainForm: TMainForm Left = 181 Height = 15 Top = 40 - Width = 36 + Width = 37 Caption = 'txHash' ParentColor = False ShowAccelChar = False @@ -420,7 +420,7 @@ inherited MainForm: TMainForm Left = 578 Height = 15 Top = 40 - Width = 63 + Width = 64 Caption = 'txComment' ParentColor = False ShowAccelChar = False @@ -437,7 +437,7 @@ inherited MainForm: TMainForm Left = 181 Height = 15 Top = 58 - Width = 60 + Width = 61 Caption = 'txAddedOn' ParentColor = False end @@ -453,7 +453,7 @@ inherited MainForm: TMainForm Left = 578 Height = 15 Top = 58 - Width = 84 + Width = 85 Caption = 'txCompletedOn' ParentColor = False end @@ -488,7 +488,7 @@ inherited MainForm: TMainForm Left = 578 Height = 15 Top = 86 - Width = 42 + Width = 43 Caption = 'txLabels' ParentColor = False end @@ -523,7 +523,7 @@ inherited MainForm: TMainForm Left = 140 Height = 15 Top = 4 - Width = 41 + Width = 42 Caption = 'txStatus' ParentColor = False end @@ -539,7 +539,7 @@ inherited MainForm: TMainForm Left = 407 Height = 15 Top = 4 - Width = 34 + Width = 35 Caption = 'txError' ParentColor = False end @@ -555,7 +555,7 @@ inherited MainForm: TMainForm Left = 651 Height = 15 Top = 4 - Width = 66 + Width = 67 Caption = 'txRemaining' ParentColor = False end @@ -571,7 +571,7 @@ inherited MainForm: TMainForm Left = 140 Height = 15 Top = 22 - Width = 76 + Width = 77 Caption = 'txDownloaded' ParentColor = False end @@ -587,7 +587,7 @@ inherited MainForm: TMainForm Left = 407 Height = 15 Top = 22 - Width = 60 + Width = 61 Caption = 'txUploaded' ParentColor = False end @@ -603,7 +603,7 @@ inherited MainForm: TMainForm Left = 651 Height = 15 Top = 22 - Width = 48 + Width = 49 Caption = 'txWasted' ParentColor = False end @@ -619,7 +619,7 @@ inherited MainForm: TMainForm Left = 140 Height = 15 Top = 40 - Width = 72 + Width = 73 Caption = 'txDownSpeed' ParentColor = False end @@ -635,7 +635,7 @@ inherited MainForm: TMainForm Left = 407 Height = 15 Top = 40 - Width = 56 + Width = 57 Caption = 'txUpSpeed' ParentColor = False end @@ -651,7 +651,7 @@ inherited MainForm: TMainForm Left = 651 Height = 15 Top = 40 - Width = 36 + Width = 37 Caption = 'txRatio' ParentColor = False end @@ -667,7 +667,7 @@ inherited MainForm: TMainForm Left = 140 Height = 15 Top = 58 - Width = 67 + Width = 68 Caption = 'txDownLimit' ParentColor = False end @@ -683,7 +683,7 @@ inherited MainForm: TMainForm Left = 407 Height = 15 Top = 58 - Width = 51 + Width = 52 Caption = 'txUpLimit' ParentColor = False end @@ -713,7 +713,7 @@ inherited MainForm: TMainForm Left = 140 Height = 15 Top = 76 - Width = 39 + Width = 40 Caption = 'txSeeds' ParentColor = False end @@ -729,7 +729,7 @@ inherited MainForm: TMainForm Left = 407 Height = 15 Top = 76 - Width = 37 + Width = 38 Caption = 'txPeers' ParentColor = False end @@ -737,7 +737,7 @@ inherited MainForm: TMainForm Left = 541 Height = 15 Top = 76 - Width = 56 + Width = 57 Caption = 'Max peers:' ParentColor = False end @@ -745,7 +745,7 @@ inherited MainForm: TMainForm Left = 651 Height = 15 Top = 76 - Width = 59 + Width = 61 Caption = 'txMaxPeers' ParentColor = False end @@ -753,7 +753,7 @@ inherited MainForm: TMainForm Left = 4 Height = 15 Top = 94 - Width = 41 + Width = 40 Caption = 'Tracker:' ParentColor = False end @@ -769,7 +769,7 @@ inherited MainForm: TMainForm Left = 262 Height = 15 Top = 94 - Width = 98 + Width = 97 Caption = 'Tracker update on:' ParentColor = False end @@ -793,7 +793,7 @@ inherited MainForm: TMainForm Left = 651 Height = 15 Top = 94 - Width = 63 + Width = 64 Caption = 'txLastActive' ParentColor = False end @@ -1103,63 +1103,63 @@ inherited MainForm: TMainForm TabOrder = 2 OnContextPopup = MainToolBarContextPopup object ToolButton1: TToolButton - Left = 179 + Left = 178 Top = 2 Action = acAddTorrent AutoSize = True ShowCaption = False end object ToolButton2: TToolButton - Left = 225 + Left = 224 Height = 23 Top = 2 Caption = 'ToolButton2' Style = tbsDivider end object ToolButton3: TToolButton - Left = 230 + Left = 229 Top = 2 Action = acStartTorrent AutoSize = True ShowCaption = False end object ToolButton4: TToolButton - Left = 253 + Left = 252 Top = 2 Action = acStopTorrent AutoSize = True ShowCaption = False end object tbStopTorrent: TToolButton - Left = 276 + Left = 275 Top = 2 Action = acRemoveTorrent AutoSize = True ShowCaption = False end object ToolButton6: TToolButton - Left = 174 + Left = 173 Height = 23 Top = 2 Caption = 'ToolButton6' Style = tbsDivider end object ToolButton7: TToolButton - Left = 378 + Left = 377 Height = 23 Top = 2 Caption = 'ToolButton7' Style = tbsDivider end object ToolButton8: TToolButton - Left = 383 + Left = 382 Top = 2 Action = acDaemonOptions AutoSize = True ShowCaption = False end object ToolButton9: TToolButton - Left = 202 + Left = 201 Top = 2 Action = acAddLink AutoSize = True @@ -1174,42 +1174,42 @@ inherited MainForm: TMainForm Style = tbsDropDown end object tbtAltSpeed: TToolButton - Left = 355 + Left = 354 Top = 2 Action = acAltSpeed AutoSize = True ShowCaption = False end object sepAltSpeed: TToolButton - Left = 350 + Left = 349 Height = 23 Top = 2 Caption = 'sepAltSpeed' Style = tbsDivider end object sepQueue: TToolButton - Left = 299 + Left = 298 Height = 23 Top = 2 Caption = 'sepQueue' Style = tbsDivider end object tbQMoveUp: TToolButton - Left = 304 + Left = 303 Top = 2 Action = acQMoveUp AutoSize = True ShowCaption = False end object tbQMoveDown: TToolButton - Left = 327 + Left = 326 Top = 2 Action = acQMoveDown AutoSize = True ShowCaption = False end object ToolButton5: TToolButton - Left = 406 + Left = 405 Hint = 'Application Options (Ctrl+F9)' Top = 2 Action = acConnOptions @@ -1219,19 +1219,17 @@ inherited MainForm: TMainForm ShowCaption = False end object ToolButton10: TToolButton - Left = 429 + Left = 428 Height = 23 Top = 2 Caption = 'ToolButton10' Style = tbsSeparator end object panSearch: TPanel - AnchorSideLeft.Control = ToolButton10 - Left = 437 + Left = 436 Height = 23 Top = 2 Width = 395 - Anchors = [akLeft, akRight] BorderSpacing.Top = 2 BorderSpacing.Bottom = 2 BevelOuter = bvNone @@ -1405,42 +1403,6 @@ inherited MainForm: TMainForm Caption = '&Torrent' object miConnect: TMenuItem Caption = 'Connect to Transmission' - Bitmap.Data = { - 36040000424D3604000000000000360000002800000010000000100000000100 - 2000000000000004000064000000640000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 00FF000000FF0000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000FF6666 - 00FF666600FF000000FF000000FF000000000000000000000000000000000000 - 0000000000000000000000000000000000FF000000FF000000FF666600FF8080 - 00FF808000FF808000FF808000FF000000FF000000FF00000000000000000000 - 00000000000000000000000000FF868686FF868686FF000000FF006666FF0080 - 80FF008080FFC0C0C0FFC0C0C0FF808000FF808000FF000000FF000000000000 - 000000000000000000FF868686FFC0C0C0FFF8F8F8FF000000FF000000FF00FF - FFFF00FFFFFF008080FFD7D7D7FFF8F8F8FFF8F8F8FF808000FF000000000000 - 0000000000FF868686FFC0C0C0FFF8F8F8FFC0C0C0FFB2B2B2FF868686FF0000 - 00FF000000FFC0C0C0FFD7D7D7FFF8F8F8FF808000FF00000000000000000000 - 00FF868686FFC0C0C0FFF8F8F8FFC0C0C0FFC0C0C0FFC0C0C0FFB2B2B2FFA4A0 - A0FF868686FF000000FF000000FFC0C0C0FF000000FF00000000000000FF8686 - 86FFC0C0C0FFF8F8F8FFDDDDDDFFDDDDDDFFC0C0C0FFB2B2B2FFC0C0C0FFB2B2 - B2FFB2B2B2FF868686FF868686FF000000FF000000FF00000000868686FFC0C0 - C0FFF8F8F8FF868686FF868686FFC0C0C0FFC0C0C0FFC0C0C0FFB2B2B2FFB2B2 - B2FFB2B2B2FFA4A0A0FFA4A0A0FF868686FF868686FF00000000868686FFF8F8 - F8FFDDDDDDFFDDDDDDFFC0C0C0FF868686FF868686FFB2B2B2FFC0C0C0FFB2B2 - B2FFB2B2B2FFB2B2B2FFA4A0A0FFA4A0A0FF868686FF00000000000000008686 - 86FF868686FFDDDDDDFFDDDDDDFFCCCCCCFFCCCCCCFF868686FF868686FFB2B2 - B2FFB2B2B2FFA4A0A0FFA4A0A0FF868686FF0000000000000000000000000000 - 000000000000868686FF868686FFDDDDDDFFCCCCCCFFCCCCCCFFC0C0C0FF8686 - 86FF868686FFB2B2B2FF868686FF000000000000000000000000000000000000 - 0000000000FF868686FF00000000868686FF868686FFCCCCCCFFCCCCCCFFC0C0 - C0FFC0C0C0FF868686FF00000000000000000000000000000000000000000000 - 00FF868686FF00000000000000000000000000000000868686FF868686FFCCCC - CCFF868686FF0000000000000000000000000000000000000000000000FF8686 - 86FF000000000000000000000000000000000000000000000000000000008686 - 86FF000000000000000000000000000000000000000000000000 - } ImageIndex = 18 object sepCon1: TMenuItem Tag = 1 diff --git a/main.pas b/main.pas index 7835d364..cfb3f1d1 100644 --- a/main.pas +++ b/main.pas @@ -16,7 +16,7 @@ along with Transmission Remote GUI; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - In addition, as a special exception, the copyright holders give permission to + In addition, as a special exception, the copyright holders give permission to link the code of portions of this program with the OpenSSL library under certain conditions as described in each individual source file, and distribute linked combinations including the two. @@ -719,6 +719,7 @@ TMainForm = class(TBaseForm) FCalcAvg: boolean; FPasswords: TStringList; FAppProps:TApplicationProperties; + FApplyAll: boolean; // add new torrent - apply all procedure UpdateUI; procedure UpdateUIRpcVersion(RpcVersion: integer); @@ -732,7 +733,7 @@ TMainForm = class(TBaseForm) procedure LoadColumns(LV: TVarGrid; const AName: string; FullInfo: boolean = True); function GetTorrentError(t: TJSONObject; Status: integer): string; function SecondsToString(j: integer): string; - function DoAddTorrent(const FileName: Utf8String): boolean; + function DoAddTorrent(const FileName: Utf8String; const MultipleTorrents: boolean = False): boolean; procedure UpdateTray; procedure HideApp; procedure ShowApp; @@ -2303,22 +2304,29 @@ procedure TMainForm.acCheckNewVersionExecute(Sender: TObject); end; procedure TMainForm.acAddLinkExecute(Sender: TObject); +var + i: integer; begin AppBusy; with TAddLinkForm.Create(Self) do try AppNormal; if ShowModal = mrOk then + begin + FApplyAll:=false; + for i := 0 to meLink.Lines.Count - 1 do begin - if isHash(edLink.Text) then edLink.Text := 'magnet:?xt=urn:btih:'+ edLink.Text; - DoAddTorrent(edLink.Text); + if isHash(meLink.Lines[i]) then meLink.Lines[i] := 'magnet:?xt=urn:btih:' + meLink.Lines[i]; + DoAddTorrent(meLink.Lines[i], meLink.Lines.Count > 1); end; + FApplyAll:=false; + end; finally Free; end; end; -function TMainForm.DoAddTorrent(const FileName: Utf8String): boolean; +function TMainForm.DoAddTorrent(const FileName: Utf8String; const MultipleTorrents: boolean = false): boolean; var torrent: string; WaitForm: TBaseForm; @@ -2739,12 +2747,13 @@ function TMainForm.DoAddTorrent(const FileName: Utf8String): boolean; OldDownloadDir:=cbDestFolder.Text; AppNormal; - ok:=not Ini.ReadBool('Interface', 'ShowAddTorrentWindow', True); + ok:=(not Ini.ReadBool('Interface', 'ShowAddTorrentWindow', True)) or FApplyAll; if FWatchDownloading then ok:= true; if ok then btSelectAllClick(nil) else begin HideWaitMsg; + cbApplyAll.Visible := MultipleTorrents; ok:=ShowModal = mrOk; if BorderStyle = bsSizeable then begin Ini.WriteInteger('AddTorrent', 'Width', Width); @@ -2834,6 +2843,9 @@ function TMainForm.DoAddTorrent(const FileName: Utf8String): boolean; if cbStartTorrent.Checked then TorrentAction(id, 'torrent-start'); + if cbApplyAll.Checked then + FApplyAll:=true; + SelectTorrent(id, 2000); id:=0; @@ -7861,12 +7873,14 @@ procedure TMainForm.CheckAddTorrents; else ShowApp; try + FApplyAll:=false; while FPendingTorrents.Count > 0 do begin s:=FPendingTorrents[0]; FPendingTorrents.Delete(0); if s <> '' then DoAddTorrent(s); end; + FApplyAll:=false; finally if WasHidden then HideTaskbarButton; diff --git a/transgui.lpi b/transgui.lpi index ae0c07de..493455f1 100644 --- a/transgui.lpi +++ b/transgui.lpi @@ -1,7 +1,7 @@ - + @@ -22,7 +22,6 @@ - @@ -31,16 +30,21 @@ - - - - + + + + + + + + +