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

KDEUI

ktoolbarpopupaction.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002     Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org>
00003               (C) 1999 Simon Hausmann <hausmann@kde.org>
00004               (C) 2000 Nicolas Hadacek <haadcek@kde.org>
00005               (C) 2000 Kurt Granroth <granroth@kde.org>
00006               (C) 2000 Michael Koch <koch@kde.org>
00007               (C) 2001 Holger Freyther <freyther@kde.org>
00008               (C) 2002 Ellis Whitehead <ellis@kde.org>
00009               (C) 2002 Joseph Wenninger <jowenn@kde.org>
00010               (C) 2003 Andras Mantia <amantia@kde.org>
00011               (C) 2005-2006 Hamish Rodda <rodda@kde.org>
00012 
00013     This library is free software; you can redistribute it and/or
00014     modify it under the terms of the GNU Library General Public
00015     License version 2 as published by the Free Software Foundation.
00016 
00017     This library is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020     Library General Public License for more details.
00021 
00022     You should have received a copy of the GNU Library General Public License
00023     along with this library; see the file COPYING.LIB.  If not, write to
00024     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00025     Boston, MA 02110-1301, USA.
00026 */
00027 
00028 #include "ktoolbarpopupaction.h"
00029 #include "kmenu.h"
00030 
00031 #include <QtGui/QToolBar>
00032 #include <QtGui/QToolButton>
00033 
00034 #include <kdebug.h>
00035 #include <klocale.h>
00036 #include <kicon.h>
00037 
00038 class KToolBarPopupAction::Private
00039 {
00040   public:
00041     Private()
00042       : delayed( true ), stickyMenu( true )
00043     {
00044     }
00045 
00046     bool delayed:1;
00047     bool stickyMenu:1;
00048 };
00049 
00050 KToolBarPopupAction::KToolBarPopupAction(const KIcon& icon, const QString& text, QObject *parent)
00051   : KAction(icon, text, parent),
00052     d( new Private )
00053 {
00054   setMenu( new KMenu );
00055 }
00056 
00057 KToolBarPopupAction::~KToolBarPopupAction()
00058 {
00059   delete d;
00060   delete menu();
00061 }
00062 
00063 KMenu* KToolBarPopupAction::popupMenu() const
00064 {
00065   return qobject_cast<KMenu*>( menu() );
00066 }
00067 
00068 QWidget * KToolBarPopupAction::createWidget( QWidget * _parent )
00069 {
00070   QToolBar *parent = qobject_cast<QToolBar *>(_parent);
00071   if (!parent)
00072     return KAction::createWidget(_parent);
00073   QToolButton* button = new QToolButton( parent );
00074   button->setAutoRaise( true );
00075   button->setFocusPolicy( Qt::NoFocus );
00076   button->setIconSize( parent->iconSize() );
00077   button->setToolButtonStyle( parent->toolButtonStyle() );
00078   button->setDefaultAction( this );
00079 
00080   connect( parent, SIGNAL( iconSizeChanged( const QSize& ) ),
00081            button, SLOT( setIconSize( const QSize& ) ) );
00082   connect( parent, SIGNAL( toolButtonStyleChanged( Qt::ToolButtonStyle ) ),
00083            button, SLOT( setToolButtonStyle( Qt::ToolButtonStyle ) ) );
00084   connect( button, SIGNAL( triggered( QAction* ) ),
00085            parent, SIGNAL( actionTriggered( QAction* ) ) );
00086 
00087   if ( d->delayed )
00088     if ( d->stickyMenu )
00089       button->setPopupMode( QToolButton::MenuButtonPopup );
00090     else
00091       button->setPopupMode( QToolButton::DelayedPopup );
00092   else
00093     button->setPopupMode( QToolButton::InstantPopup );
00094 
00095   return button;
00096 }
00097 
00098 bool KToolBarPopupAction::delayed() const
00099 {
00100   return d->delayed;
00101 }
00102 
00103 void KToolBarPopupAction::setDelayed( bool delayed )
00104 {
00105   d->delayed = delayed;
00106 }
00107 
00108 bool KToolBarPopupAction::stickyMenu() const
00109 {
00110   return d->stickyMenu;
00111 }
00112 
00113 void KToolBarPopupAction::setStickyMenu( bool sticky )
00114 {
00115   d->stickyMenu = sticky;
00116 }
00117 
00118 #include "ktoolbarpopupaction.moc"

KDEUI

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal