#include "InputPopup.h"
+#include "Tools/EflTools.h"
namespace tizen_browser {
namespace base_ui {
InputPopup::InputPopup() :
m_parent(nullptr),
- m_layout(nullptr),
- m_buttons_box(nullptr),
+ m_popup(nullptr),
+ m_icon(nullptr),
m_button_left(nullptr),
m_button_right(nullptr),
- m_input_area(nullptr),
- m_input_cancel(nullptr),
m_entry(nullptr),
- m_accept_right_left(true)
+ m_box(nullptr),
+ m_label(nullptr)
{
m_edjFilePath = EDJE_DIR;
m_edjFilePath.append("SimpleUI/InputPopup.edj");
InputPopup::~InputPopup()
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
- evas_object_smart_callback_del(m_entry, "focused", _entry_focused);
- evas_object_smart_callback_del(m_entry, "unfocused", _entry_unfocused);
- evas_object_smart_callback_del(m_entry, "changed,user", _entry_changed);
- evas_object_smart_callback_del(m_input_cancel, "clicked", _input_cancel_clicked);
- evas_object_smart_callback_del(m_button_right, "clicked", _right_button_clicked);
- evas_object_smart_callback_del(m_button_left, "clicked", _left_button_clicked);
- evas_object_del(m_input_cancel);
- evas_object_del(m_entry);
- evas_object_del(m_input_area);
- evas_object_del(m_button_right);
- evas_object_del(m_button_left);
- evas_object_del(m_buttons_box);
- evas_object_del(m_layout);
+
+ if (m_icon) {
+ evas_object_smart_callback_del(m_icon, "clicked", _input_cancel_clicked);
+ evas_object_del(m_icon);
+ }
+ if (m_entry) {
+ evas_object_smart_callback_del(m_entry, "changed,user", _entry_changed);
+ evas_object_del(m_entry);
+ }
+ if (m_button_right) {
+ evas_object_smart_callback_del(m_button_right, "clicked", _right_button_clicked);
+ evas_object_del(m_button_right);
+ }
+ if (m_button_left) {
+ evas_object_smart_callback_del(m_button_left, "clicked", _left_button_clicked);
+ evas_object_del(m_button_left);
+ }
+ if (m_label)
+ evas_object_del(m_label);
+ if (m_box)
+ evas_object_del(m_box);
+ if (m_popup)
+ evas_object_del(m_popup);
+
button_clicked.disconnect_all_slots();
popupDismissed.disconnect_all_slots();
popupShown.disconnect_all_slots();
InputPopup* InputPopup::createPopup(Evas_Object* parent)
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
- InputPopup *inputPopup = new InputPopup();
+ auto inputPopup = new InputPopup();
inputPopup->m_parent = parent;
return inputPopup;
}
-InputPopup* InputPopup::createPopup(Evas_Object *parent, const std::string& title, const std::string& message, const std::string& input,
- const std::string& rightButtonText, const std::string& leftButtonText, bool accept_right_left)
+InputPopup* InputPopup::createPopup(
+ Evas_Object *parent,
+ const std::string& title,
+ const std::string& message,
+ const std::string& input,
+ const std::string& rightButtonText,
+ const std::string& leftButtonText)
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
- InputPopup *inputPopup = new InputPopup();
+ auto inputPopup = new InputPopup();
inputPopup->m_parent = parent;
inputPopup->m_title = title;
inputPopup->m_message = message;
inputPopup->m_input = input;
inputPopup->m_ok_button_text = rightButtonText;
inputPopup->m_cancel_button_text = leftButtonText;
- inputPopup->m_accept_right_left = accept_right_left;
return inputPopup;
}
m_cancel_button_text = cancelButtonText;
}
-void InputPopup::setAcceptRightLeft(bool right_left)
-{
- m_accept_right_left = right_left;
-}
-
void InputPopup::addBadWord(const std::string &word)
{
m_bad_words.push_back(word);
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
createLayout();
popupShown(this);
+
+ elm_object_disabled_set(
+ m_button_right,
+ std::find(
+ m_bad_words.begin(),
+ m_bad_words.end(),
+ elm_entry_utf8_to_markup(m_input.c_str())) != m_bad_words.end());
}
void InputPopup::dismiss()
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
- m_layout = elm_layout_add(m_parent);
- elm_layout_file_set(m_layout, m_edjFilePath.c_str(), "input-popup-layout");
- evas_object_size_hint_weight_set(m_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(m_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_object_part_text_set(m_layout, "title_text", m_title.c_str());
-
- m_input_area = elm_layout_add(m_layout);
- elm_object_part_content_set(m_layout, "input_swallow", m_input_area);
-
- evas_object_size_hint_weight_set(m_input_area, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(m_input_area, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_show(m_input_area);
-
- elm_layout_file_set(m_input_area, m_edjFilePath.c_str(), "input-area-layout");
- elm_object_part_text_set(m_input_area, "input_message_text", m_message.c_str());
-
- m_entry = elm_entry_add(m_input_area);
- elm_object_style_set(m_entry, "popup-input-entry");
+ m_popup = elm_popup_add(m_parent);
+ elm_popup_align_set(m_popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
+ evas_object_size_hint_weight_set(m_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+ elm_object_translatable_part_text_set(m_popup, "default", m_message.c_str());
+ elm_object_translatable_part_text_set(m_popup, "title,text", m_title.c_str());
+
+ m_box = elm_box_add(m_popup);
+ tools::EflTools::setExpandHints(m_box);
+ elm_object_content_set(m_popup, m_box);
+
+ if (!m_message.empty()) {
+ m_label = elm_entry_add(m_box);
+ elm_entry_editable_set(m_label, EINA_FALSE);
+ elm_entry_single_line_set(m_label, EINA_TRUE);
+ elm_entry_scrollable_set(m_label, EINA_FALSE);
+ elm_entry_input_panel_layout_set(m_entry, ELM_INPUT_PANEL_LAYOUT_NORMAL);
+ elm_object_text_set(m_label, elm_entry_utf8_to_markup(m_message.c_str()));
+ elm_box_pack_end(m_box, m_label);
+ evas_object_show(m_label);
+ }
+ m_entry = elm_entry_add(m_box);
+ tools::EflTools::setExpandHints(m_entry);
elm_entry_single_line_set(m_entry, EINA_TRUE);
elm_entry_scrollable_set(m_entry, EINA_TRUE);
- elm_entry_input_panel_layout_set(m_entry, ELM_INPUT_PANEL_LAYOUT_URL);
- elm_object_part_content_set(m_input_area, "input_text_swallow", m_entry);
+ elm_entry_input_panel_layout_set(m_entry, ELM_INPUT_PANEL_LAYOUT_NORMAL);
+ elm_box_pack_end(m_box, m_entry);
+
+ m_icon = elm_icon_add(m_entry);
+ elm_icon_standard_set(m_icon, "close");
+ evas_object_size_hint_min_set(
+ m_icon,
+ ELM_SCALE_SIZE(40),
+ ELM_SCALE_SIZE(40));
+ evas_object_size_hint_max_set(
+ m_icon,
+ ELM_SCALE_SIZE(40),
+ ELM_SCALE_SIZE(40));
+ elm_object_part_content_set(m_entry, "end", m_icon);
+
elm_object_part_text_set(m_entry, "elm.text", elm_entry_utf8_to_markup(m_input.c_str()));
elm_object_part_text_set(m_entry, "elm.guide", elm_entry_utf8_to_markup(m_tip.c_str()));
- evas_object_smart_callback_add(m_entry, "focused", _entry_focused, (void*)this);
- evas_object_smart_callback_add(m_entry, "unfocused", _entry_unfocused, (void*)this);
- evas_object_smart_callback_add(m_entry, "changed,user", _entry_changed, (void*)this);
-
- m_input_cancel = elm_button_add(m_input_area);
- elm_object_style_set(m_input_cancel, "invisible_button");
- evas_object_smart_callback_add(m_input_cancel, "clicked", _input_cancel_clicked, this);
+ m_button_left = elm_button_add(m_popup);
+ tools::EflTools::setExpandHints(m_button_left);
+ elm_object_text_set(m_button_left, m_cancel_button_text.c_str());
+ elm_object_part_content_set(m_popup, "button1", m_button_left);
- evas_object_show(m_input_cancel);
- elm_object_part_content_set(m_input_area, "input_cancel_click", m_input_cancel);
+ m_button_right = elm_button_add(m_popup);
+ tools::EflTools::setExpandHints(m_button_right);
+ elm_object_text_set(m_button_right, m_ok_button_text.c_str());
+ elm_object_part_content_set(m_popup, "button2", m_button_right);
- m_buttons_box = elm_box_add(m_layout);
- elm_box_horizontal_set(m_buttons_box, EINA_TRUE);
- evas_object_size_hint_weight_set(m_buttons_box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(m_buttons_box, EVAS_HINT_FILL, EVAS_HINT_FILL);
-
- m_button_left = elm_button_add(m_buttons_box);
- elm_object_style_set(m_button_left, "input-popup-button");
- evas_object_size_hint_weight_set(m_button_left, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(m_button_left, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_object_part_text_set(m_button_left, "elm.text", m_cancel_button_text.c_str());
- elm_box_pack_end(m_buttons_box, m_button_left);
- evas_object_smart_callback_add(m_button_left, "clicked", _left_button_clicked, (void*)this);
+ evas_object_smart_callback_add(m_entry, "changed,user", _entry_changed, this);
+ evas_object_smart_callback_add(m_icon, "clicked", _input_cancel_clicked, this);
+ evas_object_smart_callback_add(m_button_left, "clicked", _left_button_clicked, this);
+ evas_object_smart_callback_add(m_button_right, "clicked", _right_button_clicked, this);
+ evas_object_show(m_box);
+ evas_object_show(m_icon);
+ evas_object_show(m_entry);
evas_object_show(m_button_left);
-
- m_button_right = elm_button_add(m_buttons_box);
- elm_object_style_set(m_button_right, "input-popup-button");
- evas_object_size_hint_weight_set(m_button_right, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(m_button_right, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_object_part_text_set(m_button_right, "elm.text", m_ok_button_text.c_str());
- elm_box_pack_end(m_buttons_box, m_button_right);
- evas_object_smart_callback_add(m_button_right, "clicked", _right_button_clicked, (void*)this);
-
evas_object_show(m_button_right);
- elm_object_signal_emit(m_button_right, "visible", "ui");
-
- evas_object_show(m_buttons_box);
- elm_object_part_content_set(m_layout, "buttons_swallow", m_buttons_box);
-
- evas_object_show(m_layout);
- elm_object_part_content_set(m_parent, "popup_content", m_layout);
-
- if (std::find(m_bad_words.begin(), m_bad_words.end(), m_input) != m_bad_words.end()) {
- elm_object_disabled_set(m_accept_right_left ? m_button_right : m_button_left, EINA_TRUE);
- elm_object_signal_emit(m_accept_right_left ? m_button_right : m_button_left, "dissabled", "ui");
- }
-
- elm_object_signal_emit(m_input_area, "close_icon_show", "ui");
-}
-
-void InputPopup::_entry_focused(void* data, Evas_Object *, void *)
-{
- BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
- if (data != nullptr) {
- InputPopup* inputPopup = static_cast<InputPopup*>(data);
- elm_object_focus_allow_set(inputPopup->m_input_cancel, EINA_TRUE);
- elm_object_signal_emit(inputPopup->m_entry, "focused", "ui");
- }
-}
-
-void InputPopup::_entry_unfocused(void* data, Evas_Object *, void *)
-{
- BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
- if (data != nullptr) {
- InputPopup* inputPopup = static_cast<InputPopup*>(data);
- elm_object_focus_allow_set(inputPopup->m_input_cancel, EINA_FALSE);
- elm_object_signal_emit(inputPopup->m_entry, "unfocused", "ui");
- }
+ evas_object_show(m_popup);
}
void InputPopup::_entry_changed(void* data, Evas_Object *, void *)
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
- if (data != nullptr) {
- InputPopup* inputPopup = static_cast<InputPopup*>(data);
- std::string text = elm_entry_markup_to_utf8(elm_object_part_text_get(inputPopup->m_entry, "elm.text"));
-
- if (text.empty())
- elm_object_signal_emit(inputPopup->m_input_area, "close_icon_hide", "ui");
- else
- elm_object_signal_emit(inputPopup->m_input_area, "close_icon_show", "ui");
-
- if (std::find(inputPopup->m_bad_words.begin(), inputPopup->m_bad_words.end(), text)
- != inputPopup->m_bad_words.end()) {
- elm_object_disabled_set(inputPopup->m_accept_right_left ? inputPopup->m_button_right :
- inputPopup->m_button_left, EINA_TRUE);
- elm_object_signal_emit(inputPopup->m_accept_right_left ? inputPopup->m_button_right :
- inputPopup->m_button_left, "dissabled", "ui");
- } else {
- elm_object_disabled_set(inputPopup->m_accept_right_left ? inputPopup->m_button_right :
- inputPopup->m_button_left, EINA_FALSE);
- elm_object_signal_emit(inputPopup->m_accept_right_left ? inputPopup->m_button_right :
- inputPopup->m_button_left, "enabled", "ui");
- }
- }
+ if (data) {
+ auto inputPopup = static_cast<InputPopup*>(data);
+ std::string text =
+ elm_entry_markup_to_utf8(
+ elm_object_part_text_get(inputPopup->m_entry, "elm.text"));
+
+ elm_object_disabled_set(
+ inputPopup->m_button_right,
+ std::find(
+ inputPopup->m_bad_words.begin(),
+ inputPopup->m_bad_words.end(),
+ text) != inputPopup->m_bad_words.end());
+ } else
+ BROWSER_LOGD("data is null ");
}
-void InputPopup::_input_cancel_clicked(void * data, Evas_Object *, void *)
+void InputPopup::_input_cancel_clicked(void* data, Evas_Object*, void *)
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
- if (data != nullptr) {
- InputPopup* inputPopup = static_cast<InputPopup*>(data);
+ if (data) {
+ auto inputPopup = static_cast<InputPopup*>(data);
elm_object_part_text_set(inputPopup->m_entry, "elm.text", "");
- elm_object_disabled_set(inputPopup->m_accept_right_left ? inputPopup->m_button_right :
- inputPopup->m_button_left, EINA_TRUE);
- elm_object_signal_emit(inputPopup->m_accept_right_left ? inputPopup->m_button_right :
- inputPopup->m_button_left, "dissabled", "ui");
- elm_object_signal_emit(inputPopup->m_input_area, "close_icon_hide", "ui");
- }
+ elm_object_disabled_set(inputPopup->m_button_right, EINA_TRUE);
+ } else
+ BROWSER_LOGD("data is null ");
}
void InputPopup::_right_button_clicked(void *data, Evas_Object *, void*)
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
- InputPopup *inputPopup = static_cast<InputPopup*>(data);
- if (inputPopup->m_accept_right_left)
- inputPopup->button_clicked(elm_entry_markup_to_utf8(elm_object_part_text_get(inputPopup->m_entry, "elm.text")));
- inputPopup->dismiss();
+ if (data) {
+ auto inputPopup = static_cast<InputPopup*>(data);
+ inputPopup->button_clicked(
+ elm_entry_markup_to_utf8(
+ elm_object_part_text_get(inputPopup->m_entry, "elm.text")));
+ inputPopup->dismiss();
+ } else
+ BROWSER_LOGD("data is null ");
}
void InputPopup::_left_button_clicked(void* data, Evas_Object *, void*)
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
- InputPopup *inputPopup = static_cast<InputPopup*>(data);
- if (!inputPopup->m_accept_right_left)
- inputPopup->button_clicked(elm_entry_markup_to_utf8(elm_object_part_text_get(inputPopup->m_entry, "elm.text")));
- inputPopup->dismiss();
+ if (data) {
+ auto inputPopup = static_cast<InputPopup*>(data);
+ inputPopup->dismiss();
+ } else
+ BROWSER_LOGD("data is null ");
}
}
}
}
-void SimpleUI::onBookmarkEdit(std::shared_ptr<tizen_browser::services::BookmarkItem> bookmarkItem)
+void SimpleUI::onBookmarkEdit(std::shared_ptr<services::BookmarkItem> bookmarkItem)
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
if (bookmarkItem->is_folder()) {
- InputPopup *inputPopup = InputPopup::createPopup(m_viewManager.getContent(), "Edit Folder name",
- "Edit folder name?", bookmarkItem->getTitle(), _("IDS_BR_SK_DONE"), _("IDS_BR_SK_CANCEL_ABB"), true);
- services::SharedBookmarkItemList badWords = m_favoriteService->getFolders(bookmarkItem->getParent());
+ InputPopup *inputPopup =
+ InputPopup::createPopup(
+ m_viewManager.getContent(),
+ "Edit Folder name",
+ "Edit folder name?",
+ bookmarkItem->getTitle(),
+ _("IDS_BR_SK_DONE"),
+ _("IDS_BR_SK_CANCEL_ABB"));
+ services::SharedBookmarkItemList badWords =
+ m_favoriteService->getFolders(bookmarkItem->getParent());
for (auto it = badWords.begin(); it != badWords.end(); ++it)
inputPopup->addBadWord((*it)->getTitle());
inputPopup->button_clicked.connect(boost::bind(&SimpleUI::onEditFolderPopupClicked, this, _1, bookmarkItem));
void SimpleUI::onNewFolderClicked(int parent)
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
- InputPopup *inputPopup = InputPopup::createPopup(m_viewManager.getContent(), "New Folder", "Add New Folder?",
- "New Folder #", _("IDS_BR_OPT_ADD"), _("IDS_BR_SK_CANCEL_ABB"), true);
+ InputPopup *inputPopup =
+ InputPopup::createPopup(
+ m_viewManager.getContent(),
+ "New Folder",
+ "Add New Folder?",
+ "New Folder #",
+ _("IDS_BR_OPT_ADD"),
+ _("IDS_BR_SK_CANCEL_ABB"));
services::SharedBookmarkItemList badWords = m_favoriteService->getFolders(parent);
for (auto it = badWords.begin(); it != badWords.end(); ++it)
inputPopup->addBadWord((*it)->getTitle());
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
//TODO: Implement it right with a correct functionality.
- InputPopup *inputPopup = InputPopup::createPopup(m_viewManager.getContent(), "Add to Quick access", "",
- "Enter web address", _("IDS_BR_OPT_ADD"), _("IDS_BR_SK_CANCEL_ABB"), true);
+ auto inputPopup = InputPopup::createPopup(
+ m_viewManager.getContent(),
+ "Add to Quick access",
+ "",
+ "",
+ _("IDS_BR_OPT_ADD"),
+ _("IDS_BR_SK_CANCEL_ABB"));
+ // TODO Add missing translations
+ inputPopup->setTip(_("Enter web address"));
inputPopup->button_clicked.connect(boost::bind(&SimpleUI::addQuickAccessItem, this, _1)); //TODO: connect new function
inputPopup->popupShown.connect(boost::bind(&SimpleUI::showPopup, this, _1)); //TODO: connect new function
inputPopup->popupDismissed.connect(boost::bind(&SimpleUI::dismissPopup, this, _1)); //TODO: connect new function
void SimpleUI::selectSettingsOtherPageChange()
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
- InputPopup* popup = InputPopup::createPopup(m_viewManager.getContent());
+ auto popup = InputPopup::createPopup(m_viewManager.getContent());
popup->setTitle(_("IDS_BR_MBODY_SET_HOMEPAGE"));
- popup->setAcceptRightLeft(true);
popup->setCancelButtonText(_("IDS_BR_BUTTON_CANCEL"));
popup->setOkButtonText(_("IDS_BR_BUTTON_SET"));
popup->setTip(_("IDS_BR_BODY_WEB_ADDRESS"));
}
}
if (isSelected) {
- TextPopup* popup = TextPopup::createPopup(m_viewManager.getContent());
- popup->addButton(OK);
- popup->addButton(CANCEL);
- popup->buttonClicked.connect(boost::bind(&SimpleUI::onDeleteSelectedDataButton, this, _1, options));
- popup->setTitle("Delete");
- popup->setMessage("The selected web browsing data will be deleted.");
- popup->popupShown.connect(boost::bind(&SimpleUI::showPopup, this, _1));
- popup->popupDismissed.connect(boost::bind(&SimpleUI::dismissPopup, this, _1));
- popup->show();
+ TextPopup* popup = TextPopup::createPopup(m_viewManager.getContent());
+ popup->addButton(OK);
+ popup->addButton(CANCEL);
+ popup->buttonClicked.connect(boost::bind(&SimpleUI::onDeleteSelectedDataButton, this, _1, options));
+ popup->setTitle("Delete");
+ popup->setMessage("The selected web browsing data will be deleted.");
+ popup->popupShown.connect(boost::bind(&SimpleUI::showPopup, this, _1));
+ popup->popupDismissed.connect(boost::bind(&SimpleUI::dismissPopup, this, _1));
+ popup->show();
}
}
}
if (userAgent.empty()) {
- InputPopup *inputPopup = InputPopup::createPopup(
+ auto inputPopup = InputPopup::createPopup(
m_viewManager.getContent(),
"Override UserAgent", "",
"",
_("IDS_BR_SK_DONE"),
- _("IDS_BR_SK_CANCEL_ABB"),
- true);
+ _("IDS_BR_SK_CANCEL_ABB"));
inputPopup->button_clicked.connect(
boost::bind(&SimpleUI::onOverrideUseragentButton, this, _1));
inputPopup->popupShown.connect(
#include "TextPopup_mob.h"
#include "ServiceManager.h"
#include "AbstractMainWindow.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include "Tools/EflTools.h"
namespace tizen_browser
{
{
TextPopup* TextPopup::createPopup(Evas_Object* parent)
{
- TextPopup *raw_popup = new TextPopup(parent);
+ auto raw_popup = new TextPopup(parent);
return raw_popup;
}
-TextPopup* TextPopup::createPopup(Evas_Object* parent,
- const std::string& title,
- const std::string& message)
+TextPopup* TextPopup::createPopup(
+ Evas_Object* parent,
+ const std::string& title,
+ const std::string& message)
{
- TextPopup *raw_popup = new TextPopup(parent, title, message);
+ auto raw_popup = new TextPopup(parent, title, message);
return raw_popup;
}
TextPopup::~TextPopup()
{
buttonClicked.disconnect_all_slots();
- evas_object_del(m_layout);
+ for (auto& button : m_buttons) {
+ evas_object_smart_callback_del(button.m_evasObject, "clicked", _response_cb);
+ evas_object_del(button.m_evasObject);
+ }
+ evas_object_del(m_popup);
}
TextPopup::TextPopup(Evas_Object* parent)
: m_parent(parent)
- , m_layout(nullptr)
- , m_buttons_box(nullptr)
+ , m_popup(nullptr)
{
m_edjFilePath = EDJE_DIR;
m_edjFilePath.append("SimpleUI/TextPopup.edj");
elm_theme_extension_add(nullptr, m_edjFilePath.c_str());
}
-TextPopup::TextPopup(Evas_Object* parent,
- const std::string& title,
- const std::string& message)
+TextPopup::TextPopup(
+ Evas_Object* parent,
+ const std::string& title,
+ const std::string& message)
: m_parent(parent)
- , m_layout(nullptr)
- , m_buttons_box(nullptr)
+ , m_popup(nullptr)
, m_title(title)
, m_message(message)
{
popupShown(this);
}
-void TextPopup::dismiss(){
+void TextPopup::dismiss()
+{
popupDismissed(this);
}
-void TextPopup::onBackPressed(){
+void TextPopup::onBackPressed()
+{
if (m_defaultBackButton != NONE)
buttonClicked(m_defaultBackButton);
dismiss();
}
-void TextPopup::_response_cb(void* data,
- Evas_Object* obj,
- void* /*event_info*/)
+void TextPopup::_response_cb(
+ void* data,
+ Evas_Object* obj,
+ void*)
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
- auto self = static_cast<TextPopup*>(data);
- auto it = std::find_if(self->m_buttons.begin(),
- self->m_buttons.end(),
- [obj] (const Button& i)
- { return i.m_evasObject == obj; }
- );
-
- if (it == self->m_buttons.end()) {
- BROWSER_LOGW("[%s:%d] Button not found!", __PRETTY_FUNCTION__, __LINE__);
- } else {
- self->buttonClicked(it->m_type);
- }
- if (it->m_dismissOnClick)
- self->dismiss();
+ if (data) {
+ auto self = static_cast<TextPopup*>(data);
+ auto it = std::find_if(
+ self->m_buttons.begin(),
+ self->m_buttons.end(),
+ [obj] (const Button& i) {
+ return i.m_evasObject == obj;
+ });
+
+ (it == self->m_buttons.end()) ?
+ BROWSER_LOGW("[%s:%d] Button not found!", __PRETTY_FUNCTION__, __LINE__) :
+ self->buttonClicked(it->m_type);
+
+ if (it->m_dismissOnClick)
+ self->dismiss();
+ } else
+ BROWSER_LOGD("data is null ");
}
void TextPopup::setTitle(const std::string& title)
{
- this->m_title = title;
+ m_title = title;
}
void TextPopup::setMessage(const std::string& message)
{
- this->m_message = message;
+ m_message = message;
}
void TextPopup::setContent(Evas_Object* content)
{
- elm_object_part_content_set(m_layout, "content_swallow", content);
+ elm_object_content_set(m_popup, content);
}
-void TextPopup::addButton(const PopupButtons& button, bool dismissOnClick, bool defaultBackButton)
+void TextPopup::addButton(
+ const PopupButtons& button,
+ bool dismissOnClick,
+ bool defaultBackButton)
{
m_buttons.push_back(Button(button, dismissOnClick));
if (defaultBackButton)
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
M_ASSERT(m_parent);
- m_layout = elm_layout_add(m_parent);
- elm_object_tree_focus_allow_set(m_layout, EINA_FALSE);
- elm_layout_file_set(m_layout, m_edjFilePath.c_str(), "text_popup_layout");
- evas_object_size_hint_weight_set(m_layout, EVAS_HINT_EXPAND, 0);
- evas_object_size_hint_align_set(m_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ m_popup = elm_popup_add(m_parent);
+ elm_popup_align_set(m_popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
+ evas_object_size_hint_weight_set(m_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_object_translatable_part_text_set(m_layout, "title_text", m_title.c_str());
- elm_object_translatable_text_set(m_layout, m_message.c_str());
+ elm_object_translatable_part_text_set(m_popup, "default", m_message.c_str());
+ elm_object_translatable_part_text_set(m_popup, "title,text", m_title.c_str());
- m_buttons_box = elm_box_add(m_layout);
- elm_box_horizontal_set(m_buttons_box, EINA_TRUE);
- evas_object_size_hint_weight_set(m_buttons_box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(m_buttons_box, EVAS_HINT_FILL, EVAS_HINT_FILL);
-
- for (size_t i=0; i < m_buttons.size(); ++i) {
- auto btn = elm_button_add(m_buttons_box);
- m_buttons[i].m_evasObject = btn;
- elm_object_style_set(btn, "text-popup-button");
- evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_object_part_text_set(btn, "elm.text", _(buttonsTranslations[m_buttons[i].m_type].c_str()));
- elm_box_pack_end(m_buttons_box, btn);
+ for (size_t i = 0; i < m_buttons.size(); ++i) {
+ auto buttonString = std::string("button") + std::to_string(i+1);
+ auto btn = elm_button_add(m_popup);
+ tools::EflTools::setExpandHints(btn);
+ elm_object_text_set(btn, _(buttonsTranslations[m_buttons[i].m_type].c_str()));
evas_object_smart_callback_add(btn, "clicked", _response_cb, (void*) this);
-
+ elm_object_part_content_set(m_popup, buttonString.c_str(), btn);
evas_object_show(btn);
- if (i > 0) // separator for more buttons than one
- elm_object_signal_emit(btn, "visible", "ui");
+ m_buttons[i].m_evasObject = btn;
}
-
- evas_object_show(m_buttons_box);
- elm_object_part_content_set(m_layout, "buttons_swallow", m_buttons_box);
-
- evas_object_show(m_layout);
- elm_object_part_content_set(m_parent, "popup_content", m_layout);
+ evas_object_show(m_popup);
}
}