From 7a6776a4a965258d80a039511844f4a4a8a64ac9 Mon Sep 17 00:00:00 2001 From: Anatoly Mihalchenko Date: Thu, 27 Oct 2011 15:57:50 +0300 Subject: [PATCH] SANKORE-329 last part of issue - refactoring virtual keyboard. source code still require testing and defect correction for Linux and Mac OS --- src/board/UBBoardPaletteManager.cpp | 153 ++++++++++++++---- src/core/UBApplicationController.cpp | 7 +- src/desktop/UBDesktopAnnotationController.cpp | 87 +++++----- src/desktop/UBDesktopAnnotationController.h | 8 +- src/document/UBDocumentController.cpp | 18 ++- src/document/UBDocumentController.h | 6 +- src/gui/UBKeyboardPalette.cpp | 57 ++----- src/gui/UBKeyboardPalette.h | 9 +- src/web/UBWebController.cpp | 31 ++-- src/web/UBWebController.h | 14 +- 10 files changed, 236 insertions(+), 154 deletions(-) diff --git a/src/board/UBBoardPaletteManager.cpp b/src/board/UBBoardPaletteManager.cpp index e0152975..3ab4f111 100755 --- a/src/board/UBBoardPaletteManager.cpp +++ b/src/board/UBBoardPaletteManager.cpp @@ -220,15 +220,38 @@ void UBBoardPaletteManager::setupDockPaletteWidgets() void UBBoardPaletteManager::slot_changeMainMode(UBApplicationController::MainMode mainMode) { +// Board = 0, Internet, Document, Tutorial, ParaschoolEditor, WebDocument + switch( mainMode ) { - case UBApplicationController::Board: - // call changeMode only when switch NOT from desktop mode - if(!UBApplication::applicationController->isShowingDesktop()) - changeMode(eUBDockPaletteWidget_BOARD); + case UBApplicationController::Board: + { + // call changeMode only when switch NOT from desktop mode + if(!UBApplication::applicationController->isShowingDesktop()) + changeMode(eUBDockPaletteWidget_BOARD); + } + break; + + case UBApplicationController::Tutorial: + { + if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL) + mKeyboardPalette->hide(); + } + break; + + case UBApplicationController::Internet: + changeMode(eUBDockPaletteWidget_WEB); + break; + + case UBApplicationController::Document: + changeMode(eUBDockPaletteWidget_DOCUMENT); break; default: + { + if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL) + mKeyboardPalette->hide(); + } break; } } @@ -255,25 +278,25 @@ void UBBoardPaletteManager::slot_changeDesktopMode(bool isDesktop) void UBBoardPaletteManager::setupPalettes() { - setupDockPaletteWidgets(); - - - // Add the other palettes - mStylusPalette = new UBStylusPalette(mContainer, UBSettings::settings()->appToolBarOrientationVertical->get().toBool() ? Qt::Vertical : Qt::Horizontal); - connect(mStylusPalette, SIGNAL(stylusToolDoubleClicked(int)), UBApplication::boardController, SLOT(stylusToolDoubleClicked(int))); - mStylusPalette->show(); // always show stylus palette at startup - if (UBPlatformUtils::hasVirtualKeyboard()) { - mKeyboardPalette = UBKeyboardPalette::create(0); + mKeyboardPalette = new UBKeyboardPalette(0); #ifndef Q_WS_WIN connect(mKeyboardPalette, SIGNAL(closed()), mKeyboardPalette, SLOT(onDeactivated())); #endif #ifndef Q_WS_MAC - mKeyboardPalette->setParent(mContainer); + // mKeyboardPalette->setParent(mContainer); #endif } + setupDockPaletteWidgets(); + + + // Add the other palettes + mStylusPalette = new UBStylusPalette(mContainer, UBSettings::settings()->appToolBarOrientationVertical->get().toBool() ? Qt::Vertical : Qt::Horizontal); + connect(mStylusPalette, SIGNAL(stylusToolDoubleClicked(int)), UBApplication::boardController, SLOT(stylusToolDoubleClicked(int))); + mStylusPalette->show(); // always show stylus palette at startup + mZoomPalette = new UBZoomPalette(mContainer); QList backgroundsActions; @@ -483,7 +506,7 @@ void UBBoardPaletteManager::connectPalettes() } - +bool isFirstResized = true; void UBBoardPaletteManager::containerResized() { int innerMargin = UBSettings::boardMargin; @@ -493,25 +516,39 @@ void UBBoardPaletteManager::containerResized() int userTop = innerMargin; int userHeight = mContainer->height() - (2 * innerMargin); - mStylusPalette->move(userLeft, userTop); - mStylusPalette->adjustSizeAndPosition(); - mStylusPalette->initPosition(); + if(mStylusPalette) + { + mStylusPalette->move(userLeft, userTop); + mStylusPalette->adjustSizeAndPosition(); + mStylusPalette->initPosition(); + } - mZoomPalette->move(userLeft + userWidth - mZoomPalette->width() - , userTop + userHeight /*- mPageNumberPalette->height()*/ - innerMargin - mZoomPalette->height()); - mZoomPalette->adjustSizeAndPosition(); + if(mZoomPalette) + { + mZoomPalette->move(userLeft + userWidth - mZoomPalette->width() + , userTop + userHeight /*- mPageNumberPalette->height()*/ - innerMargin - mZoomPalette->height()); + mZoomPalette->adjustSizeAndPosition(); + } - if (mKeyboardPalette) + if (isFirstResized && mKeyboardPalette && mKeyboardPalette->parent() == UBApplication::boardController->controlContainer()) { - mKeyboardPalette->move(userLeft + (userWidth - mKeyboardPalette->width())/2, - userTop + userHeight - mKeyboardPalette->height()); - mKeyboardPalette->adjustSizeAndPosition(); + isFirstResized = false; + mKeyboardPalette->move(userLeft + (userWidth - mKeyboardPalette->width())/2, + userTop + (userHeight - mKeyboardPalette->height())/2); + mKeyboardPalette->adjustSizeAndPosition(); } - mLeftPalette->resize(mLeftPalette->width()-1, mContainer->height()); - mRightPalette->resize(mRightPalette->width()-1, mContainer->height()); - mLeftPalette->resize(mLeftPalette->width(), mContainer->height()); - mRightPalette->resize(mRightPalette->width(), mContainer->height()); + if(mLeftPalette) + { + mLeftPalette->resize(mLeftPalette->width()-1, mContainer->height()); + mLeftPalette->resize(mLeftPalette->width(), mContainer->height()); + } + + if(mRightPalette) + { + mRightPalette->resize(mRightPalette->width()-1, mContainer->height()); + mRightPalette->resize(mRightPalette->width(), mContainer->height()); + } } @@ -683,6 +720,18 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is { mLeftPalette->setParent(UBApplication::boardController->controlContainer()); mRightPalette->setParent(UBApplication::boardController->controlContainer()); + if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL) + { + + if(mKeyboardPalette->m_isVisible) + { + mKeyboardPalette->hide(); + mKeyboardPalette->setParent(UBApplication::boardController->controlContainer()); + mKeyboardPalette->show(); + } + else + mKeyboardPalette->setParent(UBApplication::boardController->controlContainer()); + } mLeftPalette->setVisible(true); mRightPalette->setVisible(true); @@ -696,6 +745,18 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is { mLeftPalette->setParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView()); mRightPalette->setParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView()); + if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL) + { + + if(mKeyboardPalette->m_isVisible) + { + mKeyboardPalette->hide(); + mKeyboardPalette->setParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView()); + mKeyboardPalette->show(); + } + else + mKeyboardPalette->setParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView()); + } mLeftPalette->setVisible(false); mRightPalette->setVisible(true); @@ -705,12 +766,46 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is } break; + case eUBDockPaletteWidget_WEB: + { + if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL) + { + WBBrowserWindow* brWnd = UBApplication::webController->GetCurrentWebBrowser(); + + if(mKeyboardPalette->m_isVisible) + { + mKeyboardPalette->hide(); + mKeyboardPalette->setParent(brWnd); + mKeyboardPalette->show(); + } + else + mKeyboardPalette->setParent(brWnd); + } + + } + break; + default: { mLeftPalette->setVisible(false); mRightPalette->setVisible(false); mLeftPalette->setParent(0); mRightPalette->setParent(0); + if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL) + { + + if(mKeyboardPalette->m_isVisible) + { + mKeyboardPalette->hide(); + mKeyboardPalette->setParent(0); + mKeyboardPalette->show(); + } + else + mKeyboardPalette->setParent(0); + +// mKeyboardPalette->update(); + + } } break; } diff --git a/src/core/UBApplicationController.cpp b/src/core/UBApplicationController.cpp index b3560186..6000f097 100644 --- a/src/core/UBApplicationController.cpp +++ b/src/core/UBApplicationController.cpp @@ -368,6 +368,8 @@ void UBApplicationController::showInternet() if (UBSettings::settings()->webUseExternalBrowser->get().toBool()) { showDesktop(true); + UBApplication::webController->show(UBWebController::WebBrowser); + // really no have emit mainModeChanged here ? potential problem with virtual keyboard ? } else { @@ -382,10 +384,11 @@ void UBApplicationController::showInternet() mMainWindow->show(); mUninoteController->hideWindow(); + + UBApplication::webController->show(UBWebController::WebBrowser); + emit mainModeChanged(Internet); } - - UBApplication::webController->show(UBWebController::WebBrowser); } diff --git a/src/desktop/UBDesktopAnnotationController.cpp b/src/desktop/UBDesktopAnnotationController.cpp index 5ffd8759..9bf8a694 100644 --- a/src/desktop/UBDesktopAnnotationController.cpp +++ b/src/desktop/UBDesktopAnnotationController.cpp @@ -52,7 +52,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent) , mTransparentDrawingView(0) , mTransparentDrawingScene(0) , mDesktopPalette(NULL) - , mKeyboardPalette(0) +// , mKeyboardPalette(0) , mDesktopPenPalette(NULL) , mDesktopMarkerPalette(NULL) , mDesktopEraserPalette(NULL) @@ -64,7 +64,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent) , mPendingMarkerButtonPressed(false) , mPendingEraserButtonPressed(false) , mbArrowClicked(false) - , mBoardStylusTool(UBStylusTool::Pen) + , mBoardStylusTool(UBStylusTool::Selector /*UBStylusTool::Pen*/) , mDesktopStylusTool(UBStylusTool::Selector) { @@ -101,10 +101,15 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent) connect(mTransparentDrawingView, SIGNAL(hidden()), mKeyboardPalette, SLOT(hide())); connect(mTransparentDrawingView, SIGNAL(shown()), this, SLOT(showKeyboard())); #else - mKeyboardPalette = UBKeyboardPalette::create(mTransparentDrawingView); - mKeyboardPalette->setParent(mTransparentDrawingView); +// mKeyboardPalette = UBKeyboardPalette::create(mTransparentDrawingView); +// mKeyboardPalette->setParent(mTransparentDrawingView); #endif - connect(mKeyboardPalette, SIGNAL(keyboardActivated(bool)), mTransparentDrawingView, SLOT(virtualKeyboardActivated(bool))); + connect( UBApplication::boardController->paletteManager()->mKeyboardPalette, SIGNAL(keyboardActivated(bool)), + mTransparentDrawingView, SLOT(virtualKeyboardActivated(bool))); + +// connect(UBApplication::mainWindow->actionVirtualKeyboard, SIGNAL(triggered(bool)), +// mTransparentDrawingView, SLOT(virtualKeyboardActivated(bool))); + #ifdef Q_WS_X11 connect(mKeyboardPalette, SIGNAL(moved(QPoint)), this, SLOT(refreshMask())); connect(mDesktopPalette,SIGNAL(refreshMask()), this, SLOT(refreshMask())); @@ -117,7 +122,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent) 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(UBApplication::mainWindow->actionVirtualKeyboard, SIGNAL(triggered(bool)), this, SLOT(showKeyboard(bool))); connect(mTransparentDrawingView, SIGNAL(resized(QResizeEvent*)), this, SLOT(onTransparentWidgetResized())); @@ -164,31 +169,32 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent) onDesktopPaletteMaximized(); } -void UBDesktopAnnotationController::showKeyboard(bool show) -{ - #ifdef Q_WS_X11 - if (!mTransparentDrawingView->isVisible()) - return; - #endif - - if(mKeyboardPalette) - { - if(show) - UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); - mKeyboardPalette->setVisible(show); - - #ifdef Q_WS_X11 - updateMask(true); - #endif - - } - -} -void UBDesktopAnnotationController::showKeyboard() -{ - if (UBApplication::mainWindow->actionVirtualKeyboard->isChecked()) - mKeyboardPalette->show(); -} +// void UBDesktopAnnotationController::showKeyboard(bool show) +// { +// #ifdef Q_WS_X11 +// if (!mTransparentDrawingView->isVisible()) +// return; +// #endif +// +// if(mKeyboardPalette) +// { +// if(show) +// UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); +// mKeyboardPalette->setVisible(show); +// +// #ifdef Q_WS_X11 +// updateMask(true); +// #endif +// +// } +// +// } + +// void UBDesktopAnnotationController::showKeyboard() +// { +// if (UBApplication::mainWindow->actionVirtualKeyboard->isChecked()) +// mKeyboardPalette->show(); +// } UBDesktopAnnotationController::~UBDesktopAnnotationController() { @@ -366,12 +372,12 @@ void UBDesktopAnnotationController::close() void UBDesktopAnnotationController::stylusToolChanged(int tool) { - UBStylusTool::Enum eTool = (UBStylusTool::Enum)tool; - if(eTool != UBStylusTool::Selector && eTool != UBStylusTool::Text) - { - if(mKeyboardPalette->m_isVisible) - UBApplication::mainWindow->actionVirtualKeyboard->activate(QAction::Trigger); - } +// UBStylusTool::Enum eTool = (UBStylusTool::Enum)tool; +// if(eTool != UBStylusTool::Selector && eTool != UBStylusTool::Text) +// { +// if(mKeyboardPalette->m_isVisible) +// UBApplication::mainWindow->actionVirtualKeyboard->activate(QAction::Trigger); +// } updateBackground(); } @@ -910,9 +916,10 @@ void UBDesktopAnnotationController::updateMask(bool bTransparent) { p.drawRect(mDesktopPalette->geometry().x(), mDesktopPalette->geometry().y(), mDesktopPalette->width(), mDesktopPalette->height()); } - if(mKeyboardPalette->isVisible()) + if(UBApplication::boardController->paletteManager()->mKeyboardPalette->isVisible()) { - p.drawRect(mKeyboardPalette->geometry().x(), mKeyboardPalette->geometry().y(), mKeyboardPalette->width(), mKeyboardPalette->height()); + p.drawRect(UBApplication::boardController->paletteManager()->mKeyboardPalette->geometry().x(), UBApplication::boardController->paletteManager()->mKeyboardPalette->geometry().y(), + UBApplication::boardController->paletteManager()->mKeyboardPalette->width(), UBApplication::boardController->paletteManager()->mKeyboardPalette->height()); } // UBApplication::boardController->paletteManager()->mDesktopRightPalette @@ -978,4 +985,4 @@ void UBDesktopAnnotationController::refreshMask() { updateMask(true); } -} +} \ No newline at end of file diff --git a/src/desktop/UBDesktopAnnotationController.h b/src/desktop/UBDesktopAnnotationController.h index b3a9e37f..924156b0 100644 --- a/src/desktop/UBDesktopAnnotationController.h +++ b/src/desktop/UBDesktopAnnotationController.h @@ -29,7 +29,7 @@ class UBDesktopPenPalette; class UBDesktopMarkerPalette; class UBDesktopEraserPalette; class UBActionPalette; -class UBKeyboardPalette; +//class UBKeyboardPalette; class UBMainWindow; #define PROPERTY_PALETTE_TIMER 1000 @@ -72,8 +72,8 @@ class UBDesktopAnnotationController : public QObject void stylusToolChanged(int tool); void updateBackground(); - void showKeyboard(bool show); - void showKeyboard(); //X11 virtual keyboard working only needed +// void showKeyboard(bool show); +// void showKeyboard(); //X11 virtual keyboard working only needed signals: /** @@ -118,7 +118,7 @@ class UBDesktopAnnotationController : public QObject void updateMask(bool bTransparent); UBDesktopPalette *mDesktopPalette; - UBKeyboardPalette *mKeyboardPalette; + //UBKeyboardPalette *mKeyboardPalette; UBDesktopPenPalette* mDesktopPenPalette; UBDesktopMarkerPalette* mDesktopMarkerPalette; UBDesktopEraserPalette* mDesktopEraserPalette; diff --git a/src/document/UBDocumentController.cpp b/src/document/UBDocumentController.cpp index b2cd201b..dd014988 100644 --- a/src/document/UBDocumentController.cpp +++ b/src/document/UBDocumentController.cpp @@ -38,7 +38,7 @@ #include "board/UBBoardPaletteManager.h" #include "board/UBDrawingController.h" -#include "gui/UBKeyboardPalette.h" +//#include "gui/UBKeyboardPalette.h" #include "gui/UBThumbnailView.h" #include "gui/UBDocumentTreeWidget.h" @@ -70,7 +70,7 @@ UBDocumentController::UBDocumentController(UBMainWindow* mainWindow) , mToolsPalette(0) , mToolsPalettePositionned(false) , mTrashTi(0) - , mKeyboardPalette(0) +// , mKeyboardPalette(0) { setupViews(); setupToolbar(); @@ -444,12 +444,12 @@ void UBDocumentController::setupViews() mMessageWindow = new UBMessageWindow(mDocumentUI->thumbnailWidget); mMessageWindow->hide(); - if (UBPlatformUtils::hasVirtualKeyboard()) - { - mKeyboardPalette = UBKeyboardPalette::create(0); - mKeyboardPalette->setParent(controlView()); - connect(mMainWindow->actionVirtualKeyboard, SIGNAL(triggered(bool)), this, SLOT(showKeyboard(bool))); - } +// if (UBPlatformUtils::hasVirtualKeyboard()) +// { +// mKeyboardPalette = UBKeyboardPalette::create(0); +// mKeyboardPalette->setParent(controlView()); +// connect(mMainWindow->actionVirtualKeyboard, SIGNAL(triggered(bool)), this, SLOT(showKeyboard(bool))); +// } } } @@ -467,6 +467,7 @@ void UBDocumentController::setupToolbar() connect(mMainWindow->actionDocumentTools, SIGNAL(triggered()), this, SLOT(toggleDocumentToolsPalette())); } +/* void UBDocumentController::showKeyboard(bool show) { if(mKeyboardPalette) @@ -477,6 +478,7 @@ void UBDocumentController::showKeyboard(bool show) } } +*/ void UBDocumentController::setupPalettes() { diff --git a/src/document/UBDocumentController.h b/src/document/UBDocumentController.h index 4e9b3d31..4baf8b36 100644 --- a/src/document/UBDocumentController.h +++ b/src/document/UBDocumentController.h @@ -34,7 +34,7 @@ class UBDocumentGroupTreeItem; class UBDocumentProxyTreeItem; class UBMainWindow; class UBDocumentToolsPalette; -class UBKeyboardPalette; +//class UBKeyboardPalette; class UBDocumentController : public QObject { @@ -76,7 +76,7 @@ class UBDocumentController : public QObject void paste(); void focusChanged(QWidget *old, QWidget *current); - void showKeyboard(bool show); +// void showKeyboard(bool show); protected: virtual void setupViews(); @@ -112,7 +112,7 @@ class UBDocumentController : public QObject UBDocumentGroupTreeItem* mTrashTi; UBDocumentProxy* mCurrentDocument; - UBKeyboardPalette *mKeyboardPalette; +// UBKeyboardPalette *mKeyboardPalette; private slots: diff --git a/src/gui/UBKeyboardPalette.cpp b/src/gui/UBKeyboardPalette.cpp index cf4f3b85..9c76cc9b 100644 --- a/src/gui/UBKeyboardPalette.cpp +++ b/src/gui/UBKeyboardPalette.cpp @@ -27,6 +27,9 @@ UBKeyboardPalette::UBKeyboardPalette(QWidget *parent) : UBActionPalette(Qt::TopRightCorner, parent) { + + // setWindowFlags(/*Qt::CustomizeWindowHint|*/Qt::WindowStaysOnTopHint|Qt::FramelessWindowHint); + setCustomCloseProcessing(true); setCustomPosition(true); setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); @@ -56,57 +59,25 @@ UBKeyboardPalette::UBKeyboardPalette(QWidget *parent) setContentsMargins( 22, 22, 22, 22 ); - connect(this, SIGNAL(keyboardActivated(bool)), this, SLOT(onActivated(bool))); + init(); } -QList UBKeyboardPalette::instances; -UBKeyboardPalette* UBKeyboardPalette::create(QWidget *parent) +//QList UBKeyboardPalette::instances; +void UBKeyboardPalette::init() { - //------------------------------// - - if (!UBPlatformUtils::hasVirtualKeyboard()) - return NULL; - - //------------------------------// - - UBKeyboardPalette* firstKeyboard = NULL; - // if we already have keyboards inside, get it position and show/hide status, for new keyboard - if(instances.size() > 0) - firstKeyboard = instances.at(0); - - //------------------------------// + m_isVisible = false; + setVisible(false); - UBKeyboardPalette* instance = new UBKeyboardPalette(parent); - instance->setKeyButtonSize(UBSettings::settings()->boardKeyboardPaletteKeyBtnSize->get().toString()); + setKeyButtonSize(UBSettings::settings()->boardKeyboardPaletteKeyBtnSize->get().toString()); - instance->m_isVisible = firstKeyboard ? firstKeyboard->m_isVisible : false; - instance->setVisible(instance->m_isVisible); - - if( firstKeyboard ) - instance->move(firstKeyboard->m_pos); - - connect(UBSettings::settings()->boardKeyboardPaletteKeyBtnSize, SIGNAL(changed(QVariant)), instance, SLOT(keyboardPaletteButtonSizeChanged(QVariant))); - connect(UBApplication::mainWindow->actionVirtualKeyboard, SIGNAL(triggered(bool)), instance, SLOT(showKeyboard(bool))); -// connect(instance, SIGNAL(moved(const QPoint&)), instance, SLOT(syncPosition(const QPoint&))); - connect(instance, SIGNAL(closed()), instance, SLOT(hideKeyboard())); - - //------------------------------// - - instances.append(instance); - foreach(UBKeyboardPalette* inst, instances) - { - connect(inst, SIGNAL(moved(const QPoint&)), instance, 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(instance, SIGNAL(localeChanged(int)), inst, SLOT(syncLocale(int))); - -// connect(instance, SIGNAL(closed()), inst, ) - } + connect(this, SIGNAL(keyboardActivated(bool)), this, SLOT(onActivated(bool))); + connect(UBSettings::settings()->boardKeyboardPaletteKeyBtnSize, SIGNAL(changed(QVariant)), this, SLOT(keyboardPaletteButtonSizeChanged(QVariant))); + connect(UBApplication::mainWindow->actionVirtualKeyboard, SIGNAL(triggered(bool)), this, SLOT(showKeyboard(bool))); + connect(this, SIGNAL(closed()), this, SLOT(hideKeyboard())); //------------------------------// - return instance; + UBPlatformUtils::setWindowNonActivableFlag(this, true); } void UBKeyboardPalette::showKeyboard(bool show) diff --git a/src/gui/UBKeyboardPalette.h b/src/gui/UBKeyboardPalette.h index 68a0a7e9..c7077fe2 100644 --- a/src/gui/UBKeyboardPalette.h +++ b/src/gui/UBKeyboardPalette.h @@ -67,6 +67,7 @@ friend class UBCapsLockButton; friend class UBLocaleButton; public: + UBKeyboardPalette(QWidget *parent); ~UBKeyboardPalette(); BTNImages *currBtnImages; @@ -77,8 +78,6 @@ public: QString getKeyButtonSize() const {QString res; res.sprintf("%dx%d", btnWidth, btnHeight); return res;} void setKeyButtonSize(const QString& strSize); - static UBKeyboardPalette* create(QWidget *parent); - static QList instances; bool m_isVisible; QPoint m_pos; @@ -119,10 +118,10 @@ protected: void setLocale(int nLocale); const QString* getLocaleName(); - -private: - UBKeyboardPalette(QWidget *parent); + void init(); + +private: QRect originalRect; diff --git a/src/web/UBWebController.cpp b/src/web/UBWebController.cpp index 6ae2361b..463354ef 100644 --- a/src/web/UBWebController.cpp +++ b/src/web/UBWebController.cpp @@ -32,7 +32,7 @@ #include "gui/UBScreenMirror.h" #include "gui/UBMainWindow.h" #include "gui/UBWebToolsPalette.h" -#include "gui/UBKeyboardPalette.h" +//#include "gui/UBKeyboardPalette.h" #include "core/UBSettings.h" #include "core/UBSetting.h" @@ -55,7 +55,7 @@ UBWebController::UBWebController(UBMainWindow* mainWindow) , mBrowserWidget(0) , mTrapFlashController(0) , mToolsCurrentPalette(0) - , mKeyboardCurrentPalette(0) +// , mKeyboardCurrentPalette(0) , mToolsPalettePositionned(false) , mDownloadViewIsVisible(false) @@ -113,7 +113,7 @@ void UBWebController::webBrowserInstance() { mCurrentWebBrowser = &mWebBrowserList[WebBrowser]; mToolsCurrentPalette = &mToolsPaletteList[WebBrowser]; - mKeyboardCurrentPalette = &mKeyboardPaletteList[WebBrowser]; +// mKeyboardCurrentPalette = &mKeyboardPaletteList[WebBrowser]; mToolsPalettePositionned = mToolsPalettePositionnedList[WebBrowser]; if (!(*mCurrentWebBrowser)) { @@ -191,7 +191,7 @@ void UBWebController::tutorialWebInstance() { mCurrentWebBrowser = &mWebBrowserList[Tutorial]; mToolsCurrentPalette = &mToolsPaletteList[Tutorial]; - mKeyboardCurrentPalette = &mKeyboardPaletteList[Tutorial]; +// mKeyboardCurrentPalette = &mKeyboardPaletteList[Tutorial]; mToolsPalettePositionned = &mToolsPalettePositionnedList[Tutorial]; if (!(*mCurrentWebBrowser)) { @@ -249,7 +249,7 @@ void UBWebController::paraschoolWebInstance() else { mCurrentWebBrowser = &mWebBrowserList[Paraschool]; mToolsCurrentPalette = &mToolsPaletteList[Paraschool]; - mKeyboardCurrentPalette = &mKeyboardPaletteList[Paraschool]; +// mKeyboardCurrentPalette = &mKeyboardPaletteList[Paraschool]; mToolsPalettePositionned = &mToolsPalettePositionnedList[Paraschool]; if (!(*mCurrentWebBrowser)){ (*mCurrentWebBrowser) = new WBBrowserWindow(mMainWindow->centralWidget(), mMainWindow, true); @@ -391,7 +391,7 @@ void UBWebController::setupPalettes() { (*mToolsCurrentPalette) = new UBWebToolsPalette((*mCurrentWebBrowser),false); - (*mKeyboardCurrentPalette) = UBKeyboardPalette::create(*mCurrentWebBrowser); +// (*mKeyboardCurrentPalette) = UBKeyboardPalette::create(*mCurrentWebBrowser); #ifndef Q_WS_WIN if (*mKeyboardCurrentPalette) connect(*mKeyboardCurrentPalette, SIGNAL(closed()), *mKeyboardCurrentPalette, SLOT(onDeactivated())); @@ -411,7 +411,7 @@ void UBWebController::setupPalettes() (*mToolsCurrentPalette)->hide(); (*mToolsCurrentPalette)->adjustSizeAndPosition(); - (*mKeyboardCurrentPalette)->adjustSizeAndPosition(); +// (*mKeyboardCurrentPalette)->adjustSizeAndPosition(); if (controlView()){ int left = controlView()->width() - 20 - (*mToolsCurrentPalette)->width(); @@ -435,15 +435,14 @@ void UBWebController::toggleWebTrap(bool checked) } } -void UBWebController::showKeyboard(bool checked) -{ - if (mKeyboardCurrentPalette - && (*mKeyboardCurrentPalette)) - { - (*mKeyboardCurrentPalette)->setVisible(checked); - } -} - +// void UBWebController::showKeyboard(bool checked) +// { +// if (mKeyboardCurrentPalette +// && (*mKeyboardCurrentPalette)) +// { +// (*mKeyboardCurrentPalette)->setVisible(checked); +// } +// } void UBWebController::toggleWebToolsPalette(bool checked) { diff --git a/src/web/UBWebController.h b/src/web/UBWebController.h index 1cb38c4c..29640cbe 100644 --- a/src/web/UBWebController.h +++ b/src/web/UBWebController.h @@ -28,7 +28,7 @@ class UBMainWindow; class UBWebToolsPalette; class WBWebView; class UBServerXMLHttpRequest; -class UBKeyboardPalette; +//class UBKeyboardPalette; class UBWebController : public QObject @@ -58,6 +58,12 @@ class UBWebController : public QObject void show(WebInstance type = UBWebController::WebBrowser); + WBBrowserWindow* GetCurrentWebBrowser() + { + if( mCurrentWebBrowser != NULL ) return *mCurrentWebBrowser; + else return NULL; + }; + protected: void setupPalettes(); @@ -101,8 +107,8 @@ class UBWebController : public QObject UBTrapFlashController* mTrapFlashController; UBWebToolsPalette** mToolsCurrentPalette; UBWebToolsPalette* mToolsPaletteList[TotalNumberOfWebInstances]; - UBKeyboardPalette** mKeyboardCurrentPalette; - UBKeyboardPalette* mKeyboardPaletteList[TotalNumberOfWebInstances]; +// UBKeyboardPalette** mKeyboardCurrentPalette; +// UBKeyboardPalette* mKeyboardPaletteList[TotalNumberOfWebInstances]; bool mToolsPalettePositionned; bool mToolsPalettePositionnedList[TotalNumberOfWebInstances]; @@ -124,7 +130,7 @@ class UBWebController : public QObject void toggleWebTrap(bool checked); - void showKeyboard(bool checked); +// void showKeyboard(bool checked); signals: /**