Respect the PM_SmallIconSize setting for icons in a menu on OS X
When a platform menu is used then it would hard code the icon size to 16x16. Instead of using the hard coded value then PM_SmallIconSize should be used instead. Change-Id: I27540ebc4397501e8f57686a118c28cd7167c0a1 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>bb10
parent
4d8dd7f673
commit
b53f6fdd31
|
|
@ -86,7 +86,7 @@ public:
|
|||
virtual void setChecked(bool isChecked) = 0;
|
||||
virtual void setShortcut(const QKeySequence& shortcut) = 0;
|
||||
virtual void setEnabled(bool enabled) = 0;
|
||||
|
||||
virtual void setIconSize(int size) = 0;
|
||||
virtual void setNativeContents(WId item) { Q_UNUSED(item); }
|
||||
|
||||
Q_SIGNALS:
|
||||
|
|
|
|||
|
|
@ -181,4 +181,9 @@ bool QAndroidPlatformMenuItem::isEnabled() const
|
|||
return m_isEnabled;
|
||||
}
|
||||
|
||||
void QAndroidPlatformMenuItem::setIconSize(int size)
|
||||
{
|
||||
Q_UNUSED(size)
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -85,6 +85,8 @@ public:
|
|||
void setEnabled(bool enabled);
|
||||
bool isEnabled() const;
|
||||
|
||||
void setIconSize(int size);
|
||||
|
||||
private:
|
||||
quintptr m_tag;
|
||||
QString m_text;
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ public:
|
|||
void setCheckable(bool checkable) { Q_UNUSED(checkable) }
|
||||
void setChecked(bool isChecked);
|
||||
void setEnabled(bool isEnabled);
|
||||
void setIconSize(int size);
|
||||
|
||||
void setNativeContents(WId item);
|
||||
|
||||
|
|
@ -123,6 +124,7 @@ private:
|
|||
bool m_checked;
|
||||
bool m_merged;
|
||||
quintptr m_tag;
|
||||
int m_iconSize;
|
||||
};
|
||||
|
||||
#define COCOA_MENU_ANCESTOR(m) ((m)->property("_qCocoaMenuAncestor").value<QObject *>())
|
||||
|
|
|
|||
|
|
@ -100,7 +100,8 @@ QCocoaMenuItem::QCocoaMenuItem() :
|
|||
m_role(NoRole),
|
||||
m_checked(false),
|
||||
m_merged(false),
|
||||
m_tag(0)
|
||||
m_tag(0),
|
||||
m_iconSize(16)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -332,7 +333,7 @@ NSMenuItem *QCocoaMenuItem::sync()
|
|||
NSImage *img = nil;
|
||||
if (!m_icon.isNull()) {
|
||||
img = qt_mac_create_nsimage(m_icon);
|
||||
[img setSize:NSMakeSize(16, 16)];
|
||||
[img setSize:NSMakeSize(m_iconSize, m_iconSize)];
|
||||
}
|
||||
[m_native setImage:img];
|
||||
[img release];
|
||||
|
|
@ -403,3 +404,8 @@ QPlatformMenuItem::MenuRole QCocoaMenuItem::effectiveRole() const
|
|||
else
|
||||
return m_detectedRole;
|
||||
}
|
||||
|
||||
void QCocoaMenuItem::setIconSize(int size)
|
||||
{
|
||||
m_iconSize = size;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2978,8 +2978,17 @@ static void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem* i
|
|||
{
|
||||
item->setText(action->text());
|
||||
item->setIsSeparator(action->isSeparator());
|
||||
if (action->isIconVisibleInMenu())
|
||||
if (action->isIconVisibleInMenu()) {
|
||||
item->setIcon(action->icon());
|
||||
if (QWidget *w = action->parentWidget()) {
|
||||
QStyleOption opt;
|
||||
opt.init(w);
|
||||
item->setIconSize(w->style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, w));
|
||||
} else {
|
||||
QStyleOption opt;
|
||||
item->setIconSize(qApp->style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, 0));
|
||||
}
|
||||
}
|
||||
item->setVisible(action->isVisible());
|
||||
item->setShortcut(action->shortcut());
|
||||
item->setCheckable(action->isCheckable());
|
||||
|
|
|
|||
Loading…
Reference in New Issue