summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMahmoud Badri <mahmoud.badri@qt.io>2019-03-15 16:47:39 +0200
committerMahmoud Badri <mahmoud.badri@qt.io>2019-03-18 10:27:40 +0000
commit5677201fe7c560564e16ae61452fbfe5c0fe5ea8 (patch)
tree7b2a7384ee702465df4b469970e5c8fcbcb882f7
parent311ef123e2f700ffbf9b74868f88d3c159eba57f (diff)
Show tags names in dark color when when group color is bright
Applies to the inspector and filter dialog Change-Id: I668bb905b171cb96f83f1da7bfd20c1fd672dd18 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--src/Authoring/Studio/Application/FilterVariantsDlg.cpp1
-rw-r--r--src/Authoring/Studio/Application/FilterVariantsDlg.h3
-rw-r--r--src/Authoring/Studio/Application/FilterVariantsDlg.qml6
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp1
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/InspectorControlView.h2
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/InspectorControlView.qml6
-rw-r--r--src/Authoring/Studio/Qt3DStudio.pro6
-rw-r--r--src/Authoring/Studio/Utils/QmlUtils.cpp46
-rw-r--r--src/Authoring/Studio/Utils/QmlUtils.h46
9 files changed, 111 insertions, 6 deletions
diff --git a/src/Authoring/Studio/Application/FilterVariantsDlg.cpp b/src/Authoring/Studio/Application/FilterVariantsDlg.cpp
index 67a79afe..2b7fafb8 100644
--- a/src/Authoring/Studio/Application/FilterVariantsDlg.cpp
+++ b/src/Authoring/Studio/Application/FilterVariantsDlg.cpp
@@ -49,6 +49,7 @@ void FilterVariantsDlg::initialize()
CStudioPreferences::setQmlContextProperties(rootContext());
rootContext()->setContextProperty(QStringLiteral("_view"), this);
rootContext()->setContextProperty(QStringLiteral("_model"), m_model);
+ rootContext()->setContextProperty(QStringLiteral("_utils"), &m_qmlUtils);
setSource(QUrl(QStringLiteral("qrc:/Application/FilterVariantsDlg.qml")));
}
diff --git a/src/Authoring/Studio/Application/FilterVariantsDlg.h b/src/Authoring/Studio/Application/FilterVariantsDlg.h
index ed2fd8a4..be3b6206 100644
--- a/src/Authoring/Studio/Application/FilterVariantsDlg.h
+++ b/src/Authoring/Studio/Application/FilterVariantsDlg.h
@@ -29,6 +29,8 @@
#ifndef FILTER_VARIANTS_DLG_H
#define FILTER_VARIANTS_DLG_H
+#include "QmlUtils.h"
+
#include <QtQuickWidgets/qquickwidget.h>
class FilterVariantsModel;
@@ -53,6 +55,7 @@ private:
void initialize();
+ QmlUtils m_qmlUtils;
QHash<QString, QSet<QString> > m_variantsFilter; // key: group, value: tags
FilterVariantsModel *m_model = nullptr;
QAction *m_action = nullptr;
diff --git a/src/Authoring/Studio/Application/FilterVariantsDlg.qml b/src/Authoring/Studio/Application/FilterVariantsDlg.qml
index 1f971509..d66e88a3 100644
--- a/src/Authoring/Studio/Application/FilterVariantsDlg.qml
+++ b/src/Authoring/Studio/Application/FilterVariantsDlg.qml
@@ -165,7 +165,8 @@ Rectangle {
Rectangle {
property bool toggled: tagsModel ? tagsModel.selected : false
- property string grpColor: grpModel ? grpModel.color : ""
+ property color grpColor: grpModel ? grpModel.color : ""
+ property bool isBright: grpModel ? _utils.isBright(grpModel.color) : false
width: Math.max(tLabel.width + 10, 60)
height: 25
@@ -176,7 +177,8 @@ Rectangle {
id: tLabel
anchors.centerIn: parent
text: tagsModel ? tagsModel.tag : ""
- color: toggled ? _textColor : _studioColor4
+ color: toggled ? (isBright ? _studioColor1 : _textColor)
+ : _studioColor4
}
MouseArea {
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
index eb1ece18..6ba75709 100644
--- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
@@ -250,6 +250,7 @@ void InspectorControlView::initialize()
rootContext()->setContextProperty(QStringLiteral("_resDir"), StudioUtils::resourceImageUrl());
rootContext()->setContextProperty(QStringLiteral("_tabOrderHandler"), tabOrderHandler());
rootContext()->setContextProperty(QStringLiteral("_mouseHelper"), &m_mouseHelper);
+ rootContext()->setContextProperty(QStringLiteral("_utils"), &m_qmlUtils);
m_mouseHelper.setWidget(this);
qmlRegisterUncreatableType<qt3dsdm::DataModelDataType>(
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.h b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.h
index c997721a..ace070b6 100644
--- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.h
+++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.h
@@ -36,6 +36,7 @@
#include "Qt3DSFileTools.h"
#include "TabOrderHandler.h"
#include "MouseHelper.h"
+#include "QmlUtils.h"
#include "DataInputSelectView.h"
class InspectorControlModel;
@@ -144,6 +145,7 @@ private:
QPointer<DataInputSelectView> m_dataInputChooserView;
std::vector<Q3DStudio::CFilePath> m_fileList;
MouseHelper m_mouseHelper;
+ QmlUtils m_qmlUtils;
int m_instance = 0;
int m_handle = 0;
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.qml b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.qml
index a94f5f34..02e8f4c1 100644
--- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.qml
+++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.qml
@@ -1246,7 +1246,8 @@ Rectangle {
Rectangle {
property bool toggled: tagsModel ? tagsModel.selected : false
- property string grpColor: grpModel ? grpModel.color : ""
+ property color grpColor: grpModel ? grpModel.color : ""
+ property bool isBright: grpModel ? _utils.isBright(grpColor) : false
width: Math.max(tLabel.width + 10, 60)
height: 25
@@ -1257,7 +1258,8 @@ Rectangle {
id: tLabel
anchors.centerIn: parent
text: tagsModel ? tagsModel.tag : ""
- color: toggled ? _textColor : _studioColor4
+ color: toggled ? (isBright ? _studioColor1 : _textColor)
+ : _studioColor4
}
MouseArea {
diff --git a/src/Authoring/Studio/Qt3DStudio.pro b/src/Authoring/Studio/Qt3DStudio.pro
index acdf81f8..0045d5c5 100644
--- a/src/Authoring/Studio/Qt3DStudio.pro
+++ b/src/Authoring/Studio/Qt3DStudio.pro
@@ -232,7 +232,8 @@ HEADERS += \
Palettes/Inspector/VariantsTagModel.h \
Palettes/Inspector/VariantTagDialog.h \
Application/FilterVariantsDlg.h \
- Application/FilterVariantsModel.h
+ Application/FilterVariantsModel.h \
+ Utils/QmlUtils.h
FORMS += \
MainFrm.ui \
@@ -414,7 +415,8 @@ SOURCES += \
Palettes/Inspector/VariantsTagModel.cpp \
Palettes/Inspector/VariantTagDialog.cpp \
Application/FilterVariantsDlg.cpp \
- Application/FilterVariantsModel.cpp
+ Application/FilterVariantsModel.cpp \
+ Utils/QmlUtils.cpp
RESOURCES += \
MainFrm.qrc \
diff --git a/src/Authoring/Studio/Utils/QmlUtils.cpp b/src/Authoring/Studio/Utils/QmlUtils.cpp
new file mode 100644
index 00000000..a80c6642
--- /dev/null
+++ b/src/Authoring/Studio/Utils/QmlUtils.cpp
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "QmlUtils.h"
+
+#include <QtGui/qcolor.h>
+
+QmlUtils::QmlUtils()
+{
+
+}
+
+double QmlUtils::getLuminance(const QColor &color)
+{
+ return 0.2126 * color.redF() + 0.7152 * color.greenF() + 0.0722 * color.blueF();
+}
+
+bool QmlUtils::isBright(const QColor &color)
+{
+ return getLuminance(color) > .7;
+}
diff --git a/src/Authoring/Studio/Utils/QmlUtils.h b/src/Authoring/Studio/Utils/QmlUtils.h
new file mode 100644
index 00000000..0f772fb6
--- /dev/null
+++ b/src/Authoring/Studio/Utils/QmlUtils.h
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef COLORUTILS_H
+#define COLORUTILS_H
+
+#include <QtCore/qobject.h>
+
+class QmlUtils : public QObject
+{
+ Q_OBJECT
+
+public:
+ QmlUtils();
+
+ Q_INVOKABLE double getLuminance(const QColor &color);
+ Q_INVOKABLE bool isBright(const QColor &color);
+};
+
+
+#endif // COLORUTILS_H