瀏覽代碼

Factoring out LocaleHex

Source commit: 7e8eeba7ccaacd0d0b3b07f0d9c05bf089c6594c
Martin Prikryl 9 年之前
父節點
當前提交
35f19fc795

+ 1 - 1
source/forms/MessageDlg.cpp

@@ -155,7 +155,7 @@ void __fastcall TMessageForm::ReportButtonClick(TObject * /*Sender*/)
   // And we need to preserve the other parameters.
   UnicodeString Url =
     FMTLOAD(ERROR_REPORT_URL2,
-      (Configuration->ProductVersion, IntToHex(__int64(GUIConfiguration->Locale), 4),
+      (Configuration->ProductVersion, GUIConfiguration->LocaleHex,
        EncodeUrlString(GetReportText())));
 
   OpenBrowser(Url);

+ 5 - 0
source/windows/GUIConfiguration.cpp

@@ -855,6 +855,11 @@ void __fastcall TGUIConfiguration::SetLocaleSafe(LCID value)
   SetLocaleInternal(value, true);
 }
 //---------------------------------------------------------------------------
+UnicodeString __fastcall TGUIConfiguration::GetLocaleHex()
+{
+  return IntToHex(__int64(GUIConfiguration->Locale), 4);
+}
+//---------------------------------------------------------------------------
 void __fastcall TGUIConfiguration::SetLocaleInternal(LCID value, bool Safe)
 {
   if (Locale != value)

+ 2 - 0
source/windows/GUIConfiguration.h

@@ -189,6 +189,7 @@ protected:
   virtual LCID __fastcall GetLocale();
   void __fastcall SetLocale(LCID value);
   void __fastcall SetLocaleSafe(LCID value);
+  UnicodeString __fastcall GetLocaleHex();
   virtual HINSTANCE __fastcall LoadNewResourceModule(LCID Locale,
     UnicodeString & FileName);
   HANDLE __fastcall GetResourceModule();
@@ -243,6 +244,7 @@ public:
   __property bool SessionRememberPassword = { read = FSessionRememberPassword, write = FSessionRememberPassword };
   __property LCID Locale = { read = GetLocale, write = SetLocale };
   __property LCID LocaleSafe = { read = GetLocale, write = SetLocaleSafe };
+  __property UnicodeString LocaleHex = { read = GetLocaleHex };
   __property TStrings * Locales = { read = GetLocales };
   __property UnicodeString PuttyPath = { read = FPuttyPath, write = FPuttyPath };
   __property UnicodeString DefaultPuttyPath = { read = FDefaultPuttyPath };

+ 1 - 1
source/windows/Setup.cpp

@@ -786,7 +786,7 @@ UnicodeString __fastcall ProgramUrl(UnicodeString URL)
   UnicodeString Params =
     FORMAT(L"v=%s&lang=%s&isinstalled=%d",
       (CurrentVersionStr,
-      IntToHex(__int64(GUIConfiguration->Locale), 4),
+      GUIConfiguration->LocaleHex,
       int(IsInstalled())));
 
   if (Configuration->IsUnofficial)

+ 2 - 2
source/windows/WinHelp.cpp

@@ -36,14 +36,14 @@ void __fastcall SearchHelp(const UnicodeString & Message)
   // Message goes last, as it may exceed URL parameters limit (2048) and get truncated.
   // And we need to preserve the other parameters.
   OpenBrowser(FMTLOAD(DOCUMENTATION_SEARCH_URL3,
-    (Configuration->ProductVersion, IntToHex(__int64(GUIConfiguration->Locale), 4),
+    (Configuration->ProductVersion, GUIConfiguration->LocaleHex,
      EncodeUrlString(Message))));
 }
 //---------------------------------------------------------------------------
 void __fastcall InitializeWinHelp()
 {
   InitializeCustomHelp(new TWebHelpSystem(
-      Configuration->ProductVersion, IntToHex(__int64(GUIConfiguration->Locale), 4)));
+      Configuration->ProductVersion, GUIConfiguration->LocaleHex));
 }
 //---------------------------------------------------------------------------
 void __fastcall FinalizeWinHelp()

+ 1 - 0
source/windows/WinMain.cpp

@@ -353,6 +353,7 @@ void __fastcall UpdateStaticUsage()
   Configuration->Usage->Set(L"WindowsProductType", (static_cast<int>(Type)));
   Configuration->Usage->Set(L"Windows64", IsWin64());
   Configuration->Usage->Set(L"DefaultLocale",
+    // See TGUIConfiguration::GetLocaleHex()
     IntToHex(static_cast<int>(GetDefaultLCID()), 4));
   Configuration->Usage->Set(L"Locale",
     IntToHex(static_cast<int>(WinConfiguration->Locale), 4));