diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2018-04-19 15:26:56 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2018-04-20 08:06:50 +0000 |
commit | b16f0030f348965a81698063b7f8a0a82de5a1e6 (patch) | |
tree | 04e4acaea51d46de92693cecf6d5661f8bd46f1a /src/imports/platform/qquickplatformmenuitem.cpp | |
parent | 7a1d2e71d7aff9ab31e267e1e07280a39165640b (diff) |
Platform: make icon a grouped property
[ChangeLog][Platform][Menu] Deprecated iconName and iconSource
properties in favor of icon.name and icon.source grouped properties.
[ChangeLog][Platform][MenuItem] Deprecated iconName and iconSource
properties in favor of icon.name and icon.source grouped properties.
[ChangeLog][Platform][SystemTrayIcon] Deprecated iconName and iconSource
properties in favor of icon.name and icon.source grouped properties.
Task-number: QTBUG-67730
Change-Id: I08bbb2bb5ed2aaae02f9264c63fb6cfa04240a74
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/imports/platform/qquickplatformmenuitem.cpp')
-rw-r--r-- | src/imports/platform/qquickplatformmenuitem.cpp | 82 |
1 files changed, 47 insertions, 35 deletions
diff --git a/src/imports/platform/qquickplatformmenuitem.cpp b/src/imports/platform/qquickplatformmenuitem.cpp index bc6d97e1..62a75d60 100644 --- a/src/imports/platform/qquickplatformmenuitem.cpp +++ b/src/imports/platform/qquickplatformmenuitem.cpp @@ -443,63 +443,41 @@ void QQuickPlatformMenuItem::setText(const QString &text) /*! \qmlproperty url Qt.labs.platform::MenuItem::iconSource - - This property holds the url of the menu item's icon. - - \code - MenuItem { - iconName: "edit-undo" - iconSource: "qrc:/images/undo.png" - } - \endcode - - \sa iconName + \deprecated Use icon.source instead */ QUrl QQuickPlatformMenuItem::iconSource() const { - if (!m_iconLoader) - return QUrl(); - - return m_iconLoader->iconSource(); + return icon().source(); } void QQuickPlatformMenuItem::setIconSource(const QUrl& source) { - if (source == iconSource()) + QQuickPlatformIcon newIcon = icon(); + if (source == newIcon.source()) return; - iconLoader()->setIconSource(source); + newIcon.setSource(source); + iconLoader()->setIcon(newIcon); emit iconSourceChanged(); } /*! \qmlproperty string Qt.labs.platform::MenuItem::iconName - - This property holds the theme name of the menu item's icon. - - \code - MenuItem { - iconName: "edit-undo" - iconSource: "qrc:/images/undo.png" - } - \endcode - - \sa iconSource, QIcon::fromTheme() + \deprecated Use icon.name instead */ QString QQuickPlatformMenuItem::iconName() const { - if (!m_iconLoader) - return QString(); - - return m_iconLoader->iconName(); + return icon().name(); } void QQuickPlatformMenuItem::setIconName(const QString& name) { - if (name == iconName()) + QQuickPlatformIcon newIcon = icon(); + if (name == newIcon.name()) return; - iconLoader()->setIconName(name); + newIcon.setName(name); + iconLoader()->setIcon(newIcon); emit iconNameChanged(); } @@ -560,6 +538,40 @@ void QQuickPlatformMenuItem::setFont(const QFont& font) } /*! + \since Qt.labs.platform 1.1 (Qt 5.12) + \qmlpropertygroup Qt.labs.platform::MenuItem::icon + \qmlproperty url Qt.labs.platform::MenuItem::icon.source + \qmlproperty string Qt.labs.platform::MenuItem::icon.name + + This property holds the menu item's icon. + + \code + MenuItem { + icon.name: "edit-undo" + icon.source: "qrc:/images/undo.png" + } + \endcode + + \sa QIcon::fromTheme() +*/ +QQuickPlatformIcon QQuickPlatformMenuItem::icon() const +{ + if (!m_iconLoader) + return QQuickPlatformIcon(); + + return m_iconLoader->icon(); +} + +void QQuickPlatformMenuItem::setIcon(const QQuickPlatformIcon &icon) +{ + if (iconLoader()->icon() == icon) + return; + + iconLoader()->setIcon(icon); + emit iconChanged(); +} + +/*! \qmlmethod void Qt.labs.platform::MenuItem::toggle() Toggles the \l checked state to its opposite state. @@ -604,7 +616,7 @@ void QQuickPlatformMenuItem::updateIcon() if (!m_handle || !m_iconLoader) return; - m_handle->setIcon(m_iconLoader->icon()); + m_handle->setIcon(m_iconLoader->toQIcon()); sync(); } |