forked from qt-creator/qt-creator
Theming: Use QQmlPropertyHash for passing theme to QML
This makes the mapping of theme values to QML automatic. Change-Id: I4442ef454dc3a7dde1bd6b068b03ff890db3e49f Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -61,60 +61,60 @@ Button {
|
|||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
antialiasing: true
|
antialiasing: true
|
||||||
radius: (creatorTheme.widgetStyle === 'flat') ? 0 : 3
|
radius: (creatorTheme.WidgetStyle === 'StyleFlat') ? 0 : 3
|
||||||
|
|
||||||
visible: !(button.pressed || button.checked)
|
visible: !(button.pressed || button.checked)
|
||||||
|
|
||||||
gradient: Gradient {
|
gradient: Gradient {
|
||||||
GradientStop {
|
GradientStop {
|
||||||
position: 0
|
position: 0
|
||||||
color: (theme==='dark') ? "#232323" : "#f9f9f9"
|
color: (creatorTheme.WidgetStyle === 'StyleFlat') ? "#232323" : "#f9f9f9"
|
||||||
}
|
}
|
||||||
|
|
||||||
GradientStop {
|
GradientStop {
|
||||||
position: 0.49
|
position: 0.49
|
||||||
color: (theme === 'dark') ? "#232323" : "#f9f9f9"
|
color: (creatorTheme.WidgetStyle === 'StyleFlat') ? "#232323" : "#f9f9f9"
|
||||||
}
|
}
|
||||||
|
|
||||||
GradientStop {
|
GradientStop {
|
||||||
position: 0.5
|
position: 0.5
|
||||||
color: (theme === 'dark') ? "#232323" : "#eeeeee"
|
color: (creatorTheme.WidgetStyle === 'StyleFlat') ? "#232323" : "#eeeeee"
|
||||||
}
|
}
|
||||||
|
|
||||||
GradientStop {
|
GradientStop {
|
||||||
position: 1
|
position: 1
|
||||||
color: (theme === 'dark') ? "#232323" : "#eeeeee"
|
color: (creatorTheme.WidgetStyle === 'StyleFlat') ? "#232323" : "#eeeeee"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
border.color: creatorTheme.button_BorderColor
|
border.color: creatorTheme.Welcome_Button_BorderColor
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
antialiasing: true
|
antialiasing: true
|
||||||
radius: (creatorTheme.widgetStyle === 'flat') ? 0 : 3
|
radius: (creatorTheme.WidgetStyle === 'StyleFlat') ? 0 : 3
|
||||||
|
|
||||||
visible: button.pressed || button.checked
|
visible: button.pressed || button.checked
|
||||||
|
|
||||||
gradient: Gradient {
|
gradient: Gradient {
|
||||||
GradientStop {
|
GradientStop {
|
||||||
position: 0.00;
|
position: 0.00;
|
||||||
color: (theme === "dark") ? "#151515" : "#4c4c4c"
|
color: (creatorTheme.WidgetStyle === 'StyleFlat') ? "#151515" : "#4c4c4c"
|
||||||
}
|
}
|
||||||
GradientStop {
|
GradientStop {
|
||||||
position: 0.49;
|
position: 0.49;
|
||||||
color: (theme === "dark") ? "#151515" : "#4c4c4c"
|
color: (creatorTheme.WidgetStyle === 'StyleFlat') ? "#151515" : "#4c4c4c"
|
||||||
}
|
}
|
||||||
GradientStop {
|
GradientStop {
|
||||||
position: 0.50;
|
position: 0.50;
|
||||||
color: (theme === "dark") ? "#151515" : "#424242"
|
color: (creatorTheme.WidgetStyle === 'StyleFlat') ? "#151515" : "#424242"
|
||||||
}
|
}
|
||||||
GradientStop {
|
GradientStop {
|
||||||
position: 1.00;
|
position: 1.00;
|
||||||
color: (theme === "dark") ? "#151515" : "#424242"
|
color: (creatorTheme.WidgetStyle === 'StyleFlat') ? "#151515" : "#424242"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
border.color: creatorTheme.button_BorderColor
|
border.color: creatorTheme.Welcome_Button_BorderColor
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,8 +124,8 @@ Button {
|
|||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
text: button.text
|
text: button.text
|
||||||
color: button.pressed || button.checked
|
color: button.pressed || button.checked
|
||||||
? creatorTheme.button_TextColorPressed
|
? creatorTheme.Welcome_Button_TextColorPressed
|
||||||
: creatorTheme.button_TextColorNormal
|
: creatorTheme.Welcome_Button_TextColorNormal
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
font.bold: false
|
font.bold: false
|
||||||
smooth: true
|
smooth: true
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ Rectangle {
|
|||||||
id: delegate
|
id: delegate
|
||||||
height: 240
|
height: 240
|
||||||
width: 216
|
width: 216
|
||||||
color: creatorTheme.backgroundColorNormal
|
color: creatorTheme.Welcome_BackgroundColorNormal
|
||||||
|
|
||||||
property alias caption: captionItem.text
|
property alias caption: captionItem.text
|
||||||
property alias imageSource: imageItem.source
|
property alias imageSource: imageItem.source
|
||||||
@@ -107,7 +107,7 @@ Rectangle {
|
|||||||
y: 161
|
y: 161
|
||||||
width: 200
|
width: 200
|
||||||
height: 69
|
height: 69
|
||||||
color: creatorTheme.backgroundColorNormal
|
color: creatorTheme.Welcome_BackgroundColorNormal
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
@@ -117,7 +117,7 @@ Rectangle {
|
|||||||
id: captionItem
|
id: captionItem
|
||||||
x: 16
|
x: 16
|
||||||
y: 170
|
y: 170
|
||||||
color: creatorTheme.caption_TextColorNormal
|
color: creatorTheme.Welcome_Caption_TextColorNormal
|
||||||
text: qsTr("2D PAINTING EXAMPLE long description")
|
text: qsTr("2D PAINTING EXAMPLE long description")
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
@@ -164,7 +164,7 @@ Rectangle {
|
|||||||
x: 16
|
x: 16
|
||||||
y: 198
|
y: 198
|
||||||
text: qsTr("Tags:")
|
text: qsTr("Tags:")
|
||||||
color: creatorTheme.textColorNormal
|
color: creatorTheme.Welcome_TextColorNormal
|
||||||
smooth: true
|
smooth: true
|
||||||
font.italic: false
|
font.italic: false
|
||||||
font.pixelSize: 11
|
font.pixelSize: 11
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ Row {
|
|||||||
LinkedText {
|
LinkedText {
|
||||||
text: title
|
text: title
|
||||||
font.pixelSize: 11
|
font.pixelSize: 11
|
||||||
color: creatorTheme.textColorNormal // 'Qt Account' .. 'User Guide' on lower left
|
color: creatorTheme.Welcome_TextColorNormal // 'Qt Account' .. 'User Guide' on lower left
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (openUrl)
|
if (openUrl)
|
||||||
gettingStarted.openUrl(openUrl);
|
gettingStarted.openUrl(openUrl);
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ import QtQuick 2.1
|
|||||||
NativeText {
|
NativeText {
|
||||||
id: root
|
id: root
|
||||||
height: 16
|
height: 16
|
||||||
color: active ? creatorTheme.link_TextColorActive
|
color: active ? creatorTheme.Welcome_Link_TextColorActive
|
||||||
: creatorTheme.link_TextColorNormal
|
: creatorTheme.Welcome_Link_TextColorNormal
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
|
||||||
font: fonts.linkFont
|
font: fonts.linkFont
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ Item {
|
|||||||
|
|
||||||
Rectangle { // background shown on hover over project item
|
Rectangle { // background shown on hover over project item
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
color: creatorTheme.projectItem_BackgroundColorHover
|
color: creatorTheme.Welcome_ProjectItem_BackgroundColorHover
|
||||||
visible: mouseArea.containsMouse
|
visible: mouseArea.containsMouse
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ Item {
|
|||||||
NativeText {
|
NativeText {
|
||||||
id: pathText
|
id: pathText
|
||||||
height: 20
|
height: 20
|
||||||
color: creatorTheme.projectItem_TextColorFilepath
|
color: creatorTheme.Welcome_ProjectItem_TextColorFilepath
|
||||||
font: fonts.smallPath
|
font: fonts.smallPath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import QtQuick.Controls 1.0
|
|||||||
Rectangle {
|
Rectangle {
|
||||||
id: projectList
|
id: projectList
|
||||||
height: column.height + 200
|
height: column.height + 200
|
||||||
color: creatorTheme.backgroundColorNormal
|
color: creatorTheme.Welcome_BackgroundColorNormal
|
||||||
|
|
||||||
property alias model: repeater.model
|
property alias model: repeater.model
|
||||||
// Behavior on verticalScrollBar.opacity {
|
// Behavior on verticalScrollBar.opacity {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ Rectangle {
|
|||||||
|
|
||||||
width: 930
|
width: 930
|
||||||
height: 27
|
height: 27
|
||||||
color: creatorTheme.backgroundColorNormal
|
color: creatorTheme.Welcome_BackgroundColorNormal
|
||||||
radius: 6
|
radius: 6
|
||||||
border.color: "#cccccc" // FIXME: make themable
|
border.color: "#cccccc" // FIXME: make themable
|
||||||
|
|
||||||
@@ -56,8 +56,8 @@ Rectangle {
|
|||||||
font.pixelSize: 14
|
font.pixelSize: 14
|
||||||
placeholderText: qsTr("Search...")
|
placeholderText: qsTr("Search...")
|
||||||
style: TextFieldStyle {
|
style: TextFieldStyle {
|
||||||
placeholderTextColor: creatorTheme.textColorNormal
|
placeholderTextColor: creatorTheme.Welcome_TextColorNormal
|
||||||
textColor: creatorTheme.textColorNormal
|
textColor: creatorTheme.Welcome_TextColorNormal
|
||||||
background: Item {
|
background: Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ Item {
|
|||||||
Rectangle {
|
Rectangle {
|
||||||
z: -4
|
z: -4
|
||||||
// background of session item
|
// background of session item
|
||||||
color: creatorTheme.sessionItem_BackgroundColorHover
|
color: creatorTheme.Welcome_SessionItem_BackgroundColorHover
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
visible: iArea.containsMouse || text.hovered
|
visible: iArea.containsMouse || text.hovered
|
||||||
anchors.topMargin: 1
|
anchors.topMargin: 1
|
||||||
@@ -116,7 +116,7 @@ Item {
|
|||||||
NativeText {
|
NativeText {
|
||||||
text: projectsName[index]
|
text: projectsName[index]
|
||||||
font: fonts.boldDescription
|
font: fonts.boldDescription
|
||||||
color: creatorTheme.textColorNormal
|
color: creatorTheme.Welcome_TextColorNormal
|
||||||
}
|
}
|
||||||
NativeText {
|
NativeText {
|
||||||
x: 4
|
x: 4
|
||||||
@@ -141,7 +141,7 @@ Item {
|
|||||||
maximumLineCount: 2
|
maximumLineCount: 2
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
height: lineCount == 2 ? font.pixelSize * 2 + 4 : font.pixelSize + 2
|
height: lineCount == 2 ? font.pixelSize * 2 + 4 : font.pixelSize + 2
|
||||||
color: creatorTheme.projectItem_TextColorFilepath
|
color: creatorTheme.Welcome_ProjectItem_TextColorFilepath
|
||||||
width: delegate.ListView.view.width - 48
|
width: delegate.ListView.view.width - 48
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@@ -224,8 +224,8 @@ Item {
|
|||||||
id: collapseButton
|
id: collapseButton
|
||||||
visible: text.hovered || iArea.containsMouse || delegate.expanded
|
visible: text.hovered || iArea.containsMouse || delegate.expanded
|
||||||
|
|
||||||
property color color: iArea.containsMouse ? creatorTheme.sessionItemExpanded_BackgroundColorHover
|
property color color: iArea.containsMouse ? creatorTheme.Welcome_SessionItemExpanded_BackgroundColorHover
|
||||||
: creatorTheme.sessionItemExpanded_BackgroundColorNormal
|
: creatorTheme.Welcome_SessionItemExpanded_BackgroundColorNormal
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
Image {
|
Image {
|
||||||
@@ -241,7 +241,7 @@ Item {
|
|||||||
Rectangle {
|
Rectangle {
|
||||||
color: collapseButton.color
|
color: collapseButton.color
|
||||||
z: -1
|
z: -1
|
||||||
radius: creatorTheme.widgetStyle === 'flat' ? 0 : 6
|
radius: creatorTheme.WidgetStyle === 'StyleFlat' ? 0 : 6
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.topMargin: 1
|
anchors.topMargin: 1
|
||||||
anchors.bottomMargin: 1
|
anchors.bottomMargin: 1
|
||||||
|
|||||||
@@ -59,13 +59,13 @@ ColumnLayout {
|
|||||||
Component {
|
Component {
|
||||||
id: flatBackground
|
id: flatBackground
|
||||||
Rectangle {
|
Rectangle {
|
||||||
color: creatorTheme.sideBar_BackgroundColor
|
color: creatorTheme.Welcome_SideBar_BackgroundColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loader {
|
Loader {
|
||||||
id: topLeftLoader
|
id: topLeftLoader
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
sourceComponent: creatorTheme.widgetStyle === 'flat' ? flatBackground : imageBackground;
|
sourceComponent: creatorTheme.WidgetStyle === 'StyleFlat' ? flatBackground : imageBackground;
|
||||||
}
|
}
|
||||||
|
|
||||||
Tabs {
|
Tabs {
|
||||||
@@ -78,7 +78,8 @@ ColumnLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
color: creatorTheme.widgetStyle === 'flat' ? creatorTheme.sideBar_BackgroundColor : creatorTheme.dividerColor
|
color: creatorTheme.WidgetStyle === 'StyleFlat' ?
|
||||||
|
creatorTheme.Welcome_SideBar_BackgroundColor : creatorTheme.Welcome_DividerColor
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
@@ -87,7 +88,8 @@ ColumnLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
color: creatorTheme.widgetStyle === 'flat' ? creatorTheme.sideBar_BackgroundColor : creatorTheme.dividerColor
|
color: creatorTheme.WidgetStyle === 'StyleFlat' ?
|
||||||
|
creatorTheme.Welcome_SideBar_BackgroundColor : creatorTheme.Welcome_DividerColor
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
@@ -97,7 +99,8 @@ ColumnLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
color: creatorTheme.widgetStyle === 'flat' ? creatorTheme.sideBar_BackgroundColor : creatorTheme.dividerColor
|
color: creatorTheme.WidgetStyle === 'StyleFlat' ?
|
||||||
|
creatorTheme.Welcome_SideBar_BackgroundColor : creatorTheme.Welcome_DividerColor
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
@@ -108,7 +111,7 @@ ColumnLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
color: creatorTheme.sideBar_BackgroundColor
|
color: creatorTheme.Welcome_SideBar_BackgroundColor
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredWidth: innerColumn.width + 20
|
Layout.preferredWidth: innerColumn.width + 20
|
||||||
@@ -129,7 +132,7 @@ ColumnLayout {
|
|||||||
|
|
||||||
NativeText {
|
NativeText {
|
||||||
text: qsTr("New to Qt?")
|
text: qsTr("New to Qt?")
|
||||||
color: creatorTheme.textColorNormal
|
color: creatorTheme.Welcome_TextColorNormal
|
||||||
font.pixelSize: 18
|
font.pixelSize: 18
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,7 +142,7 @@ ColumnLayout {
|
|||||||
Layout.preferredWidth: innerColumn.width
|
Layout.preferredWidth: innerColumn.width
|
||||||
|
|
||||||
text: qsTr("Learn how to develop your own applications and explore Qt Creator.")
|
text: qsTr("Learn how to develop your own applications and explore Qt Creator.")
|
||||||
color: creatorTheme.textColorNormal
|
color: creatorTheme.Welcome_TextColorNormal
|
||||||
font.pixelSize: 12
|
font.pixelSize: 12
|
||||||
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,6 +123,32 @@ void Theme::setName(const QString &name)
|
|||||||
d->name = name;
|
d->name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariantHash Theme::values() const
|
||||||
|
{
|
||||||
|
QVariantHash result;
|
||||||
|
const QMetaObject &m = *metaObject();
|
||||||
|
{
|
||||||
|
const QMetaEnum e = m.enumerator(m.indexOfEnumerator("ColorRole"));
|
||||||
|
for (int i = 0, total = e.keyCount(); i < total; ++i) {
|
||||||
|
const QString key = QLatin1String(e.key(i));
|
||||||
|
const QPair<QColor, QString> &var = d->colors.at(i);
|
||||||
|
result.insert(key, var.first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const QMetaEnum e = m.enumerator(m.indexOfEnumerator("Flag"));
|
||||||
|
for (int i = 0, total = e.keyCount(); i < total; ++i) {
|
||||||
|
const QString key = QLatin1String(e.key(i));
|
||||||
|
result.insert(key, flag(static_cast<Theme::Flag>(i)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const QMetaEnum e = m.enumerator(m.indexOfEnumerator("WidgetStyle"));
|
||||||
|
result.insert(QLatin1String("WidgetStyle"), QLatin1String(e.valueToKey(widgetStyle())));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
static QColor readColor(const QString &color)
|
static QColor readColor(const QString &color)
|
||||||
{
|
{
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
|
|||||||
@@ -201,6 +201,8 @@ public:
|
|||||||
QString fileName() const;
|
QString fileName() const;
|
||||||
void setName(const QString &name);
|
void setName(const QString &name);
|
||||||
|
|
||||||
|
QVariantHash values() const;
|
||||||
|
|
||||||
void writeSettings(const QString &filename) const;
|
void writeSettings(const QString &filename) const;
|
||||||
void readSettings(QSettings &settings);
|
void readSettings(QSettings &settings);
|
||||||
ThemePrivate *d;
|
ThemePrivate *d;
|
||||||
|
|||||||
@@ -1,88 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2014 Thorben Kroeger <thorbenkroeger@gmail.com>.
|
|
||||||
** Contact: http://www.qt-project.org/legal
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** 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 Digia. For licensing terms and
|
|
||||||
** conditions see http://www.qt.io/licensing. For further information
|
|
||||||
** use the contact form at http://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
||||||
** General Public License version 2.1 or version 3 as published by the Free
|
|
||||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
||||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
||||||
** following information to ensure the GNU Lesser General Public License
|
|
||||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
||||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
||||||
**
|
|
||||||
** In addition, as a special exception, Digia gives you certain additional
|
|
||||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
|
||||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "welcometheme.h"
|
|
||||||
|
|
||||||
#include "theme.h"
|
|
||||||
|
|
||||||
using namespace Utils;
|
|
||||||
|
|
||||||
#define IMPL_COLOR_PROPERTY(propName, enumName) \
|
|
||||||
QColor WelcomeTheme::propName () const { \
|
|
||||||
return creatorTheme()->color(Theme::enumName); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define GRADIENT(x) \
|
|
||||||
QGradient grad; \
|
|
||||||
grad.setStops(creatorTheme()->gradient(Theme::x)); \
|
|
||||||
return grad;
|
|
||||||
|
|
||||||
WelcomeTheme::WelcomeTheme(QObject *parent)
|
|
||||||
: QObject(parent)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QString WelcomeTheme::widgetStyle() const
|
|
||||||
{
|
|
||||||
switch (creatorTheme()->widgetStyle()) {
|
|
||||||
case Theme::StyleDefault:
|
|
||||||
return QLatin1String("default");
|
|
||||||
case Theme::StyleFlat:
|
|
||||||
return QLatin1String("flat");
|
|
||||||
}
|
|
||||||
return QString::null;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WelcomeTheme::notifyThemeChanged()
|
|
||||||
{
|
|
||||||
emit themeChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
IMPL_COLOR_PROPERTY(textColorNormal , Welcome_TextColorNormal )
|
|
||||||
IMPL_COLOR_PROPERTY(textColorHeading , Welcome_TextColorHeading )
|
|
||||||
IMPL_COLOR_PROPERTY(backgroundColorNormal , Welcome_BackgroundColorNormal )
|
|
||||||
IMPL_COLOR_PROPERTY(dividerColor , Welcome_DividerColor )
|
|
||||||
IMPL_COLOR_PROPERTY(button_BorderColor , Welcome_Button_BorderColor )
|
|
||||||
IMPL_COLOR_PROPERTY(button_TextColorNormal , Welcome_Button_TextColorNormal )
|
|
||||||
IMPL_COLOR_PROPERTY(button_TextColorPressed, Welcome_Button_TextColorPressed)
|
|
||||||
IMPL_COLOR_PROPERTY(link_TextColorNormal , Welcome_Link_TextColorNormal )
|
|
||||||
IMPL_COLOR_PROPERTY(link_TextColorActive , Welcome_Link_TextColorActive )
|
|
||||||
IMPL_COLOR_PROPERTY(link_BackgroundColor , Welcome_Link_BackgroundColor )
|
|
||||||
IMPL_COLOR_PROPERTY(caption_TextColorNormal, Welcome_Caption_TextColorNormal)
|
|
||||||
IMPL_COLOR_PROPERTY(sideBar_BackgroundColor, Welcome_SideBar_BackgroundColor)
|
|
||||||
IMPL_COLOR_PROPERTY(projectItem_TextColorFilepath, Welcome_ProjectItem_TextColorFilepath)
|
|
||||||
IMPL_COLOR_PROPERTY(projectItem_BackgroundColorHover, Welcome_ProjectItem_BackgroundColorHover)
|
|
||||||
IMPL_COLOR_PROPERTY(sessionItem_BackgroundColorNormal, Welcome_SessionItem_BackgroundColorNormal)
|
|
||||||
IMPL_COLOR_PROPERTY(sessionItemExpanded_BackgroundColorHover, Welcome_SessionItemExpanded_BackgroundColorHover)
|
|
||||||
IMPL_COLOR_PROPERTY(sessionItemExpanded_BackgroundColorNormal, Welcome_SessionItemExpanded_BackgroundColorNormal)
|
|
||||||
IMPL_COLOR_PROPERTY(sessionItem_BackgroundColorHover, Welcome_SessionItem_BackgroundColorHover)
|
|
||||||
|
|
||||||
QGradient WelcomeTheme::button_GradientNormal () const { GRADIENT(Welcome_Button_GradientNormal); }
|
|
||||||
QGradient WelcomeTheme::button_GradientPressed () const { GRADIENT(Welcome_Button_GradientPressed); }
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2014 Thorben Kroeger <thorbenkroeger@gmail.com>.
|
|
||||||
** Contact: http://www.qt-project.org/legal
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** 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 Digia. For licensing terms and
|
|
||||||
** conditions see http://www.qt.io/licensing. For further information
|
|
||||||
** use the contact form at http://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
||||||
** General Public License version 2.1 or version 3 as published by the Free
|
|
||||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
||||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
||||||
** following information to ensure the GNU Lesser General Public License
|
|
||||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
||||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
||||||
**
|
|
||||||
** In addition, as a special exception, Digia gives you certain additional
|
|
||||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
|
||||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef WELCOMETHEME_H
|
|
||||||
#define WELCOMETHEME_H
|
|
||||||
|
|
||||||
#include "../utils_global.h"
|
|
||||||
|
|
||||||
#include <QStyle>
|
|
||||||
|
|
||||||
#define DECLARE_COLOR_PROPERTY(propName) \
|
|
||||||
Q_PROPERTY(QColor propName READ propName NOTIFY themeChanged) \
|
|
||||||
QColor propName () const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Expose theme properties to QML (for welcomeplugin)
|
|
||||||
*/
|
|
||||||
class QTCREATOR_UTILS_EXPORT WelcomeTheme : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
WelcomeTheme(QObject *parent);
|
|
||||||
|
|
||||||
DECLARE_COLOR_PROPERTY(textColorNormal)
|
|
||||||
DECLARE_COLOR_PROPERTY(textColorHeading)
|
|
||||||
DECLARE_COLOR_PROPERTY(backgroundColorNormal)
|
|
||||||
DECLARE_COLOR_PROPERTY(dividerColor)
|
|
||||||
DECLARE_COLOR_PROPERTY(button_BorderColor)
|
|
||||||
DECLARE_COLOR_PROPERTY(button_TextColorNormal)
|
|
||||||
DECLARE_COLOR_PROPERTY(button_TextColorPressed)
|
|
||||||
DECLARE_COLOR_PROPERTY(link_TextColorNormal)
|
|
||||||
DECLARE_COLOR_PROPERTY(link_TextColorActive)
|
|
||||||
DECLARE_COLOR_PROPERTY(link_BackgroundColor)
|
|
||||||
DECLARE_COLOR_PROPERTY(sideBar_BackgroundColor)
|
|
||||||
DECLARE_COLOR_PROPERTY(caption_TextColorNormal)
|
|
||||||
DECLARE_COLOR_PROPERTY(projectItem_TextColorFilepath)
|
|
||||||
DECLARE_COLOR_PROPERTY(projectItem_BackgroundColorHover)
|
|
||||||
DECLARE_COLOR_PROPERTY(sessionItem_BackgroundColorNormal)
|
|
||||||
DECLARE_COLOR_PROPERTY(sessionItemExpanded_BackgroundColorNormal)
|
|
||||||
DECLARE_COLOR_PROPERTY(sessionItemExpanded_BackgroundColorHover)
|
|
||||||
DECLARE_COLOR_PROPERTY(sessionItem_BackgroundColorHover)
|
|
||||||
|
|
||||||
Q_PROPERTY(QGradient button_GradientNormal READ button_GradientNormal NOTIFY themeChanged)
|
|
||||||
Q_PROPERTY(QGradient button_GradientPressed READ button_GradientPressed NOTIFY themeChanged)
|
|
||||||
|
|
||||||
Q_PROPERTY(QString widgetStyle READ widgetStyle CONSTANT)
|
|
||||||
|
|
||||||
QString widgetStyle() const;
|
|
||||||
|
|
||||||
QGradient button_GradientNormal () const;
|
|
||||||
QGradient button_GradientPressed () const;
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void notifyThemeChanged();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void themeChanged();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // WELCOMETHEME_H
|
|
||||||
@@ -93,8 +93,7 @@ SOURCES += $$PWD/environment.cpp \
|
|||||||
$$PWD/treeviewcombobox.cpp \
|
$$PWD/treeviewcombobox.cpp \
|
||||||
$$PWD/proxycredentialsdialog.cpp \
|
$$PWD/proxycredentialsdialog.cpp \
|
||||||
$$PWD/macroexpander.cpp \
|
$$PWD/macroexpander.cpp \
|
||||||
$$PWD/theme/theme.cpp \
|
$$PWD/theme/theme.cpp
|
||||||
$$PWD/theme/welcometheme.cpp
|
|
||||||
|
|
||||||
win32:SOURCES += $$PWD/consoleprocess_win.cpp
|
win32:SOURCES += $$PWD/consoleprocess_win.cpp
|
||||||
else:SOURCES += $$PWD/consoleprocess_unix.cpp
|
else:SOURCES += $$PWD/consoleprocess_unix.cpp
|
||||||
@@ -193,8 +192,7 @@ HEADERS += \
|
|||||||
$$PWD/proxycredentialsdialog.h \
|
$$PWD/proxycredentialsdialog.h \
|
||||||
$$PWD/macroexpander.h \
|
$$PWD/macroexpander.h \
|
||||||
$$PWD/theme/theme.h \
|
$$PWD/theme/theme.h \
|
||||||
$$PWD/theme/theme_p.h \
|
$$PWD/theme/theme_p.h
|
||||||
$$PWD/theme/welcometheme.h
|
|
||||||
|
|
||||||
FORMS += $$PWD/filewizardpage.ui \
|
FORMS += $$PWD/filewizardpage.ui \
|
||||||
$$PWD/projectintropage.ui \
|
$$PWD/projectintropage.ui \
|
||||||
|
|||||||
@@ -211,8 +211,6 @@ QtcLibrary {
|
|||||||
"theme.cpp",
|
"theme.cpp",
|
||||||
"theme.h",
|
"theme.h",
|
||||||
"theme_p.h",
|
"theme_p.h",
|
||||||
"welcometheme.cpp",
|
|
||||||
"welcometheme.h",
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,12 +45,12 @@
|
|||||||
#include <utils/iwelcomepage.h>
|
#include <utils/iwelcomepage.h>
|
||||||
|
|
||||||
#include <utils/theme/theme.h>
|
#include <utils/theme/theme.h>
|
||||||
#include <utils/theme/welcometheme.h>
|
|
||||||
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QQmlPropertyMap>
|
||||||
|
|
||||||
#ifdef USE_QUICK_WIDGET
|
#ifdef USE_QUICK_WIDGET
|
||||||
#include <QtQuickWidgets/QQuickWidget>
|
#include <QtQuickWidgets/QQuickWidget>
|
||||||
@@ -111,13 +111,12 @@ private:
|
|||||||
QuickContainer *m_welcomePage;
|
QuickContainer *m_welcomePage;
|
||||||
QList<QObject*> m_pluginList;
|
QList<QObject*> m_pluginList;
|
||||||
int m_activePlugin;
|
int m_activePlugin;
|
||||||
WelcomeTheme *m_welcomeTheme;
|
QQmlPropertyMap m_themeProperties;
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- WelcomeMode
|
// --- WelcomeMode
|
||||||
WelcomeMode::WelcomeMode() :
|
WelcomeMode::WelcomeMode()
|
||||||
m_activePlugin(0),
|
: m_activePlugin(0)
|
||||||
m_welcomeTheme(new WelcomeTheme(this))
|
|
||||||
{
|
{
|
||||||
setDisplayName(tr("Welcome"));
|
setDisplayName(tr("Welcome"));
|
||||||
setIcon(QIcon(QLatin1String(":/welcome/images/mode_welcome.png")));
|
setIcon(QIcon(QLatin1String(":/welcome/images/mode_welcome.png")));
|
||||||
@@ -163,7 +162,10 @@ WelcomeMode::WelcomeMode() :
|
|||||||
void WelcomeMode::onThemeChanged()
|
void WelcomeMode::onThemeChanged()
|
||||||
{
|
{
|
||||||
m_welcomePage->setColor(creatorTheme()->color(Theme::BackgroundColorNormal));
|
m_welcomePage->setColor(creatorTheme()->color(Theme::BackgroundColorNormal));
|
||||||
m_welcomeTheme->notifyThemeChanged();
|
const QVariantHash creatorTheme = Utils::creatorTheme()->values();
|
||||||
|
QVariantHash::const_iterator it;
|
||||||
|
for (it = creatorTheme.constBegin(); it != creatorTheme.constEnd(); ++it)
|
||||||
|
m_themeProperties.insert(it.key(), it.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
WelcomeMode::~WelcomeMode()
|
WelcomeMode::~WelcomeMode()
|
||||||
@@ -255,14 +257,9 @@ void WelcomeMode::initPlugins()
|
|||||||
|
|
||||||
ctx->setContextProperty(QLatin1String("pagesModel"), QVariant::fromValue(m_pluginList));
|
ctx->setContextProperty(QLatin1String("pagesModel"), QVariant::fromValue(m_pluginList));
|
||||||
|
|
||||||
|
onThemeChanged();
|
||||||
connect(creatorTheme(), &Theme::changed, this, &WelcomeMode::onThemeChanged);
|
connect(creatorTheme(), &Theme::changed, this, &WelcomeMode::onThemeChanged);
|
||||||
ctx->setContextProperty(QLatin1String("creatorTheme"), m_welcomeTheme);
|
ctx->setContextProperty(QLatin1String("creatorTheme"), &m_themeProperties);
|
||||||
|
|
||||||
// FIXME: pass theme class to QML somehow
|
|
||||||
if (creatorTheme()->widgetStyle() == Theme::StyleFlat)
|
|
||||||
ctx->setContextProperty(QLatin1String("theme"), QLatin1String("dark"));
|
|
||||||
else
|
|
||||||
ctx->setContextProperty(QLatin1String("theme"), QLatin1String("default"));
|
|
||||||
|
|
||||||
QString path = resourcePath() + QLatin1String("/welcomescreen/welcomescreen.qml");
|
QString path = resourcePath() + QLatin1String("/welcomescreen/welcomescreen.qml");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user