diff options
| author | handsome_feng <445865575@qq.com> | 2015-11-23 17:24:10 +0800 |
|---|---|---|
| committer | handsome_feng <445865575@qq.com> | 2015-11-23 17:24:10 +0800 |
| commit | 0ba4ad707833928adc16d697bd9a3fefa40598bf (patch) | |
| tree | 8202d6b2a6fa575e4d4fbaa0acce2556cc921165 /lockscreen | |
| parent | d6a56f9b78ef585784c2b72810316ff28635881b (diff) | |
Modified UserIconFile(), Add DesktopType to UnitySettings,Add some nux::Property in textinput
(bzr r4016.2.26)
Diffstat (limited to 'lockscreen')
| -rw-r--r-- | lockscreen/KylinLockScreenShield.cpp | 2 | ||||
| -rw-r--r-- | lockscreen/KylinLockScreenShield.h | 5 | ||||
| -rw-r--r-- | lockscreen/KylinUserPromptView.cpp | 59 | ||||
| -rw-r--r-- | lockscreen/KylinUserPromptView.h | 8 | ||||
| -rw-r--r-- | lockscreen/LockScreenAbstractPromptView.h | 2 | ||||
| -rw-r--r-- | lockscreen/LockScreenAbstractShield.h | 4 | ||||
| -rw-r--r-- | lockscreen/LockScreenController.cpp | 4 | ||||
| -rw-r--r-- | lockscreen/LockScreenController.h | 3 | ||||
| -rw-r--r-- | lockscreen/LockScreenShieldFactory.cpp | 3 | ||||
| -rw-r--r-- | lockscreen/UserPromptView.h | 3 |
10 files changed, 57 insertions, 36 deletions
diff --git a/lockscreen/KylinLockScreenShield.cpp b/lockscreen/KylinLockScreenShield.cpp index 0108fb862..ee865fee8 100644 --- a/lockscreen/KylinLockScreenShield.cpp +++ b/lockscreen/KylinLockScreenShield.cpp @@ -1,6 +1,6 @@ // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- /* -* Copyright (C) 2013 Canonical Ltd +* Copyright (C) 2015 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as diff --git a/lockscreen/KylinLockScreenShield.h b/lockscreen/KylinLockScreenShield.h index cd18c1ef3..e896c0583 100644 --- a/lockscreen/KylinLockScreenShield.h +++ b/lockscreen/KylinLockScreenShield.h @@ -1,6 +1,6 @@ // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- /* -* Copyright (C) 2013 Canonical Ltd +* Copyright (C) 2015 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as @@ -43,8 +43,6 @@ public: int monitor, bool is_primary); bool HasGrab() const override; - bool IsIndicatorOpen() const override { return false;} - void ActivatePanel() override {} protected: bool AcceptKeyNavFocus() override; @@ -63,7 +61,6 @@ private: nux::ObjectPtr<nux::Layout> primary_layout_; nux::ObjectPtr<nux::Layout> prompt_layout_; nux::ObjectPtr<nux::Layout> cof_layout_; - connection::Wrapper panel_active_conn_; connection::Wrapper regrab_conn_; glib::Source::UniquePtr regrab_timeout_; CofView* cof_view_; diff --git a/lockscreen/KylinUserPromptView.cpp b/lockscreen/KylinUserPromptView.cpp index a61d4796b..a52b950a9 100644 --- a/lockscreen/KylinUserPromptView.cpp +++ b/lockscreen/KylinUserPromptView.cpp @@ -1,6 +1,6 @@ // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- /* -* Copyright (C) 2014 Canonical Ltd +* Copyright (C) 2015 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as @@ -43,16 +43,19 @@ namespace lockscreen { namespace { +const RawPixel AVATAR_SIZE = 128_em; +const RawPixel ACTIVATOR_ICON_SIZE = 34_em; const RawPixel LAYOUT_MARGIN = 20_em; const RawPixel MSG_LAYOUT_MARGIN = 15_em; const RawPixel MSG_LAYOUT_PADDING = 33_em; const RawPixel PROMPT_LAYOUT_MARGIN = 5_em; const RawPixel SWITCH_ICON_SIZE = 32_em; -const RawPixel AVATAR_SIZE = 128_em; const RawPixel TEXT_INPUT_HEIGHT = 36_em; const RawPixel TEXT_INPUT_WIDTH = 320_em; const int PROMPT_FONT_SIZE = 14; +const std::string ACTIVATOR_ICON = "login.png"; + std::string SanitizeMessage(std::string const& message) { std::string msg = boost::algorithm::trim_copy(message); @@ -81,8 +84,9 @@ KylinUserPromptView::KylinUserPromptView(session::Manager::Ptr const& session_ma , username_(nullptr) , msg_layout_(nullptr) , prompt_layout_(nullptr) - , SwitchIcon_(nullptr) - , Avatar_(nullptr) + , avatar_layout_(nullptr) + , switch_icon_(nullptr) + , avatar_(nullptr) { user_authenticator_.echo_on_requested.connect([this](std::string const& message, PromiseAuthCodePtr const& promise){ AddPrompt(message, true, promise); @@ -106,6 +110,10 @@ KylinUserPromptView::KylinUserPromptView(session::Manager::Ptr const& session_ma scale.changed.connect(sigc::hide(sigc::mem_fun(this, &KylinUserPromptView::UpdateSize))); + session_manager_->UserIconFile([this] (GVariant* value) { + AddAvatar(glib::gchar_to_string(g_variant_get_string(value, NULL)), AVATAR_SIZE.CP(scale)); + }); + UpdateSize(); ResetLayout(); @@ -126,19 +134,17 @@ void KylinUserPromptView::ResetLayout() nux::Layout* switch_layout = new nux::HLayout(); TextureCache& cache = TextureCache::GetDefault(); - SwitchIcon_ = new IconTexture(cache.FindTexture("switch_user.png", SWITCH_ICON_SIZE.CP(scale), SWITCH_ICON_SIZE.CP(scale))); - switch_layout->AddView(SwitchIcon_); - SwitchIcon_->mouse_click.connect([this](int x, int y, unsigned long button_flags, unsigned long key_flags) { + switch_icon_ = new IconTexture(cache.FindTexture("switch_user.png", SWITCH_ICON_SIZE.CP(scale), SWITCH_ICON_SIZE.CP(scale))); + switch_layout->AddView(switch_icon_); + switch_icon_->mouse_click.connect([this](int x, int y, unsigned long button_flags, unsigned long key_flags) { session_manager_->SwitchToGreeter(); }); switch_layout->SetMaximumSize(SWITCH_ICON_SIZE.CP(scale), SWITCH_ICON_SIZE.CP(scale)); GetLayout()->AddLayout(switch_layout); } - Avatar_ = new IconTexture(LoadUserIcon(AVATAR_SIZE.CP(scale))); - Avatar_->SetMinimumWidth(AVATAR_SIZE.CP(scale)); - Avatar_->SetMaximumWidth(AVATAR_SIZE.CP(scale)); - GetLayout()->AddView(Avatar_); + avatar_layout_ = new nux::VLayout(); + GetLayout()->AddLayout(avatar_layout_); nux::Layout* prompt_layout = new nux::VLayout(); @@ -276,6 +282,12 @@ void KylinUserPromptView::AddPrompt(std::string const& message, bool visible, Pr auto* text_entry = text_input->text_entry(); text_input->scale = scale(); + text_input->activator_icon = ACTIVATOR_ICON; + text_input->activator_icon_size = ACTIVATOR_ICON_SIZE; + text_input->background_color = nux::Color(1.0f, 1.0f, 1.0f, 0.8f); + text_input->border_color = nux::Color(0.0f, 0.0f, 0.0f, 0.0f); + text_input->border_radius = 0; + text_input->hint_color = nux::Color(0.0f, 0.0f, 0.0f, 0.5f); text_input->input_hint = SanitizeMessage(message); text_input->hint_font_size = PROMPT_FONT_SIZE; text_input->show_caps_lock = true; @@ -342,17 +354,30 @@ void KylinUserPromptView::AddMessage(std::string const& message, nux::Color cons QueueDraw(); } -nux::ObjectPtr<nux::BaseTexture> KylinUserPromptView::LoadUserIcon(int user_icon_size) +void KylinUserPromptView::AddAvatar(std::string const& icon_file, int icon_size) +{ + avatar_ = new IconTexture(LoadUserIcon(icon_file, icon_size)); + avatar_->SetMinimumWidth(icon_size); + avatar_->SetMaximumWidth(icon_size); + avatar_layout_->AddView(avatar_); + + GetLayout()->ComputeContentPosition(0, 0); + ComputeContentSize(); + QueueRelayout(); + QueueDraw(); +} + +nux::ObjectPtr<nux::BaseTexture> KylinUserPromptView::LoadUserIcon(std::string const& icon_file, int icon_size) { glib::Error error; - glib::Object<GdkPixbuf> pixbuf(gdk_pixbuf_new_from_file_at_size(session_manager_->UserIconFile().c_str(), user_icon_size, user_icon_size, &error)); - if (pixbuf == nullptr) + glib::Object<GdkPixbuf> pixbuf(gdk_pixbuf_new_from_file_at_size(icon_file.c_str(), icon_size, icon_size, &error)); + if (!pixbuf) { auto* theme = gtk_icon_theme_get_default(); GtkIconLookupFlags flags = GTK_ICON_LOOKUP_FORCE_SIZE; - pixbuf = gtk_icon_theme_load_icon(theme, "avatar-default-kylin", user_icon_size, flags, &error); - if ( pixbuf == nullptr) - pixbuf = gtk_icon_theme_load_icon(theme, "avatar-default", user_icon_size, flags, &error); + pixbuf = gtk_icon_theme_load_icon(theme, "avatar-default-kylin", icon_size, flags, &error); + if (!pixbuf) + pixbuf = gtk_icon_theme_load_icon(theme, "avatar-default", icon_size, flags, &error); } nux::CairoGraphics cg(CAIRO_FORMAT_ARGB32, gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf)); cairo_t* cr = cg.GetInternalContext(); diff --git a/lockscreen/KylinUserPromptView.h b/lockscreen/KylinUserPromptView.h index c02bd0670..a6938e409 100644 --- a/lockscreen/KylinUserPromptView.h +++ b/lockscreen/KylinUserPromptView.h @@ -48,6 +48,7 @@ public: nux::View* focus_view(); + void AddAvatar(std::string const& avatar_icon, int avatar_size); void AddPrompt(std::string const& message, bool visible, PromiseAuthCodePtr const&); void AddMessage(std::string const& message, nux::Color const& color); void AuthenticationCb(bool authenticated); @@ -58,7 +59,7 @@ protected: void ResetLayout(); void UpdateSize(); bool InspectKeyEvent(unsigned int eventType, unsigned int key_sym, const char* character); - nux::ObjectPtr<nux::BaseTexture> LoadUserIcon(int icon_size); + nux::ObjectPtr<nux::BaseTexture> LoadUserIcon(std::string const& icon_file, int icon_size); private: session::Manager::Ptr session_manager_; @@ -66,9 +67,10 @@ private: StaticCairoText* username_; nux::VLayout* msg_layout_; nux::VLayout* prompt_layout_; + nux::VLayout* avatar_layout_; std::deque<TextInput*> focus_queue_; - IconTexture* SwitchIcon_; - IconTexture* Avatar_; + IconTexture* switch_icon_; + IconTexture* avatar_; nux::Geometry cached_focused_geo_; }; diff --git a/lockscreen/LockScreenAbstractPromptView.h b/lockscreen/LockScreenAbstractPromptView.h index c8fb749c9..3a5d5284f 100644 --- a/lockscreen/LockScreenAbstractPromptView.h +++ b/lockscreen/LockScreenAbstractPromptView.h @@ -62,8 +62,6 @@ public: virtual void ResetLayout() = 0; virtual void UpdateSize() = 0; - virtual bool InspectKeyEvent(unsigned int eventType, unsigned int key_sym, const char* character) = 0; - protected: session::Manager::Ptr session_manager_; UserAuthenticatorPam user_authenticator_; diff --git a/lockscreen/LockScreenAbstractShield.h b/lockscreen/LockScreenAbstractShield.h index 4843a00c4..603e0294a 100644 --- a/lockscreen/LockScreenAbstractShield.h +++ b/lockscreen/LockScreenAbstractShield.h @@ -58,8 +58,8 @@ public: using MockableBaseWindow::RemoveLayout; virtual bool HasGrab() const = 0; - virtual bool IsIndicatorOpen() const = 0; - virtual void ActivatePanel() = 0; + virtual bool IsIndicatorOpen() const { return false; } + virtual void ActivatePanel() {} sigc::signal<void> grabbed; sigc::signal<void> grab_failed; diff --git a/lockscreen/LockScreenController.cpp b/lockscreen/LockScreenController.cpp index b44f7481c..3a1a0d2fa 100644 --- a/lockscreen/LockScreenController.cpp +++ b/lockscreen/LockScreenController.cpp @@ -23,10 +23,12 @@ #include <UnityCore/GLibDBusProxy.h> #include <NuxCore/Logger.h> +#include "KylinUserPromptView.h" #include "LockScreenShield.h" #include "LockScreenSettings.h" #include "unity-shared/AnimationUtils.h" #include "unity-shared/UScreen.h" +#include "unity-shared/UnitySettings.h" #include "unity-shared/WindowManager.h" namespace unity @@ -224,7 +226,7 @@ void Controller::EnsureShields(std::vector<nux::Geometry> const& monitors) if (!prompt_view) { - if (g_strcmp0(getenv("KYLIN_CURRENT_DESKTOP"), "Kylin") == 0) + if (unity::Settings::Instance().desktop_type() == DesktopType::UBUNTUKYLIN) prompt_view = test_mode_ ? nullptr : new KylinUserPromptView(session_manager_); else prompt_view = test_mode_ ? nullptr : new UserPromptView(session_manager_); diff --git a/lockscreen/LockScreenController.h b/lockscreen/LockScreenController.h index d190fb93c..bc409f050 100644 --- a/lockscreen/LockScreenController.h +++ b/lockscreen/LockScreenController.h @@ -33,9 +33,6 @@ #include "unity-shared/BackgroundEffectHelper.h" #include "unity-shared/UpstartWrapper.h" -#include "KylinUserPromptView.h" -#include "LockScreenAbstractPromptView.h" - namespace unity { namespace lockscreen diff --git a/lockscreen/LockScreenShieldFactory.cpp b/lockscreen/LockScreenShieldFactory.cpp index abd9866a0..74bc77c9b 100644 --- a/lockscreen/LockScreenShieldFactory.cpp +++ b/lockscreen/LockScreenShieldFactory.cpp @@ -21,6 +21,7 @@ #include "LockScreenShield.h" #include "LockScreenAbstractPromptView.h" #include "KylinLockScreenShield.h" +#include "unity-shared/UnitySettings.h" namespace unity { @@ -33,7 +34,7 @@ nux::ObjectPtr<AbstractShield> ShieldFactory::CreateShield(session::Manager::Ptr nux::ObjectPtr<AbstractUserPromptView> const& prompt_view, int monitor, bool is_primary) { - if (g_strcmp0(getenv("KYLIN_CURRENT_DESKTOP"),"Kylin") == 0) + if (Settings::Instance().desktop_type() == DesktopType::UBUNTUKYLIN) return nux::ObjectPtr<KylinShield>(new KylinShield(session_manager, accelerators, prompt_view, monitor, is_primary)); else return nux::ObjectPtr<Shield>(new Shield(session_manager, indicators, accelerators, prompt_view, monitor, is_primary)); diff --git a/lockscreen/UserPromptView.h b/lockscreen/UserPromptView.h index 15741030b..381ad8f50 100644 --- a/lockscreen/UserPromptView.h +++ b/lockscreen/UserPromptView.h @@ -27,11 +27,10 @@ #include <Nux/View.h> #include <UnityCore/SessionManager.h> +#include "LockScreenAbstractPromptView.h" #include "UserAuthenticatorPam.h" #include "unity-shared/IMTextEntry.h" -#include "LockScreenAbstractPromptView.h" - namespace nux { class VLayout; |
