]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/YQWizardButton.cc
don't create QObjects in ycp thread - make timeouts work
[duncan/yast2-qt4.git] / src / YQWizardButton.cc
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQWizardButton.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 "YQWizardButton.h"
28 #include "YQWizard.h"
29
30
31 YQWizardButton::YQWizardButton( YQWizard *      wizard,
32                                 QWidget *       buttonParent,
33                                 const string &  label )
34     : YQGenericButton( wizard, label )
35     , _wizard( wizard )
36 {
37     QPushButton * button = new QPushButton( fromUTF8( label ), buttonParent );
38     Q_CHECK_PTR( button );
39
40     setQPushButton( button );
41     setWidgetRep( button );
42
43     connect( button, SIGNAL( clicked() ),
44              this,   SIGNAL( clicked() ) );
45
46
47     // This widget itself will never be visible, only its button - which is not
48     // a child of this widget.
49     QWidget::hide();
50 }
51
52
53 YQWizardButton::~YQWizardButton()
54 {
55     // Don't delete qPushButton() here - its parent (buttonParent) will take
56     // care of that!
57 }
58
59
60 void YQWizardButton::hide()
61 {
62     if ( qPushButton() )
63         qPushButton()->hide();
64 }
65
66
67 void YQWizardButton::show()
68 {
69     if ( qPushButton() )
70         qPushButton()->show();
71 }
72
73
74 bool YQWizardButton::isShown() const
75 {
76     if ( qPushButton() )
77         return !qPushButton()->isHidden();
78     else
79         return false;
80 }
81
82
83 bool YQWizardButton::isHidden() const
84 {
85     return ! isShown();
86 }
87
88
89 int YQWizardButton::preferredWidth()
90 {
91     // This widget doesn't have a YWidget-based visual representation, it's
92     // only a YWidget for shortcut checking etc.
93
94     return 0;
95 }
96
97
98 int YQWizardButton::preferredHeight()
99 {
100     // This widget doesn't have a YWidget-based visual representation, it's
101     // only a YWidget for shortcut checking etc.
102
103     return 0;
104 }
105
106
107 void YQWizardButton::setSize( int newWidth, int newHeight )
108 {
109     // NOP
110 }
111
112
113
114 #include "YQWizardButton.moc"