summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaj Grönholm <kaj.gronholm@qt.io>2019-09-02 07:48:44 +0300
committerKaj Grönholm <kaj.gronholm@qt.io>2019-09-04 11:57:54 +0300
commit1e3d7d9f5523477bbb013072aa2be9040e64c734 (patch)
treeb1cd0cec2e29d6d57db59c27bcb1cc2191265a2d
parent32a4774f6d838f019997dce0bef11b4c4b96eb4f (diff)
Limit timeline labels width
This avoids crash when selecting labels clipped with splitter. Also add default font size for labels. Task-number: QT3DS-3913 Change-Id: I89ff403634dedf6d83704c2dd25b8f22da8d8484 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.cpp11
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.cpp b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.cpp
index b3d6e7c9..a5431b14 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.cpp
@@ -41,10 +41,14 @@ RowTreeLabel::RowTreeLabel(QGraphicsItem *parent)
, m_locked(false)
, m_master(false)
, m_acceptOnFocusOut(true)
+ , m_labelWidth(100)
{
setTextInteractionFlags(Qt::TextEditorInteraction);
setEnabled(false);
updateLabelColor();
+ QFont font;
+ font.setPixelSize(12);
+ setFont(font);
}
QString RowTreeLabel::label() const
@@ -96,6 +100,13 @@ void RowTreeLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
if (!m_rowTree->y()) // prevents flickering when the row is just inserted to the layout
return;
+ // Limit the painted label width, see QT3DS-3913
+ int labelWidth = m_rowTree->treeWidth() - int(TimelineConstants::TREE_ICONS_W) - 30;
+ if (labelWidth != m_labelWidth) {
+ m_labelWidth = labelWidth;
+ setTextWidth(m_labelWidth);
+ }
+
// Remove the HasFocus style state, to prevent the dotted line from being drawn.
QStyleOptionGraphicsItem *style = const_cast<QStyleOptionGraphicsItem *>(option);
style->state &= ~QStyle::State_HasFocus;
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.h b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.h
index c438a366..edddcb99 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.h
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTreeLabel.h
@@ -70,6 +70,7 @@ private:
bool m_locked;
bool m_master;
bool m_acceptOnFocusOut;
+ int m_labelWidth;
};
#endif // ROWTREELABELITEM_H