26 #include <qpushbutton.h>
30 #define YUILogComponent "qt-ui"
31 #include <yui/YUILog.h>
35 #include "YQApplication.h"
36 #include <yui/YEvent.h>
37 #include "YQGenericButton.h"
45 const string & label )
46 : QWidget( (QWidget *) parent->widgetRep() )
47 , YPushButton( parent, label )
58 _qPushButton->installEventFilter(
this );
59 _qPushButton->setAutoDefault(
true );
61 YPushButton::setLabel( toUTF8 ( _qPushButton->text() ) );
78 void YQGenericButton::forgetDialog()
89 YDialog * yDialog = findDialog();
92 _dialog =
dynamic_cast<YQDialog *
> (yDialog);
94 YUI_CHECK_PTR( _dialog );
104 _qPushButton->setEnabled( enabled );
106 YWidget::setEnabled( enabled );
112 return _qPushButton ? _qPushButton->isEnabled() :
false;
118 if ( ! _qPushButton )
120 yuiError() <<
"NULL button (icon " << iconName <<
")" << endl;
124 QString qIconName = fromUTF8( iconName );
126 if ( qIconName.isEmpty() )
128 _qPushButton->setIcon( QIcon() );
136 QIcon icon = QIcon::fromTheme ( iconName.c_str() );
139 yuiWarning() <<
"Can't load icon \"" << qIconName <<
"\"" << endl;
141 _qPushButton->setIcon( icon );
148 _qPushButton->setText( label );
150 yuiError() <<
"NULL button \"" << label <<
"\"" << endl;
152 YPushButton::setLabel( toUTF8( label ) );
159 _qPushButton->setText( fromUTF8( label ) );
161 yuiError() <<
"NULL button \"" << label <<
"\"" << endl;
163 YPushButton::setLabel( label );
171 _qPushButton->setAutoDefault( !show );
172 _qPushButton->setDefault( show );
173 _qPushButton->update();
180 return _qPushButton ? _qPushButton->isDefault() :
false;
187 return _qPushButton ? _qPushButton->text() :
"";
194 _qPushButton->animateClick();
202 if ( event->type() == QEvent::FocusIn )
207 else if ( event->type() == QEvent::FocusOut )
212 else if ( event->type() == QEvent::MouseButtonRelease )
214 QMouseEvent * mouseEvent =
dynamic_cast<QMouseEvent *
> (event);
216 if ( mouseEvent && mouseEvent->button() == Qt::RightButton )
218 yuiMilestone() <<
"Right click on button detected" << endl;
225 return QObject::eventFilter( obj, event );
231 if ( ! _qPushButton )
235 _qPushButton->setFocus();
242 _qPushButton->setShortcut (key );
void maybeLeftHandedUser()
A mouse click with the wrong mouse button was detected - e.g., a right click on a push button.
YQGenericButton * defaultButton() const
Returns the dialog's default button - the button that is activated with [Return] if no button has the...
void gettingFocus(YQGenericButton *button)
Notification that a button gets the keyboard focus.
YQGenericButton * focusButton() const
Returns the button that has the keyboard focus or 0 if no button has the keyboard focus.
void setDefaultButton(YPushButton *newDefaultButton)
Set the dialog's default button - the button that is activated with [Return] if no other button has t...
void losingFocus(YQGenericButton *button)
Notification that a button loses the keyboard focus.
static YQApplication * yqApp()
Return the global YApplication object as YQApplication.