Implemented the desktop mode for Linux

preferencesAboutTextFull
shibakaneki 14 years ago
parent 80ceb2223d
commit 4f3b163b34
  1. 1758
      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

File diff suppressed because it is too large Load Diff

@ -90,6 +90,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
mKeyboardPalette = UBKeyboardPalette::create(mTransparentDrawingView);
mKeyboardPalette->setParent(mTransparentDrawingView);
connect(mKeyboardPalette, SIGNAL(keyboardActivated(bool)), mTransparentDrawingView, SLOT(virtualKeyboardActivated(bool)));
connect(mKeyboardPalette, SIGNAL(moved(QPoint)), this, SLOT(refreshMask()));
}
connect(mDesktopPalette, SIGNAL(uniboardClick()), this, SLOT(goToUniboard()));
@ -143,12 +144,16 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
connect(&mHoldTimerMarker, SIGNAL(timeout()), this, SLOT(markerActionReleased()));
connect(&mHoldTimerEraser, SIGNAL(timeout()), this, SLOT(eraserActionReleased()));
connect(mDesktopPalette, SIGNAL(moving()), this, SLOT(refreshMask()));
connect(mLibPalette, SIGNAL(resized()), this, SLOT(refreshMask()));
onDesktopPaletteMaximized();
}
void UBDesktopAnnotationController::showKeyboard(bool show)
{
mKeyboardPalette->setVisible(show);
updateMask(true);
// mDesktopPalette->showVirtualKeyboard(show);
}
@ -332,6 +337,10 @@ void UBDesktopAnnotationController::showWindow()
UBPlatformUtils::setDesktopMode(true);
mDesktopPalette->appear();
#ifdef Q_WS_X11
updateMask(true);
#endif
}
@ -343,7 +352,15 @@ void UBDesktopAnnotationController::close()
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();
}
@ -356,6 +373,9 @@ void UBDesktopAnnotationController::updateBackground()
|| UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Selector)
{
newBrush = QBrush(Qt::transparent);
#ifdef Q_WS_X11
updateMask(true);
#endif
}
else
{
@ -363,6 +383,9 @@ void UBDesktopAnnotationController::updateBackground()
newBrush = QBrush(QColor(127, 127, 127, 15));
#else
newBrush = QBrush(QColor(127, 127, 127, 1));
#endif
#ifdef Q_WS_X11
updateMask(false);
#endif
}
@ -389,6 +412,8 @@ void UBDesktopAnnotationController::goToUniboard()
UBPlatformUtils::setDesktopMode(false);
UBApplication::mainWindow->actionVirtualKeyboard->setEnabled(true);
emit restoreUniboard();
}
@ -751,3 +776,83 @@ void UBDesktopAnnotationController::onTransparentWidgetResized()
// qDebug() << "mLibPalette (" << mLibPalette->width() << "," << mLibPalette->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 onDesktopPaletteMinimize();
void onTransparentWidgetResized();
void refreshMask();
private:
void setAssociatedPalettePosition(UBActionPalette* palette, const QString& actionName);
void togglePropertyPalette(UBActionPalette* palette);
void updateMask(bool bTransparent);
UBDesktopPalette *mDesktopPalette;
UBKeyboardPalette *mKeyboardPalette;
@ -126,6 +128,8 @@ class UBDesktopAnnotationController : public QObject
int mBoardStylusTool;
int mDesktopStylusTool;
QPixmap mMask;
};
#endif /* UBUNINOTESWINDOWCONTROLLER_H_ */

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

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

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

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

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

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

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

Loading…
Cancel
Save