]> git.sesse.net Git - kdenlive/commitdiff
Fix colors not correctly set depending on style
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 13 Sep 2010 10:40:27 +0000 (10:40 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 13 Sep 2010 10:40:27 +0000 (10:40 +0000)
svn path=/trunk/kdenlive/; revision=4881

src/customtrackview.cpp
src/customtrackview.h
src/headertrack.cpp
src/trackview.cpp

index 1d73e133bd91d607dcf89684fdbe9740a3a8eb8c..5852bce01929945e3f9efdcc2cbc6e21a071a7c3 100644 (file)
@@ -67,7 +67,6 @@
 #include <KUrl>
 #include <KIcon>
 #include <KCursor>
-#include <KColorScheme>
 #include <KMessageBox>
 #include <KIO/NetAccess>
 
@@ -135,8 +134,9 @@ CustomTrackView::CustomTrackView(KdenliveDoc *doc, CustomTrackScene* projectscen
     setLineWidth(0);
     //setCacheMode(QGraphicsView::CacheBackground);
     //setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
+    setAutoFillBackground(false);
     setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
-
+    m_activeTrackBrush = KStatefulBrush(KColorScheme::View, KColorScheme::ActiveBackground, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
     pixmapCache = new KPixmapCache("kdenlive-thumbs");
     KdenliveSettings::setTrackheight(m_tracksHeight);
     m_animationTimer = new QTimeLine(800);
@@ -280,7 +280,7 @@ void CustomTrackView::checkTrackHeight()
         }
     }
     double newHeight = m_tracksHeight * m_document->tracksCount() * matrix().m22();
-    m_cursorLine->setLine(m_cursorLine->line().x1(), 0, m_cursorLine->line().x1(), newHeight);
+    m_cursorLine->setLine(m_cursorLine->line().x1(), 0, m_cursorLine->line().x1(), newHeight - 1);
 
     for (int i = 0; i < m_guides.count(); i++) {
         QLineF l = m_guides.at(i)->line();
@@ -2571,7 +2571,8 @@ void CustomTrackView::addTrack(TrackInfo type, int ix)
         l.setP2(QPointF(l.x2(), maxHeight));
         m_guides.at(i)->setLine(l);
     }
-    m_cursorLine->setLine(m_cursorLine->line().x1(), 0, m_cursorLine->line().x1(), maxHeight);
+
+    m_cursorLine->setLine(m_cursorLine->line().x1(), 0, m_cursorLine->line().x1(), maxHeight - 1);
     setSceneRect(0, 0, sceneRect().width(), m_tracksHeight * m_document->tracksCount());
     viewport()->update();
     emit tracksChanged();
@@ -2644,7 +2645,7 @@ void CustomTrackView::removeTrack(int ix)
         l.setP2(QPointF(l.x2(), maxHeight));
         m_guides.at(i)->setLine(l);
     }
-    m_cursorLine->setLine(m_cursorLine->line().x1(), 0, m_cursorLine->line().x1(), maxHeight);
+    m_cursorLine->setLine(m_cursorLine->line().x1(), 0, m_cursorLine->line().x1(), maxHeight - 1);
     setSceneRect(0, 0, sceneRect().width(), m_tracksHeight * m_document->tracksCount());
 
     m_selectedTrack = qMin(m_selectedTrack, m_document->tracksCount() - 1);
@@ -4997,13 +4998,12 @@ void CustomTrackView::setScale(double scaleFactor, double verticalScale)
     newmatrix = newmatrix.scale(scaleFactor, verticalScale);
     m_scene->setScale(scaleFactor, verticalScale);
     removeTipAnimation();
-    double verticalPos = mapToScene(QPoint(0, viewport()->height() / 2)).y();
     bool adjust = false;
     if (verticalScale != matrix().m22()) adjust = true;
     setMatrix(newmatrix);
     if (adjust) {
         double newHeight = m_tracksHeight * m_document->tracksCount() * matrix().m22();
-        m_cursorLine->setLine(m_cursorLine->line().x1(), 0, m_cursorLine->line().x1(), newHeight);
+        m_cursorLine->setLine(m_cursorLine->line().x1(), 0, m_cursorLine->line().x1(), newHeight - 1);
         for (int i = 0; i < m_guides.count(); i++) {
             QLineF l = m_guides.at(i)->line();
             l.setP2(QPointF(l.x2(), newHeight));
@@ -5019,6 +5019,7 @@ void CustomTrackView::setScale(double scaleFactor, double verticalScale)
         else
             setSceneRect(0, 0, (m_projectDuration + 300), sceneRect().height());
     }
+    double verticalPos = mapToScene(QPoint(0, viewport()->height() / 2)).y();
     centerOn(QPointF(cursorPos(), verticalPos));
 }
 
@@ -5032,35 +5033,27 @@ void CustomTrackView::slotRefreshGuides()
 
 void CustomTrackView::drawBackground(QPainter * painter, const QRectF &rect)
 {
-    //kDebug() << "// DRAW BG: " << rect.width();
     painter->setClipRect(rect);
-    KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window);
     QPen pen1 = painter->pen();
-    pen1.setColor(scheme.shade(KColorScheme::DarkShade));
+    pen1.setColor(palette().dark().color());
     painter->setPen(pen1);
     double min = rect.left();
     double max = rect.right();
     painter->drawLine(QPointF(min, 0), QPointF(max, 0));
     int maxTrack = m_document->tracksCount();
-    QColor lockedColor = scheme.background(KColorScheme::NegativeBackground).color();
+    QColor lockedColor = palette().button().color();
     QColor audioColor = palette().alternateBase().color();
-    QColor base = scheme.background(KColorScheme::NormalBackground).color();
     for (int i = 0; i < maxTrack; i++) {
         TrackInfo info = m_document->trackInfoAt(maxTrack - i - 1);
         if (info.isLocked || info.type == AUDIOTRACK || i == m_selectedTrack) {
             const QRectF track(min, m_tracksHeight * i + 1, max - min, m_tracksHeight - 1);
             if (i == m_selectedTrack)
-                painter->fillRect(track, scheme.background(KColorScheme::ActiveBackground).color());
+                painter->fillRect(track, m_activeTrackBrush.brush(this));
             else
                 painter->fillRect(track, info.isLocked ? lockedColor : audioColor);
         }
         painter->drawLine(QPointF(min, m_tracksHeight *(i + 1)), QPointF(max, m_tracksHeight *(i + 1)));
     }
-    int lowerLimit = m_tracksHeight * maxTrack + 1;
-    if (height() > lowerLimit) {
-        const QRectF bg(min, lowerLimit, max - min, height() - lowerLimit);
-        painter->fillRect(bg, base);
-    }
 }
 
 bool CustomTrackView::findString(const QString &text)
@@ -6253,12 +6246,14 @@ void CustomTrackView::clearSelection()
 
 void CustomTrackView::updatePalette()
 {
+    m_activeTrackBrush = KStatefulBrush(KColorScheme::View, KColorScheme::ActiveBackground, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
     if (m_cursorLine) {
         QPen pen1 = QPen();
         pen1.setWidth(1);
         pen1.setColor(palette().text().color());
         m_cursorLine->setPen(pen1);
     }
+    emit tracksChanged();
 }
 
 void CustomTrackView::removeTipAnimation()
index adc68714f02fc6adf768114421be90a3b287e266..995e134e369aa6a26ff375ff9ea8e6e455bc1abd 100644 (file)
@@ -22,6 +22,7 @@
 #define CUSTOMTRACKVIEW_H
 
 #include <KPixmapCache>
+#include <KColorScheme>
 
 #include <QGraphicsView>
 #include <QGraphicsItemAnimation>
@@ -42,6 +43,7 @@ class AbstractClipItem;
 class AbstractGroupItem;
 class Transition;
 
+
 class CustomTrackView : public QGraphicsView
 {
     Q_OBJECT
@@ -332,6 +334,7 @@ private:
 
     QMutex m_mutex;
     QWaitCondition m_producerNotReady;
+    KStatefulBrush m_activeTrackBrush;
 
     /** stores the state of the control modifier during mouse press.
      * Will then be used to identify whether we resize a group or only one item of it. */
index 7447c433b7d74bcb47f39a3acac0f5490af8b290..4926b0499e655a8adcfe35230b11f121b8c64f57 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "headertrack.h"
 #include "effectslist.h"
+#include "kdenlivesettings.h"
 
 #include <KIcon>
 #include <KLocale>
@@ -42,8 +43,16 @@ HeaderTrack::HeaderTrack(int index, TrackInfo info, int height, QWidget *parent)
 {
     setFixedHeight(height);
     setupUi(this);
-    QColor col = track_number->palette().color(QPalette::Base);
-    track_number->setStyleSheet(QString("QLineEdit { background-color: transparent;} QLineEdit:hover{ background-color: rgb(%1, %2, %3);} QLineEdit:focus { background-color: rgb(%1, %2, %3);}").arg(col.red()).arg(col.green()).arg(col.blue()));
+
+    QPalette p = 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);
+    setPalette(p);
+
+    QColor col = scheme.background().color();
+    QColor col2 = scheme.foreground().color();
+    track_number->setStyleSheet(QString("QLineEdit { background-color: transparent;color: rgb(%4, %5, %6);} QLineEdit:hover{ background-color: rgb(%1, %2, %3);} QLineEdit:focus { background-color: rgb(%1, %2, %3);}").arg(col.red()).arg(col.green()).arg(col.blue()).arg(col2.red()).arg(col2.green()).arg(col2.blue()));
 
     m_name = info.trackName.isEmpty() ? QString::number(m_index) : info.trackName;
     track_number->setText(m_name);
@@ -59,11 +68,6 @@ HeaderTrack::HeaderTrack(int index, TrackInfo info, int height, QWidget *parent)
     updateEffectLabel(info.effectsList.effectNames());
     setAcceptDrops(true);
 
-    QPalette p = palette();
-    KColorScheme scheme(p.currentColorGroup(), KColorScheme::Window);
-    p.setColor(QPalette::Button, scheme.background(KColorScheme::ActiveBackground).color().darker(120));
-    setPalette(p);
-
     if (m_type == VIDEOTRACK) {
         setBackgroundRole(QPalette::AlternateBase);
         setAutoFillBackground(true);
index c72136c569948e87a2604ff1c2974424a7f38c3e..0e8a8c1857a34ac05f0c98ce3c9b4e2e837c9148 100644 (file)
@@ -54,7 +54,6 @@ TrackView::TrackView(KdenliveDoc *doc, bool *ok, QWidget *parent) :
     m_trackview = new CustomTrackView(doc, m_scene, parent);
     m_trackview->scale(1, 1);
     m_trackview->setAlignment(Qt::AlignLeft | Qt::AlignTop);
-    //m_scene->addRect(QRectF(0, 0, 100, 100), QPen(), QBrush(Qt::red));
 
     m_ruler = new CustomRuler(doc->timecode(), m_trackview);
     connect(m_ruler, SIGNAL(zoneMoved(int, int)), this, SIGNAL(zoneMoved(int, int)));
@@ -518,13 +517,9 @@ void TrackView::refresh()
 
 void TrackView::slotRepaintTracks()
 {
-    QLayoutItem *child;
-    for (int i = 0; i < headers_container->layout()->count(); i++) {
-        child = headers_container->layout()->itemAt(i);
-        if (child->widget() && child->widget()->height() > 5) {
-            HeaderTrack *head = static_cast <HeaderTrack *>(child->widget());
-            if (head) head->setSelectedIndex(m_trackview->selectedTrack());
-        }
+    QList<HeaderTrack *> widgets = findChildren<HeaderTrack *>();
+    for (int i = 0; i < widgets.count(); i++) {
+        if (widgets.at(i)) widgets.at(i)->setSelectedIndex(m_trackview->selectedTrack());
     }
 }
 
@@ -549,10 +544,8 @@ void TrackView::slotRebuildTrackHeaders()
     QFrame *frame = NULL;
     for (int i = 0; i < max; i++) {
         frame = new QFrame(headers_container);
+        frame->setFrameStyle(QFrame::HLine);
         frame->setFixedHeight(1);
-        frame->setFrameStyle(QFrame::Plain);
-        frame->setFrameShape(QFrame::Box);
-        frame->setLineWidth(1);
         headers_container->layout()->addWidget(frame);
         TrackInfo info = list.at(max - i - 1);
         header = new HeaderTrack(i, info, height, headers_container);
@@ -570,10 +563,8 @@ void TrackView::slotRebuildTrackHeaders()
         headers_container->layout()->addWidget(header);
     }
     frame = new QFrame(this);
+    frame->setFrameStyle(QFrame::HLine);
     frame->setFixedHeight(1);
-    frame->setFrameStyle(QFrame::Plain);
-    frame->setFrameShape(QFrame::Box);
-    frame->setLineWidth(1);
     headers_container->layout()->addWidget(frame);
 }
 
@@ -581,10 +572,9 @@ void TrackView::slotRebuildTrackHeaders()
 void TrackView::adjustTrackHeaders()
 {
     int height = KdenliveSettings::trackheight() * m_scene->scale().y() - 1;
-    QLayoutItem *child;
-    for (int i = 0; i < headers_container->layout()->count(); i++) {
-        child = headers_container->layout()->itemAt(i);
-        if (child->widget() && child->widget()->height() > 5)(static_cast <HeaderTrack *>(child->widget()))->adjustSize(height);
+    QList<HeaderTrack *> widgets = findChildren<HeaderTrack *>();
+    for (int i = 0; i < widgets.count(); i++) {
+        if (widgets.at(i)) widgets.at(i)->adjustSize(height);
     }
 }