Skip to content

Commit

Permalink
Implemented paste feature and timecode format selector dialog
Browse files Browse the repository at this point in the history
+ added a menu item to open online wiki
+ removed unused constants and resourcestrings
  • Loading branch information
m-audio91 committed Sep 20, 2017
1 parent 1ea894a commit 87a246f
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 50 deletions.
7 changes: 6 additions & 1 deletion umain.lfm
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ object SBMain: TSBMain
Top = 216
Width = 500
AllowDropFiles = True
Caption = 'SubzBor - سابزبُر'
Caption = 'SubzBor v1.1.0'
ClientHeight = 330
ClientWidth = 500
Constraints.MinHeight = 350
Constraints.MinWidth = 500
DefaultMonitor = dmPrimary
Menu = TopMenu
OnCloseQuery = FormCloseQuery
OnCreate = FormCreate
OnDropFiles = FormDropFiles
OnShow = FormShow
SessionProperties = 'Left;SubtitleFile.InitialDir;Top'
Expand Down Expand Up @@ -644,6 +645,10 @@ object SBMain: TSBMain
Caption = 'درباره'
OnClick = MenuSBAboutClick
end
object MenuSBGuide: TMenuItem
Caption = 'آموزش'
OnClick = MenuSBGuideClick
end
object MenuSBLang: TMenuItem
Caption = 'زبان/Lang'
object MenuSBLangTranslateIt: TMenuItem
Expand Down
115 changes: 70 additions & 45 deletions umain.pas
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ interface
Classes, SysUtils, FileUtil, LazFileUtils, Forms, Controls, Graphics, Dialogs,
LclIntf, IniPropStorage, ExtCtrls, StdCtrls, Menus, EditBtn, ComCtrls,
Buttons, uDatas, uPrefs, uAbout, uProbe, uProc, uTimeSlice, ui18nGuide,
CommonFileUtils, CommonGUIUtils, uCharEnc, uResourcestrings, uSBConst,
uTimeSliceEditEx, uListBoxUtils, LCLTranslator;
CommonFileUtils, CommonGUIUtils, uTimeCode, uCharEnc, uResourcestrings,
uSBConst, uTimeSliceEditEx, uListBoxUtils, uTimeCodeFormatDialog,
LCLTranslator;

type

Expand Down Expand Up @@ -60,6 +61,7 @@ TSBMain = class(TForm)
MenuSBLangTranslateIt: TMenuItem;
MenuSBLangDownloadMore: TMenuItem;
MenuSBLangSep: TMenuItem;
MenuSBGuide: TMenuItem;
procedure IniPropsRestoringProperties(Sender: TObject);
procedure IniPropsRestoreProperties(Sender: TObject);
procedure MenuSBLangDownloadMoreClick(Sender: TObject);
Expand All @@ -72,15 +74,19 @@ TSBMain = class(TForm)
procedure ClearTimeSlicesClick(Sender: TObject);
procedure LoadTimeSlicesClick(Sender: TObject);
procedure MenuSBAboutClick(Sender: TObject);
procedure MenuSBGuideClick(Sender: TObject);
procedure MenuSBLangTranslateItClick(Sender: TObject);
procedure SaveTimeSlicesClick(Sender: TObject);
procedure MenuSBPrefsClick(Sender: TObject);
procedure SubtitleFileAcceptFileName(Sender: TObject; var Value: String);
procedure TimeSlicesListDblClick(Sender: TObject);
procedure AddTimeSliceClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
FLangID: String;
FLangsDir: String;
FFormatSettings: TTimeCodeFormatSettings;
FInputsFormatDefined: Boolean;
FProbeInfo: TSubzBorProbeInfo;
FProbeResult: TSubzBorProbeResult;
FProbeThread: TSubzBorProbeThread;
Expand All @@ -91,6 +97,7 @@ TSBMain = class(TForm)
procedure Status(const MsgType, Msg: String; Bar: boolean = False;
BarPos: Word = 0; HideBarAfter: Word = 0);
procedure SetGlyphs;
procedure DefineUserInputsFormat;
procedure SaveDummyVidResToFile(const Dir: String);
procedure LoadTimeSlicesFromFile(const F: String);
procedure StartProbe;
Expand Down Expand Up @@ -119,6 +126,12 @@ implementation

{ TSBMain }

procedure TSBMain.FormCreate(Sender: TObject);
begin
FInputsFormatDefined := False;
FFormatSettings := DefaultTimeCodeFormatSettings;
end;

procedure TSBMain.SetGlyphs;
begin
SBDatas.ChangeGlyph(AddTimeSlice);
Expand All @@ -130,6 +143,23 @@ procedure TSBMain.SetGlyphs;
SBDatas.ChangeGlyph(SubtitleFile);
end;

procedure TSBMain.DefineUserInputsFormat;
var
fd: TTimeCodeFormatDialog;
begin
SBDatas.TaskDlg.Execute(Self.Handle);
fd := TTimeCodeFormatDialog.Create(Self);
try
fd.Value.TimeCodeFormat := FFormatSettings;
fd.ShowModal;
if fd.ModalResult = mrOK then
FFormatSettings := fd.Value.TimeCodeFormat;
finally
fd.Free;
end;
FInputsFormatDefined := True;
end;

procedure TSBMain.SaveDummyVidResToFile(const Dir: String);
var
pic: TPicture;
Expand Down Expand Up @@ -159,7 +189,6 @@ procedure TSBMain.FormShow(Sender: TObject);
begin
SetGlyphs;
CurrectFormSize;
Status(rsHint, rsReady);
ListTranslations;
HandleTranslation(LangID);
end;
Expand All @@ -174,7 +203,7 @@ procedure TSBMain.FormCloseQuery(Sender: TObject; var CanClose: boolean);

procedure TSBMain.IniPropsRestoringProperties(Sender: TObject);
begin
SessionProperties := SessionProperties+';LangID;';
SessionProperties := SessionProperties+';LangID';
end;

procedure TSBMain.IniPropsRestoreProperties(Sender: TObject);
Expand Down Expand Up @@ -212,8 +241,11 @@ procedure TSBMain.AddTimeSliceClick(Sender: TObject);
var
tse: TTimeSliceEditEx;
begin
if not FInputsFormatDefined then
DefineUserInputsFormat;
tse := TTimeSliceEditEx.Create(Self);
try
tse.PasteFormat := FFormatSettings;
tse.ShowModal;
if tse.ModalResult = mrOk then
TimeSlicesList.Items.Add(tse.Value);
Expand Down Expand Up @@ -264,50 +296,36 @@ procedure TSBMain.LoadTimeSlicesFromFile(const F: String);
tsl: TTimeSliceList;
ts: TTimeSlice;
sl: TStringList;
i,ri: Integer;
i: Integer;
begin
if SBDatas.TaskDlg.Execute(Self.Handle) then
if SBDatas.TaskDlg.ModalResult = mrOk then
begin
try
ri := SBDatas.TaskDlg.RadioButton.Index;
case ri of
0:tsl.LoadFromFileEx(F);
1..2:
begin
sl := TStringList.Create;
try
sl.LoadFromFile(F);
for i := 0 to sl.Count-1 do
begin
case ri of
1:begin
ts.Initialize(2, ':', '.', '-');
ts.ValueAsString := sl[i].Split(',')[0];
ts.Delay := sl[i].Split(',')[1].Replace(',','.').ToDouble;
end;
2:begin
ts.Initialize(3, ':', ',', '-');
ts.ValueAsString := sl[i];
end;
end;
ts.Initialize(3, ':', '.', '-');
sl[i] := ts.ValueAsStringEx;
end;
tsl.ExtendedValue := sl.Text;
finally
sl.Free;
end;
end;
end;
if tsl.Incremental then
TimeSlicesList.Items.Text := tsl.ExtendedValue
else
raise Exception.Create(rsFatal);
except
ShowError(rsTimeSliceFileNotRead, rsFatal);
if not FInputsFormatDefined then
DefineUserInputsFormat;

sl := TStringList.Create;
try
try
tsl.LoadFromFileEx(F);
if tsl.Incremental then Exit;

sl.LoadFromFile(F);
for i := 0 to sl.Count-1 do
begin
ts.Initialize(FFormatSettings.MillisecondPrecision, FFormatSettings.MajorSep,
FFormatSettings.MinorSep, DefaultTimeSliceSep);
ts.ValueAsString := sl[i];
ts.Initialize;
sl[i] := ts.ValueAsStringEx;
end;
tsl.ExtendedValue := sl.Text;
if not tsl.Incremental then
raise Exception.Create(rsFatal);
finally
TimeSlicesList.Items.Text := tsl.ExtendedValue;
sl.Free;
end;
except
ShowError(rsTimeSliceFileNotRead, rsFatal);
end;
end;

procedure TSBMain.SaveTimeSlicesClick(Sender: TObject);
Expand Down Expand Up @@ -437,6 +455,11 @@ procedure TSBMain.MenuSBPrefsClick(Sender: TObject);
procedure TSBMain.MenuSBAboutClick(Sender: TObject);
begin
SBAbout.ShowModal;
end;

procedure TSBMain.MenuSBGuideClick(Sender: TObject);
begin
OpenURL(urlGuide);
end;

procedure TSBMain.MenuSBLangTranslateItClick(Sender: TObject);
Expand Down Expand Up @@ -524,6 +547,8 @@ procedure TSBMain.HandleTranslation(const LID: String);
mi.Checked := True;
SBAbout.UsedTools.BiDiMode := bd;
SBAbout.ContactMe.BiDiMode := bd;

Status(rsHint, rsReady);
end;

procedure TSBMain.Status(const MsgType, Msg: String; Bar: boolean; BarPos: Word;
Expand Down
1 change: 0 additions & 1 deletion uresourcestrings.pas
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ interface
rsExportingImgBased = 'در حال خروجی گرفتن، خونسرد باشید. زیرنویس های PGS و VobSub زمان به مراتب بیشتری می خواهد';
rsExportingDone = 'زیرنویس با موفقیت ذخیره شد';
rsExportingFailed = 'عملیات خروجی گرفتن با خطا مواجه شد';
rsMakingReporstDirFiled = 'موفق به ساختن پوشه گزارش ها نشد';
rsCloseWhileProcWarn = 'عملیاتی در حال اجراست. اگر سابزبُر را اجبارا ببنید نشتی حافظه خواهد داشت و برخی داده ها تا زمان لاگ اوت بعدی در حافظه می مانند' + LineEnding + 'هنوز هم می خواهید اجبارا خارج شوید؟';
rsNoTempsDir = 'ساخت پوشه فایل های موقتی با خطا مواجه شد';
rsNoReportsDir = 'ساخت پوشه گزارش ها با خطا مواجه شد';
Expand Down
4 changes: 1 addition & 3 deletions usbconst.pas
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ interface
ContactMail = 'm.audio91@gmail.com';
urlIssueTracker = 'https://github.com/m-audio91/SubzBor/issues';
urlSBLanguages = 'https://github.com/m-audio91/SubzBor/tree/master/languages';
SB13TimingsFormat = 'Start=00:00:00.000 End=00:00:00.000 Delay=0';
SB12TimingsFormat = '00:00:00.00-00:00:00.00,0';
SMMVideoSplitterTimingsFormat = '00:00:00,000-00:00:00,000';
urlGuide = 'https://github.com/m-audio91/SubzBor/wiki/Quick-Start-Guide';

implementation

Expand Down

0 comments on commit 87a246f

Please sign in to comment.