From b5d26ab5e5a7f603082b0cc57cd050184cd4a27c Mon Sep 17 00:00:00 2001 From: Anatoly Mihalchenko Date: Tue, 4 Sep 2012 18:04:18 +0300 Subject: [PATCH] SANKORE-523 Changing the languages of the virtual keyboard crashes the software --- src/frameworks/UBPlatformUtils.h | 40 ++++++++++++++---------- src/frameworks/UBPlatformUtils_linux.cpp | 10 +++--- src/frameworks/UBPlatformUtils_win.cpp | 15 ++++++--- 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/src/frameworks/UBPlatformUtils.h b/src/frameworks/UBPlatformUtils.h index ebac3995..29af417e 100644 --- a/src/frameworks/UBPlatformUtils.h +++ b/src/frameworks/UBPlatformUtils.h @@ -19,6 +19,11 @@ #include #include +#ifdef Q_WS_MACX + #import +#endif + + class QMainWindow; #define SYMBOL_KEYS_COUNT 47 @@ -125,28 +130,31 @@ struct KEYBT class UBKeyboardLocale { public: - UBKeyboardLocale(const QString& _fullName, - const QString& _name, - const QString& _id, - QIcon* _icon, - KEYBT** _symbols) - :fullName(_fullName),name(_name), id(_id), icon(_icon), - constSymbols(NULL), varSymbols(_symbols) - {} - UBKeyboardLocale(const QString& _fullName, - const QString& _name, - const QString& _id, - QIcon* _icon, - KEYBT _symbols[]) - :fullName(_fullName),name(_name), id(_id), icon(_icon), + #ifdef Q_WS_MACX + UBKeyboardLocale(const QString& _fullName, + const QString& _name, + TISInputSourceRef _tisInputSourceRef, + QIcon* _icon, + KEYBT** _symbols) + :fullName(_fullName),name(_name), tisInputSourceRef(_tisInputSourceRef), + icon(_icon),constSymbols(NULL), varSymbols(_symbols) + {} + + TISInputSourceRef tisInputSourceRef; + #else + UBKeyboardLocale(const QString& _fullName, + const QString& _name, + QIcon* _icon, + KEYBT _symbols[]) + :fullName(_fullName),name(_name), icon(_icon), constSymbols(_symbols), varSymbols(NULL) - {} + {} + #endif ~UBKeyboardLocale(); const QString fullName; const QString name; - const QString id; QIcon* icon; KEYBT* operator[] (int index) const { diff --git a/src/frameworks/UBPlatformUtils_linux.cpp b/src/frameworks/UBPlatformUtils_linux.cpp index 8c10c4c9..411d812a 100644 --- a/src/frameworks/UBPlatformUtils_linux.cpp +++ b/src/frameworks/UBPlatformUtils_linux.cpp @@ -399,11 +399,11 @@ void UBPlatformUtils::initializeKeyboardLayouts() { nKeyboardLayouts = 5; keyboardLayouts = new UBKeyboardLocale*[nKeyboardLayouts]; - keyboardLayouts[0] = new UBKeyboardLocale(tr("English"), "en", "", new QIcon(":/images/flags/en.png"), ENGLISH_LOCALE); - keyboardLayouts[1] = new UBKeyboardLocale(tr("Russian"), "ru", "", new QIcon(":/images/flags/ru.png"),RUSSIAN_LOCALE); - keyboardLayouts[2] = new UBKeyboardLocale(tr("German"), "de", "", new QIcon(":/images/flags/de.png"), GERMAN_LOCALE); - keyboardLayouts[3] = new UBKeyboardLocale(tr("French"), "fr", "", new QIcon(":/images/flags/fr.png"), FRENCH_LOCALE); - keyboardLayouts[4] = new UBKeyboardLocale(tr("Swiss French"), "fr-CH", "", new QIcon(":/images/flags/fr.png"), SWISS_FRENCH_LOCALE); + keyboardLayouts[0] = new UBKeyboardLocale(tr("English"), "en", new QIcon(":/images/flags/en.png"), ENGLISH_LOCALE); + keyboardLayouts[1] = new UBKeyboardLocale(tr("Russian"), "ru", new QIcon(":/images/flags/ru.png"),RUSSIAN_LOCALE); + keyboardLayouts[2] = new UBKeyboardLocale(tr("German"), "de", new QIcon(":/images/flags/de.png"), GERMAN_LOCALE); + keyboardLayouts[3] = new UBKeyboardLocale(tr("French"), "fr", new QIcon(":/images/flags/fr.png"), FRENCH_LOCALE); + keyboardLayouts[4] = new UBKeyboardLocale(tr("Swiss French"), "fr-CH", new QIcon(":/images/flags/fr.png"), SWISS_FRENCH_LOCALE); } void UBPlatformUtils::destroyKeyboardLayouts() diff --git a/src/frameworks/UBPlatformUtils_win.cpp b/src/frameworks/UBPlatformUtils_win.cpp index 95a6970e..f7c67f8b 100644 --- a/src/frameworks/UBPlatformUtils_win.cpp +++ b/src/frameworks/UBPlatformUtils_win.cpp @@ -407,11 +407,16 @@ void UBPlatformUtils::initializeKeyboardLayouts() { nKeyboardLayouts = 5; keyboardLayouts = new UBKeyboardLocale*[nKeyboardLayouts]; - keyboardLayouts[0] = new UBKeyboardLocale(tr("English"), "en", "", new QIcon(":/images/flags/en.png"), ENGLISH_LOCALE); - keyboardLayouts[1] = new UBKeyboardLocale(tr("Russian"), "ru", "", new QIcon(":/images/flags/ru.png"),RUSSIAN_LOCALE); - keyboardLayouts[2] = new UBKeyboardLocale(tr("French"), "fr", "", new QIcon(":/images/flags/fr.png"), FRENCH_LOCALE); - keyboardLayouts[3] = new UBKeyboardLocale(tr("Swiss French"), "fr-CH", "", new QIcon(":/images/flags/fr.png"), SWISS_FRENCH_LOCALE); - keyboardLayouts[4] = new UBKeyboardLocale(tr("German"), "de", "", new QIcon(":/images/flags/de.png"), GERMAN_LOCALE); + keyboardLayouts[0] = new UBKeyboardLocale(tr("English"),"en", + new QIcon(":/images/flags/en.png"), ENGLISH_LOCALE); + keyboardLayouts[1] = new UBKeyboardLocale(tr("Russian"), "ru", + new QIcon(":/images/flags/ru.png"),RUSSIAN_LOCALE); + keyboardLayouts[2] = new UBKeyboardLocale(tr("French"), "fr", + new QIcon(":/images/flags/fr.png"), FRENCH_LOCALE); + keyboardLayouts[3] = new UBKeyboardLocale(tr("Swiss French"), "fr-CH", + new QIcon(":/images/flags/fr.png"), SWISS_FRENCH_LOCALE); + keyboardLayouts[4] = new UBKeyboardLocale(tr("German"), "de", + new QIcon(":/images/flags/de.png"), GERMAN_LOCALE); } void UBPlatformUtils::destroyKeyboardLayouts()