*
* @param[in] alarm The alarm passed with event
*/
- RingNewAlarmEvent(Alarm &alarm);
+ RingNewAlarmEvent(Alarm &alarm) : alarm_(&alarm) {};
/**
* @brief Gets event's alarm
#include "Model/Timer.h"
#include "Common/CounterAnimator.h"
#include "Utils/Signal.h"
+#include "Utils/EventBus.h"
namespace presenter {
void CancelButtonClicked();
void TimeIsUp();
-
void TimeUpdateRequest();
+ void RingDismissHandle(utils::Event &e);
+
std::vector<utils::Connection> connections_;
};
utils::Signal<void(void)> OnCounterUnfocused;
/**
- * @brief Enables Start button
+ * @brief Sets all menu buttons enabled
*
- * When time selector's time is set to 00:00:00 which is default value,
- * the Start button is disabled. This might be changed whenever this
- * value changes.
+ * Enables all timer's menu buttons.
*
* @param[in] enable The enable flag
*/
- void SetEnabledStartButton(bool enable);
+ void SetAllButtonsEnabled(bool enable);
+
+ /**
+ * @brief Enables button
+ *
+ * @param[in] name Name of the button
+ * @param[in] enable The enable flag
+ */
+ void SetButtonEnabled(const char *name, bool enable);
/**
* @brief Displays time in counter's view
void CreateMenuButtons();
Evas_Object *CreateEntry(Evas_Object *parent, const char *part, const char *description);
void CreateEntries(Evas_Object *parent);
+ void SetStartButtonEnabled(bool enable);
void UpdateView();
void UpdateTime();
+++ /dev/null
-/*
-* Copyright 2016 Samsung Electronics Co., Ltd
-*
-* Licensed under the Flora License, Version 1.1 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://floralicense.org/license/
-*
-* 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.
-*/
-
-#include "Model/RingEvent.h"
-
-namespace model {
-
-RingNewAlarmEvent::RingNewAlarmEvent(Alarm &alarm) :
- alarm_(&alarm)
-{
-}
-
-} //namespace model
*/
#include "Presenter/TimerPresenter.h"
+#include "Utils/EventBus.h"
#include "Utils/Log.h"
+#include "Model/RingEvent.h"
namespace presenter {
std::bind(&TimerPresenter::ResetButtonClicked, this)));
connections_.push_back(animator_.OnTick.Connect(
std::bind(&TimerPresenter::TimeUpdateRequest, this)));
+
+ connections_.push_back(utils::EventBus::AddListener<model::RingDismissEvent>(
+ std::bind(&TimerPresenter::RingDismissHandle,
+ this, std::placeholders::_1)));
}
TimerPresenter::~TimerPresenter()
{
model_->Stop();
model_->Reset();
+ view_->SetAllButtonsEnabled(false);
animator_.Stop();
view_->ShowEditingMenu();
}
+void TimerPresenter::RingDismissHandle(utils::Event &e)
+{
+ if (view_)
+ view_->SetAllButtonsEnabled(true);
+}
+
} //namespace presenter
object->UpdateTime();
if (object->set_time_.Hour || object->set_time_.Min || object->set_time_.Sec) {
- object->SetEnabledStartButton(true);
+ object->SetStartButtonEnabled(true);
object->ShowEditingMenu();
} else {
- object->SetEnabledStartButton(false);
+ object->SetStartButtonEnabled(false);
object->ShowStartupMenu();
}
CreateButton(layout_, "IDS_COM_SK_CANCEL", "sw.btn.cancel", CancelButtonClicked);
CreateButton(layout_, "IDS_SWT_BUTTON_RESUME", "sw.btn.resume", ResumeButtonClicked);
- SetEnabledStartButton(false);
+ SetStartButtonEnabled(false);
}
-void TimerView::SetEnabledStartButton(bool enable)
-{
- Evas_Object *startButton = elm_object_part_content_get(layout_, "sw.btn.start");
- if (!startButton)
+void TimerView::SetButtonEnabled(const char *name, bool enable){
+ Evas_Object *button = elm_object_part_content_get(layout_, name);
+ if (!button)
return;
- Eina_Bool isDisabled = elm_object_disabled_get(startButton);
+ elm_object_disabled_set(button, !enable);
+}
+
+void TimerView::SetAllButtonsEnabled(bool enable)
+{
+ SetButtonEnabled("sw.btn.start", enable);
+ SetButtonEnabled("sw.btn.reset", enable);
+ SetButtonEnabled("sw.btn.pause", enable);
+ SetButtonEnabled("sw.btn.cancel", enable);
+ SetButtonEnabled("sw.btn.resume", enable);
+}
- if (isDisabled && enable)
- elm_object_disabled_set(startButton, EINA_FALSE);
- else if (!isDisabled && !enable)
- elm_object_disabled_set(startButton, EINA_TRUE);
+void TimerView::SetStartButtonEnabled(bool enable)
+{
+ SetButtonEnabled("sw.btn.start", enable);
}
void TimerView::CreateButton(Evas_Object *parent, const char *name,