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" 42 const std::string & label )
43 : QWidget( (QWidget *) parent->widgetRep() )
44 , YPushButton( parent, label )
55 _qPushButton->installEventFilter(
this );
56 _qPushButton->setAutoDefault(
true );
58 YPushButton::setLabel( toUTF8 ( _qPushButton->text() ) );
75 void YQGenericButton::forgetDialog()
86 YDialog * yDialog = findDialog();
89 _dialog =
dynamic_cast<YQDialog *
> (yDialog);
91 YUI_CHECK_PTR( _dialog );
101 _qPushButton->setEnabled( enabled );
103 YWidget::setEnabled( enabled );
109 return _qPushButton ? _qPushButton->isEnabled() :
false;
115 if ( ! _qPushButton )
117 yuiError() <<
"NULL button (icon " << iconName <<
")" << std::endl;
121 QString qIconName = fromUTF8( iconName );
123 if ( qIconName.isEmpty() )
125 _qPushButton->setIcon( QIcon() );
133 QIcon icon = QIcon::fromTheme ( iconName.c_str() );
136 yuiWarning() <<
"Can't load icon \"" << qIconName <<
"\"" << std::endl;
138 _qPushButton->setIcon( icon );
145 _qPushButton->setText( label );
147 yuiError() <<
"NULL button \"" << label <<
"\"" << std::endl;
149 YPushButton::setLabel( toUTF8( label ) );
156 _qPushButton->setText( fromUTF8( label ) );
158 yuiError() <<
"NULL button \"" << label <<
"\"" << std::endl;
160 YPushButton::setLabel( label );
168 _qPushButton->setAutoDefault( !show );
169 _qPushButton->setDefault( show );
170 _qPushButton->update();
177 return _qPushButton ? _qPushButton->isDefault() :
false;
184 return _qPushButton ? _qPushButton->text() :
"";
191 _qPushButton->animateClick();
199 if ( event->type() == QEvent::FocusIn )
204 else if ( event->type() == QEvent::FocusOut )
209 else if ( event->type() == QEvent::MouseButtonRelease )
211 QMouseEvent * mouseEvent =
dynamic_cast<QMouseEvent *
> (event);
213 if ( mouseEvent && mouseEvent->button() == Qt::RightButton )
215 yuiMilestone() <<
"Right click on button detected" << std::endl;
222 return QObject::eventFilter( obj, event );
228 if ( ! _qPushButton )
232 _qPushButton->setFocus();
239 _qPushButton->setShortcut (key );
static YQApplication * yqApp()
Return the global YApplication object as YQApplication.
YQGenericButton * defaultButton() const
Returns the dialog's default button - the button that is activated with [Return] if no button has the...
void maybeLeftHandedUser()
A mouse click with the wrong mouse button was detected - e.g., a right click on a push button...
YQGenericButton * focusButton() const
Returns the button that has the keyboard focus or 0 if no button has the keyboard focus...
void gettingFocus(YQGenericButton *button)
Notification that a button gets 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.