libyui-qt  2.47.1.1
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 
38  QWidget * buttonParent,
39  const std::string & label )
40  : YQGenericButton( wizard, label )
41  , _wizard( wizard )
42 {
43  QPushButton * button = new QPushButton( fromUTF8( label ), buttonParent );
44  Q_CHECK_PTR( button );
45 
46  setQPushButton( button );
47  setWidgetRep( button );
48 
49  connect( button, &pclass(button)::clicked,
50  this, &pclass(this)::clicked );
51 
52 
53  // This widget itself will never be visible, only its button - which is not
54  // a child of this widget.
55  QWidget::hide();
56 }
57 
58 
60 {
61  // Don't delete qPushButton() here - its parent (buttonParent) will take
62  // care of that!
63 }
64 
65 
67 {
68  if ( qPushButton() )
69  qPushButton()->hide();
70 }
71 
72 
74 {
75  if ( qPushButton() )
76  qPushButton()->show();
77 }
78 
79 
81 {
82  if ( qPushButton() )
83  return !qPushButton()->isHidden();
84  else
85  return false;
86 }
87 
88 
90 {
91  return ! isShown();
92 }
93 
94 
96 {
97  // This widget doesn't have a YWidget-based visual representation, it's
98  // only a YWidget for shortcut checking etc.
99 
100  return 0;
101 }
102 
103 
105 {
106  // This widget doesn't have a YWidget-based visual representation, it's
107  // only a YWidget for shortcut checking etc.
108 
109  return 0;
110 }
111 
112 
113 void YQWizardButton::setSize( int newWidth, int newHeight )
114 {
115  // NOP
116 }
117 
118 
119 
120 #include "YQWizardButton.moc"
void clicked()
Emitted when the button is clicked or otherwise activated.
void setQPushButton(QPushButton *pb)
Set the corresponding QPushButton.
QPushButton * qPushButton() const
Returns the internal Qt PushButton.
bool isShown() const
Returns &#39;true&#39; if the associated QPushButton (!) is shown.
virtual void setSize(int newWidth, int newHeight)
Set the new size of the widget.
YQWizardButton(YQWizard *wizard, QWidget *buttonParent, const std::string &label)
Constructor.
virtual int preferredHeight()
Preferred height of the widget.
Abstract base class for push button and similar widgets - all that can become a YQDialog&#39;s "default b...
virtual int preferredWidth()
Preferred width of the widget.
void hide()
Hide the associated QPushButton.
bool isHidden() const
Returns &#39;true&#39; if the associated QPushButton (!) is hidden.
virtual ~YQWizardButton()
Destructor.
void show()
Show the associated QPushButton - not this widget itself (!).