Fix parts of Kdenlive not responding to color theme change

parent dee58715
......@@ -88,6 +88,11 @@ CustomRuler::CustomRuler(Timecode tc, CustomTrackView *parent) :
setMouseTracking(true);
}
void CustomRuler::updatePalette()
{
m_zoneColor = KStatefulBrush(KColorScheme::View, KColorScheme::PositiveBackground, KSharedConfig::openConfig(KdenliveSettings::colortheme())).brush(this).color();
}
void CustomRuler::updateProjectFps(Timecode t)
{
m_timecode = t;
......@@ -343,7 +348,7 @@ void CustomRuler::paintEvent(QPaintEvent *e)
p.setClipRect(e->rect());
// Draw background
p.fillRect(0, 0, m_duration * m_factor - m_offset, MAX_HEIGHT, palette().alternateBase().color());
//p.fillRect(0, 0, m_duration * m_factor - m_offset, MAX_HEIGHT, palette().alternateBase().color());
// Draw zone background
const int zoneStart = (int)(m_zoneStart * m_factor);
......
......@@ -49,6 +49,8 @@ public:
int offset() const;
void updateProjectFps(Timecode t);
void updateFrameSize();
void updatePalette();
protected:
virtual void paintEvent(QPaintEvent * /*e*/);
virtual void wheelEvent(QWheelEvent * e);
......
......@@ -6519,7 +6519,6 @@ void CustomTrackView::updatePalette()
pen1.setColor(palette().text().color());
m_cursorLine->setPen(pen1);
}
emit tracksChanged();
}
void CustomTrackView::removeTipAnimation()
......
......@@ -210,4 +210,9 @@ void EffectsListView::slotAutoExpand(QString text)
if (!selected) m_effectsList->setCurrentItem(NULL);
}
void EffectsListView::updatePalette()
{
m_effectsList->setStyleSheet(m_effectsList->styleSheet());
}
#include "effectslistview.moc"
......@@ -51,6 +51,9 @@ public:
void reloadEffectList(QMenu *effectsMenu, KActionCategory *effectActions);
QMenu* getEffectsMenu();
//void slotAddEffect(GenTime pos, int track, QString name);
/** @brief Palette was changed, update styles. */
void updatePalette();
private:
EffectsListWidget *m_effectsList;
......
......@@ -205,9 +205,9 @@ CollapsibleEffect::~CollapsibleEffect()
}
//static
const QString CollapsibleEffect::getStyleSheet(QPalette p)
const QString CollapsibleEffect::getStyleSheet()
{
KColorScheme scheme(p.currentColorGroup(), KColorScheme::View, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
KColorScheme scheme(QApplication::palette().currentColorGroup(), KColorScheme::View, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
QColor dark_bg = scheme.shade(KColorScheme::DarkShade);
QColor selected_bg = scheme.decoration(KColorScheme::FocusColor).color();
QColor hover_bg = scheme.decoration(KColorScheme::HoverColor).color();
......@@ -216,7 +216,7 @@ const QString CollapsibleEffect::getStyleSheet(QPalette p)
QColor normal_bg = scheme.background(KColorScheme::AlternateBackground).color();
QColor alt_bg = scheme.background(KColorScheme::NormalBackground).color();
KColorScheme scheme2(p.currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
KColorScheme scheme2(QApplication::palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
QColor normal_bg2 = scheme2.background(KColorScheme::NormalBackground).color();
QColor normal_bg3 = scheme2.background(KColorScheme::AlternateBackground).color();
......
......@@ -145,7 +145,7 @@ public:
bool filterWheelEvent;
/** @brief Return the stylesheet required for effect parameters. */
static const QString getStyleSheet(QPalette p);
static const QString getStyleSheet();
public slots:
void slotSyncEffectsPos(int pos);
......
......@@ -68,13 +68,17 @@ EffectStackView2::EffectStackView2(Monitor *monitor, QWidget *parent) :
setEnabled(false);
setStyleSheet(CollapsibleEffect::getStyleSheet(palette()));
setStyleSheet(CollapsibleEffect::getStyleSheet());
}
EffectStackView2::~EffectStackView2()
{
}
void EffectStackView2::updatePalette()
{
setStyleSheet(CollapsibleEffect::getStyleSheet());
}
void EffectStackView2::slotRenderPos(int pos)
{
......
......@@ -66,6 +66,9 @@ public:
/** @brief Delete currently selected effect. */
void deleteCurrentEffect();
/** @brief Palette was changed, update style. */
void updatePalette();
protected:
virtual void mouseMoveEvent(QMouseEvent * event);
......
......@@ -100,7 +100,7 @@ EffectStackEdit::EffectStackEdit(Monitor *monitor, QWidget *parent) :
setFrameStyle(QFrame::NoFrame);
setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding));
setStyleSheet(CollapsibleEffect::getStyleSheet(palette()));
setStyleSheet(CollapsibleEffect::getStyleSheet());
setWidget(m_baseWidget);
/*m_vbox = new QVBoxLayout(m_baseWidget);
m_vbox->setContentsMargins(0, 0, 0, 0);
......
......@@ -144,6 +144,8 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
KXmlGuiWindow(parent),
m_activeDocument(NULL),
m_activeTimeline(NULL),
m_clipMonitor(NULL),
m_projectMonitor(NULL),
m_recMonitor(NULL),
m_renderWidget(NULL),
#ifdef USE_JOGSHUTTLE
......@@ -630,6 +632,8 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
KdenliveSettings::setDecklink_extension(data.section(';', 1, 1));
}
}
connect (KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), this, SLOT(slotChangePalette()));
}
MainWindow::~MainWindow()
......@@ -949,12 +953,8 @@ void MainWindow::setupActions()
KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
toolbar->setMovable(false);
KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
QString style1 = QString("QToolBar { border: 0px } QToolButton { border-style: inset; border:1px solid transparent;border-radius: 3px;margin: 0px 3px;padding: 0px;} QToolButton:hover { background: rgb(%7, %8, %9);border-style: inset; border:1px solid rgb(%7, %8, %9);border-radius: 3px;} QToolButton:checked { background-color: rgb(%1, %2, %3); border-style: inset; border:1px solid rgb(%4, %5, %6);border-radius: 3px;}").arg(buttonBg.red()).arg(buttonBg.green()).arg(buttonBg.blue()).arg(buttonBord.red()).arg(buttonBord.green()).arg(buttonBord.blue()).arg(buttonBord2.red()).arg(buttonBord2.green()).arg(buttonBord2.blue());
setStatusBarStyleSheet(palette());
QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
//create edit mode buttons
......@@ -1040,7 +1040,6 @@ void MainWindow::setupActions()
actionWidget->setMaximumWidth(max);
actionWidget->setMaximumHeight(max - 4);
toolbar->setStyleSheet(style1);
connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
toolbar->addSeparator();
......@@ -1683,6 +1682,17 @@ void MainWindow::slotDisplayActionMessage(QAction *a)
statusBar()->showMessage(a->data().toString(), 3000);
}
void MainWindow::setStatusBarStyleSheet(const QPalette &p)
{
KColorScheme scheme(p.currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
QString style1 = QString("QToolBar { border: 0px } QToolButton { border-style: inset; border:1px solid transparent;border-radius: 3px;margin: 0px 3px;padding: 0px;} QToolButton:hover { background: %3;border-style: inset; border:1px solid %3;border-radius: 3px;} QToolButton:checked { background-color: %1; border-style: inset; border:1px solid %2;border-radius: 3px;}").arg(buttonBg.name()).arg(buttonBord.name()).arg(buttonBord2.name());
statusBar()->setStyleSheet(style1);
}
void MainWindow::loadLayouts()
{
QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
......@@ -4176,6 +4186,7 @@ void MainWindow::slotChangePalette(QAction *action, const QString &themename)
}
kapp->setPalette(plt);
slotChangePalette();
const QObjectList children = statusBar()->children();
foreach(QObject * child, children) {
......@@ -4187,9 +4198,6 @@ void MainWindow::slotChangePalette(QAction *action, const QString &themename)
((QWidget*)subchild)->setPalette(plt);
}
}
if (m_activeTimeline) {
m_activeTimeline->projectView()->updatePalette();
}
}
......@@ -4418,6 +4426,23 @@ void MainWindow::slotDownloadResources()
d->show();
}
void MainWindow::slotChangePalette()
{
QPalette plt = QApplication::palette();
if (m_effectStack) m_effectStack->updatePalette();
if (m_projectList) m_projectList->updatePalette();
if (m_effectList) m_effectList->updatePalette();
if (m_clipMonitor) m_clipMonitor->setPalette(plt);
if (m_projectMonitor) m_projectMonitor->setPalette(plt);
setStatusBarStyleSheet(plt);
if (m_activeTimeline) {
m_activeTimeline->updatePalette();
}
}
#include "mainwindow.moc"
#ifdef DEBUG_MAINW
......
......@@ -311,6 +311,9 @@ private:
StopmotionWidget *m_stopmotion;
QTime m_timer;
/** @brief Update statusbar stylesheet (in case of color theme change). */
void setStatusBarStyleSheet(const QPalette &p);
public slots:
/** @brief Prepares opening @param url.
......@@ -548,6 +551,8 @@ private slots:
void slotElapsedTime();
/** @brief Open the online services search dialog. */
void slotDownloadResources();
void slotChangePalette();
signals:
Q_SCRIPTABLE void abortRenderJob(const QString &url);
......
......@@ -1051,6 +1051,12 @@ void Monitor::reloadProducer(const QString &id)
slotSetClipProducer(m_currentClip, m_currentClip->zone(), true);
}
void Monitor::setPalette ( const QPalette & p)
{
QWidget::setPalette(p);
if (m_ruler) m_ruler->updatePalette();
}
Overlay::Overlay(QWidget* parent) :
QLabel(parent)
......
......@@ -89,6 +89,8 @@ public:
QWidget *container();
void reloadProducer(const QString &id);
QFrame *m_volumePopup;
/** @brief Reimplemented from QWidget, updates the palette colors. */
void setPalette ( const QPalette & p);
protected:
virtual void mousePressEvent(QMouseEvent * event);
......
......@@ -72,6 +72,7 @@
#include <QIcon>
#include <QMenu>
#include <QProcess>
#include <QScrollBar>
#include <QHeaderView>
#include <QInputDialog>
#include <QtConcurrentRun>
......@@ -84,7 +85,15 @@ SmallInfoLabel::SmallInfoLabel(QWidget *parent) : QPushButton(parent)
/*QString style = "QToolButton {background-color: %1;border-style: outset;border-width: 2px;
border-radius: 5px;border-color: beige;}";*/
KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
m_timeLine = new QTimeLine(500, this);
QObject::connect(m_timeLine, SIGNAL(valueChanged(qreal)), this, SLOT(slotTimeLineChanged(qreal)));
QObject::connect(m_timeLine, SIGNAL(finished()), this, SLOT(slotTimeLineFinished()));
hide();
}
const QString SmallInfoLabel::getStyleSheet(const QPalette &p)
{
KColorScheme scheme(p.currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
QColor bg = scheme.background(KColorScheme::LinkBackground).color();
QColor fg = scheme.foreground(KColorScheme::LinkText).color();
QString style = QString("QPushButton {padding:2px;background-color: rgb(%1, %2, %3);border-radius: 4px;border: none;color: rgb(%4, %5, %6)}").arg(bg.red()).arg(bg.green()).arg(bg.blue()).arg(fg.red()).arg(fg.green()).arg(fg.blue());
......@@ -93,11 +102,7 @@ SmallInfoLabel::SmallInfoLabel(QWidget *parent) : QPushButton(parent)
fg = scheme.foreground(KColorScheme::ActiveText).color();
style.append(QString("\nQPushButton:hover {padding:2px;background-color: rgb(%1, %2, %3);border-radius: 4px;border: none;color: rgb(%4, %5, %6)}").arg(bg.red()).arg(bg.green()).arg(bg.blue()).arg(fg.red()).arg(fg.green()).arg(fg.blue()));
setStyleSheet(style);
m_timeLine = new QTimeLine(500, this);
QObject::connect(m_timeLine, SIGNAL(valueChanged(qreal)), this, SLOT(slotTimeLineChanged(qreal)));
QObject::connect(m_timeLine, SIGNAL(finished()), this, SLOT(slotTimeLineFinished()));
hide();
return style;
}
void SmallInfoLabel::slotTimeLineChanged(qreal value)
......@@ -233,6 +238,7 @@ ProjectList::ProjectList(QWidget *parent) :
// small info button for pending jobs
m_infoLabel = new SmallInfoLabel(this);
m_infoLabel->setStyleSheet(SmallInfoLabel::getStyleSheet(palette()));
connect(this, SIGNAL(jobCount(int)), m_infoLabel, SLOT(slotSetJobCount(int)));
m_jobsMenu = new QMenu(this);
connect(m_jobsMenu, SIGNAL(aboutToShow()), this, SLOT(slotPrepareJobsMenu()));
......@@ -269,7 +275,7 @@ ProjectList::ProjectList(QWidget *parent) :
frame->setLayout(box);
layout->addWidget(frame);
m_listView = new ProjectListView;
m_listView = new ProjectListView(this);
layout->addWidget(m_listView);
#if KDE_IS_VERSION(4,7,0)
......@@ -3448,4 +3454,10 @@ void ProjectList::slotDiscardClipJobs()
discardJobs(id);
}
void ProjectList::updatePalette()
{
m_infoLabel->setStyleSheet(SmallInfoLabel::getStyleSheet(QApplication::palette()));
m_listView->updateStyleSheet();
}
#include "projectlist.moc"
......@@ -80,7 +80,7 @@ class SmallInfoLabel: public QPushButton
Q_OBJECT
public:
SmallInfoLabel(QWidget *parent = 0);
static const QString getStyleSheet(const QPalette &p);
private:
QTimeLine* m_timeLine;
......@@ -261,6 +261,9 @@ public:
void startClipFilterJob(const QString &filterName, const QString &condition);
/** @brief Set current document for the project tree. */
void setDocument(KdenliveDoc *doc);
/** @brief Palette was changed, update style. */
void updatePalette();
public slots:
void updateAllClips(bool displayRatioChanged, bool fpsChanged, QStringList brokenClips);
......
......@@ -45,15 +45,7 @@ ProjectListView::ProjectListView(QWidget *parent) :
setFrameShape(QFrame::NoFrame);
setRootIsDecorated(true);
QString style = "QTreeView::branch:has-siblings:!adjoins-item{border-image: none;border:0px} \
QTreeView::branch:has-siblings:adjoins-item {border-image: none;border:0px} \
QTreeView::branch:!has-children:!has-siblings:adjoins-item {border-image: none;border:0px} \
QTreeView::branch:has-children:!has-siblings:closed,QTreeView::branch:closed:has-children:has-siblings { \
border-image: none;image: url(:/images/stylesheet-branch-closed.png);} \
QTreeView::branch:open:has-children:!has-siblings,QTreeView::branch:open:has-children:has-siblings { \
border-image: none;image: url(:/images/stylesheet-branch-open.png);}";
setStyleSheet(style);
updateStyleSheet();
setColumnCount(4);
QStringList headers;
......@@ -82,6 +74,18 @@ ProjectListView::~ProjectListView()
{
}
void ProjectListView::updateStyleSheet()
{
QString style = "QTreeView::branch:has-siblings:!adjoins-item{border-image: none;border:0px} \
QTreeView::branch:has-siblings:adjoins-item {border-image: none;border:0px} \
QTreeView::branch:!has-children:!has-siblings:adjoins-item {border-image: none;border:0px} \
QTreeView::branch:has-children:!has-siblings:closed,QTreeView::branch:closed:has-children:has-siblings { \
border-image: none;image: url(:/images/stylesheet-branch-closed.png);} \
QTreeView::branch:open:has-children:!has-siblings,QTreeView::branch:open:has-children:has-siblings { \
border-image: none;image: url(:/images/stylesheet-branch-open.png);}";
setStyleSheet(style);
}
void ProjectListView::processLayout()
{
executeDelayedItemsLayout();
......
......@@ -37,6 +37,7 @@ public:
ProjectListView(QWidget *parent = 0);
virtual ~ProjectListView();
void processLayout();
void updateStyleSheet();
protected:
virtual void contextMenuEvent(QContextMenuEvent * event);
......
......@@ -233,4 +233,11 @@ void SmallRuler::paintEvent(QPaintEvent *e)
p.drawPolygon(pa);
}
void SmallRuler::updatePalette()
{
KSharedConfigPtr config = KSharedConfig::openConfig(KdenliveSettings::colortheme());
m_zoneBrush = KStatefulBrush(KColorScheme::View, KColorScheme::PositiveBackground, config);
updatePixmap();
}
#include "smallruler.moc"
......@@ -41,6 +41,7 @@ public:
QPoint zone();
void setMarkers(QList < int > list);
int position() const;
void updatePalette();
protected:
virtual void paintEvent(QPaintEvent *e);
......
......@@ -537,14 +537,7 @@ void TrackView::slotRebuildTrackHeaders()
HeaderTrack *header = NULL;
QFrame *frame = NULL;
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);
QColor col = scheme.background().color();
QColor col2 = scheme.foreground().color();
headers_container->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()));
updatePalette();
for (int i = 0; i < max; i++) {
frame = new QFrame(headers_container);
......@@ -553,7 +546,6 @@ void TrackView::slotRebuildTrackHeaders()
headers_container->layout()->addWidget(frame);
TrackInfo info = list.at(max - i - 1);
header = new HeaderTrack(i, info, height, m_trackActions, headers_container);
header->setPalette(p);
header->setSelectedIndex(m_trackview->selectedTrack());
connect(header, SIGNAL(switchTrackVideo(int)), m_trackview, SLOT(slotSwitchTrackVideo(int)));
connect(header, SIGNAL(switchTrackAudio(int)), m_trackview, SLOT(slotSwitchTrackAudio(int)));
......@@ -572,6 +564,20 @@ void TrackView::slotRebuildTrackHeaders()
}
void TrackView::updatePalette()
{
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);
QColor col = scheme.background().color();
QColor col2 = scheme.foreground().color();
headers_container->setStyleSheet(QString("QLineEdit { background-color: transparent;color: %1;} QLineEdit:hover{ background-color: %2;} QLineEdit:focus { background-color: %2;}").arg(col2.name()).arg(col.name()));
m_trackview->updatePalette();
m_ruler->updatePalette();
}
void TrackView::adjustTrackHeaders()
{
int height = KdenliveSettings::trackheight() * m_scene->scale().y() - 1;
......
......@@ -78,6 +78,7 @@ public:
void checkTrackHeight();
void updateProfile();
void updatePalette();
protected:
virtual void keyPressEvent(QKeyEvent * event);
......
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