26 #include <qpushbutton.h> 31 #define YUILogComponent "qt-ui" 32 #include <yui/YUILog.h> 36 #include "YQApplication.h" 37 #include <yui/YEvent.h> 38 #include "YQGenericButton.h" 43 const std::string & label )
44 : QWidget( (QWidget *) parent->widgetRep() )
45 , YPushButton( parent, label )
56 _qPushButton->installEventFilter(
this );
57 _qPushButton->setAutoDefault(
true );
59 YPushButton::setLabel( toUTF8 ( _qPushButton->text() ) );
76 void YQGenericButton::forgetDialog()
87 YDialog * yDialog = findDialog();
90 _dialog =
dynamic_cast<YQDialog *
> (yDialog);
92 YUI_CHECK_PTR( _dialog );
102 _qPushButton->setEnabled( enabled );
104 YWidget::setEnabled( enabled );
110 return _qPushButton ? _qPushButton->isEnabled() :
false;
116 if ( ! _qPushButton )
118 yuiError() <<
"NULL button (icon " << iconName <<
")" << std::endl;
122 QString qIconName = fromUTF8( iconName );
124 if ( qIconName.isEmpty() )
126 _qPushButton->setIcon( QIcon() );
131 qIconName = fromUTF8(
YQUI::yqApp()->iconLoader()->findIcon( iconName ) );
132 QPixmap icon( qIconName );
135 yuiWarning() <<
"Can't load icon \"" << qIconName <<
"\"" << std::endl;
137 _qPushButton->setIcon( icon );
144 _qPushButton->setText( label );
146 yuiError() <<
"NULL button \"" << label <<
"\"" << std::endl;
148 YPushButton::setLabel( toUTF8( label ) );
155 _qPushButton->setText( fromUTF8( label ) );
157 yuiError() <<
"NULL button \"" << label <<
"\"" << std::endl;
159 YPushButton::setLabel( label );
167 _qPushButton->setAutoDefault( !show );
168 _qPushButton->setDefault( show );
169 _qPushButton->update();
176 return _qPushButton ? _qPushButton->isDefault() :
false;
183 return _qPushButton ? _qPushButton->text() :
"";
190 _qPushButton->animateClick();
198 if ( event->type() == QEvent::FocusIn )
203 else if ( event->type() == QEvent::FocusOut )
208 else if ( event->type() == QEvent::MouseButtonRelease )
210 QMouseEvent * mouseEvent =
dynamic_cast<QMouseEvent *
> (event);
212 if ( mouseEvent && mouseEvent->button() == Qt::RightButton )
214 yuiMilestone() <<
"Right click on button detected" << std::endl;
221 return QObject::eventFilter( obj, event );
227 if ( ! _qPushButton )
231 _qPushButton->setFocus();
238 _qPushButton->setShortcut (key );
241 #include "YQGenericButton.moc"
static YQApplication * yqApp()
Return the global YApplication object as YQApplication.
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.
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.
YQGenericButton * focusButton() const
Returns the button that has the keyboard focus or 0 if no button has the keyboard focus...