/**
* @brief Create popup.
- * @param[in] size Popup size
+ * @param[in] size Popup size
+ * @param[in] showDelayTime Delay before showing popup
+ * @param[in] showMinTime Minimum time popup should be shown
*/
- explicit ProcessPopup(Size size = SizeMedium);
+ explicit ProcessPopup(Size size = SizeMedium,
+ double showDelayTime = 0.2, double showMinTime = 1.0);
+ virtual ~ProcessPopup() override;
/**
* @brief Allows method overload instead of shadowing
static ProcessPopup *create(Evas_Object *parent, const char *text, Size size = SizeMedium);
/**
+ * @brief Destroy the popup once minimum show time has elapsed.
+ */
+ void destroy();
+
+ /**
* @brief Set Popup text.
* @param[in] text Popup text
*/
virtual Evas_Object *onCreate(Evas_Object *parent) override;
private:
+ Eina_Bool onShowDelayElapsed();
+ Eina_Bool onShowMinElapsed();
+
Size m_Size;
Evas_Object *m_Layout;
+
+ Ecore_Timer *m_ShowDelayTimer;
+ Ecore_Timer *m_ShowMinTimer;
+ bool m_IsDestroyPending;
};
}
#include "Ui/Window.h"
#include "App/Path.h"
+#include "Utils/Callback.h"
#include "AppsCommonPopup.h"
-#include <efl_extension.h>
-
using namespace Ui;
-ProcessPopup::ProcessPopup(Size size)
- : m_Size(size), m_Layout(nullptr)
+ProcessPopup::ProcessPopup(Size size, double showDelayTime, double showMinTime)
+ : m_Size(size), m_Layout(nullptr),
+ m_ShowDelayTimer(nullptr), m_ShowMinTimer(nullptr),
+ m_IsDestroyPending(false)
+{
+ m_ShowDelayTimer = ecore_timer_add(showDelayTime,
+ makeCallback(&ProcessPopup::onShowDelayElapsed), this);
+ ecore_timer_freeze(m_ShowDelayTimer);
+ m_ShowMinTimer = ecore_timer_add(showMinTime,
+ makeCallback(&ProcessPopup::onShowMinElapsed), this);
+ ecore_timer_freeze(m_ShowMinTimer);
+
+ setBackCallback([this] {
+ return m_IsDestroyPending;
+ });
+}
+
+ProcessPopup::~ProcessPopup()
{
- setBackCallback([]{ return false; });
+ ecore_timer_del(m_ShowDelayTimer);
+ ecore_timer_del(m_ShowMinTimer);
}
ProcessPopup *ProcessPopup::create(Evas_Object *parent, const char *text, Size size)
return popup;
}
+void ProcessPopup::destroy()
+{
+ if (m_ShowMinTimer && !m_ShowDelayTimer) {
+ m_IsDestroyPending = true;
+ } else {
+ delete this;
+ }
+}
+
void ProcessPopup::setText(const char *text)
{
elm_object_translatable_part_text_set(m_Layout, "elm.text", text);
const char *layout;
const char *progress;
} styles[] = {
- /* SizeSmall = */ { GROUP_PROCESS_SMALL, "process_small" },
+ /* SizeSmall = */ { GROUP_PROCESS_SMALL, "process_small" },
/* SizeMedium = */ { GROUP_PROCESS_MEDIUM, "process_medium" }
};
elm_progressbar_pulse(progressbar, EINA_TRUE);
elm_object_content_set(m_Layout, progressbar);
+ if (m_ShowDelayTimer) {
+ evas_object_hide(popup);
+ ecore_timer_thaw(m_ShowDelayTimer);
+ } else {
+ ecore_timer_thaw(m_ShowMinTimer);
+ }
+
return popup;
}
+
+Eina_Bool ProcessPopup::onShowDelayElapsed()
+{
+ evas_object_show(getEvasObject());
+ ecore_timer_thaw(m_ShowMinTimer);
+
+ m_ShowDelayTimer = nullptr;
+ return EINA_FALSE;
+}
+
+Eina_Bool ProcessPopup::onShowMinElapsed()
+{
+ m_ShowMinTimer = nullptr;
+ if (m_IsDestroyPending) {
+ delete this;
+ }
+ return EINA_FALSE;
+}
using namespace std::placeholders;
#define SYMBOL_MAGNIFIER "\U0001f50d"
-#define PROGRESS_RESULTS_LIMIT 40
ListView::ListView(Model::PersonProvider *provider)
: m_Box(nullptr), m_NoContent(nullptr), m_Genlist(nullptr),
contacts_disconnect_on_thread();
};
- Ui::ProcessPopup *popup = nullptr;
- if (results.size() > PROGRESS_RESULTS_LIMIT) {
- popup = Ui::ProcessPopup::create(getEvasObject(), "IDS_PB_TPOP_DELETING_ING_ABB");
- }
+ auto popup = Ui::ProcessPopup::create(getEvasObject(), "IDS_PB_TPOP_DELETING_ING_ABB");
new Thread(std::bind(task, std::move(results)), [this, popup] {
- delete popup;
+ popup->destroy();
onSelectFinished();
});
using namespace Contacts::List;
using namespace Contacts::List::Model;
-#define PROGRESS_RESULTS_LIMIT 40
-
ManageFavoritesPopup::ManageFavoritesPopup(Ui::Navigator *navigator)
: m_Navigator(navigator)
{
view->setSelectMode(Ux::SelectMulti);
view->setSectionVisibility(ListView::SectionFavorites, false);
view->setSelectCallback([view](Ux::SelectResults results) {
- Ui::ProcessPopup *popup = nullptr;
- if (results.size() > PROGRESS_RESULTS_LIMIT) {
- popup = Ui::ProcessPopup::create(view->getEvasObject(), "IDS_PB_TPOP_PROCESSING_ING");
- }
+ auto popup = Ui::ProcessPopup::create(view->getEvasObject(), "IDS_PB_TPOP_PROCESSING_ING");
new Utils::Thread(std::bind(addFavorites, std::move(results)), [view, popup] {
- delete popup;
+ popup->destroy();
view->getPage()->close();
});
return false;
//todo Implement separate controller to handle callback, because object is destroyed after popup close.
auto &onMfcUpdated = m_OnMfcUpdated;
view->setSelectCallback([view, onMfcUpdated](Ux::SelectResults results) {
- Ui::ProcessPopup *popup = nullptr;
- if (results.size() > PROGRESS_RESULTS_LIMIT) {
- popup = Ui::ProcessPopup::create(view->getEvasObject(), "IDS_PB_TPOP_PROCESSING_ING");
- }
+ auto popup = Ui::ProcessPopup::create(view->getEvasObject(), "IDS_PB_TPOP_PROCESSING_ING");
new Utils::Thread(std::bind(removeFavorites, std::move(results), std::move(onMfcUpdated)), [view, popup] {
- delete popup;
+ popup->destroy();
view->getPage()->close();
});
return false;