From ae3e98931458fe2e19c9bad4f123f9f2f5b3b70a Mon Sep 17 00:00:00 2001 From: mateoconlechuga Date: Fri, 1 Sep 2017 19:29:00 -0600 Subject: [PATCH 1/3] Add shift activated text (Fix #22) This adds the text 'shift' when the shift key is activated. No functionality changes were made. --- apps/Makefile | 2 +- apps/i18n.cpp | 3 +- apps/i18n.h | 3 +- ...ock_view.cpp => shift_alpha_lock_view.cpp} | 34 +++++++++++-------- ...ha_lock_view.h => shift_alpha_lock_view.h} | 2 +- apps/title_bar_view.h | 2 +- 6 files changed, 26 insertions(+), 20 deletions(-) rename apps/{alpha_lock_view.cpp => shift_alpha_lock_view.cpp} (51%) rename apps/{alpha_lock_view.h => shift_alpha_lock_view.h} (94%) diff --git a/apps/Makefile b/apps/Makefile index ec371132a..85433e051 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -13,7 +13,6 @@ include apps/code/Makefile #include apps/picview/Makefile app_objs += $(addprefix apps/,\ - alpha_lock_view.o\ apps_container.o\ apps_window.o\ battery_timer.o\ @@ -29,6 +28,7 @@ app_objs += $(addprefix apps/,\ main.o\ math_toolbox.o\ node.o\ + shift_alpha_lock_view.o\ suspend_timer.o\ title_bar_view.o\ toolbox_node.o\ diff --git a/apps/i18n.cpp b/apps/i18n.cpp index 8933ac9d3..a78460e62 100644 --- a/apps/i18n.cpp +++ b/apps/i18n.cpp @@ -316,12 +316,13 @@ constexpr static char leftIntegralFirstLegend[] = {'P', '(', 'X', Ion::Charset:: constexpr static char finiteIntegralLegend[] = {Ion::Charset::LessEqual, 'X', Ion::Charset::LessEqual, 0}; -const char * universalMessages[241] { +const char * universalMessages[242] { "", "Python", "PYTHON (BETA)", "alpha", "ALPHA", + "shift", "x", "y", "n", diff --git a/apps/i18n.h b/apps/i18n.h index 3805c003e..4f126ba5b 100644 --- a/apps/i18n.h +++ b/apps/i18n.h @@ -152,7 +152,7 @@ namespace I18n { ValueNotReachedBySequence, NColumn, - /* Statistics */ + /* Statistics */ StatsApp, StatsAppCapital, DataTab, @@ -276,6 +276,7 @@ namespace I18n { CodeAppCapital, Alpha, CapitalAlpha, + Shift, X, Y, N, diff --git a/apps/alpha_lock_view.cpp b/apps/shift_alpha_lock_view.cpp similarity index 51% rename from apps/alpha_lock_view.cpp rename to apps/shift_alpha_lock_view.cpp index 645914af8..3edc66bba 100644 --- a/apps/alpha_lock_view.cpp +++ b/apps/shift_alpha_lock_view.cpp @@ -1,8 +1,8 @@ -#include "alpha_lock_view.h" +#include "shift_alpha_lock_view.h" AlphaLockView::AlphaLockView() : View(), - m_alphaView(KDText::FontSize::Small, I18n::Message::Default, 1.0f, 0.5f, KDColorWhite, Palette::YellowDark), + m_modifierView(KDText::FontSize::Small, I18n::Message::Default, 1.0f, 0.5f, KDColorWhite, Palette::YellowDark), m_status(Ion::Events::ShiftAlphaStatus::Default) { } @@ -14,18 +14,21 @@ void AlphaLockView::drawRect(KDContext * ctx, KDRect rect) const { bool AlphaLockView::setStatus(Ion::Events::ShiftAlphaStatus status) { if (status != m_status) { m_status = status; - switch (status) { + switch (m_status) { case Ion::Events::ShiftAlphaStatus::Alpha: case Ion::Events::ShiftAlphaStatus::AlphaLock: case Ion::Events::ShiftAlphaStatus::AlphaLockShift: - m_alphaView.setMessage(I18n::Message::Alpha); + m_modifierView.setMessage(I18n::Message::Alpha); break; case Ion::Events::ShiftAlphaStatus::ShiftAlpha: case Ion::Events::ShiftAlphaStatus::ShiftAlphaLock: - m_alphaView.setMessage(I18n::Message::CapitalAlpha); + m_modifierView.setMessage(I18n::Message::CapitalAlpha); break; - default: - m_alphaView.setMessage(I18n::Message::Default); + case Ion::Events::ShiftAlphaStatus::Shift: + m_modifierView.setMessage(I18n::Message::Shift); + break; + case Ion::Events::ShiftAlphaStatus::Default: + m_modifierView.setMessage(I18n::Message::Default); break; } markRectAsDirty(bounds()); @@ -35,37 +38,38 @@ bool AlphaLockView::setStatus(Ion::Events::ShiftAlphaStatus status) { } KDSize AlphaLockView::minimalSizeForOptimalDisplay() const { - KDSize alphaSize = KDText::stringSize(I18n::translate(I18n::Message::Alpha)); + KDSize modifierSize = KDText::stringSize(I18n::translate(I18n::Message::Alpha), KDText::FontSize::Small); KDSize lockSize = m_lockView.minimalSizeForOptimalDisplay(); - KDCoordinate height = lockSize.height() > alphaSize.height() ? lockSize.height() : alphaSize.height(); - return KDSize(alphaSize.width() + lockSize.width() + k_lockRightMargin, height); + KDCoordinate height = lockSize.height() > modifierSize.height() ? lockSize.height() : modifierSize.height(); + return KDSize(modifierSize.width() + lockSize.width() + k_lockRightMargin, height); } int AlphaLockView::numberOfSubviews() const { switch (m_status) { case Ion::Events::ShiftAlphaStatus::Alpha: + case Ion::Events::ShiftAlphaStatus::Shift: case Ion::Events::ShiftAlphaStatus::ShiftAlpha: return 1; case Ion::Events::ShiftAlphaStatus::AlphaLock: case Ion::Events::ShiftAlphaStatus::AlphaLockShift: case Ion::Events::ShiftAlphaStatus::ShiftAlphaLock: return 2; - default: + case Ion::Events::ShiftAlphaStatus::Default: return 0; } } View * AlphaLockView::subviewAtIndex(int index) { if (index == 0) { - return &m_alphaView; + return &m_modifierView; } return &m_lockView; } void AlphaLockView::layoutSubviews() { - KDSize alphaSize = KDText::stringSize(I18n::translate(I18n::Message::Alpha), KDText::FontSize::Small); - m_alphaView.setFrame(KDRect(bounds().width() - alphaSize.width(), (bounds().height()- alphaSize.height())/2, alphaSize)); + KDSize modifierSize = KDText::stringSize(I18n::translate(I18n::Message::Alpha), KDText::FontSize::Small); + m_modifierView.setFrame(KDRect(bounds().width() - modifierSize.width(), (bounds().height()- modifierSize.height())/2, modifierSize)); KDSize lockSize = m_lockView.minimalSizeForOptimalDisplay(); - m_lockView.setFrame(KDRect(bounds().width() - alphaSize.width() - lockSize.width() - k_lockRightMargin, (bounds().height()- lockSize.height())/2, lockSize)); + m_lockView.setFrame(KDRect(bounds().width() - modifierSize.width() - lockSize.width() - k_lockRightMargin, (bounds().height()- lockSize.height())/2, lockSize)); } diff --git a/apps/alpha_lock_view.h b/apps/shift_alpha_lock_view.h similarity index 94% rename from apps/alpha_lock_view.h rename to apps/shift_alpha_lock_view.h index c9d0b9d6e..00a57ba9d 100644 --- a/apps/alpha_lock_view.h +++ b/apps/shift_alpha_lock_view.h @@ -17,7 +17,7 @@ private: void layoutSubviews() override; View * subviewAtIndex(int index) override; LockView m_lockView; - MessageTextView m_alphaView; + MessageTextView m_modifierView; Ion::Events::ShiftAlphaStatus m_status; }; diff --git a/apps/title_bar_view.h b/apps/title_bar_view.h index b53da3dc7..26e51b6aa 100644 --- a/apps/title_bar_view.h +++ b/apps/title_bar_view.h @@ -3,7 +3,7 @@ #include #include "battery_view.h" -#include "alpha_lock_view.h" +#include "shift_alpha_lock_view.h" #include "i18n.h" class TitleBarView : public View { From 9d155f325b08897fca583743e2a56f0745b1b44e Mon Sep 17 00:00:00 2001 From: mateoconlechuga Date: Fri, 1 Sep 2017 20:06:59 -0600 Subject: [PATCH 2/3] Match names everywhere --- apps/shift_alpha_lock_view.cpp | 28 ++++++++++++++-------------- apps/shift_alpha_lock_view.h | 10 +++++----- apps/title_bar_view.h | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/apps/shift_alpha_lock_view.cpp b/apps/shift_alpha_lock_view.cpp index 3edc66bba..bc6c57584 100644 --- a/apps/shift_alpha_lock_view.cpp +++ b/apps/shift_alpha_lock_view.cpp @@ -1,34 +1,34 @@ #include "shift_alpha_lock_view.h" -AlphaLockView::AlphaLockView() : +ShiftAlphaLockView::ShiftAlphaLockView() : View(), - m_modifierView(KDText::FontSize::Small, I18n::Message::Default, 1.0f, 0.5f, KDColorWhite, Palette::YellowDark), + m_shiftAlphaView(KDText::FontSize::Small, I18n::Message::Default, 1.0f, 0.5f, KDColorWhite, Palette::YellowDark), m_status(Ion::Events::ShiftAlphaStatus::Default) { } -void AlphaLockView::drawRect(KDContext * ctx, KDRect rect) const { +void ShiftAlphaLockView::drawRect(KDContext * ctx, KDRect rect) const { ctx->fillRect(bounds(), Palette::YellowDark); } -bool AlphaLockView::setStatus(Ion::Events::ShiftAlphaStatus status) { +bool ShiftAlphaLockView::setStatus(Ion::Events::ShiftAlphaStatus status) { if (status != m_status) { m_status = status; switch (m_status) { case Ion::Events::ShiftAlphaStatus::Alpha: case Ion::Events::ShiftAlphaStatus::AlphaLock: case Ion::Events::ShiftAlphaStatus::AlphaLockShift: - m_modifierView.setMessage(I18n::Message::Alpha); + m_shiftAlphaView.setMessage(I18n::Message::Alpha); break; case Ion::Events::ShiftAlphaStatus::ShiftAlpha: case Ion::Events::ShiftAlphaStatus::ShiftAlphaLock: - m_modifierView.setMessage(I18n::Message::CapitalAlpha); + m_shiftAlphaView.setMessage(I18n::Message::CapitalAlpha); break; case Ion::Events::ShiftAlphaStatus::Shift: - m_modifierView.setMessage(I18n::Message::Shift); + m_shiftAlphaView.setMessage(I18n::Message::Shift); break; case Ion::Events::ShiftAlphaStatus::Default: - m_modifierView.setMessage(I18n::Message::Default); + m_shiftAlphaView.setMessage(I18n::Message::Default); break; } markRectAsDirty(bounds()); @@ -37,14 +37,14 @@ bool AlphaLockView::setStatus(Ion::Events::ShiftAlphaStatus status) { return false; } -KDSize AlphaLockView::minimalSizeForOptimalDisplay() const { +KDSize ShiftAlphaLockView::minimalSizeForOptimalDisplay() const { KDSize modifierSize = KDText::stringSize(I18n::translate(I18n::Message::Alpha), KDText::FontSize::Small); KDSize lockSize = m_lockView.minimalSizeForOptimalDisplay(); KDCoordinate height = lockSize.height() > modifierSize.height() ? lockSize.height() : modifierSize.height(); return KDSize(modifierSize.width() + lockSize.width() + k_lockRightMargin, height); } -int AlphaLockView::numberOfSubviews() const { +int ShiftAlphaLockView::numberOfSubviews() const { switch (m_status) { case Ion::Events::ShiftAlphaStatus::Alpha: case Ion::Events::ShiftAlphaStatus::Shift: @@ -59,16 +59,16 @@ int AlphaLockView::numberOfSubviews() const { } } -View * AlphaLockView::subviewAtIndex(int index) { +View * ShiftAlphaLockView::subviewAtIndex(int index) { if (index == 0) { - return &m_modifierView; + return &m_shiftAlphaView; } return &m_lockView; } -void AlphaLockView::layoutSubviews() { +void ShiftAlphaLockView::layoutSubviews() { KDSize modifierSize = KDText::stringSize(I18n::translate(I18n::Message::Alpha), KDText::FontSize::Small); - m_modifierView.setFrame(KDRect(bounds().width() - modifierSize.width(), (bounds().height()- modifierSize.height())/2, modifierSize)); + m_shiftAlphaView.setFrame(KDRect(bounds().width() - modifierSize.width(), (bounds().height()- modifierSize.height())/2, modifierSize)); KDSize lockSize = m_lockView.minimalSizeForOptimalDisplay(); m_lockView.setFrame(KDRect(bounds().width() - modifierSize.width() - lockSize.width() - k_lockRightMargin, (bounds().height()- lockSize.height())/2, lockSize)); diff --git a/apps/shift_alpha_lock_view.h b/apps/shift_alpha_lock_view.h index 00a57ba9d..f96dcfedc 100644 --- a/apps/shift_alpha_lock_view.h +++ b/apps/shift_alpha_lock_view.h @@ -1,13 +1,13 @@ -#ifndef APPS_ALPHA_LOCK_VIEW_H -#define APPS_ALPHA_LOCK_VIEW_H +#ifndef APPS_SHIFT_ALPHA_LOCK_VIEW_H +#define APPS_SHIFT_ALPHA_LOCK_VIEW_H #include #include "lock_view.h" #include "i18n.h" -class AlphaLockView : public View { +class ShiftAlphaLockView : public View { public: - AlphaLockView(); + ShiftAlphaLockView(); void drawRect(KDContext * ctx, KDRect rect) const override; bool setStatus(Ion::Events::ShiftAlphaStatus status); KDSize minimalSizeForOptimalDisplay() const override; @@ -17,7 +17,7 @@ private: void layoutSubviews() override; View * subviewAtIndex(int index) override; LockView m_lockView; - MessageTextView m_modifierView; + MessageTextView m_shiftAlphaView; Ion::Events::ShiftAlphaStatus m_status; }; diff --git a/apps/title_bar_view.h b/apps/title_bar_view.h index 26e51b6aa..e7a5c42aa 100644 --- a/apps/title_bar_view.h +++ b/apps/title_bar_view.h @@ -29,7 +29,7 @@ private: View * subviewAtIndex(int index) override; MessageTextView m_titleView; BatteryView m_batteryView; - AlphaLockView m_alphaLockView; + ShiftAlphaLockView m_alphaLockView; BufferTextView m_preferenceView; ImageView m_examModeIconView; }; From 22b74892d7af06208f67071b192dfa121032f519 Mon Sep 17 00:00:00 2001 From: mateoconlechuga Date: Fri, 1 Sep 2017 20:06:59 -0600 Subject: [PATCH 3/3] Match names everywhere --- apps/apps_window.cpp | 2 +- apps/title_bar_view.cpp | 10 +++++----- apps/title_bar_view.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/apps_window.cpp b/apps/apps_window.cpp index 85dcdf32d..e3d11d693 100644 --- a/apps/apps_window.cpp +++ b/apps/apps_window.cpp @@ -31,7 +31,7 @@ void AppsWindow::refreshPreferences() { } bool AppsWindow::updateAlphaLock() { - return m_titleBarView.setAlphaLockStatus(Ion::Events::shiftAlphaStatus()); + return m_titleBarView.setShiftAlphaLockStatus(Ion::Events::shiftAlphaStatus()); } void AppsWindow::hideTitleBarView(bool hide) { diff --git a/apps/title_bar_view.cpp b/apps/title_bar_view.cpp index 9bdae920b..332ae61b9 100644 --- a/apps/title_bar_view.cpp +++ b/apps/title_bar_view.cpp @@ -42,8 +42,8 @@ bool TitleBarView::setIsPlugged(bool isPlugged) { return m_batteryView.setIsPlugged(isPlugged); } -bool TitleBarView::setAlphaLockStatus(Ion::Events::ShiftAlphaStatus status) { - return m_alphaLockView.setStatus(status); +bool TitleBarView::setShiftAlphaLockStatus(Ion::Events::ShiftAlphaStatus status) { + return m_shiftAlphaLockView.setStatus(status); } int TitleBarView::numberOfSubviews() const { @@ -61,7 +61,7 @@ View * TitleBarView::subviewAtIndex(int index) { return &m_examModeIconView; } if (index == 3) { - return &m_alphaLockView; + return &m_shiftAlphaLockView; } return &m_batteryView; } @@ -81,8 +81,8 @@ void TitleBarView::layoutSubviews() { } else { m_examModeIconView.setFrame(KDRectZero); } - KDSize alphaLockSize = m_alphaLockView.minimalSizeForOptimalDisplay(); - m_alphaLockView.setFrame(KDRect(bounds().width()-batterySize.width()-k_batteryRightMargin-k_alphaRightMargin-alphaLockSize.width(), (bounds().height()- alphaLockSize.height())/2, alphaLockSize)); + KDSize shiftAlphaLockSize = m_shiftAlphaLockView.minimalSizeForOptimalDisplay(); + m_shiftAlphaLockView.setFrame(KDRect(bounds().width()-batterySize.width()-k_batteryRightMargin-k_alphaRightMargin-shiftAlphaLockSize.width(), (bounds().height()- shiftAlphaLockSize.height())/2, shiftAlphaLockSize)); } void TitleBarView::refreshPreferences() { diff --git a/apps/title_bar_view.h b/apps/title_bar_view.h index e7a5c42aa..2058cb898 100644 --- a/apps/title_bar_view.h +++ b/apps/title_bar_view.h @@ -15,7 +15,7 @@ public: bool setChargeState(Ion::Battery::Charge chargeState); bool setIsCharging(bool isCharging); bool setIsPlugged(bool isPlugged); - bool setAlphaLockStatus(Ion::Events::ShiftAlphaStatus status); + bool setShiftAlphaLockStatus(Ion::Events::ShiftAlphaStatus status); void refreshPreferences(); private: constexpr static KDCoordinate k_batteryRightMargin = 5; @@ -29,7 +29,7 @@ private: View * subviewAtIndex(int index) override; MessageTextView m_titleView; BatteryView m_batteryView; - ShiftAlphaLockView m_alphaLockView; + ShiftAlphaLockView m_shiftAlphaLockView; BufferTextView m_preferenceView; ImageView m_examModeIconView; };