summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMahmoud Badri <mahmoud.badri@qt.io>2019-02-27 14:03:20 +0200
committerMahmoud Badri <mahmoud.badri@qt.io>2019-03-04 12:06:19 +0000
commitbddb943092efb0cc59f90109d4f6bfbbdad77bfc (patch)
treee69a154f84c6744328ce919c17e95901a12bdd7f
parent52b9483372fc2a0aa8588660af557a3413a18e93 (diff)
Implement variants tags timeline tooltip
Task-number: QT3DS-3105 Change-Id: I9919858193257f3b4a8add3d5ffc3eb95888b3a7 Reviewed-by: Antti Määttä <antti.maatta@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp82
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.h4
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/InteractiveTimelineItem.cpp2
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/InteractiveTimelineItem.h2
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp22
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h3
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.cpp1
-rw-r--r--src/Authoring/Studio/style.qss5
8 files changed, 97 insertions, 24 deletions
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp
index 7f608683..1f750f15 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp
@@ -68,7 +68,6 @@
#include <QtGui/qevent.h>
#include <QtCore/qtimer.h>
#include <QtCore/qglobal.h>
-#include <QtCore/qdebug.h>
#include <QtWidgets/qaction.h>
static const QPointF invalidPoint(-999999.0, -999999.0);
@@ -100,6 +99,14 @@ TimelineGraphicsScene::TimelineGraphicsScene(TimelineWidget *timelineWidget)
m_timebarToolTip->setWindowModality(Qt::NonModal);
m_timebarToolTip->setWindowFlags(Qt::FramelessWindowHint | Qt::ToolTip);
m_timebarToolTip->setContentsMargins(2, 2, 2, 2);
+
+ m_variantsToolTip = new QLabel(m_widgetTimeline);
+ m_variantsToolTip->setObjectName(QStringLiteral("variantsToolTip"));
+ m_variantsToolTip->setWindowModality(Qt::NonModal);
+ m_variantsToolTip->setWindowFlags(Qt::FramelessWindowHint | Qt::ToolTip
+ | Qt::WindowTransparentForInput);
+ m_variantsToolTip->setContentsMargins(2, 2, 2, 2);
+
connect(qApp, &QApplication::focusChanged,
this, &TimelineGraphicsScene::handleApplicationFocusLoss);
@@ -861,9 +868,7 @@ void TimelineGraphicsScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *even
} else if (!treeLabelItem->isLocked()
&& treeLabelItem->parentRow()->rowType() != OBJTYPE_SCENE
&& treeLabelItem->parentRow()->rowType() != OBJTYPE_IMAGE) {
- qt3dsdm::Qt3DSDMInstanceHandle instance
- = static_cast<Qt3DSDMTimelineItemBinding *>(
- treeLabelItem->parentRow()->getBinding())->GetInstance();
+ int instance = treeLabelItem->parentRow()->instance();
const auto bridge = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()
->GetClientDataModelBridge();
if (bridge->GetObjectType(instance) != OBJTYPE_REFERENCEDMATERIAL
@@ -974,9 +979,11 @@ bool TimelineGraphicsScene::event(QEvent *event)
void TimelineGraphicsScene::updateHoverStatus(const QPointF &scenePos)
{
+ bool variantsAreaHovered = false;
QGraphicsItem *item = itemAt(scenePos, QTransform());
if (item) {
item = getItemBelowType(TimelineItem::TypePlayHead, item, scenePos);
+ // update timeline row cursor
if (item->type() == TimelineItem::TypeRowTimeline) {
RowTimeline *timelineItem = static_cast<RowTimeline *>(item);
TimelineControlType controlType = timelineItem->getClickedControl(scenePos);
@@ -986,8 +993,69 @@ void TimelineGraphicsScene::updateHoverStatus(const QPointF &scenePos)
} else {
resetMouseCursor();
}
+ } else if (!m_dragging && (item->type() == TimelineItem::TypeRowTree
+ || item->type() == TimelineItem::TypeRowTreeLabelItem)) {
+ // update tree row variants tooltip
+ RowTree *rowTree = item->type() == TimelineItem::TypeRowTree
+ ? static_cast<RowTree *>(item)
+ : static_cast<RowTreeLabelItem *>(item)->parentRow();
+ int left = rowTree->clipX();
+ int right = (int)rowTree->treeWidth() - TimelineConstants::TREE_ICONS_W;
+ variantsAreaHovered = scenePos.x() > left && scenePos.x() < right;
+ if (variantsAreaHovered && rowTree != m_variantsRowTree) {
+ CDoc *doc = g_StudioApp.GetCore()->GetDoc();
+ const auto propertySystem = doc->GetStudioSystem()->GetPropertySystem();
+ const auto bridge = doc->GetStudioSystem()->GetClientDataModelBridge();
+ auto property = bridge->GetLayer().m_variants;
+
+ using namespace qt3dsdm;
+ SValue sValue;
+ if (propertySystem->GetInstancePropertyValue(rowTree->instance(), property,
+ sValue)) {
+ QString propVal = QString::fromWCharArray(get<TDataStrPtr>(sValue)
+ ->GetData());
+ if (!propVal.isEmpty()) {
+ // parse propVal into variantsHash (group => tags)
+ const QStringList tagPairs = propVal.split(QLatin1Char(','));
+ QHash<QString, QStringList> variantsHash;
+ for (auto &tagPair : tagPairs) {
+ const QStringList pair = tagPair.split(QLatin1Char(':'));
+ variantsHash[pair[0]].append(pair[1]);
+ }
+
+ // parse variantsHash into tooltipStr
+ const auto variantsDef
+ = g_StudioApp.GetCore()->getProjectFile().variantsDef();
+ QString templ = QStringLiteral("<font color='%1'>%2</font>");
+ QString tooltipStr("<table>");
+ const auto keys = variantsHash.keys();
+ for (auto &g : keys) {
+ tooltipStr.append("<tr><td>");
+ tooltipStr.append(templ.arg(variantsDef[g].m_color).arg(g + ": "));
+ tooltipStr.append("</td><td>");
+ for (auto &t : qAsConst(variantsHash[g]))
+ tooltipStr.append(t + ", ");
+ tooltipStr.chop(2);
+ tooltipStr.append("</td></tr>");
+ }
+ tooltipStr.append("</table>");
+ m_variantsToolTip->setText(tooltipStr);
+ m_variantsToolTip->adjustSize();
+ m_variantsToolTip->move(m_widgetTimeline->mapToGlobal(
+ {right, (int)rowTree->y()}));
+ m_variantsToolTip->raise();
+ m_variantsToolTip->show();
+ m_variantsRowTree = rowTree;
+ }
+ }
+ }
}
}
+
+ if (m_variantsRowTree && !variantsAreaHovered) {
+ m_variantsToolTip->hide();
+ m_variantsRowTree = nullptr;
+ }
}
// Return next item below [type] item, or item itself
@@ -1065,9 +1133,11 @@ void TimelineGraphicsScene::handleEditComponent()
void TimelineGraphicsScene::handleApplicationFocusLoss()
{
- // Hide the timebar tooltip if application loses focus
- if (!QApplication::focusWidget())
+ // Hide the timebar and variants tooltips if application loses focus
+ if (!QApplication::focusWidget()) {
m_timebarToolTip->hide();
+ m_variantsToolTip->hide();
+ }
}
void TimelineGraphicsScene::handleShowDISelector(const QString &propertyname,
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.h b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.h
index 8a41ea49..146009ee 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.h
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.h
@@ -104,7 +104,7 @@ protected:
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
- void wheelEvent(QGraphicsSceneWheelEvent *wheelEvent);
+ void wheelEvent(QGraphicsSceneWheelEvent *wheelEvent) override;
void keyPressEvent(QKeyEvent *keyEvent) override;
void keyReleaseEvent(QKeyEvent *keyEvent) override;
@@ -167,6 +167,8 @@ private:
QTimer m_autoScrollTimer;
QTimer m_autoScrollTriggerTimer; // triggers m_autoScrollTimer
QLabel *m_timebarToolTip = nullptr;
+ QLabel *m_variantsToolTip = nullptr;
+ RowTree* m_variantsRowTree = nullptr;
};
#endif // TIMELINEGRAPHICSSCENE_H
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/InteractiveTimelineItem.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/InteractiveTimelineItem.cpp
index a4bb31f4..efc7a2c1 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/InteractiveTimelineItem.cpp
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/InteractiveTimelineItem.cpp
@@ -28,8 +28,6 @@
#include "InteractiveTimelineItem.h"
-#include <QtGui/qpainter.h>
-
InteractiveTimelineItem::InteractiveTimelineItem(TimelineItem *parent) : TimelineItem(parent)
{
setAcceptHoverEvents(true);
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/InteractiveTimelineItem.h b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/InteractiveTimelineItem.h
index ca88e6cc..a6a5e5ee 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/InteractiveTimelineItem.h
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/InteractiveTimelineItem.h
@@ -46,7 +46,7 @@ public:
virtual void setState(State state);
- int type() const;
+ int type() const override;
protected:
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp
index c3b2595a..39405ac4 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp
@@ -77,6 +77,12 @@ ITimelineItemBinding *RowTree::getBinding() const
return m_binding;
}
+// object instance handle
+int RowTree::instance() const
+{
+ return static_cast<Qt3DSDMTimelineItemBinding *>(m_binding)->GetInstance();
+}
+
// property row constructor
RowTree::RowTree(TimelineGraphicsScene *timelineScene, const QString &propType)
: InteractiveTimelineItem()
@@ -493,9 +499,7 @@ void RowTree::setBinding(ITimelineItemBinding *binding)
m_binding = binding;
// Restore the expansion state of rows
- m_expandState = m_scene->expandMap().value(
- static_cast<Qt3DSDMTimelineItemBinding *>(binding)->GetInstance(),
- ExpandState::Unknown);
+ m_expandState = m_scene->expandMap().value(instance(), ExpandState::Unknown);
if (m_expandState == ExpandState::Unknown) {
// Everything but scene/component is initially collapsed and hidden
@@ -935,11 +939,8 @@ void RowTree::updateExpandStatus(ExpandState state, bool animate, bool forceChil
return;
// Store the expanded state of items so we can restore it on slide change
- if (changed && m_binding) {
- m_scene->expandMap().insert(
- static_cast<Qt3DSDMTimelineItemBinding *>(m_binding)->GetInstance(),
- m_expandState);
- }
+ if (changed && m_binding)
+ m_scene->expandMap().insert(instance(), m_expandState);
if (animate)
animateExpand(m_expandState);
@@ -1263,9 +1264,6 @@ void RowTree::setPropertyExpanded(bool expand)
void RowTree::showDataInputSelector(const QString &propertyname, const QPoint &pos)
{
- m_scene->handleShowDISelector(
- propertyname, static_cast<Qt3DSDMTimelineItemBinding *>(m_binding)->GetInstance(),
- pos);
-
+ m_scene->handleShowDISelector(propertyname, instance(), pos);
}
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h
index 4524f345..249a3271 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h
@@ -120,7 +120,7 @@ public:
bool hasDurationBar() const;
bool propertyExpanded() const;
int depth() const;
- int type() const;
+ int type() const override;
int index() const;
int indexInLayout() const;
int treeWidth() const;
@@ -150,6 +150,7 @@ public:
void updateLock(bool state);
void updateSubpresentations(int updateParentsOnlyVal = 0);
int clipX() const;
+ int instance() const;
protected:
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.cpp
index 1029c00a..21b57aaa 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.cpp
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.cpp
@@ -33,7 +33,6 @@
#include "StudioPreferences.h"
#include <QtWidgets/qstyleoption.h>
-#include <QtCore/qdebug.h>
#include <QtGui/qevent.h>
#include <QtGui/qtextcursor.h>
diff --git a/src/Authoring/Studio/style.qss b/src/Authoring/Studio/style.qss
index d78d780d..0636e49c 100644
--- a/src/Authoring/Studio/style.qss
+++ b/src/Authoring/Studio/style.qss
@@ -180,6 +180,11 @@ QToolTip {
border-radius: 2;
}
+QLabel#variantsToolTip {
+ background: #222222;
+ border: 1px solid #444444;
+}
+
/* Dialog widgets */
QComboBox,
QLineEdit,