Merge branch 'develop' of github.com:OpenEducationFoundation/OpenBoard into develop

preferencesAboutTextFull
Claudio Valerio 11 years ago
commit efd2c485a3
  1. 12
      src/domain/UBGraphicsItemDelegate.cpp
  2. 3
      src/domain/UBGraphicsItemDelegate.h
  3. 24
      src/domain/UBGraphicsTextItem.cpp
  4. 3
      src/domain/UBGraphicsTextItem.h
  5. 37
      src/domain/UBGraphicsTextItemDelegate.cpp
  6. 4
      src/domain/UBGraphicsTextItemDelegate.h

@ -407,6 +407,18 @@ void UBGraphicsItemDelegate::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
} }
bool UBGraphicsItemDelegate::keyPressEvent(QKeyEvent *event)
{
Q_UNUSED(event);
return true;
}
bool UBGraphicsItemDelegate::keyReleaseEvent(QKeyEvent *event)
{
Q_UNUSED(event);
return true;
}
QGraphicsItem *UBGraphicsItemDelegate::delegated() QGraphicsItem *UBGraphicsItemDelegate::delegated()
{ {
QGraphicsItem *curDelegate = 0; QGraphicsItem *curDelegate = 0;

@ -255,6 +255,9 @@ class UBGraphicsItemDelegate : public QObject
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event); virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
virtual bool keyPressEvent(QKeyEvent *event);
virtual bool keyReleaseEvent(QKeyEvent *event);
virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange change, virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange change,
const QVariant &value); const QVariant &value);
virtual UBGraphicsScene *castUBGraphicsScene(); virtual UBGraphicsScene *castUBGraphicsScene();

@ -201,10 +201,10 @@ void UBGraphicsTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
if (mMultiClickState == 1) if (mMultiClickState == 1)
{ {
QGraphicsTextItem::mouseReleaseEvent(event);
if (Delegate()) if (Delegate())
Delegate()->mouseReleaseEvent(event); Delegate()->mouseReleaseEvent(event);
QGraphicsTextItem::mouseReleaseEvent(event);
} }
else else
{ {
@ -212,6 +212,26 @@ void UBGraphicsTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
} }
} }
void UBGraphicsTextItem::keyPressEvent(QKeyEvent *event)
{
if (Delegate() && !Delegate()->keyPressEvent(event)) {
qDebug() << "UBGraphicsTextItem::keyPressEvent(QKeyEvent *event) has been rejected by delegate. Don't call base class method";
return;
}
QGraphicsTextItem::keyPressEvent(event);
}
void UBGraphicsTextItem::keyReleaseEvent(QKeyEvent *event)
{
if (Delegate() && !Delegate()->keyReleaseEvent(event)) {
qDebug() << "UBGraphicsTextItem::keyPressEvent(QKeyEvent *event) has been rejected by delegate. Don't call base class method";
return;
}
QGraphicsTextItem::keyReleaseEvent(event);
}
void UBGraphicsTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void UBGraphicsTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{ {
QColor color = UBSettings::settings()->isDarkBackground() ? mColorOnDarkBackground : mColorOnLightBackground; QColor color = UBSettings::settings()->isDarkBackground() ? mColorOnDarkBackground : mColorOnLightBackground;

@ -110,6 +110,9 @@ class UBGraphicsTextItem : public QGraphicsTextItem, public UBItem, public UBRes
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void keyPressEvent(QKeyEvent *event);
virtual void keyReleaseEvent(QKeyEvent *event);
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);

@ -334,6 +334,8 @@ void UBGraphicsTextItemDelegate::alignButtonProcess()
AlignTextButton *asAlText = static_cast<AlignTextButton*>(mAlignButton); AlignTextButton *asAlText = static_cast<AlignTextButton*>(mAlignButton);
if (asAlText->nextKind() == AlignTextButton::k_mixed) { if (asAlText->nextKind() == AlignTextButton::k_mixed) {
restoreTextCursorFormats(); restoreTextCursorFormats();
asAlText->setNextKind();
return;
} }
asAlText->setNextKind(); asAlText->setNextKind();
@ -366,14 +368,19 @@ void UBGraphicsTextItemDelegate::onCursorPositionChanged(const QTextCursor &curs
qDebug() << "-----------------------"; qDebug() << "-----------------------";
qDebug() << "we have a selection!" << cursor.selectionStart(); qDebug() << "we have a selection!" << cursor.selectionStart();
qDebug() << "-----------------------"; qDebug() << "-----------------------";
updateAlighButtonState(); // updateAlighButtonState();
} }
void UBGraphicsTextItemDelegate::onModificationChanged(bool ch) void UBGraphicsTextItemDelegate::onModificationChanged(bool ch)
{ {
Q_UNUSED(ch); Q_UNUSED(ch);
qDebug() << "modification changed"; qDebug() << "modification changed";
updateAlighButtonState(); // updateAlighButtonState();
}
void UBGraphicsTextItemDelegate::onContentChanged()
{
qDebug() << "onContentChanged";
} }
UBGraphicsTextItem* UBGraphicsTextItemDelegate::delegated() UBGraphicsTextItem* UBGraphicsTextItemDelegate::delegated()
@ -502,6 +509,31 @@ bool UBGraphicsTextItemDelegate::mouseReleaseEvent(QGraphicsSceneMouseEvent *eve
return true; return true;
} }
bool UBGraphicsTextItemDelegate::keyPressEvent(QKeyEvent *event)
{
Q_UNUSED(event);
return true;
}
bool UBGraphicsTextItemDelegate::keyReleaseEvent(QKeyEvent *event)
{
if (!delegated()->hasFocus()) {
return true;
}
switch (event->key()) {
case Qt::Key_Left:
case Qt::Key_Right:
case Qt::Key_Up:
case Qt::Key_Down:
updateAlighButtonState();
break;
}
qDebug() << "Key has been released" << QString::number(event->key(), 16);
return true;
}
void UBGraphicsTextItemDelegate::ChangeTextSize(qreal factor, textChangeMode changeMode) void UBGraphicsTextItemDelegate::ChangeTextSize(qreal factor, textChangeMode changeMode)
{ {
if (scaleSize == changeMode) if (scaleSize == changeMode)
@ -609,6 +641,7 @@ void UBGraphicsTextItemDelegate::updateAlighButtonState()
return; return;
} }
qDebug() << "new cursor position" << delegated()->textCursor().position();
AlignTextButton *asAlBtn = static_cast<AlignTextButton*>(mAlignButton); AlignTextButton *asAlBtn = static_cast<AlignTextButton*>(mAlignButton);
if (!oneBlockSelection()) { if (!oneBlockSelection()) {

@ -129,6 +129,9 @@ class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate
virtual bool mouseMoveEvent(QGraphicsSceneMouseEvent *event); virtual bool mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual bool mouseReleaseEvent(QGraphicsSceneMouseEvent *event); virtual bool mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual bool keyPressEvent(QKeyEvent *event);
virtual bool keyReleaseEvent(QKeyEvent *event);
private: private:
UBGraphicsTextItem* delegated(); UBGraphicsTextItem* delegated();
@ -179,6 +182,7 @@ class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate
void alignButtonProcess(); void alignButtonProcess();
void onCursorPositionChanged(const QTextCursor& cursor); void onCursorPositionChanged(const QTextCursor& cursor);
void onModificationChanged(bool ch); void onModificationChanged(bool ch);
void onContentChanged();
private: private:
const int delta; const int delta;

Loading…
Cancel
Save