aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKnud Dollereder <knud.dollereder@qt.io>2021-03-15 15:31:52 +0100
committerKnud Dollereder <knud.dollereder@qt.io>2021-03-16 16:16:36 +0000
commitd41d59774a7ca003fce131b23ff3b0cce487eff4 (patch)
tree73d30b50a4230e65354c5cb254795bc2ea96ad42
parent2bcc33e0109419d1e977fc4b2c8f060ccbfae5e4 (diff)
Apply new theming colors to the curveeditor
Change-Id: Ia919bfda4db1205b9c30ece247d2e3d49a6362ed Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
-rw-r--r--src/plugins/qmldesigner/components/curveeditor/curveeditormodel.cpp6
-rw-r--r--src/plugins/qmldesigner/components/curveeditor/detail/graphicsview.cpp8
-rw-r--r--src/plugins/qmldesigner/components/timelineeditor/preseteditor.cpp50
-rw-r--r--src/plugins/qmldesigner/components/timelineeditor/preseteditor.h13
4 files changed, 55 insertions, 22 deletions
diff --git a/src/plugins/qmldesigner/components/curveeditor/curveeditormodel.cpp b/src/plugins/qmldesigner/components/curveeditor/curveeditormodel.cpp
index ab3caa3966..6b52b3d1db 100644
--- a/src/plugins/qmldesigner/components/curveeditor/curveeditormodel.cpp
+++ b/src/plugins/qmldesigner/components/curveeditor/curveeditormodel.cpp
@@ -63,9 +63,9 @@ CurveEditorStyle CurveEditorModel::style() const
{
// Pseudo auto generated. See: CurveEditorStyleDialog
CurveEditorStyle out;
- out.backgroundBrush = QBrush(QColor(21, 21, 21));
- out.backgroundAlternateBrush = QBrush(QColor(32, 32, 32));
- out.fontColor = QColor(255, 255, 255);
+ out.backgroundBrush = QmlDesigner::Theme::getColor(QmlDesigner::Theme::DSsectionHeadBackground);
+ out.backgroundAlternateBrush = QmlDesigner::Theme::getColor(QmlDesigner::Theme::DSpanelBackground);
+ out.fontColor = QmlDesigner::Theme::getColor(QmlDesigner::Theme::DStextColor);
out.gridColor = QColor(114, 116, 118);
out.canvasMargin = 15;
out.zoomInWidth = 99;
diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/graphicsview.cpp b/src/plugins/qmldesigner/components/curveeditor/detail/graphicsview.cpp
index b27015aa97..9324059cf7 100644
--- a/src/plugins/qmldesigner/components/curveeditor/detail/graphicsview.cpp
+++ b/src/plugins/qmldesigner/components/curveeditor/detail/graphicsview.cpp
@@ -31,6 +31,9 @@
#include "treeitem.h"
#include "utils.h"
+#include <theme.h>
+#include <utils/fileutils.h>
+
#include <QAction>
#include <QMenu>
#include <QResizeEvent>
@@ -84,6 +87,11 @@ GraphicsView::GraphicsView(CurveEditorModel *model, QWidget *parent)
applyZoom(m_zoomX, m_zoomY);
update();
+
+ const QString css = Theme::replaceCssColors(QString::fromUtf8(
+ Utils::FileReader::fetchQrc(QLatin1String(":/qmldesigner/scrollbar.css"))));
+ horizontalScrollBar()->setStyleSheet(css);
+ verticalScrollBar()->setStyleSheet(css);
}
GraphicsView::~GraphicsView()
diff --git a/src/plugins/qmldesigner/components/timelineeditor/preseteditor.cpp b/src/plugins/qmldesigner/components/timelineeditor/preseteditor.cpp
index 2ef68f24b4..f755e4863e 100644
--- a/src/plugins/qmldesigner/components/timelineeditor/preseteditor.cpp
+++ b/src/plugins/qmldesigner/components/timelineeditor/preseteditor.cpp
@@ -55,11 +55,10 @@ constexpr int spacingg = 5;
const QColor background = Qt::white;
-const QColor labelBackground = qRgb(0x70, 0x70, 0x70);
-const QColor canvasBackground = qRgb(0x46, 0x46, 0x46);
-const QColor curveLine = qRgb(0xe6, 0xe7, 0xe8);
-
-PresetItemDelegate::PresetItemDelegate() = default;
+PresetItemDelegate::PresetItemDelegate(const QColor& background)
+ : QStyledItemDelegate()
+ , m_background(background)
+{}
void PresetItemDelegate::paint(QPainter *painter,
const QStyleOptionViewItem &opt,
@@ -80,10 +79,10 @@ void PresetItemDelegate::paint(QPainter *painter,
option.font.setPixelSize(Theme::instance()->smallFontPixelSize());
painter->save();
- painter->fillRect(option.rect, canvasBackground);
+ painter->fillRect(option.rect, m_background);
if (option.text.isEmpty())
- painter->fillRect(textRect, canvasBackground);
+ painter->fillRect(textRect, m_background);
else
painter->fillRect(textRect, Theme::instance()->qmlDesignerButtonColor());
@@ -118,23 +117,25 @@ QSize PresetItemDelegate::sizeHint(const QStyleOptionViewItem &opt, const QModel
return size;
}
-QIcon paintPreview()
+QIcon paintPreview(const QColor& background)
{
QPixmap pm(iconWidth, iconHeight);
- pm.fill(canvasBackground);
+ pm.fill(background);
return QIcon(pm);
}
-QIcon paintPreview(const EasingCurve &curve)
+QIcon paintPreview(const EasingCurve &curve, const QColor& background, const QColor& curveColor)
{
+ const QColor curveLine = Theme::getColor(Theme::DStextColor);
+
QPixmap pm(iconWidth, iconHeight);
- pm.fill(canvasBackground);
+ pm.fill(background);
QPainter painter(&pm);
painter.setRenderHint(QPainter::Antialiasing, true);
Canvas canvas(iconWidth, iconHeight, 2, 2, 9, 6, 0, 1);
- canvas.paintCurve(&painter, curve, curveLine);
+ canvas.paintCurve(&painter, curve, curveColor);
return QIcon(pm);
}
@@ -159,6 +160,8 @@ PresetList::PresetList(QSettings::Scope scope, QWidget *parent)
, m_scope(scope)
, m_index(-1)
, m_filename(Internal::settingsFullFilePath(scope))
+ , m_background(Theme::getColor(Theme::DSsectionHeadBackground ))
+ , m_curveColor(Theme::getColor(Theme::DStextColor))
{
int magic = 4;
int scrollBarWidth = this->style()->pixelMetric(QStyle::PM_ScrollBarExtent);
@@ -168,7 +171,7 @@ PresetList::PresetList(QSettings::Scope scope, QWidget *parent)
setModel(new QStandardItemModel);
- setItemDelegate(new PresetItemDelegate);
+ setItemDelegate(new PresetItemDelegate(m_background));
setSpacing(spacingg);
@@ -260,6 +263,16 @@ bool PresetList::isEditable(const QModelIndex &index) const
return flags.testFlag(Qt::ItemIsEditable);
}
+QColor PresetList::backgroundColor() const
+{
+ return m_background;
+}
+
+QColor PresetList::curveColor() const
+{
+ return m_curveColor;
+}
+
void PresetList::initialize(int index)
{
m_index = index;
@@ -278,7 +291,7 @@ void PresetList::readPresets()
for (int i = 0; i < curves.size(); ++i) {
QVariant curveData = QVariant::fromValue(curves[i].curve());
- auto *item = new QStandardItem(paintPreview(curves[i].curve()), curves[i].name());
+ auto *item = new QStandardItem(paintPreview(curves[i].curve(), m_background, m_curveColor), curves[i].name());
item->setData(curveData, ItemRole_Data);
item->setEditable(m_scope == QSettings::UserScope);
item->setToolTip(curves[i].name());
@@ -320,7 +333,7 @@ void PresetList::revert(const QModelIndex &index)
for (const auto &curve : curves) {
if (curve.name() == name) {
item->setData(false, ItemRole_Dirty);
- item->setData(paintPreview(curve.curve()), Qt::DecorationRole);
+ item->setData(paintPreview(curve.curve(), m_background, m_curveColor), Qt::DecorationRole);
item->setData(QVariant::fromValue(curve.curve()), ItemRole_Data);
item->setToolTip(name);
return;
@@ -334,7 +347,7 @@ void PresetList::updateCurve(const EasingCurve &curve)
if (!selectionModel()->hasSelection())
return;
- QVariant icon = QVariant::fromValue(paintPreview(curve));
+ QVariant icon = QVariant::fromValue(paintPreview(curve, m_background, m_curveColor));
QVariant curveData = QVariant::fromValue(curve);
for (const auto &index : selectionModel()->selectedIndexes())
@@ -382,7 +395,7 @@ void PresetList::createItem()
void PresetList::createItem(const QString &name, const EasingCurve &curve)
{
- auto *item = new QStandardItem(paintPreview(curve), name);
+ auto *item = new QStandardItem(paintPreview(curve, m_background, m_curveColor), name);
item->setData(QVariant::fromValue(curve), ItemRole_Data);
item->setToolTip(name);
@@ -507,7 +520,8 @@ void PresetEditor::update(const EasingCurve &curve)
m_presets->selectionModel()->clear();
else {
if (m_customs->selectionModel()->hasSelection()) {
- QVariant icon = QVariant::fromValue(paintPreview(curve));
+ QVariant icon = QVariant::fromValue(
+ paintPreview(curve, m_presets->backgroundColor(), m_presets->curveColor()));
QVariant curveData = QVariant::fromValue(curve);
for (const QModelIndex &index : m_customs->selectionModel()->selectedIndexes())
m_customs->setItemData(index, curveData, icon);
diff --git a/src/plugins/qmldesigner/components/timelineeditor/preseteditor.h b/src/plugins/qmldesigner/components/timelineeditor/preseteditor.h
index 6fab3e7adb..4e805fcf2b 100644
--- a/src/plugins/qmldesigner/components/timelineeditor/preseteditor.h
+++ b/src/plugins/qmldesigner/components/timelineeditor/preseteditor.h
@@ -43,13 +43,16 @@ class PresetItemDelegate : public QStyledItemDelegate
Q_OBJECT
public:
- PresetItemDelegate();
+ PresetItemDelegate(const QColor& background);
void paint(QPainter *painter,
const QStyleOptionViewItem &opt,
const QModelIndex &index) const override;
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
+
+private:
+ QColor m_background;
};
class PresetList : public QListView
@@ -80,6 +83,10 @@ public:
bool isEditable(const QModelIndex &index) const;
+ QColor backgroundColor() const;
+
+ QColor curveColor() const;
+
void initialize(int index);
void readPresets();
@@ -118,6 +125,10 @@ private:
int m_index;
QString m_filename;
+
+ QColor m_background;
+
+ QColor m_curveColor;
};
class PresetEditor : public QStackedWidget