Skip to content

Commit

Permalink
Make sponsor message customizable
Browse files Browse the repository at this point in the history
Signed-off-by: Maxime Gervais <[email protected]>
  • Loading branch information
g-maxime committed Oct 6, 2020
1 parent 4fde6ce commit 613ce08
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 119 deletions.
30 changes: 30 additions & 0 deletions Source/Common/Preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ Preferences::Preferences()
//Donate
Donated=false;
Donate_Display=true;

//Sponsor
Sponsored=false;
SponsorMessage=__T("");
SponsorUrl=__T("");
}

//***************************************************************************
Expand Down Expand Up @@ -193,6 +198,13 @@ int Preferences::Config_Load()
if ((int64u)time(NULL)-Config(__T("Install")).To_int64u()<7*24*60*60)
Donate_Display=false;

// Sponsor
if (Config(__T("Sponsored"))==__T("1") && Config(__T("SponsorMessage"))!=__T("") && Config(__T("SponsorUrl"))!=__T(""))
{
Sponsored=true;
SponsorMessage=Config(__T("SponsorMessage"));
SponsorUrl=Config(__T("SponsorUrl"));
}

delete Reg_User; Reg_User=NULL;

Expand Down Expand Up @@ -220,6 +232,7 @@ int Preferences::Config_Save()
if (Config(__T("FirstInstall")).empty()) Config(__T("FirstInstall")).From_Number((int64u)time(NULL));
if (Config(__T("Donated")).empty()) Config(__T("Donated"))=__T("0");
if (Config(__T("Donate_Display")).empty()) Config(__T("Donate_Display"))=__T("1");
if (Config(__T("Sponsored")).empty()) Config(__T("Sponsored"))=__T("0");

HANDLE Temp=CreateFile((BaseFolder+__T("MediaInfo.cfg")).c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
if (Temp==INVALID_HANDLE_VALUE)
Expand Down Expand Up @@ -450,6 +463,23 @@ void __fastcall ThreadInternetCheck::Execute()
Prefs->Config_Save();
}

//Sponsored
ZtringList Sponsor=Download.SubSheet(__T("ShowSponsor"))[0];
if (Sponsor(1)==__T("1") && Sponsor(2)!=__T("") && Sponsor(3)!=__T(""))
{
Prefs->Config(__T("Sponsored"))=__T("1");
Prefs->Config(__T("SponsorMessage"))=Sponsor(2);
Prefs->Config(__T("SponsorUrl"))=Sponsor(3);
Prefs->Config_Save();
}
else
{
Prefs->Config(__T("Sponsored"))=__T("0");
Prefs->Config(__T("SponsorMessage"))=__T("");
Prefs->Config(__T("SponsorUrl"))=__T("");
Prefs->Config_Save();
}

//Chargement de pages
ZtringListList Pages=Download.SubSheet(__T("Url"));
for (size_t Pos=0; Pos<Pages.size(); Pos++)
Expand Down
5 changes: 5 additions & 0 deletions Source/Common/Preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ class Preferences
bool Donated;
bool Donate_Display;
bool NewVersion_Display;

//Sponsor
bool Sponsored;
ZenLib::Ztring SponsorMessage;
ZenLib::Ztring SponsorUrl;
};

//General preference for the whole program
Expand Down
15 changes: 8 additions & 7 deletions Source/GUI/VCL/GUI_About.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@ void __fastcall TAboutF::FormShow(TObject *Sender)
WriteToTranslator->Visible=true;
}

//if (Prefs->Donated) //No more
Sponsor_Label->Caption = (__T("<a href=\"") + Prefs->SponsorUrl + __T("\">") + Prefs->SponsorMessage + __T("</a>")).c_str();

if (!Prefs->Sponsored || Prefs->Donated)
{
Tektronix->Visible=false;
Tektronix_Label->Visible=false;
//Sponsor->Visible=false;
Sponsor_Label->Visible=false;
}
}

Expand Down Expand Up @@ -124,9 +126,8 @@ void __fastcall TAboutF::WebSiteClick(TObject *Sender)



void __fastcall TAboutF::TektronixClick(TObject *Sender)
void __fastcall TAboutF::SponsorClick(TObject *Sender, const UnicodeString Link,
TSysLinkType LinkType)
{
ShellExecute(NULL, NULL, __T("http://www.tek.com/file-based-qc-solutions"), NULL, NULL, SW_SHOWNORMAL);
ShellExecute(NULL, NULL, Link.c_str(), NULL, NULL, SW_SHOWNORMAL);
}
//---------------------------------------------------------------------------

37 changes: 8 additions & 29 deletions Source/GUI/VCL/GUI_About.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ object AboutF: TAboutF
Font.Style = []
ParentFont = False
end
object Tektronix_Label: TLabel
Left = 184
Top = 412
Width = 71
Height = 14
Caption = 'Sponsored by:'
end
object Memo: TMemo
Left = 142
Top = 1
Expand Down Expand Up @@ -159,30 +152,16 @@ object AboutF: TAboutF
TabOrder = 8
OnClick = WriteToTranslatorClick
end
object ToolBar3: TToolBar
Left = 261
object Sponsor_Label: TLinkLabel
Left = 145
Top = 380
Width = 265
Height = 85
Align = alNone
ButtonHeight = 70
ButtonWidth = 263
Caption = 'ToolBar1'
DisabledImages = ImageList3
EdgeInner = esNone
EdgeOuter = esNone
Images = ImageList3
Width = 380
Height = 18
Alignment = taRightJustify
AutoSize = False
Caption = 'Sponsor_Label'
TabOrder = 9
object Tektronix: TToolButton
Left = 0
Top = 0
Hint = 'Visit Tektronix website'
Caption = 'ToolButton1'
ImageIndex = 0
ParentShowHint = False
ShowHint = True
OnClick = TektronixClick
end
OnLinkClick = SponsorClick
end
object ImageList1: TImageList
Height = 64
Expand Down
7 changes: 3 additions & 4 deletions Source/GUI/VCL/GUI_About.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <Forms.hpp>
#include <ComCtrls.hpp>
#include <StdCtrls.hpp>
#include <Vcl.ExtCtrls.hpp>
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -46,17 +47,15 @@ class TAboutF : public TForm
TButton *WriteToTranslator;
TImageList *ImageList1;
TImageList *ImageList2;
TToolBar *ToolBar3;
TToolButton *Tektronix;
TImageList *ImageList3;
TLabel *Tektronix_Label;
TLinkLabel *Sponsor_Label;
void __fastcall WebSiteClick(TObject *Sender);
void __fastcall FormShow(TObject *Sender);
void __fastcall NewVersionClick(TObject *Sender);
void __fastcall DonateClick(TObject *Sender);
void __fastcall WriteMeClick(TObject *Sender);
void __fastcall WriteToTranslatorClick(TObject *Sender);
void __fastcall TektronixClick(TObject *Sender);
void __fastcall SponsorClick(TObject *Sender, const UnicodeString Link, TSysLinkType LinkType);
private: // User declarations
public: // User declarations
__fastcall TAboutF(TComponent* Owner);
Expand Down
16 changes: 8 additions & 8 deletions Source/GUI/VCL/GUI_Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void __fastcall TMainF::GUI_Configure()
if (Screen->Width>=1024)
Width=700;
if (Screen->Width>=1280)
Width=820;
Width=830;
if (Screen->Height>=768)
Height=500;
if (Screen->Height>=1024)
Expand Down Expand Up @@ -593,10 +593,12 @@ void __fastcall TMainF::Translate()
}
*/
}
//if (Prefs->Donated) //No more

M_Sponsor->Caption = Prefs->SponsorMessage.c_str();

if (!Prefs->Sponsored || Prefs->Donated)
{
M_Tektronix->Visible=false;
Tool_Tektronix->Visible=false;
M_Sponsor->Visible=false;
}
}

Expand Down Expand Up @@ -943,8 +945,6 @@ void __fastcall TMainF::Refresh(TTabSheet *Page)
//0 fichier
{
Caption=MEDIAINFO_TITLE;
if (Prefs->Donated)
Caption+=" - Sponsored by Tektronix";
}
else if (FilesCount==1)
//un fichier
Expand Down Expand Up @@ -1800,9 +1800,9 @@ void __fastcall TMainF::M_NewVersionClick(TObject *Sender)
ShellExecute(NULL, NULL, (Ztring(__T("http://mediaarea.net/"))+Prefs->Translate(__T(" Language_ISO639"))+__T("/MediaInfo/?NewVersionRequested=true")).c_str(), NULL, NULL, SW_SHOWNORMAL);
}

void __fastcall TMainF::M_TektronixClick(TObject *Sender)
void __fastcall TMainF::M_SponsorClick(TObject *Sender)
{
ShellExecute(NULL, NULL, __T("http://www.tek.com/file-based-qc-solutions"), NULL, NULL, SW_SHOWNORMAL);
ShellExecute(NULL, NULL, Prefs->SponsorUrl.c_str(), NULL, NULL, SW_SHOWNORMAL);
}
//---------------------------------------------------------------------------

Loading

0 comments on commit 613ce08

Please sign in to comment.