certmanager

customactions.cpp
1 /*
2  customactions.cpp
3 
4  This file is part of Kleopatra, the KDE keymanager
5  Copyright (c) 2001,2002,2004 Klar�lvdalens Datakonsult AB
6 
7  Kleopatra is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  Kleopatra is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21  In addition, as a special exception, the copyright holders give
22  permission to link the code of this program with any edition of
23  the TQt library by Trolltech AS, Norway (or with modified versions
24  of TQt that use the same license as TQt), and distribute linked
25  combinations including the two. You must obey the GNU General
26  Public License in all respects for all of the code used other than
27  TQt. If you modify this file, you may extend this exception to
28  your version of the file, but you are not obligated to do so. If
29  you do not wish to do so, delete this exception statement from
30  your version.
31 */
32 
33 #include "customactions.h"
34 
35 #include <tdetoolbar.h>
36 #include <tdeapplication.h>
37 
38 #include <tqlineedit.h>
39 #include <tqlabel.h>
40 
41 
42 LabelAction::LabelAction( const TQString & text, TDEActionCollection * parent,
43  const char* name )
44  : TDEAction( text, TQIconSet(), TDEShortcut(), 0, 0, parent, name )
45 {
46 
47 }
48 
49 int LabelAction::plug( TQWidget * widget, int index ) {
50  if ( kapp && !kapp->authorizeTDEAction( name() ) )
51  return -1;
52  if ( widget->inherits( "TDEToolBar" ) ) {
53  TDEToolBar * bar = (TDEToolBar *)widget;
54  int id_ = getToolButtonID();
55  TQLabel* label = new TQLabel( text(), bar, "tde toolbar widget" );
56  bar->insertWidget( id_, label->width(), label, index );
57  addContainer( bar, id_ );
58  connect( bar, TQ_SIGNAL( destroyed() ), this, TQ_SLOT( slotDestroyed() ) );
59  return containerCount() - 1;
60  }
61 
62  return TDEAction::plug( widget, index );
63 }
64 
65 LineEditAction::LineEditAction( const TQString & text, TDEActionCollection * parent,
66  TQObject * receiver, const char * member, const char * name )
67  : TDEAction( text, TQIconSet(), TDEShortcut(), 0, 0, parent, name ),
68  _le(0), _receiver(receiver), _member(member)
69 {
70 
71 }
72 
73 int LineEditAction::plug( TQWidget * widget, int index ) {
74  if ( kapp && !kapp->authorizeTDEAction( name() ) )
75  return -1;
76  if ( widget->inherits( "TDEToolBar" ) ) {
77  TDEToolBar *bar = (TDEToolBar *)widget;
78  int id_ = getToolButtonID();
79  // The toolbar trick doesn't seem to work for lineedits
80  //_le = new TQLineEdit( bar, "tde toolbar widget" );
81  _le = new TQLineEdit( bar );
82  bar->insertWidget( id_, _le->width(), _le, index );
83  bar->setStretchableWidget( _le );
84  addContainer( bar, id_ );
85  connect( bar, TQ_SIGNAL( destroyed() ), this, TQ_SLOT( slotDestroyed() ) );
86  connect( _le, TQ_SIGNAL( returnPressed() ), _receiver, _member );
87  return containerCount() - 1;
88  }
89 
90  return TDEAction::plug( widget, index );
91 }
92 
93 void LineEditAction::clear() {
94  _le->clear();
95 }
96 
97 void LineEditAction::focusAll() {
98  _le->selectAll();
99  _le->setFocus();
100 }
101 
102 TQString LineEditAction::text() const {
103  return _le->text();
104 }
105 
106 void LineEditAction::setText( const TQString & txt ) {
107  _le->setText(txt);
108 }
109 
110 
111 ComboAction::ComboAction( const TQStringList & lst, TDEActionCollection * parent,
112  TQObject * receiver, const char * member, const char * name,
113  int selectedID )
114  : TDEAction( TQString(), TQIconSet(), TDEShortcut(), 0, 0, parent, name ),
115  _lst(lst), _receiver(receiver), _member(member), _selectedId( selectedID )
116 {
117 
118 }
119 
120 int ComboAction::plug( TQWidget * widget, int index ) {
121  if ( kapp && !kapp->authorizeTDEAction( name() ) )
122  return -1;
123  if ( widget->inherits( "TDEToolBar" ) ) {
124  TDEToolBar *bar = (TDEToolBar *)widget;
125  int id_ = getToolButtonID();
126  bar->insertCombo( _lst, id_, false, TQ_SIGNAL( highlighted(int) ), _receiver, _member );
127  bar->setCurrentComboItem( id_,_selectedId );
128  addContainer( bar, id_ );
129  connect( bar, TQ_SIGNAL( destroyed() ), this, TQ_SLOT( slotDestroyed() ) );
130  return containerCount() - 1;
131  }
132 
133  return TDEAction::plug( widget, index );
134 }
135 
136 #include "customactions.moc"