libyui-qt  2.53.0
YQWizardButton.cc
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YQWizardButton.cc
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 
26 #include <qpushbutton.h>
27 #include <qsize.h>
28 #define YUILogComponent "qt-ui"
29 #include <yui/YUILog.h>
30 
31 #include "utf8.h"
32 #include "YQUI.h"
33 #include "YQWizardButton.h"
34 #include "YQWizard.h"
35 
36 using std::string;
37 
38 
40  QWidget * buttonParent,
41  const string & label )
42  : YQGenericButton( wizard, label )
43  , _wizard( wizard )
44 {
45  QPushButton * button = new QPushButton( fromUTF8( label ), buttonParent );
46  Q_CHECK_PTR( button );
47 
48  setQPushButton( button );
49  setWidgetRep( button );
50 
51  connect( button, &pclass(button)::clicked,
52  this, &pclass(this)::clicked );
53 
54 
55  // This widget itself will never be visible, only its button - which is not
56  // a child of this widget.
57  QWidget::hide();
58 }
59 
60 
62 {
63  // Don't delete qPushButton() here - its parent (buttonParent) will take
64  // care of that!
65 }
66 
67 
69 {
70  if ( qPushButton() )
71  qPushButton()->hide();
72 }
73 
74 
76 {
77  if ( qPushButton() )
78  qPushButton()->show();
79 }
80 
81 
83 {
84  if ( qPushButton() )
85  return !qPushButton()->isHidden();
86  else
87  return false;
88 }
89 
90 
92 {
93  return ! isShown();
94 }
95 
96 
98 {
99  // This widget doesn't have a YWidget-based visual representation, it's
100  // only a YWidget for shortcut checking etc.
101 
102  return 0;
103 }
104 
105 
107 {
108  // This widget doesn't have a YWidget-based visual representation, it's
109  // only a YWidget for shortcut checking etc.
110 
111  return 0;
112 }
113 
114 
115 void YQWizardButton::setSize( int newWidth, int newHeight )
116 {
117  // NOP
118 }
119 
120 
121 
122 
Abstract base class for push button and similar widgets - all that can become a YQDialog's "default b...
QPushButton * qPushButton() const
Returns the internal Qt PushButton.
void setQPushButton(QPushButton *pb)
Set the corresponding QPushButton.
void hide()
Hide the associated QPushButton.
bool isHidden() const
Returns 'true' if the associated QPushButton (!) is hidden.
YQWizardButton(YQWizard *wizard, QWidget *buttonParent, const std::string &label)
Constructor.
virtual ~YQWizardButton()
Destructor.
virtual int preferredWidth()
Preferred width of the widget.
void clicked()
Emitted when the button is clicked or otherwise activated.
virtual void setSize(int newWidth, int newHeight)
Set the new size of the widget.
virtual int preferredHeight()
Preferred height of the widget.
bool isShown() const
Returns 'true' if the associated QPushButton (!) is shown.
void show()
Show the associated QPushButton - not this widget itself (!).