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 "customactions.h"
00034
00035
#include <ktoolbar.h>
00036
#include <kapplication.h>
00037
00038
#include <qlineedit.h>
00039
#include <qlabel.h>
00040
00041
00042 LabelAction::LabelAction(
const QString & text, KActionCollection * parent,
00043
const char* name )
00044 : KAction( text,
QIconSet(), KShortcut(), 0, 0, parent, name )
00045 {
00046
00047 }
00048
00049
int LabelAction::plug(
QWidget * widget,
int index ) {
00050
if ( kapp && !kapp->authorizeKAction( name() ) )
00051
return -1;
00052
if ( widget->inherits(
"KToolBar" ) ) {
00053 KToolBar * bar = (KToolBar *)widget;
00054
int id_ = getToolButtonID();
00055
QLabel* label =
new QLabel( text(), bar,
"kde toolbar widget" );
00056 bar->insertWidget( id_, label->width(), label, index );
00057 addContainer( bar, id_ );
00058 connect( bar, SIGNAL( destroyed() ),
this, SLOT( slotDestroyed() ) );
00059
return containerCount() - 1;
00060 }
00061
00062
return KAction::plug( widget, index );
00063 }
00064
00065 LineEditAction::LineEditAction(
const QString & text, KActionCollection * parent,
00066
QObject * receiver,
const char * member,
const char * name )
00067 : KAction( text,
QIconSet(), KShortcut(), 0, 0, parent, name ),
00068 _le(0), _receiver(receiver), _member(member)
00069 {
00070
00071 }
00072
00073
int LineEditAction::plug(
QWidget * widget,
int index ) {
00074
if ( kapp && !kapp->authorizeKAction( name() ) )
00075
return -1;
00076
if ( widget->inherits(
"KToolBar" ) ) {
00077 KToolBar *bar = (KToolBar *)widget;
00078
int id_ = getToolButtonID();
00079
00080
00081 _le =
new QLineEdit( bar );
00082 bar->insertWidget( id_, _le->width(), _le, index );
00083 bar->setStretchableWidget( _le );
00084 addContainer( bar, id_ );
00085 connect( bar, SIGNAL( destroyed() ),
this, SLOT( slotDestroyed() ) );
00086 connect( _le, SIGNAL( returnPressed() ), _receiver, _member );
00087
return containerCount() - 1;
00088 }
00089
00090
return KAction::plug( widget, index );
00091 }
00092
00093
void LineEditAction::clear() {
00094 _le->clear();
00095 }
00096
00097
void LineEditAction::focusAll() {
00098 _le->selectAll();
00099 _le->setFocus();
00100 }
00101
00102
QString LineEditAction::text()
const {
00103
return _le->text();
00104 }
00105
00106
void LineEditAction::setText(
const QString & txt ) {
00107 _le->setText(txt);
00108 }
00109
00110
00111 ComboAction::ComboAction(
const QStringList & lst, KActionCollection * parent,
00112
QObject * receiver,
const char * member,
const char * name )
00113 : KAction(
QString::null,
QIconSet(), KShortcut(), 0, 0, parent, name ),
00114 _lst(lst), _receiver(receiver), _member(member)
00115 {
00116
00117 }
00118
00119
int ComboAction::plug(
QWidget * widget,
int index ) {
00120
if ( kapp && !kapp->authorizeKAction( name() ) )
00121
return -1;
00122
if ( widget->inherits(
"KToolBar" ) ) {
00123 KToolBar *bar = (KToolBar *)widget;
00124
int id_ = getToolButtonID();
00125 bar->insertCombo( _lst, id_,
false, SIGNAL( highlighted(
int) ), _receiver, _member );
00126 addContainer( bar, id_ );
00127 connect( bar, SIGNAL( destroyed() ),
this, SLOT( slotDestroyed() ) );
00128
return containerCount() - 1;
00129 }
00130
00131
return KAction::plug( widget, index );
00132 }
00133
00134
#include "customactions.moc"