forked from qt-creator/qt-creator
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: Tim Jenssen <tim.jenssen@theqtcompany.com>
This commit is contained in:
@@ -54,7 +54,11 @@ Rectangle {
|
|||||||
style: ButtonStyle {
|
style: ButtonStyle {
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
color: control.hovered ? Qt.lighter(baseColor, 1.2) : "transparent"
|
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
|
anchors.verticalCenter: stateNameField.verticalCenter
|
||||||
height: 16
|
height: 16
|
||||||
width: 16
|
width: 16
|
||||||
iconSource: "images/darkclose.png"
|
|
||||||
visible: !isBaseState
|
visible: !isBaseState
|
||||||
|
|
||||||
onClicked: root.deleteState(internalNodeId)
|
onClicked: root.deleteState(internalNodeId)
|
||||||
|
@@ -104,7 +104,6 @@ FocusScope {
|
|||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
width: Math.max(parent.height / 2 - 8, 18)
|
width: Math.max(parent.height / 2 - 8, 18)
|
||||||
height: width
|
height: width
|
||||||
iconSource: "images/plus.png"
|
|
||||||
|
|
||||||
onClicked: root.createNewState()
|
onClicked: root.createNewState()
|
||||||
|
|
||||||
@@ -113,6 +112,13 @@ FocusScope {
|
|||||||
property color buttonBaseColor: "#6f6f6f"
|
property color buttonBaseColor: "#6f6f6f"
|
||||||
color: control.hovered ? Qt.lighter(buttonBaseColor, 1.2) : buttonBaseColor
|
color: control.hovered ? Qt.lighter(buttonBaseColor, 1.2) : buttonBaseColor
|
||||||
border.width: 1
|
border.width: 1
|
||||||
|
Image {
|
||||||
|
source: "image://icons/plus"
|
||||||
|
width: 16
|
||||||
|
height: 16
|
||||||
|
anchors.centerIn: parent
|
||||||
|
smooth: false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 312 B |
Binary file not shown.
Before Width: | Height: | Size: 197 B |
@@ -0,0 +1,55 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 \
|
SOURCES += stateseditorwidget.cpp \
|
||||||
stateseditormodel.cpp \
|
stateseditormodel.cpp \
|
||||||
stateseditorview.cpp \
|
stateseditorview.cpp \
|
||||||
stateseditorimageprovider.cpp
|
stateseditorimageprovider.cpp \
|
||||||
|
stateeditorsiconprovider.cpp
|
||||||
HEADERS += stateseditorwidget.h \
|
HEADERS += stateseditorwidget.h \
|
||||||
stateseditormodel.h \
|
stateseditormodel.h \
|
||||||
stateseditorview.h \
|
stateseditorview.h \
|
||||||
stateseditorimageprovider.cpp
|
stateseditorimageprovider.h \
|
||||||
|
stateseditoriconprovider.h
|
||||||
|
@@ -0,0 +1,39 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 "stateseditormodel.h"
|
||||||
#include "stateseditorview.h"
|
#include "stateseditorview.h"
|
||||||
#include "stateseditorimageprovider.h"
|
#include "stateseditorimageprovider.h"
|
||||||
|
#include "stateseditoriconprovider.h"
|
||||||
|
|
||||||
#include <invalidqmlsourceexception.h>
|
#include <invalidqmlsourceexception.h>
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/stylehelper.h>
|
#include <utils/stylehelper.h>
|
||||||
|
|
||||||
@@ -95,9 +97,10 @@ StatesEditorWidget::StatesEditorWidget(StatesEditorView *statesEditorView, State
|
|||||||
rootContext()->setContextProperty(QStringLiteral("statesEditorModel"), statesEditorModel);
|
rootContext()->setContextProperty(QStringLiteral("statesEditorModel"), statesEditorModel);
|
||||||
rootContext()->setContextProperty(QStringLiteral("highlightColor"), Utils::StyleHelper::notTooBrightHighlightColor());
|
rootContext()->setContextProperty(QStringLiteral("highlightColor"), Utils::StyleHelper::notTooBrightHighlightColor());
|
||||||
|
|
||||||
|
|
||||||
rootContext()->setContextProperty(QLatin1String("canAddNewStates"), true);
|
rootContext()->setContextProperty(QLatin1String("canAddNewStates"), true);
|
||||||
|
|
||||||
|
engine()->addImageProvider(QLatin1String("icons"), new StatesEditorIconProvider());
|
||||||
|
|
||||||
setWindowTitle(tr("States", "Title of Editor widget"));
|
setWindowTitle(tr("States", "Title of Editor widget"));
|
||||||
|
|
||||||
// init the first load of the QML UI elements
|
// init the first load of the QML UI elements
|
||||||
|
@@ -554,6 +554,7 @@ Project {
|
|||||||
"propertyeditor/qmlmodelnodeproxy.h",
|
"propertyeditor/qmlmodelnodeproxy.h",
|
||||||
"resources/resources.qrc",
|
"resources/resources.qrc",
|
||||||
"stateseditor/stateseditorimageprovider.cpp",
|
"stateseditor/stateseditorimageprovider.cpp",
|
||||||
|
"stateseditor/stateseditoriconprovider.cpp",
|
||||||
"stateseditor/stateseditormodel.cpp",
|
"stateseditor/stateseditormodel.cpp",
|
||||||
"stateseditor/stateseditormodel.h",
|
"stateseditor/stateseditormodel.h",
|
||||||
"stateseditor/stateseditorview.cpp",
|
"stateseditor/stateseditorview.cpp",
|
||||||
|
Reference in New Issue
Block a user