TizenRefApp-8320 Update GUI of delete popup. 25/122825/1
authorDenis Dolzhenko <d.dolzhenko@samsung.com>
Mon, 3 Apr 2017 13:03:16 +0000 (16:03 +0300)
committerDenis Dolzhenko <d.dolzhenko@samsung.com>
Mon, 3 Apr 2017 13:03:16 +0000 (16:03 +0300)
+ Refact TText util.

Change-Id: Ibaa6186fe10799ba2e14121676fc17a6e653e16f
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
13 files changed:
src/Common/Controller/src/NaviFrameController.cpp
src/Common/Utils/inc/LangUtils.h
src/Common/View/inc/IconTextPopup.h
src/Common/View/inc/Popup.h
src/Common/View/inc/ToastPopup.h
src/Common/View/inc/View.h
src/Common/View/inc/ViewItem.h
src/Common/View/src/Entry.cpp
src/Common/View/src/IconTextPopup.cpp
src/Common/View/src/Popup.cpp
src/Common/View/src/ToastPopup.cpp
src/Conversation/Controller/src/ConvFrame.cpp
src/MsgThread/Controller/src/MsgThreadFrame.cpp

index a2aacf1ea6cc3ed0692cad6e5d4f99fe55b6ad38..c4822137bfa8f684ed0b3c7a40b606a0242dd722 100644 (file)
@@ -48,10 +48,7 @@ void NaviFrameController::pop(FrameController &frame)
     if (isLastFrame() || isEmpty())
         App::getInst().exit();
     else {
-        // TODO: Check this code.
-        bool isToastPopup = dynamic_cast<ToastPopup*>(App::getInst().getPopupManager().getTop()) != nullptr;
-        if (!isToastPopup)
-            App::getInst().getPopupManager().pop();
+        App::getInst().getPopupManager().pop(&frame);
         NaviFrameView::pop(frame);
     }
 }
index 275d38e87a6096ea6171b0e5d47f8b8679d1cbb0..bb2673f665b062507b962284f9b49d6af7949ad9 100644 (file)
@@ -31,17 +31,38 @@ namespace Msg
     // Translatable Text
     struct TText
     {
+        // Constructor for nullptr;
         TText(std::nullptr_t)
             : m_pDomain(nullptr)
             , m_pMsg(nullptr)
+            , m_IsTranslatable(false)
         {
         }
 
-        explicit TText(const char *stringId, const char *domainName)
+        // Constructor for translatable string;
+        TText(bool dummy, const char *stringId, const char *domainName)
             : m_pDomain(domainName)
             , m_pMsg(stringId)
+            , m_IsTranslatable(true)
         {
-        };
+        }
+
+        // Constructor for plain C string;
+        TText(const char *str)
+            : m_pDomain(nullptr)
+            , m_pMsg(str)
+            , m_IsTranslatable(false)
+        {
+        }
+
+        // Constructor for plain std::string;
+        TText(std::string str)
+            : m_pDomain(nullptr)
+            , m_Str(std::move(str))
+            , m_pMsg(m_Str.c_str())
+            , m_IsTranslatable(false)
+        {
+        }
 
         const char *getMsg() const
         {
@@ -53,12 +74,19 @@ namespace Msg
             return m_pDomain;
         }
 
+        bool isTranslatable() const
+        {
+            return  m_IsTranslatable;
+        }
+
     private:
         TText(TText&) = delete;
         TText operator =(TText&) = delete;
 
         const char *m_pDomain;
+        std::string m_Str;
         const char *m_pMsg;
+        bool m_IsTranslatable;
     };
 
     // dgettext
@@ -107,11 +135,11 @@ namespace Msg
         const char *m_pMsg;
     };
 
-    #define msgt(strId) TText(strId, MSG_DOMAIN)
+    #define msgt(strId) TText(true, strId, MSG_DOMAIN)
     #define msg(strId) DText(strId, MSG_DOMAIN)
     #define msgArgs(strId, ...) DText(0, strId, MSG_DOMAIN, __VA_ARGS__)
     #define sys(strId) DText(strId, SYS_DOMAIN)
-    #define syst(strId) TText(strId, SYS_DOMAIN)
+    #define syst(strId) TText(true, strId, SYS_DOMAIN)
     #define sysArgs(strId, ...) DText(0, strId, SYS_DOMAIN, __VA_ARGS__)
 }
 
index 070a59140175967b854c5ae22730384867b080d2..abe4491ed516e2057725054986f4de9e209e625b 100644 (file)
@@ -34,7 +34,7 @@ namespace Msg {
             IconTextPopup();
             virtual ~IconTextPopup();
 
-            void setText(const std::string &text);
+            void setText(const TText &text);
             void setIcon(IconType type);
 
         private:
index 5a4d4ea2ad6b63d31fe3e6f6af3b6231b8f29265..a007f1a159c8844867c9b5ecf088019679c5e31b 100644 (file)
@@ -29,15 +29,16 @@ namespace Msg {
 
         public:
             static void defaultButtonCb(Popup &popup, void *userData);
+            static const double defaultTimeOut;
 
         public:
             Popup();
             virtual ~Popup();
 
             void show(bool deferred = true);
-            void setTitle(const std::string &title);
             void setTitle(const TText &title);
-            void setTimeOut(double timeout);
+            void setTimeOut(double timeout = defaultTimeOut);
+            double getTimeOut() const;
 
             Evas_Object *addBottomButton(const TText &text, PopupButtonCb cb = defaultButtonCb, void *userData = nullptr);
             Evas_Object *addBottomButton(const char *iconName, PopupButtonCb cb = defaultButtonCb, void *userData = nullptr);
index eb51384e254df1063afa4ceef66462b0049838ce..28a8a5b1a8b0800e6629f4f1dfdaee0ac39019bd 100644 (file)
@@ -24,7 +24,7 @@ namespace Msg {
         : public Popup {
 
         public:
-            ToastPopup(double timeout = 2.0);
+            ToastPopup(double timeout = defaultTimeOut);
             virtual ~ToastPopup();
 
             void setIcon(const char *iconName);
@@ -32,7 +32,6 @@ namespace Msg {
             void setText(const std::string &text);
 
             static ToastPopup *toast(const TText &text, const char *iconName = nullptr);
-            static ToastPopup *toast(const std::string &text, const char *iconName = nullptr);
     };
 }
 
index 9d3ed31093af38dedf464fddef537cd7d9190d3f..07d32bb953ef75354e2bafeb3580b7dd602181b2 100644 (file)
@@ -254,20 +254,6 @@ namespace Msg
              */
             const char *getTextCStr(const char *part = nullptr) const;
 
-            /**
-             * @brief Sets text into specified part.
-             * @param[in] text a text to be set in specified part
-             * @param[in] part a part to get text from. If part is nullptr the default part is used.
-             */
-            void setText(const char *text, const char *part = nullptr);
-
-            /**
-             * @brief Sets text into specified part.
-             * @param[in] text a text to be set in specified part
-             * @param[in] part a part to get text from. If part is nullptr the default part is used.
-             */
-            void setText(const std::string &text, const char *part = nullptr);
-
             /**
              * @brief Sets IDS of translatable string into specified part.
              * @param[in] text a translatable text to be set in specified part.
@@ -295,8 +281,6 @@ namespace Msg
             Evas *getEvas() const;
 
             static void setText(Evas_Object *obj, const TText &text, const char *part = nullptr);
-            static void setText(Evas_Object *obj, const std::string &text, const char *part = nullptr);
-            static void setText(Evas_Object *obj, const char *text, const char *part = nullptr);
 
             static Evas_Object *addLayout(Evas_Object *parent, const std::string &edjePath, const std::string &group);
             static Evas_Object *addIconButton(Evas_Object *parent, const std::string &iconName, Evas_Smart_Cb clickedCb = nullptr, void *cbData = nullptr);
@@ -438,17 +422,6 @@ namespace Msg
         edje_message_signal_process();
     }
 
-    inline void View::setText(const char *text, const char *part)
-    {
-        const char *notNullText = text ? text : "";
-        elm_object_part_text_set(m_pEo, part, notNullText);
-    }
-
-    inline void View::setText(const std::string &text, const char *part)
-    {
-        setText(text.c_str(), part);
-    }
-
     inline void View::setText(const TText &text, const char *part)
     {
         setText(m_pEo, text, part);
@@ -466,17 +439,12 @@ namespace Msg
 
     inline void View::setText(Evas_Object *obj, const TText &text, const char *part)
     {
-        elm_object_domain_translatable_part_text_set(obj, part, text.getDomain(), text.getMsg());
-    }
-
-    inline void View::setText(Evas_Object *obj, const std::string &text, const char *part)
-    {
-        setText(obj, text.c_str(), part);
-    }
-
-    inline void View::setText(Evas_Object *obj, const char *text, const char *part)
-    {
-        elm_object_part_text_set(obj, part, text);
+        if (text.isTranslatable())
+            elm_object_domain_translatable_part_text_set(obj, part, text.getDomain(), text.getMsg());
+        else {
+            elm_object_part_text_translatable_set(obj, part, false);
+            elm_object_part_text_set(obj, part, text.getMsg());
+        }
     }
 
     inline std::string View::getText(const char *part) const
index b280b3b5dd8e67adff7a8b4514c54b0067e676e8..b40daf33d4e616a06434a22b25ec92f5bffafa8b 100644 (file)
@@ -121,20 +121,6 @@ namespace Msg
              */
             const char *getTextCStr(const char *part = nullptr) const;
 
-            /**
-             * @brief Sets text into specified part.
-             * @param[in] text a text to be set in specified part
-             * @param[in] part a part to get text from. If part is nullptr the default part is used.
-             */
-            void setText(const char *text, const char *part = nullptr);
-
-            /**
-             * @brief Sets text into specified part.
-             * @param[in] text a text to be set in specified part
-             * @param[in] part a part to get text from. If part is nullptr the default part is used.
-             */
-            void setText(const std::string &text, const char *part = nullptr);
-
             /**
              * @brief Sets IDS of translatable string into specified part.
              * @param[in] text a translatable text to be set in specified part.
@@ -201,21 +187,11 @@ namespace Msg
         return elm_object_item_disabled_get(getElmObjItem());
     }
 
-    inline void ViewItem::setText(const char *text, const char *part)
-    {
-        elm_object_item_part_text_set(getElmObjItem(), part, text);
-    }
-
     inline void ViewItem::setTranslatable(bool translatable, const char *domain, const char *part)
     {
         elm_object_item_domain_part_text_translatable_set(getElmObjItem(), part, domain, translatable);
     }
 
-    inline void ViewItem::setText(const std::string &text, const char *part)
-    {
-        setText(text.c_str(), part);
-    }
-
     inline void ViewItem::setText(const TText &text, const char *part)
     {
         setText(getElmObjItem(), text, part);
@@ -223,7 +199,12 @@ namespace Msg
 
     inline void ViewItem::setText(Elm_Object_Item *it, const TText &text, const char *part)
     {
-        elm_object_item_domain_translatable_part_text_set(it, part, text.getDomain(), text.getMsg());
+        if (text.isTranslatable()) {
+            elm_object_item_domain_translatable_part_text_set(it, part, text.getDomain(), text.getMsg());
+        } else {
+            elm_object_item_part_text_translatable_set(it, part, false);
+            elm_object_item_part_text_set(it, part, text.getMsg());
+        }
     }
 
     inline std::string ViewItem::getText(const char *part) const
index 9b874239970e78cf6e4d5ffb95b5067ebd1baadf..96de1fa65b4a7eee9bcd0e3d7bc7a70d81bc4748 100644 (file)
@@ -109,7 +109,7 @@ int Entry::getCursorPos() const
 
 void Entry::setEditInfo(Entry &entry)
 {
-    setText(entry.getEntry());
+    View::setText(entry.getEntry());
     setCursorPos(getCursorPos());
 }
 
index 9e6d006911001258245887fbbec3596e17f50497..57303f135aa51309415023985042a3f9388c2d8d 100644 (file)
@@ -35,7 +35,7 @@ IconTextPopup::~IconTextPopup()
 {
 }
 
-void IconTextPopup::setText(const std::string &text)
+void IconTextPopup::setText(const TText &text)
 {
     View::setText(m_pLayout, text, "text");
 }
index ae2875cdb8d400d934fb6b05c2c65c41c35c58b0..094d1423b58162d78a06d7e93e6ca0636514c853 100644 (file)
@@ -32,6 +32,8 @@ namespace {
     const char *buttonRightStyle = "popup/circle/right";
 }
 
+const double Popup::defaultTimeOut = 2.0;
+
 Popup::Popup()
     : BasePopup(elm_popup_add(getWindow()))
     , m_pShowIdler(nullptr)
@@ -57,6 +59,11 @@ void Popup::setTimeOut(double timeout)
     elm_popup_timeout_set(getEo(), timeout);
 }
 
+double Popup::getTimeOut() const
+{
+    return elm_popup_timeout_get(getEo());
+}
+
 Evas_Object *Popup::addButton(const char *part, PopupButtonCb buttonCb, void *userData)
 {
     Evas_Object *btn = elm_button_add(getEo());
@@ -114,11 +121,6 @@ Evas_Object *Popup::addRightButton(const char *iconName, PopupButtonCb cb, void
     return button;
 }
 
-void Popup::setTitle(const std::string &title)
-{
-    setText(title, titlePart);
-}
-
 void Popup::setTitle(const TText &title)
 {
     setText(title, titlePart);
index 0ed3ae2b2e9609e34febf1435832617f4495c37c..c20132dbcb3ef6fb6037e2b67de5954e8e759f79 100644 (file)
@@ -66,9 +66,3 @@ ToastPopup *ToastPopup::toast(const TText &text, const char *iconName)
     return toast;
 }
 
-ToastPopup *ToastPopup::toast(const std::string &text, const char *iconName)
-{
-    auto *toast = createToast(iconName);
-    toast->setText(text);
-    return toast;
-}
index 29635f70f61029ef6afa45700be2e621a9abb0f8..19f5d2d3bcf35b1537386affb7e3aacd701851cb 100644 (file)
@@ -21,6 +21,7 @@
 #include "MoreOption.h"
 #include "SelectCtxPopup.h"
 #include "ToastPopup.h"
+#include "IconTextPopup.h"
 
 using namespace Msg;
 
@@ -228,8 +229,13 @@ void ConvFrame::onListChanged(ConvList &list)
 void ConvFrame::onDelButtonClicked(Evas_Object *obj, void *event)
 {
     MSG_LOG("");
-    if (m_pList->deleteCheckedItems())
-        ToastPopup::toast(msgt("WDS_ALM_TPOP_DELETED_ABB"), DELETEG_MORE_ICON);
+    if (m_pList->deleteCheckedItems()) {
+        auto *popup = new IconTextPopup;
+        popup->setIcon(IconTextPopup::CheckIcon);
+        popup->setText(msgt("WDS_ALM_TPOP_DELETED_ABB"));
+        popup->setTimeOut();
+        popup->show();
+    }
     setMode(NormalMode);
 }
 
index 5f56dd17cc0427431b9b5675f502815e932797ef..455e1fa960e62b7a0edd9c07c4f8c346645f257a 100644 (file)
@@ -18,6 +18,7 @@
 #include "SelectCtxPopup.h"
 #include "StandardPopup.h"
 #include "ToastPopup.h"
+#include "IconTextPopup.h"
 #include "PopupManager.h"
 #include "MsgThreadFrame.h"
 #include "Callback.h"
@@ -193,8 +194,13 @@ void MsgThreadFrame::onHwBackButtonPreessed(Evas_Object *obj, void *event_info)
 void MsgThreadFrame::onDelButtonClicked(Evas_Object *obj, void *event)
 {
     MSG_LOG("");
-    if (m_pThreadList->deleteCheckedItems())
-        ToastPopup::toast(msgt("WDS_ALM_TPOP_DELETED_ABB"), DELETEG_MORE_ICON);
+    if (m_pThreadList->deleteCheckedItems()) {
+        auto *popup = new IconTextPopup;
+        popup->setIcon(IconTextPopup::CheckIcon);
+        popup->setText(msgt("WDS_ALM_TPOP_DELETED_ABB"));
+        popup->setTimeOut();
+        popup->show();
+    }
     setNormalMode(true);
 }