From 4f92c462a506c6bce90826336169f0dd499f0f4c Mon Sep 17 00:00:00 2001 From: Adam Skobodzinski Date: Tue, 20 Oct 2015 10:50:07 +0200 Subject: [PATCH] Using UrlHistoryList do display history list (on urientry edition). [Issue] https://bugs.tizen.org/jira/browse/TT-161 [Problem] 'Display URL from browser history that matches to given keyword.' [Solution] UrlHistoryList is receiving list of matched entries and creates a genlist. List is hidden, when list item is selected (with cursor only for now) or focus changes from the uri entry. Created genlist is not added to a focus chain yet (this will be delivered soon). [Verify] Typing words in uri entry should display list with matched entries. Choosing item shoud load page in a new tab. Loading page or focusing out from urientry should hide the list. Signed-off-by: Adam Skobodzinski Change-Id: Icb67a9b5c47556788d256613c832cdacb7620bf3 --- services/HistoryService/HistoryService.cpp | 13 ++- services/HistoryService/HistoryService.h | 11 +- .../PlatformInputManager/PlatformInputManager.cpp | 2 + .../PlatformInputManager/PlatformInputManager.h | 1 + services/QuickAccess/CMakeLists.txt | 1 - services/QuickAccess/QuickAccess.cpp | 29 ++++- services/QuickAccess/QuickAccess.h | 9 ++ .../QuickAccess/UrlHistoryList/GenlistManager.cpp | 75 +++++++------ .../QuickAccess/UrlHistoryList/GenlistManager.h | 53 +++++---- .../UrlHistoryList/GenlistManagerCallbacks.cpp | 123 +++++++++------------ .../UrlHistoryList/GenlistManagerCallbacks.h | 66 +++++------ .../QuickAccess/UrlHistoryList/UrlHistoryList.cpp | 93 ++++++++++------ .../QuickAccess/UrlHistoryList/UrlHistoryList.h | 102 +++++++++++++---- .../UrlHistoryList/UrlMatchesStyler.cpp | 4 +- .../QuickAccess/UrlHistoryList/UrlMatchesStyler.h | 4 +- .../QuickAccess/UrlHistoryList/WidgetListManager.h | 51 --------- services/QuickAccess/edc/QuickAccess.edc | 32 ++++++ services/SimpleUI/SimpleUI.cpp | 29 +++++ services/SimpleUI/SimpleUI.h | 6 + services/WebPageUI/URIEntry.cpp | 27 +++-- services/WebPageUI/URIEntry.h | 14 ++- 21 files changed, 441 insertions(+), 304 deletions(-) delete mode 100644 services/QuickAccess/UrlHistoryList/WidgetListManager.h diff --git a/services/HistoryService/HistoryService.cpp b/services/HistoryService/HistoryService.cpp index a346c71..1287c1c 100644 --- a/services/HistoryService/HistoryService.cpp +++ b/services/HistoryService/HistoryService.cpp @@ -485,7 +485,8 @@ std::shared_ptr HistoryService::getHistoryItemsByURL( } std::shared_ptr HistoryService::getHistoryItemsByKeywordsString( - const std::string& keywordsString, int maxItems) + const std::string& keywordsString, const int maxItems, + const int minKeywordLength) { if (keywordsString.empty()) return std::make_shared(); @@ -500,7 +501,7 @@ std::shared_ptr HistoryService::getHistoryItemsByKeywordsStri boost::algorithm::to_lower(longestKeyword); // assumption: search starts when longest keyword is at least 3 characters long - if (longestKeyword.length() < 3) { + if (longestKeyword.length() < minKeywordLength) { return std::make_shared(); } @@ -515,9 +516,11 @@ std::shared_ptr HistoryService::getHistoryItemsByKeywordsStri m_historyMatchFinder->removeMismatches(historyItems, keywords); } - if (historyItems->size() > maxItems) { - historyItems->erase(historyItems->begin() + maxItems, - historyItems->end()); + if (maxItems != -1) { + if (historyItems->size() > maxItems) { + historyItems->erase(historyItems->begin() + maxItems, + historyItems->end()); + } } return historyItems; } diff --git a/services/HistoryService/HistoryService.h b/services/HistoryService/HistoryService.h index 3eda793..fe23f8e 100644 --- a/services/HistoryService/HistoryService.h +++ b/services/HistoryService/HistoryService.h @@ -68,13 +68,18 @@ public: * Splits pattern into words by removing spaces. History item matches * pattern, when its url contains all words (order not considered). * - * @param keywords - * @param maxItems + * @param keywords string containing keywords separated by spaces + * @param maxItems searched items number will be shortened to this maxItems. + * if -1: no shortening. + * @param minKeywordLength minimum length of the longest keyword picked, + * from which searching will start. If longest keyword is shorter than + * #minKeywordLength, then search will not start. * @return vector of shared pointers to history items matching given * pattern */ std::shared_ptr getHistoryItemsByKeywordsString( - const std::string& keywordsString, int maxItems); + const std::string& keywordsString, const int maxItems, + const int minKeywordLength); int getHistoryItemsCount(); void setStorageServiceTestMode(bool testmode = true); diff --git a/services/PlatformInputManager/PlatformInputManager.cpp b/services/PlatformInputManager/PlatformInputManager.cpp index fddb242..3d3d85c 100644 --- a/services/PlatformInputManager/PlatformInputManager.cpp +++ b/services/PlatformInputManager/PlatformInputManager.cpp @@ -91,6 +91,8 @@ Eina_Bool PlatformInputManager::__filter(void *data, void */*loop_data*/, int ty return EINA_TRUE; BROWSER_LOGD("Released key: %s", ev->keyname); + } else if (type == ECORE_EVENT_MOUSE_BUTTON_DOWN) { + self->mouseClicked(); } return EINA_TRUE; } diff --git a/services/PlatformInputManager/PlatformInputManager.h b/services/PlatformInputManager/PlatformInputManager.h index 0dc980e..781a418 100644 --- a/services/PlatformInputManager/PlatformInputManager.h +++ b/services/PlatformInputManager/PlatformInputManager.h @@ -54,6 +54,7 @@ public: boost::signals2::signal leftPressed; boost::signals2::signal rightPressed; boost::signals2::signal backPressed; + boost::signals2::signal mouseClicked; /** * @brief Returns current service's name. diff --git a/services/QuickAccess/CMakeLists.txt b/services/QuickAccess/CMakeLists.txt index 9d794bd..2b76470 100644 --- a/services/QuickAccess/CMakeLists.txt +++ b/services/QuickAccess/CMakeLists.txt @@ -13,7 +13,6 @@ set(QuickAccess_HEADERS QuickAccess.h DetailPopup.h UrlHistoryList/UrlHistoryList.h - UrlHistoryList/WidgetListManager.h UrlHistoryList/GenlistManager.h UrlHistoryList/GenlistManagerCallbacks.h UrlHistoryList/UrlMatchesStyler.h diff --git a/services/QuickAccess/QuickAccess.cpp b/services/QuickAccess/QuickAccess.cpp index 5db57b6..0624b26 100644 --- a/services/QuickAccess/QuickAccess.cpp +++ b/services/QuickAccess/QuickAccess.cpp @@ -25,6 +25,7 @@ #include "Tools/EflTools.h" #include "../Tools/BrowserImage.h" #include "Tools/GeneralTools.h" +#include "UrlHistoryList/UrlHistoryList.h" #define efl_scale (elm_config_scale_get() / elm_app_base_scale_get()) @@ -75,10 +76,14 @@ QuickAccess::QuickAccess() , m_after_history_thumb(false) { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); - edjFilePath = EDJE_DIR; + edjFilePath = edjFilePathUrlHistoryList = EDJE_DIR; edjFilePath.append("QuickAccess/QuickAccess.edj"); + edjFilePathUrlHistoryList.append("QuickAccess/UrlHistoryList.edj"); elm_theme_extension_add(nullptr, edjFilePath.c_str()); + elm_theme_extension_add(nullptr, edjFilePathUrlHistoryList.c_str()); QuickAccess::createItemClasses(); + + m_urlHistoryList = std::make_shared(this); } QuickAccess::~QuickAccess() @@ -100,6 +105,7 @@ Evas_Object* QuickAccess::getContent() M_ASSERT(m_parent); if (!m_layout) { m_layout = createQuickAccessLayout(m_parent); + m_urlHistoryListLayout = createUrlHistoryListLayout(m_layout); } return m_layout; } @@ -249,6 +255,21 @@ Evas_Object* QuickAccess::createBottomButton(Evas_Object *parent) return layoutBottom; } +Evas_Object* QuickAccess::createUrlHistoryListLayout(Evas_Object* parent) +{ + Evas_Object* urlHistoryListLayout = elm_layout_add(parent); + elm_layout_file_set(urlHistoryListLayout, edjFilePath.c_str(), "url_history_list_layout"); + evas_object_size_hint_weight_set(urlHistoryListLayout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set (urlHistoryListLayout, EVAS_HINT_FILL, EVAS_HINT_FILL); + + m_urlHistoryList->createLayout(urlHistoryListLayout); + if(m_urlHistoryList->getLayout()) + { + elm_object_part_content_set(urlHistoryListLayout, "url_history_list_swallow", m_urlHistoryList->getLayout()); + } + return urlHistoryListLayout; +} + void QuickAccess::_mostVisited_clicked(void * data, Evas_Object *, void *) { BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__); @@ -440,6 +461,7 @@ void QuickAccess::showUI() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); evas_object_show(m_layout); + evas_object_show(m_urlHistoryListLayout); if (elm_layout_content_get(m_layout, "elm.swallow.content") == m_bookmarksView) { evas_object_show(m_bookmarksView); } else { @@ -493,6 +515,11 @@ DetailPopup& QuickAccess::getDetailPopup() return m_detailPopup; } +UrlHistoryPtr QuickAccess::getUrlHistoryList() +{ + return m_urlHistoryList; +} + void QuickAccess::backButtonClicked() { if (m_detailPopup.isVisible()) { diff --git a/services/QuickAccess/QuickAccess.h b/services/QuickAccess/QuickAccess.h index 5418b38..9dd5155 100644 --- a/services/QuickAccess/QuickAccess.h +++ b/services/QuickAccess/QuickAccess.h @@ -31,6 +31,9 @@ namespace tizen_browser{ namespace base_ui{ +class UrlHistoryList; +typedef std::shared_ptr UrlHistoryPtr; + //TODO: This class name is not revelant to what this class actually does. //Rename this class and file to "QuickAccessUI". class BROWSER_EXPORT QuickAccess @@ -50,6 +53,7 @@ public: bool isDesktopMode() const; void setDesktopMode(bool mode); DetailPopup & getDetailPopup(); + UrlHistoryPtr getUrlHistoryList(); void backButtonClicked(); inline bool isMostVisitedActive() const; void refreshFocusChain(); @@ -80,6 +84,7 @@ private: Evas_Object* createBookmarksView(Evas_Object *parent); Evas_Object* createBottomButton(Evas_Object *parent); Evas_Object* createTopButtons(Evas_Object *parent); + Evas_Object* createUrlHistoryListLayout(Evas_Object *parent); static char* _grid_bookmark_text_get(void *data, Evas_Object *obj, const char *part); static Evas_Object * _grid_bookmark_content_get(void *data, Evas_Object *obj, const char *part); @@ -104,11 +109,15 @@ private: std::vector m_tiles; Eina_List* m_parentFocusChain; + UrlHistoryPtr m_urlHistoryList; + Evas_Object* m_urlHistoryListLayout; + Elm_Gengrid_Item_Class * m_bookmark_item_class; DetailPopup m_detailPopup; services::HistoryItemVector m_historyItems; bool m_gengridSetup; std::string edjFilePath; + std::string edjFilePathUrlHistoryList; bool m_desktopMode; static const int MAX_TILES_NUMBER; diff --git a/services/QuickAccess/UrlHistoryList/GenlistManager.cpp b/services/QuickAccess/UrlHistoryList/GenlistManager.cpp index c29dfc5..fda4254 100644 --- a/services/QuickAccess/UrlHistoryList/GenlistManager.cpp +++ b/services/QuickAccess/UrlHistoryList/GenlistManager.cpp @@ -19,7 +19,7 @@ #include "UrlMatchesStyler.h" namespace tizen_browser { -namespace services { +namespace base_ui { GenlistManager::GenlistManager() { @@ -38,6 +38,8 @@ GenlistManager::GenlistManager() m_historyItemSpaceClass->func.content_get = nullptr; m_historyItemSpaceClass->func.state_get = nullptr; m_historyItemSpaceClass->func.del = nullptr; + + GenlistManagerCallbacks::setGenlistManager(this); } GenlistManager::~GenlistManager() @@ -47,10 +49,8 @@ GenlistManager::~GenlistManager() void GenlistManager::clearWidget() { - elm_genlist_clear(m_genlist); - elm_genlist_clear(m_genlist); - elm_genlist_clear(m_genlist); - elm_genlist_clear(m_genlist); + if(m_genlist && elm_genlist_items_count(m_genlist)) + elm_genlist_clear(m_genlist); } void GenlistManager::onMouseFocusChange(bool mouseInsideWidget) @@ -72,28 +72,22 @@ Evas_Object* GenlistManager::createWidget(Evas_Object* parentLayout) ELM_SCROLLER_POLICY_OFF); } - evas_object_smart_callback_add(m_genlist, "scroll,anim,stop", - GenlistManagerCallbacks::cb_genlistAnimStop, this); evas_object_smart_callback_add(m_genlist, "edge,top", - GenlistManagerCallbacks::cb_genlistEdgeTop, this); + GenlistManagerCallbacks::_genlist_edge_top, this); evas_object_smart_callback_add(m_genlist, "edge,bottom", - GenlistManagerCallbacks::cb_genlistEdgeBottom, this); - - evas_object_smart_callback_add(m_genlist, "activated", - GenlistManagerCallbacks::cb_genlistActivated, this); - evas_object_smart_callback_add(m_genlist, "pressed", - GenlistManagerCallbacks::cb_genlistPressed, this); - evas_object_smart_callback_add(m_genlist, "selected", - GenlistManagerCallbacks::cb_genlistSelected, this); + GenlistManagerCallbacks::_genlist_edge_bottom, this); evas_object_event_callback_add(m_genlist, EVAS_CALLBACK_MOUSE_IN, - GenlistManagerCallbacks::cb_genlistMouseIn, this); + GenlistManagerCallbacks::_genlist_mouse_in, this); evas_object_event_callback_add(m_genlist, EVAS_CALLBACK_MOUSE_OUT, - GenlistManagerCallbacks::cb_genlistMouseOut, this); - evas_object_smart_callback_add(m_genlist, "unselected", - GenlistManagerCallbacks::cb_genlistUnselected, this); + GenlistManagerCallbacks::_genlist_mouse_out, this); + evas_object_smart_callback_add(m_genlist, "focused", - GenlistManagerCallbacks::cb_genlistFocused, this); + GenlistManagerCallbacks::_genlist_focused, this); + evas_object_smart_callback_add(m_genlist, "unfocused", + GenlistManagerCallbacks::_genlist_unfocused, this); + + } return m_genlist; } @@ -113,9 +107,9 @@ void GenlistManager::showWidget(const string& editedUrl, m_itemUrlFirst = m_itemUrlLast = nullptr; Elm_Object_Item* itemAppended; - for (auto it : m_readyUrls) { + for(auto it : m_readyUrlPairs) { itemAppended = elm_genlist_item_append(m_genlist, m_historyItemClass, - it.get(), nullptr, ELM_GENLIST_ITEM_NONE, nullptr, this); + it.get(), nullptr, ELM_GENLIST_ITEM_NONE, GenlistManagerCallbacks::_item_selected, it.get()); if (!m_itemUrlFirst) m_itemUrlFirst = itemAppended; } @@ -127,14 +121,22 @@ void GenlistManager::showWidget(const string& editedUrl, } } -void GenlistManager::hideWidget() +void GenlistManager::hideWidgetPretty() { - if (widgetPreviouslyHidden) + if (widgetPreviouslyHidden) { + hideWidgetInstant(); return; + } startScrollOut(); widgetPreviouslyHidden = true; } +void GenlistManager::hideWidgetInstant() +{ + if(m_genlist) + evas_object_hide(m_genlist); +} + bool GenlistManager::isWidgetHidden() { return widgetPreviouslyHidden; @@ -143,7 +145,7 @@ bool GenlistManager::isWidgetHidden() void GenlistManager::onMouseClick() { if (!mouseInsideWidget) { - hideWidget(); + hideWidgetPretty(); } } @@ -181,7 +183,7 @@ void GenlistManager::addSpaces() if (m_itemUrlLast) { m_itemSpaceFirst = m_itemSpaceLast = nullptr; Elm_Object_Item* itemAppended; - for (auto i = 0; i < historyItemsVisibleMax; ++i) { + for (auto i = 0; i < HISTORY_ITEMS_VISIBLE_MAX; ++i) { // append spaces to the last url item, so they can be easily cleared itemAppended = elm_genlist_item_append(m_genlist, m_historyItemSpaceClass, nullptr, m_itemUrlLast, @@ -201,14 +203,14 @@ void GenlistManager::removeSpaces() m_itemSpaceFirst = m_itemSpaceLast = nullptr; } -Evas_Object* GenlistManager::m_contentGet(void *data, Evas_Object *obj, - const char *part) +Evas_Object* GenlistManager::m_contentGet(void* data, Evas_Object* obj, + const char* part) { Evas_Object* label = elm_label_add(obj); if (strcmp(part, "matched_url") == 0) { - const string * const item = reinterpret_cast(data); + const UrlPair* const item = reinterpret_cast(data); if (item) { - elm_object_text_set(label, item->c_str()); + elm_object_text_set(label, item->urlHighlighted.c_str()); evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(label, EVAS_HINT_FILL, @@ -224,13 +226,14 @@ void GenlistManager::prepareUrlsVector(const string& editedUrl, // free previously used urls. IMPORTANT: it has to be assured that previous // genlist items are not using these pointers. m_readyUrls.clear(); + m_readyUrlPairs.clear(); for (auto it : *matchedEntries) { - m_readyUrls.push_back( - make_shared < string - > (m_urlMatchesStyler->getUrlHighlightedMatches( - it->getUrl(), editedUrl))); + UrlPair newUrlPair(it->getUrl(), + m_urlMatchesStyler->getUrlHighlightedMatches(it->getUrl(), + editedUrl)); + m_readyUrlPairs.push_back(make_shared < UrlPair > (newUrlPair)); } } -} /* namespace services */ +} /* namespace base_ui */ } /* namespace tizen_browser */ diff --git a/services/QuickAccess/UrlHistoryList/GenlistManager.h b/services/QuickAccess/UrlHistoryList/GenlistManager.h index 05d5cd3..b1e91e1 100644 --- a/services/QuickAccess/UrlHistoryList/GenlistManager.h +++ b/services/QuickAccess/UrlHistoryList/GenlistManager.h @@ -18,46 +18,54 @@ #define GENLISTMANAGER_H_ #include - +#include "services/HistoryService/HistoryItem.h" +#include #include "BrowserLogger.h" -#include "WidgetListManager.h" using namespace std; namespace tizen_browser { -namespace services { +namespace base_ui { class GenlistManagerCallbacks; class UrlMatchesStyler; typedef shared_ptr UrlMatchesStylerPtr; -class GenlistManager: public WidgetListManager +typedef struct UrlPair_s { + UrlPair_s(string a, string b) : urlOriginal(a), urlHighlighted(b) {} + string urlOriginal; + string urlHighlighted; +} UrlPair; + +class GenlistManager { friend class GenlistManagerCallbacks; public: GenlistManager(); - virtual ~GenlistManager(); + ~GenlistManager(); - virtual Evas_Object* createWidget(Evas_Object* parentLayout); - virtual Evas_Object* getWidget(); + Evas_Object* createWidget(Evas_Object* parentLayout); + Evas_Object* getWidget(); - virtual void showWidget(const string& editedUrl, + void showWidget(const string& editedUrl, shared_ptr matchedEntries); - virtual void hideWidget(); - void onMouseClick(); - + void hideWidgetPretty(); + void hideWidgetInstant(); bool isWidgetHidden(); + void onMouseClick(); /** * Add empty list elements to allow scroll in effect. */ void addSpaces(); void removeSpaces(); - void clearWidget(); -private: + boost::signals2::signal signalItemSelected; + boost::signals2::signal signalWidgetFocused; + boost::signals2::signal signalWidgetUnfocused; +private: static Evas_Object* m_contentGet(void *data, Evas_Object *obj, const char *part); bool widgetExists() @@ -66,21 +74,23 @@ private: } void prepareUrlsVector(const string& editedUrl, shared_ptr matchedEntries); - void startScrollIn(); - void startScrollOut(); + void setLastEdgeTop(bool edgeTop); bool getLastEdgeTop(); void onMouseFocusChange(bool mouseInsideWidget); + void startScrollIn(); + void startScrollOut(); + Evas_Object* m_parentLayout = nullptr; Evas_Object* m_genlist = nullptr; const bool genlistShowScrollbar = false; // don't know how to get from edc: - const int historyItemH = 82; - const int historyItemsVisibleMax = 5; + const int HISTORY_ITEM_H = 82; + const int HISTORY_ITEMS_VISIBLE_MAX = 5; // don't know how to calculate: - const int genlistH = historyItemH * historyItemsVisibleMax; + const int GENLIST_H = HISTORY_ITEM_H * HISTORY_ITEMS_VISIBLE_MAX; /* * Set to true, whenever hide request occurs. Set to false, whenever show @@ -96,8 +106,8 @@ private: */ bool lastEdgeTop = true; - Elm_Gengrid_Item_Class * m_historyItemClass; - Elm_Gengrid_Item_Class * m_historyItemSpaceClass; + Elm_Gengrid_Item_Class* m_historyItemClass; + Elm_Gengrid_Item_Class* m_historyItemSpaceClass; Elm_Object_Item* m_itemUrlFirst = nullptr; Elm_Object_Item* m_itemUrlLast = nullptr; Elm_Object_Item* m_itemSpaceFirst = nullptr; @@ -111,11 +121,12 @@ private: * manually in m_contentGet(). */ vector> m_readyUrls; + vector> m_readyUrlPairs; UrlMatchesStylerPtr m_urlMatchesStyler; }; -} /* namespace services */ +} /* namespace base_ui */ } /* namespace tizen_browser */ #endif /* GENLISTMANAGER_H_ */ diff --git a/services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.cpp b/services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.cpp index 25c3868..17d1cf3 100644 --- a/services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.cpp +++ b/services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.cpp @@ -15,13 +15,12 @@ */ #include "BrowserLogger.h" -#include "GenlistManagerCallbacks.h" -#include "GenlistManager.h" +#include -namespace tizen_browser -{ -namespace services -{ +namespace tizen_browser { +namespace base_ui { + +GenlistManager* GenlistManagerCallbacks::genlistManager = nullptr; GenlistManagerCallbacks::GenlistManagerCallbacks() { @@ -31,89 +30,69 @@ GenlistManagerCallbacks::~GenlistManagerCallbacks() { } -void GenlistManagerCallbacks::cb_genlistAnimStop(void *data, Evas_Object *obj, - void *event_info) -{ -} - -void GenlistManagerCallbacks::cb_genlistEdgeTop(void *data, Evas_Object *obj, - void *event_info) +void GenlistManagerCallbacks::_genlist_edge_top(void *data, Evas_Object* /*obj*/, + void* /*event_info*/) { - BROWSER_LOGD("@@ %s", __FUNCTION__); - auto manager = static_cast(data); - manager->setLastEdgeTop(false); - // spaces added for 'slide in' effect are not longer needed - manager->removeSpaces(); + auto manager = static_cast(data); + manager->setLastEdgeTop(false); + // spaces added for 'slide in' effect are not longer needed + manager->removeSpaces(); } -void GenlistManagerCallbacks::cb_genlistEdgeBottom(void *data, Evas_Object *obj, - void *event_info) +void GenlistManagerCallbacks::_genlist_edge_bottom(void *data, Evas_Object* /*obj*/, + void* /*event_info*/) { - auto manager = static_cast(data); - manager->setLastEdgeTop(true); - if (manager->isWidgetHidden()) - { - manager->clearWidget(); - evas_object_hide(manager->getWidget()); - } + auto manager = static_cast(data); + manager->setLastEdgeTop(true); + if (manager->isWidgetHidden()) { + manager->clearWidget(); + evas_object_hide(manager->getWidget()); + } } -void GenlistManagerCallbacks::cb_genlistActivated(void *data, Evas_Object *obj, - void *event_info) -{ -} -void GenlistManagerCallbacks::cb_genlistPressed(void *data, Evas_Object *obj, - void *event_info) -{ -} -void GenlistManagerCallbacks::cb_genlistSelected(void *data, Evas_Object *obj, - void *event_info) -{ -} -void GenlistManagerCallbacks::cb_genlistUnselected(void *data, Evas_Object *obj, - void *event_info) +void GenlistManagerCallbacks::_genlist_mouse_in(void* data, Evas* /*e*/, + Evas_Object* /*obj*/, void* /*event_info*/) { + auto manager = static_cast(data); + manager->onMouseFocusChange(true); } - -void GenlistManagerCallbacks::cb_genlistFocused(void *data, Evas_Object *obj, - void *event_info) +void GenlistManagerCallbacks::_genlist_mouse_out(void* data, Evas* /*e*/, + Evas_Object* /*obj*/, void* /*event_info*/) { + auto manager = static_cast(data); + manager->onMouseFocusChange(false); } -void GenlistManagerCallbacks::cb_genlistUnfocused(void *data, Evas_Object *obj, - void *event_info) +void GenlistManagerCallbacks::_genlist_focused(void* /*data*/, Evas_Object* /*obj*/, + void* /*event_info*/) { + if(genlistManager) + { + genlistManager->signalWidgetFocused(); + } } -void GenlistManagerCallbacks::cb_genlistMouseIn(void *data, Evas *e, - Evas_Object *obj, void *event_info) -{ - auto manager = static_cast(data); - manager->onMouseFocusChange(true); -} -void GenlistManagerCallbacks::cb_genlistMouseOut(void *data, Evas *e, - Evas_Object *obj, void *event_info) +void GenlistManagerCallbacks::_genlist_unfocused(void* /*data*/, Evas_Object* /*obj*/, + void* /*event_info*/) { - auto manager = static_cast(data); - manager->onMouseFocusChange(false); + if(genlistManager) + { + genlistManager->signalWidgetUnfocused(); + } } -void GenlistManagerCallbacks::cb_itemFocused(void *data, Evas_Object *obj, - void *event_info) -{ -} -void GenlistManagerCallbacks::cb_itemUnfocused(void *data, Evas_Object *obj, - void *event_info) -{ -} -void GenlistManagerCallbacks::cb_itemMouseIn(void *data, Elm_Object_Item *it, - const char *emission, const char *source) -{ -} -void GenlistManagerCallbacks::cb_itemMouseOut(void *data, Evas *e, - Evas_Object *obj, void *event_info) -{ +void GenlistManagerCallbacks::_item_selected(void* data, Evas_Object* /*obj*/, + void* /*event_info*/) +{ + const UrlPair* const item = reinterpret_cast(data); + if (item) { + if(genlistManager) + { + genlistManager->signalItemSelected(item->urlOriginal); + genlistManager->hideWidgetPretty(); + } + } } -} /* namespace services */ +} /* namespace base_ui */ } /* namespace tizen_browser */ diff --git a/services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.h b/services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.h index 25ff418..228108d 100644 --- a/services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.h +++ b/services/QuickAccess/UrlHistoryList/GenlistManagerCallbacks.h @@ -17,57 +17,47 @@ #ifndef GENLISTMANAGERCALLBACKS_H_ #define GENLISTMANAGERCALLBACKS_H_ +#include #include #include -class GenlistManager; - -namespace tizen_browser -{ -namespace services -{ +namespace tizen_browser { +namespace base_ui { class GenlistManagerCallbacks { public: - GenlistManagerCallbacks(); - virtual ~GenlistManagerCallbacks(); + GenlistManagerCallbacks(); + virtual ~GenlistManagerCallbacks(); + + static void _genlist_edge_top(void* data, Evas_Object* obj, + void* event_info); + static void _genlist_edge_bottom(void* data, Evas_Object* obj, + void* event_info); + + static void _genlist_mouse_in(void* data, Evas* e, Evas_Object* obj, + void* event_info); + static void _genlist_mouse_out(void* data, Evas* e, Evas_Object* obj, + void* event_info); + + static void _genlist_focused(void* data, Evas_Object* obj, + void* event_info); + static void _genlist_unfocused(void* data, Evas_Object* obj, + void* event_info); - static void cb_genlistAnimStop(void *data, Evas_Object *obj, - void *event_info); - static void cb_genlistEdgeTop(void *data, Evas_Object *obj, - void *event_info); - static void cb_genlistEdgeBottom(void *data, Evas_Object *obj, - void *event_info); + static void _item_selected(void* data, Evas_Object* obj, void* event_info); - static void cb_genlistActivated(void *data, Evas_Object *obj, - void *event_info); - static void cb_genlistPressed(void *data, Evas_Object *obj, - void *event_info); - static void cb_genlistSelected(void *data, Evas_Object *obj, - void *event_info); - static void cb_genlistUnselected(void *data, Evas_Object *obj, - void *event_info); + static void setGenlistManager(GenlistManager* genlistManager) + { + GenlistManagerCallbacks::genlistManager = genlistManager; + } - static void cb_genlistFocused(void *data, Evas_Object *obj, - void *event_info); - static void cb_genlistUnfocused(void *data, Evas_Object *obj, - void *event_info); - static void cb_genlistMouseIn(void *data, Evas *e, Evas_Object *obj, - void *event_info); - static void cb_genlistMouseOut(void *data, Evas *e, Evas_Object *obj, - void *event_info); +private: + static GenlistManager* genlistManager; - static void cb_itemFocused(void *data, Evas_Object *obj, void *event_info); - static void cb_itemUnfocused(void *data, Evas_Object *obj, - void *event_info); - static void cb_itemMouseIn(void *data, Elm_Object_Item *it, - const char *emission, const char *source); - static void cb_itemMouseOut(void *data, Evas *e, Evas_Object *obj, - void *event_info); }; -} /* namespace services */ +} /* namespace base_ui */ } /* namespace tizen_browser */ #endif /* GENLISTMANAGERCALLBACKS_H_ */ diff --git a/services/QuickAccess/UrlHistoryList/UrlHistoryList.cpp b/services/QuickAccess/UrlHistoryList/UrlHistoryList.cpp index fd76489..c6530bc 100644 --- a/services/QuickAccess/UrlHistoryList/UrlHistoryList.cpp +++ b/services/QuickAccess/UrlHistoryList/UrlHistoryList.cpp @@ -17,66 +17,89 @@ #include #include "UrlHistoryList.h" #include "GenlistManager.h" - #include "BrowserLogger.h" +#include "../QuickAccess.h" -namespace tizen_browser -{ -namespace base_ui -{ +namespace tizen_browser { +namespace base_ui { -UrlHistoryList::UrlHistoryList() : - m_layout(nullptr) +UrlHistoryList::UrlHistoryList(QuickAccess* quickAccess) : + m_layout(nullptr), m_quickAccess(quickAccess) { - m_edjFilePath = EDJE_DIR; - m_edjFilePath.append("MainUI/UrlHistoryList.edj"); - m_widgetListManager = make_shared(); + m_edjFilePath = EDJE_DIR; + m_edjFilePath.append("QuickAccess/UrlHistoryList.edj"); + m_genlistListManager = make_shared(); + m_genlistListManager->signalItemSelected.connect( + boost::bind(&UrlHistoryList::onListItemSelect, this, _1)); + m_genlistListManager->signalWidgetFocused.connect( + boost::bind(&UrlHistoryList::onListWidgetFocused, this)); + m_genlistListManager->signalWidgetUnfocused.connect( + boost::bind(&UrlHistoryList::onListWidgetUnfocused, this)); } UrlHistoryList::~UrlHistoryList() { } -void UrlHistoryList::show() +Evas_Object* UrlHistoryList::getLayout() { - if (m_layout) - { - evas_object_show(m_layout); - } + return m_layout; } -Evas_Object* UrlHistoryList::getLayout() +void UrlHistoryList::createLayout(Evas_Object* parentLayout) { - return m_layout; + m_layout = elm_layout_add(parentLayout); + elm_layout_file_set(m_layout, m_edjFilePath.c_str(), "url_history_list"); + + Evas_Object* widgetList = m_genlistListManager->createWidget(m_layout); } -void UrlHistoryList::createLayout(Evas_Object* parentLayout) +void UrlHistoryList::onURLEntryEditedByUser(const string& editedUrl, + shared_ptr matchedEntries) { - m_layout = elm_layout_add(parentLayout); - elm_layout_file_set(m_layout, m_edjFilePath.c_str(), "url_history_list"); + editedUrlStatesHelper.changeState(true); - Evas_Object* widgetList = m_widgetListManager->createWidget(m_layout); + if (matchedEntries->size() == 0) { + m_genlistListManager->hideWidgetPretty(); + } else { + Evas_Object* widgetList = m_genlistListManager->getWidget(); + elm_object_part_content_set(m_layout, "list_swallow", widgetList); + m_genlistListManager->showWidget(editedUrl, matchedEntries); + evas_object_show(widgetList); + } } -void UrlHistoryList::onURLEntryEdit(const string& editedUrl, - shared_ptr matchedEntries) +void UrlHistoryList::onURLEntryEdited() { - Evas_Object* widgetList = m_widgetListManager->getWidget(); - if (matchedEntries->size() == 0) - { - m_widgetListManager->hideWidget(); - } - else - { - elm_object_part_content_set(m_layout, "list_swallow", widgetList); - m_widgetListManager->showWidget(editedUrl, matchedEntries); - evas_object_show(widgetList); - } + editedUrlStatesHelper.changeState(false); + if (editedUrlStatesHelper.getCurrentState() + == EditedUrlState::EDITED_OTHER_FIRST) { + m_genlistListManager->hideWidgetPretty(); + } else { + // in this situation scroll will not work, it has to be hidden instantly + m_genlistListManager->hideWidgetInstant(); + } } void UrlHistoryList::onMouseClick() { - m_widgetListManager->onMouseClick(); + m_genlistListManager->onMouseClick(); +} + +void UrlHistoryList::onListItemSelect(std::string content) +{ + openURLInNewTab(make_shared < services::HistoryItem > (content), + m_quickAccess->isDesktopMode()); +} + +void UrlHistoryList::onListWidgetFocused() +{ + // will be used soon: in a proper focus-chain solution +} + +void UrlHistoryList::onListWidgetUnfocused() +{ + // will be used soon: in a proper focus-chain solution } }/* namespace base_ui */ diff --git a/services/QuickAccess/UrlHistoryList/UrlHistoryList.h b/services/QuickAccess/UrlHistoryList/UrlHistoryList.h index fa9934a..f42a425 100644 --- a/services/QuickAccess/UrlHistoryList/UrlHistoryList.h +++ b/services/QuickAccess/UrlHistoryList/UrlHistoryList.h @@ -21,20 +21,56 @@ #include #include "services/HistoryService/HistoryItem.h" +#include using namespace std; -namespace tizen_browser -{ +namespace tizen_browser { +namespace base_ui { + +class QuickAccess; +class GenlistManager; +typedef shared_ptr GenlistManagerPtr; -namespace services +enum class EditedUrlState { -class WidgetListManager; -typedef shared_ptr WidgetListManagerPtr; -} + // url was edited by a user (by typing) + EDITED_BY_USER, + // url was edited in other way than typing (but for the first time after previous user edition) + EDITED_OTHER_FIRST, + // url was edited in other way than typing (and previously was not edited by the user) + EDITED_OTHER_MANY_TIMES +}; -namespace base_ui +/** + * Needed to indicate who did the last url entry edition (user/other/other many times). Used + * to indicate when widget can be hidden in a pretty way or an instant way. + */ +class EditedUrlStatesHelper { +public: + EditedUrlStatesHelper() + { + } + void changeState(bool editedByUser) + { + if (editedByUser) { + currentState = EditedUrlState::EDITED_BY_USER; + } else { + if (currentState == EditedUrlState::EDITED_BY_USER) { + currentState = EditedUrlState::EDITED_OTHER_FIRST; + } else { + currentState = EditedUrlState::EDITED_OTHER_MANY_TIMES; + } + } + } + EditedUrlState getCurrentState() + { + return currentState; + } +private: + EditedUrlState currentState = EditedUrlState::EDITED_BY_USER; +}; /** * Manages list of url matches (URL from history). Manages top layout, creates @@ -43,25 +79,47 @@ namespace base_ui class UrlHistoryList { public: - UrlHistoryList(); - virtual ~UrlHistoryList(); - void show(); - void createLayout(Evas_Object* parentLayout); - Evas_Object *getLayout(); - - /** - * \brief entered url is edited (edited before acceptation) - */ - void onURLEntryEdit(const string& editedUrl, - shared_ptr matchedEntries); - void onMouseClick(); + UrlHistoryList(QuickAccess* quickAccess); + virtual ~UrlHistoryList(); + void createLayout(Evas_Object* parentLayout); + Evas_Object* getLayout(); + + // // on uri entry widget "changed,user" signal + void onURLEntryEditedByUser(const string& editedUrl, + shared_ptr matchedEntries); + // on uri entry widget "changed" signal + void onURLEntryEdited(); + + void onMouseClick(); + + boost::signals2::signal, bool)> openURLInNewTab; + + int getVisibleItemsMax() const + { + return VISIBLE_ITEMS_MAX; + } + + int getMinKeywordLength() const + { + return MIN_KEYWORD_LENGTH; + } private: + void onListItemSelect(std::string content); + void onListWidgetFocused(); + void onListWidgetUnfocused(); + + EditedUrlStatesHelper editedUrlStatesHelper; - Evas_Object* m_layout; - string m_edjFilePath; + // the maximum items number on a list + const int VISIBLE_ITEMS_MAX = 12; + // the minimum length of the keyword used to search matches + const int MIN_KEYWORD_LENGTH = 3; + Evas_Object* m_layout; + string m_edjFilePath; - services::WidgetListManagerPtr m_widgetListManager; + GenlistManagerPtr m_genlistListManager = nullptr; + QuickAccess* m_quickAccess; }; diff --git a/services/QuickAccess/UrlHistoryList/UrlMatchesStyler.cpp b/services/QuickAccess/UrlHistoryList/UrlMatchesStyler.cpp index c97758b..b03af5a 100644 --- a/services/QuickAccess/UrlHistoryList/UrlMatchesStyler.cpp +++ b/services/QuickAccess/UrlHistoryList/UrlMatchesStyler.cpp @@ -17,7 +17,7 @@ #include "UrlMatchesStyler.h" namespace tizen_browser { -namespace services { +namespace base_ui { UrlMatchesStyler::UrlMatchesStyler() : TAG_WHOLE_URL(""), @@ -127,5 +127,5 @@ string UrlMatchesStyler::getTaggedString(const string& strToHighlight, return strResult; } -} /* namespace services */ +} /* namespace base_ui */ } /* namespace tizen_browser */ diff --git a/services/QuickAccess/UrlHistoryList/UrlMatchesStyler.h b/services/QuickAccess/UrlHistoryList/UrlMatchesStyler.h index d100b29..75c5432 100644 --- a/services/QuickAccess/UrlHistoryList/UrlMatchesStyler.h +++ b/services/QuickAccess/UrlHistoryList/UrlMatchesStyler.h @@ -26,7 +26,7 @@ using namespace std; namespace tizen_browser { -namespace services { +namespace base_ui { class UrlMatchesStyler { public: @@ -103,7 +103,7 @@ private: }; -} /* namespace services */ +} /* namespace base_ui */ } /* namespace tizen_browser */ #endif /* URLMATCHESSTYLER_H_ */ diff --git a/services/QuickAccess/UrlHistoryList/WidgetListManager.h b/services/QuickAccess/UrlHistoryList/WidgetListManager.h deleted file mode 100644 index 18c22b5..0000000 --- a/services/QuickAccess/UrlHistoryList/WidgetListManager.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed 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 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WIDGETLISTMANAGER_H_ -#define WIDGETLISTMANAGER_H_ - -#include -#include -#include "services/HistoryService/HistoryItem.h" - -namespace tizen_browser -{ -namespace services -{ - -/** - * Interface for classes managing list-like widgets. - * TODO: consider if it could be used in whole application, not only for URL - * list. - */ -class WidgetListManager -{ -public: - virtual ~WidgetListManager() - { - } - virtual Evas_Object* createWidget(Evas_Object* parentLayout) = 0; - virtual Evas_Object* getWidget() = 0; - virtual void hideWidget() = 0; - virtual void showWidget(const std::string& editedUrl, - std::shared_ptr matchedEntries) = 0; - virtual void onMouseClick() = 0; -}; - -} /* namespace services */ -} /* namespace tizen_browser */ - -#endif /* WIDGETLISTMANAGER_H_ */ diff --git a/services/QuickAccess/edc/QuickAccess.edc b/services/QuickAccess/edc/QuickAccess.edc index c87299b..ef1881b 100644 --- a/services/QuickAccess/edc/QuickAccess.edc +++ b/services/QuickAccess/edc/QuickAccess.edc @@ -20,6 +20,11 @@ collections { #define ITEM_WIDTH 374 #define PARENT_ITEM_HEIGHT 36 +#define URI_INPUTBOX_LENGTH 1720 +#define URL_HISTORY_ITEM_H 82 +#define URL_HISTORY_ITEMS_VISIBLE_MAX 5 +#define URL_HISTORY_LIST_MAX_H HISTORY_ITEM_H*HISTORY_ITEMS_VISIBLE_MAX + group{ name: "elm/button/base/invisible_button"; parts{ @@ -1383,6 +1388,33 @@ group { name: "top_button_item"; } } +group { + name: "url_history_list_layout"; + parts + { + part + { + name: "url_history_list_swallow"; + type: SWALLOW; + description { + state: "default" 0.0; + min: URI_INPUTBOX_LENGTH URL_HISTORY_LIST_MAX_H; + max: -1 -1; + align: 0.0 0.0; + fixed: 1 1; + visible: 1; + rel1 { + relative: 0 0; + offset: 10 106; + } + rel2 { + relative: 1.0 1.0; + } + } + } + } +} + group { name: "bottom_button_item"; min: 1920 181; max: 1920 181; diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index 084de51..8697e7e 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -46,6 +46,7 @@ #include "boost/date_time/posix_time/posix_time.hpp" #include "SqlStorage.h" #include "DetailPopup.h" +#include "UrlHistoryList/UrlHistoryList.h" #include "NotificationPopup.h" @@ -236,6 +237,8 @@ void SimpleUI::connectUISignals() M_ASSERT(m_webPageUI.get()); m_webPageUI->getURIEntry().uriChanged.connect(boost::bind(&SimpleUI::filterURL, this, _1)); + m_webPageUI->getURIEntry().uriEntryEditingChangedByUser.connect(boost::bind(&SimpleUI::onURLEntryEditedByUser, this, _1)); + m_webPageUI->getURIEntry().uriEntryEditingChanged.connect(boost::bind(&SimpleUI::onURLEntryEdited, this)); m_webPageUI->backPage.connect(boost::bind(&SimpleUI::switchViewToWebPage, this)); m_webPageUI->backPage.connect(boost::bind(&tizen_browser::basic_webengine::AbstractWebEngine::back, m_webEngine.get())); m_webPageUI->reloadPage.connect(boost::bind(&SimpleUI::switchViewToWebPage, this)); @@ -251,6 +254,7 @@ void SimpleUI::connectUISignals() M_ASSERT(m_quickAccess.get()); m_quickAccess->getDetailPopup().openURLInNewTab.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this, _1, _2)); + m_quickAccess->getUrlHistoryList()->openURLInNewTab.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this, _1, _2)); m_quickAccess->openURLInNewTab.connect(boost::bind(&SimpleUI::onOpenURLInNewTab, this, _1, _2)); m_quickAccess->mostVisitedTileClicked.connect(boost::bind(&SimpleUI::onMostVisitedTileClicked, this, _1, _2)); m_quickAccess->mostVisitedClicked.connect(boost::bind(&SimpleUI::onMostVisitedClicked, this)); @@ -409,6 +413,8 @@ void SimpleUI::connectModelSignals() m_platformInputManager->returnPressed.connect(boost::bind(&elm_exit)); m_platformInputManager->backPressed.connect(boost::bind(&SimpleUI::onBackPressed, this)); + m_platformInputManager->mouseClicked.connect( + boost::bind(&SimpleUI::onMouseClick, this)); } @@ -688,6 +694,29 @@ void SimpleUI::filterURL(const std::string& url) m_webPageUI->getURIEntry().clearFocus(); } +void SimpleUI::onURLEntryEditedByUser(const std::shared_ptr editedUrlPtr) +{ + string editedUrl(*editedUrlPtr); + int historyItemsVisibleMax = + m_quickAccess->getUrlHistoryList()->getVisibleItemsMax(); + int minKeywordLength = + m_quickAccess->getUrlHistoryList()->getMinKeywordLength(); + std::shared_ptr result = + m_historyService->getHistoryItemsByKeywordsString(editedUrl, + historyItemsVisibleMax, minKeywordLength); + m_quickAccess->getUrlHistoryList()->onURLEntryEditedByUser(editedUrl, result); +} + +void SimpleUI::onURLEntryEdited() +{ + m_quickAccess->getUrlHistoryList()->onURLEntryEdited(); +} + +void SimpleUI::onMouseClick() +{ + m_quickAccess->getUrlHistoryList()->onMouseClick(); +} + void SimpleUI::webEngineURLChanged(const std::string url) { BROWSER_LOGD("webEngineURLChanged:%s", url.c_str()); diff --git a/services/SimpleUI/SimpleUI.h b/services/SimpleUI/SimpleUI.h index 5e4ecd4..f4d41b1 100644 --- a/services/SimpleUI/SimpleUI.h +++ b/services/SimpleUI/SimpleUI.h @@ -139,6 +139,7 @@ private: void authPopupButtonClicked(PopupButtons button, std::shared_ptr popupData); void onActionTriggered(const Action& action); + void onMouseClick(); void setwvIMEStatus(bool status); sharedAction m_showBookmarkManagerUI; @@ -153,6 +154,11 @@ private: */ void filterURL(const std::string& url); + // // on uri entry widget "changed,user" signal + void onURLEntryEditedByUser(const std::shared_ptr editedUrlPtr); + // on uri entry widget "changed" signal + void onURLEntryEdited(); + /** * Checks if correct tab is visible to user, and if not, it update browser view * @param id of tab that should be visible to user diff --git a/services/WebPageUI/URIEntry.cpp b/services/WebPageUI/URIEntry.cpp index 39bdbb2..9200abb 100644 --- a/services/WebPageUI/URIEntry.cpp +++ b/services/WebPageUI/URIEntry.cpp @@ -80,11 +80,12 @@ Evas_Object* URIEntry::getContent() evas_object_smart_callback_add(m_entry, "activated", URIEntry::activated, this); evas_object_smart_callback_add(m_entry, "aborted", URIEntry::aborted, this); evas_object_smart_callback_add(m_entry, "preedit,changed", URIEntry::preeditChange, this); - evas_object_smart_callback_add(m_entry, "changed,user", URIEntry::changedUser, this); + evas_object_smart_callback_add(m_entry, "changed", URIEntry::_uri_entry_editing_changed, this); + evas_object_smart_callback_add(m_entry, "changed,user", URIEntry::_uri_entry_editing_changed_user, this); evas_object_smart_callback_add(m_entry, "focused", URIEntry::focused, this); evas_object_smart_callback_add(m_entry, "unfocused", URIEntry::unfocused, this); - evas_object_smart_callback_add(m_entry, "clicked", _uriEntryClicked, this); - evas_object_event_callback_priority_add(m_entry, EVAS_CALLBACK_KEY_DOWN, 2 * EVAS_CALLBACK_PRIORITY_BEFORE, URIEntry::fixed_entry_key_down_handler, this); + evas_object_smart_callback_add(m_entry, "clicked", _uri_entry_clicked, this); + evas_object_event_callback_priority_add(m_entry, EVAS_CALLBACK_KEY_DOWN, 2 * EVAS_CALLBACK_PRIORITY_BEFORE, URIEntry::_fixed_entry_key_down_handler, this); elm_object_part_content_set(m_entry_layout, "uri_entry_swallow", m_entry); @@ -94,7 +95,7 @@ Evas_Object* URIEntry::getContent() evas_object_smart_callback_add(m_entryBtn, "unfocused", URIEntry::unfocusedBtn, this); elm_object_style_set(m_entryBtn, "entry_btn"); - evas_object_smart_callback_add(m_entryBtn, "clicked", _uriEntryBtnClicked, this); + evas_object_smart_callback_add(m_entryBtn, "clicked", _uri_entry_btn_clicked, this); elm_object_part_content_set(m_entry_layout, "uri_entry_btn", m_entryBtn); } @@ -182,14 +183,13 @@ void URIEntry::selectWholeText() } } -void URIEntry::_uriEntryClicked(void* data, Evas_Object* /* obj */, void* /* event_info */) +void URIEntry::_uri_entry_clicked(void* data, Evas_Object* /* obj */, void* /* event_info */) { - BROWSER_LOGD("%s", __func__); URIEntry* self = static_cast(data); self->selectWholeText(); } -void URIEntry::_uriEntryBtnClicked(void* data, Evas_Object* /*obj*/, void* /*event_info*/) +void URIEntry::_uri_entry_btn_clicked(void* data, Evas_Object* /*obj*/, void* /*event_info*/) { URIEntry* self = static_cast(data); elm_object_focus_set(self->m_entry, EINA_TRUE); @@ -215,7 +215,7 @@ void URIEntry::preeditChange(void* /* data */, Evas_Object* /* obj */, void* /*e BROWSER_LOGD("%s", __func__); } -void URIEntry::changedUser(void* data, Evas_Object* /* obj */, void* /*event_info*/) +void URIEntry::_uri_entry_editing_changed_user(void* data, Evas_Object* /* obj */, void* /*event_info*/) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); URIEntry* self = reinterpret_cast(data); @@ -227,6 +227,13 @@ void URIEntry::changedUser(void* data, Evas_Object* /* obj */, void* /*event_inf } else {//if(entry.find(" ") != std::string::npos){ self->setSearchIcon(); } + self->uriEntryEditingChangedByUser(std::make_shared(entry)); +} + +void URIEntry::_uri_entry_editing_changed(void* data, Evas_Object* /* obj */, void* /* event_info */) +{ + URIEntry* self = static_cast(data); + self->uriEntryEditingChanged(); } void URIEntry::setUrlGuideText(const char* txt) const @@ -257,7 +264,7 @@ void URIEntry::focused(void* data, Evas_Object* /* obj */, void* /* event_info * BROWSER_LOGD("%s, URI: %s", __func__, self->m_URI.c_str()); } -void URIEntry::fixed_entry_key_down_handler(void* data, Evas* /*e*/, Evas_Object* /*obj*/, void* event_info) +void URIEntry::_fixed_entry_key_down_handler(void* data, Evas* /*e*/, Evas_Object* /*obj*/, void* event_info) { BROWSER_LOGD("%s", __func__); Evas_Event_Key_Down* ev = static_cast(event_info); @@ -284,8 +291,6 @@ void URIEntry::fixed_entry_key_down_handler(void* data, Evas* /*e*/, Evas_Object void URIEntry::editingCompleted() { - BROWSER_LOGD("%s", __func__); - char* text = elm_entry_markup_to_utf8(elm_entry_entry_get(m_entry)); std::string userString(text); free(text); diff --git a/services/WebPageUI/URIEntry.h b/services/WebPageUI/URIEntry.h index 20b1774..c23a0c4 100644 --- a/services/WebPageUI/URIEntry.h +++ b/services/WebPageUI/URIEntry.h @@ -45,6 +45,11 @@ public: void changeUri(const std::string&); boost::signals2::signal uriChanged; + // uri edition change + boost::signals2::signal uriEntryEditingChanged; + // uri edition change (by a user) + boost::signals2::signal)> uriEntryEditingChangedByUser; + void setFavIcon(std::shared_ptr favicon); void setCurrentFavIcon(); void setSearchIcon(); @@ -87,11 +92,8 @@ private: static void activated(void* data, Evas_Object* obj, void* event_info); static void aborted(void* data, Evas_Object* obj, void* event_info); static void preeditChange(void* data, Evas_Object* obj, void* event_info); - static void changedUser(void* data, Evas_Object* obj, void* event_info); static void focused(void* data, Evas_Object* obj, void* event_info); static void unfocused(void* data, Evas_Object* obj, void* event_info); - static void fixed_entry_key_down_handler(void* data, Evas* e, Evas_Object* obj, void* event_info); - static void _uriEntryBtnClicked(void* data, Evas_Object* obj, void* event_info); void editingCompleted(); void selectWholeText(); @@ -102,7 +104,11 @@ private: */ std::string rewriteURI(const std::string& url); - static void _uriEntryClicked(void* data, Evas_Object* obj, void* event_info); + static void _fixed_entry_key_down_handler(void* data, Evas* e, Evas_Object* obj, void* event_info); + static void _uri_entry_btn_clicked(void* data, Evas_Object* obj, void* event_info); + static void _uri_entry_clicked(void* data, Evas_Object* obj, void* event_info); + static void _uri_entry_editing_changed(void* data, Evas_Object* obj, void* event_info); + static void _uri_entry_editing_changed_user(void* data, Evas_Object* obj, void* event_info); static void focusedBtn(void* data, Evas_Object* obj, void* event_info); static void unfocusedBtn(void* data, Evas_Object* obj, void* event_info); -- 2.7.4