diff options
author | Muhammet Kara <muhammet.kara@pardus.org.tr> | 2018-10-22 16:55:38 +0300 |
---|---|---|
committer | Muhammet Kara <muhammet.kara@pardus.org.tr> | 2018-10-23 12:32:10 +0200 |
commit | 0c18395d56fe56db375a10592fe2702fa1e700fd (patch) | |
tree | be6181524723e1f35b93db10426a0b3c07bc2f03 | |
parent | 1688a395d05125b83eac6cd5c43f0e3f2f66c491 (diff) |
tdf#120475: Sync persona categories with Mozilla
* Removed buttons which represent the static set of 6 categories
* Added all categories from Mozilla:
https://addons.mozilla.org/en-US/firefox/themes/
* Added extra category, named Featured,
which will be selected by default
* Sort results based on download numbers
Change-Id: Ia3908f560dedbd08ce2c0d469fbe75a7d3dee15b
Reviewed-on: https://gerrit.libreoffice.org/62183
Tested-by: Jenkins
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
-rw-r--r-- | cui/inc/personalization.hrc | 41 | ||||
-rw-r--r-- | cui/source/options/personalization.cxx | 84 | ||||
-rw-r--r-- | cui/source/options/personalization.hxx | 11 | ||||
-rw-r--r-- | cui/uiconfig/ui/select_persona_dialog.ui | 285 |
4 files changed, 137 insertions, 284 deletions
diff --git a/cui/inc/personalization.hrc b/cui/inc/personalization.hrc deleted file mode 100644 index c7bda2bed3a8..000000000000 --- a/cui/inc/personalization.hrc +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#ifndef INCLUDED_CUI_INC_PERSONALIZATION_HRC -#define INCLUDED_CUI_INC_PERSONALIZATION_HRC - -#define NC_(Context, String) (Context "\004" u8##String) - -/* - * This string array must have exactly the same content - * and the same order as the m_vSuggestionCategories array - * in personalization.cxx file. - */ -const char* RID_SVXSTR_PERSONA_CATEGORIES[] = -{ - NC_("RID_SVXSTR_PERSONA_CATEGORIES", "LibreOffice"), - NC_("RID_SVXSTR_PERSONA_CATEGORIES", "Abstract"), - NC_("RID_SVXSTR_PERSONA_CATEGORIES", "Color"), - NC_("RID_SVXSTR_PERSONA_CATEGORIES", "Music"), - NC_("RID_SVXSTR_PERSONA_CATEGORIES", "Nature"), - NC_("RID_SVXSTR_PERSONA_CATEGORIES", "Solid") -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/options/personalization.cxx b/cui/source/options/personalization.cxx index fb4032fa76fd..e46a15454ceb 100644 --- a/cui/source/options/personalization.cxx +++ b/cui/source/options/personalization.cxx @@ -30,7 +30,6 @@ #include <vcl/mnemonic.hxx> #include <dialmgr.hxx> #include <strings.hrc> -#include <personalization.hrc> #include <com/sun/star/task/InteractionHandler.hpp> #include <com/sun/star/ucb/SimpleFileAccess.hpp> @@ -169,22 +168,11 @@ SelectPersonaDialog::SelectPersonaDialog( vcl::Window *pParent ) get( m_pSearchButton, "search_personas" ); m_pSearchButton->SetClickHdl( LINK( this, SelectPersonaDialog, SearchPersonas ) ); - get( m_vSearchSuggestions[0], "suggestion1" ); - get( m_vSearchSuggestions[1], "suggestion2" ); - get( m_vSearchSuggestions[2], "suggestion3" ); - get( m_vSearchSuggestions[3], "suggestion4" ); - get( m_vSearchSuggestions[4], "suggestion5" ); - get( m_vSearchSuggestions[5], "suggestion6" ); - - assert(SAL_N_ELEMENTS(RID_SVXSTR_PERSONA_CATEGORIES) >= CATEGORYCOUNT); - for(sal_uInt32 i = 0; i < CATEGORYCOUNT; ++i) - { - m_vSearchSuggestions[i]->SetText(CuiResId(RID_SVXSTR_PERSONA_CATEGORIES[i])); - m_vSearchSuggestions[i]->SetClickHdl( LINK( this, SelectPersonaDialog, SearchPersonas ) ); - } - get( m_pEdit, "search_term" ); + get( m_pCategories, "categoriesCB" ); + m_pCategories->SetSelectHdl( LINK( this, SelectPersonaDialog, SelectCategory ) ); + get( m_pProgressLabel, "progress_label" ); get( m_pOkButton, "ok" ); @@ -208,7 +196,8 @@ SelectPersonaDialog::SelectPersonaDialog( vcl::Window *pParent ) nIndex->Disable(); } - m_vSearchSuggestions[DEFAULT_PERSONA_CATEGORY]->Click(); + m_pCategories->SelectEntry("Featured"); + m_pCategories->GetSelectHdl().Call(*m_pCategories); } SelectPersonaDialog::~SelectPersonaDialog() @@ -227,13 +216,12 @@ void SelectPersonaDialog::dispose() m_pSearchThread->join(); } + m_pCategories.clear(); m_pEdit.clear(); m_pSearchButton.clear(); m_pProgressLabel.clear(); for (VclPtr<PushButton>& vp : m_vResultList) vp.clear(); - for (VclPtr<PushButton>& vp : m_vSearchSuggestions) - vp.clear(); m_pOkButton.clear(); m_pCancelButton.clear(); ModalDialog::dispose(); @@ -247,44 +235,16 @@ OUString SelectPersonaDialog::GetSelectedPersona() const return OUString(); } -IMPL_LINK( SelectPersonaDialog, SearchPersonas, Button*, pButton, void ) +IMPL_LINK_NOARG( SelectPersonaDialog, SearchPersonas, Button*, 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.hrc - */ - /* FIXME: These categories are actual categories of Mozilla themes/personas, - * but we are using them just as regular search terms, and bringing the first - * 9 (MAX_RESULTS) personas which have all the fields set. We should instead bring - * results from the actual categories; maybe the most downloaded one, or the ones with - * the highest ratings. - */ - static const OUStringLiteral vSuggestionCategories[] = - {"LibreOffice", "Abstract", "Color", "Music", "Nature", "Solid"}; - - OUString searchTerm; - if( m_pSearchThread.is() ) - m_pSearchThread->StopExecution(); - - if( pButton == m_pSearchButton ) - searchTerm = m_pEdit->GetText(); - else - { - for ( sal_uInt32 i = 0; i < CATEGORYCOUNT; ++i) - { - if( pButton == m_vSearchSuggestions[i] ) - { - // Use the category name in English as search term - searchTerm = vSuggestionCategories[i]; - break; - } - } - } + OUString searchTerm = m_pEdit->GetText(); if( searchTerm.isEmpty( ) ) return; + if( m_pSearchThread.is() ) + m_pSearchThread->StopExecution(); + // Direct url of a persona given if ( searchTerm.startsWith( "https://addons.mozilla.org/" ) ) { @@ -352,6 +312,28 @@ IMPL_LINK_NOARG( SelectPersonaDialog, ActionCancel, Button*, void ) EndDialog(); } +IMPL_LINK_NOARG( SelectPersonaDialog, SelectCategory, ListBox&, void ) +{ + OUString searchTerm = *static_cast<OUString*>(m_pCategories->GetSelectedEntryData()); + OUString rSearchURL; + + if (searchTerm.isEmpty()) + return; + + if( m_pSearchThread.is() ) + m_pSearchThread->StopExecution(); + + // 15 results so that invalid and duplicate search results whose names, textcolors etc. are null can be skipped + if (searchTerm == "featured") + rSearchURL = "https://addons.mozilla.org/api/v3/addons/search/?type=persona&app=firefox&status=public&sort=users&featured=true&page_size=15"; + else + rSearchURL = "https://addons.mozilla.org/api/v3/addons/search/?type=persona&app=firefox&category=" + searchTerm + "&status=public&sort=downloads&page_size=15"; + + m_pSearchThread = new SearchAndParseThread( this, rSearchURL, false ); + + m_pSearchThread->launch(); +} + IMPL_LINK( SelectPersonaDialog, SelectPersona, Button*, pButton, void ) { if( m_pSearchThread.is() ) diff --git a/cui/source/options/personalization.hxx b/cui/source/options/personalization.hxx index e05a27842b7b..4eb55b589f60 100644 --- a/cui/source/options/personalization.hxx +++ b/cui/source/options/personalization.hxx @@ -18,15 +18,8 @@ #include <array> #include <atomic> -#define CATEGORYCOUNT 6 // Number of persona categories #define MAX_RESULTS 9 // Maximum number of search results #define MAX_DEFAULT_PERSONAS 6 // Maximum number of default personas -/* - * The category which will be loaded initially. - Should be a non-negative integer lower than CATEGORYCOUNT - Categories are defined in RID_SVXSTR_PERSONA_CATEGORIES - */ -#define DEFAULT_PERSONA_CATEGORY 0 class FixedText; class FixedHyperlink; @@ -107,7 +100,7 @@ private: VclPtr<PushButton> m_pSearchButton; ///< The search button VclPtr<FixedText> m_pProgressLabel; ///< The label for showing progress of search VclPtr<PushButton> m_vResultList[MAX_RESULTS]; ///< List of buttons to show search results - VclPtr<PushButton> m_vSearchSuggestions[CATEGORYCOUNT]; ///< List of buttons for the search suggestions + VclPtr<ListBox> m_pCategories; ///< The list of categories VclPtr<PushButton> m_pOkButton; ///< The OK button VclPtr<PushButton> m_pCancelButton; ///< The Cancel button @@ -133,6 +126,8 @@ public: private: /// Handle the Search button DECL_LINK( SearchPersonas, Button*, void ); + /// Handle persona categories list box + DECL_LINK( SelectCategory, ListBox&, void ); DECL_LINK( SelectPersona, Button*, void ); DECL_LINK( ActionOK, Button*, void ); DECL_LINK( ActionCancel, Button*, void ); diff --git a/cui/uiconfig/ui/select_persona_dialog.ui b/cui/uiconfig/ui/select_persona_dialog.ui index db160917b886..ca746046f3df 100644 --- a/cui/uiconfig/ui/select_persona_dialog.ui +++ b/cui/uiconfig/ui/select_persona_dialog.ui @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.16.1 --> +<!-- Generated with glade 3.22.1 --> <interface domain="cui"> <requires lib="gtk+" version="3.18"/> <object class="GtkDialog" id="SelectPersonaDialog"> @@ -7,12 +7,87 @@ <property name="border_width">6</property> <property name="title" translatable="yes" context="select_persona_dialog|SelectPersonaDialog">Select Firefox Theme</property> <property name="type_hint">dialog</property> + <child> + <placeholder/> + </child> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="orientation">vertical</property> <property name="spacing">12</property> + <child internal-child="action_area"> + <object class="GtkButtonBox" id="dialog-action_area1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="layout_style">end</property> + <child> + <object class="GtkButton" id="ok"> + <property name="label">gtk-ok</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="cancel"> + <property name="label">gtk-cancel</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkButton" id="help"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">2</property> + <property name="secondary">True</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="progress_label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="ellipsize">end</property> + <property name="max_width_chars">45</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">3</property> + <property name="secondary">True</property> + <property name="non_homogeneous">True</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">end</property> + <property name="position">4</property> + </packing> + </child> <child> <object class="GtkFrame" id="frame1"> <property name="visible">True</property> @@ -114,101 +189,30 @@ <property name="orientation">vertical</property> <property name="spacing">6</property> <child> - <object class="GtkBox" id="box7"> + <object class="GtkComboBoxText" id="categoriesCB"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="spacing">6</property> - <property name="homogeneous">True</property> - <child> - <object class="GtkButton" id="suggestion1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkButton" id="suggestion2"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkButton" id="suggestion3"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">2</property> - </packing> - </child> - <child> - <object class="GtkButton" id="suggestion4"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">3</property> - </packing> - </child> - <child> - <object class="GtkButton" id="suggestion5"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">4</property> - </packing> - </child> - <child> - <object class="GtkButton" id="suggestion6"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">5</property> - </packing> - </child> + <items> + <item id="abstract" translatable="yes" context="select_persona_dialog|categoriesCB">Abstract</item> + <item id="causes" translatable="yes" context="select_persona_dialog|categoriesCB">Causes</item> + <item id="fashion" translatable="yes" context="select_persona_dialog|categoriesCB">Fashion</item> + <item id="film-and-tv" translatable="yes" context="select_persona_dialog|categoriesCB">Film and TV</item> + <item id="firefox" translatable="yes" context="select_persona_dialog|categoriesCB">Firefox</item> + <item id="foxkeh" translatable="yes" comments="https://addons.mozilla.org/en-US/firefox/themes/" context="select_persona_dialog|categoriesCB">Foxkeh</item> + <item id="holiday" translatable="yes" context="select_persona_dialog|categoriesCB">Holiday</item> + <item id="music" translatable="yes" context="select_persona_dialog|categoriesCB">Music</item> + <item id="nature" translatable="yes" context="select_persona_dialog|categoriesCB">Nature</item> + <item id="other" translatable="yes" context="select_persona_dialog|categoriesCB">Other</item> + <item id="scenery" translatable="yes" context="select_persona_dialog|categoriesCB">Scenery</item> + <item id="seasonal" translatable="yes" context="select_persona_dialog|categoriesCB">Seasonal</item> + <item id="solid" translatable="yes" context="select_persona_dialog|categoriesCB">Solid</item> + <item id="sports" translatable="yes" context="select_persona_dialog|categoriesCB">Sports</item> + <item id="websites" translatable="yes" context="select_persona_dialog|categoriesCB">Websites</item> + <item id="featured" translatable="yes" context="select_persona_dialog|categoriesCB">Featured</item> + </items> + <accessibility> + <relation type="labelled-by" target="label6"/> + </accessibility> </object> <packing> <property name="expand">False</property> @@ -228,6 +232,9 @@ <attributes> <attribute name="weight" value="bold"/> </attributes> + <accessibility> + <relation type="label-for" target="categoriesCB"/> + </accessibility> </object> </child> </object> @@ -269,8 +276,6 @@ <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -284,8 +289,6 @@ <packing> <property name="left_attach">1</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -299,8 +302,6 @@ <packing> <property name="left_attach">2</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -314,8 +315,6 @@ <packing> <property name="left_attach">0</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -329,8 +328,6 @@ <packing> <property name="left_attach">1</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -344,8 +341,6 @@ <packing> <property name="left_attach">2</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -359,8 +354,6 @@ <packing> <property name="left_attach">0</property> <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -374,8 +367,6 @@ <packing> <property name="left_attach">1</property> <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -389,8 +380,6 @@ <packing> <property name="left_attach">2</property> <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> </object> @@ -400,78 +389,6 @@ <property name="position">3</property> </packing> </child> - <child internal-child="action_area"> - <object class="GtkButtonBox" id="dialog-action_area1"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="layout_style">end</property> - <child> - <object class="GtkButton" id="ok"> - <property name="label">gtk-ok</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="use_stock">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkButton" id="cancel"> - <property name="label">gtk-cancel</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="use_stock">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkButton" id="help"> - <property name="label">gtk-help</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="use_stock">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">2</property> - <property name="secondary">True</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="progress_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="ellipsize">end</property> - <property name="max_width_chars">45</property> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">3</property> - <property name="secondary">True</property> - <property name="non_homogeneous">True</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">end</property> - <property name="position">4</property> - </packing> - </child> </object> </child> <action-widgets> |