{
dBusClient_ = DBus::DBusClient(BUS, PATH, IFACE, DBus::ConnectionType::SESSION);
synchronizeProviders();
- dBusClient_.addSignal<void()>(std::string{"switchesConfigurationChanged"}, [this]() {
- this->switchesConfigurationChanged_ = std::chrono::system_clock::now();
- });
+ // temporary fix to defend against segfault because dbus signals doesn't unregister on object destroy
+ // dBusClient_.addSignal<void()>(std::string{"switchesConfigurationChanged"}, [this]() {
+ // this->switchesConfigurationChanged_ = std::chrono::system_clock::now();
+ // });
}
void AddSwitchPageModel::synchronizeProviders()
{
presentersStack_.push_back(std::move(presenter));
presenterToBroadcast_ = presentersStack_.back().get();
+ countOfPagesToPop_ = 1;
notify();
}
-void AppContext::pop()
+void AppContext::pop(size_t countOfPagesToPop)
{
+ if (countOfPagesToPop < 1)
+ return;
+
presenterToBroadcast_ = nullptr;
- notify();
- presentersStack_.pop_back();
+ if (countOfPagesToPop > presentersStack_.size())
+ countOfPagesToPop_ = presentersStack_.size();
+ else
+ countOfPagesToPop_ = countOfPagesToPop;
+
+ for (auto i = 0u; i < countOfPagesToPop_; ++i)
+ presentersStack_.pop_back();
if (presentersStack_.empty())
ui_app_exit();
+ else
+ notify();
}
Presenter *AppContext::back()
void AppContext::notify()
{
- for (auto &c : this->Observable<Presenter *>::onChangeCallbacks_)
+ for (auto &c : this->Observable<Presenter *, size_t>::onChangeCallbacks_)
if (c)
- c(presenterToBroadcast_);
+ c(presenterToBroadcast_, countOfPagesToPop_);
}
void AppContext::notifyAboutModal()
#include <memory>
#include <string>
-class AppContext : public Observable<Presenter *>, public Observable<ModalPresenter *>
+class AppContext : public Observable<Presenter *, size_t>, public Observable<ModalPresenter *>
{
public:
AppContext();
void push(std::unique_ptr<Presenter> presenter);
- void pop();
+ void pop(size_t countOfPagesToPop = 1);
Presenter *back();
bool empty();
void notify();
std::vector<std::unique_ptr<Presenter>> presentersStack_;
std::vector<std::unique_ptr<ModalPresenter>> modalPresentersStack_;
Presenter *presenterToBroadcast_ = nullptr;
+ size_t countOfPagesToPop_ = 1;
ModalPresenter *modalPresenterToBroadcast_ = nullptr;
};
#include "SelectActionPagePresenter.hpp"
-SelectActionPagePresenter::SelectActionPagePresenter(std::string switchId, std::string userName, ChangeType changeType, int countOfPagesToPop)
+#include "AppContext.hpp"
+
+SelectActionPagePresenter::SelectActionPagePresenter(std::string switchId, std::string userName, ChangeType changeType, size_t countOfPagesToPop)
: switchId_(std::move(switchId)), userName_(std::move(userName)), changeType_(changeType), countOfPagesToPop_(countOfPagesToPop)
{
setTitle("IDS_ACCS_UNIVERSAL_SWITCH_SELECT_ACTION");
ASSERT(0, "Unhandled change type");
break;
}
- //Singleton<AppContext>::instance().pop(countOfPagesToPop+1);
+ Singleton<AppContext>::instance().pop(countOfPagesToPop_ + 1);
}
\ No newline at end of file
class SelectActionPagePresenter : public ListPresenter
{
public:
- SelectActionPagePresenter(std::string switchId, std::string userName, ChangeType changeType, int countOfPagesToPop);
+ SelectActionPagePresenter(std::string switchId, std::string userName, ChangeType changeType, size_t countOfPagesToPop);
private:
void addOrUpdateSwitchConfigurationItem(const std::string &activityType);
const std::string switchId_;
const std::string userName_;
ChangeType changeType_;
- const int countOfPagesToPop_;
+ const size_t countOfPagesToPop_;
SelectActionPageModel model_;
};
items.front()->title_ = value ? "IDS_ST_BODY_ON" : "IDS_ST_BODY_OFF";
items.front()->widgetState_ = value;
});
+}
- onPopCallback_ = [this]() {
- model_.configurationServiceState_ = false;
- };
+UniversalSwitchPagePresenter::~UniversalSwitchPagePresenter()
+{
+ model_.configurationServiceState_ = false;
}
\ No newline at end of file
{
public:
UniversalSwitchPagePresenter();
+ ~UniversalSwitchPagePresenter();
private:
std::unique_ptr<UniversalSwitchSettingsPage> universalSwitchSettingsPage_;
elm_object_item_part_content_set(item_, part.c_str(), content->getObject());
}
-void Naviframe::createEflObject()
+void Naviframe::createEflObject(std::function<void()> onBackButtonPressed)
{
uniqueObj_.reset(elm_naviframe_add(parent_->getObject()));
- eext_object_event_callback_add(uniqueObj_.get(), EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
+ if (onBackButtonPressed)
+ setEextEventCallback(EEXT_CALLBACK_BACK, onBackButtonPressed);
+ else
+ eext_object_event_callback_add(uniqueObj_.get(), EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
+
eext_object_event_callback_add(uniqueObj_.get(), EEXT_CALLBACK_MORE, eext_naviframe_more_cb, NULL);
elm_naviframe_content_preserve_on_pop_set(uniqueObj_.get(), EINA_TRUE);
}
using Layout::Layout;
private:
- void createEflObject();
+ void createEflObject(std::function<void()> onBackButtonPressed = {});
void onPop(Elm_Object_Item *item);
static Eina_Bool callbackMethod(void *data, Elm_Object_Item *it);
void onPopAnimationEnd();
#include "ListView.hpp"
+#include "AppContext.hpp"
#include "Button.hpp"
#include "Check.hpp"
#include "Genlist.hpp"
#include "ListPresenter.hpp"
#include "NavigationContext.hpp"
+#include "Singleton.hpp"
ListView::ListView(const NavigationContext &context, Presenter *presenter)
- : View(context), listPresenter_(dynamic_cast<ListPresenter *>(presenter))
+ : NaviframeView(context), listPresenter_(dynamic_cast<ListPresenter *>(presenter))
{
ASSERT(listPresenter_, "ListPresenter required");
});
} else {
backItem_ = Widget::make<Button>(context.getNaviframe(),
- [naviframe = context.getNaviframe()]() { naviframe->popBack(); },
+ []() { Singleton<AppContext>::instance().pop(); },
"IDS_ST_BUTTON_BACK",
Button::BACK_BUTTON_ARROW_STYLE);
}
}
- naviframe->pushBack(listPresenter_->getTitle(), genlist_, listPresenter_->getOnPopCallback(), backItem_);
+ naviframeItem_ = naviframe->pushBack(listPresenter_->getTitle(), genlist_, {}, backItem_);
if (auto action = listPresenter_->getAction("titleRightAction")) {
titleRightButton_ = Widget::make<Button>(context.getNaviframe(), [this, action]() {
#include "Button.hpp"
#include "ListPresenter.hpp"
+#include "NaviframeView.hpp"
#include "Presenter.hpp"
-#include "View.hpp"
#include <unordered_map>
-class ListView : public View
+class ListView : public NaviframeView
{
public:
ListView(const NavigationContext &context, Presenter *presenter);
--- /dev/null
+#include "NaviframeView.hpp"
+
+#include "NavigationContext.hpp"
+
+NaviframeView::NaviframeView(const NavigationContext &context) : View(context)
+{}
\ No newline at end of file
--- /dev/null
+#ifndef NAVIFRAME_VIEW_HPP
+#define NAVIFRAME_VIEW_HPP
+
+#include "Naviframe.hpp"
+#include "View.hpp"
+
+class NaviframeView : public View
+{
+ public:
+ NaviframeView(const NavigationContext &context);
+ NaviframeItem naviframeItem_ = {};
+};
+
+#endif
\ No newline at end of file
window_->setConformant(true);
window_->addResizeObject(conformant);
- naviframe_ = Widget::make<Naviframe>(conformant);
+ naviframe_ = Widget::make<Naviframe>(conformant, []() {
+ Singleton<AppContext>::instance().pop();
+ });
conformant->setContent(naviframe_);
conformant->emitSignal("elm,state,virtualkeypad,enable");
window_->show();
- Singleton<AppContext>::instance().Observable<Presenter *>::attach([this](auto presenter) {
- if (presenter)
+ Singleton<AppContext>::instance().Observable<Presenter *, size_t>::attach([this](auto presenter, auto count) {
+ if (presenter) {
this->emplaceView(presenter);
- else
- this->popView();
+ } else {
+ NaviframeItem naviframeItem;
+ for (auto i = 0u; i < count; ++i) {
+ this->popView();
+ naviframeItem = viewsStack_.back()->naviframeItem_;
+ }
+ this->naviframe_->popBack(naviframeItem);
+ }
});
Singleton<AppContext>::instance().Observable<ModalPresenter *>::attach([this](auto presenter) {
#include "ModalView.hpp"
#include "Naviframe.hpp"
+#include "NaviframeView.hpp"
#include "Presenter.hpp"
-#include "View.hpp"
#include "Window.hpp"
#include <memory>
std::unique_ptr<Window> window_;
Naviframe *naviframe_;
- std::vector<std::unique_ptr<View>> viewsStack_;
+ std::vector<std::unique_ptr<NaviframeView>> viewsStack_;
std::vector<std::unique_ptr<ModalView>> modalViewsStack_;
};
#include "SpinnerView.hpp"
+#include "AppContext.hpp"
#include "Box.hpp"
#include "Label.hpp"
#include "Layout.hpp"
#include "NavigationContext.hpp"
+#include "Singleton.hpp"
SpinnerView::SpinnerView(const NavigationContext &context, Presenter *presenter)
- : View(context), spinnerPresenter_(dynamic_cast<SpinnerPresenter *>(presenter))
+ : NaviframeView(context), spinnerPresenter_(dynamic_cast<SpinnerPresenter *>(presenter))
{
ASSERT(spinnerPresenter_, "SpinnerPresenter required");
layout->setPartText("description", spinnerPresenter_->getLabel());
backItem_ = Widget::make<Button>(context.getNaviframe(),
- [naviframe = context.getNaviframe()]() { naviframe->popBack(); },
+ []() { Singleton<AppContext>::instance().pop(); },
"IDS_ST_BUTTON_BACK",
Button::BACK_BUTTON_ARROW_STYLE);
- naviframe->pushBack(spinnerPresenter_->getTitle(), layout, spinnerPresenter_->getOnPopCallback(), backItem_);
+ naviframeItem_ = naviframe->pushBack(spinnerPresenter_->getTitle(), layout, {}, backItem_);
}
\ No newline at end of file
#define SPINNER_VIEW_HPP
#include "Button.hpp"
+#include "NaviframeView.hpp"
#include "Spinner.hpp"
#include "SpinnerPresenter.hpp"
-#include "View.hpp"
-class SpinnerView : public View
+class SpinnerView : public NaviframeView
{
public:
SpinnerView(const NavigationContext &context, Presenter *presenter);
#include "AppContext.hpp"
#include "Layout.hpp"
#include "NavigationContext.hpp"
+#include "Singleton.hpp"
SpinnerViewWithToggle::SpinnerViewWithToggle(const NavigationContext &context, Presenter *presenter)
- : View(context), spinnerPresenter_(dynamic_cast<SpinnerPresenterWithToggle *>(presenter))
+ : NaviframeView(context), spinnerPresenter_(dynamic_cast<SpinnerPresenterWithToggle *>(presenter))
{
ASSERT(spinnerPresenter_, "SpinnerPresenterWithToggle required");
layout_->setPartText("description", spinnerPresenter_->getLabel());
backItem_ = Widget::make<Button>(context.getNaviframe(),
- [naviframe = context.getNaviframe()]() { naviframe->popBack(); },
+ []() { Singleton<AppContext>::instance().pop(); },
"IDS_ST_BUTTON_BACK",
Button::BACK_BUTTON_ARROW_STYLE);
- naviframe->pushBack(spinnerPresenter_->getTitle(), layout_, spinnerPresenter_->getOnPopCallback(), backItem_);
+ naviframe->pushBack(spinnerPresenter_->getTitle(), layout_, {}, backItem_);
}
\ No newline at end of file
#include "Button.hpp"
#include "Check.hpp"
#include "Layout.hpp"
+#include "NaviframeView.hpp"
#include "Spinner.hpp"
#include "SpinnerPresenterWithToggle.hpp"
-#include "View.hpp"
-class SpinnerViewWithToggle : public View
+class SpinnerViewWithToggle : public NaviframeView
{
public:
SpinnerViewWithToggle(const NavigationContext &context, Presenter *presenter);