]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/YQLabel.cc
disabling the style for now as the theming causes terrible
[duncan/yast2-qt4.git] / src / YQLabel.cc
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQLabel.cc
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17 /-*/
18
19
20 #define y2log_component "qt-ui"
21 #include <ycp/y2log.h>
22
23 #include "utf8.h"
24 #include "YQUI.h"
25 #include "YQApplication.h"
26 #include "YQLabel.h"
27 //Added by qt3to4:
28 #include <qlabel.h>
29
30
31 YQLabel::YQLabel( YWidget *             parent,
32                   const string &        text,
33                   bool                  isHeading,
34                   bool                  isOutputField )
35     : QLabel( (QWidget *) parent->widgetRep() )
36     , YLabel( parent, text, isHeading, isOutputField )
37 {
38     setWidgetRep( this );
39
40     setTextFormat( Qt::PlainText );
41     QLabel::setText( fromUTF8( text ) );
42     setIndent(0);
43
44     if ( isHeading )
45     {
46         setFont( YQUI::yqApp()->headingFont() );
47     }
48     else if ( isOutputField )
49     {
50         setFrameStyle ( QFrame::Panel | QFrame::Sunken );
51         setLineWidth(2);
52         setMidLineWidth(2);
53     }
54                 
55     setMargin( YQWidgetMargin );
56     setAlignment( Qt::AlignLeft | Qt::AlignTop );
57 }
58
59
60 YQLabel::~YQLabel()
61 {
62     // NOP
63 }
64
65
66 void YQLabel::setText( const string & newText )
67 {
68     YLabel::setText( newText );
69     QLabel::setText( fromUTF8( newText ) );
70 }
71
72
73 void YQLabel::setUseBoldFont( bool useBold )
74 {
75     setFont( useBold ?
76              YQUI::yqApp()->boldFont() :
77              YQUI::yqApp()->currentFont() );
78     
79     YLabel::setUseBoldFont( useBold );
80 }
81
82
83 void YQLabel::setEnabled( bool enabled )
84 {
85     QLabel::setEnabled( enabled );
86     YWidget::setEnabled( enabled );
87 }
88
89
90 int YQLabel::preferredWidth()
91 {
92     return sizeHint().width();
93 }
94
95
96 int YQLabel::preferredHeight()
97 {
98     return sizeHint().height();
99 }
100
101
102 void YQLabel::setSize( int newWidth, int newHeight )
103 {
104     resize( newWidth, newHeight );
105 }
106
107
108 #include "YQLabel.moc"