From 47dd119c76d6315aea511a1dbd90289a48c9dfbf Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Mon, 10 Sep 2012 09:37:26 +0200 Subject: [PATCH 1/7] Modified placeholder management in teacherguide --- src/gui/UBTeacherGuideWidgetsTools.cpp | 50 +++++++++++++------------- src/gui/UBTeacherGuideWidgetsTools.h | 7 +++- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/src/gui/UBTeacherGuideWidgetsTools.cpp b/src/gui/UBTeacherGuideWidgetsTools.cpp index 4456b243..b71bf82f 100644 --- a/src/gui/UBTeacherGuideWidgetsTools.cpp +++ b/src/gui/UBTeacherGuideWidgetsTools.cpp @@ -148,30 +148,10 @@ void UBTGAdaptableText::setPlaceHolderText(QString text) setPlainText(mPlaceHolderText); } -void UBTGAdaptableText::keyPressEvent(QKeyEvent* e) -{ - if(isReadOnly()){ - // this is important if you set a placeholder. In this case even if the text field is readonly the - // keypressed event came here. So if you don't ignore it you'll have a flick on the text zone - e->ignore(); - return; - } - - if(toPlainText() == mPlaceHolderText){ - setPlainText(""); - } - setTextColor(QColor(Qt::black)); - QTextEdit::keyPressEvent(e); -} - void UBTGAdaptableText::keyReleaseEvent(QKeyEvent* e) { QTextEdit::keyReleaseEvent(e); - if(toPlainText().isEmpty()){ - setTextColor(QColor(Qt::lightGray)); - setPlainText(mPlaceHolderText); - } if(mMaximumLength && toPlainText().length()>mMaximumLength){ setPlainText(toPlainText().left(mMaximumLength)); QTextCursor tc(document()); @@ -183,8 +163,10 @@ void UBTGAdaptableText::keyReleaseEvent(QKeyEvent* e) void UBTGAdaptableText::showEvent(QShowEvent* e) { Q_UNUSED(e); - if(!mIsUpdatingSize && mHasPlaceHolder && toPlainText().isEmpty()) - setPlainText(mPlaceHolderText); + if(!mIsUpdatingSize && mHasPlaceHolder && toPlainText().isEmpty()){ + setTextColor(QColor(Qt::lightGray)); + setPlainText(mPlaceHolderText); + } else // If the teacherguide is collapsed, don't updated the size. Or set the size as the expanded size onTextChanged(); @@ -201,9 +183,7 @@ QString UBTGAdaptableText::text() void UBTGAdaptableText::onTextChanged() { - //qDebug() << ">> onTextChanged CALLED!"; qreal documentSize = document()->size().height(); - //qDebug() << ">> documentSize: " << documentSize << ", height: " << height(); if(height() == documentSize + mBottomMargin){ return; } @@ -248,6 +228,28 @@ void UBTGAdaptableText::bottomMargin(int newValue) onTextChanged(); } +void UBTGAdaptableText::focusInEvent(QFocusEvent* e){ + if(isReadOnly()){ + e->ignore(); + } + managePlaceholder(); + QTextEdit::focusInEvent(e); +} + +void UBTGAdaptableText::focusOutEvent(QFocusEvent* e){ + if(toPlainText().isEmpty()){ + setTextColor(QColor(Qt::lightGray)); + setPlainText(mPlaceHolderText); + } + QTextEdit::focusOutEvent(e); +} + +void UBTGAdaptableText::managePlaceholder(){ + if(toPlainText() == mPlaceHolderText){ + setTextColor(QColor(Qt::black)); + setPlainText(""); + } +} /*************************************************************************** * class UBTGDraggableWeb * diff --git a/src/gui/UBTeacherGuideWidgetsTools.h b/src/gui/UBTeacherGuideWidgetsTools.h index 2f87ccfd..364f3d99 100644 --- a/src/gui/UBTeacherGuideWidgetsTools.h +++ b/src/gui/UBTeacherGuideWidgetsTools.h @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include "customWidgets/UBMediaWidget.h" @@ -103,11 +105,14 @@ public slots: void onTextChanged(); protected: - void keyPressEvent(QKeyEvent* e); void keyReleaseEvent(QKeyEvent* e); void showEvent(QShowEvent* e); + void focusInEvent(QFocusEvent* e); + void focusOutEvent(QFocusEvent* e); private: + void managePlaceholder(); + int mBottomMargin; QTreeWidgetItem* mpTreeWidgetItem; int mMinimumHeight; From 1d06110b5ef99dd7b136cc12d52ac3b6b22e2837 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Mon, 10 Sep 2012 12:07:33 +0200 Subject: [PATCH 2/7] Resolved the placeholder issue in the new ubtgadaptabletext implementation --- src/gui/UBTeacherGuideWidget.cpp | 4 ++++ src/gui/UBTeacherGuideWidgetsTools.cpp | 26 ++++++++++++++------------ src/gui/UBTeacherGuideWidgetsTools.h | 3 +-- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/gui/UBTeacherGuideWidget.cpp b/src/gui/UBTeacherGuideWidget.cpp index 679da6a8..cfa76117 100644 --- a/src/gui/UBTeacherGuideWidget.cpp +++ b/src/gui/UBTeacherGuideWidget.cpp @@ -1023,14 +1023,18 @@ void UBTeacherGuidePageZeroWidget::switchToMode(tUBTGZeroPageMode mode) QString inputStyleSheet("QTextEdit { background: white; border-radius: 10px; border: 2px;}"); mpModePushButton->hide(); mpSessionTitle->setReadOnly(false); + mpSessionTitle->managePlaceholder(false); mpSessionTitle->setStyleSheet(inputStyleSheet); QFont titleFont(QApplication::font().family(), 11, -1); mpSessionTitle->document()->setDefaultFont(titleFont); mpAuthors->setReadOnly(false); + mpAuthors->managePlaceholder(false); mpAuthors->setStyleSheet(inputStyleSheet); mpObjectives->setReadOnly(false); + mpObjectives->managePlaceholder(false); mpObjectives->setStyleSheet(inputStyleSheet); mpKeywords->setReadOnly(false); + mpKeywords->managePlaceholder(false); mpKeywords->setStyleSheet(inputStyleSheet); mpSchoolLevelValueLabel->hide(); mpSchoolLevelBox->show(); diff --git a/src/gui/UBTeacherGuideWidgetsTools.cpp b/src/gui/UBTeacherGuideWidgetsTools.cpp index b71bf82f..7ecfbd27 100644 --- a/src/gui/UBTeacherGuideWidgetsTools.cpp +++ b/src/gui/UBTeacherGuideWidgetsTools.cpp @@ -163,7 +163,7 @@ void UBTGAdaptableText::keyReleaseEvent(QKeyEvent* e) void UBTGAdaptableText::showEvent(QShowEvent* e) { Q_UNUSED(e); - if(!mIsUpdatingSize && mHasPlaceHolder && toPlainText().isEmpty()){ + if(!mIsUpdatingSize && mHasPlaceHolder && toPlainText().isEmpty() && !isReadOnly()){ setTextColor(QColor(Qt::lightGray)); setPlainText(mPlaceHolderText); } @@ -204,8 +204,6 @@ void UBTGAdaptableText::onTextChanged() setFocus(); } mIsUpdatingSize = false; - - } void UBTGAdaptableText::setInitialText(const QString& text) @@ -232,22 +230,26 @@ void UBTGAdaptableText::focusInEvent(QFocusEvent* e){ if(isReadOnly()){ e->ignore(); } - managePlaceholder(); + managePlaceholder(true); QTextEdit::focusInEvent(e); } void UBTGAdaptableText::focusOutEvent(QFocusEvent* e){ - if(toPlainText().isEmpty()){ - setTextColor(QColor(Qt::lightGray)); - setPlainText(mPlaceHolderText); - } + managePlaceholder(false); QTextEdit::focusOutEvent(e); } -void UBTGAdaptableText::managePlaceholder(){ - if(toPlainText() == mPlaceHolderText){ - setTextColor(QColor(Qt::black)); - setPlainText(""); +void UBTGAdaptableText::managePlaceholder(bool focus){ + if(focus){ + if(toPlainText() == mPlaceHolderText){ + setTextColor(QColor(Qt::black)); + setPlainText(""); + } + }else{ + if(toPlainText().isEmpty()){ + setTextColor(QColor(Qt::lightGray)); + setPlainText(mPlaceHolderText); + } } } diff --git a/src/gui/UBTeacherGuideWidgetsTools.h b/src/gui/UBTeacherGuideWidgetsTools.h index 364f3d99..933bdd30 100644 --- a/src/gui/UBTeacherGuideWidgetsTools.h +++ b/src/gui/UBTeacherGuideWidgetsTools.h @@ -100,6 +100,7 @@ public: QString text(); void setInitialText(const QString& text); void setMaximumLength(int length); + void managePlaceholder(bool focus); public slots: void onTextChanged(); @@ -111,8 +112,6 @@ protected: void focusOutEvent(QFocusEvent* e); private: - void managePlaceholder(); - int mBottomMargin; QTreeWidgetItem* mpTreeWidgetItem; int mMinimumHeight; From 77aa2783a23e0db96d997db7b239616177be3e37 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Mon, 10 Sep 2012 15:39:57 +0200 Subject: [PATCH 3/7] Fixed some little things --- src/gui/UBTeacherGuideWidget.cpp | 2 +- src/gui/UBTeacherGuideWidgetsTools.cpp | 23 +++++++++++++++++++---- src/gui/UBTeacherGuideWidgetsTools.h | 1 + 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/gui/UBTeacherGuideWidget.cpp b/src/gui/UBTeacherGuideWidget.cpp index cfa76117..03e5190d 100644 --- a/src/gui/UBTeacherGuideWidget.cpp +++ b/src/gui/UBTeacherGuideWidget.cpp @@ -1023,7 +1023,7 @@ void UBTeacherGuidePageZeroWidget::switchToMode(tUBTGZeroPageMode mode) QString inputStyleSheet("QTextEdit { background: white; border-radius: 10px; border: 2px;}"); mpModePushButton->hide(); mpSessionTitle->setReadOnly(false); - mpSessionTitle->managePlaceholder(false); + mpSessionTitle->managePlaceholder(true); mpSessionTitle->setStyleSheet(inputStyleSheet); QFont titleFont(QApplication::font().family(), 11, -1); mpSessionTitle->document()->setDefaultFont(titleFont); diff --git a/src/gui/UBTeacherGuideWidgetsTools.cpp b/src/gui/UBTeacherGuideWidgetsTools.cpp index 7ecfbd27..c67b09a8 100644 --- a/src/gui/UBTeacherGuideWidgetsTools.cpp +++ b/src/gui/UBTeacherGuideWidgetsTools.cpp @@ -24,6 +24,9 @@ #include #include #include +#include +#include +#include #include "UBTeacherGuideWidgetsTools.h" @@ -190,10 +193,11 @@ void UBTGAdaptableText::onTextChanged() mIsUpdatingSize = true; - if(documentSize < mMinimumHeight) - setFixedHeight(mMinimumHeight); - else - setFixedHeight(documentSize+mBottomMargin); + if(documentSize < mMinimumHeight){ + setFixedHeight(mMinimumHeight); + }else{ + setFixedHeight(documentSize+mBottomMargin); + } updateGeometry(); //to trig a resize on the tree widget item @@ -245,6 +249,7 @@ void UBTGAdaptableText::managePlaceholder(bool focus){ setTextColor(QColor(Qt::black)); setPlainText(""); } + setCursorToTheEnd(); }else{ if(toPlainText().isEmpty()){ setTextColor(QColor(Qt::lightGray)); @@ -253,6 +258,16 @@ void UBTGAdaptableText::managePlaceholder(bool focus){ } } +void UBTGAdaptableText::setCursorToTheEnd(){ + QTextDocument* doc = document(); + if(NULL != doc){ + QTextBlock block = doc->lastBlock(); + QTextCursor cursor(doc); + cursor.setPosition(block.position() + block.length() - 1); + setTextCursor(cursor); + } +} + /*************************************************************************** * class UBTGDraggableWeb * ***************************************************************************/ diff --git a/src/gui/UBTeacherGuideWidgetsTools.h b/src/gui/UBTeacherGuideWidgetsTools.h index 933bdd30..cd37fe2d 100644 --- a/src/gui/UBTeacherGuideWidgetsTools.h +++ b/src/gui/UBTeacherGuideWidgetsTools.h @@ -112,6 +112,7 @@ protected: void focusOutEvent(QFocusEvent* e); private: + void setCursorToTheEnd(); int mBottomMargin; QTreeWidgetItem* mpTreeWidgetItem; int mMinimumHeight; From 197ba3a5f4a8a66c295d10f6be1cc4f9767cdc4d Mon Sep 17 00:00:00 2001 From: Aleksei Kanash Date: Mon, 10 Sep 2012 17:01:15 +0300 Subject: [PATCH 4/7] Fixed undo stack for background objects. --- src/board/UBBoardController.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp index 3a6a2394..d5032fc0 100644 --- a/src/board/UBBoardController.cpp +++ b/src/board/UBBoardController.cpp @@ -950,6 +950,10 @@ void UBBoardController::downloadURL(const QUrl& url, const QPointF& pPos, const qDebug() << "something has been dropped on the board! Url is: " << url.toString(); QString sUrl = url.toString(); + QGraphicsItem *oldBackgroundObject = NULL; + if (isBackground) + oldBackgroundObject = mActiveScene->backgroundObject(); + if(sUrl.startsWith("uniboardTool://")) { downloadFinished(true, url, "application/vnd.mnemis-uniboard-tool", QByteArray(), pPos, pSize, isBackground); @@ -990,6 +994,16 @@ void UBBoardController::downloadURL(const QUrl& url, const QPointF& pPos, const UBDownloadManager::downloadManager()->addFileToDownload(desc); } + + if (isBackground && oldBackgroundObject != mActiveScene->backgroundObject()) + { + if (mActiveScene->isURStackIsEnabled()) { //should be deleted after scene own undo stack implemented + UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(mActiveScene, oldBackgroundObject, mActiveScene->backgroundObject()); + UBApplication::undoStack->push(uc); + } + } + + } From 816bfaa42873a704a89c035a3f120d055dd69465 Mon Sep 17 00:00:00 2001 From: Aleksei Kanash Date: Mon, 10 Sep 2012 18:30:51 +0300 Subject: [PATCH 5/7] Fixed changing mode from desktop to board. --- src/core/UBApplicationController.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/UBApplicationController.cpp b/src/core/UBApplicationController.cpp index c0f9918a..c711184b 100644 --- a/src/core/UBApplicationController.cpp +++ b/src/core/UBApplicationController.cpp @@ -595,7 +595,7 @@ void UBApplicationController::checkUpdateRequest() void UBApplicationController::hideDesktop() { - mDisplayManager->adjustScreens(-1); + if(UBStylusTool::Eraser != UBDrawingController::drawingController()->stylusTool()){ UBDrawingController::drawingController()->setDrawingMode(eDrawingMode_Vector); @@ -623,6 +623,9 @@ void UBApplicationController::hideDesktop() } mIsShowingDesktop = false; + + mDisplayManager->adjustScreens(-1); + emit desktopMode(false); } From 76b2d83bc2b493c97ad963431b4615e81bdf8909 Mon Sep 17 00:00:00 2001 From: Aleksei Kanash Date: Tue, 11 Sep 2012 11:23:58 +0300 Subject: [PATCH 6/7] Fixed adding lines to stroke groups. --- src/domain/UBGraphicsScene.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index 352d0f2a..2ac7e581 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -742,6 +742,9 @@ void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth, // Here we add the item to the scene addItem(polygonItem); + if (!mCurrentStroke) + mCurrentStroke = new UBGraphicsStroke(); + if (mCurrentStroke) { polygonItem->setStroke(mCurrentStroke); From 1f83f35176b6bf7d89fc8fd13212c82997bcf66e Mon Sep 17 00:00:00 2001 From: Aleksei Kanash Date: Tue, 11 Sep 2012 12:52:22 +0300 Subject: [PATCH 7/7] Fixed writing a lines with Marker. --- src/domain/UBGraphicsScene.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index 2ac7e581..48929e63 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -477,6 +477,7 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres if (currentTool == UBStylusTool::Line || dc->mActiveRuler) { + if (UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Marker) if(NULL != mpLastPolygon && NULL != mCurrentStroke && mAddedItems.size() > 0){ UBCoreGraphicsScene::removeItemFromDeletion(mpLastPolygon); mAddedItems.remove(mpLastPolygon);