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" 44 const string & label )
45 : QWidget( (QWidget *) parent->widgetRep() )
46 , YPushButton( parent, label )
57 _qPushButton->installEventFilter(
this );
58 _qPushButton->setAutoDefault(
true );
60 YPushButton::setLabel( toUTF8 ( _qPushButton->text() ) );
77 void YQGenericButton::forgetDialog()
88 YDialog * yDialog = findDialog();
91 _dialog =
dynamic_cast<YQDialog *
> (yDialog);
93 YUI_CHECK_PTR( _dialog );
103 _qPushButton->setEnabled( enabled );
105 YWidget::setEnabled( enabled );
111 return _qPushButton ? _qPushButton->isEnabled() :
false;
117 if ( ! _qPushButton )
119 yuiError() <<
"NULL button (icon " << iconName <<
")" << endl;
123 QString qIconName = fromUTF8( iconName );
125 if ( qIconName.isEmpty() )
127 _qPushButton->setIcon( QIcon() );
135 QIcon icon = QIcon::fromTheme ( iconName.c_str() );
138 yuiWarning() <<
"Can't load icon \"" << qIconName <<
"\"" << endl;
140 _qPushButton->setIcon( icon );
147 _qPushButton->setText( label );
149 yuiError() <<
"NULL button \"" << label <<
"\"" << endl;
151 YPushButton::setLabel( toUTF8( label ) );
158 _qPushButton->setText( fromUTF8( label ) );
160 yuiError() <<
"NULL button \"" << label <<
"\"" << endl;
162 YPushButton::setLabel( label );
170 _qPushButton->setAutoDefault( !show );
171 _qPushButton->setDefault( show );
172 _qPushButton->update();
179 return _qPushButton ? _qPushButton->isDefault() :
false;
186 return _qPushButton ? _qPushButton->text() :
"";
193 _qPushButton->animateClick();
201 if ( event->type() == QEvent::FocusIn )
206 else if ( event->type() == QEvent::FocusOut )
211 else if ( event->type() == QEvent::MouseButtonRelease )
213 QMouseEvent * mouseEvent =
dynamic_cast<QMouseEvent *
> (event);
215 if ( mouseEvent && mouseEvent->button() == Qt::RightButton )
217 yuiMilestone() <<
"Right click on button detected" << endl;
224 return QObject::eventFilter( obj, event );
230 if ( ! _qPushButton )
234 _qPushButton->setFocus();
241 _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.