Commit 3901cc01 authored by Anatoly Mihalchenko's avatar Anatoly Mihalchenko

OSK - design integration

parent 31d36e64
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -289,5 +289,27 @@
<file>images/toolbar/hide.png</file>
<file>images/toolbar/record.png</file>
<file>images/libpalette/MoviesCategory.svg</file>
<file>images/virtual.keyboard/41/centre-passive.png</file>
<file>images/virtual.keyboard/41/left-passive.png</file>
<file>images/virtual.keyboard/41/right-passive.png</file>
<file>images/virtual.keyboard/41/centre-active.png</file>
<file>images/virtual.keyboard/41/left-active.png</file>
<file>images/virtual.keyboard/41/right-active.png</file>
<file>images/virtual.keyboard/41/backspace.png</file>
<file>images/virtual.keyboard/41/capslock.png</file>
<file>images/virtual.keyboard/41/tab.png</file>
<file>images/virtual.keyboard/29/centre-passive.png</file>
<file>images/virtual.keyboard/29/left-passive.png</file>
<file>images/virtual.keyboard/29/right-passive.png</file>
<file>images/virtual.keyboard/29/centre-active.png</file>
<file>images/virtual.keyboard/29/left-active.png</file>
<file>images/virtual.keyboard/29/right-active.png</file>
<file>images/virtual.keyboard/29/backspace.png</file>
<file>images/virtual.keyboard/29/capslock.png</file>
<file>images/virtual.keyboard/29/tab.png</file>
</qresource>
</RCC>
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* UBBoardPaletteManager.cpp
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* Created on: 3 nov. 2009
* Author: Luc
*/
#include "UBBoardPaletteManager.h"
......@@ -132,7 +124,10 @@ void UBBoardPaletteManager::setupPalettes()
mStylusPalette->show(); // always show stylus palette at startup
if (UBPlatformUtils::hasVirtualKeyboard())
{
mKeyboardPalette = UBKeyboardPalette::create(0);
mKeyboardPalette->setParent(mContainer);
}
mZoomPalette = new UBZoomPalette(mContainer);
......@@ -647,8 +642,8 @@ void UBBoardPaletteManager::panButtonReleased()
void UBBoardPaletteManager::showVirtualKeyboard(bool show)
{
if (mKeyboardPalette)
mKeyboardPalette->setVisible(show);
if (mKeyboardPalette)
mKeyboardPalette->setVisible(show);
}
void UBBoardPaletteManager::changeStylusPaletteOrientation(QVariant var)
......
......@@ -106,10 +106,8 @@ void UBPreferencesController::wire()
// OSK preferences
mPreferencesUI->keyboardPaletteKeyButtonSize->addItem("16x16");
mPreferencesUI->keyboardPaletteKeyButtonSize->addItem("24x24");
mPreferencesUI->keyboardPaletteKeyButtonSize->addItem("32x32");
connect(mPreferencesUI->keyboardPaletteAutoMinimize, SIGNAL(clicked(bool)), settings->boardKeyboardPaletteAutoMinimize, SLOT(setBool(bool)));
mPreferencesUI->keyboardPaletteKeyButtonSize->addItem("29x29");
mPreferencesUI->keyboardPaletteKeyButtonSize->addItem("41x41");
connect(mPreferencesUI->keyboardPaletteKeyButtonSize, SIGNAL(currentIndexChanged(const QString &)), settings->boardKeyboardPaletteKeyBtnSize, SLOT(setString(const QString &)));
......@@ -169,7 +167,6 @@ void UBPreferencesController::init()
mPreferencesUI->checkSoftwareUpdateAtLaunchCheckBox->setChecked(settings->appEnableAutomaticSoftwareUpdates->get().toBool());
// display tab
mPreferencesUI->keyboardPaletteAutoMinimize->setChecked(settings->boardKeyboardPaletteAutoMinimize->get().toBool());
for(int i=0; i<mPreferencesUI->keyboardPaletteKeyButtonSize->count(); i++)
if (mPreferencesUI->keyboardPaletteKeyButtonSize->itemText(i) ==
settings->boardKeyboardPaletteKeyBtnSize->get().toString())
......
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* UBSettings.cpp
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* Created on: Oct 29, 2008
* Author: luc
*/
#include "UBSettings.h"
......@@ -198,7 +191,7 @@ void UBSettings::init()
boardUseHighResTabletEvent = new UBSetting(this, "Board", "UseHighResTabletEvent", true);
boardKeyboardPaletteAutoMinimize = new UBSetting(this, "Board", "KeyboardPaletteAutoMinimize", true);
// boardKeyboardPaletteAutoMinimize = new UBSetting(this, "Board", "KeyboardPaletteAutoMinimize", true);
boardKeyboardPaletteKeyBtnSize = new UBSetting(this, "Board", "KeyboardPaletteKeyBtnSize", "24x24");
QStringList penLightBackgroundColors;
......
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* UBSettings.h
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* Created on: Oct 29, 2008
* Author: luc
*/
#ifndef UBSETTINGS_H_
......@@ -236,7 +228,7 @@ class UBSettings : public QObject
UBSetting* boardUseHighResTabletEvent;
UBSetting* boardKeyboardPaletteAutoMinimize;
// UBSetting* boardKeyboardPaletteAutoMinimize;
UBSetting* boardKeyboardPaletteKeyBtnSize;
UBColorListSetting* boardPenLightBackgroundColors;
......
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* UNWindowController.cpp
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* Created on: Jan 15, 2009
* Author: julienbachmann
*/
#include <QDesktopWidget>
......@@ -65,6 +57,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
, mbArrowClicked(false)
, mBoardStylusTool(UBStylusTool::Pen)
, mDesktopStylusTool(UBStylusTool::Selector)
, mKeyboardPalette(0)
{
mTransparentDrawingView = new UBBoardView(UBApplication::boardController, 0); // deleted in UBDesktopAnnotationController::destructor
......@@ -92,12 +85,21 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
mDesktopPalette = new UBDesktopPalette(mTransparentDrawingView);
if (UBPlatformUtils::hasVirtualKeyboard())
{
mKeyboardPalette = UBKeyboardPalette::create(mTransparentDrawingView);
//mKeyboardPalette->setParent(mTransparentDrawingView);
}
connect(mDesktopPalette, SIGNAL(uniboardClick()), this, SLOT(goToUniboard()));
connect(mDesktopPalette, SIGNAL(customClick()), this, SLOT(customCapture()));
connect(mDesktopPalette, SIGNAL(windowClick()), this, SLOT(windowCapture()));
connect(mDesktopPalette, SIGNAL(screenClick()), this, SLOT(screenCapture()));
connect(mDesktopPalette, SIGNAL(maximized()), this, SLOT(onDesktopPaletteMaximized()));
connect(mDesktopPalette, SIGNAL(minimizeStart(eMinimizedLocation)), this, SLOT(onDesktopPaletteMinimize()));
connect(UBApplication::mainWindow->actionVirtualKeyboard, SIGNAL(triggered(bool)), this, SLOT(showKeyboard(bool)));
// connect(mDesktopPalette, SIGNAL(showVirtualKeyboard(bool)), this, SLOT());
connect(mTransparentDrawingView, SIGNAL(resized(QResizeEvent*)), this, SLOT(onTransparentWidgetResized()));
......@@ -143,6 +145,13 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
onDesktopPaletteMaximized();
}
void UBDesktopAnnotationController::showKeyboard(bool show)
{
mKeyboardPalette->setVisible(show);
// mDesktopPalette->showVirtualKeyboard(show);
}
UBDesktopAnnotationController::~UBDesktopAnnotationController()
{
delete mTransparentDrawingScene;
......
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* UNWindowController.h
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* Created on: Jan 15, 2009
* Author: julienbachmann
*/
#ifndef UBUNINOTESWINDOWCONTROLLER_H_
......@@ -70,6 +62,8 @@ class UBDesktopAnnotationController : public QObject
void stylusToolChanged(int tool);
void updateBackground();
void showKeyboard(bool show);
signals:
/**
* This signal is emitted once the screenshot has been performed. This signal is also emitted when user
......@@ -106,6 +100,7 @@ class UBDesktopAnnotationController : public QObject
void togglePropertyPalette(UBActionPalette* palette);
UBDesktopPalette *mDesktopPalette;
UBKeyboardPalette *mKeyboardPalette;
UBDesktopToolsPalette *mDesktopToolsPalette;
UBDesktopPenPalette* mDesktopPenPalette;
UBDesktopMarkerPalette* mDesktopMarkerPalette;
......
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* UBDesktopPalette.cpp
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* Created on: Jan 9, 2009
* Author: julienbachmann
*/
#include "UBDesktopPalette.h"
......@@ -49,12 +41,8 @@ UBDesktopPalette::UBDesktopPalette(QWidget *parent)
#endif
actions << UBApplication::mainWindow->actionPointer;
if (UBPlatformUtils::hasVirtualKeyboard())
{
actions << UBApplication::mainWindow->actionVirtualKeyboard;
connect(UBApplication::mainWindow->actionVirtualKeyboard, SIGNAL(toggled(bool)), this, SIGNAL(showVirtualKeyboard(bool)));
}
mActionCustomSelect = new QAction(QIcon(":/images/toolbar/captureArea.png"), tr("Capture Part of the Screen"), this);
connect(mActionCustomSelect, SIGNAL(triggered()), this, SIGNAL(customClick()));
......
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* UNWindow.h
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* Created on: Jan 9, 2009
* Author: julienbachmann
*/
#ifndef UBUNINOTESWINDOW_H_
......@@ -41,7 +33,7 @@ class UBDesktopPalette : public UBActionPalette
void customClick();
void windowClick();
void screenClick();
void showVirtualKeyboard(bool);
// void showVirtualKeyboard(bool);
public slots:
......
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* UBActionPalette.cpp
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* Created on: 8 oct. 2009
* Author: Luc
*/
#include "UBActionPalette.h"
......@@ -48,6 +40,8 @@ UBActionPalette::UBActionPalette(Qt::Corner corner, QWidget * parent, Qt::Orient
void UBActionPalette::init(Qt::Orientation orientation)
{
m_customCloseProcessing = false;
mButtonSize = QSize(32, 32);
mIsClosable = false;
mAutoClose = false;
......@@ -174,7 +168,7 @@ void UBActionPalette::updateLayout()
, sLayoutContentMargin + border(), sLayoutContentMargin + border());
}
update();
update();
}
......@@ -209,7 +203,9 @@ void UBActionPalette::paintEvent(QPaintEvent *event)
void UBActionPalette::close()
{
hide();
if(!m_customCloseProcessing)
hide();
emit closed();
}
......@@ -240,17 +236,18 @@ void UBActionPalette::clearLayout()
QLayout* pLayout = layout();
if(NULL != pLayout)
{
while(!pLayout->isEmpty())
{
QLayoutItem* pItem = pLayout->itemAt(0);
QWidget* pW = pItem->widget();
pLayout->removeItem(pItem);
delete pItem;
pLayout->removeWidget(pW);
delete pW;
}
mActions.clear();
mButtons.clear();
while(!pLayout->isEmpty())
{
QLayoutItem* pItem = pLayout->itemAt(0);
QWidget* pW = pItem->widget();
pLayout->removeItem(pItem);
delete pItem;
pLayout->removeWidget(pW);
delete pW;
}
mActions.clear();
mButtons.clear();
}
}
......
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* UBActionPalette.h
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* Created on: 8 oct. 2009
* Author: Luc
*/
#ifndef UBACTIONPALETTE_H_
......@@ -48,6 +40,13 @@ class UBActionPalette : public UBFloatingPalette
{
mAutoClose = autoClose;
}
void setCustomCloseProcessing(bool customCloseProcessing)
{
m_customCloseProcessing = customCloseProcessing;
}
bool m_customCloseProcessing;
virtual int border();
void clearLayout();
QSize buttonSize();
......
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QtGui>
#include <QPainterPath>
......@@ -56,6 +42,12 @@ UBFloatingPalette::UBFloatingPalette(Qt::Corner position, QWidget *parent)
mbGrip = true;
}
void UBFloatingPalette::setGrip(bool newGrip)
{
mbGrip = newGrip;
update();
}
void UBFloatingPalette::setBackgroundBrush(const QBrush& brush)
{
......@@ -157,7 +149,7 @@ void UBFloatingPalette::moveInsideParent(const QPoint &position)
}
}
move(newX, newY);
minimizePalette(QPoint(newX, newY));
minimizePalette(QPoint(newX, newY));
}
else
{
......
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBFLOATINGPALLETTE_H_
......@@ -55,6 +41,8 @@ class UBFloatingPalette : public QWidget
QSize preferredSize();
void setBackgroundBrush(const QBrush& brush);
void setGrip(bool newGrip);
void setMinimizePermission(bool permission);
protected:
......
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* UBKeyboardPalette.cpp
*
* Created on: Feb 10, 2011
* Author: tolik
*/
#include <QtGui>
#include <QList>
......@@ -21,6 +12,8 @@
#include "UBKeyboardPalette.h"
#include "core/UBSettings.h"
#include "core/UBApplication.h"
#include "gui/UBMainWindow.h"
#include "core/memcheck.h"
......@@ -29,16 +22,24 @@
UBKeyboardPalette
*/
UBKeyboardPalette::UBKeyboardPalette(QWidget *parent)
: UBFloatingPalette(Qt::TopRightCorner, parent)
: UBActionPalette(Qt::TopRightCorner, parent)
{
setCustomCloseProcessing(true);
setCustomPosition(true);
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
setFocusPolicy(Qt::NoFocus);
setClosable(true);
setGrip(false);
capsLock = false;
languagePopupActive = false;
keyboardActive = false;
btnWidth = btnHeight = 16;
strSize = "16x16";
currBtnImages = new BTNImages("16", btnWidth, btnHeight);
buttons = new UBKeyButton*[47];
for (int i=0; i<47; i++)
......@@ -53,7 +54,7 @@ UBKeyboardPalette::UBKeyboardPalette(QWidget *parent)
nCurrentLocale = 0;
setInput(locales[nCurrentLocale]);
setContentsMargins(radius() + 15, 4, radius() + 15, 4);
setContentsMargins( 22, 22, 22, 22 );
connect(this, SIGNAL(keyboardActivated(bool)), this, SLOT(onActivated(bool)));
}
......@@ -66,12 +67,12 @@ UBKeyboardPalette* UBKeyboardPalette::create(QWidget *parent)
UBKeyboardPalette* instance = new UBKeyboardPalette(parent);
instances.append(instance);
instance->setKeyButtonSize(UBSettings::settings()->boardKeyboardPaletteKeyBtnSize->get().toString());
instance->setAutoMinimize(UBSettings::settings()->boardKeyboardPaletteAutoMinimize->get().toBool());
instance->setVisible(false);
connect(UBSettings::settings()->boardKeyboardPaletteAutoMinimize , SIGNAL(changed(QVariant)), instance, SLOT(keyboardPaletteAutoMinimizeChanged(QVariant)));
connect(UBSettings::settings()->boardKeyboardPaletteKeyBtnSize, SIGNAL(changed(QVariant)), instance, SLOT(keyboardPaletteButtonSizeChanged(QVariant)));
connect(instance, SIGNAL(closed()), instance, SLOT(hideKeyboard()));
foreach(UBKeyboardPalette* inst, instances)
......@@ -82,11 +83,17 @@ UBKeyboardPalette* UBKeyboardPalette::create(QWidget *parent)
connect(inst, SIGNAL(localeChanged(int)), instance, SLOT(syncLocale(int)));
connect(instance, SIGNAL(localeChanged(int)), inst, SLOT(syncLocale(int)));
// connect(instance, SIGNAL(closed()), inst, )
}
return instance;
}
void UBKeyboardPalette::hideKeyboard()
{
UBApplication::mainWindow->actionVirtualKeyboard->activate(QAction.Trigger);
}
void UBKeyboardPalette::syncPosition(const QPoint & pos)
{
move(pos);
......@@ -98,10 +105,6 @@ void UBKeyboardPalette::syncLocale(int nLocale)
setInput(locales[nCurrentLocale]);
}
void UBKeyboardPalette::keyboardPaletteAutoMinimizeChanged(QVariant b)
{
setAutoMinimize(b.toBool());
}
void UBKeyboardPalette::keyboardPaletteButtonSizeChanged(QVariant size)
{
setKeyButtonSize(size.toString());
......@@ -122,12 +125,12 @@ void UBKeyboardPalette::setInput(const UBKeyboardLocale* locale)
UBKeyboardPalette::~UBKeyboardPalette()
{
//for (int i=0; i<47; i++)
// delete buttons[i];
for (int i=0; i<47; i++)
delete buttons[i];
delete [] buttons;
//for (int i=0; i<8; i++)
// delete ctrlButtons[i];
for (int i=0; i<8; i++)
delete ctrlButtons[i];
delete [] ctrlButtons;
if (locales!=NULL)
......@@ -136,36 +139,29 @@ UBKeyboardPalette::~UBKeyboardPalette()
delete locales[i];
delete [] locales;
}
if(currBtnImages != NULL)
{
delete currBtnImages;
currBtnImages = NULL;
}
}
QSize UBKeyboardPalette::sizeHint () const
{
if ((autoMinimize && keyboardActive) || !autoMinimize)
{
int w = contentsMargins().left() + contentsMargins().right() + 13 + 14.5 * btnWidth;
int h = contentsMargins().top() + contentsMargins().bottom() + 5 * btnHeight + 4;
return QSize(w, h);
}
else
{
int MIN_WITH = 4,
MIN_HEIGTH = 4;
int w = contentsMargins().left() + contentsMargins().right() + 13 + 14.5 * MIN_WITH;
int h = contentsMargins().top() + contentsMargins().bottom() + 5 * MIN_HEIGTH + 4;
return QSize(w, h);
}
int w = contentsMargins().left() + 15 * btnWidth + contentsMargins().right();
int h = contentsMargins().top() + 5 * btnHeight + contentsMargins().bottom();
return QSize(w, h);
}
const QString* UBKeyboardPalette::getLocaleName()
{
if (locales==NULL)
return NULL;
return &(locales[nCurrentLocale]->name);
return locales == NULL ? NULL : &(locales[nCurrentLocale]->name);
}
void UBKeyboardPalette::setLocale(int nLocale)
{
if (locales!=NULL)
if (locales != NULL)
{
nCurrentLocale = nLocale;
......@@ -176,26 +172,24 @@ void UBKeyboardPalette::setLocale(int 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)
{
strSize = _strSize;
btnWidth = strs[0].toInt();
btnHeight = strs[1].toInt();
adjustSizeAndPosition();
}
}
if(currBtnImages != NULL)
delete currBtnImages;
currBtnImages = new BTNImages(strs[1], btnWidth, btnHeight);
void UBKeyboardPalette::setAutoMinimize(bool autoMinimize)
{
this->autoMinimize = autoMinimize;
adjustSizeAndPosition();
adjustSizeAndPosition();
}
}
void UBKeyboardPalette::enterEvent ( QEvent * )
{
if (keyboardActive)
......@@ -222,7 +216,7 @@ void UBKeyboardPalette::leaveEvent ( QEvent * )
void UBKeyboardPalette::moveEvent ( QMoveEvent * event )
{
UBFloatingPalette::moveEvent(event);
UBActionPalette::moveEvent(event);
emit moved(event->pos());
}
......@@ -237,109 +231,230 @@ void UBKeyboardPalette::adjustSizeAndPosition(bool pUp)
this->move(x()-dx, y() - dy);
this->resize(rSize.width(), rSize.height());
}
UBFloatingPalette::adjustSizeAndPosition(pUp);
UBActionPalette::adjustSizeAndPosition(pUp);
}
void UBKeyboardPalette::paintEvent( QPaintEvent* event)
{
UBFloatingPalette::paintEvent(event);
UBActionPalette::paintEvent(event);
QRect r = this->geometry();
int lleft, ltop, lright, lbottom;
getContentsMargins ( &lleft, &ltop, &lright, &lbottom ) ;
int btw = (r.width() - lleft - lright - 13) / 14.5;
int bth = (r.height() - ltop - lbottom -4) / 5;
//------------------------------------------------
// calculate start offset from left, and from top
int ctrlButtonsId = 0;
lleft = ( r.width() - btnWidth * 15 ) / 2;
ltop = ( r.height() - btnHeight * 5 ) / 2;
//------------------------------------------------
// set geometry (position) for row 1
lleft = (r.width() - (btw * 14.5 + 13))/2;
ltop = (r.height() - (bth * 5 + 4)) / 2;
int offX = lleft;
int offY = ltop;
int off = lleft;;
//-------------------
// buttons [`]..[+]
for (int i = 0; i<13; i++)
{
QRect cr(off, ltop, btw, bth);
buttons[i]->setGeometry(cr);
off += btw + 1;
buttons[i]->setGeometry(offX, offY, btnWidth, btnHeight);
offX += btnWidth;
}
ctrlButtons[0]->setGeometry(off, ltop, btw * 1.5, bth);
off += btw * 1.5;
lright = off;
ltop += bth + 1;
int lwidth = 12 * btw + 12 + btw * 1.3;
off = (r.width() - lwidth) / 2;
ctrlButtons[1]->setGeometry(off, ltop, btw * 1.3, bth);
off += btw * 1.3 + 1;
for (int i=0; i<12; i++)
// button Backspace
ctrlButtons[ctrlButtonsId++]->setGeometry(offX, offY, btnWidth * 2, btnHeight);
offX += btnWidth * 2;
//------------------------------------------------
// set geometry (position) for row 2
offX = lleft;
offY += btnHeight;
offX += btnWidth / 2;
//-------------------
// button Tab
ctrlButtons[ctrlButtonsId++]->setGeometry(offX, offY, btnWidth * 2, btnHeight);
offX += btnWidth * 2;
// buttons [q]..[]]
for (int i = 0; i<12; i++)
{
QRect cr(off, ltop, btw, bth);
buttons[13 + i]->setGeometry(cr);
off += btw + 1;
buttons[i + 13]->setGeometry(offX, offY, btnWidth, btnHeight);
offX += btnWidth;
}
ltop += bth + 1;
lwidth = 12 * btw + 12 + btw * 2;
off = (r.width() - lwidth) / 2;
for (int i=0; i<12; i++)
// // Row 2 Stub
// ctrlButtons[ctrlButtonsId++]->setGeometry(offX, offY, btnWidth * 1.5, btnHeight);
// offX += btnWidth * 1.5;
//------------------------------------------------
// set geometry (position) for row 3
offX = lleft;
offY += btnHeight;
//-------------------
// // Row 3 Stub
// ctrlButtons[ctrlButtonsId++]->setGeometry(offX, offY, btnWidth, btnHeight);
// offX += btnWidth;
// buttons [a]..[\]
for (int i = 0; i < 12; i++)
{
QRect cr(off, ltop, btw, bth);
buttons[13 + 12 + i]->setGeometry(cr);
off += btw + 1;
buttons[i + 12 + 13]->setGeometry(offX, offY, btnWidth, btnHeight);
offX += btnWidth;
}
ctrlButtons[2]->setGeometry(off, ltop, btw * 2, bth);
ltop += bth + 1;
lwidth = 12 * btw + 11;
off = (r.width() - lwidth) / 2;
ctrlButtons[3]->setGeometry(off, ltop, btw, bth);
off+=btw+1;
for (int i=0; i<10; i++)
// button Enter
ctrlButtons[ctrlButtonsId++]->setGeometry(offX, offY, btnWidth * 3, btnHeight);
offX += btnWidth*3;
//------------------------------------------------
// set geometry (position) for row 4
offX = lleft;
offY += btnHeight;
//-------------------
// button LCapsLock
ctrlButtons[ctrlButtonsId++]->setGeometry(offX, offY, btnWidth*2.5, btnHeight);
offX += btnWidth*2.5;
for (int i = 0; i < 10; i++)
{
QRect cr(off, ltop, btw, bth);
buttons[13 + 12 + 12 + i]->setGeometry(cr);
off += btw + 1;
buttons[i + 12 + 12 + 13]->setGeometry(offX, offY, btnWidth, btnHeight);
offX += btnWidth;
}
ctrlButtons[4]->setGeometry(r.x() + off, ltop, btw, bth);
ltop += bth + 1;
lwidth = 11 * btw + 2;
off = (r.width() - lwidth) / 2;
ctrlButtons[5]->setGeometry(off, ltop, btw, bth);
ctrlButtons[6]->setGeometry(off + btw + 1, ltop, btw*9, bth);
ctrlButtons[7]->setGeometry(off + btw*10 + 2, ltop, btw, bth);
// button RCapsLock
ctrlButtons[ctrlButtonsId++]->setGeometry(offX, offY, btnWidth*2.5, btnHeight);
offX += btnWidth*2.5;
//------------------------------------------------
// set geometry (position) for row 5
offX = lleft;
offY += btnHeight;
//-------------------
ctrlButtons[ctrlButtonsId++]->setGeometry(offX + btnWidth * 1 , offY, btnWidth * 2, btnHeight);
ctrlButtons[ctrlButtonsId++]->setGeometry(offX + btnWidth * 3 , offY, btnWidth * 9, btnHeight);
ctrlButtons[ctrlButtonsId++]->setGeometry(offX + btnWidth * 12, offY, btnWidth * 2, btnHeight);
//------------------------------------------------
}
/*
//-----------------------------------------------------------------------//
// BTNImages Class
//-----------------------------------------------------------------------//
UBKeyboardButton
*/
BTNImages::BTNImages(QString strHeight, int width, int height)
{
m_strHeight = strHeight;
m_width = width;
m_height = height;
m_strLeftPassive = ":/images/virtual.keyboard/" + strHeight + "/left-passive.png";
m_strCenterPassive = ":/images/virtual.keyboard/" + strHeight + "/centre-passive.png";
m_strRightPassive = ":/images/virtual.keyboard/" + strHeight + "/right-passive.png";
m_strLeftActive = ":/images/virtual.keyboard/" + strHeight + "/left-active.png";
m_strCenterActive = ":/images/virtual.keyboard/" + strHeight + "/centre-active.png";
m_strRightActive = ":/images/virtual.keyboard/" + strHeight + "/right-active.png";
m_btnLeftPassive = QImage(m_strLeftPassive);
m_btnCenterPassive = QImage(m_strCenterPassive);
m_btnRightPassive = QImage(m_strRightPassive);
m_btnLeftActive = QImage(m_strLeftActive);
m_btnCenterActive = QImage(m_strCenterActive);
m_btnRightActive = QImage(m_strRightActive);
}
ContentImage::ContentImage(QString strHeight, int height, QString strContentName)
{
m_strHeight = strHeight;
m_height = height;
UBKeyboardButton::UBKeyboardButton(UBKeyboardPalette* parent)
m_strContent = ":/images/virtual.keyboard/" + strHeight + "/" + strContentName + ".png";
m_btnContent = QImage(m_strContent);
}
//-----------------------------------------------------------------------//
// UBKeyboardButton Class
//-----------------------------------------------------------------------//
UBKeyboardButton::UBKeyboardButton(UBKeyboardPalette* parent, QString contentImagePath = "")
:QWidget(parent),
keyboard(parent),
bFocused(false),
bPressed(false)
{
m_parent = parent;
m_contentImagePath = contentImagePath;
imgContent = NULL;
setCursor(Qt::PointingHandCursor);
}
UBKeyboardButton::~UBKeyboardButton()
{}
{
if(imgContent != NULL)
{
delete imgContent;
imgContent = NULL;
}
}
void UBKeyboardButton::paintEvent(QPaintEvent*)
{
QPainter painter(this);
//--------------------------
if(imgContent != NULL)
{
if(imgContent->m_height != m_parent->currBtnImages->m_height)
{
delete imgContent;
if(!m_contentImagePath.isEmpty())
imgContent = new ContentImage(m_parent->currBtnImages->m_strHeight, m_parent->currBtnImages->m_height, m_contentImagePath);
}
}
else
if(!m_contentImagePath.isEmpty())
imgContent = new ContentImage(m_parent->currBtnImages->m_strHeight, m_parent->currBtnImages->m_height, m_contentImagePath);
//--------------------------
if (bPressed)
painter.setBrush(QBrush(QColor(0, 0xcc, 0)));
else if (bFocused)
painter.setBrush(QBrush(QColor(0xcc, 0, 0)));
{
painter.drawImage( 0,0, m_parent->currBtnImages->m_btnLeftActive, 0,0, m_parent->currBtnImages->m_btnLeftActive.width(), m_parent->currBtnImages->m_btnLeftActive.height() );
painter.drawImage( QRect(m_parent->currBtnImages->m_btnLeftActive.width(), 0, width() - m_parent->currBtnImages->m_btnLeftActive.width() - m_parent->currBtnImages->m_btnRightActive.width(), height()), m_parent->currBtnImages->m_btnCenterActive );
painter.drawImage( width() - m_parent->currBtnImages->m_btnRightActive.width(), 0, m_parent->currBtnImages->m_btnRightActive, 0,0, m_parent->currBtnImages->m_btnRightActive.width(), m_parent->currBtnImages->m_btnRightActive.height() );
}
else
{
painter.drawImage( 0,0, m_parent->currBtnImages->m_btnLeftPassive, 0,0, m_parent->currBtnImages->m_btnLeftPassive.width(), m_parent->currBtnImages->m_btnLeftPassive.height() );
painter.drawImage( QRect(m_parent->currBtnImages->m_btnLeftPassive.width(), 0, width() - m_parent->currBtnImages->m_btnLeftPassive.width() - m_parent->currBtnImages->m_btnRightPassive.width(), height()), m_parent->currBtnImages->m_btnCenterPassive );
painter.drawImage( width() - m_parent->currBtnImages->m_btnRightPassive.width(), 0, m_parent->currBtnImages->m_btnRightPassive, 0,0, m_parent->currBtnImages->m_btnRightPassive.width(), m_parent->currBtnImages->m_btnRightPassive.height() );
}
painter.drawRoundedRect(0, 0, width()-1, height()-1, 3, 3);
//--------------------------
this->paintContent(painter);
//--------------------------
}
void UBKeyboardButton::enterEvent ( QEvent*)
......@@ -388,7 +503,6 @@ void UBKeyButton::onRelease()
void UBKeyButton::paintContent(QPainter& painter)
{
if (keybt)
{
QString text(QChar(capsLock() ? keybt->symbol2 : keybt->symbol1));
......@@ -397,6 +511,12 @@ void UBKeyButton::paintContent(QPainter& painter)
}
}
UBCntrlButton::UBCntrlButton(UBKeyboardPalette* parent, int _code, const QString& _contentImagePath )
:UBKeyboardButton(parent, _contentImagePath),
label(""),
code(_code)
{}
UBCntrlButton::UBCntrlButton(UBKeyboardPalette* parent, const QString& _label, int _code )
:UBKeyboardButton(parent),
......@@ -409,7 +529,7 @@ UBCntrlButton::~UBCntrlButton()
void UBCntrlButton::onPress()
{
sendControlSymbol(code);
sendControlSymbol(code);
}
void UBCntrlButton::onRelease()
......@@ -417,11 +537,20 @@ void UBCntrlButton::onRelease()
void UBCntrlButton::paintContent(QPainter& painter)
{
painter.drawText(rect(), Qt::AlignCenter, label);
if(!label.isEmpty())
{
painter.drawText(rect(), Qt::AlignCenter, label);
}
else
if(imgContent != NULL)
{
painter.drawImage(( rect().width() - imgContent->m_btnContent.width() ) / 2, ( rect().height() - imgContent->m_btnContent.height() ) / 2,
imgContent->m_btnContent, 0,0, imgContent->m_btnContent.width(), imgContent->m_btnContent.height());
}
}
UBCapsLockButton::UBCapsLockButton(UBKeyboardPalette* parent)
:UBKeyboardButton(parent)
UBCapsLockButton::UBCapsLockButton(UBKeyboardPalette* parent, const QString _contentImagePath)
:UBKeyboardButton(parent, _contentImagePath)
{}
UBCapsLockButton::~UBCapsLockButton()
......@@ -438,7 +567,13 @@ void UBCapsLockButton::onRelease()
void UBCapsLockButton::paintContent(QPainter& painter)
{
painter.drawText(rect(), Qt::AlignCenter, "^");
if(imgContent != NULL)
{
painter.drawImage(( rect().width() - imgContent->m_btnContent.width() ) / 2, ( rect().height() - imgContent->m_btnContent.height() ) / 2,
imgContent->m_btnContent, 0,0, imgContent->m_btnContent.width(), imgContent->m_btnContent.height());
}
else
painter.drawText(rect(), Qt::AlignCenter, "^");
}
......
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBKEYBOARDPALETTE_H
#define UBKEYBOARDPALETTE_H
#include "UBFloatingPalette.h"
#include "UBActionPalette.h"
#include <QLayout>
#include <QPainter>
......@@ -28,7 +13,52 @@
class UBKeyButton;
class UBKeyboardButton;
class UBKeyboardPalette : public UBFloatingPalette
class UBApplication;
class UBMainWindow;
class BTNImages
{
public:
BTNImages(QString _strHeight, int _width, int _height);
QString m_strHeight;
int m_width;
int m_height;
QImage m_btnLeftPassive;
QImage m_btnCenterPassive;
QImage m_btnRightPassive;
QImage m_btnLeftActive;
QImage m_btnCenterActive;
QImage m_btnRightActive;
private:
QString m_strLeftPassive;
QString m_strCenterPassive;
QString m_strRightPassive;
QString m_strLeftActive;
QString m_strCenterActive;
QString m_strRightActive;
};
class ContentImage
{
public:
ContentImage(QString strHeight, int m_height, QString strContentPath);
QString m_strHeight;
int m_height;
QImage m_btnContent;
private:
QString m_strContent;
};
class UBKeyboardPalette : public UBActionPalette
{
Q_OBJECT
......@@ -39,12 +69,13 @@ friend class UBLocaleButton;
public:
~UBKeyboardPalette();
BTNImages *currBtnImages;
bool isEnabled(){return locales!= NULL;}
virtual QSize sizeHint () const;
virtual void adjustSizeAndPosition(bool pUp = true);
QString getKeyButtonSize() const {QString res; res.sprintf("%dx%d", btnWidth, btnHeight); return res;}
void setKeyButtonSize(const QString& strSize);
void setAutoMinimize(bool autoMinimize);
static UBKeyboardPalette* create(QWidget *parent);
signals:
......@@ -55,9 +86,9 @@ signals:
private slots:
void syncPosition(const QPoint & pos);
void syncLocale(int nLocale);
void keyboardPaletteAutoMinimizeChanged(QVariant b);
void keyboardPaletteButtonSizeChanged(QVariant size);
void onActivated(bool b);
void hideKeyboard();
protected:
bool capsLock;
......@@ -65,16 +96,16 @@ protected:
int nLocalesCount;
UBKeyboardLocale** locales;
QString strSize;
int btnWidth;
int btnHeight;
//
bool languagePopupActive;
bool keyboardActive;
bool autoMinimize;
//
virtual void enterEvent ( QEvent * event );
virtual void leaveEvent ( QEvent * event );
virtual void paintEvent(QPaintEvent *event);
virtual void paintEvent(QPaintEvent *event);
virtual void moveEvent ( QMoveEvent * event );
void sendKeyEvent(const KEYBT& keybt);
......@@ -110,17 +141,22 @@ private:
};
class UBKeyboardButton : public QWidget
{
Q_OBJECT
public:
UBKeyboardButton(UBKeyboardPalette* parent);
UBKeyboardButton(UBKeyboardPalette* parent, QString contentImagePath);
~UBKeyboardButton();
protected:
UBKeyboardPalette* m_parent;
ContentImage *imgContent;
QString m_contentImagePath;
void paintEvent(QPaintEvent *event);
virtual void enterEvent ( QEvent * event );
virtual void leaveEvent ( QEvent * event );
virtual void mousePressEvent ( QMouseEvent * event );
......@@ -165,6 +201,7 @@ class UBCntrlButton : public UBKeyboardButton
Q_OBJECT
public:
UBCntrlButton(UBKeyboardPalette* parent, int _code, const QString& _contentImagePath );
UBCntrlButton(UBKeyboardPalette* parent, const QString& _label, int _code );
~UBCntrlButton();
......@@ -182,7 +219,7 @@ class UBCapsLockButton : public UBKeyboardButton
Q_OBJECT
public:
UBCapsLockButton(UBKeyboardPalette* parent);
UBCapsLockButton(UBKeyboardPalette* parent, const QString _contentImagePath);
~UBCapsLockButton();
virtual void onPress();
......@@ -203,7 +240,7 @@ public:
virtual void paintContent(QPainter& painter);
protected:
QMenu* localeMenu;
QMenu* localeMenu;
};
#endif // UBKEYBOARDPALETTE_H
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "UBKeyboardPalette.h"
......@@ -66,16 +52,19 @@ void UBKeyboardButton::sendControlSymbol(int nSymbol)
void UBKeyboardPalette::createCtrlButtons()
{
ctrlButtons = new UBKeyboardButton*[7];
ctrlButtons[0] = new UBCntrlButton(this, "<-", 0x08);
ctrlButtons[1] = new UBCntrlButton(this, "<->", 0x09);
ctrlButtons[2] = new UBCntrlButton(this, "Enter", 0x0d);
ctrlButtons[3] = new UBCapsLockButton(this);
ctrlButtons[4] = new UBCapsLockButton(this);
ctrlButtons[5] = new UBLocaleButton(this);
ctrlButtons[6] = new UBCntrlButton(this, "", 0x20);
ctrlButtons[7] = new UBLocaleButton(this);
int ctrlID = 0;
ctrlButtons = new UBKeyboardButton*[9];
ctrlButtons[ctrlID++] = new UBCntrlButton(this, 0x08, "backspace");// Backspace
ctrlButtons[ctrlID++] = new UBCntrlButton(this, 0x09, "tab"); // Tab
// ctrlButtons[ctrlID++] = new UBKeyButton(this); // Row 2 Stub
// ctrlButtons[ctrlID++] = new UBKeyButton(this); // Row 3 Stub
ctrlButtons[ctrlID++] = new UBCntrlButton(this, "Enter", 0x0d); // Enter
ctrlButtons[ctrlID++] = new UBCapsLockButton(this, "capslock"); // Caps Lock
ctrlButtons[ctrlID++] = new UBCapsLockButton(this, "capslock"); // Caps Lock
ctrlButtons[ctrlID++] = new UBLocaleButton(this); // Language Switch
ctrlButtons[ctrlID++] = new UBCntrlButton(this, "", 0x20); // Space
ctrlButtons[ctrlID++] = new UBLocaleButton(this); // Language Switch
}
void UBKeyboardPalette::onActivated(bool)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment