diff options
author | Kaj Grönholm <kaj.gronholm@qt.io> | 2018-05-25 10:19:04 +0300 |
---|---|---|
committer | Kaj Grönholm <kaj.gronholm@qt.io> | 2018-05-28 04:29:04 +0000 |
commit | f75459b11255b14cb15e195c4b5edf685b55b033 (patch) | |
tree | 807b9252b300c309d657ba0d7b299fe462d37a9a | |
parent | ce33f24d3eced42131f0bc00c233b58738cf25a2 (diff) |
Improve timeline row label handling
Trim labels, inform when trying to use empty label and keep visible
label always up-to-date. Default label names not needed, user can't
change label to empty and if uip contains empty "name" parameter
just show it empty so user knows what to correct. This matches to
previous timeline behavior.
Task-number: QT3DS-1746
Change-Id: Ibb065ee9cd0ba5d46f2cd15929c4eacfa4036855
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
3 files changed, 5 insertions, 52 deletions
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp index 0a7cdc9e..5e587653 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp @@ -50,7 +50,6 @@ RowTree::RowTree(TimelineGraphicsScene *timelineScene, EStudioObjectType rowType m_scene = timelineScene; m_rowType = rowType; m_label = label; - m_labelItem.setRowTypeLabel(m_rowType); initialize(); } diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.cpp index 1712b6ac..cfd0ddd8 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.cpp @@ -55,9 +55,9 @@ QString RowTreeLabelItem::label() const void RowTreeLabelItem::setLabel(const QString &label) { + setPlainText(label); if (m_label != label) { m_label = label; - setPlainText(m_label); emit labelChanged(m_label); } } @@ -154,15 +154,14 @@ QRectF RowTreeLabelItem::boundingRect() const void RowTreeLabelItem::validateLabel() { - QString text = toPlainText(); + QString text = toPlainText().trimmed(); if (text.isEmpty()) { - setLabel(m_rowTypeLabel); + // Inform label was empty and return previous label + emit labelChanged(""); + setLabel(m_label); return; } - // TODO: Check label is valid? - //emit invalidLabel(); - setLabel(text); } @@ -175,45 +174,3 @@ void RowTreeLabelItem::updateLabelColor() else setDefaultTextColor(CStudioPreferences::GetNormalColor()); } - -void RowTreeLabelItem::setRowTypeLabel(EStudioObjectType rowType) -{ - switch (rowType) { - case OBJTYPE_SCENE: - m_rowTypeLabel = tr("Scene"); - break; - case OBJTYPE_LAYER: - m_rowTypeLabel = tr("Layer"); - break; - case OBJTYPE_MODEL: - m_rowTypeLabel = tr("Object"); - break; - case OBJTYPE_LIGHT: - m_rowTypeLabel = tr("Light"); - break; - case OBJTYPE_CAMERA: - m_rowTypeLabel = tr("Camera"); - break; - case OBJTYPE_TEXT: - m_rowTypeLabel = tr("Text"); - break; - case OBJTYPE_ALIAS: - m_rowTypeLabel = tr("Alias"); - break; - case OBJTYPE_GROUP: - m_rowTypeLabel = tr("Group"); - break; - case OBJTYPE_COMPONENT: - m_rowTypeLabel = tr("Component"); - break; - case OBJTYPE_MATERIAL: - m_rowTypeLabel = tr("Default"); - break; - default: - break; - } - - if (m_label.isEmpty()) - setLabel(m_rowTypeLabel); -} - diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.h b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.h index 2655c1bd..01d4be48 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.h +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.h @@ -47,7 +47,6 @@ public: void setLabel(const QString &label); void setLocked(bool isLocked); void setMaster(bool isMaster); - void setRowTypeLabel(EStudioObjectType rowType); RowTree *parentRow() const; void setParentRow(RowTree *row); int type() const; @@ -59,7 +58,6 @@ protected: QRectF boundingRect() const override; signals: - void invalidLabel(); void labelChanged(const QString label); private: @@ -68,7 +66,6 @@ private: RowTree *m_rowTree = nullptr; QString m_label; - QString m_rowTypeLabel; bool m_locked; bool m_master; bool m_acceptOnFocusOut; |