From 4ad0cfecf276a86c9e849290512a0a93bd8c40d3 Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 15 Apr 2015 18:49:17 +0000 Subject: [PATCH] Added color icons to the timeline. --- common/lc_timelinewidget.cpp | 19 +++++++++++++++++++ common/lc_timelinewidget.h | 1 + 2 files changed, 20 insertions(+) diff --git a/common/lc_timelinewidget.cpp b/common/lc_timelinewidget.cpp index 75d50f7e..882b05b8 100644 --- a/common/lc_timelinewidget.cpp +++ b/common/lc_timelinewidget.cpp @@ -151,6 +151,25 @@ void lcTimelineWidget::Update(bool Clear) PieceItem->setData(0, Qt::UserRole, qVariantFromValue((uintptr_t)Piece)); StepItem->insertChild(PieceItemIndex, PieceItem); mItems[Piece] = PieceItem; + + int ColorIndex = Piece->mColorIndex; + if (!mIcons.contains(ColorIndex)) + { + int Size = rowHeight(indexFromItem(PieceItem)); + + QImage Image(Size, Size, QImage::Format_ARGB32); + Image.fill(QColor::fromRgbF(1.0, 1.0, 1.0, 0.0)); + + float* Color = gColorList[ColorIndex].Value; + QPainter Painter(&Image); + Painter.setPen(Qt::NoPen); + Painter.setBrush(QColor::fromRgbF(Color[0], Color[1], Color[2])); + Painter.drawEllipse(QPoint(Size / 2, Size / 2), Size / 2, Size / 2); + + mIcons[ColorIndex] = QIcon(QPixmap::fromImage(Image)); + } + + PieceItem->setIcon(0, mIcons[ColorIndex]); } else { diff --git a/common/lc_timelinewidget.h b/common/lc_timelinewidget.h index 620e47d5..3ca376ba 100644 --- a/common/lc_timelinewidget.h +++ b/common/lc_timelinewidget.h @@ -21,6 +21,7 @@ public slots: protected: virtual void dropEvent(QDropEvent* Event); + QMap mIcons; QMap mItems; bool mIgnoreUpdates; };