From 1d130b3e60df312bd107e4aba949000bc13a57ab Mon Sep 17 00:00:00 2001 From: Anatoly Mihalchenko Date: Fri, 10 Aug 2012 11:35:12 +0300 Subject: [PATCH] SANKORE-896 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Impossible to write an ê and an ë using the keyboard --- src/domain/UBGraphicsItemDelegate.cpp | 6 ++-- src/gui/UBKeyboardPalette.cpp | 2 ++ src/gui/UBKeyboardPalette.h | 10 +++--- src/gui/UBKeyboardPalette_linux.cpp | 3 ++ src/gui/UBKeyboardPalette_mac.cpp | 51 ++++++++++++++------------- src/gui/UBKeyboardPalette_win.cpp | 7 ++-- 6 files changed, 46 insertions(+), 33 deletions(-) diff --git a/src/domain/UBGraphicsItemDelegate.cpp b/src/domain/UBGraphicsItemDelegate.cpp index 387ffda1..39721a3d 100644 --- a/src/domain/UBGraphicsItemDelegate.cpp +++ b/src/domain/UBGraphicsItemDelegate.cpp @@ -107,12 +107,12 @@ UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObjec , mFrame(0) , mFrameWidth(UBSettings::settings()->objectFrameWidth) , mAntiScaleRatio(1.0) + , mToolBarItem(NULL) , mCanRotate(canRotate) , mCanDuplicate(true) , mRespectRatio(respectRatio) , mMimeData(NULL) , mFlippable(false) - , mToolBarItem(NULL) , mToolBarUsed(useToolBar) { // NOOP @@ -1075,11 +1075,11 @@ void MediaTimer::display(const QString &s) void MediaTimer::setNumDigits(int numDigits) { if (numDigits > 99) { - qWarning("QLCDNumber::setNumDigits: (%s) Max 99 digits allowed"); + qWarning("QLCDNumber::setNumDigits: Max 99 digits allowed"); numDigits = 99; } if (numDigits < 0) { - qWarning("QLCDNumber::setNumDigits: (%s) Min 0 digits allowed"); + qWarning("QLCDNumber::setNumDigits: Min 0 digits allowed"); numDigits = 0; } if (digitStr.isNull()) { // from constructor diff --git a/src/gui/UBKeyboardPalette.cpp b/src/gui/UBKeyboardPalette.cpp index 846d9d89..3f1fe242 100644 --- a/src/gui/UBKeyboardPalette.cpp +++ b/src/gui/UBKeyboardPalette.cpp @@ -243,6 +243,8 @@ void UBKeyboardPalette::adjustSizeAndPosition(bool pUp) void UBKeyboardPalette::paintEvent( QPaintEvent* event) { + checkLayout(); + UBActionPalette::paintEvent(event); QRect r = this->geometry(); diff --git a/src/gui/UBKeyboardPalette.h b/src/gui/UBKeyboardPalette.h index 3b717fc8..8cee0686 100644 --- a/src/gui/UBKeyboardPalette.h +++ b/src/gui/UBKeyboardPalette.h @@ -127,6 +127,7 @@ protected: void init(); + private: QRect originalRect; @@ -134,6 +135,11 @@ private: UBKeyButton** buttons; UBKeyboardButton** ctrlButtons; + /* + For MacOS: synchronization with system locale. + */ + void checkLayout(); + void createCtrlButtons(); void setInput(const UBKeyboardLocale* locale); @@ -145,10 +151,6 @@ private: void* storage; // Linux-related parameters int min_keycodes, max_keycodes, byte_per_code; - - // Save locale before activation to restore it after (MAC) - QString activeLocale; - }; class UBKeyboardButton : public QWidget diff --git a/src/gui/UBKeyboardPalette_linux.cpp b/src/gui/UBKeyboardPalette_linux.cpp index 1b216e9e..317a2b91 100644 --- a/src/gui/UBKeyboardPalette_linux.cpp +++ b/src/gui/UBKeyboardPalette_linux.cpp @@ -164,6 +164,9 @@ void UBKeyboardPalette::createCtrlButtons() } +void UBKeyboardPalette::checkLayout() +{} + void UBKeyboardPalette::onActivated(bool activated) { if (activated) diff --git a/src/gui/UBKeyboardPalette_mac.cpp b/src/gui/UBKeyboardPalette_mac.cpp index 3b91d782..3b179c36 100644 --- a/src/gui/UBKeyboardPalette_mac.cpp +++ b/src/gui/UBKeyboardPalette_mac.cpp @@ -74,32 +74,35 @@ void SetMacLocaleByIdentifier(const QString& id) } } -void UBKeyboardPalette::onActivated(bool activated) + +void UBKeyboardPalette::checkLayout() { - if (activated) - { - TISInputSourceRef selectedLocale = TISCopyCurrentKeyboardInputSource(); - - CFStringRef sr = (CFStringRef) TISGetInputSourceProperty(selectedLocale, - kTISPropertyInputSourceID); - - if (sr!=NULL) - { - char tmp[1024]; - CFStringGetCString(sr, tmp, 1024, 0); - activeLocale = tmp; - } - else - activeLocale = ""; - + TISInputSourceRef selectedLocale = TISCopyCurrentKeyboardInputSource(); - onLocaleChanged(locales[nCurrentLocale]); - } - else - { - if (activeLocale != "") - SetMacLocaleByIdentifier(activeLocale); - } + CFStringRef sr = (CFStringRef) TISGetInputSourceProperty(selectedLocale, + kTISPropertyInputSourceID); + + if (sr!=NULL) + { + char clId[1024]; + CFStringGetCString(sr, clId, 1024, 0); + + for(int i=0; iid == clId) + { + if (nCurrentLocale!=i) + { + setLocale(i); + } + break; + } + } + } +} + +void UBKeyboardPalette::onActivated(bool) +{ } void UBKeyboardPalette::onLocaleChanged(UBKeyboardLocale* locale) diff --git a/src/gui/UBKeyboardPalette_win.cpp b/src/gui/UBKeyboardPalette_win.cpp index 495175c8..cee91e92 100644 --- a/src/gui/UBKeyboardPalette_win.cpp +++ b/src/gui/UBKeyboardPalette_win.cpp @@ -64,9 +64,12 @@ void UBKeyboardPalette::createCtrlButtons() ctrlButtons[ctrlID++] = new UBLocaleButton(this); // Language Switch } +void UBKeyboardPalette::checkLayout() +{} + void UBKeyboardPalette::onActivated(bool) -{ -} +{} + void UBKeyboardPalette::onLocaleChanged(UBKeyboardLocale* ) {}