Skip to content

Commit ecfaf19

Browse files
Merge pull request #1137 from g-maxime/sponsor
Windows GUI: Add sponsor banner + installer widget
2 parents 84a812b + aa31f7d commit ecfaf19

14 files changed

+694
-20
lines changed

Project/BCB/GUI/MediaInfo_GUI.cbproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,13 @@
239239
<DependentOn>..\..\..\Source\GUI\VCL\GUI_Preferences_Sheet.h</DependentOn>
240240
<BuildOrder>9</BuildOrder>
241241
</CppCompile>
242+
<CppCompile Include="..\..\..\Source\GUI\VCL\GUI_Sponsor.cpp">
243+
<Form>SponsorFrame</Form>
244+
<FormType>dfm</FormType>
245+
<DesignClass>TFrame</DesignClass>
246+
<DependentOn>..\..\..\Source\GUI\VCL\GUI_Sponsor.h</DependentOn>
247+
<BuildOrder>21</BuildOrder>
248+
</CppCompile>
242249
<CppCompile Include="..\..\..\Source\GUI\VCL\GUI_Web.cpp">
243250
<Form>WebF</Form>
244251
<DependentOn>..\..\..\Source\GUI\VCL\GUI_Web.h</DependentOn>
@@ -269,6 +276,7 @@
269276
<IgnorePath>true</IgnorePath>
270277
</LibFiles>
271278
<FormResources Include="..\..\..\Source\GUI\VCL\GUI_Web.dfm"/>
279+
<FormResources Include="..\..\..\Source\GUI\VCL\GUI_Sponsor.dfm"/>
272280
<FormResources Include="..\..\..\Source\GUI\VCL\GUI_Preferences_Sheet.dfm"/>
273281
<FormResources Include="..\..\..\Source\GUI\VCL\GUI_Preferences_Output.dfm"/>
274282
<FormResources Include="..\..\..\Source\GUI\VCL\GUI_Preferences_Language.dfm"/>

Project/BCB/GUI/MediaInfo_GUI.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@
77

88
#include <Vcl.Styles.hpp>
99
#include <Vcl.Themes.hpp>
10-
USEFORM("..\..\..\Source\GUI\VCL\GUI_Preferences_Language.cpp", Preferences_LanguageF);
10+
USEFORM("..\..\..\Source\GUI\VCL\GUI_Web.cpp", WebF);
11+
USEFORM("..\..\..\Source\GUI\VCL\GUI_Preferences_Sheet.cpp", Preferences_SheetF);
1112
USEFORM("..\..\..\Source\GUI\VCL\GUI_Preferences_Output.cpp", Preferences_OutputF);
12-
USEFORM("..\..\..\Source\GUI\VCL\GUI_Preferences.cpp", PreferencesF);
13+
USEFORM("..\..\..\Source\GUI\VCL\GUI_Preferences_Language.cpp", Preferences_LanguageF);
1314
USEFORM("..\..\..\Source\GUI\VCL\GUI_Preferences_Custom.cpp", Preferences_CustomF);
14-
USEFORM("..\..\..\Source\GUI\VCL\GUI_Preferences_Sheet.cpp", Preferences_SheetF);
15-
USEFORM("..\..\..\Source\GUI\VCL\GUI_Web.cpp", WebF);
15+
USEFORM("..\..\..\Source\GUI\VCL\GUI_Preferences.cpp", PreferencesF);
16+
USEFORM("..\..\..\Source\GUI\VCL\GUI_Plugin.cpp", PluginF);
1617
USEFORM("..\..\..\Source\GUI\VCL\GUI_Main.cpp", MainF);
17-
USEFORM("..\..\..\Source\GUI\VCL\GUI_About.cpp", AboutF);
1818
USEFORM("..\..\..\Source\GUI\VCL\GUI_Export.cpp", ExportF);
19+
USEFORM("..\..\..\Source\GUI\VCL\GUI_About.cpp", AboutF);
20+
USEFORM("..\..\..\Source\GUI\VCL\GUI_Sponsor.cpp", SponsorFrame); /* TFrame: File Type */
1921
//---------------------------------------------------------------------------
2022
int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
2123
{

Source/Common/Preferences.cpp

Lines changed: 67 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ using namespace ZenLib;
3535

3636
//---------------------------------------------------------------------------
3737
Preferences* Prefs=new Preferences;
38+
const Ztring Empty_Ztring_Ref=__T("");
3839
int ExplorerShell_Edit (const AnsiString &Name, bool ShellExtension, bool &IsChanged);
3940
//---------------------------------------------------------------------------
4041

@@ -71,6 +72,8 @@ Preferences::Preferences()
7172
Sponsored=false;
7273
SponsorMessage=__T("");
7374
SponsorUrl=__T("");
75+
SponsorBanner=__T("");
76+
SponsorBannerClickUrl=__T("");
7477

7578
//Plugins
7679
GraphPluginURL=__T("");
@@ -218,6 +221,14 @@ int Preferences::Config_Load()
218221
Saved=Config(__T("SponsorUrl"));
219222
Saved.FindAndReplace(__T("\\r\\n"), __T("\r\n"), 0, Ztring_Recursive);
220223
SponsorUrl.Write(Saved);
224+
225+
Saved=Config(__T("SponsorBanner"));
226+
Saved.FindAndReplace(__T("\\r\\n"), __T("\r\n"), 0, Ztring_Recursive);
227+
SponsorBanner.Write(Saved);
228+
229+
Saved=Config(__T("SponsorBannerClickUrl"));
230+
Saved.FindAndReplace(__T("\\r\\n"), __T("\r\n"), 0, Ztring_Recursive);
231+
SponsorBannerClickUrl.Write(Saved);
221232
}
222233

223234
if (!Config(__T("GraphPlugin64URL")).empty())
@@ -522,14 +533,17 @@ void __fastcall ThreadInternetCheck::Execute()
522533
Prefs->Config(__T("Sponsored"))=__T("0");
523534
Prefs->Config(__T("SponsorMessage"))=__T("");
524535
Prefs->Config(__T("SponsorUrl"))=__T("");
525-
536+
Prefs->Config(__T("SponsorBanner"))=__T("");
537+
Prefs->Config(__T("SponsorBannerClickUrl"))=__T("");
526538
ZtringListList Sponsor=Download.SubSheet(__T("ShowSponsor"));
527539
unsigned int En=Sponsor.Find(__T("en"), 1);
528-
if (En!=(unsigned int)-1 && Sponsor[En](2)!=__T("") && Sponsor[En](3)!=__T(""))
540+
if (En!=(unsigned int)-1)
529541
{
530542
Prefs->Config(__T("Sponsored"))=__T("1");
531543
Ztring Message;
532544
Ztring Url;
545+
Ztring Banner;
546+
Ztring BannerClickUrl;
533547
for (size_t Pos=0; Pos<Sponsor.size(); Pos++)
534548
{
535549
if (Sponsor[Pos](1)!=__T(""))
@@ -538,13 +552,34 @@ void __fastcall ThreadInternetCheck::Execute()
538552
Message+=(Message.empty()?__T(""):__T("\\r\\n"))+Sponsor[Pos](1)+__T(";")+Sponsor[Pos](2);
539553
if (Sponsor[Pos](3)!=__T(""))
540554
Url+=(Url.empty()?__T(""):__T("\\r\\n"))+Sponsor[Pos](1)+__T(";")+Sponsor[Pos](3);
555+
if (Sponsor[Pos](4)!=__T(""))
556+
Banner+=(Banner.empty()?__T(""):__T("\\r\\n"))+Sponsor[Pos](1)+__T(";")+Sponsor[Pos](4);
557+
if (Sponsor[Pos](5)!=__T(""))
558+
BannerClickUrl+=(BannerClickUrl.empty()?__T(""):__T("\\r\\n"))+Sponsor[Pos](1)+__T(";")+Sponsor[Pos](5);
541559
}
542560
}
543561
Prefs->Config(__T("SponsorMessage"))=Message.Quote();
544562
Prefs->Config(__T("SponsorUrl"))=Url.Quote();
563+
Prefs->Config(__T("SponsorBanner"))=Banner.Quote();
564+
Prefs->Config(__T("SponsorBannerClickUrl"))=BannerClickUrl.Quote();
545565
}
566+
546567
Prefs->Config_Save();
547568

569+
Ztring SponsorBannerInstallGracePeriod=Download(__T("SponsorBannerInstallGracePeriod"));
570+
if (!SponsorBannerInstallGracePeriod.empty())
571+
{
572+
Prefs->Config(__T("SponsorBannerInstallGracePeriod"))=SponsorBannerInstallGracePeriod;
573+
Prefs->Config_Save();
574+
}
575+
576+
Ztring SponsorBannerCloseGracePeriod=Download(__T("SponsorBannerCloseGracePeriod"));
577+
if (!SponsorBannerCloseGracePeriod.empty())
578+
{
579+
Prefs->Config(__T("SponsorBannerCloseGracePeriod"))=SponsorBannerCloseGracePeriod;
580+
Prefs->Config_Save();
581+
}
582+
548583
//Plugins
549584
Ztring GraphPlugin64URL=Download(__T("GraphPlugin64URL"));
550585
if (!GraphPlugin64URL.empty())
@@ -559,7 +594,6 @@ void __fastcall ThreadInternetCheck::Execute()
559594
Prefs->Config(__T("GraphPluginURL"))=GraphPluginURL;
560595
Prefs->Config_Save();
561596
}
562-
563597
Ztring GraphPluginVersion=Download(__T("GraphPluginVersion"));
564598
if (!GraphPluginVersion.empty())
565599
{
@@ -1614,9 +1648,9 @@ int Preferences::ShellToolTip()
16141648
//***************************************************************************
16151649

16161650
//---------------------------------------------------------------------------
1617-
ZenLib::Ztring &Preferences::Translate(ZenLib::Ztring Name)
1651+
const ZenLib::Ztring &Preferences::Translate(ZenLib::Ztring Name)
16181652
{
1619-
if (Name==__T("SponsorMessage") || Name==__T("SponsorUrl"))
1653+
if (Name==__T("SponsorMessage") || Name==__T("SponsorUrl") || Name==__T("SponsorBanner") || Name==__T("SponsorBannerClickUrl"))
16201654
{
16211655
Ztring Language=Translate(__T(" Language_ISO639"));
16221656
if (Name==__T("SponsorMessage"))
@@ -1625,6 +1659,9 @@ ZenLib::Ztring &Preferences::Translate(ZenLib::Ztring Name)
16251659
if (Index==-1 || SponsorMessage(Index)(1)==__T(""))
16261660
Index=SponsorMessage.Find(__T("en"), 0);
16271661

1662+
if (Index==-1 || SponsorMessage(Index).empty())
1663+
return Empty_Ztring_Ref;
1664+
16281665
return SponsorMessage(Index)(1);
16291666
}
16301667
else if (Name==__T("SponsorUrl"))
@@ -1633,8 +1670,33 @@ ZenLib::Ztring &Preferences::Translate(ZenLib::Ztring Name)
16331670
if (Index==-1 || SponsorUrl(Index)(1)==__T(""))
16341671
Index=SponsorUrl.Find(__T("en"), 0);
16351672

1673+
if (Index==-1 || SponsorUrl(Index).empty())
1674+
return Empty_Ztring_Ref;
1675+
16361676
return SponsorUrl(Index)(1);
16371677
}
1678+
else if (Name==__T("SponsorBanner"))
1679+
{
1680+
int Index=SponsorBanner.Find(Language, 0);
1681+
if (Index==-1 || SponsorBanner(Index)(1)==__T(""))
1682+
Index=SponsorBanner.Find(__T("en"), 0);
1683+
1684+
if (Index==-1 || SponsorBanner(Index).empty())
1685+
return Empty_Ztring_Ref;
1686+
1687+
return SponsorBanner(Index)(1);
1688+
}
1689+
else if (Name==__T("SponsorBannerClickUrl"))
1690+
{
1691+
int Index=SponsorBannerClickUrl.Find(Language, 0);
1692+
if (Index==-1 || SponsorBannerClickUrl(Index)(1)==__T(""))
1693+
Index=SponsorBannerClickUrl.Find(__T("en"), 0);
1694+
1695+
if (Index==-1 || SponsorBannerClickUrl(Index).empty())
1696+
return Empty_Ztring_Ref;
1697+
1698+
return SponsorBannerClickUrl(Index)(1);
1699+
}
16381700
}
16391701

16401702
size_t Pos=Details[Prefs_Language].Find(Name, 0, 0, __T("=="), Ztring_CaseSensitive);

Source/Common/Preferences.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ class Preferences
5959
ZenLib::ZtringListListF Config; //Configuration file
6060
ZenLib::ZtringList FilesList[Prefs_Max]; //List of available files for an Item
6161
ZenLib::ZtringListListF Details[Prefs_Max];
62-
ZenLib::ZtringListList SponsorMessage;
63-
ZenLib::ZtringListList SponsorUrl;
6462

6563
//Useful functions about preferences
6664
int Config_Create ();
@@ -79,7 +77,7 @@ class Preferences
7977
int ShellToolTip (); //To be available with mouse in Explorer
8078

8179
//Special things
82-
ZenLib::Ztring &Translate (ZenLib::Ztring Name); //return in the good language, or in English if not found
80+
const ZenLib::Ztring &Translate (ZenLib::Ztring Name); //return in the good language, or in English if not found
8381

8482
//Info about Lists
8583
ZenLib::ZtringList FolderNames; //List of list_t --> Foldernames
@@ -92,6 +90,10 @@ class Preferences
9290

9391
//Sponsor
9492
bool Sponsored;
93+
ZenLib::ZtringListList SponsorMessage;
94+
ZenLib::ZtringListList SponsorUrl;
95+
ZenLib::ZtringListList SponsorBanner;
96+
ZenLib::ZtringListList SponsorBannerClickUrl;
9597

9698
//Plugins
9799
ZenLib::Ztring GraphPluginURL;

Source/GUI/VCL/GUI_Main.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,14 @@ __fastcall TMainF::TMainF(TComponent* Owner)
244244
Page_Sheet_X_Web[Stream_Text]=Page_Sheet_T_Web;
245245
Page_Sheet_X_Web[Stream_Other]=Page_Sheet_C_Web;
246246

247+
//Configuration of properties
248+
Page_Position=-1;
249+
Caption=MEDIAINFO_TITLE;
250+
251+
//Configuration of MediaInfoLib
252+
if (I == NULL)
253+
I = new MediaInfoList;
254+
247255
//Footer
248256
//Note: If Height is set after Parent, button will be too small on high-DPI
249257
// If Font is set before Parent, button text will be too large on high-DPI
@@ -255,13 +263,10 @@ __fastcall TMainF::TMainF(TComponent* Owner)
255263
Footer_Button->OnClick=&Footer_ButtonClick;
256264
Footer_Button->Visible=false;
257265

258-
//Configuration of properties
259-
Page_Position=-1;
260-
Caption=MEDIAINFO_TITLE;
261-
262-
//Configuration of MediaInfoLib
263-
if (I == NULL)
264-
I = new MediaInfoList;
266+
Footer_Sponsor=new TSponsorFrame(this, this);
267+
Footer_Sponsor->Height=150;
268+
Footer_Sponsor->Parent=Page;
269+
Footer_Sponsor->Align=alBottom;
265270

266271
//Load GUI preferences
267272
GUI_Configure();
@@ -483,6 +488,9 @@ void __fastcall TMainF::GUI_Configure()
483488
}
484489
}
485490

491+
// Sponsor
492+
Footer_Sponsor->Init();
493+
486494
//Translation
487495
Translate();
488496

@@ -807,6 +815,8 @@ void __fastcall TMainF::Translate()
807815
M_Sponsor->Caption = + Prefs->Translate(__T("SponsorMessage")).c_str();
808816
M_Sponsor->Visible=true;
809817
}
818+
if (Footer_Sponsor && Footer_Sponsor->Visible)
819+
Footer_Sponsor->Translate();
810820

811821
//Footer
812822
Footer_Button->Caption=L"Go to conformance errors and warnings glossary page";

Source/GUI/VCL/GUI_Main.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <Winapi.ActiveX.hpp>
3838
#include <Winapi.WebView2.hpp>
3939
#include <SHDocVw.hpp>
40+
#include "GUI_Sponsor.h"
4041
//---------------------------------------------------------------------------
4142

4243
//---------------------------------------------------------------------------
@@ -305,6 +306,7 @@ class TMainF : public TForm
305306
virtual void __fastcall DestroyWnd();
306307
private: // User declarations
307308
TButton *Footer_Button;
309+
TSponsorFrame *Footer_Sponsor;
308310
const UnicodeString LIGHT_MODE_STYLE = "Windows"; // Name of style for light mode;
309311
const UnicodeString DARK_MODE_STYLE = "Windows11 Modern Dark"; // Name of style for dark mode
310312
bool StartupReady = false;

0 commit comments

Comments
 (0)