Qt 4.8
qaction.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qaction.h"
43 #include "qactiongroup.h"
44 
45 #ifndef QT_NO_ACTION
46 #include "qaction_p.h"
47 #include "qapplication.h"
48 #include "qevent.h"
49 #include "qlist.h"
50 #include "qdebug.h"
51 #include <private/qshortcutmap_p.h>
52 #include <private/qapplication_p.h>
53 #include <private/qmenu_p.h>
54 
55 #define QAPP_CHECK(functionName) \
56  if (!qApp) { \
57  qWarning("QAction: Initialize QApplication before calling '" functionName "'."); \
58  return; \
59  }
60 
62 
63 /*
64  internal: guesses a descriptive text from a text suited for a menu entry
65  */
67 {
68  s.remove( QString::fromLatin1("...") );
69  int i = 0;
70  while (i < s.size()) {
71  ++i;
72  if (s.at(i-1) != QLatin1Char('&'))
73  continue;
74  if (i < s.size() && s.at(i) == QLatin1Char('&'))
75  ++i;
76  s.remove(i-1,1);
77  }
78  return s.trimmed();
79 }
80 
81 
82 QActionPrivate::QActionPrivate() : group(0), enabled(1), forceDisabled(0),
83  visible(1), forceInvisible(0), checkable(0), checked(0), separator(0), fontSet(false),
84  forceEnabledInSoftkeys(false), menuActionSoftkeys(false),
85  iconVisibleInMenu(-1),
86  menuRole(QAction::TextHeuristicRole), softKeyRole(QAction::NoSoftKey),
87  priority(QAction::NormalPriority)
88 {
89 #ifdef QT3_SUPPORT
90  static int qt_static_action_id = -1;
91  param = id = --qt_static_action_id;
92  act_signal = 0;
93 #endif
94 #ifndef QT_NO_SHORTCUT
95  shortcutId = 0;
97  autorepeat = true;
98 #endif
99 }
100 
102 {
103 }
104 
106 {
107 #ifdef QT_NO_STATUSTIP
108  Q_UNUSED(widget);
109  Q_UNUSED(str);
110 #else
111  if(QObject *object = widget ? widget : parent) {
112  QStatusTipEvent tip(str);
113  QApplication::sendEvent(object, &tip);
114  return true;
115  }
116 #endif
117  return false;
118 }
119 
121 {
122  Q_Q(QAction);
124  for (int i = 0; i < widgets.size(); ++i) {
125  QWidget *w = widgets.at(i);
127  }
128 #ifndef QT_NO_GRAPHICSVIEW
129  for (int i = 0; i < graphicsWidgets.size(); ++i) {
132  }
133 #endif
135 
136  emit q->changed();
137 }
138 
139 #ifndef QT_NO_SHORTCUT
141 {
142  Q_Q(QAction);
143  if (shortcutId)
144  map.removeShortcut(shortcutId, q);
145  if (shortcut.isEmpty())
146  return;
148  if (!enabled)
149  map.setShortcutEnabled(false, shortcutId, q);
150  if (!autorepeat)
151  map.setShortcutAutoRepeat(false, shortcutId, q);
152 }
153 
155 {
156  Q_Q(QAction);
157  for(int i = 0; i < alternateShortcutIds.count(); ++i) {
158  if (const int id = alternateShortcutIds.at(i))
159  map.removeShortcut(id, q);
160  }
163  return;
164  for(int i = 0; i < alternateShortcuts.count(); ++i) {
165  const QKeySequence& alternate = alternateShortcuts.at(i);
166  if (!alternate.isEmpty())
168  else
170  }
171  if (!enabled) {
172  for(int i = 0; i < alternateShortcutIds.count(); ++i) {
173  const int id = alternateShortcutIds.at(i);
174  map.setShortcutEnabled(false, id, q);
175  }
176  }
177  if (!autorepeat) {
178  for(int i = 0; i < alternateShortcutIds.count(); ++i) {
179  const int id = alternateShortcutIds.at(i);
180  map.setShortcutAutoRepeat(false, id, q);
181  }
182  }
183 }
184 
186 {
187  Q_Q(QAction);
188  if (shortcutId)
189  map.setShortcutEnabled(enable, shortcutId, q);
190  for(int i = 0; i < alternateShortcutIds.count(); ++i) {
191  if (const int id = alternateShortcutIds.at(i))
192  map.setShortcutEnabled(enable, id, q);
193  }
194 }
195 #endif // QT_NO_SHORTCUT
196 
197 
329  : QObject(*(new QActionPrivate), parent)
330 {
331  Q_D(QAction);
332  d->group = qobject_cast<QActionGroup *>(parent);
333  if (d->group)
334  d->group->addAction(this);
335 }
336 
337 
352  : QObject(*(new QActionPrivate), parent)
353 {
354  Q_D(QAction);
355  d->text = text;
356  d->group = qobject_cast<QActionGroup *>(parent);
357  if (d->group)
358  d->group->addAction(this);
359 }
360 
374  : QObject(*(new QActionPrivate), parent)
375 {
376  Q_D(QAction);
377  d->icon = icon;
378  d->text = text;
379  d->group = qobject_cast<QActionGroup *>(parent);
380  if (d->group)
381  d->group->addAction(this);
382 }
383 
388  : QObject(dd, parent)
389 {
390  Q_D(QAction);
391  d->group = qobject_cast<QActionGroup *>(parent);
392  if (d->group)
393  d->group->addAction(this);
394 }
395 
400 {
401  QObject *ret = parent();
402  while (ret && !ret->isWidgetType())
403  ret = ret->parent();
404  return (QWidget*)ret;
405 }
406 
417 {
418  Q_D(const QAction);
419  return d->widgets;
420 }
421 
422 #ifndef QT_NO_GRAPHICSVIEW
423 
433 {
434  Q_D(const QAction);
435  return d->graphicsWidgets;
436 }
437 #endif
438 
439 #ifndef QT_NO_SHORTCUT
440 
451 {
452  QAPP_CHECK("setShortcut");
453 
454  Q_D(QAction);
455  if (d->shortcut == shortcut)
456  return;
457 
458  d->shortcut = shortcut;
459  d->redoGrab(qApp->d_func()->shortcutMap);
460  d->sendDataChanged();
461 }
462 
475 {
476  Q_D(QAction);
477 
478  QList <QKeySequence> listCopy = shortcuts;
479 
480  QKeySequence primary;
481  if (!listCopy.isEmpty())
482  primary = listCopy.takeFirst();
483 
484  if (d->shortcut == primary && d->alternateShortcuts == listCopy)
485  return;
486 
487  QAPP_CHECK("setShortcuts");
488 
489  d->shortcut = primary;
490  d->alternateShortcuts = listCopy;
491  d->redoGrab(qApp->d_func()->shortcutMap);
492  d->redoGrabAlternate(qApp->d_func()->shortcutMap);
493  d->sendDataChanged();
494 }
495 
510 {
512  setShortcuts(list);
513 }
514 
521 {
522  Q_D(const QAction);
523  return d->shortcut;
524 }
525 
538 {
539  Q_D(const QAction);
541  if (!d->shortcut.isEmpty())
542  shortcuts << d->shortcut;
543  if (!d->alternateShortcuts.isEmpty())
544  shortcuts << d->alternateShortcuts;
545  return shortcuts;
546 }
547 
559 {
560  Q_D(QAction);
561  if (d->shortcutContext == context)
562  return;
563  QAPP_CHECK("setShortcutContext");
564  d->shortcutContext = context;
565  d->redoGrab(qApp->d_func()->shortcutMap);
566  d->redoGrabAlternate(qApp->d_func()->shortcutMap);
567  d->sendDataChanged();
568 }
569 
571 {
572  Q_D(const QAction);
573  return d->shortcutContext;
574 }
575 
590 {
591  Q_D(QAction);
592  if (d->autorepeat == on)
593  return;
594  QAPP_CHECK("setAutoRepeat");
595  d->autorepeat = on;
596  d->redoGrab(qApp->d_func()->shortcutMap);
597  d->redoGrabAlternate(qApp->d_func()->shortcutMap);
598  d->sendDataChanged();
599 }
600 
601 bool QAction::autoRepeat() const
602 {
603  Q_D(const QAction);
604  return d->autorepeat;
605 }
606 #endif // QT_NO_SHORTCUT
607 
624 {
625  Q_D(QAction);
626  if (d->font == font)
627  return;
628 
629  d->fontSet = true;
630  d->font = font;
631  d->sendDataChanged();
632 }
633 
634 QFont QAction::font() const
635 {
636  Q_D(const QAction);
637  return d->font;
638 }
639 
640 #ifdef QT3_SUPPORT
641 
645 QAction::QAction(QObject* parent, const char* name)
646  : QObject(*(new QActionPrivate), parent)
647 {
648  Q_D(QAction);
650  d->group = qobject_cast<QActionGroup *>(parent);
651  if (d->group)
652  d->group->addAction(this);
653 }
654 
655 
660 QAction::QAction(const QString &text, const QKeySequence &shortcut, QObject* parent, const char* name)
661  : QObject(*(new QActionPrivate), parent)
662 {
663  Q_D(QAction);
665  d->text = text;
666  setShortcut(shortcut);
667  d->group = qobject_cast<QActionGroup *>(parent);
668  if (d->group)
669  d->group->addAction(this);
670 }
671 
676 QAction::QAction(const QIcon &icon, const QString &text, const QKeySequence &shortcut,
677  QObject* parent, const char* name)
678  : QObject(*(new QActionPrivate), parent)
679 {
680  Q_D(QAction);
682  d->text = text;
683  setShortcut(shortcut);
684  d->icon = icon;
685  d->group = qobject_cast<QActionGroup *>(parent);
686  if (d->group)
687  d->group->addAction(this);
688 }
689 #endif
690 
695 {
696  Q_D(QAction);
697  for (int i = d->widgets.size()-1; i >= 0; --i) {
698  QWidget *w = d->widgets.at(i);
699  w->removeAction(this);
700  }
701 #ifndef QT_NO_GRAPHICSVIEW
702  for (int i = d->graphicsWidgets.size()-1; i >= 0; --i) {
703  QGraphicsWidget *w = d->graphicsWidgets.at(i);
704  w->removeAction(this);
705  }
706 #endif
707  if (d->group)
708  d->group->removeAction(this);
709 #ifndef QT_NO_SHORTCUT
710  if (d->shortcutId && qApp) {
711  qApp->d_func()->shortcutMap.removeShortcut(d->shortcutId, this);
712  for(int i = 0; i < d->alternateShortcutIds.count(); ++i) {
713  const int id = d->alternateShortcutIds.at(i);
714  qApp->d_func()->shortcutMap.removeShortcut(id, this);
715  }
716  }
717 #endif
718 }
719 
729 {
730  Q_D(QAction);
731  if(group == d->group)
732  return;
733 
734  if(d->group)
735  d->group->removeAction(this);
736  d->group = group;
737  if(group)
738  group->addAction(this);
739 }
740 
748 {
749  Q_D(const QAction);
750  return d->group;
751 }
752 
753 
772 void QAction::setIcon(const QIcon &icon)
773 {
774  Q_D(QAction);
775  d->icon = icon;
776  d->sendDataChanged();
777 }
778 
779 QIcon QAction::icon() const
780 {
781  Q_D(const QAction);
782  return d->icon;
783 }
784 
785 #ifndef QT_NO_MENU
786 
794 {
795  Q_D(const QAction);
796  return d->menu;
797 }
798 
803 {
804  Q_D(QAction);
805  if (d->menu)
806  d->menu->d_func()->setOverrideMenuAction(0); //we reset the default action of any previous menu
807  d->menu = menu;
808  if (menu)
809  menu->d_func()->setOverrideMenuAction(this);
810  d->sendDataChanged();
811 }
812 #endif // QT_NO_MENU
813 
824 {
825  Q_D(QAction);
826  if (d->separator == b)
827  return;
828 
829  d->separator = b;
830  d->sendDataChanged();
831 }
832 
840 {
841  Q_D(const QAction);
842  return d->separator;
843 }
844 
860 void QAction::setText(const QString &text)
861 {
862  Q_D(QAction);
863  if (d->text == text)
864  return;
865 
866  d->text = text;
867  d->sendDataChanged();
868 }
869 
870 QString QAction::text() const
871 {
872  Q_D(const QAction);
873  QString s = d->text;
874  if(s.isEmpty()) {
875  s = d->iconText;
876  s.replace(QLatin1Char('&'), QLatin1String("&&"));
877  }
878  return s;
879 }
880 
881 
882 
883 
884 
907 void QAction::setIconText(const QString &text)
908 {
909  Q_D(QAction);
910  if (d->iconText == text)
911  return;
912 
913  d->iconText = text;
914  d->sendDataChanged();
915 }
916 
918 {
919  Q_D(const QAction);
920  if (d->iconText.isEmpty())
921  return qt_strippedText(d->text);
922  return d->iconText;
923 }
924 
939 void QAction::setToolTip(const QString &tooltip)
940 {
941  Q_D(QAction);
942  if (d->tooltip == tooltip)
943  return;
944 
945  d->tooltip = tooltip;
946  d->sendDataChanged();
947 }
948 
950 {
951  Q_D(const QAction);
952  if (d->tooltip.isEmpty()) {
953  if (!d->text.isEmpty())
954  return qt_strippedText(d->text);
955  return qt_strippedText(d->iconText);
956  }
957  return d->tooltip;
958 }
959 
974 void QAction::setStatusTip(const QString &statustip)
975 {
976  Q_D(QAction);
977  if (d->statustip == statustip)
978  return;
979 
980  d->statustip = statustip;
981  d->sendDataChanged();
982 }
983 
985 {
986  Q_D(const QAction);
987  return d->statustip;
988 }
989 
1003 void QAction::setWhatsThis(const QString &whatsthis)
1004 {
1005  Q_D(QAction);
1006  if (d->whatsthis == whatsthis)
1007  return;
1008 
1009  d->whatsthis = whatsthis;
1010  d->sendDataChanged();
1011 }
1012 
1014 {
1015  Q_D(const QAction);
1016  return d->whatsthis;
1017 }
1018 
1057 {
1058  Q_D(QAction);
1059  if (d->priority == priority)
1060  return;
1061 
1062  d->priority = priority;
1063  d->sendDataChanged();
1064 }
1065 
1067 {
1068  Q_D(const QAction);
1069  return d->priority;
1070 }
1071 
1095 {
1096  Q_D(QAction);
1097  if (d->checkable == b)
1098  return;
1099 
1100  d->checkable = b;
1101  d->checked = false;
1102  d->sendDataChanged();
1103 }
1104 
1106 {
1107  Q_D(const QAction);
1108  return d->checkable;
1109 }
1110 
1121 {
1122  Q_D(QAction);
1123  setChecked(!d->checked);
1124 }
1125 
1139 {
1140  Q_D(QAction);
1141  if (!d->checkable || d->checked == b)
1142  return;
1143 
1144  QPointer<QAction> guard(this);
1145  d->checked = b;
1146  d->sendDataChanged();
1147  if (guard)
1148  emit toggled(b);
1149 }
1150 
1152 {
1153  Q_D(const QAction);
1154  return d->checked;
1155 }
1156 
1193 {
1194  Q_D(QAction);
1195  if (b == d->enabled && b != d->forceDisabled)
1196  return;
1197  d->forceDisabled = !b;
1198  if (b && (!d->visible || (d->group && !d->group->isEnabled())))
1199  return;
1200  QAPP_CHECK("setEnabled");
1201  d->enabled = b;
1202 #ifndef QT_NO_SHORTCUT
1203  d->setShortcutEnabled(b, qApp->d_func()->shortcutMap);
1204 #endif
1205  d->sendDataChanged();
1206 }
1207 
1209 {
1210  Q_D(const QAction);
1211  return d->enabled;
1212 }
1213 
1231 {
1232  Q_D(QAction);
1233  if (b == d->visible && b != d->forceInvisible)
1234  return;
1235  QAPP_CHECK("setVisible");
1236  d->forceInvisible = !b;
1237  d->visible = b;
1238  d->enabled = b && !d->forceDisabled && (!d->group || d->group->isEnabled()) ;
1239 #ifndef QT_NO_SHORTCUT
1240  d->setShortcutEnabled(d->enabled, qApp->d_func()->shortcutMap);
1241 #endif
1242  d->sendDataChanged();
1243 }
1244 
1245 
1247 {
1248  Q_D(const QAction);
1249  return d->visible;
1250 }
1251 
1255 bool
1257 {
1258 #ifndef QT_NO_SHORTCUT
1259  if (e->type() == QEvent::Shortcut) {
1260  QShortcutEvent *se = static_cast<QShortcutEvent *>(e);
1261  Q_ASSERT_X(se->key() == d_func()->shortcut || d_func()->alternateShortcuts.contains(se->key()),
1262  "QAction::event",
1263  "Received shortcut event from incorrect shortcut");
1264  if (se->isAmbiguous())
1265  qWarning("QAction::eventFilter: Ambiguous shortcut overload: %s", QString(se->key()).toLatin1().constData());
1266  else
1267  activate(Trigger);
1268  return true;
1269  }
1270 #endif
1271  return QObject::event(e);
1272 }
1273 
1279 QVariant
1281 {
1282  Q_D(const QAction);
1283  return d->userData;
1284 }
1285 
1296 void
1298 {
1299  Q_D(QAction);
1300  d->userData = data;
1301  d->sendDataChanged();
1302 }
1303 
1304 
1314 bool
1316 {
1317  return d_func()->showStatusText(widget, statusTip());
1318 }
1319 
1327 {
1328  Q_D(QAction);
1329  if(event == Trigger) {
1330  QObject *guard = this;
1331  QMetaObject::addGuard(&guard);
1332  if(d->checkable) {
1333  // the checked action of an exclusive group cannot be unchecked
1334  if (d->checked && (d->group && d->group->isExclusive()
1335  && d->group->checkedAction() == this)) {
1336  if (guard)
1337  emit triggered(true);
1338  QMetaObject::removeGuard(&guard);
1339  return;
1340  }
1341  setChecked(!d->checked);
1342  }
1343  if (guard)
1344  emit triggered(d->checked);
1345 #ifdef QT3_SUPPORT
1346  if (guard)
1347  emit activated(d->param);
1348 #endif
1349  QMetaObject::removeGuard(&guard);
1350  } else if(event == Hover) {
1351  emit hovered();
1352  }
1353 }
1354 
1570 {
1571  Q_D(QAction);
1572  if (d->menuRole == menuRole)
1573  return;
1574 
1575  d->menuRole = menuRole;
1576  d->sendDataChanged();
1577 }
1578 
1580 {
1581  Q_D(const QAction);
1582  return d->menuRole;
1583 }
1584 
1600 {
1601  Q_D(QAction);
1602  if (d->softKeyRole == softKeyRole)
1603  return;
1604 
1605  d->softKeyRole = softKeyRole;
1606  d->sendDataChanged();
1607 }
1608 
1610 {
1611  Q_D(const QAction);
1612  return d->softKeyRole;
1613 }
1614 
1637 {
1638  Q_D(QAction);
1639  if (d->iconVisibleInMenu == -1 || visible != bool(d->iconVisibleInMenu)) {
1640  int oldValue = d->iconVisibleInMenu;
1641  d->iconVisibleInMenu = visible;
1642  // Only send data changed if we really need to.
1643  if (oldValue != -1
1644  || (oldValue == -1
1645  && visible == !QApplication::instance()->testAttribute(Qt::AA_DontShowIconsInMenus))) {
1646  d->sendDataChanged();
1647  }
1648  }
1649 }
1650 
1652 {
1653  Q_D(const QAction);
1654  if (d->iconVisibleInMenu == -1) {
1656  }
1657  return d->iconVisibleInMenu;
1658 }
1659 
1661 
1662 #include "moc_qaction.cpp"
1663 
1664 #endif // QT_NO_ACTION
void setShortcutContext(Qt::ShortcutContext context)
Definition: qaction.cpp:558
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
bool isSeparator() const
Returns true if this action is a separator action; otherwise it returns false.
Definition: qaction.cpp:839
double d
Definition: qnumeric_p.h:62
void setAutoRepeat(bool)
Definition: qaction.cpp:589
bool event(QEvent *)
Reimplemented Function
Definition: qaction.cpp:1256
bool isEnabled() const
Definition: qaction.cpp:1208
void setShortcut(const QKeySequence &shortcut)
Definition: qaction.cpp:450
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
int setShortcutEnabled(bool enable, int id, QObject *owner, const QKeySequence &key=QKeySequence())
Changes the enable state of a shortcut to enable.
void setStatusTip(const QString &statusTip)
Definition: qaction.cpp:974
QPointer< QWidget > widget
QString iconText() const
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
void sendDataChanged()
Definition: qaction.cpp:120
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
bool showStatusText(QWidget *widget=0)
Updates the relevant status bar for the widget specified by sending a QStatusTipEvent to its parent w...
Definition: qaction.cpp:1315
static void addGuard(QObject **ptr)
Definition: qobject.cpp:390
void activate(ActionEvent event)
Sends the relevant signals for ActionEvent event.
Definition: qaction.cpp:1326
void setSeparator(bool b)
If b is true then this action will be considered a separator.
Definition: qaction.cpp:823
void setFont(const QFont &font)
Definition: qaction.cpp:623
ActionEvent
This enum type is used when calling QAction::activate()
Definition: qaction.h:176
void setCheckable(bool)
Definition: qaction.cpp:1094
void setIconVisibleInMenu(bool visible)
Definition: qaction.cpp:1636
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
QList< QWidget * > widgets
Definition: qaction_p.h:121
#define QAPP_CHECK(functionName)
Definition: qaction.cpp:55
void setMenu(QMenu *menu)
Sets the menu contained by this action to the specified menu.
Definition: qaction.cpp:802
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QAction(QObject *parent)
Constructs an action with parent.
Definition: qaction.cpp:328
The QShortcutEvent class provides an event which is generated when the user presses a key combination...
Definition: qevent.h:675
void setToolTip(const QString &tip)
Definition: qaction.cpp:939
Priority
This enum defines priorities for actions in user interface.
Definition: qaction.h:98
QList< int > alternateShortcutIds
Definition: qaction_p.h:99
void hovered()
This signal is emitted when an action is highlighted by the user; for example, when the user pauses w...
void setWhatsThis(const QString &what)
Definition: qaction.cpp:1003
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void toggle()
This is a convenience function for the checked property.
Definition: qaction.cpp:1120
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
StandardKey
This enum represent standard key bindings.
Definition: qkeysequence.h:75
The QActionEvent class provides an event that is generated when a QAction is added, removed, or changed.
Definition: qevent.h:632
static QList< QKeySequence > keyBindings(StandardKey key)
Returns a list of key bindings for the given key.
Qt::ShortcutContext shortcutContext
Definition: qaction_p.h:100
void setMenuRole(MenuRole menuRole)
Definition: qaction.cpp:1569
void removeAction(QAction *action)
Removes the action action from this widget&#39;s list of actions.
The QString class provides a Unicode character string.
Definition: qstring.h:83
void redoGrabAlternate(QShortcutMap &map)
Definition: qaction.cpp:154
T * qobject_cast(QObject *object)
Definition: qobject.h:375
static QString qt_strippedText(QString s)
Definition: qaction.cpp:66
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
#define Q_D(Class)
Definition: qglobal.h:2482
The QActionGroup class groups actions together.
Definition: qactiongroup.h:57
void setData(const QVariant &var)
Sets the action&#39;s internal data to the given userData.
Definition: qaction.cpp:1297
void setEnabled(bool)
Definition: qaction.cpp:1192
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
void setObjectName(const QString &name)
Definition: qobject.cpp:1112
#define Q_Q(Class)
Definition: qglobal.h:2483
bool isVisible() const
Definition: qaction.cpp:1246
QList< QWidget * > associatedWidgets() const
Returns a list of widgets this action has been added to.
Definition: qaction.cpp:416
QIcon icon() const
QWidget * parentWidget() const
Returns the parent widget.
Definition: qaction.cpp:399
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QKeySequence shortcut() const
bool isIconVisibleInMenu() const
Definition: qaction.cpp:1651
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
void toggled(bool)
This signal is emitted whenever a checkable action changes its isChecked() status.
QString trimmed() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end.
Definition: qstring.cpp:4506
T takeFirst()
Removes the first item in the list and returns it.
Definition: qlist.h:489
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define qApp
void setSoftKeyRole(SoftKeyRole softKeyRole)
Definition: qaction.cpp:1599
const char * name
QList< QGraphicsWidget * > associatedGraphicsWidgets() const
Returns a list of widgets this action has been added to.
Definition: qaction.cpp:432
QString whatsThis() const
Priority priority() const
QAction * addAction(QAction *a)
Adds the action to this group, and returns it.
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
#define emit
Definition: qobjectdefs.h:76
QList< QGraphicsWidget * > graphicsWidgets
Definition: qaction_p.h:123
void setIconText(const QString &text)
Definition: qaction.cpp:907
void setShortcutEnabled(bool enable, QShortcutMap &map)
Definition: qaction.cpp:185
void setPriority(Priority priority)
Definition: qaction.cpp:1056
Q_CORE_EXPORT void qWarning(const char *,...)
void setText(const QString &text)
Definition: qaction.cpp:860
QList< QKeySequence > shortcuts() const
Returns the list of shortcuts, with the primary shortcut as the first element of the list...
Definition: qaction.cpp:537
SoftKeyRole softKeyRole() const
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
bool visible
whether the action can be seen (e.g.
Definition: qaction.h:87
SoftKeyRole
This enum describes how an action should be placed in the softkey bar.
Definition: qaction.h:96
void clear()
Removes all items from the list.
Definition: qlist.h:764
~QAction()
Destroys the object and frees allocated resources.
Definition: qaction.cpp:694
bool isEmpty() const
Returns true if the key sequence is empty; otherwise returns false.
void setShortcuts(const QList< QKeySequence > &shortcuts)
Sets shortcuts as the list of shortcuts that trigger the action.
Definition: qaction.cpp:474
bool autoRepeat() const
const QKeySequence & key()
Definition: qevent.h:681
int setShortcutAutoRepeat(bool on, int id, QObject *owner, const QKeySequence &key=QKeySequence())
Changes the auto repeat state of a shortcut to enable.
QList< QKeySequence > alternateShortcuts
Definition: qaction_p.h:94
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
bool isWidgetType() const
Returns true if the object is a widget; otherwise returns false.
Definition: qobject.h:146
QMenu * menu() const
Returns the menu contained by this action.
Definition: qaction.cpp:793
void setVisible(bool)
Definition: qaction.cpp:1230
The QKeySequence class encapsulates a key sequence as used by shortcuts.
Definition: qkeysequence.h:72
void redoGrab(QShortcutMap &map)
Definition: qaction.cpp:140
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
MenuRole menuRole() const
void setChecked(bool)
Definition: qaction.cpp:1138
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
static QCoreApplication * instance()
Returns a pointer to the application&#39;s QCoreApplication (or QApplication) instance.
The QStatusTipEvent class provides an event that is used to show messages in a status bar...
Definition: qevent.h:606
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
QString text() const
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
void removeAction(QAction *action)
Removes the action action from this widget&#39;s list of actions.
Definition: qwidget.cpp:3386
int key
QVariant data() const
Returns the user data as set in QAction::setData.
Definition: qaction.cpp:1280
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
bool isCheckable() const
Definition: qaction.cpp:1105
int removeShortcut(int id, QObject *owner, const QKeySequence &key=QKeySequence())
Removes a shortcut from the global map.
if(void) toggleToolbarShown
void setActionGroup(QActionGroup *group)
Sets this action group to group.
Definition: qaction.cpp:728
void setIcon(const QIcon &icon)
Definition: qaction.cpp:772
bool isChecked() const
Definition: qaction.cpp:1151
Qt::ShortcutContext shortcutContext() const
MenuRole
This enum describes how an action should be moved into the application menu on Mac OS X...
Definition: qaction.h:94
QObject * parent
Definition: qobject.h:92
int addShortcut(QObject *owner, const QKeySequence &key, Qt::ShortcutContext context)
Adds a shortcut to the global map.
static void removeGuard(QObject **ptr)
Definition: qobject.cpp:406
QKeySequence shortcut
Definition: qaction_p.h:93
bool isAmbiguous()
Definition: qevent.h:685
ShortcutContext
Definition: qnamespace.h:1478
QString toolTip() const
QFont font() const
QActionGroup * actionGroup() const
Returns the action group for this action.
Definition: qaction.cpp:747
static bool testAttribute(Qt::ApplicationAttribute attribute)
Returns true if attribute attribute is set; otherwise returns false.
QString & remove(int i, int len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
Definition: qstring.cpp:1867
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
void triggered(bool checked=false)
This signal is emitted when an action is activated by the user; for example, when the user clicks a m...
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
bool showStatusText(QWidget *w, const QString &str)
Definition: qaction.cpp:105
QString statusTip() const
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition: qstring.h:712
#define enabled
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60