[Libreoffice-commits] core.git: cui/source
Muhammet Kara
muhammet.kara at pardus.org.tr
Thu Aug 18 10:47:05 UTC 2016
cui/source/inc/cuires.hrc | 7 +----
cui/source/options/personalization.cxx | 45 +++++++++++++++++----------------
cui/source/options/personalization.hxx | 28 +++++++++-----------
cui/source/options/personalization.src | 37 +++++++++++----------------
4 files changed, 54 insertions(+), 63 deletions(-)
New commits:
commit 6bfa24aacb56aaf0d16c278ec1f3561d5e3b4606
Author: Muhammet Kara <muhammet.kara at pardus.org.tr>
Date: Wed Aug 10 10:42:44 2016 +0300
Use English category names instead of localized ones in theme search tdf#87597
Added an OUString array to hold the original English strings
for search categories. The array is initialized in ctor by using
an initializer list of strings.
Also grouped the related strings of category names. So it can be
iterated easily without writing their names one by one.
Buttons in the UI will be displayed with localized strings,
but the search will take place with the original strings
coming from the array created in ctor.
Change-Id: Ieb72644203df1325e97693b14d5b3476020c6ff1
Reviewed-on: https://gerrit.libreoffice.org/28027
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/cui/source/inc/cuires.hrc b/cui/source/inc/cuires.hrc
index 67c79e2..8b452f2 100644
--- a/cui/source/inc/cuires.hrc
+++ b/cui/source/inc/cuires.hrc
@@ -435,11 +435,8 @@
#define RID_SVXSTR_CONFIRM_RESTORE_DEFAULT (RID_SVX_START + 1284)
#define RID_SVXSTR_CONFIRM_SET_LANGUAGE (RID_SVX_START + 1285)
-#define RID_SVXSTR_PERSONA_ABSTRACT (RID_SVX_START + 1286)
-#define RID_SVXSTR_PERSONA_COLOR (RID_SVX_START + 1287)
-#define RID_SVXSTR_PERSONA_MUSIC (RID_SVX_START + 1288)
-#define RID_SVXSTR_PERSONA_NATURE (RID_SVX_START + 1289)
-#define RID_SVXSTR_PERSONA_SOLID (RID_SVX_START + 1290)
+// String Array for Persona Categories
+#define RID_SVXSTR_PERSONA_CATEGORIES (RID_SVX_START + 1286)
#define RID_SVXPAGE_OPENCL (RID_SVX_START + 254)
diff --git a/cui/source/options/personalization.cxx b/cui/source/options/personalization.cxx
index 559eb85..ea7a49a 100644
--- a/cui/source/options/personalization.cxx
+++ b/cui/source/options/personalization.cxx
@@ -36,6 +36,7 @@
#include <com/sun/star/xml/sax/Parser.hpp>
#include "ucbhelper/content.hxx"
#include <comphelper/simplefileaccessinteraction.hxx>
+#include <tools/resary.hxx>
#define MAX_RESULTS 9
@@ -51,28 +52,19 @@ SelectPersonaDialog::SelectPersonaDialog( vcl::Window *pParent )
m_pSearchButton->SetClickHdl( LINK( this, SelectPersonaDialog, SearchPersonas ) );
get( m_vSearchSuggestions[0], "suggestion1" );
- m_vSearchSuggestions[0]->SetText( "LibreOffice" );
- m_vSearchSuggestions[0]->SetClickHdl( LINK( this, SelectPersonaDialog, SearchPersonas ) );
-
get( m_vSearchSuggestions[1], "suggestion2" );
- m_vSearchSuggestions[1]->SetText( CUI_RES ( RID_SVXSTR_PERSONA_ABSTRACT ) );
- m_vSearchSuggestions[1]->SetClickHdl( LINK( this, SelectPersonaDialog, SearchPersonas ) );
-
get( m_vSearchSuggestions[2], "suggestion3" );
- m_vSearchSuggestions[2]->SetText( CUI_RES ( RID_SVXSTR_PERSONA_COLOR ) );
- m_vSearchSuggestions[2]->SetClickHdl( LINK( this, SelectPersonaDialog, SearchPersonas ) );
-
get( m_vSearchSuggestions[3], "suggestion4" );
- m_vSearchSuggestions[3]->SetText( CUI_RES( RID_SVXSTR_PERSONA_MUSIC ) );
- m_vSearchSuggestions[3]->SetClickHdl( LINK( this, SelectPersonaDialog, SearchPersonas ) );
-
get( m_vSearchSuggestions[4], "suggestion5" );
- m_vSearchSuggestions[4]->SetText( CUI_RES( RID_SVXSTR_PERSONA_NATURE ) );
- m_vSearchSuggestions[4]->SetClickHdl( LINK( this, SelectPersonaDialog, SearchPersonas ) );
-
get( m_vSearchSuggestions[5], "suggestion6" );
- m_vSearchSuggestions[5]->SetText( CUI_RES( RID_SVXSTR_PERSONA_SOLID ) );
- m_vSearchSuggestions[5]->SetClickHdl( LINK( this, SelectPersonaDialog, SearchPersonas ) );
+
+ ResStringArray aCategoriesArr(CUI_RES(RID_SVXSTR_PERSONA_CATEGORIES));
+ assert(aCategoriesArr.Count() >= CATEGORYCOUNT);
+ for(sal_uInt32 i = 0; i < CATEGORYCOUNT; ++i)
+ {
+ m_vSearchSuggestions[i]->SetText( aCategoriesArr.GetString(i) );
+ m_vSearchSuggestions[i]->SetClickHdl( LINK( this, SelectPersonaDialog, SearchPersonas ) );
+ }
get( m_pEdit, "search_term" );
@@ -132,6 +124,17 @@ OUString SelectPersonaDialog::GetSelectedPersona() const
IMPL_LINK_TYPED( SelectPersonaDialog, SearchPersonas, Button*, pButton, void )
{
+ /*
+ * English category names should be used for search.
+ * These strings should be in sync with the strings of
+ * RID_SVXSTR_PERSONA_CATEGORIES in personalization.src
+ */
+ static const OUStringLiteral vSuggestionCategories[] =
+ {
+ OUStringLiteral("LibreOffice"), OUStringLiteral("Abstract"), OUStringLiteral("Color"),
+ OUStringLiteral("Music"), OUStringLiteral("Nature"), OUStringLiteral("Solid")
+ };
+
OUString searchTerm;
if( m_pSearchThread.is() )
m_pSearchThread->StopExecution();
@@ -140,12 +143,12 @@ IMPL_LINK_TYPED( SelectPersonaDialog, SearchPersonas, Button*, pButton, void )
searchTerm = m_pEdit->GetText();
else
{
- for( VclPtr<PushButton> & i : m_vSearchSuggestions )
+ for ( sal_uInt32 i = 0; i < CATEGORYCOUNT; ++i)
{
- if( pButton == i )
+ if( pButton == m_vSearchSuggestions[i] )
{
- // GetDisplayText() is returning a blank string, thus removing mnemonics explicitly.
- searchTerm = MnemonicGenerator::EraseAllMnemonicChars(i->GetText());
+ // Use the category name in English as search term
+ searchTerm = vSuggestionCategories[i];
break;
}
}
diff --git a/cui/source/options/personalization.hxx b/cui/source/options/personalization.hxx
index 205b981..42f9f61 100644
--- a/cui/source/options/personalization.hxx
+++ b/cui/source/options/personalization.hxx
@@ -14,8 +14,10 @@
#include <salhelper/thread.hxx>
#include <rtl/ref.hxx>
#include <vcl/prgsbar.hxx>
-
#include <vector>
+#include <array>
+
+#define CATEGORYCOUNT 6 // Number of persona categories
class FixedText;
class SearchAndParseThread;
@@ -32,9 +34,9 @@ private:
VclPtr<PushButton> m_vDefaultPersonaImages[3]; ///< Buttons to show the default persona images
VclPtr<PushButton> m_pExtensionPersonaPreview; ///< Buttons to show the last 3 personas installed via extensions
VclPtr<ListBox> m_pPersonaList; ///< The ListBox to show the list of installed personas
- OUString m_aPersonaSettings; ///< Header and footer images + color to be set in the settings.
+ OUString m_aPersonaSettings; ///< Header and footer images + color to be set in the settings.
VclPtr<FixedText> m_pExtensionLabel; ///< The "select persona installed via extensions" label
- VclPtr<FixedText> m_pAppliedThemeLabel; ///< The label for showing applied custom theme
+ VclPtr<FixedText> m_pAppliedThemeLabel; ///< The label for showing applied custom theme
std::vector<OUString> m_vDefaultPersonaSettings;
std::vector<OUString> m_vExtensionPersonaSettings;
@@ -73,21 +75,17 @@ private:
DECL_LINK_TYPED( SelectInstalledPersona, ListBox&, void );
};
-/** Dialog that will allow the user to choose a Persona to use.
-
-So far there is no better possibility than just to paste the URL from
-https://addons.mozilla.org/firefox/themes ...
-*/
+/** Dialog that will allow the user to choose a Persona to use. */
class SelectPersonaDialog : public ModalDialog
{
private:
- VclPtr<Edit> m_pEdit; ///< The input line for the search term
- VclPtr<PushButton> m_pSearchButton; ///< The search button
- VclPtr<FixedText> m_pProgressLabel; ///< The label for showing progress of search
- VclPtr<PushButton> m_vResultList[9]; ///< List of buttons to show search results
- VclPtr<PushButton> m_vSearchSuggestions[6]; ///< List of buttons for the search suggestions
- VclPtr<PushButton> m_pOkButton; ///< The OK button
- VclPtr<PushButton> m_pCancelButton; ///< The Cancel button
+ VclPtr<Edit> m_pEdit; ///< The input line for the search term
+ VclPtr<PushButton> m_pSearchButton; ///< The search button
+ VclPtr<FixedText> m_pProgressLabel; ///< The label for showing progress of search
+ VclPtr<PushButton> m_vResultList[9]; ///< List of buttons to show search results
+ VclPtr<PushButton> m_vSearchSuggestions[CATEGORYCOUNT]; ///< List of buttons for the search suggestions
+ VclPtr<PushButton> m_pOkButton; ///< The OK button
+ VclPtr<PushButton> m_pCancelButton; ///< The Cancel button
std::vector<OUString> m_vPersonaSettings;
OUString m_aSelectedPersona;
diff --git a/cui/source/options/personalization.src b/cui/source/options/personalization.src
index c98fd49..6170dd9 100644
--- a/cui/source/options/personalization.src
+++ b/cui/source/options/personalization.src
@@ -49,29 +49,22 @@ String RID_SVXSTR_APPLYPERSONA
Text [ en-US ] = "Applying Theme...";
};
-String RID_SVXSTR_PERSONA_ABSTRACT
-{
- Text [ en-US ] = "Abstract";
-};
-
-String RID_SVXSTR_PERSONA_COLOR
-{
- Text [ en-US ] = "Color";
-};
-
-String RID_SVXSTR_PERSONA_MUSIC
-{
- Text [ en-US ] = "Music";
-};
-
-String RID_SVXSTR_PERSONA_NATURE
-{
- Text [ en-US ] = "Nature";
-};
-
-String RID_SVXSTR_PERSONA_SOLID
+/*
+ * This string array must have exactly the same content
+ * and the same order as the m_vSuggestionCategories array
+ * in personalization.cxx file.
+ */
+StringArray RID_SVXSTR_PERSONA_CATEGORIES
{
- Text [ en-US ] = "Solid";
+ ItemList [en-US]=
+ {
+ < "LibreOffice" ; > ;
+ < "Abstract" ; > ;
+ < "Color" ; > ;
+ < "Music" ; > ;
+ < "Nature" ; > ;
+ < "Solid" ; > ;
+ };
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list