• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDE3Support

  • sources
  • kde-4.14
  • kdelibs
  • kde3support
  • kdeui
k3popupmenu.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org>
3  Copyright (C) 2002 Hamish Rodda <rodda@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License version 2 as published by the Free Software Foundation.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #include "k3popupmenu.h"
21 
22 #include <QtGui/QCursor>
23 #include <QtGui/QPainter>
24 #include <QtCore/QTimer>
25 #include <QtGui/QFontMetrics>
26 #include <QKeyEvent>
27 #include <QPointer>
28 #include <QMenuItem>
29 
30 #include <kdebug.h>
31 #include <kglobal.h>
32 #include <klocale.h>
33 
34 class K3PopupMenu::K3PopupMenuPrivate
35 {
36 public:
37  K3PopupMenuPrivate ()
38  : noMatches(false)
39  , shortcuts(false)
40  , autoExec(false)
41  , lastHitAction(0L)
42 #ifdef QT3_SUPPORT
43  , state(Qt::NoButton)
44 #endif
45  , mouseButtons(Qt::NoButton)
46  , keyboardModifiers(Qt::NoModifier)
47  , m_ctxMenu(0)
48  {}
49 
50  ~K3PopupMenuPrivate ()
51  {
52  delete m_ctxMenu;
53  }
54 
55  QString m_lastTitle;
56 
57  // variables for keyboard navigation
58  QTimer clearTimer;
59 
60  bool noMatches : 1;
61  bool shortcuts : 1;
62  bool autoExec : 1;
63 
64  QString keySeq;
65  QString originalText;
66 
67  QAction* lastHitAction;
68 #ifdef QT3_SUPPORT
69  Qt::ButtonState state;
70  Qt::MouseButtons mouseButtons;
71  Qt::KeyboardModifiers keyboardModifiers;
72 #endif
73 
74  // support for RMB menus on menus
75  Q3PopupMenu* m_ctxMenu;
76  static bool s_continueCtxMenuShow;
77  static QPointer<QAction> s_highlightedAction;
78  // KDE4: deprecated
79  static int s_highlightedItem;
80  static K3PopupMenu* s_contextedMenu;
81 };
82 
83 QPointer<QAction> K3PopupMenu::K3PopupMenuPrivate::s_highlightedAction(0L);
84 int K3PopupMenu::K3PopupMenuPrivate::s_highlightedItem(-1);
85 K3PopupMenu* K3PopupMenu::K3PopupMenuPrivate::s_contextedMenu(0);
86 bool K3PopupMenu::K3PopupMenuPrivate::s_continueCtxMenuShow(true);
87 
88 K3PopupMenu::K3PopupMenu(QWidget *parent)
89  : Q3PopupMenu(parent)
90  , d(new K3PopupMenuPrivate())
91 {
92  resetKeyboardVars();
93  connect(&(d->clearTimer), SIGNAL(timeout()), SLOT(resetKeyboardVars()));
94 }
95 
96 K3PopupMenu::~K3PopupMenu()
97 {
98  if (K3PopupMenuPrivate::s_contextedMenu == this)
99  {
100  K3PopupMenuPrivate::s_contextedMenu = 0;
101  K3PopupMenuPrivate::s_highlightedAction = 0L;
102  K3PopupMenuPrivate::s_highlightedItem = -1;
103  }
104 
105  delete d;
106 }
107 
108 QAction* K3PopupMenu::addTitle(const QString &text, QAction* before)
109 {
110  QAction* action = new QAction(text, this);
111  action->setEnabled(false);
112  QFont f = action->font();
113  f.setBold(true);
114  action->setFont(f);
115  insertAction(before, action);
116  return action;
117 }
118 
119 QAction* K3PopupMenu::addTitle(const QIcon &icon, const QString &text, QAction* before)
120 {
121  QAction* action = new QAction(icon, text, this);
122  action->setEnabled(false);
123  QFont f = action->font();
124  f.setBold(true);
125  action->setFont(f);
126  insertAction(before, action);
127  return action;
128 }
129 
133 void K3PopupMenu::closeEvent(QCloseEvent*e)
134 {
135  if (d->shortcuts)
136  resetKeyboardVars();
137  Q3PopupMenu::closeEvent(e);
138 }
139 
140 void K3PopupMenu::activateItemAt(int index)
141 {
142 #ifdef QT3_SUPPORT
143  d->state = Qt::NoButton;
144 #endif
145  d->mouseButtons = Qt::NoButton;
146  d->keyboardModifiers = Qt::NoModifier;
147  Q3PopupMenu::activateItemAt(index);
148 }
149 
150 #ifdef QT3_SUPPORT
151 Qt::ButtonState K3PopupMenu::state() const
152 {
153  return d->state;
154 }
155 #endif
156 
157 Qt::MouseButtons K3PopupMenu::mouseButtons() const
158 {
159  return d->mouseButtons;
160 }
161 
162 Qt::KeyboardModifiers K3PopupMenu::keyboardModifiers() const
163 {
164  return d->keyboardModifiers;
165 }
166 
167 void K3PopupMenu::keyPressEvent(QKeyEvent* e)
168 {
169 #ifdef QT3_SUPPORT
170  d->state = Qt::NoButton;
171 #endif
172  d->mouseButtons = Qt::NoButton;
173  d->keyboardModifiers = Qt::NoModifier;
174  if (!d->shortcuts) {
175  // continue event processing by Qpopup
176  //e->ignore();
177 #ifdef QT3_SUPPORT
178  d->state = e->state();
179 #endif
180  d->keyboardModifiers = e->modifiers();
181  Q3PopupMenu::keyPressEvent(e);
182  return;
183  }
184 
185  QAction* a = 0L;
186  bool firstpass = true;
187  QString keyString = e->text();
188 
189  // check for common commands dealt with by QPopup
190  int key = e->key();
191  if (key == Qt::Key_Escape || key == Qt::Key_Return || key == Qt::Key_Enter
192  || key == Qt::Key_Up || key == Qt::Key_Down || key == Qt::Key_Left
193  || key == Qt::Key_Right || key == Qt::Key_F1) {
194 
195  resetKeyboardVars();
196  // continue event processing by Qpopup
197  //e->ignore();
198 #ifdef QT3_SUPPORT
199  d->state = e->state();
200 #endif
201  d->keyboardModifiers = e->modifiers();
202  Q3PopupMenu::keyPressEvent(e);
203  return;
204  } else if ( key == Qt::Key_Shift || key == Qt::Key_Control || key == Qt::Key_Alt || key == Qt::Key_Meta )
205  return Q3PopupMenu::keyPressEvent(e);
206 
207  // check to see if the user wants to remove a key from the sequence (backspace)
208  // or clear the sequence (delete)
209  if (!d->keySeq.isNull()) {
210  if (key == Qt::Key_Backspace) {
211 
212  if (d->keySeq.length() == 1) {
213  resetKeyboardVars();
214  return;
215  }
216 
217  // keep the last sequence in keyString
218  keyString = d->keySeq.left(d->keySeq.length() - 1);
219 
220  // allow sequence matching to be tried again
221  resetKeyboardVars();
222 
223  } else if (key == Qt::Key_Delete) {
224  resetKeyboardVars();
225 
226  // clear active item
227  setActiveAction(0L);
228  return;
229 
230  } else if (d->noMatches) {
231  // clear if there are no matches
232  resetKeyboardVars();
233 
234  // clear active item
235  setActiveAction(0L);
236 
237  } else {
238  // the key sequence is not a null string
239  // therefore the lastHitAction is valid
240  a = d->lastHitAction;
241  }
242 
243  } else if (key == Qt::Key_Backspace && menuAction()) {
244  // backspace with no chars in the buffer... go back a menu.
245  hide();
246  resetKeyboardVars();
247  return;
248  }
249 
250  d->keySeq += keyString;
251  int seqLen = d->keySeq.length();
252 
253  foreach (a, actions()) {
254  // don't search disabled entries
255  if (!a->isEnabled())
256  continue;
257 
258  QString thisText;
259 
260  // retrieve the right text
261  // (the last selected item one may have additional ampersands)
262  if (a == d->lastHitAction)
263  thisText = d->originalText;
264  else
265  thisText = a->text();
266 
267  // if there is an accelerator present, remove it
268  thisText = KGlobal::locale()->removeAcceleratorMarker(thisText);
269 
270  // chop text to the search length
271  thisText = thisText.left(seqLen);
272 
273  // do the search
274  if (!thisText.contains(d->keySeq, Qt::CaseInsensitive)) {
275 
276  if (firstpass) {
277  // match
278  setActiveAction(a);
279 
280  // check to see if we're underlining a different item
281  if (d->lastHitAction != a)
282  // yes; revert the underlining
283  d->lastHitAction->setText(d->originalText);
284 
285  // set the original text if it's a different item
286  if (d->lastHitAction != a || d->lastHitAction == 0L)
287  d->originalText = a->text();
288 
289  // underline the currently selected item
290  a->setText(underlineText(d->originalText, d->keySeq.length()));
291 
292  // remember what's going on
293  d->lastHitAction = a;
294 
295  // start/restart the clear timer
296  d->clearTimer.start(5000, true);
297 
298  // go around for another try, to see if we can execute
299  firstpass = false;
300  } else {
301  // don't allow execution
302  return;
303  }
304  }
305 
306  // fall through to allow execution
307  }
308 
309  if (!firstpass) {
310  if (d->autoExec) {
311  // activate anything
312  d->lastHitAction->activate(QAction::Trigger);
313  resetKeyboardVars();
314 
315  } else if (d->lastHitAction && d->lastHitAction->menu()) {
316  // only activate sub-menus
317  d->lastHitAction->activate(QAction::Trigger);
318  resetKeyboardVars();
319  }
320 
321  return;
322  }
323 
324  // no matches whatsoever, clean up
325  resetKeyboardVars(true);
326  //e->ignore();
327  Q3PopupMenu::keyPressEvent(e);
328 }
329 
330 bool K3PopupMenu::focusNextPrevChild( bool next )
331 {
332  resetKeyboardVars();
333  return Q3PopupMenu::focusNextPrevChild( next );
334 }
335 
336 QString K3PopupMenu::underlineText(const QString& text, uint length)
337 {
338  QString ret = text;
339  for (uint i = 0; i < length; i++) {
340  if (ret[2*i] != '&')
341  ret.insert(2*i, "&");
342  }
343  return ret;
344 }
345 
346 void K3PopupMenu::resetKeyboardVars(bool noMatches /* = false */)
347 {
348  // Clean up keyboard variables
349  if (d->lastHitAction) {
350  d->lastHitAction->setText(d->originalText);
351  d->lastHitAction = 0L;
352  }
353 
354  if (!noMatches) {
355  d->keySeq.clear();
356  }
357 
358  d->noMatches = noMatches;
359 }
360 
361 void K3PopupMenu::setKeyboardShortcutsEnabled(bool enable)
362 {
363  d->shortcuts = enable;
364 }
365 
366 void K3PopupMenu::setKeyboardShortcutsExecute(bool enable)
367 {
368  d->autoExec = enable;
369 }
378 void K3PopupMenu::mousePressEvent(QMouseEvent* e)
379 {
380  if (d->m_ctxMenu && d->m_ctxMenu->isVisible())
381  {
382  // hide on a second context menu event
383  d->m_ctxMenu->hide();
384  }
385 
386  Q3PopupMenu::mousePressEvent(e);
387 }
388 
389 void K3PopupMenu::mouseReleaseEvent(QMouseEvent* e)
390 {
391 #ifdef QT3_SUPPORT
392  // Save the button, and the modifiers from state()
393  d->state = Qt::ButtonState(uint(e->button()) | (e->state() & Qt::KeyboardModifierMask));
394 #endif
395  // Save the button, and the modifiers
396  d->keyboardModifiers = e->modifiers();
397  d->mouseButtons = e->buttons();
398 
399  if ( !d->m_ctxMenu || !d->m_ctxMenu->isVisible() )
400  Q3PopupMenu::mouseReleaseEvent(e);
401 }
402 
403 Q3PopupMenu* K3PopupMenu::contextMenu()
404 {
405  if (!d->m_ctxMenu)
406  {
407  d->m_ctxMenu = new Q3PopupMenu(this);
408  connect(d->m_ctxMenu, SIGNAL(aboutToHide()), this, SLOT(ctxMenuHiding()));
409  }
410 
411  return d->m_ctxMenu;
412 }
413 
414 const Q3PopupMenu* K3PopupMenu::contextMenu() const
415 {
416  return const_cast< K3PopupMenu* >( this )->contextMenu();
417 }
418 
419 void K3PopupMenu::hideContextMenu()
420 {
421  K3PopupMenuPrivate::s_continueCtxMenuShow = false;
422 }
423 
424 QAction* K3PopupMenu::contextMenuFocusAction()
425 {
426  return K3PopupMenuPrivate::s_highlightedAction;
427 }
428 
429 K3PopupMenu* K3PopupMenu::contextMenuFocus()
430 {
431  return K3PopupMenuPrivate::s_contextedMenu;
432 }
433 
434 void K3PopupMenu::actionHovered(QAction* action)
435 {
436  if (!d->m_ctxMenu || !d->m_ctxMenu->isVisible())
437  {
438  return;
439  }
440 
441  d->m_ctxMenu->hide();
442  showCtxMenu(actionGeometry(action).center());
443 }
444 
445 void K3PopupMenu::showCtxMenu(const QPoint &pos)
446 {
447  if (K3PopupMenuPrivate::s_highlightedAction)
448  if (QMenu* subMenu = K3PopupMenuPrivate::s_highlightedAction->menu())
449  disconnect(subMenu, SIGNAL(aboutToShow()), this, SLOT(ctxMenuHideShowingMenu()));
450 
451  K3PopupMenuPrivate::s_highlightedAction = activeAction();
452  K3PopupMenuPrivate::s_highlightedItem = itemAtPos(pos);
453 
454  if (!K3PopupMenuPrivate::s_highlightedAction)
455  {
456  K3PopupMenuPrivate::s_contextedMenu = 0;
457  return;
458  }
459 
460  emit aboutToShowContextMenu(this, K3PopupMenuPrivate::s_highlightedAction, d->m_ctxMenu);
461  emit aboutToShowContextMenu(this, K3PopupMenuPrivate::s_highlightedItem, d->m_ctxMenu);
462 
463  if (QMenu* subMenu = K3PopupMenuPrivate::s_highlightedAction->menu())
464  {
465  connect(subMenu, SIGNAL(aboutToShow()), SLOT(ctxMenuHideShowingMenu()));
466  QTimer::singleShot(100, subMenu, SLOT(hide()));
467  }
468 
469  if (!K3PopupMenuPrivate::s_continueCtxMenuShow)
470  {
471  K3PopupMenuPrivate::s_continueCtxMenuShow = true;
472  return;
473  }
474 
475  K3PopupMenuPrivate::s_contextedMenu = this;
476  d->m_ctxMenu->exec(this->mapToGlobal(pos));
477  connect(this, SIGNAL(hovered(QAction*)), SLOT(actionHovered(QAction*)));
478 }
479 
480 /*
481  * this method helps prevent submenus popping up while we have a context menu
482  * showing
483  */
484 void K3PopupMenu::ctxMenuHideShowingMenu()
485 {
486  if (K3PopupMenuPrivate::s_highlightedAction)
487  if (QMenu* subMenu = K3PopupMenuPrivate::s_highlightedAction->menu())
488  QTimer::singleShot(0, subMenu, SLOT(hide()));
489 }
490 
491 void K3PopupMenu::ctxMenuHiding()
492 {
493  if (K3PopupMenuPrivate::s_highlightedAction)
494  if (QMenu* subMenu = K3PopupMenuPrivate::s_highlightedAction->menu())
495  disconnect(subMenu, SIGNAL(aboutToShow()), this, SLOT(ctxMenuHideShowingMenu()));
496 
497  connect(this, SIGNAL(hovered(QAction*)), this, SLOT(actionHovered(QAction*)));
498  K3PopupMenuPrivate::s_continueCtxMenuShow = true;
499 }
500 
501 void K3PopupMenu::contextMenuEvent(QContextMenuEvent* e)
502 {
503  if (d->m_ctxMenu)
504  {
505  if (e->reason() == QContextMenuEvent::Mouse)
506  {
507  showCtxMenu(e->pos());
508  }
509  else if (activeAction())
510  {
511  showCtxMenu(actionGeometry(activeAction()).center());
512  }
513 
514  e->accept();
515  return;
516  }
517 
518  Q3PopupMenu::contextMenuEvent(e);
519 }
520 
521 void K3PopupMenu::hideEvent(QHideEvent *e)
522 {
523  if (d->m_ctxMenu && d->m_ctxMenu->isVisible())
524  {
525  // we need to block signals here when the ctxMenu is showing
526  // to prevent the QPopupMenu::activated(int) signal from emitting
527  // when hiding with a context menu, the user doesn't expect the
528  // menu to actually do anything.
529  // since hideEvent gets called very late in the process of hiding
530  // (deep within QWidget::hide) the activated(int) signal is the
531  // last signal to be emitted, even after things like aboutToHide()
532  // AJS
533  bool blocked = blockSignals(true);
534  d->m_ctxMenu->hide();
535  blockSignals(blocked);
536  }
537  Q3PopupMenu::hideEvent(e);
538 }
543 void K3PopupMenu::virtual_hook( int, void* )
544 { /*BASE::virtual_hook( id, data );*/ }
545 
546 
547 K3PopupMenu::K3PopupMenu(const QString &title, QWidget *parent)
548  : Q3PopupMenu(parent)
549  , d(new K3PopupMenuPrivate())
550 {
551  resetKeyboardVars();
552  connect(&(d->clearTimer), SIGNAL(timeout()), SLOT(resetKeyboardVars()));
553  addAction(title);
554 }
555 
556 #ifdef QT3_SUPPORT
557 int K3PopupMenu::insertTitle(const QString &text, int id, int index)
558 {
559  int newid = insertItem(text, id, index);
560  QMenuItem* menuItem = findItem(newid);
561  Q_ASSERT(menuItem);
562  menuItem->setEnabled(false);
563  QFont f = menuItem->font();
564  f.setBold(true);
565  menuItem->setFont(f);
566  return newid;
567 }
568 
569 int K3PopupMenu::insertTitle(const QPixmap &icon, const QString &text, int id, int index)
570 {
571  int newid = insertItem(text, id, index);
572  QMenuItem* menuItem = findItem(newid);
573  Q_ASSERT(menuItem);
574  menuItem->setEnabled(false);
575  menuItem->setIcon(icon);
576  QFont f = menuItem->font();
577  f.setBold(true);
578  menuItem->setFont(f);
579  return newid;
580 }
581 
582 void K3PopupMenu::changeTitle(int id, const QString &text)
583 {
584  QMenuItem* menuItem = findItem(id);
585  Q_ASSERT(menuItem);
586  if (!menuItem)
587  return;
588  menuItem->setText(text);
589  menuItem->setIcon(QIcon());
590  return;
591 }
592 
593 void K3PopupMenu::changeTitle(int id, const QPixmap &icon, const QString &text)
594 {
595  QMenuItem* menuItem = findItem(id);
596  Q_ASSERT(menuItem);
597  if (!menuItem)
598  return;
599  menuItem->setText(text);
600  menuItem->setIcon(icon);
601  return;
602 }
603 
604 QString K3PopupMenu::title(int id) const
605 {
606  QMenuItem* menuItem = findItem(id);
607  Q_ASSERT(menuItem);
608  if (!menuItem)
609  return QString();
610  return menuItem->text();
611 }
612 
613 QPixmap K3PopupMenu::titlePixmap(int id) const
614 {
615  QMenuItem* menuItem = findItem(id);
616  Q_ASSERT(menuItem);
617  if (!menuItem)
618  return QPixmap();
619  return menuItem->icon().pixmap();
620 }
621 
622 void K3PopupMenu::setTitle(const QString &title)
623 {
624  addAction(title);
625 }
626 
627 int K3PopupMenu::contextMenuFocusItem()
628 {
629  return K3PopupMenuPrivate::s_highlightedItem;
630 }
631 
632 #endif // END compat methods
633 
634 #include "k3popupmenu.moc"
QHideEvent
QMenu::hovered
void hovered(QAction *action)
QAction::text
text
K3PopupMenu::virtual_hook
virtual void virtual_hook(int id, void *data)
end of RMB menus on menus support
Definition: k3popupmenu.cpp:543
K3PopupMenu::keyPressEvent
virtual void keyPressEvent(QKeyEvent *e)
Definition: k3popupmenu.cpp:167
QMenu::aboutToHide
void aboutToHide()
K3PopupMenu::hideContextMenu
void hideContextMenu()
Hides the context menu if shown.
Definition: k3popupmenu.cpp:419
QWidget
QKeyEvent::modifiers
Qt::KeyboardModifiers modifiers() const
kdebug.h
K3PopupMenu::~K3PopupMenu
~K3PopupMenu()
Destructs the object.
Definition: k3popupmenu.cpp:96
QAction::font
font
QMouseEvent::state
Qt::ButtonState state() const
K3PopupMenu::K3PopupMenu
K3PopupMenu(QWidget *parent=0)
Constructs a K3PopupMenu.
Definition: k3popupmenu.cpp:88
K3PopupMenu
A menu with keyboard searching and convenience methods for title items.
Definition: k3popupmenu.h:49
K3PopupMenu::titlePixmap
QPixmap titlePixmap(int id) const
Returns the icon of the title item at the specified id.
Definition: k3popupmenu.cpp:613
QMenu::focusNextPrevChild
virtual bool focusNextPrevChild(bool next)
timeout
int timeout
K3PopupMenu::resetKeyboardVars
void resetKeyboardVars(bool noMatches=false)
Definition: k3popupmenu.cpp:346
QFont
QMenu::itemAtPos
int itemAtPos(const QPoint &p, bool ignoreSeparator)
QMenu::setActiveAction
void setActiveAction(QAction *act)
K3PopupMenu::aboutToShowContextMenu
void aboutToShowContextMenu(K3PopupMenu *menu, QAction *menuAction, QMenu *ctxMenu)
connect to this signal to be notified when a context menu is about to be shown
QAction::setIcon
void setIcon(const QIcon &icon)
QMenu::addAction
void addAction(QAction *action)
QPointer< QAction >
k3popupmenu.h
QWidget::mapToGlobal
QPoint mapToGlobal(const QPoint &pos) const
K3PopupMenu::focusNextPrevChild
virtual bool focusNextPrevChild(bool next)
Definition: k3popupmenu.cpp:330
K3PopupMenu::hideEvent
virtual void hideEvent(QHideEvent *)
Definition: k3popupmenu.cpp:521
K3PopupMenu::setKeyboardShortcutsExecute
void setKeyboardShortcutsExecute(bool enable)
Enables execution of the menu item once it is uniquely specified.
Definition: k3popupmenu.cpp:366
Q3PopupMenu::Q3PopupMenu
Q3PopupMenu(QWidget *parent, const char *name)
K3PopupMenu::mouseButtons
Qt::MouseButtons mouseButtons() const
Return the state of the mouse buttons when the last menuitem was activated.
Definition: k3popupmenu.cpp:157
QPoint
QMouseEvent
QMenu::actionGeometry
QRect actionGeometry(QAction *act) const
QMouseEvent::buttons
Qt::MouseButtons buttons() const
K3PopupMenu::contextMenuFocus
static K3PopupMenu * contextMenuFocus()
Returns the K3PopupMenu associated with the current context menu.
Definition: k3popupmenu.cpp:429
QMenu::activateItemAt
void activateItemAt(int index)
QMenuItem
klocale.h
QObject::disconnect
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
K3PopupMenu::mouseReleaseEvent
virtual void mouseReleaseEvent(QMouseEvent *e)
Definition: k3popupmenu.cpp:389
QKeyEvent::state
Qt::ButtonState state() const
K3PopupMenu::addTitle
QAction * addTitle(const QString &text, QAction *before=0L)
Inserts a title item with no icon.
Definition: k3popupmenu.cpp:108
Q3PopupMenu
QFont::setBold
void setBold(bool enable)
K3PopupMenu::mousePressEvent
virtual void mousePressEvent(QMouseEvent *e)
End keyboard navigation.
Definition: k3popupmenu.cpp:378
QCloseEvent
kglobal.h
QWidget::insertAction
void insertAction(QAction *before, QAction *action)
QMenu::aboutToShow
void aboutToShow()
QWidget::contextMenuEvent
virtual void contextMenuEvent(QContextMenuEvent *event)
QString::insert
QString & insert(int position, QChar ch)
QTimer
K3PopupMenu::contextMenuFocusAction
static QAction * contextMenuFocusAction()
returns the QAction associated with the current context menu
Definition: k3popupmenu.cpp:424
QContextMenuEvent
QMenu::mousePressEvent
virtual void mousePressEvent(QMouseEvent *e)
QMouseEvent::button
Qt::MouseButton button() const
QKeyEvent::text
QString text() const
K3PopupMenu::keyboardModifiers
Qt::KeyboardModifiers keyboardModifiers() const
Return the state of the keyboard modifiers when the last menuitem was activated.
Definition: k3popupmenu.cpp:162
K3PopupMenu::contextMenuEvent
virtual void contextMenuEvent(QContextMenuEvent *e)
Definition: k3popupmenu.cpp:501
K3PopupMenu::actionHovered
void actionHovered(QAction *action)
Definition: k3popupmenu.cpp:434
Qt::ButtonState
typedef ButtonState
QMenu::title
QString title() const
QString
QWidget::hide
void hide()
QT3_SUPPORT
#define QT3_SUPPORT
Definition: k3popupmenu.h:23
K3PopupMenu::setTitle
void setTitle(const QString &title)
Definition: k3popupmenu.cpp:622
K3PopupMenu::activateItemAt
virtual void activateItemAt(int index)
Reimplemented for internal purposes.
Definition: k3popupmenu.cpp:140
K3PopupMenu::insertTitle
int insertTitle(const QString &text, int id=-1, int index=-1)
Inserts a title item with no icon.
Definition: k3popupmenu.cpp:557
QMenu::hideEvent
virtual void hideEvent(QHideEvent *)
QPixmap
QInputEvent::modifiers
Qt::KeyboardModifiers modifiers() const
QKeyEvent::key
int key() const
QMenu
QEvent::accept
void accept()
QObject::blockSignals
bool blockSignals(bool block)
QString::contains
bool contains(QChar ch, Qt::CaseSensitivity cs) const
K3PopupMenu::changeTitle
void changeTitle(int id, const QString &text)
Changes the title of the item at the specified id.
Definition: k3popupmenu.cpp:582
K3PopupMenu::showCtxMenu
void showCtxMenu(const QPoint &pos)
Definition: k3popupmenu.cpp:445
KGlobal::locale
KLocale * locale()
KLocale::removeAcceleratorMarker
QString removeAcceleratorMarker(const QString &label) const
QKeyEvent
K3PopupMenu::contextMenu
Q3PopupMenu * contextMenu()
Returns the context menu associated with this menu.
Definition: k3popupmenu.cpp:403
QContextMenuEvent::pos
const QPoint & pos() const
Qt::MouseButtons
typedef MouseButtons
K3PopupMenu::ctxMenuHideShowingMenu
void ctxMenuHideShowingMenu()
Definition: k3popupmenu.cpp:484
K3PopupMenu::contextMenuFocusItem
static int contextMenuFocusItem()
returns the ID of the menuitem associated with the current context menu
Definition: k3popupmenu.cpp:627
QAction
QMenu::findItem
QMenuItem * findItem(int id) const
QString::left
QString left(int n) const
K3PopupMenu::setKeyboardShortcutsEnabled
void setKeyboardShortcutsEnabled(bool enable)
Enables keyboard navigation by searching for the entered key sequence.
Definition: k3popupmenu.cpp:361
QMenu::menuAction
QAction * menuAction() const
QMenu::insertItem
int insertItem(const QString &text, const QObject *receiver, const char *member, const QKeySequence &shortcut, int id, int index)
QWidget::closeEvent
virtual void closeEvent(QCloseEvent *event)
QContextMenuEvent::reason
Reason reason() const
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QWidget::actions
QList< QAction * > actions() const
QMenu::mouseReleaseEvent
virtual void mouseReleaseEvent(QMouseEvent *e)
K3PopupMenu::state
Qt::ButtonState state() const
Return the state of the mouse button and keyboard modifiers when the last menuitem was activated...
Definition: k3popupmenu.cpp:151
K3PopupMenu::closeEvent
virtual void closeEvent(QCloseEvent *)
This is re-implemented for keyboard navigation.
Definition: k3popupmenu.cpp:133
QMenu::text
QString text(int id) const
K3PopupMenu::underlineText
QString underlineText(const QString &text, uint length)
Definition: k3popupmenu.cpp:336
QAction::setEnabled
void setEnabled(bool)
QMenu::activeAction
QAction * activeAction() const
K3PopupMenu::ctxMenuHiding
void ctxMenuHiding()
Definition: k3popupmenu.cpp:491
QIcon
QMenu::keyPressEvent
virtual void keyPressEvent(QKeyEvent *e)
QTimer::singleShot
singleShot
Qt::KeyboardModifiers
typedef KeyboardModifiers
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:26:48 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDE3Support

Skip menu "KDE3Support"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal