summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/kernel/qplatformmenu.h2
-rw-r--r--src/plugins/platforms/android/qandroidplatformmenuitem.cpp5
-rw-r--r--src/plugins/platforms/android/qandroidplatformmenuitem.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenuitem.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenuitem.mm10
-rw-r--r--src/widgets/widgets/qmenu.cpp11
6 files changed, 28 insertions, 4 deletions
diff --git a/src/gui/kernel/qplatformmenu.h b/src/gui/kernel/qplatformmenu.h
index 39184826df..5731b4f56a 100644
--- a/src/gui/kernel/qplatformmenu.h
+++ b/src/gui/kernel/qplatformmenu.h
@@ -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:
diff --git a/src/plugins/platforms/android/qandroidplatformmenuitem.cpp b/src/plugins/platforms/android/qandroidplatformmenuitem.cpp
index 4e19ec2939..e510327ba5 100644
--- a/src/plugins/platforms/android/qandroidplatformmenuitem.cpp
+++ b/src/plugins/platforms/android/qandroidplatformmenuitem.cpp
@@ -181,4 +181,9 @@ bool QAndroidPlatformMenuItem::isEnabled() const
return m_isEnabled;
}
+void QAndroidPlatformMenuItem::setIconSize(int size)
+{
+ Q_UNUSED(size)
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/android/qandroidplatformmenuitem.h b/src/plugins/platforms/android/qandroidplatformmenuitem.h
index 40c3ab2761..32aeca105b 100644
--- a/src/plugins/platforms/android/qandroidplatformmenuitem.h
+++ b/src/plugins/platforms/android/qandroidplatformmenuitem.h
@@ -85,6 +85,8 @@ public:
void setEnabled(bool enabled);
bool isEnabled() const;
+ void setIconSize(int size);
+
private:
quintptr m_tag;
QString m_text;
diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.h b/src/plugins/platforms/cocoa/qcocoamenuitem.h
index 1efc9f9bfd..0ce3970fc4 100644
--- a/src/plugins/platforms/cocoa/qcocoamenuitem.h
+++ b/src/plugins/platforms/cocoa/qcocoamenuitem.h
@@ -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 *>())
diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm
index 4b9a0146a9..d0d1e7e8b8 100644
--- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm
@@ -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;
+}
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index 846199ebe2..94cdf2e763 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -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());