aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmldesigner/components/stateseditor
diff options
context:
space:
mode:
authorThomas Hartmann <Thomas.Hartmann@theqtcompany.com>2016-07-05 16:25:14 +0200
committerThomas Hartmann <Thomas.Hartmann@theqtcompany.com>2016-07-05 18:39:01 +0000
commit268fea1c5a3eff46dc1013b3d0d4d928bede2d46 (patch)
tree1933351991a9d63e00a3b67b9e4d38d0e29e1a7d /src/plugins/qmldesigner/components/stateseditor
parent6015ed133adb57b417181f81403bc507b9beb422 (diff)
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>
Diffstat (limited to 'src/plugins/qmldesigner/components/stateseditor')
-rw-r--r--src/plugins/qmldesigner/components/stateseditor/stateeditorsiconprovider.cpp55
-rw-r--r--src/plugins/qmldesigner/components/stateseditor/stateseditor.pri6
-rw-r--r--src/plugins/qmldesigner/components/stateseditor/stateseditoriconprovider.h39
-rw-r--r--src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp5
4 files changed, 102 insertions, 3 deletions
diff --git a/src/plugins/qmldesigner/components/stateseditor/stateeditorsiconprovider.cpp b/src/plugins/qmldesigner/components/stateseditor/stateeditorsiconprovider.cpp
new file mode 100644
index 00000000000..c57462409ce
--- /dev/null
+++ b/src/plugins/qmldesigner/components/stateseditor/stateeditorsiconprovider.cpp
@@ -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
diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditor.pri b/src/plugins/qmldesigner/components/stateseditor/stateseditor.pri
index 3054479edba..82308af935c 100644
--- a/src/plugins/qmldesigner/components/stateseditor/stateseditor.pri
+++ b/src/plugins/qmldesigner/components/stateseditor/stateseditor.pri
@@ -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
diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditoriconprovider.h b/src/plugins/qmldesigner/components/stateseditor/stateseditoriconprovider.h
new file mode 100644
index 00000000000..94fddeef0b9
--- /dev/null
+++ b/src/plugins/qmldesigner/components/stateseditor/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
diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp
index 52b4620d9fe..35567e22a16 100644
--- a/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp
+++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp
@@ -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