using utf8 string to keyboard languages

preferencesAboutTextFull
Claudio Valerio 13 years ago
parent c988c2c0a6
commit 2ab3471c25
  1. 17
      src/frameworks/UBPlatformUtils_mac.mm

@ -373,10 +373,10 @@ QPixmap qpixmapFromIconRef(IconRef iconRef, int size) {
HLock(hRawBitmapData); HLock(hRawBitmapData);
unsigned long* data = (unsigned long*) *hRawBitmapData; unsigned long* data = (unsigned long*) *hRawBitmapData;
for (int posy=0; posy<iconSize; ++posy, data+=iconSize) { for (int posy=0; posy<iconSize; ++posy, data+=iconSize) {
#ifdef __BIG_ENDIAN__ #ifdef __BIG_ENDIAN__
uchar* line = image.scanLine(posy); uchar* line = image.scanLine(posy);
memcpy(line, data, iconSize * 4); memcpy(line, data, iconSize * 4);
#else #else
uchar* src = (uchar*) data; uchar* src = (uchar*) data;
uchar* dst = image.scanLine(posy); uchar* dst = image.scanLine(posy);
for (int posx=0; posx<iconSize; src+=4, dst+=4, ++posx) { for (int posx=0; posx<iconSize; src+=4, dst+=4, ++posx) {
@ -385,7 +385,7 @@ QPixmap qpixmapFromIconRef(IconRef iconRef, int size) {
dst[2] = src[1]; dst[2] = src[1];
dst[3] = src[0]; dst[3] = src[0];
} }
#endif #endif
} }
HUnlock(hRawBitmapData); HUnlock(hRawBitmapData);
DisposeHandle( hRawBitmapData ); DisposeHandle( hRawBitmapData );
@ -413,7 +413,7 @@ KEYBT* createKeyBt(const UCKeyboardLayout* keyLayout, int vkk)
UInt32 deadKeyState = 0L; UInt32 deadKeyState = 0L;
UInt32 kbdType = kKeyboardISO; UInt32 kbdType = kKeyboardISO;
UniCharCount cnt1, cnt2, cnt3; UniCharCount cnt1, cnt2;
UniChar unicodeString1[100], unicodeString2[100], unicodeString3[100]; UniChar unicodeString1[100], unicodeString2[100], unicodeString3[100];
UCKeyTranslate(keyLayout, vkk, kUCKeyActionDisplay, 0, kbdType, kUCKeyTranslateNoDeadKeysBit, &deadKeyState, 100, &cnt1, unicodeString1); UCKeyTranslate(keyLayout, vkk, kUCKeyActionDisplay, 0, kbdType, kUCKeyTranslateNoDeadKeysBit, &deadKeyState, 100, &cnt1, unicodeString1);
@ -421,11 +421,12 @@ KEYBT* createKeyBt(const UCKeyboardLayout* keyLayout, int vkk)
UCKeyTranslate(keyLayout, vkk, kUCKeyActionDisplay, (alphaLock >> 8) & 0xff, kbdType, kUCKeyTranslateNoDeadKeysBit, &deadKeyState, 100, &cnt2, unicodeString3); UCKeyTranslate(keyLayout, vkk, kUCKeyActionDisplay, (alphaLock >> 8) & 0xff, kbdType, kUCKeyTranslateNoDeadKeysBit, &deadKeyState, 100, &cnt2, unicodeString3);
return new KEYBT(unicodeString1[0], unicodeString2[0], unicodeString1[0] != unicodeString3[0], 0,0, KEYCODE(0, vkk, 0), KEYCODE(0, vkk, 1)); return new KEYBT(unicodeString1[0], unicodeString2[0], unicodeString1[0] != unicodeString3[0], 0,0, KEYCODE(0, vkk, 0), KEYCODE(0, vkk, 1));
} }
void UBPlatformUtils::initializeKeyboardLayouts() void UBPlatformUtils::initializeKeyboardLayouts()
{ {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
CFStringRef keys[] = { kTISPropertyInputSourceCategory, kTISPropertyInputSourceIsEnableCapable, kTISPropertyInputSourceIsSelectCapable }; CFStringRef keys[] = { kTISPropertyInputSourceCategory, kTISPropertyInputSourceIsEnableCapable, kTISPropertyInputSourceIsSelectCapable };
const void* values[] = { kTISCategoryKeyboardInputSource, kCFBooleanTrue, kCFBooleanTrue }; const void* values[] = { kTISCategoryKeyboardInputSource, kCFBooleanTrue, kCFBooleanTrue };
CFDictionaryRef dict = CFDictionaryCreate(NULL, (const void **)keys, (const void **)values, 3, NULL, NULL); CFDictionaryRef dict = CFDictionaryCreate(NULL, (const void **)keys, (const void **)values, 3, NULL, NULL);
@ -506,7 +507,7 @@ void UBPlatformUtils::initializeKeyboardLayouts()
QString ID = QStringFromStringRef(sr); QString ID = QStringFromStringRef(sr);
sr = (CFStringRef) TISGetInputSourceProperty(keyLayoutRef, kTISPropertyLocalizedName); sr = (CFStringRef) TISGetInputSourceProperty(keyLayoutRef, kTISPropertyLocalizedName);
QString fullName = QStringFromStringRef(sr); QString fullName = QString::fromUtf8([sr UTF8String], strlen([sr UTF8String]));
CFArrayRef langs = (CFArrayRef) TISGetInputSourceProperty(keyLayoutRef, kTISPropertyInputSourceLanguages); CFArrayRef langs = (CFArrayRef) TISGetInputSourceProperty(keyLayoutRef, kTISPropertyInputSourceLanguages);
@ -539,7 +540,7 @@ void UBPlatformUtils::initializeKeyboardLayouts()
for(int i=0; i<nKeyboardLayouts; i++) for(int i=0; i<nKeyboardLayouts; i++)
keyboardLayouts[i] = result[i]; keyboardLayouts[i] = result[i];
} }
[pool drain];
} }
void UBPlatformUtils::destroyKeyboardLayouts() void UBPlatformUtils::destroyKeyboardLayouts()
@ -548,7 +549,7 @@ void UBPlatformUtils::destroyKeyboardLayouts()
QString UBPlatformUtils::urlFromClipboard() QString UBPlatformUtils::urlFromClipboard()
{ {
QString qsRet; QString qsRet;
/* /*
// commented because Sankore crashes on Java Script. It seems to backends dependencies. // commented because Sankore crashes on Java Script. It seems to backends dependencies.
NSPasteboard* pPasteboard = [NSPasteboard pasteboardWithName:@"Apple CFPasteboard drag"]; NSPasteboard* pPasteboard = [NSPasteboard pasteboardWithName:@"Apple CFPasteboard drag"];
WebArchive* pArchive = [[WebArchive alloc] initWithData:[pPasteboard dataForType:@"com.apple.webarchive"]]; WebArchive* pArchive = [[WebArchive alloc] initWithData:[pPasteboard dataForType:@"com.apple.webarchive"]];

Loading…
Cancel
Save