Small color adjustments for timeline (make locked tracks more visible)

Fix missing icons on small track height
CCBUG: 361978
parent a88d8769
......@@ -137,6 +137,9 @@ CustomTrackView::CustomTrackView(KdenliveDoc *doc, Timeline *timeline, CustomTra
m_selectedTrackColor = scheme.background(KColorScheme::ActiveBackground ).color();
m_selectedTrackColor.setAlpha(150);
m_lockedTrackColor = scheme.background(KColorScheme::NegativeBackground ).color();
m_lockedTrackColor.setAlpha(150);
m_keyPropertiesTimer = new QTimeLine(800);
m_keyPropertiesTimer->setFrameRange(0, 5);
m_keyPropertiesTimer->setUpdateInterval(100);
......@@ -6459,16 +6462,17 @@ void CustomTrackView::drawBackground(QPainter * painter, const QRectF &rect)
double max = rect.right();
painter->drawLine(QPointF(min, 0), QPointF(max, 0));
int maxTrack = m_timeline->visibleTracksCount();
QColor lockedColor = palette().button().color();
QColor audioColor = palette().alternateBase().color();
QColor activeLockColor = m_lockedTrackColor;
activeLockColor.setAlpha(90);
for (int i = 1; i <= maxTrack; ++i) {
TrackInfo info = m_timeline->getTrackInfo(i);
if (info.isLocked || info.type == AudioTrack || i == m_selectedTrack) {
const QRectF track(min, m_tracksHeight * (maxTrack - i), max - min, m_tracksHeight - 1);
if (i == m_selectedTrack)
painter->fillRect(track, m_selectedTrackColor);
painter->fillRect(track, info.isLocked ? activeLockColor : m_selectedTrackColor);
else
painter->fillRect(track, info.isLocked ? lockedColor : audioColor);
painter->fillRect(track, info.isLocked ? m_lockedTrackColor : audioColor);
}
painter->drawLine(QPointF(min, m_tracksHeight * (maxTrack - i) - 1), QPointF(max, m_tracksHeight * (maxTrack - i) - 1));
}
......@@ -7988,6 +7992,8 @@ void CustomTrackView::updatePalette()
KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
m_selectedTrackColor = scheme.background(KColorScheme::ActiveBackground ).color();
m_selectedTrackColor.setAlpha(150);
m_lockedTrackColor = scheme.background(KColorScheme::NegativeBackground ).color();
m_lockedTrackColor.setAlpha(150);
}
void CustomTrackView::removeTipAnimation()
......
......@@ -389,6 +389,7 @@ private:
QList <CommentedTime> m_searchPoints;
QList <Guide *> m_guides;
QColor m_selectedTrackColor;
QColor m_lockedTrackColor;
/** @brief Returns a clip from timeline
* @param pos a time value that is inside the clip
......
......@@ -77,10 +77,8 @@ HeaderTrack::HeaderTrack(TrackInfo info, const QList <QAction *> &actions, Track
m_switchAudio->setActive(info.isMute);
connect(m_switchAudio, SIGNAL(activeChanged(bool)), this, SLOT(switchAudio(bool)));
m_tb->addAction(m_switchAudio);
setAutoFillBackground(true);
if (m_type == VideoTrack) {
setBackgroundRole(QPalette::AlternateBase);
setAutoFillBackground(true);
m_switchVideo = new KDualAction(i18n("Disable video"), i18n("Enable video"), this);
m_switchVideo->setActiveIcon(KoIconUtils::themedIcon(QStringLiteral("kdenlive-hide-video")));
m_switchVideo->setInactiveIcon(KoIconUtils::themedIcon(QStringLiteral("kdenlive-show-video")));
......@@ -95,6 +93,7 @@ HeaderTrack::HeaderTrack(TrackInfo info, const QList <QAction *> &actions, Track
connect(m_switchComposite, &KDualAction::activeChangedByUser, this, &HeaderTrack::switchComposite);
m_tb->addAction(m_switchComposite);
} else {
setBackgroundRole(QPalette::AlternateBase);
m_switchVideo = NULL;
m_switchComposite = NULL;
}
......@@ -131,9 +130,23 @@ void HeaderTrack::updateStatus(TrackInfo info)
if (m_switchVideo) m_switchVideo->setActive(info.isBlind);
if (m_switchComposite) m_switchComposite->setActive(info.composite);
m_switchLock->setActive(info.isLocked);
updateBackground(info.isLocked);
renameTrack(info.trackName);
}
void HeaderTrack::updateBackground(bool isLocked)
{
if (isLocked) {
setBackgroundRole(m_isSelected ? QPalette::Dark : QPalette::Shadow);
} else if (m_isSelected) {
setBackgroundRole(QPalette::Mid);
} else if (m_type == VideoTrack) {
setBackgroundRole(QPalette::Base);
} else {
setBackgroundRole(QPalette::AlternateBase);
}
}
void HeaderTrack::setTrackHeight(int height)
{
setFixedHeight(height);
......@@ -214,28 +227,18 @@ void HeaderTrack::dragEnterEvent(QDragEnterEvent *event)
void HeaderTrack::setSelectedIndex(int ix)
{
if (m_parentTrack->index() == ix) {
m_isSelected = true;
QPalette pal = palette();
KColorScheme scheme(pal.currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
pal.setColor(QPalette::Mid, scheme.background(KColorScheme::ActiveBackground ).color());
setPalette(pal);
setBackgroundRole(QPalette::Mid);
setAutoFillBackground(true);
} else if (m_type != VideoTrack) {
m_isSelected = false;
setAutoFillBackground(false);
} else {
m_isSelected = false;
setBackgroundRole(QPalette::AlternateBase);
}
update();
m_isSelected = ix == m_parentTrack->index();
updateBackground(m_switchLock->isActive());
}
void HeaderTrack::adjustSize(int height)
{
// Don't show track buttons if size is too small
bool smallTracks = height < 40;
QFontMetrics metrics(font());
int trackHeight = metrics.height();
QStyle *style = qApp->style();
trackHeight += style->pixelMetric(QStyle::PM_ToolBarIconSize) + 2 * style->pixelMetric(QStyle::PM_ToolBarItemMargin) + style->pixelMetric(QStyle::PM_ToolBarItemSpacing);
bool smallTracks = height < trackHeight;
m_tb->setHidden(smallTracks);
setFixedHeight(height);
}
......@@ -265,6 +268,7 @@ void HeaderTrack::setLock(bool lock)
m_switchLock->blockSignals(true);
m_switchLock->setActive(lock);
m_switchLock->blockSignals(false);
updateBackground(lock);
}
void HeaderTrack::disableComposite()
......@@ -301,6 +305,16 @@ QString HeaderTrack::name() const
return m_name;
}
void HeaderTrack::refreshPalette()
{
QPalette pal = palette();
KColorScheme scheme(pal.currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
pal.setColor(QPalette::Base, scheme.background(KColorScheme::NormalBackground).color());
pal.setColor(QPalette::AlternateBase, scheme.background(KColorScheme::AlternateBackground).color());
pal.setColor(QPalette::Mid, scheme.background(KColorScheme::ActiveBackground ).color());
pal.setColor(QPalette::Shadow, scheme.background(KColorScheme::NeutralBackground ).color());
pal.setColor(QPalette::Dark, scheme.background(KColorScheme::NegativeBackground ).color());
setPalette(pal);
}
......@@ -49,6 +49,7 @@ public:
void updateStatus(TrackInfo info);
/** @brief Track has no composite transition, disable switch button.*/
void disableComposite();
void refreshPalette();
protected:
void mousePressEvent(QMouseEvent * event);
......@@ -67,7 +68,7 @@ private:
KDualAction *m_switchVideo;
KDualAction *m_switchAudio;
KDualAction *m_switchLock;
void updateBackground(bool isLocked);
private slots:
void switchAudio(bool);
......
......@@ -835,16 +835,18 @@ void Timeline::updatePalette()
setPalette(qApp->palette());
QPalette p = qApp->palette();
KColorScheme scheme(p.currentColorGroup(), KColorScheme::View, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
QColor norm = scheme.shade(scheme.background(KColorScheme::ActiveBackground).color(), KColorScheme::MidShade);
p.setColor(QPalette::Button, norm);
QColor col = scheme.background().color();
QColor col2 = scheme.foreground().color();
headers_container->setStyleSheet(QStringLiteral("QLineEdit { background-color: transparent;color: %1;} QLineEdit:hover{ background-color: %2;} QLineEdit:focus { background-color: %2;}").arg(col2.name(), col.name()));
headers_container->setStyleSheet(QStringLiteral("QLineEdit { background-color: transparent;color: %1;} QLineEdit:hover{ background-color: %2;} QLineEdit:focus { background-color: %2;} ").arg(col2.name(), col.name()));
m_trackview->updatePalette();
if (!m_tracks.isEmpty()) {
int ix = m_trackview->selectedTrack();
if (m_tracks.at(ix)->trackHeader) {
m_tracks.at(ix)->trackHeader->setSelectedIndex(ix);
for (int i = 0; i < m_tracks.count(); i++) {
if (m_tracks.at(i)->trackHeader) {
m_tracks.at(i)->trackHeader->refreshPalette();
if (i == ix)
m_tracks.at(ix)->trackHeader->setSelectedIndex(ix);
}
}
}
}
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>308</width>
<height>163</height>
<height>139</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
......@@ -90,7 +90,7 @@
<x>0</x>
<y>0</y>
<width>70</width>
<height>153</height>
<height>129</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment