kleopatra
action_data.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include <config-kleopatra.h>
00034
00035 #include "action_data.h"
00036
00037 #include <KToggleAction>
00038 #include <KActionCollection>
00039
00040 KAction * Kleo::make_action_from_data( const action_data & ad, QObject * parent ) {
00041
00042 KAction * const a = ad.toggle ? new KToggleAction( parent ) : new KAction( parent ) ;
00043 a->setObjectName( ad.name );
00044 a->setText( ad.text );
00045 if ( !ad.tooltip.isEmpty() )
00046 a->setToolTip( ad.tooltip );
00047 if ( ad.icon )
00048 a->setIcon( KIcon( ad.icon ) );
00049 if ( ad.receiver && ad.slot )
00050 if ( ad.toggle )
00051 QObject::connect( a, SIGNAL(toggled(bool)), ad.receiver, ad.slot );
00052 else
00053 QObject::connect( a, SIGNAL(triggered()), ad.receiver, ad.slot );
00054 if ( !ad.shortcut.isEmpty() )
00055 a->setShortcuts( KShortcut( ad.shortcut ) );
00056 a->setEnabled( ad.enabled );
00057 return a;
00058 }
00059
00060 void Kleo::make_actions_from_data( const action_data * ads, unsigned int size, QObject * parent ) {
00061 for ( unsigned int i = 0 ; i < size ; ++i )
00062 make_action_from_data( ads[i], parent );
00063 }
00064
00065 void Kleo::make_actions_from_data( const action_data * ads, unsigned int size, KActionCollection * coll ) {
00066 for ( unsigned int i = 0 ; i < size ; ++i )
00067 coll->addAction( ads[i].name, make_action_from_data( ads[i], coll ) );
00068 }