Commit 8dd5e4e5 authored by Tim Jenssen's avatar Tim Jenssen
Browse files

QmlDesigner: use a central notTooBrightHighlightColor()



Change-Id: I71988cda0f9488a59722b00e0c0c0e926a15e7f2
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent 5e883e5b
...@@ -70,6 +70,15 @@ qreal StyleHelper::sidebarFontSize() ...@@ -70,6 +70,15 @@ qreal StyleHelper::sidebarFontSize()
return HostOsInfo::isMacHost() ? 10 : 7.5; return HostOsInfo::isMacHost() ? 10 : 7.5;
} }
QColor StyleHelper::notTooBrightHighlightColor()
{
QColor highlightColor = qApp->palette().highlight().color();
if (0.5 * highlightColor.saturationF() + 0.75 - highlightColor.valueF() < 0)
highlightColor.setHsvF(highlightColor.hsvHueF(), 0.1 + highlightColor.saturationF() * 2.0, highlightColor.valueF());
return highlightColor;
}
QPalette StyleHelper::sidebarFontPalette(const QPalette &original) QPalette StyleHelper::sidebarFontPalette(const QPalette &original)
{ {
QPalette palette = original; QPalette palette = original;
......
...@@ -70,6 +70,8 @@ public: ...@@ -70,6 +70,8 @@ public:
static QColor sidebarHighlight() { return QColor(255, 255, 255, 40); } static QColor sidebarHighlight() { return QColor(255, 255, 255, 40); }
static QColor sidebarShadow() { return QColor(0, 0, 0, 40); } static QColor sidebarShadow() { return QColor(0, 0, 0, 40); }
static QColor notTooBrightHighlightColor();
// Sets the base color and makes sure all top level widgets are updated // Sets the base color and makes sure all top level widgets are updated
static void setBaseColor(const QColor &color); static void setBaseColor(const QColor &color);
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/stylehelper.h>
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include "itemlibrarymodel.h" #include "itemlibrarymodel.h"
...@@ -84,11 +86,7 @@ ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) : ...@@ -84,11 +86,7 @@ ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) :
rootContext->setContextProperty(QStringLiteral("itemLibraryIconWidth"), m_itemIconSize.width()); rootContext->setContextProperty(QStringLiteral("itemLibraryIconWidth"), m_itemIconSize.width());
rootContext->setContextProperty(QStringLiteral("itemLibraryIconHeight"), m_itemIconSize.height()); rootContext->setContextProperty(QStringLiteral("itemLibraryIconHeight"), m_itemIconSize.height());
QColor highlightColor = palette().highlight().color(); m_itemsView->rootContext()->setContextProperty(QStringLiteral("highlightColor"), Utils::StyleHelper::notTooBrightHighlightColor());
if (0.5*highlightColor.saturationF()+0.75-highlightColor.valueF() < 0)
highlightColor.setHsvF(highlightColor.hsvHueF(),0.1 + highlightColor.saturationF()*2.0, highlightColor.valueF());
m_itemsView->rootContext()->setContextProperty(QStringLiteral("highlightColor"), highlightColor);
/* create Resources view and its model */ /* create Resources view and its model */
m_resourcesFileSystemModel = new QFileSystemModel(this); m_resourcesFileSystemModel = new QFileSystemModel(this);
......
...@@ -36,6 +36,9 @@ ...@@ -36,6 +36,9 @@
#include "qproxystyle.h" #include "qproxystyle.h"
#include "metainfo.h" #include "metainfo.h"
#include <utils/stylehelper.h>
#include <QLineEdit> #include <QLineEdit>
#include <QPen> #include <QPen>
#include <QPixmapCache> #include <QPixmapCache>
...@@ -47,13 +50,10 @@ namespace QmlDesigner { ...@@ -47,13 +50,10 @@ namespace QmlDesigner {
void drawSelectionBackground(QPainter *painter, const QStyleOption &option) void drawSelectionBackground(QPainter *painter, const QStyleOption &option)
{ {
QWidget colorReference;
painter->save(); painter->save();
QLinearGradient gradient; QLinearGradient gradient;
QColor highlightColor = colorReference.palette().highlight().color();
if (0.5*highlightColor.saturationF()+0.75-highlightColor.valueF() < 0) QColor highlightColor = Utils::StyleHelper::notTooBrightHighlightColor();
highlightColor.setHsvF(highlightColor.hsvHueF(),0.1 + highlightColor.saturationF()*2.0, highlightColor.valueF());
gradient.setColorAt(0, highlightColor.lighter(130)); gradient.setColorAt(0, highlightColor.lighter(130));
gradient.setColorAt(1, highlightColor.darker(130)); gradient.setColorAt(1, highlightColor.darker(130));
gradient.setStart(option.rect.topLeft()); gradient.setStart(option.rect.topLeft());
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/stylehelper.h>
#include <QApplication> #include <QApplication>
...@@ -103,10 +104,8 @@ StatesEditorWidget::StatesEditorWidget(StatesEditorView *statesEditorView, State ...@@ -103,10 +104,8 @@ StatesEditorWidget::StatesEditorWidget(StatesEditorView *statesEditorView, State
container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_quickView->rootContext()->setContextProperty(QStringLiteral("statesEditorModel"), statesEditorModel); m_quickView->rootContext()->setContextProperty(QStringLiteral("statesEditorModel"), statesEditorModel);
QColor highlightColor = palette().highlight().color(); m_quickView->rootContext()->setContextProperty(QStringLiteral("highlightColor"), Utils::StyleHelper::notTooBrightHighlightColor());
if (0.5*highlightColor.saturationF()+0.75-highlightColor.valueF() < 0)
highlightColor.setHsvF(highlightColor.hsvHueF(),0.1 + highlightColor.saturationF()*2.0, highlightColor.valueF());
m_quickView->rootContext()->setContextProperty(QStringLiteral("highlightColor"), highlightColor);
m_quickView->rootContext()->setContextProperty("canAddNewStates", true); m_quickView->rootContext()->setContextProperty("canAddNewStates", true);
......
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