From 294be519781b33287e34ed3ffadb91b015488445 Mon Sep 17 00:00:00 2001 From: Majid Date: Sat, 16 Dec 2017 02:28:24 +0330 Subject: [PATCH] Urls are updated. --- .gitignore | 72 ++++++++++++++++++++++++++++++++++++++++++ PersianTT.dpr | 19 +++++++---- PersianTT.dproj | 4 +-- PersianTT.res | Bin 104480 -> 104508 bytes Src/PersianTT.nsi | 4 +-- Units/UGlobalUnit.pas | 66 ++++++++++++++++++++++++++++++++++---- Units/UfrmAbout.dfm | 20 ++++++------ Units/UfrmAbout.pas | 2 +- Units/UfrmMain.dfm | 3 +- Units/UfrmMain.pas | 12 +++++++ Units/UfrmSplash.dfm | 20 ++---------- Units/UfrmSplash.pas | 1 - 12 files changed, 175 insertions(+), 48 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ac3659f --- /dev/null +++ b/.gitignore @@ -0,0 +1,72 @@ + +# Created by https://www.gitignore.io/api/delphi + +### Delphi ### +# Uncomment these types if you want even more clean repository. But be careful. +# It can make harm to an existing project source. Read explanations below. +# +# Resource files are binaries containing manifest, project icon and version info. +# They can not be viewed as text or compared by diff-tools. Consider replacing them with .rc files. +#*.res +# +# Type library file (binary). In old Delphi versions it should be stored. +# Since Delphi 2009 it is produced from .ridl file and can safely be ignored. +#*.tlb +# +# Diagram Portfolio file. Used by the diagram editor up to Delphi 7. +# Uncomment this if you are not using diagrams or use newer Delphi version. +#*.ddp +# +# Visual LiveBindings file. Added in Delphi XE2. +# Uncomment this if you are not using LiveBindings Designer. +#*.vlb +# +# Deployment Manager configuration file for your project. Added in Delphi XE2. +# Uncomment this if it is not mobile development and you do not use remote debug feature. +#*.deployproj +# +# C++ object files produced when C/C++ Output file generation is configured. +# Uncomment this if you are not using external objects (zlib library for example). +#*.obj +# + +# Delphi compiler-generated binaries (safe to delete) +*.exe +*.dll +*.bpl +*.bpi +*.dcp +*.so +*.apk +*.drc +*.map +*.dres +*.rsm +*.tds +*.dcu +*.lib +*.a +*.o +*.ocx + +# Delphi autogenerated files (duplicated info) +*.cfg +*.hpp +*Resource.rc + +# Delphi local files (user-specific info) +*.local +*.identcache +*.projdata +*.tvsconfig +*.dsk + +# Delphi history and backups +__history/ +__recovery/ +*.~* + +# Castalia statistics file (since XE7 Castalia is distributed with Delphi) +*.stat + +# End of https://www.gitignore.io/api/delphi diff --git a/PersianTT.dpr b/PersianTT.dpr index 7b8a86f..a6c90bc 100644 --- a/PersianTT.dpr +++ b/PersianTT.dpr @@ -2,31 +2,37 @@ program PersianTT; {$R *.dres} + uses Vcl.Forms, System.SysUtils, - UfrmMain in 'Units\UfrmMain.pas' {frmMain}, + UfrmMain in 'Units\UfrmMain.pas' {frmMain} , UTextDrawer in 'Units\UTextDrawer.pas', - UKeyboard in 'Units\UKeyboard.pas' {Keyboard: TFrame}, + UKeyboard in 'Units\UKeyboard.pas' {Keyboard: TFrame} , UKeyboardKey in 'Units\UKeyboardKey.pas', UGlobalUnit in 'Units\UGlobalUnit.pas', UFingerCaption in 'Units\UFingerCaption.pas', - UHand in 'Units\UHand.pas' {Hand: TFrame}, + UHand in 'Units\UHand.pas' {Hand: TFrame} , UObserver in 'Units\UObserver.pas', - UTutor in 'Units\UTutor.pas' {Tutor: TFrame}, + UTutor in 'Units\UTutor.pas' {Tutor: TFrame} , UTutorController in 'Units\UTutorController.pas', - UfrmSplash in 'Units\UfrmSplash.pas' {frmSplash}, + UfrmSplash in 'Units\UfrmSplash.pas' {frmSplash} , UfrmAbout in 'Units\UfrmAbout.pas' {frmAbout}; {$R *.res} +var + Version: string; + begin ReportMemoryLeaksOnShutdown := DebugHook <> 0; Application.MainFormOnTaskbar := True; frmSplash := TfrmSplash.Create(Application); frmSplash.Show; frmSplash.Update; - Sleep(2000); + GetLatestVersion; + if LatestVersion = '' then + Sleep(1500); Application.Initialize; Application.CreateForm(TfrmMain, frmMain); Application.CreateForm(TfrmAbout, frmAbout); @@ -34,4 +40,5 @@ begin frmSplash.Free; frmSplash := nil; Application.Run; + end. diff --git a/PersianTT.dproj b/PersianTT.dproj index 41ed061..b5c63a4 100644 --- a/PersianTT.dproj +++ b/PersianTT.dproj @@ -85,11 +85,11 @@ false - 7 + 8 PersianTT_Icon.ico true 1033 - CompanyName=http://persiantt.codeplex.com/;FileDescription=Persian and English type tutor. Developed by Majid Shamkhani;FileVersion=1.7.0.0;InternalName=;LegalCopyright=GNU General Public License version 2 (GPLv2);LegalTrademarks=;OriginalFilename=;ProductName=Persian Type Tutor;ProductVersion=1.7.0.0;Comments= + CompanyName=https://github.com/Majid110/PersianTypeTutor;FileDescription=Persian and English type tutor. Developed by Majid Shamkhani;FileVersion=1.8.0.0;InternalName=;LegalCopyright=GNU General Public License version 2 (GPLv2);LegalTrademarks=;OriginalFilename=;ProductName=Persian Type Tutor;ProductVersion=1.8.0.0;Comments= diff --git a/PersianTT.res b/PersianTT.res index e8a646219626b5b19803c217b3e989eae7174f2e..c4c9e9ab1269633b6ffa7d11d2a3d637f02a85b7 100644 GIT binary patch delta 149 zcmZ3mfo;zQwh0Q18WR=efrO(zCkF!~0|;hk0F^MpCK10>dTPGkOh=UVK4+j1E5F%Ln=cNLorY+ks*&E ogrSn504Ndy)K>!3Q#9F_@hqdoWJadnj26v*nYRCBVpN_A00I^x00000 delta 121 zcmdn9fo;JCwh0Q1JQEe=frO(zCp!Zp0|>BBtW;*qnK)OO(PQF4appJ%`H8nxjjb5; zfv|ufm7$2Cm?4uPks*(v1PJvQk{R+DQh?$G3^_ou0xFWrpg-B4@hqeHWLc))jONXf M%-bcI8I`930JNza<^TWy diff --git a/Src/PersianTT.nsi b/Src/PersianTT.nsi index 121b6aa..179c8e9 100644 --- a/Src/PersianTT.nsi +++ b/Src/PersianTT.nsi @@ -4,9 +4,9 @@ Var run_app_text ; HM NIS Edit Wizard helper defines !define PRODUCT_NAME "Persian Type Tutor" !define SETUP_NAME "PersianTypeTutor" -!define PRODUCT_VERSION "1.7" +!define PRODUCT_VERSION "1.8" !define PRODUCT_PUBLISHER "Majid Shamkhani" -!define PRODUCT_WEB_SITE "http://www.persiantt.codeplex.com" +!define PRODUCT_WEB_SITE "https://github.com/Majid110/PersianTypeTutor" !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\PersianTT.exe" !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" !define PRODUCT_UNINST_ROOT_KEY "HKLM" diff --git a/Units/UGlobalUnit.pas b/Units/UGlobalUnit.pas index 2ba5064..418a589 100644 --- a/Units/UGlobalUnit.pas +++ b/Units/UGlobalUnit.pas @@ -4,20 +4,29 @@ interface uses System.SysUtils, + IdHTTP, + System.Classes, + System.RegularExpressions, + IdSSLOpenSSL, Vcl.Forms; type - //TTypeLanguage = (tlPersian, tlEnglish); - TTutorState = (tsNon, tsReady, tsStarted, tsFinished); + // TTypeLanguage = (tlPersian, tlEnglish); + TTutorState = (tsNon, tsReady, tsStarted, tsFinished); TKeyboardLayout = (klEnglish, klMicrosoftPersian, klPersian); + const - NULL_CHAR = #13; - TUTOR_EXT = '.ttd'; - NULL_CHAR_INDEX = -1; - APPLICATION_VERSION = '1.7'; - VIRTUAL_SPACE = #$200C; + NULL_CHAR = #13; + TUTOR_EXT = '.ttd'; + NULL_CHAR_INDEX = -1; + APPLICATION_VERSION = '1.8'; + VIRTUAL_SPACE = #$200C; + +var + LatestVersion : string; function ApplicationPath: String; +procedure GetLatestVersion; implementation @@ -26,4 +35,47 @@ function ApplicationPath: String; Result := ExtractFilePath(Application.ExeName); end; +Function ExtractVersion(InputtedTerm: String): String; +var + RegularExpression: TRegEx; + Match : TMatch; +begin + try + Result := ''; + Match := RegularExpression.Match(InputtedTerm, '("tag_name": ")(.*?)(")'); + if Match.Groups.Count <> 4 then + begin + Exit; + end; + Result := Match.Groups[2].Value; + finally + end; +end; + +procedure GetLatestVersion; +var + lHTTP : TIdHTTP; + LHandler : TIdSSLIOHandlerSocketOpenSSL; + Src : String; + LastVersion: String; +begin + try + lHTTP := TIdHTTP.Create(nil); + try + LHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil); + try + lHTTP.IOHandler := LHandler; + lHTTP.Request.UserAgent := 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0'; + Src := lHTTP.Get('https://api.github.com/repos/majid110/PersianTypeTutor/releases/latest'); + LatestVersion := ExtractVersion(Src); + finally + LHandler.Free; + end; + finally + FreeAndNil(lHTTP); + end; + except + end; +end; + end. diff --git a/Units/UfrmAbout.dfm b/Units/UfrmAbout.dfm index 28210cb..622369f 100644 --- a/Units/UfrmAbout.dfm +++ b/Units/UfrmAbout.dfm @@ -692,31 +692,31 @@ object frmAbout: TfrmAbout IsControl = True end object ProductName: TLabel - Left = 204 - Top = 104 + Left = 124 + Top = 124 Width = 90 Height = 13 Caption = 'Persian Type Tutor' IsControl = True end object Version: TLabel - Left = 204 - Top = 128 + Left = 124 + Top = 143 Width = 53 Height = 13 Caption = 'Version 1.0' IsControl = True end object WebSite: TLabel - Left = 204 - Top = 152 - Width = 140 + Left = 124 + Top = 163 + Width = 225 Height = 13 Cursor = crHandPoint - Caption = 'http://persiantt.codeplex.com' + Caption = 'https://github.com/Majid110/PersianTypeTutor' Font.Charset = DEFAULT_CHARSET Font.Color = clBlue - Font.Height = -11 + Font.Height = -12 Font.Name = 'MS Sans Serif' Font.Style = [fsUnderline] ParentFont = False @@ -733,7 +733,7 @@ object frmAbout: TfrmAbout Default = True Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText - Font.Height = -11 + Font.Height = -12 Font.Name = 'Tahoma' Font.Style = [] ModalResult = 1 diff --git a/Units/UfrmAbout.pas b/Units/UfrmAbout.pas index 7cf87a1..0f31dd6 100644 --- a/Units/UfrmAbout.pas +++ b/Units/UfrmAbout.pas @@ -46,7 +46,7 @@ procedure TfrmAbout.FormCreate(Sender: TObject); procedure TfrmAbout.WebSiteClick(Sender: TObject); begin - shellExecute(Application.Handle, 'open', 'http://persiantt.codeplex.com', nil, nil, SW_NORMAL); + ShellExecute(Application.Handle, 'open', 'https://github.com/Majid110/PersianTypeTutor', nil, nil, SW_NORMAL); end; end. diff --git a/Units/UfrmMain.dfm b/Units/UfrmMain.dfm index d367d37..6290149 100644 --- a/Units/UfrmMain.dfm +++ b/Units/UfrmMain.dfm @@ -17,6 +17,7 @@ object frmMain: TfrmMain Position = poScreenCenter OnCreate = FormCreate OnKeyDown = FormKeyDown + OnShow = FormShow DesignSize = ( 1024 748) @@ -256,7 +257,7 @@ object frmMain: TfrmMain Left = 788 Top = 271 Width = 231 - Height = 472 + Height = 471 AutoSize = True BiDiMode = bdRightToLeft ParentBiDiMode = False diff --git a/Units/UfrmMain.pas b/Units/UfrmMain.pas index 167de7f..83b7cb0 100644 --- a/Units/UfrmMain.pas +++ b/Units/UfrmMain.pas @@ -39,6 +39,7 @@ TfrmMain = class(TForm, IObserver) procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure Tutor1imgOSKClick(Sender: TObject); procedure Tutor1imgAboutClick(Sender: TObject); + procedure FormShow(Sender: TObject); private { Private declarations } FTextDrawer : TTextDrawer; @@ -95,6 +96,17 @@ procedure TfrmMain.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftStat FTutorController.CheckKey(Key, Shift); end; +procedure TfrmMain.FormShow(Sender: TObject); +begin + if (LatestVersion <> '') and (LatestVersion <> APPLICATION_VERSION) then + begin + if MessageDlg('New version available. Do you want open download page?', mtConfirmation, mbYesNo, 0) = mrYes Then + begin + ShellExecute(Application.Handle, 'open', 'https://github.com/Majid110/PersianTypeTutor/releases', nil, nil, SW_NORMAL); + end; + end; +end; + procedure TfrmMain.Tutor1imgAboutClick(Sender: TObject); begin frmAbout := TfrmAbout.Create(Application); diff --git a/Units/UfrmSplash.dfm b/Units/UfrmSplash.dfm index e0c59cf..0ce3500 100644 --- a/Units/UfrmSplash.dfm +++ b/Units/UfrmSplash.dfm @@ -31,25 +31,9 @@ object frmSplash: TfrmSplash Height = 300 OnClick = imgBackClick end - object lblWebsite: TLabel - Left = 18 - Top = 264 - Width = 145 - Height = 13 - Cursor = crHandPoint - BiDiMode = bdLeftToRight - Caption = 'http://persiantt.codeplex.com' - Font.Charset = ARABIC_CHARSET - Font.Color = clSilver - Font.Height = -11 - Font.Name = 'Tahoma' - Font.Style = [] - ParentBiDiMode = False - ParentFont = False - end object lblVersion: TLabel - Left = 18 - Top = 250 + Left = 22 + Top = 262 Width = 45 Height = 13 Alignment = taRightJustify diff --git a/Units/UfrmSplash.pas b/Units/UfrmSplash.pas index f01ee04..7e1ae79 100644 --- a/Units/UfrmSplash.pas +++ b/Units/UfrmSplash.pas @@ -17,7 +17,6 @@ interface type TfrmSplash = class(TForm) imgBack: TImage; - lblWebsite: TLabel; lblVersion: TLabel; procedure FormActivate(Sender: TObject); procedure FormCreate(Sender: TObject);