Issue Sankore 1554

preferencesAboutTextFull
Nicolas Nenon 11 years ago committed by -f
parent cb64a03751
commit eb60133355
  1. 1
      src/adaptors/UBSvgSubsetAdaptor.cpp
  2. 25
      src/board/UBBoardView.cpp
  3. 16
      src/domain/UBGraphicsScene.cpp
  4. 1
      src/domain/UBGraphicsScene.h
  5. 17
      src/domain/UBGraphicsTextItem.cpp
  6. 4
      src/domain/UBGraphicsTextItem.h

@ -29,6 +29,7 @@
#include <QtCore> #include <QtCore>
#include <QtXml> #include <QtXml>
#include <QGraphicsTextItem>
#include "domain/UBGraphicsSvgItem.h" #include "domain/UBGraphicsSvgItem.h"
#include "domain/UBGraphicsPixmapItem.h" #include "domain/UBGraphicsPixmapItem.h"

@ -497,30 +497,7 @@ void UBBoardView::handleItemsSelection(QGraphicsItem *item)
// only with UB items. // only with UB items.
if ((UBGraphicsItemType::UserTypesCount > item->type()) && (item->type() > QGraphicsItem::UserType)) if ((UBGraphicsItemType::UserTypesCount > item->type()) && (item->type() > QGraphicsItem::UserType))
{ {
// if Item can be selected at mouse press - then we need to deselect all other items. scene()->deselectAllItemsExcept(item);
foreach(QGraphicsItem *iter_item, scene()->selectedItems())
{
if (iter_item != item)
{
iter_item->setSelected(false);
}
}
}
}
}else{
// Deselect the other items
foreach(QGraphicsItem* it, scene()->selectedItems()){
UBGraphicsGroupContainerItem* pGroup = dynamic_cast<UBGraphicsGroupContainerItem*>(it);
if(NULL != pGroup){
foreach(QGraphicsItem* pGIt, pGroup->childItems()){
UBGraphicsTextItem* pTxt = dynamic_cast<UBGraphicsTextItem*>(pGIt);
if(NULL != pTxt){
// We must clear the text selection
QTextCursor t = pTxt->textCursor();
t.clearSelection();
pTxt->setTextCursor(t);
}
}
} }
} }
} }

@ -1685,6 +1685,22 @@ void UBGraphicsScene::deselectAllItems()
if (mSelectionFrame) { if (mSelectionFrame) {
mSelectionFrame->setEnclosedItems(QList<QGraphicsItem*>()); mSelectionFrame->setEnclosedItems(QList<QGraphicsItem*>());
} }
UBGraphicsTextItem* textItem = dynamic_cast<UBGraphicsTextItem*>(gi);
if(textItem)
textItem->activateTextEditor(false);
}
}
void UBGraphicsScene::deselectAllItemsExcept(QGraphicsItem* item)
{
foreach(QGraphicsItem* eachItem,selectedItems()){
if(eachItem != item){
eachItem->setSelected(false);
UBGraphicsTextItem* textItem = dynamic_cast<UBGraphicsTextItem*>(eachItem);
if(textItem)
textItem->activateTextEditor(false);
}
} }
} }

@ -317,6 +317,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
void clearSelectionFrame(); void clearSelectionFrame();
UBBoardView *controlView(); UBBoardView *controlView();
void notifyZChanged(QGraphicsItem *item, qreal zValue); void notifyZChanged(QGraphicsItem *item, qreal zValue);
void deselectAllItemsExcept(QGraphicsItem* graphicsItem);
public slots: public slots:
void updateSelectionFrame(); void updateSelectionFrame();

@ -47,6 +47,7 @@ UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent)
, mMultiClickState(0) , mMultiClickState(0)
, mLastMousePressTime(QTime::currentTime()) , mLastMousePressTime(QTime::currentTime())
, mTypeTextHereLabel(tr("<Type Text Here>")) , mTypeTextHereLabel(tr("<Type Text Here>"))
, isActivatedTextEditor(true)
{ {
setDelegate(new UBGraphicsTextItemDelegate(this, 0)); setDelegate(new UBGraphicsTextItemDelegate(this, 0));
@ -152,6 +153,7 @@ void UBGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
if (mMultiClickState == 1) if (mMultiClickState == 1)
{ {
activateTextEditor(true);
QGraphicsTextItem::mousePressEvent(event); QGraphicsTextItem::mousePressEvent(event);
setFocus(); setFocus();
} }
@ -373,8 +375,17 @@ void UBGraphicsTextItem::documentSizeChanged(const QSizeF & newSize)
resize(newSize.width(), newSize.height()); resize(newSize.width(), newSize.height());
} }
void UBGraphicsTextItem::setHtml(const QString &text) void UBGraphicsTextItem::activateTextEditor(bool activate)
{ {
QGraphicsTextItem::setHtml(text); qDebug() << textInteractionFlags();
setTextInteractionFlags(Qt::NoTextInteraction);
this->isActivatedTextEditor = activate;
if(!activate){
setTextInteractionFlags(Qt::TextSelectableByMouse);
}else{
setTextInteractionFlags(Qt::TextEditorInteraction);
}
qDebug() << textInteractionFlags();
} }

@ -94,8 +94,7 @@ class UBGraphicsTextItem : public QGraphicsTextItem, public UBItem, public UBRes
virtual void clearSource(){;} virtual void clearSource(){;}
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);
void setHtml(const QString &text); void activateTextEditor(bool activate);
void setSelected(bool selected); void setSelected(bool selected);
QString mTypeTextHereLabel; QString mTypeTextHereLabel;
@ -126,6 +125,7 @@ class UBGraphicsTextItem : public QGraphicsTextItem, public UBItem, public UBRes
QColor mColorOnDarkBackground; QColor mColorOnDarkBackground;
QColor mColorOnLightBackground; QColor mColorOnLightBackground;
bool isActivatedTextEditor;
}; };
#endif /* UBGRAPHICSTEXTITEM_H_ */ #endif /* UBGRAPHICSTEXTITEM_H_ */

Loading…
Cancel
Save