Convert QPA menus to use QIcon, and enable icons.
Icon support was disabled in QPA menus, now QIcon is in QtGui, convert the QPA interface, enable setting the icon in QMenu, and make the Cocoa implementation use it. (And fix a ref-counting leak if an icon is actually set) Change-Id: Ica203bf6826b79d8beee58f39febc851b9633a66 Reviewed-by: Christoph Schleifenbaum <christoph.schleifenbaum@kdab.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com> Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
This commit is contained in:
parent
c0a0b37103
commit
9315497d2a
@ -55,6 +55,7 @@
|
||||
#include <QtCore/qpointer.h>
|
||||
#include <QtGui/QFont>
|
||||
#include <QtGui/QKeySequence>
|
||||
#include <QtGui/QIcon>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
@ -73,7 +74,7 @@ public:
|
||||
virtual quintptr tag()const = 0;
|
||||
|
||||
virtual void setText(const QString &text) = 0;
|
||||
virtual void setIcon(const QImage &icon) = 0;
|
||||
virtual void setIcon(const QIcon &icon) = 0;
|
||||
virtual void setMenu(QPlatformMenu *menu) = 0;
|
||||
virtual void setVisible(bool isVisible) = 0;
|
||||
virtual void setIsSeparator(bool isSeparator) = 0;
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
{ return m_tag; }
|
||||
|
||||
void setText(const QString &text);
|
||||
void setIcon(const QImage &icon);
|
||||
void setIcon(const QIcon &icon);
|
||||
void setMenu(QPlatformMenu *menu);
|
||||
void setVisible(bool isVisible);
|
||||
void setIsSeparator(bool isSeparator);
|
||||
@ -97,7 +97,7 @@ private:
|
||||
|
||||
NSMenuItem *m_native;
|
||||
QString m_text;
|
||||
QImage m_icon;
|
||||
QIcon m_icon;
|
||||
QCocoaMenu *m_menu;
|
||||
bool m_isVisible;
|
||||
bool m_enabled;
|
||||
|
@ -114,7 +114,7 @@ void QCocoaMenuItem::setText(const QString &text)
|
||||
m_text = qt_mac_removeAmpersandEscapes(text);
|
||||
}
|
||||
|
||||
void QCocoaMenuItem::setIcon(const QImage &icon)
|
||||
void QCocoaMenuItem::setIcon(const QIcon &icon)
|
||||
{
|
||||
m_icon = icon;
|
||||
}
|
||||
@ -306,8 +306,9 @@ NSMenuItem *QCocoaMenuItem::sync()
|
||||
}
|
||||
|
||||
if (!m_icon.isNull()) {
|
||||
NSImage *img = qt_mac_cgimage_to_nsimage(qt_mac_image_to_cgimage(m_icon));
|
||||
NSImage *img = static_cast<NSImage *>(qt_mac_create_nsimage(m_icon.pixmap(16, QIcon::Normal)));
|
||||
[m_native setImage: img];
|
||||
[img release];
|
||||
}
|
||||
|
||||
[m_native setState:m_checked ? NSOnState : NSOffState];
|
||||
|
@ -2830,7 +2830,8 @@ void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem* item)
|
||||
{
|
||||
item->setText(action->text());
|
||||
item->setIsSeparator(action->isSeparator());
|
||||
// item->setIcon(action->icon());
|
||||
if (action->isIconVisibleInMenu())
|
||||
item->setIcon(action->icon());
|
||||
item->setVisible(action->isVisible());
|
||||
item->setShortcut(action->shortcut());
|
||||
item->setChecked(action->isChecked());
|
||||
|
Loading…
Reference in New Issue
Block a user