Menu Builder now uses Window, causing tests to fail.
This patch does not resolve quickpanel scanning/capturing switches problem.
Change-Id: Ia878609d17cf0ffc237a84aa59e2f0fbed63ff26
gobject-2.0
sqlite3
tts
+ tzsh-quickpanel
)
SET(COMMON_FLAGS "-fdiagnostics-color=always -fPIC")
BuildRequires: pkgconfig(capi-ui-efl-util)
BuildRequires: pkgconfig(gobject-2.0)
BuildRequires: pkgconfig(eldbus)
+BuildRequires: pkgconfig(tzsh-quickpanel)
#Required for tests
BuildRequires: net-config
%if %{with docs}
msgid "IDS_ACTIVITY_NAME_MORE_OPTIONS"
msgstr "More options"
+msgid "IDS_ACTIVITY_NAME_OPEN_QUICKPANEL"
+msgstr "Open notifications"
+
# PROVIDERS
msgid "IDS_SWITCH_PROVIDER_NAME_AccessoriesSwitchProvider"
#include "VConf.hpp"
#include "VConfKeys.hpp"
#include "UniversalSwitchLog.hpp"
-
+#include "UniversalSwitch.hpp"
+#include "Singleton.hpp"
+#include "Window.hpp"
+#include "Quickpanel.hpp"
MenuItem::MenuItem(std::vector<std::string> names, std::string iconPath, std::string activityType,
VconfKeyType vconfStateKeysType, std::vector<std::string> vconfStateKeys,
std::string subMenuLabel, std::string showingStateVconfKey)
: names(std::move(names)), iconPath(std::move(iconPath)), activityType(std::move(activityType)),
vconfStateKeysType(vconfStateKeysType), vconfStateKeys(std::move(vconfStateKeys)),
- subMenuLabel(std::move(subMenuLabel)), showingStateVconfKey(std::move(showingStateVconfKey))
+ subMenuLabel(std::move(subMenuLabel)), showingStateVconfKey(std::move(showingStateVconfKey)),
+ quickpanelItem(false)
+{}
+
+MenuItem::MenuItem(std::vector<std::string> names, std::string iconPath, std::string activityType, bool quickpanelItem)
+ : names(std::move(names)), iconPath(std::move(iconPath)), activityType(std::move(activityType)),
+ vconfStateKeysType(VconfKeyType::NONE), quickpanelItem(quickpanelItem)
{}
std::string MenuItem::getName() const
{
if (names.empty())
return {};
+
+ if (quickpanelItem) {
+ /*
+ * Using window will crash MenuBuilderTests
+ * TODO solve in next patch
+ **/
+ auto window = Singleton<UniversalSwitch>::instance().getMainWindow();
+ ASSERT(window, "NULL Window");
+ return gettext(names[window->getQuickpanel()->isVisible() ? 1 : 0].c_str());
+ }
+
if (vconfStateKeys.empty())
return gettext(names[0].c_str());
VCONF_KEY_SHOW_BACK_MENU_ITEM);
auto openCloseNotifications = std::make_shared<MenuItem>(
std::vector<std::string> {"IDS_OPEN_NOTI_PANEL", "IDS_CLOSE_NOTI_PANEL"},
- defaultImg);//TODO add settings key, when activity will be ready;
+ defaultImg,
+ "TOGGLE_QUICKPANEL",
+ true);
auto recentApps = std::make_shared<MenuItem>(
std::vector<std::string> {"IDS_RECENT_APPS"},
defaultImg,
VconfKeyType vconfStateKeysType = VconfKeyType::NONE, std::vector<std::string> vconfStateKeys = {},
std::string subMenuLabel = {}, std::string showingStateVconfKey = {});
+ MenuItem(std::vector<std::string> names, std::string iconPath, std::string activityType, bool quickpanelItem);
+
std::string getName() const;
std::string getIconPath() const;
std::string getActivityType() const;
std::vector<std::string> vconfStateKeys;
std::string subMenuLabel;
std::string showingStateVconfKey;
+ bool quickpanelItem; //TODO remove in next patch
};
class MenuMap
--- /dev/null
+#include "Quickpanel.hpp"
+#include "UniversalSwitch.hpp"
+#include "UniversalSwitchLog.hpp"
+#include "Window.hpp"
+
+Quickpanel::Quickpanel(Evas_Object *window)
+ : tzsh(nullptr), handle(nullptr)
+{
+ DEBUG("Quickpanel creation");
+ tzsh = tzsh_create(TZSH_TOOLKIT_TYPE_EFL);
+ if (!tzsh) {
+ ERROR("tzsh creation fail");
+ return;
+ }
+
+ auto tzshWin = elm_win_window_id_get(window);
+ if (!tzshWin) {
+ ERROR("tzsh window fail");
+ return;
+ }
+
+ handle = tzsh_quickpanel_create(tzsh, tzshWin);
+ if (!handle) {
+ ERROR("tzsh quickpanel creation fail");
+ }
+}
+
+Quickpanel::~Quickpanel()
+{
+ DEBUG("Quickpanel destruction");
+ if (handle) {
+ tzsh_quickpanel_destroy(handle);
+ }
+
+ if (tzsh) {
+ tzsh_destroy(tzsh);
+ }
+}
+
+bool Quickpanel::isVisible() const
+{
+ DEBUG("Quickpanel get state");
+ tzsh_quickpanel_state_visible_e visible;
+ auto error = tzsh_quickpanel_visible_get(handle, &visible);
+ if (error != TZSH_ERROR_NONE)
+ ERROR("Quickpanel get state error: %d", error);
+
+ return visible == TZSH_QUICKPANEL_STATE_VISIBLE_SHOWN;
+}
+
+void Quickpanel::show() const
+{
+ DEBUG("Quickpanel show request");
+ auto error = tzsh_quickpanel_show(handle);
+ if (error != TZSH_ERROR_NONE)
+ ERROR("Quickpanel show error: %d", error);
+}
+
+void Quickpanel::hide() const
+{
+ DEBUG("Quickpanel hide request");
+ auto error = tzsh_quickpanel_hide(handle);
+ if (error != TZSH_ERROR_NONE)
+ ERROR("Quickpanel hide error: %d", error);
+}
\ No newline at end of file
--- /dev/null
+#ifndef QUICKPANEL_HPP
+#define QUICKPANEL_HPP
+
+#include "Singleton.hpp"
+
+#include <Elementary.h>
+#include <tzsh.h>
+#include <tzsh_quickpanel.h>
+
+#include <memory>
+
+
+
+class Quickpanel
+{
+public:
+ Quickpanel(Evas_Object *);
+ ~Quickpanel();
+
+ bool isVisible() const;
+ void show() const;
+ void hide() const;
+
+private:
+ tzsh_h tzsh;
+ tzsh_quickpanel_h handle;
+};
+
+#endif
\ No newline at end of file
--- /dev/null
+#include "UniversalSwitch.hpp"
+#include "Activity.hpp"
+#include "ActivityFactory.hpp"
+#include "UniversalSwitchLog.hpp"
+#include "Window.hpp"
+
+#include <memory>
+
+namespace
+{
+ static constexpr char openQuickpanelActivityName[] = "OPEN_QUICKPANEL";
+ static constexpr char toggleQuickpanelActivityName[] = "TOGGLE_QUICKPANEL";
+}
+
+template <typename DerivedType, const char *tempActivityType, bool bindable>
+class QuickpanelActivity : public Activity, private RegisterActivity<DerivedType, bindable>
+{
+public:
+ constexpr static const char *activityType = tempActivityType;
+ QuickpanelActivity()
+ : Activity(activityType)
+ {}
+
+ bool process() override
+ {
+ DerivedType::changeQuickpanelState();
+ return true;
+ }
+};
+
+class OpenQuickpanelActivity : public QuickpanelActivity<OpenQuickpanelActivity, openQuickpanelActivityName, true>
+{
+public:
+ static void changeQuickpanelState()
+ {
+ Singleton<UniversalSwitch>::instance().getMainWindow()->getQuickpanel()->show();
+ }
+};
+
+class ToggleQuickpanelActivity : public QuickpanelActivity<ToggleQuickpanelActivity, toggleQuickpanelActivityName, false>
+{
+public:
+ static void changeQuickpanelState()
+ {
+ auto quickpanel = Singleton<UniversalSwitch>::instance().getMainWindow()->getQuickpanel();
+ if (quickpanel->isVisible())
+ quickpanel->hide();
+ else
+ quickpanel->show();
+ }
+};
\ No newline at end of file
waylandWindow = elm_win_wl_window_get(windowHandler);
handler.reset(windowHandler);
ecore_wl_window_input_region_set(waylandWindow, 0, 0, 0, 0);
+ quickpanel = std::make_unique<Quickpanel>(windowHandler);
}
Evas_Object *Window::getHandler()
{
return {{0, 0}, {screenWidth, screenHeight}};
}
+
+Quickpanel *Window::getQuickpanel() const
+{
+ return quickpanel.get();
+}
#define WINDOW_HPP
#include "Geometry.hpp"
+#include "Quickpanel.hpp"
#include <Elementary.h>
#include <ui/efl_util.h>
Evas_Object *getHandler();
Rectangle getDimensions() const;
+ Quickpanel *getQuickpanel() const;
private:
std::unique_ptr<Evas_Object, void(*)(Evas_Object *)> handler;
Ecore_Wl_Window *waylandWindow;
int screenWidth;
int screenHeight;
+ std::unique_ptr<Quickpanel> quickpanel;
};
#endif