diff --git a/app/timeline/timelinecommon.h b/app/timeline/timelinecommon.h index ba059e258..8bd042de0 100644 --- a/app/timeline/timelinecommon.h +++ b/app/timeline/timelinecommon.h @@ -56,6 +56,9 @@ public: }; +// FIXME: Hardcoded (but that might be okay here) +#define PLAYHEAD_COLOR Qt::red + OLIVE_NAMESPACE_EXIT #endif // TIMELINECOMMON_H diff --git a/app/ui/style/olive-dark/style.css b/app/ui/style/olive-dark/style.css index bf3fef323..96be8d2ef 100644 --- a/app/ui/style/olive-dark/style.css +++ b/app/ui/style/olive-dark/style.css @@ -22,15 +22,3 @@ QPushButton:checked { background: #191919; } - -/* Node styling */ -NodeViewItemWidget { - qproperty-titlebarColor: #4040a0; - qproperty-borderColor: #000000; -} - -/* Timeline playhead styling */ -TimelinePlayhead { - qproperty-playheadColor: #ff0000; - qproperty-playheadHighlightColor: rgba(255, 255, 255, 0.2); -} diff --git a/app/ui/style/olive-light/style.css b/app/ui/style/olive-light/style.css index 300445ac7..bab366ba1 100644 --- a/app/ui/style/olive-light/style.css +++ b/app/ui/style/olive-light/style.css @@ -17,18 +17,3 @@ along with this program. If not, see . ***/ - -/* Hack that forces checked QPushButtons to use dark color */ - - -/* Node styling */ -NodeViewItemWidget { - qproperty-titlebarColor: #a0a0ff; - qproperty-borderColor: #000000; -} - -/* Timeline playhead styling */ -TimelinePlayhead { - qproperty-playheadColor: #ff0000; - qproperty-playheadHighlightColor: rgba(0, 0, 0, 0.25); -} diff --git a/app/widget/timelinewidget/view/CMakeLists.txt b/app/widget/timelinewidget/view/CMakeLists.txt index c2da0eead..5a57efbc1 100644 --- a/app/widget/timelinewidget/view/CMakeLists.txt +++ b/app/widget/timelinewidget/view/CMakeLists.txt @@ -18,8 +18,6 @@ set(OLIVE_SOURCES ${OLIVE_SOURCES} widget/timelinewidget/view/handmovableview.h widget/timelinewidget/view/handmovableview.cpp - widget/timelinewidget/view/timelineplayhead.h - widget/timelinewidget/view/timelineplayhead.cpp widget/timelinewidget/view/timelineview.h widget/timelinewidget/view/timelineview.cpp widget/timelinewidget/view/timelineviewmouseevent.h diff --git a/app/widget/timelinewidget/view/timelineplayhead.cpp b/app/widget/timelinewidget/view/timelineplayhead.cpp deleted file mode 100644 index f15e9cf2d..000000000 --- a/app/widget/timelinewidget/view/timelineplayhead.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/*** - - Olive - Non-Linear Video Editor - Copyright (C) 2019 Olive Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -***/ - -#include "timelineplayhead.h" - -#include - -const QColor &TimelinePlayhead::GetPlayheadColor() const -{ - return playhead_color_; -} - -const QColor &TimelinePlayhead::GetPlayheadHighlightColor() const -{ - return playhead_highlight_color_; -} - -void TimelinePlayhead::SetPlayheadColor(QColor c) -{ - playhead_color_ = c; -} - -void TimelinePlayhead::SetPlayheadHighlightColor(QColor c) -{ - playhead_highlight_color_ = c; -} - -void TimelinePlayhead::Draw(QPainter* painter, const QRectF& playhead_rect) const -{ - painter->setPen(Qt::NoPen); - painter->setBrush(GetPlayheadHighlightColor()); - painter->drawRect(playhead_rect); - - painter->setPen(GetPlayheadColor()); - painter->setBrush(Qt::NoBrush); - painter->drawLine(QLineF(playhead_rect.topLeft(), playhead_rect.bottomLeft())); -} diff --git a/app/widget/timelinewidget/view/timelineplayhead.h b/app/widget/timelinewidget/view/timelineplayhead.h deleted file mode 100644 index 15b2f0031..000000000 --- a/app/widget/timelinewidget/view/timelineplayhead.h +++ /dev/null @@ -1,52 +0,0 @@ -/*** - - Olive - Non-Linear Video Editor - Copyright (C) 2019 Olive Team - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -***/ - -#ifndef TIMELINEPLAYHEADSTYLE_H -#define TIMELINEPLAYHEADSTYLE_H - -#include - -/** - * @brief A QWidget proxy for TimeRuler and TimelinePlayheadItem to allow them to share CSS values - * - * To allow Qt CSS customization (which is only available to QWidgets) to be accessed by TimeRuler - */ -class TimelinePlayhead : public QWidget -{ - Q_OBJECT - Q_PROPERTY(QColor playheadColor READ GetPlayheadColor WRITE SetPlayheadColor DESIGNABLE true) - Q_PROPERTY(QColor playheadHighlightColor READ GetPlayheadHighlightColor WRITE SetPlayheadHighlightColor DESIGNABLE true) -public: - TimelinePlayhead() = default; - - const QColor& GetPlayheadColor() const; - const QColor& GetPlayheadHighlightColor() const; - - void SetPlayheadColor(QColor c); - void SetPlayheadHighlightColor(QColor c); - - void Draw(QPainter *painter, const QRectF &rect) const; - -private: - QColor playhead_color_; - QColor playhead_highlight_color_; -}; - -#endif // TIMELINEPLAYHEADSTYLE_H diff --git a/app/widget/timelinewidget/view/timelineviewbase.cpp b/app/widget/timelinewidget/view/timelineviewbase.cpp index a5acb99e1..d0eb9e4c3 100644 --- a/app/widget/timelinewidget/view/timelineviewbase.cpp +++ b/app/widget/timelinewidget/view/timelineviewbase.cpp @@ -132,7 +132,19 @@ void TimelineViewBase::drawForeground(QPainter *painter, const QRectF &rect) playhead_scene_left_ = GetPlayheadX(); playhead_scene_right_ = playhead_scene_left_ + width; - playhead_style_.Draw(painter, QRectF(playhead_scene_left_, rect.top(), width, rect.height())); + QRectF playhead_rect(playhead_scene_left_, rect.top(), width, rect.height()); + + // Get playhead highlight color + QColor highlight = palette().text().color(); + highlight.setAlpha(128); + painter->setPen(Qt::NoPen); + painter->setBrush(highlight); + painter->drawRect(playhead_rect); + + // FIXME: Hardcoded... + painter->setPen(PLAYHEAD_COLOR); + painter->setBrush(Qt::NoBrush); + painter->drawLine(QLineF(playhead_rect.topLeft(), playhead_rect.bottomLeft())); } if (snapped_) { diff --git a/app/widget/timelinewidget/view/timelineviewbase.h b/app/widget/timelinewidget/view/timelineviewbase.h index d24af659e..f8da914e7 100644 --- a/app/widget/timelinewidget/view/timelineviewbase.h +++ b/app/widget/timelinewidget/view/timelineviewbase.h @@ -25,7 +25,6 @@ #include "core.h" #include "handmovableview.h" -#include "timelineplayhead.h" #include "widget/timelinewidget/snapservice.h" #include "widget/timelinewidget/timelinescaledobject.h" @@ -101,8 +100,6 @@ private: int64_t playhead_; - TimelinePlayhead playhead_style_; - double playhead_scene_left_; double playhead_scene_right_; diff --git a/app/widget/timeruler/seekablewidget.h b/app/widget/timeruler/seekablewidget.h index 0abfa3e53..eabd1ccaf 100644 --- a/app/widget/timeruler/seekablewidget.h +++ b/app/widget/timeruler/seekablewidget.h @@ -24,7 +24,6 @@ #include "common/rational.h" #include "timeline/timelinepoints.h" #include "widget/timelinewidget/snapservice.h" -#include "widget/timelinewidget/view/timelineplayhead.h" #include "widget/timelinewidget/timelinescaledobject.h" OLIVE_NAMESPACE_ENTER @@ -80,16 +79,6 @@ protected: return playhead_width_; } - inline const QColor& GetPlayheadColor() const - { - return style_.GetPlayheadColor(); - } - - inline const QColor& GetPlayheadHighlightColor() const - { - return style_.GetPlayheadHighlightColor(); - } - signals: /** * @brief Signal emitted whenever the time changes on this ruler, either by user or programmatically @@ -99,8 +88,6 @@ signals: private: int64_t time_; - TimelinePlayhead style_; - TimelinePoints* timeline_points_; int scroll_; diff --git a/app/widget/timeruler/timeruler.cpp b/app/widget/timeruler/timeruler.cpp index b79b8121b..a95e82582 100644 --- a/app/widget/timeruler/timeruler.cpp +++ b/app/widget/timeruler/timeruler.cpp @@ -281,7 +281,7 @@ void TimeRuler::paintEvent(QPaintEvent *) // Draw the playhead if it's on screen at the moment int playhead_pos = UnitToScreen(GetTime()); p.setPen(Qt::NoPen); - p.setBrush(GetPlayheadColor()); + p.setBrush(PLAYHEAD_COLOR); DrawPlayhead(&p, playhead_pos, line_bottom); } diff --git a/app/widget/viewer/audiowaveformview.cpp b/app/widget/viewer/audiowaveformview.cpp index cc58e740a..18193fc1f 100644 --- a/app/widget/viewer/audiowaveformview.cpp +++ b/app/widget/viewer/audiowaveformview.cpp @@ -26,6 +26,7 @@ #include "common/clamp.h" #include "config/config.h" +#include "timeline/timelinecommon.h" OLIVE_NAMESPACE_ENTER @@ -130,7 +131,7 @@ void AudioWaveformView::paintEvent(QPaintEvent *event) p.drawPixmap(0, 0, cached_waveform_); // Draw playhead - p.setPen(GetPlayheadColor()); + p.setPen(PLAYHEAD_COLOR); int playhead_x = UnitToScreen(GetTime()); p.drawLine(playhead_x, 0, playhead_x, height());