Implemented the desktop mode for Linux

preferencesAboutTextFull
shibakaneki 13 years ago
parent 80ceb2223d
commit 4f3b163b34
  1. 24
      src/board/UBBoardView.cpp
  2. 107
      src/desktop/UBDesktopAnnotationController.cpp
  3. 4
      src/desktop/UBDesktopAnnotationController.h
  4. 9
      src/desktop/UBDesktopPalette.cpp
  5. 1
      src/desktop/UBDesktopPalette.h
  6. 4
      src/domain/UBGraphicsScene.cpp
  7. 1
      src/gui/UBFloatingPalette.cpp
  8. 1
      src/gui/UBFloatingPalette.h
  9. 3
      src/gui/UBLibPalette.cpp
  10. 3
      src/gui/UBLibPalette.h

@ -462,18 +462,18 @@ UBBoardView::mousePressEvent (QMouseEvent *event)
event->accept (); event->accept ();
} }
else else
{ {
if(UBDrawingController::drawingController()->mActiveRuler==NULL) if(UBDrawingController::drawingController()->mActiveRuler==NULL)
{ {
viewport()->setCursor (QCursor (Qt::BlankCursor)); viewport()->setCursor (QCursor (Qt::BlankCursor));
} }
if (scene () && !mTabletStylusIsPressed) if (scene () && !mTabletStylusIsPressed)
{ {
scene ()->inputDevicePress (mapToScene (UBGeometryUtils::pointConstrainedInRect (event->pos (), rect ()))); scene ()->inputDevicePress (mapToScene (UBGeometryUtils::pointConstrainedInRect (event->pos (), rect ())));
} }
event->accept (); event->accept ();
} }
} }
} }

@ -90,6 +90,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
mKeyboardPalette = UBKeyboardPalette::create(mTransparentDrawingView); mKeyboardPalette = UBKeyboardPalette::create(mTransparentDrawingView);
mKeyboardPalette->setParent(mTransparentDrawingView); mKeyboardPalette->setParent(mTransparentDrawingView);
connect(mKeyboardPalette, SIGNAL(keyboardActivated(bool)), mTransparentDrawingView, SLOT(virtualKeyboardActivated(bool))); connect(mKeyboardPalette, SIGNAL(keyboardActivated(bool)), mTransparentDrawingView, SLOT(virtualKeyboardActivated(bool)));
connect(mKeyboardPalette, SIGNAL(moved(QPoint)), this, SLOT(refreshMask()));
} }
connect(mDesktopPalette, SIGNAL(uniboardClick()), this, SLOT(goToUniboard())); connect(mDesktopPalette, SIGNAL(uniboardClick()), this, SLOT(goToUniboard()));
@ -143,12 +144,16 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
connect(&mHoldTimerMarker, SIGNAL(timeout()), this, SLOT(markerActionReleased())); connect(&mHoldTimerMarker, SIGNAL(timeout()), this, SLOT(markerActionReleased()));
connect(&mHoldTimerEraser, SIGNAL(timeout()), this, SLOT(eraserActionReleased())); connect(&mHoldTimerEraser, SIGNAL(timeout()), this, SLOT(eraserActionReleased()));
connect(mDesktopPalette, SIGNAL(moving()), this, SLOT(refreshMask()));
connect(mLibPalette, SIGNAL(resized()), this, SLOT(refreshMask()));
onDesktopPaletteMaximized(); onDesktopPaletteMaximized();
} }
void UBDesktopAnnotationController::showKeyboard(bool show) void UBDesktopAnnotationController::showKeyboard(bool show)
{ {
mKeyboardPalette->setVisible(show); mKeyboardPalette->setVisible(show);
updateMask(true);
// mDesktopPalette->showVirtualKeyboard(show); // mDesktopPalette->showVirtualKeyboard(show);
} }
@ -332,6 +337,10 @@ void UBDesktopAnnotationController::showWindow()
UBPlatformUtils::setDesktopMode(true); UBPlatformUtils::setDesktopMode(true);
mDesktopPalette->appear(); mDesktopPalette->appear();
#ifdef Q_WS_X11
updateMask(true);
#endif
} }
@ -343,7 +352,15 @@ void UBDesktopAnnotationController::close()
void UBDesktopAnnotationController::stylusToolChanged(int tool) void UBDesktopAnnotationController::stylusToolChanged(int tool)
{ {
Q_UNUSED(tool); UBStylusTool::Enum eTool = (UBStylusTool::Enum)tool;
mDesktopPalette->notifySelectorSelection(UBStylusTool::Selector == eTool);
if(UBStylusTool::Selector != eTool)
{
UBApplication::mainWindow->actionVirtualKeyboard->setChecked(false);
mKeyboardPalette->setVisible(false);
}
updateBackground(); updateBackground();
} }
@ -356,6 +373,9 @@ void UBDesktopAnnotationController::updateBackground()
|| UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Selector) || UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Selector)
{ {
newBrush = QBrush(Qt::transparent); newBrush = QBrush(Qt::transparent);
#ifdef Q_WS_X11
updateMask(true);
#endif
} }
else else
{ {
@ -363,6 +383,9 @@ void UBDesktopAnnotationController::updateBackground()
newBrush = QBrush(QColor(127, 127, 127, 15)); newBrush = QBrush(QColor(127, 127, 127, 15));
#else #else
newBrush = QBrush(QColor(127, 127, 127, 1)); newBrush = QBrush(QColor(127, 127, 127, 1));
#endif
#ifdef Q_WS_X11
updateMask(false);
#endif #endif
} }
@ -389,6 +412,8 @@ void UBDesktopAnnotationController::goToUniboard()
UBPlatformUtils::setDesktopMode(false); UBPlatformUtils::setDesktopMode(false);
UBApplication::mainWindow->actionVirtualKeyboard->setEnabled(true);
emit restoreUniboard(); emit restoreUniboard();
} }
@ -751,3 +776,83 @@ void UBDesktopAnnotationController::onTransparentWidgetResized()
// qDebug() << "mLibPalette (" << mLibPalette->width() << "," << mLibPalette->height() << ")"; // qDebug() << "mLibPalette (" << mLibPalette->width() << "," << mLibPalette->height() << ")";
mLibPalette->resize(mLibPalette->width(), mTransparentDrawingView->height()); mLibPalette->resize(mLibPalette->width(), mTransparentDrawingView->height());
} }
void UBDesktopAnnotationController::updateMask(bool bTransparent)
{
if(bTransparent)
{
// Here we have to generate a new mask. This method is certainly resource
// consuming but for the moment this is the only solution that I found.
mMask = QPixmap(mTransparentDrawingView->width(), mTransparentDrawingView->height());
QPainter p;
p.begin(&mMask);
p.setPen(Qt::red);
p.setBrush(QBrush(Qt::red));
// Here we draw the widget mask
if(mDesktopPalette->isVisible())
{
p.drawRect(mDesktopPalette->geometry().x(), mDesktopPalette->geometry().y(), mDesktopPalette->width(), mDesktopPalette->height());
}
if(mKeyboardPalette->isVisible())
{
p.drawRect(mKeyboardPalette->geometry().x(), mKeyboardPalette->geometry().y(), mKeyboardPalette->width(), mKeyboardPalette->height());
}
if(mLibPalette->isVisible())
{
p.drawRect(mLibPalette->geometry().x(), mLibPalette->geometry().y(), mLibPalette->width(), mLibPalette->height());
}
p.end();
// Then we add the annotations. We create another painter because we need to
// apply transformations on it for coordinates matching
QPainter annotationPainter;
QTransform trans;
trans.translate(mTransparentDrawingView->width()/2, mTransparentDrawingView->height()/2);
annotationPainter.begin(&mMask);
annotationPainter.setPen(Qt::red);
annotationPainter.setBrush(Qt::red);
annotationPainter.setTransform(trans);
QList<QGraphicsItem*> allItems = mTransparentDrawingScene->items();
for(int i = 0; i < allItems.size(); i++)
{
QGraphicsItem* pCrntItem = allItems.at(i);
if(pCrntItem->isVisible())
{
QPainterPath crntPath = pCrntItem->shape();
QRectF rect = crntPath.boundingRect();
annotationPainter.drawRect(rect);
}
}
annotationPainter.end();
mTransparentDrawingView->setMask(mMask.createMaskFromColor(Qt::black));
}
else
{
// Remove the mask
QPixmap noMask(mTransparentDrawingView->width(), mTransparentDrawingView->height());
mTransparentDrawingView->setMask(noMask.mask());
}
}
void UBDesktopAnnotationController::refreshMask()
{
if(mIsFullyTransparent
|| UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Selector)
{
updateMask(true);
}
}

@ -94,10 +94,12 @@ class UBDesktopAnnotationController : public QObject
void onDesktopPaletteMaximized(); void onDesktopPaletteMaximized();
void onDesktopPaletteMinimize(); void onDesktopPaletteMinimize();
void onTransparentWidgetResized(); void onTransparentWidgetResized();
void refreshMask();
private: private:
void setAssociatedPalettePosition(UBActionPalette* palette, const QString& actionName); void setAssociatedPalettePosition(UBActionPalette* palette, const QString& actionName);
void togglePropertyPalette(UBActionPalette* palette); void togglePropertyPalette(UBActionPalette* palette);
void updateMask(bool bTransparent);
UBDesktopPalette *mDesktopPalette; UBDesktopPalette *mDesktopPalette;
UBKeyboardPalette *mKeyboardPalette; UBKeyboardPalette *mKeyboardPalette;
@ -126,6 +128,8 @@ class UBDesktopAnnotationController : public QObject
int mBoardStylusTool; int mBoardStylusTool;
int mDesktopStylusTool; int mDesktopStylusTool;
QPixmap mMask;
}; };
#endif /* UBUNINOTESWINDOWCONTROLLER_H_ */ #endif /* UBUNINOTESWINDOWCONTROLLER_H_ */

@ -36,9 +36,7 @@ UBDesktopPalette::UBDesktopPalette(QWidget *parent)
actions << UBApplication::mainWindow->actionPen; actions << UBApplication::mainWindow->actionPen;
actions << UBApplication::mainWindow->actionEraser; actions << UBApplication::mainWindow->actionEraser;
actions << UBApplication::mainWindow->actionMarker; actions << UBApplication::mainWindow->actionMarker;
#ifndef Q_WS_X11
actions << UBApplication::mainWindow->actionSelector; actions << UBApplication::mainWindow->actionSelector;
#endif
actions << UBApplication::mainWindow->actionPointer; actions << UBApplication::mainWindow->actionPointer;
if (UBPlatformUtils::hasVirtualKeyboard()) if (UBPlatformUtils::hasVirtualKeyboard())
@ -152,9 +150,7 @@ void UBDesktopPalette::maximizeMe()
actions << UBApplication::mainWindow->actionPen; actions << UBApplication::mainWindow->actionPen;
actions << UBApplication::mainWindow->actionEraser; actions << UBApplication::mainWindow->actionEraser;
actions << UBApplication::mainWindow->actionMarker; actions << UBApplication::mainWindow->actionMarker;
#ifndef Q_WS_X11
actions << UBApplication::mainWindow->actionSelector; actions << UBApplication::mainWindow->actionSelector;
#endif
actions << UBApplication::mainWindow->actionPointer; actions << UBApplication::mainWindow->actionPointer;
if (UBPlatformUtils::hasVirtualKeyboard()) if (UBPlatformUtils::hasVirtualKeyboard())
actions << UBApplication::mainWindow->actionVirtualKeyboard; actions << UBApplication::mainWindow->actionVirtualKeyboard;
@ -221,3 +217,8 @@ QPoint UBDesktopPalette::buttonPos(QAction *action)
return p; return p;
} }
void UBDesktopPalette::notifySelectorSelection(bool selected)
{
UBApplication::mainWindow->actionVirtualKeyboard->setEnabled(selected);
}

@ -27,6 +27,7 @@ class UBDesktopPalette : public UBActionPalette
void disappearForCapture(); void disappearForCapture();
void appear(); void appear();
QPoint buttonPos(QAction* action); QPoint buttonPos(QAction* action);
void notifySelectorSelection(bool selected);
signals: signals:
void uniboardClick(); void uniboardClick();

@ -249,6 +249,8 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
{ {
if (currentTool == UBStylusTool::Line) if (currentTool == UBStylusTool::Line)
{ {
// TODO: Verify this beautiful implementation and check if
// it is possible to optimize it
QLineF radius(mPreviousPoint, position); QLineF radius(mPreviousPoint, position);
qreal angle = radius.angle(); qreal angle = radius.angle();
angle = qRound(angle / 45) * 45; angle = qRound(angle / 45) * 45;
@ -257,7 +259,7 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
mPreviousPoint.x() + radiusLength * cos((angle * PI) / 180), mPreviousPoint.x() + radiusLength * cos((angle * PI) / 180),
mPreviousPoint.y() - radiusLength * sin((angle * PI) / 180)); mPreviousPoint.y() - radiusLength * sin((angle * PI) / 180));
QLineF chord(position, newPosition); QLineF chord(position, newPosition);
if (chord.length() < qMin((int)16, (int)(radiusLength / 20))) if (chord.length() < qMin((int)16, (int)(radiusLength / 20)))
position = newPosition; position = newPosition;
} }

@ -106,6 +106,7 @@ void UBFloatingPalette::mouseMoveEvent(QMouseEvent *event)
{ {
moveInsideParent(event->globalPos() - mDragPosition); moveInsideParent(event->globalPos() - mDragPosition);
event->accept(); event->accept();
emit moving();
} }
else else
{ {

@ -78,6 +78,7 @@ class UBFloatingPalette : public QWidget
void minimizeStart(eMinimizedLocation location); void minimizeStart(eMinimizedLocation location);
void maximizeStart(); void maximizeStart();
void maximized(); void maximized();
void moving();
}; };

@ -34,7 +34,7 @@ UBLibPalette::UBLibPalette(QWidget *parent, const char *name):UBDockPalette(pare
mIcon = QPixmap(":images/paletteLibrary.png"); mIcon = QPixmap(":images/paletteLibrary.png");
setAcceptDrops(true); setAcceptDrops(true);
resize(UBSettings::settings()->libPaletteWidth->get().toInt(), height()); resize(UBSettings::settings()->libPaletteWidth->get().toInt(), parentWidget()->height());
setContentsMargins(border(), 0, 0, 0); setContentsMargins(border(), 0, 0, 0);
mCollapseWidth = 180; mCollapseWidth = 180;
mLastWidth = 300; mLastWidth = 300;
@ -201,6 +201,7 @@ void UBLibPalette::resizeEvent(QResizeEvent *event)
{ {
UBDockPalette::resizeEvent(event); UBDockPalette::resizeEvent(event);
UBSettings::settings()->libPaletteWidth->set(width()); UBSettings::settings()->libPaletteWidth->set(width());
emit resized();
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------

@ -55,6 +55,9 @@ public:
UBLibActionBar* actionBar(){return mActionBar;} UBLibActionBar* actionBar(){return mActionBar;}
signals:
void resized();
protected: protected:
void updateMaxWidth(); void updateMaxWidth();
void dragEnterEvent(QDragEnterEvent* pEvent); void dragEnterEvent(QDragEnterEvent* pEvent);

Loading…
Cancel
Save