From 17cea8059e5a09ff972f251e631e3e57476a1da2 Mon Sep 17 00:00:00 2001 From: Eike Hein Date: Thu, 14 Apr 2016 04:21:41 +0900 Subject: [PATCH] Allow setting minimum width on Menu. REVIEW:127648 --- src/declarativeimports/plasmacomponents/qmenu.cpp | 14 ++++++++++++++ src/declarativeimports/plasmacomponents/qmenu.h | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/src/declarativeimports/plasmacomponents/qmenu.cpp b/src/declarativeimports/plasmacomponents/qmenu.cpp index 2a96d775c..8ec146404 100644 --- a/src/declarativeimports/plasmacomponents/qmenu.cpp +++ b/src/declarativeimports/plasmacomponents/qmenu.cpp @@ -116,6 +116,20 @@ void QMenuProxy::setTransientParent(QWindow *parent) emit transientParentChanged(); } +int QMenuProxy::minimumWidth() const +{ + return m_menu->minimumWidth(); +} + +void QMenuProxy::setMinimumWidth(int width) +{ + if (m_menu->minimumWidth() != width) { + m_menu->setMinimumWidth(width); + + emit minimumWidthChanged(); + } +} + bool QMenuProxy::event(QEvent *event) { switch (event->type()) { diff --git a/src/declarativeimports/plasmacomponents/qmenu.h b/src/declarativeimports/plasmacomponents/qmenu.h index 41e88659c..34efe67f1 100644 --- a/src/declarativeimports/plasmacomponents/qmenu.h +++ b/src/declarativeimports/plasmacomponents/qmenu.h @@ -82,6 +82,11 @@ class QMenuProxy : public QObject Q_PROPERTY(QObject *visualParent READ visualParent WRITE setVisualParent NOTIFY visualParentChanged()) Q_PROPERTY(DialogStatus::Status status READ status NOTIFY statusChanged) + /** + * A minimum width for the menu. + */ + Q_PROPERTY(int minimumWidth READ minimumWidth WRITE setMinimumWidth NOTIFY minimumWidthChanged) + public: QMenuProxy(QObject *parent = 0); ~QMenuProxy(); @@ -97,6 +102,8 @@ public: QWindow *transientParent(); void setTransientParent(QWindow *parent); + int minimumWidth() const; + void setMinimumWidth(int width); /** * This opens the menu at position x,y on the given visualParent. By default x and y are set to 0 @@ -135,6 +142,7 @@ Q_SIGNALS: void statusChanged(); void visualParentChanged(); void transientParentChanged(); + void minimumWidthChanged(); void triggered(QMenuItem *item); void triggeredIndex(int index);