From f8a6bc7294014fc82f98f8218df1e19f75c2c290 Mon Sep 17 00:00:00 2001 From: Christiaan Janssen <christiaan.janssen@nokia.com> Date: Wed, 10 Mar 2010 17:16:15 +0100 Subject: [PATCH] QmlDesigner: Adjusted color of highlight in the case it is too bright --- .../components/itemlibrary/itemlibrary.cpp | 5 ++++ .../components/itemlibrary/qml/Selector.qml | 25 ++++++++----------- .../navigator/navigatortreeview.cpp | 17 +++++++++---- .../stateseditor/stateseditorwidget.cpp | 4 +++ .../components/stateseditor/stateslist.qml | 5 +--- 5 files changed, 33 insertions(+), 23 deletions(-) diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibrary.cpp b/src/plugins/qmldesigner/components/itemlibrary/itemlibrary.cpp index e62a4962804..cd4f1823129 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/itemlibrary.cpp +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibrary.cpp @@ -141,6 +141,11 @@ ItemLibrary::ItemLibrary(QWidget *parent) : rootContext->setContextProperty(QLatin1String("itemLibraryIconWidth"), m_d->m_itemIconSize.width()); rootContext->setContextProperty(QLatin1String("itemLibraryIconHeight"), m_d->m_itemIconSize.height()); + QColor highlightColor = 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()); + m_d->m_itemsView->rootContext()->setContextProperty(QLatin1String("highlightColor"), highlightColor); + QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(m_d->m_itemsView->rootObject()); connect(rootItem, SIGNAL(itemSelected(int)), this, SLOT(showItemInfo(int))); connect(rootItem, SIGNAL(itemDragged(int)), this, SLOT(startDragAndDrop(int))); diff --git a/src/plugins/qmldesigner/components/itemlibrary/qml/Selector.qml b/src/plugins/qmldesigner/components/itemlibrary/qml/Selector.qml index badb21fa31a..6234d631c04 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/qml/Selector.qml +++ b/src/plugins/qmldesigner/components/itemlibrary/qml/Selector.qml @@ -35,11 +35,10 @@ Item { id: selector ItemsViewStyle { id: style } - SystemPalette { id:systemPalette } Rectangle { anchors.fill: parent - color: systemPalette.highlight + color: highlightColor clip:true Rectangle { width:parent.width-1 @@ -47,8 +46,8 @@ Item { y:-parent.height/2 height:parent.height gradient: Gradient { - GradientStop { position: 0.0; color: Qt.lighter(systemPalette.highlight) } - GradientStop { position: 1.0; color: systemPalette.highlight } + GradientStop { position: 0.0; color: Qt.lighter(highlightColor) } + GradientStop { position: 1.0; color: highlightColor } } } @@ -58,8 +57,8 @@ Item { y:parent.height/2 height:parent.height gradient: Gradient { - GradientStop { position: 0.0; color: systemPalette.highlight } - GradientStop { position: 1.0; color: Qt.darker(systemPalette.highlight) } + GradientStop { position: 0.0; color: highlightColor } + GradientStop { position: 1.0; color: Qt.darker(highlightColor) } } } } @@ -70,7 +69,7 @@ Item { anchors.topMargin:1 anchors.rightMargin:2 height:1 - color:Qt.lighter(systemPalette.highlight) + color:Qt.lighter(highlightColor) } Rectangle { anchors.right:parent.right @@ -79,7 +78,7 @@ Item { anchors.bottomMargin:1 anchors.leftMargin:2 height:1 - color:Qt.darker(systemPalette.highlight) + color:Qt.darker(highlightColor) } Rectangle { anchors.left:parent.left @@ -88,10 +87,9 @@ Item { anchors.leftMargin:1 anchors.bottomMargin:2 width:1 - //color:Qt.lighter(systemPalette.highlight) gradient: Gradient { - GradientStop { position: 0.0; color: Qt.lighter(systemPalette.highlight) } - GradientStop { position: 1.0; color: systemPalette.highlight } + GradientStop { position: 0.0; color: Qt.lighter(highlightColor) } + GradientStop { position: 1.0; color: highlightColor } } } Rectangle { @@ -101,10 +99,9 @@ Item { anchors.rightMargin:1 anchors.topMargin:2 width:1 - //color:Qt.darker(systemPalette.highlight) gradient: Gradient { - GradientStop { position: 0.0; color: systemPalette.highlight } - GradientStop { position: 1.0; color: Qt.darker(systemPalette.highlight) } + GradientStop { position: 0.0; color: highlightColor } + GradientStop { position: 1.0; color: Qt.darker(highlightColor) } } } } diff --git a/src/plugins/qmldesigner/components/navigator/navigatortreeview.cpp b/src/plugins/qmldesigner/components/navigator/navigatortreeview.cpp index 2763092165a..2408609145d 100644 --- a/src/plugins/qmldesigner/components/navigator/navigatortreeview.cpp +++ b/src/plugins/qmldesigner/components/navigator/navigatortreeview.cpp @@ -42,17 +42,21 @@ namespace QmlDesigner { static void drawSelectionBackground(QPainter *painter, const QStyleOption &option) { + QWidget colorReference; + painter->save(); QLinearGradient gradient; - QColor highlight = option.palette.highlight().color(); - gradient.setColorAt(0, highlight.lighter(130)); - gradient.setColorAt(1, highlight.darker(130)); + QColor highlightColor = colorReference.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()); + gradient.setColorAt(0, highlightColor.lighter(130)); + gradient.setColorAt(1, highlightColor.darker(130)); gradient.setStart(option.rect.topLeft()); gradient.setFinalStop(option.rect.bottomLeft()); painter->fillRect(option.rect, gradient); - painter->setPen(highlight.lighter()); + painter->setPen(highlightColor.lighter()); painter->drawLine(option.rect.topLeft(),option.rect.topRight()); - painter->setPen(highlight.darker()); + painter->setPen(highlightColor.darker()); painter->drawLine(option.rect.bottomLeft(),option.rect.bottomRight()); painter->restore(); } @@ -94,6 +98,8 @@ public: painter->drawRect(rect.adjusted(0, 0, -1, -1)); } painter->restore(); + } else if (element == PE_FrameFocusRect) { + // don't draw } else { QProxyStyle::drawPrimitive(element, option, painter, widget); } @@ -217,6 +223,7 @@ void IdItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, co void IdItemDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const { + Q_UNUSED(index); QLineEdit *lineEdit = static_cast<QLineEdit*>(editor); lineEdit->setGeometry(option.rect); } diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp index 284e2b88618..b4af3252236 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp @@ -165,6 +165,10 @@ StatesEditorWidget::StatesEditorWidget(QWidget *parent): m_d->listView->setResizeMode(QDeclarativeView::SizeRootObjectToView); m_d->listView->rootContext()->setContextProperty(QLatin1String("statesEditorModel"), m_d->statesEditorModel.data()); + QColor highlightColor = 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()); + m_d->listView->rootContext()->setContextProperty(QLatin1String("highlightColor"), highlightColor); // Work around ASSERT in the internal QGraphicsScene that happens when // the scene is created + items set dirty in one event loop run (BAUHAUS-459) diff --git a/src/plugins/qmldesigner/components/stateseditor/stateslist.qml b/src/plugins/qmldesigner/components/stateseditor/stateslist.qml index af892cb4916..43d1172621f 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateslist.qml +++ b/src/plugins/qmldesigner/components/stateseditor/stateslist.qml @@ -37,9 +37,6 @@ Rectangle { if (currentStateIndex<0) currentStateIndex=0; else unFocus(); } - // Colors - SystemPalette { id:systemPalette; } - Flickable { id: listView @@ -117,7 +114,7 @@ Rectangle { Rectangle { id: highlight anchors.fill: parent - color:parent.isCurrentState?systemPalette.highlight:"#4F4F4F"; + color:parent.isCurrentState?highlightColor:"#4F4F4F"; clip:true Rectangle { width:parent.width -- GitLab