File indexing completed on 2024-10-13 04:22:08

0001 /*
0002     SPDX-FileCopyrightText: 1998-2009 Sebastian Trueg <trueg@k3b.org>
0003     SPDX-FileCopyrightText: 1998-2009 Sebastian Trueg <trueg@k3b.org>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #include "k3baction.h"
0009 
0010 QAction* K3b::createAction( QObject* parent,
0011                             const QString& text, const QString& icon, const
0012                             QKeySequence& shortcut, QObject* receiver, const char* slot,
0013                             KActionCollection* actionCollection,
0014                             const QString& actionName )
0015 {
0016     QAction* action = new QAction( parent );
0017     action->setText( text );
0018     if( !icon.isEmpty() ) {
0019         action->setIcon( QIcon::fromTheme( icon ) );
0020     }
0021     action->setShortcut( shortcut );
0022     if( receiver ) {
0023         QObject::connect( action, SIGNAL(triggered()),
0024                           receiver, slot );
0025     }
0026     if( actionCollection ) {
0027         actionCollection->addAction( actionName, action );
0028     }
0029     return action;
0030 }
0031 
0032 
0033 KToggleAction* K3b::createToggleAction( QObject* parent,
0034                                         const QString& text, const QString& icon, const
0035                                         QKeySequence& shortcut, QObject* receiver, const char* slot,
0036                                         KActionCollection* actionCollection,
0037                                         const QString& actionName )
0038 {
0039     KToggleAction* action = new KToggleAction( parent );
0040     action->setText( text );
0041     if( !icon.isEmpty() ) {
0042         action->setIcon( QIcon::fromTheme( icon ) );
0043     }
0044     action->setShortcut( shortcut );
0045     if( receiver ) {
0046         QObject::connect( action, SIGNAL(triggered(bool)),
0047                           receiver, slot );
0048     }
0049     if( actionCollection ) {
0050         actionCollection->addAction( actionName, action );
0051     }
0052     return action;
0053 }