]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/YQPushButton.cc
Qt3support--
[duncan/yast2-qt4.git] / src / YQPushButton.cc
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQPushButton.cc
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17 /-*/
18
19
20 #include <qpushbutton.h>
21 #include <qsize.h>
22 #define y2log_component "qt-ui"
23 #include <ycp/y2log.h>
24
25 #include "utf8.h"
26 #include "YQUI.h"
27 #include "YEvent.h"
28 #include "YQPushButton.h"
29
30
31 YQPushButton::YQPushButton( YWidget *           parent,
32                             const std::string & label )
33     : YQGenericButton( parent, label )
34 {
35     setWidgetRep( this );
36
37     QPushButton * button = new QPushButton( fromUTF8( label ), this );
38     Q_CHECK_PTR( button );
39
40     setQPushButton( button );
41     
42     button->setMinimumSize( 2, 2 );
43     button->move( YQButtonBorder, YQButtonBorder );
44     setMinimumSize( button->minimumSize()
45                     + 2 * QSize( YQButtonBorder, YQButtonBorder ) );
46     
47     connect( button, SIGNAL( clicked() ),
48              this,   SLOT  ( hit()     ) );
49 }
50
51
52 YQPushButton::~YQPushButton()
53 {
54 }
55
56
57 int YQPushButton::preferredWidth()
58 {
59     return 2 * YQButtonBorder + qPushButton()->sizeHint().width();
60 }
61
62
63 int YQPushButton::preferredHeight()
64 {
65     return 2 * YQButtonBorder + qPushButton()->sizeHint().height();
66 }
67
68
69 void YQPushButton::setSize( int newWidth, int newHeight )
70 {
71     qPushButton()->resize( newWidth  - 2 * YQButtonBorder,
72                            newHeight - 2 * YQButtonBorder );
73     resize( newWidth, newHeight );
74 }
75
76
77 void YQPushButton::hit()
78 {
79     YQUI::ui()->sendEvent( new YWidgetEvent( this, YEvent::Activated ) );
80 }
81
82
83 #include "YQPushButton.moc"