Commit 268fea1c authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner.StatesEditor: Add StatesEditorIconProvider

The StatesEditorIconProvider provides the proper icons
from ICore:Icon.
This icon provider should be generally available in the future.
For High DPI support we need hardcoded image sizes.

Change-Id: I323c07501664b8038c8777998901a28554c568f0
Reviewed-by: default avatarTim Jenssen <tim.jenssen@theqtcompany.com>
parent 6015ed13
......@@ -54,7 +54,11 @@ Rectangle {
style: ButtonStyle {
background: Rectangle {
color: control.hovered ? Qt.lighter(baseColor, 1.2) : "transparent"
radius: 2
Image {
source: "image://icons/close"
height: 16
width: 16
}
}
}
......@@ -64,7 +68,6 @@ Rectangle {
anchors.verticalCenter: stateNameField.verticalCenter
height: 16
width: 16
iconSource: "images/darkclose.png"
visible: !isBaseState
onClicked: root.deleteState(internalNodeId)
......
......@@ -104,7 +104,6 @@ FocusScope {
anchors.verticalCenter: parent.verticalCenter
width: Math.max(parent.height / 2 - 8, 18)
height: width
iconSource: "images/plus.png"
onClicked: root.createNewState()
......@@ -113,6 +112,13 @@ FocusScope {
property color buttonBaseColor: "#6f6f6f"
color: control.hovered ? Qt.lighter(buttonBaseColor, 1.2) : buttonBaseColor
border.width: 1
Image {
source: "image://icons/plus"
width: 16
height: 16
anchors.centerIn: parent
smooth: false
}
}
}
}
......
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** 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 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.
**
****************************************************************************/
#include "stateseditoriconprovider.h"
#include <coreplugin/coreicons.h>
namespace QmlDesigner {
StatesEditorIconProvider::StatesEditorIconProvider()
: QQuickImageProvider(Pixmap)
{
}
QPixmap StatesEditorIconProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
{
Q_UNUSED(requestedSize)
QPixmap result;
if (id == "close")
result = Core::Icons::CLOSE_TOOLBAR.pixmap();
else if (id == "plus")
result = Core::Icons::PLUS.pixmap();
if (size)
*size = result.size();
return result;
}
} // namespace QmlDesigner
......@@ -5,8 +5,10 @@ VPATH += $$PWD
SOURCES += stateseditorwidget.cpp \
stateseditormodel.cpp \
stateseditorview.cpp \
stateseditorimageprovider.cpp
stateseditorimageprovider.cpp \
stateeditorsiconprovider.cpp
HEADERS += stateseditorwidget.h \
stateseditormodel.h \
stateseditorview.h \
stateseditorimageprovider.cpp
stateseditorimageprovider.h \
stateseditoriconprovider.h
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** 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 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.
**
****************************************************************************/
#pragma once
#include <QQuickImageProvider>
namespace QmlDesigner {
class StatesEditorIconProvider : public QQuickImageProvider
{
public:
StatesEditorIconProvider();
QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) override;
};
} // namespace QmlDesigner
......@@ -27,10 +27,12 @@
#include "stateseditormodel.h"
#include "stateseditorview.h"
#include "stateseditorimageprovider.h"
#include "stateseditoriconprovider.h"
#include <invalidqmlsourceexception.h>
#include <coreplugin/icore.h>
#include <utils/qtcassert.h>
#include <utils/stylehelper.h>
......@@ -95,9 +97,10 @@ StatesEditorWidget::StatesEditorWidget(StatesEditorView *statesEditorView, State
rootContext()->setContextProperty(QStringLiteral("statesEditorModel"), statesEditorModel);
rootContext()->setContextProperty(QStringLiteral("highlightColor"), Utils::StyleHelper::notTooBrightHighlightColor());
rootContext()->setContextProperty(QLatin1String("canAddNewStates"), true);
engine()->addImageProvider(QLatin1String("icons"), new StatesEditorIconProvider());
setWindowTitle(tr("States", "Title of Editor widget"));
// init the first load of the QML UI elements
......
......@@ -554,6 +554,7 @@ Project {
"propertyeditor/qmlmodelnodeproxy.h",
"resources/resources.qrc",
"stateseditor/stateseditorimageprovider.cpp",
"stateseditor/stateseditoriconprovider.cpp",
"stateseditor/stateseditormodel.cpp",
"stateseditor/stateseditormodel.h",
"stateseditor/stateseditorview.cpp",
......
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