diff options
author | Jens Bache-Wiig <jbache@trolltech.com> | 2009-07-17 11:36:08 (GMT) |
---|---|---|
committer | Jens Bache-Wiig <jbache@trolltech.com> | 2009-07-17 13:24:22 (GMT) |
commit | 5f6c0594f07df57af2574be0420a68f84b703b87 (patch) | |
tree | 77fadf5fe3fb6de31224cc0c351005eec0750398 /src/gui/widgets | |
parent | 080231536cbc5e9acc486e57e165320416f66d85 (diff) | |
download | Qt-5f6c0594f07df57af2574be0420a68f84b703b87.zip Qt-5f6c0594f07df57af2574be0420a68f84b703b87.tar.gz Qt-5f6c0594f07df57af2574be0420a68f84b703b87.tar.bz2 |
Add priority property to QAction
We need this to support the behavior in Gtk+ where, when
Qt::ToolButtonTextBesideIcon is used, only text labels
for important actions are shown. It will also enable us to
prioritize actions in the future when for instance collapsing
a toolbar.
Task-number: 258290
Reviewed-by: thierry
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/qtoolbutton.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/gui/widgets/qtoolbutton.cpp b/src/gui/widgets/qtoolbutton.cpp index 5d0a98a..3901245 100644 --- a/src/gui/widgets/qtoolbutton.cpp +++ b/src/gui/widgets/qtoolbutton.cpp @@ -378,11 +378,17 @@ void QToolButton::initStyleOption(QStyleOptionToolButton *option) const if (d->hasMenu()) option->features |= QStyleOptionToolButton::HasMenu; #endif - if (d->toolButtonStyle == Qt::ToolButtonSystemDefault) { + if (d->toolButtonStyle == Qt::ToolButtonFollowStyle) { option->toolButtonStyle = Qt::ToolButtonStyle(style()->styleHint(QStyle::SH_ToolButtonStyle, option, this)); } else option->toolButtonStyle = d->toolButtonStyle; + if (option->toolButtonStyle == Qt::ToolButtonTextBesideIcon) { + // If the action is not prioritized, remove the text label to save space + if (d->defaultAction && d->defaultAction->priority() < QAction::NormalPriority) + option->toolButtonStyle = Qt::ToolButtonIconOnly; + } + if (d->icon.isNull() && d->arrowType == Qt::NoArrow && !forceNoText) { if (!d->text.isEmpty()) option->toolButtonStyle = Qt::ToolButtonTextOnly; @@ -482,7 +488,7 @@ QSize QToolButton::minimumSizeHint() const If you want your toolbars to depend on system settings, as is possible in GNOME and KDE desktop environments you should - use the ToolButtonSystemDefault. + use the ToolButtonFollowStyle. QToolButton automatically connects this slot to the relevant signal in the QMainWindow in which is resides. |