From ab0658ee6010d5533e64710c7474b8f75cc694af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Luthi?= Date: Mon, 20 Jun 2011 16:24:02 +0200 Subject: [PATCH] Adapt keyboard palette using widget attribute WA_MacNonActivatingToolWindow Only have one instance of the virtual keyboard palette. --- src/board/UBBoardPaletteManager.cpp | 2 +- src/desktop/UBDesktopAnnotationController.cpp | 30 ------------------- src/desktop/UBDesktopAnnotationController.h | 2 -- src/gui/UBFloatingPalette.cpp | 6 ++-- src/gui/UBFloatingPalette.h | 2 +- src/gui/UBKeyboardPalette.cpp | 4 +-- 6 files changed, 7 insertions(+), 39 deletions(-) diff --git a/src/board/UBBoardPaletteManager.cpp b/src/board/UBBoardPaletteManager.cpp index a0aad2ca..1a98bf44 100644 --- a/src/board/UBBoardPaletteManager.cpp +++ b/src/board/UBBoardPaletteManager.cpp @@ -123,7 +123,7 @@ void UBBoardPaletteManager::setupPalettes() mStylusPalette->show(); // always show stylus palette at startup if (UBPlatformUtils::hasVirtualKeyboard()) - mKeyboardPalette = UBKeyboardPalette::create(mContainer); + mKeyboardPalette = UBKeyboardPalette::create(0); mZoomPalette = new UBZoomPalette(mContainer); diff --git a/src/desktop/UBDesktopAnnotationController.cpp b/src/desktop/UBDesktopAnnotationController.cpp index 20430a86..7224a673 100644 --- a/src/desktop/UBDesktopAnnotationController.cpp +++ b/src/desktop/UBDesktopAnnotationController.cpp @@ -45,7 +45,6 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent) , mDesktopPenPalette(NULL) , mDesktopMarkerPalette(NULL) , mDesktopEraserPalette(NULL) - , mKeyboardPalette(NULL) , mLibPalette(NULL) , mWindowPositionInitialized(0) , mIsFullyTransparent(false) @@ -81,8 +80,6 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent) mDesktopPalette = new UBDesktopPalette(mTransparentDrawingView); connect(mDesktopPalette, SIGNAL(uniboardClick()), this, SLOT(goToUniboard())); - //connect(UBApplication::mainWindow->actionVirtualKeyboard, SIGNAL(triggered(bool)), this, SLOT(showKeyboard(bool))); - connect(mDesktopPalette, SIGNAL(showVirtualKeyboard(bool)), this, SLOT(showKeyboard(bool))); connect(mDesktopPalette, SIGNAL(customClick()), this, SLOT(customCapture())); connect(mDesktopPalette, SIGNAL(windowClick()), this, SLOT(windowCapture())); connect(mDesktopPalette, SIGNAL(screenClick()), this, SLOT(screenCapture())); @@ -104,19 +101,12 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent) mDesktopMarkerPalette = new UBDesktopMarkerPalette(mTransparentDrawingView); mDesktopEraserPalette = new UBDesktopEraserPalette(mTransparentDrawingView); - if (UBPlatformUtils::hasVirtualKeyboard()) - { - mKeyboardPalette = UBKeyboardPalette::create(mTransparentDrawingView); - connect(mKeyboardPalette, SIGNAL(keyboardActivated(bool)), mTransparentDrawingView, SLOT(virtualKeyboardActivated(bool))); - } mDesktopPalette->setBackgroundBrush(UBSettings::settings()->opaquePaletteColor); mDesktopToolsPalette->setBackgroundBrush(UBSettings::settings()->opaquePaletteColor); mDesktopPenPalette->setBackgroundBrush(UBSettings::settings()->opaquePaletteColor); mDesktopMarkerPalette->setBackgroundBrush(UBSettings::settings()->opaquePaletteColor); mDesktopEraserPalette->setBackgroundBrush(UBSettings::settings()->opaquePaletteColor); - if (mKeyboardPalette) - mKeyboardPalette->setBackgroundBrush(UBSettings::settings()->opaquePaletteColor); mDesktopToolsPalette->setVisible(UBApplication::mainWindow->actionDesktopTools->isChecked()); @@ -129,7 +119,6 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent) mDesktopPenPalette->setVisible(false); mDesktopMarkerPalette->setVisible(false); mDesktopEraserPalette->setVisible(false); - if (mKeyboardPalette) mKeyboardPalette->setVisible(false); connect(UBApplication::mainWindow->actionDesktopTools, SIGNAL(triggered(bool)), this, SLOT(desktopToolsActionToogled(bool))); connect(UBApplication::mainWindow->actionEraseDesktopAnnotations, SIGNAL(triggered()), this, SLOT(eraseDesktopAnnotations())); @@ -161,11 +150,6 @@ UBDesktopAnnotationController::~UBDesktopAnnotationController() delete mDesktopEraserPalette; mDesktopEraserPalette = NULL; } - if (NULL != mKeyboardPalette) - { - delete mKeyboardPalette; - mKeyboardPalette = NULL; - } if(NULL != mLibPalette) { delete mLibPalette; @@ -309,11 +293,6 @@ void UBDesktopAnnotationController::showWindow() //mDesktopPalette->move((desktopRect.right() - (mDesktopPalette->width() + 20)), desktopRect.top() + 150); mDesktopPalette->move(5, desktopRect.top() + 150); - mKeyboardPalette->move(desktopRect.left() + (desktopRect.width() - mKeyboardPalette->width())/2, - desktopRect.top() + desktopRect.height() - mKeyboardPalette->height()); - mKeyboardPalette->adjustSizeAndPosition(); - - mWindowPositionInitialized = true; } @@ -389,15 +368,6 @@ void UBDesktopAnnotationController::goToUniboard() } -void UBDesktopAnnotationController::showKeyboard(bool v) -{ - if (mKeyboardPalette!=NULL) - { - mKeyboardPalette->setVisible(v); - } -} - - void UBDesktopAnnotationController::customCapture() { mIsFullyTransparent = true; diff --git a/src/desktop/UBDesktopAnnotationController.h b/src/desktop/UBDesktopAnnotationController.h index f6c58f86..ded584bf 100644 --- a/src/desktop/UBDesktopAnnotationController.h +++ b/src/desktop/UBDesktopAnnotationController.h @@ -52,7 +52,6 @@ class UBDesktopAnnotationController : public QObject void screenLayoutChanged(); void goToUniboard(); - void showKeyboard(bool v); void customCapture(); void windowCapture(); void screenCapture(); @@ -103,7 +102,6 @@ class UBDesktopAnnotationController : public QObject UBDesktopPenPalette* mDesktopPenPalette; UBDesktopMarkerPalette* mDesktopMarkerPalette; UBDesktopEraserPalette* mDesktopEraserPalette; - UBKeyboardPalette* mKeyboardPalette; UBLibPalette* mLibPalette; diff --git a/src/gui/UBFloatingPalette.cpp b/src/gui/UBFloatingPalette.cpp index 6165df3b..3f83764a 100644 --- a/src/gui/UBFloatingPalette.cpp +++ b/src/gui/UBFloatingPalette.cpp @@ -10,7 +10,7 @@ UBFloatingPalette::UBFloatingPalette(Qt::Corner position, QWidget *parent) - : QWidget(parent, Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint) + : QWidget(parent, parent ? Qt::Widget : Qt::Tool | (Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint)) , mIsMoving(false) , mCustomPosition(false) , mCanBeMinimized(false) @@ -27,7 +27,9 @@ UBFloatingPalette::UBFloatingPalette(Qt::Corner position, QWidget *parent) { // standalone window setAttribute(Qt::WA_TranslucentBackground); - UBPlatformUtils::disableShadow(this); + setAttribute(Qt::WA_MacAlwaysShowToolWindow); + setAttribute(Qt::WA_MacNonActivatingToolWindow); + setAttribute(Qt::WA_MacNoShadow); } mBackgroundBrush = QBrush(UBSettings::paletteColor); diff --git a/src/gui/UBFloatingPalette.h b/src/gui/UBFloatingPalette.h index ba0dbb84..4d6a55c3 100644 --- a/src/gui/UBFloatingPalette.h +++ b/src/gui/UBFloatingPalette.h @@ -59,6 +59,7 @@ class UBFloatingPalette : public QWidget static const int sLayoutSpacing = 15; void moveInsideParent(const QPoint &position); bool mCustomPosition; + bool mIsMoving; private: void removeAllAssociatedPalette(); @@ -66,7 +67,6 @@ class UBFloatingPalette : public QWidget QList mAssociatedPalette; QPoint mDragPosition; - bool mIsMoving; bool mCanBeMinimized; eMinimizedLocation mMinimizedLocation; Qt::Corner mDefaultPosition; diff --git a/src/gui/UBKeyboardPalette.cpp b/src/gui/UBKeyboardPalette.cpp index 3a6dc992..51d11d9d 100644 --- a/src/gui/UBKeyboardPalette.cpp +++ b/src/gui/UBKeyboardPalette.cpp @@ -195,9 +195,7 @@ void UBKeyboardPalette::enterEvent ( QEvent * ) void UBKeyboardPalette::leaveEvent ( QEvent * ) { - if (languagePopupActive) - return; - if (!keyboardActive) + if (languagePopupActive || !keyboardActive || mIsMoving) return; keyboardActive = false;