|
|
@ -17,303 +17,303 @@ |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
|
|
UBKeyboardPalette |
|
|
|
UBKeyboardPalette |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
UBKeyboardPalette::UBKeyboardPalette(QWidget *parent) |
|
|
|
UBKeyboardPalette::UBKeyboardPalette(QWidget *parent) |
|
|
|
: UBFloatingPalette(Qt::TopRightCorner, parent) |
|
|
|
: UBFloatingPalette(Qt::TopRightCorner, parent) |
|
|
|
{ |
|
|
|
{ |
|
|
|
setCustomPosition(true); |
|
|
|
setCustomPosition(true); |
|
|
|
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); |
|
|
|
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); |
|
|
|
setFocusPolicy(Qt::NoFocus); |
|
|
|
setFocusPolicy(Qt::NoFocus); |
|
|
|
capsLock = false; |
|
|
|
capsLock = false; |
|
|
|
languagePopupActive = false; |
|
|
|
languagePopupActive = false; |
|
|
|
keyboardActive = false; |
|
|
|
keyboardActive = false; |
|
|
|
btnWidth = btnHeight = 16; |
|
|
|
btnWidth = btnHeight = 16; |
|
|
|
|
|
|
|
|
|
|
|
buttons = new UBKeyButton*[47]; |
|
|
|
buttons = new UBKeyButton*[47]; |
|
|
|
for(int i=0; i<47; i++) |
|
|
|
for (int i=0; i<47; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
buttons[i] = new UBKeyButton(this); |
|
|
|
buttons[i] = new UBKeyButton(this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
locales = UBPlatformUtils::getKeyboardLayouts(this->nLocalesCount); |
|
|
|
locales = UBPlatformUtils::getKeyboardLayouts(this->nLocalesCount); |
|
|
|
|
|
|
|
|
|
|
|
createCtrlButtons(); |
|
|
|
createCtrlButtons(); |
|
|
|
|
|
|
|
|
|
|
|
nCurrentLocale = 0; |
|
|
|
nCurrentLocale = 0; |
|
|
|
setInput(locales[nCurrentLocale]); |
|
|
|
setInput(locales[nCurrentLocale]); |
|
|
|
|
|
|
|
|
|
|
|
setContentsMargins(radius() + 15, 4, radius() + 15, 4); |
|
|
|
setContentsMargins(radius() + 15, 4, radius() + 15, 4); |
|
|
|
|
|
|
|
|
|
|
|
connect(this, SIGNAL(keyboardActivated(bool)), this, SLOT(onActivated(bool))); |
|
|
|
connect(this, SIGNAL(keyboardActivated(bool)), this, SLOT(onActivated(bool))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QList<UBKeyboardPalette*> UBKeyboardPalette::instances; |
|
|
|
QList<UBKeyboardPalette*> UBKeyboardPalette::instances; |
|
|
|
UBKeyboardPalette* UBKeyboardPalette::create(QWidget *parent) |
|
|
|
UBKeyboardPalette* UBKeyboardPalette::create(QWidget *parent) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!UBPlatformUtils::hasVirtualKeyboard()) |
|
|
|
if (!UBPlatformUtils::hasVirtualKeyboard()) |
|
|
|
return NULL; |
|
|
|
return NULL; |
|
|
|
|
|
|
|
|
|
|
|
UBKeyboardPalette* instance = new UBKeyboardPalette(parent); |
|
|
|
UBKeyboardPalette* instance = new UBKeyboardPalette(parent); |
|
|
|
instances.append(instance); |
|
|
|
instances.append(instance); |
|
|
|
|
|
|
|
|
|
|
|
instance->setKeyButtonSize(UBSettings::settings()->boardKeyboardPaletteKeyBtnSize->get().toString()); |
|
|
|
instance->setKeyButtonSize(UBSettings::settings()->boardKeyboardPaletteKeyBtnSize->get().toString()); |
|
|
|
instance->setAutoMinimize(UBSettings::settings()->boardKeyboardPaletteAutoMinimize->get().toBool()); |
|
|
|
instance->setAutoMinimize(UBSettings::settings()->boardKeyboardPaletteAutoMinimize->get().toBool()); |
|
|
|
instance->setVisible(false); |
|
|
|
instance->setVisible(false); |
|
|
|
connect(UBSettings::settings()->boardKeyboardPaletteAutoMinimize , SIGNAL(changed(QVariant)), instance, SLOT(keyboardPaletteAutoMinimizeChanged(QVariant))); |
|
|
|
connect(UBSettings::settings()->boardKeyboardPaletteAutoMinimize , SIGNAL(changed(QVariant)), instance, SLOT(keyboardPaletteAutoMinimizeChanged(QVariant))); |
|
|
|
connect(UBSettings::settings()->boardKeyboardPaletteKeyBtnSize, SIGNAL(changed(QVariant)), instance, SLOT(keyboardPaletteButtonSizeChanged(QVariant))); |
|
|
|
connect(UBSettings::settings()->boardKeyboardPaletteKeyBtnSize, SIGNAL(changed(QVariant)), instance, SLOT(keyboardPaletteButtonSizeChanged(QVariant))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach(UBKeyboardPalette* inst, instances) |
|
|
|
foreach(UBKeyboardPalette* inst, instances) |
|
|
|
{ |
|
|
|
{ |
|
|
|
connect(inst, SIGNAL(moved(const QPoint&)), instance, SLOT(syncPosition(const QPoint&))); |
|
|
|
connect(inst, SIGNAL(moved(const QPoint&)), instance, SLOT(syncPosition(const QPoint&))); |
|
|
|
connect(instance, SIGNAL(moved(const QPoint&)), inst, SLOT(syncPosition(const QPoint&))); |
|
|
|
connect(instance, SIGNAL(moved(const QPoint&)), inst, SLOT(syncPosition(const QPoint&))); |
|
|
|
|
|
|
|
|
|
|
|
connect(inst, SIGNAL(localeChanged(int)), instance, SLOT(syncLocale(int))); |
|
|
|
connect(inst, SIGNAL(localeChanged(int)), instance, SLOT(syncLocale(int))); |
|
|
|
connect(instance, SIGNAL(localeChanged(int)), inst, SLOT(syncLocale(int))); |
|
|
|
connect(instance, SIGNAL(localeChanged(int)), inst, SLOT(syncLocale(int))); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return instance; |
|
|
|
return instance; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBKeyboardPalette::syncPosition(const QPoint & pos) |
|
|
|
void UBKeyboardPalette::syncPosition(const QPoint & pos) |
|
|
|
{ |
|
|
|
{ |
|
|
|
move(pos); |
|
|
|
move(pos); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBKeyboardPalette::syncLocale(int nLocale) |
|
|
|
void UBKeyboardPalette::syncLocale(int nLocale) |
|
|
|
{ |
|
|
|
{ |
|
|
|
nCurrentLocale = nLocale; |
|
|
|
nCurrentLocale = nLocale; |
|
|
|
setInput(locales[nCurrentLocale]); |
|
|
|
setInput(locales[nCurrentLocale]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBKeyboardPalette::keyboardPaletteAutoMinimizeChanged(QVariant b) |
|
|
|
void UBKeyboardPalette::keyboardPaletteAutoMinimizeChanged(QVariant b) |
|
|
|
{ |
|
|
|
{ |
|
|
|
setAutoMinimize(b.toBool()); |
|
|
|
setAutoMinimize(b.toBool()); |
|
|
|
} |
|
|
|
} |
|
|
|
void UBKeyboardPalette::keyboardPaletteButtonSizeChanged(QVariant size) |
|
|
|
void UBKeyboardPalette::keyboardPaletteButtonSizeChanged(QVariant size) |
|
|
|
{ |
|
|
|
{ |
|
|
|
setKeyButtonSize(size.toString()); |
|
|
|
setKeyButtonSize(size.toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBKeyboardPalette::setInput(const UBKeyboardLocale* locale) |
|
|
|
void UBKeyboardPalette::setInput(const UBKeyboardLocale* locale) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (locale!=NULL) |
|
|
|
if (locale!=NULL) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for(int i=0; i<47; i++) |
|
|
|
for (int i=0; i<47; i++) |
|
|
|
buttons[i]->setKeyBt((*locale)[i]); |
|
|
|
buttons[i]->setKeyBt((*locale)[i]); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
this->hide(); |
|
|
|
this->hide(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBKeyboardPalette::~UBKeyboardPalette() |
|
|
|
UBKeyboardPalette::~UBKeyboardPalette() |
|
|
|
{ |
|
|
|
{ |
|
|
|
for(int i=0; i<47; i++) |
|
|
|
for (int i=0; i<47; i++) |
|
|
|
delete buttons[i]; |
|
|
|
delete buttons[i]; |
|
|
|
delete [] buttons; |
|
|
|
delete [] buttons; |
|
|
|
|
|
|
|
|
|
|
|
for(int i=0; i<8; i++) |
|
|
|
for (int i=0; i<8; i++) |
|
|
|
delete ctrlButtons[i]; |
|
|
|
delete ctrlButtons[i]; |
|
|
|
delete [] ctrlButtons; |
|
|
|
delete [] ctrlButtons; |
|
|
|
|
|
|
|
|
|
|
|
if (locales!=NULL) |
|
|
|
if (locales!=NULL) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for(int i=0; i<nLocalesCount; i++) |
|
|
|
for (int i=0; i<nLocalesCount; i++) |
|
|
|
delete locales[i]; |
|
|
|
delete locales[i]; |
|
|
|
delete [] locales; |
|
|
|
delete [] locales; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QSize UBKeyboardPalette::sizeHint () const |
|
|
|
QSize UBKeyboardPalette::sizeHint () const |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ((autoMinimize && keyboardActive) || !autoMinimize) |
|
|
|
if ((autoMinimize && keyboardActive) || !autoMinimize) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int w = contentsMargins().left() + contentsMargins().right() + 13 + 14.5 * btnWidth; |
|
|
|
int w = contentsMargins().left() + contentsMargins().right() + 13 + 14.5 * btnWidth; |
|
|
|
int h = contentsMargins().top() + contentsMargins().bottom() + 5 * btnHeight + 4; |
|
|
|
int h = contentsMargins().top() + contentsMargins().bottom() + 5 * btnHeight + 4; |
|
|
|
return QSize(w, h);
|
|
|
|
return QSize(w, h); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
int MIN_WITH = 4, |
|
|
|
int MIN_WITH = 4, |
|
|
|
MIN_HEIGTH = 4; |
|
|
|
MIN_HEIGTH = 4; |
|
|
|
int w = contentsMargins().left() + contentsMargins().right() + 13 + 14.5 * MIN_WITH; |
|
|
|
int w = contentsMargins().left() + contentsMargins().right() + 13 + 14.5 * MIN_WITH; |
|
|
|
int h = contentsMargins().top() + contentsMargins().bottom() + 5 * MIN_HEIGTH + 4; |
|
|
|
int h = contentsMargins().top() + contentsMargins().bottom() + 5 * MIN_HEIGTH + 4; |
|
|
|
return QSize(w, h);
|
|
|
|
return QSize(w, h); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const QString* UBKeyboardPalette::getLocaleName() |
|
|
|
const QString* UBKeyboardPalette::getLocaleName() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (locales==NULL) |
|
|
|
if (locales==NULL) |
|
|
|
return NULL; |
|
|
|
return NULL; |
|
|
|
return &(locales[nCurrentLocale]->name); |
|
|
|
return &(locales[nCurrentLocale]->name); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBKeyboardPalette::setLocale(int nLocale) |
|
|
|
void UBKeyboardPalette::setLocale(int nLocale) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (locales!=NULL) |
|
|
|
if (locales!=NULL) |
|
|
|
{ |
|
|
|
{ |
|
|
|
nCurrentLocale = nLocale; |
|
|
|
nCurrentLocale = nLocale; |
|
|
|
|
|
|
|
|
|
|
|
setInput(locales[nCurrentLocale]); |
|
|
|
setInput(locales[nCurrentLocale]); |
|
|
|
onLocaleChanged(locales[nCurrentLocale]); |
|
|
|
onLocaleChanged(locales[nCurrentLocale]); |
|
|
|
update(); |
|
|
|
update(); |
|
|
|
} |
|
|
|
} |
|
|
|
emit localeChanged(nLocale); |
|
|
|
emit localeChanged(nLocale); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBKeyboardPalette::setKeyButtonSize(const QString& strSize) |
|
|
|
void UBKeyboardPalette::setKeyButtonSize(const QString& strSize) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QStringList strs = strSize.split('x'); |
|
|
|
QStringList strs = strSize.split('x'); |
|
|
|
|
|
|
|
|
|
|
|
if (strs.size()==2) |
|
|
|
if (strs.size()==2) |
|
|
|
{ |
|
|
|
{ |
|
|
|
btnWidth = strs[0].toInt(); |
|
|
|
btnWidth = strs[0].toInt(); |
|
|
|
btnHeight = strs[1].toInt(); |
|
|
|
btnHeight = strs[1].toInt(); |
|
|
|
adjustSizeAndPosition(); |
|
|
|
adjustSizeAndPosition(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBKeyboardPalette::setAutoMinimize(bool autoMinimize) |
|
|
|
void UBKeyboardPalette::setAutoMinimize(bool autoMinimize) |
|
|
|
{ |
|
|
|
{ |
|
|
|
this->autoMinimize = autoMinimize; |
|
|
|
this->autoMinimize = autoMinimize; |
|
|
|
adjustSizeAndPosition(); |
|
|
|
adjustSizeAndPosition(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBKeyboardPalette::enterEvent ( QEvent * ) |
|
|
|
void UBKeyboardPalette::enterEvent ( QEvent * ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (keyboardActive) |
|
|
|
if (keyboardActive) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
keyboardActive = true; |
|
|
|
keyboardActive = true; |
|
|
|
|
|
|
|
|
|
|
|
adjustSizeAndPosition(); |
|
|
|
adjustSizeAndPosition(); |
|
|
|
|
|
|
|
|
|
|
|
emit keyboardActivated(true); |
|
|
|
emit keyboardActivated(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBKeyboardPalette::leaveEvent ( QEvent * ) |
|
|
|
void UBKeyboardPalette::leaveEvent ( QEvent * ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (languagePopupActive || !keyboardActive || mIsMoving) |
|
|
|
if (languagePopupActive || !keyboardActive || mIsMoving) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
keyboardActive = false; |
|
|
|
keyboardActive = false; |
|
|
|
|
|
|
|
|
|
|
|
adjustSizeAndPosition(); |
|
|
|
adjustSizeAndPosition(); |
|
|
|
|
|
|
|
|
|
|
|
emit keyboardActivated(false); |
|
|
|
emit keyboardActivated(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBKeyboardPalette::moveEvent ( QMoveEvent * event ) |
|
|
|
void UBKeyboardPalette::moveEvent ( QMoveEvent * event ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBFloatingPalette::moveEvent(event); |
|
|
|
UBFloatingPalette::moveEvent(event); |
|
|
|
emit moved(event->pos()); |
|
|
|
emit moved(event->pos()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBKeyboardPalette::adjustSizeAndPosition(bool pUp) |
|
|
|
void UBKeyboardPalette::adjustSizeAndPosition(bool pUp) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QSize rSize = sizeHint(); |
|
|
|
QSize rSize = sizeHint(); |
|
|
|
if (rSize != size()) |
|
|
|
if (rSize != size()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int dx = (rSize.width() - size().width()) /2; |
|
|
|
int dx = (rSize.width() - size().width()) /2; |
|
|
|
int dy = rSize.height() - size().height(); |
|
|
|
int dy = rSize.height() - size().height(); |
|
|
|
|
|
|
|
|
|
|
|
this->move(x()-dx, y() - dy); |
|
|
|
this->move(x()-dx, y() - dy); |
|
|
|
this->resize(rSize.width(), rSize.height()); |
|
|
|
this->resize(rSize.width(), rSize.height()); |
|
|
|
} |
|
|
|
} |
|
|
|
UBFloatingPalette::adjustSizeAndPosition(pUp); |
|
|
|
UBFloatingPalette::adjustSizeAndPosition(pUp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBKeyboardPalette::paintEvent( QPaintEvent* event) |
|
|
|
void UBKeyboardPalette::paintEvent( QPaintEvent* event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBFloatingPalette::paintEvent(event); |
|
|
|
UBFloatingPalette::paintEvent(event); |
|
|
|
|
|
|
|
|
|
|
|
QRect r = this->geometry(); |
|
|
|
QRect r = this->geometry(); |
|
|
|
|
|
|
|
|
|
|
|
int lleft, ltop, lright, lbottom; |
|
|
|
int lleft, ltop, lright, lbottom; |
|
|
|
getContentsMargins ( &lleft, <op, &lright, &lbottom ) ; |
|
|
|
getContentsMargins ( &lleft, <op, &lright, &lbottom ) ; |
|
|
|
|
|
|
|
|
|
|
|
int btw = (r.width() - lleft - lright - 13) / 14.5; |
|
|
|
int btw = (r.width() - lleft - lright - 13) / 14.5; |
|
|
|
int bth = (r.height() - ltop - lbottom -4) / 5; |
|
|
|
int bth = (r.height() - ltop - lbottom -4) / 5; |
|
|
|
|
|
|
|
|
|
|
|
lleft = (r.width() - (btw * 14.5 + 13))/2; |
|
|
|
lleft = (r.width() - (btw * 14.5 + 13))/2; |
|
|
|
ltop = (r.height() - (bth * 5 + 4)) / 2; |
|
|
|
ltop = (r.height() - (bth * 5 + 4)) / 2; |
|
|
|
|
|
|
|
|
|
|
|
int off = lleft;; |
|
|
|
int off = lleft;; |
|
|
|
for(int i = 0; i<13; i++) |
|
|
|
for (int i = 0; i<13; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QRect cr(off, ltop, btw, bth); |
|
|
|
QRect cr(off, ltop, btw, bth); |
|
|
|
buttons[i]->setGeometry(cr); |
|
|
|
buttons[i]->setGeometry(cr); |
|
|
|
off += btw + 1; |
|
|
|
off += btw + 1; |
|
|
|
} |
|
|
|
} |
|
|
|
ctrlButtons[0]->setGeometry(off, ltop, btw * 1.5, bth); |
|
|
|
ctrlButtons[0]->setGeometry(off, ltop, btw * 1.5, bth); |
|
|
|
off += btw * 1.5; |
|
|
|
off += btw * 1.5; |
|
|
|
lright = off; |
|
|
|
lright = off; |
|
|
|
|
|
|
|
|
|
|
|
ltop += bth + 1; |
|
|
|
ltop += bth + 1; |
|
|
|
int lwidth = 12 * btw + 12 + btw * 1.3; |
|
|
|
int lwidth = 12 * btw + 12 + btw * 1.3; |
|
|
|
off = (r.width() - lwidth) / 2; |
|
|
|
off = (r.width() - lwidth) / 2; |
|
|
|
ctrlButtons[1]->setGeometry(off, ltop, btw * 1.3, bth); |
|
|
|
ctrlButtons[1]->setGeometry(off, ltop, btw * 1.3, bth); |
|
|
|
off += btw * 1.3 + 1; |
|
|
|
off += btw * 1.3 + 1; |
|
|
|
for(int i=0; i<12; i++) |
|
|
|
for (int i=0; i<12; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QRect cr(off, ltop, btw, bth); |
|
|
|
QRect cr(off, ltop, btw, bth); |
|
|
|
buttons[13 + i]->setGeometry(cr); |
|
|
|
buttons[13 + i]->setGeometry(cr); |
|
|
|
off += btw + 1; |
|
|
|
off += btw + 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ltop += bth + 1; |
|
|
|
ltop += bth + 1; |
|
|
|
lwidth = 12 * btw + 12 + btw * 2; |
|
|
|
lwidth = 12 * btw + 12 + btw * 2; |
|
|
|
off = (r.width() - lwidth) / 2; |
|
|
|
off = (r.width() - lwidth) / 2; |
|
|
|
for(int i=0; i<12; i++) |
|
|
|
for (int i=0; i<12; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QRect cr(off, ltop, btw, bth); |
|
|
|
QRect cr(off, ltop, btw, bth); |
|
|
|
buttons[13 + 12 + i]->setGeometry(cr); |
|
|
|
buttons[13 + 12 + i]->setGeometry(cr); |
|
|
|
off += btw + 1; |
|
|
|
off += btw + 1; |
|
|
|
} |
|
|
|
} |
|
|
|
ctrlButtons[2]->setGeometry(off, ltop, btw * 2, bth); |
|
|
|
ctrlButtons[2]->setGeometry(off, ltop, btw * 2, bth); |
|
|
|
|
|
|
|
|
|
|
|
ltop += bth + 1; |
|
|
|
ltop += bth + 1; |
|
|
|
lwidth = 12 * btw + 11; |
|
|
|
lwidth = 12 * btw + 11; |
|
|
|
off = (r.width() - lwidth) / 2; |
|
|
|
off = (r.width() - lwidth) / 2; |
|
|
|
ctrlButtons[3]->setGeometry(off, ltop, btw, bth); |
|
|
|
ctrlButtons[3]->setGeometry(off, ltop, btw, bth); |
|
|
|
off+=btw+1; |
|
|
|
off+=btw+1; |
|
|
|
for(int i=0; i<10; i++) |
|
|
|
for (int i=0; i<10; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QRect cr(off, ltop, btw, bth); |
|
|
|
QRect cr(off, ltop, btw, bth); |
|
|
|
buttons[13 + 12 + 12 + i]->setGeometry(cr); |
|
|
|
buttons[13 + 12 + 12 + i]->setGeometry(cr); |
|
|
|
off += btw + 1; |
|
|
|
off += btw + 1; |
|
|
|
} |
|
|
|
} |
|
|
|
ctrlButtons[4]->setGeometry(r.x() + off, ltop, btw, bth); |
|
|
|
ctrlButtons[4]->setGeometry(r.x() + off, ltop, btw, bth); |
|
|
|
|
|
|
|
|
|
|
|
ltop += bth + 1; |
|
|
|
ltop += bth + 1; |
|
|
|
lwidth = 11 * btw + 2; |
|
|
|
lwidth = 11 * btw + 2; |
|
|
|
off = (r.width() - lwidth) / 2; |
|
|
|
off = (r.width() - lwidth) / 2; |
|
|
|
ctrlButtons[5]->setGeometry(off, ltop, btw, bth); |
|
|
|
ctrlButtons[5]->setGeometry(off, ltop, btw, bth); |
|
|
|
ctrlButtons[6]->setGeometry(off + btw + 1, ltop, btw*9, bth); |
|
|
|
ctrlButtons[6]->setGeometry(off + btw + 1, ltop, btw*9, bth); |
|
|
|
ctrlButtons[7]->setGeometry(off + btw*10 + 2, ltop, btw, bth); |
|
|
|
ctrlButtons[7]->setGeometry(off + btw*10 + 2, ltop, btw, bth); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
|
|
UBKeyboardButton |
|
|
|
UBKeyboardButton |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
UBKeyboardButton::UBKeyboardButton(UBKeyboardPalette* parent) |
|
|
|
UBKeyboardButton::UBKeyboardButton(UBKeyboardPalette* parent) |
|
|
|
:QWidget(parent),
|
|
|
|
:QWidget(parent), |
|
|
|
bFocused(false), |
|
|
|
keyboard(parent), |
|
|
|
bPressed(false), |
|
|
|
bFocused(false), |
|
|
|
keyboard(parent) |
|
|
|
bPressed(false) |
|
|
|
{ |
|
|
|
{ |
|
|
|
setCursor(Qt::PointingHandCursor); |
|
|
|
setCursor(Qt::PointingHandCursor); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBKeyboardButton::~UBKeyboardButton() |
|
|
|
UBKeyboardButton::~UBKeyboardButton() |
|
|
@ -321,48 +321,48 @@ UBKeyboardButton::~UBKeyboardButton() |
|
|
|
|
|
|
|
|
|
|
|
void UBKeyboardButton::paintEvent(QPaintEvent*) |
|
|
|
void UBKeyboardButton::paintEvent(QPaintEvent*) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QPainter painter(this); |
|
|
|
QPainter painter(this); |
|
|
|
|
|
|
|
|
|
|
|
if (bPressed) |
|
|
|
if (bPressed) |
|
|
|
painter.setBrush(QBrush(QColor(0, 0xcc, 0))); |
|
|
|
painter.setBrush(QBrush(QColor(0, 0xcc, 0))); |
|
|
|
else if (bFocused) |
|
|
|
else if (bFocused) |
|
|
|
painter.setBrush(QBrush(QColor(0xcc, 0, 0))); |
|
|
|
painter.setBrush(QBrush(QColor(0xcc, 0, 0))); |
|
|
|
|
|
|
|
|
|
|
|
painter.drawRoundedRect(0, 0, width()-1, height()-1, 3, 3); |
|
|
|
painter.drawRoundedRect(0, 0, width()-1, height()-1, 3, 3); |
|
|
|
|
|
|
|
|
|
|
|
this->paintContent(painter); |
|
|
|
this->paintContent(painter); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBKeyboardButton::enterEvent ( QEvent*) |
|
|
|
void UBKeyboardButton::enterEvent ( QEvent*) |
|
|
|
{ |
|
|
|
{ |
|
|
|
bFocused = true; |
|
|
|
bFocused = true; |
|
|
|
update(); |
|
|
|
update(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBKeyboardButton::leaveEvent ( QEvent*) |
|
|
|
void UBKeyboardButton::leaveEvent ( QEvent*) |
|
|
|
{ |
|
|
|
{ |
|
|
|
bFocused = false; |
|
|
|
bFocused = false; |
|
|
|
update(); |
|
|
|
update(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBKeyboardButton::mousePressEvent ( QMouseEvent * event) |
|
|
|
void UBKeyboardButton::mousePressEvent ( QMouseEvent * event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
event->accept(); |
|
|
|
event->accept(); |
|
|
|
bPressed = true; |
|
|
|
bPressed = true; |
|
|
|
update(); |
|
|
|
update(); |
|
|
|
this->onPress(); |
|
|
|
this->onPress(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBKeyboardButton::mouseReleaseEvent ( QMouseEvent * ) |
|
|
|
void UBKeyboardButton::mouseReleaseEvent ( QMouseEvent * ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
bPressed = false; |
|
|
|
bPressed = false; |
|
|
|
update(); |
|
|
|
update(); |
|
|
|
this->onRelease(); |
|
|
|
this->onRelease(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBKeyButton::UBKeyButton(UBKeyboardPalette* parent) |
|
|
|
UBKeyButton::UBKeyButton(UBKeyboardPalette* parent) |
|
|
|
:UBKeyboardButton(parent), |
|
|
|
:UBKeyboardButton(parent), |
|
|
|
keybt(0) |
|
|
|
keybt(0) |
|
|
|
{} |
|
|
|
{} |
|
|
|
|
|
|
|
|
|
|
|
UBKeyButton::~UBKeyButton() |
|
|
|
UBKeyButton::~UBKeyButton() |
|
|
@ -370,8 +370,8 @@ UBKeyButton::~UBKeyButton() |
|
|
|
|
|
|
|
|
|
|
|
void UBKeyButton::onPress() |
|
|
|
void UBKeyButton::onPress() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (keybt!=NULL) |
|
|
|
if (keybt!=NULL) |
|
|
|
sendUnicodeSymbol(keybt->code1, keybt->code2, capsLock()); |
|
|
|
sendUnicodeSymbol(keybt->code1, keybt->code2, capsLock()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBKeyButton::onRelease() |
|
|
|
void UBKeyButton::onRelease() |
|
|
@ -380,19 +380,19 @@ void UBKeyButton::onRelease() |
|
|
|
void UBKeyButton::paintContent(QPainter& painter) |
|
|
|
void UBKeyButton::paintContent(QPainter& painter) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
if (keybt) |
|
|
|
if (keybt) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QString text(QChar(capsLock() ? keybt->symbol2 : keybt->symbol1)); |
|
|
|
QString text(QChar(capsLock() ? keybt->symbol2 : keybt->symbol1)); |
|
|
|
QRect textRect(rect().x()+2, rect().y()+2, rect().width()-4, rect().height()-4); |
|
|
|
QRect textRect(rect().x()+2, rect().y()+2, rect().width()-4, rect().height()-4); |
|
|
|
painter.drawText(textRect, Qt::AlignCenter, text); |
|
|
|
painter.drawText(textRect, Qt::AlignCenter, text); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBCntrlButton::UBCntrlButton(UBKeyboardPalette* parent, const QString& _label, int _code ) |
|
|
|
UBCntrlButton::UBCntrlButton(UBKeyboardPalette* parent, const QString& _label, int _code ) |
|
|
|
:UBKeyboardButton(parent), |
|
|
|
:UBKeyboardButton(parent), |
|
|
|
label(_label), |
|
|
|
label(_label), |
|
|
|
code(_code) |
|
|
|
code(_code) |
|
|
|
{} |
|
|
|
{} |
|
|
|
|
|
|
|
|
|
|
|
UBCntrlButton::~UBCntrlButton() |
|
|
|
UBCntrlButton::~UBCntrlButton() |
|
|
@ -400,7 +400,7 @@ UBCntrlButton::~UBCntrlButton() |
|
|
|
|
|
|
|
|
|
|
|
void UBCntrlButton::onPress() |
|
|
|
void UBCntrlButton::onPress() |
|
|
|
{ |
|
|
|
{ |
|
|
|
sendControlSymbol(code); |
|
|
|
sendControlSymbol(code); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBCntrlButton::onRelease() |
|
|
|
void UBCntrlButton::onRelease() |
|
|
@ -408,11 +408,11 @@ void UBCntrlButton::onRelease() |
|
|
|
|
|
|
|
|
|
|
|
void UBCntrlButton::paintContent(QPainter& painter) |
|
|
|
void UBCntrlButton::paintContent(QPainter& painter) |
|
|
|
{ |
|
|
|
{ |
|
|
|
painter.drawText(rect(), Qt::AlignCenter, label); |
|
|
|
painter.drawText(rect(), Qt::AlignCenter, label); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBCapsLockButton::UBCapsLockButton(UBKeyboardPalette* parent) |
|
|
|
UBCapsLockButton::UBCapsLockButton(UBKeyboardPalette* parent) |
|
|
|
:UBKeyboardButton(parent) |
|
|
|
:UBKeyboardButton(parent) |
|
|
|
{} |
|
|
|
{} |
|
|
|
|
|
|
|
|
|
|
|
UBCapsLockButton::~UBCapsLockButton() |
|
|
|
UBCapsLockButton::~UBCapsLockButton() |
|
|
@ -420,8 +420,8 @@ UBCapsLockButton::~UBCapsLockButton() |
|
|
|
|
|
|
|
|
|
|
|
void UBCapsLockButton::onPress() |
|
|
|
void UBCapsLockButton::onPress() |
|
|
|
{ |
|
|
|
{ |
|
|
|
keyboard->capsLock = !keyboard->capsLock; |
|
|
|
keyboard->capsLock = !keyboard->capsLock; |
|
|
|
keyboard->update(); |
|
|
|
keyboard->update(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBCapsLockButton::onRelease() |
|
|
|
void UBCapsLockButton::onRelease() |
|
|
@ -429,27 +429,27 @@ void UBCapsLockButton::onRelease() |
|
|
|
|
|
|
|
|
|
|
|
void UBCapsLockButton::paintContent(QPainter& painter) |
|
|
|
void UBCapsLockButton::paintContent(QPainter& painter) |
|
|
|
{ |
|
|
|
{ |
|
|
|
painter.drawText(rect(), Qt::AlignCenter, "^"); |
|
|
|
painter.drawText(rect(), Qt::AlignCenter, "^"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBLocaleButton::UBLocaleButton(UBKeyboardPalette* parent) |
|
|
|
UBLocaleButton::UBLocaleButton(UBKeyboardPalette* parent) |
|
|
|
:UBKeyboardButton(parent) |
|
|
|
:UBKeyboardButton(parent) |
|
|
|
{ |
|
|
|
{ |
|
|
|
localeMenu = new QMenu(this); |
|
|
|
localeMenu = new QMenu(this); |
|
|
|
|
|
|
|
|
|
|
|
for(int i=0; i<parent->nLocalesCount; i++) |
|
|
|
for (int i=0; i<parent->nLocalesCount; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QAction* action = (parent->locales[i]->icon!=NULL) ?
|
|
|
|
QAction* action = (parent->locales[i]->icon!=NULL) ? |
|
|
|
localeMenu->addAction(*parent->locales[i]->icon, parent->locales[i]->fullName) |
|
|
|
localeMenu->addAction(*parent->locales[i]->icon, parent->locales[i]->fullName) |
|
|
|
: localeMenu->addAction(parent->locales[i]->fullName); |
|
|
|
: localeMenu->addAction(parent->locales[i]->fullName); |
|
|
|
action->setData(QVariant(i)); |
|
|
|
action->setData(QVariant(i)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBLocaleButton::~UBLocaleButton() |
|
|
|
UBLocaleButton::~UBLocaleButton() |
|
|
|
{ |
|
|
|
{ |
|
|
|
delete localeMenu; |
|
|
|
delete localeMenu; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBLocaleButton::onPress() |
|
|
|
void UBLocaleButton::onPress() |
|
|
@ -458,19 +458,19 @@ void UBLocaleButton::onPress() |
|
|
|
|
|
|
|
|
|
|
|
void UBLocaleButton::onRelease() |
|
|
|
void UBLocaleButton::onRelease() |
|
|
|
{ |
|
|
|
{ |
|
|
|
keyboard->languagePopupActive = true; |
|
|
|
keyboard->languagePopupActive = true; |
|
|
|
QAction* action = localeMenu->exec(mapToGlobal(QPoint(0,0))); |
|
|
|
QAction* action = localeMenu->exec(mapToGlobal(QPoint(0,0))); |
|
|
|
keyboard->languagePopupActive = false; |
|
|
|
keyboard->languagePopupActive = false; |
|
|
|
if (action!=NULL) |
|
|
|
if (action!=NULL) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int nLocale = action->data().toInt(); |
|
|
|
int nLocale = action->data().toInt(); |
|
|
|
keyboard->setLocale(nLocale); |
|
|
|
keyboard->setLocale(nLocale); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBLocaleButton::paintContent(QPainter& painter) |
|
|
|
void UBLocaleButton::paintContent(QPainter& painter) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const QString* localeName = keyboard->getLocaleName(); |
|
|
|
const QString* localeName = keyboard->getLocaleName(); |
|
|
|
if (localeName!=NULL) |
|
|
|
if (localeName!=NULL) |
|
|
|
painter.drawText(rect(), Qt::AlignCenter, *localeName); |
|
|
|
painter.drawText(rect(), Qt::AlignCenter, *localeName); |
|
|
|
} |
|
|
|
} |
|
|
|