libyui-qt
2.43.5
|
00001 /* 00002 Copyright (C) 2000-2012 Novell, Inc 00003 This library is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU Lesser General Public License as 00005 published by the Free Software Foundation; either version 2.1 of the 00006 License, or (at your option) version 3.0 of the License. This library 00007 is distributed in the hope that it will be useful, but WITHOUT ANY 00008 WARRANTY; without even the implied warranty of MERCHANTABILITY or 00009 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00010 License for more details. You should have received a copy of the GNU 00011 Lesser General Public License along with this library; if not, write 00012 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth 00013 Floor, Boston, MA 02110-1301 USA 00014 */ 00015 00016 00017 /*-/ 00018 00019 File: YQLabel.cc 00020 00021 Author: Stefan Hundhammer <sh@suse.de> 00022 00023 /-*/ 00024 00025 00026 #include <qlabel.h> 00027 00028 #define YUILogComponent "qt-ui" 00029 #include <yui/YUILog.h> 00030 00031 #include "utf8.h" 00032 #include "YQUI.h" 00033 #include "YQApplication.h" 00034 #include "YQLabel.h" 00035 00036 00037 YQLabel::YQLabel( YWidget * parent, 00038 const std::string & text, 00039 bool isHeading, 00040 bool isOutputField ) 00041 : QLabel( (QWidget *) parent->widgetRep() ) 00042 , YLabel( parent, text, isHeading, isOutputField ) 00043 { 00044 setWidgetRep( this ); 00045 00046 setTextFormat( Qt::PlainText ); 00047 QLabel::setText( fromUTF8( text ) ); 00048 setIndent(0); 00049 00050 if ( isHeading ) 00051 { 00052 setFont( YQUI::yqApp()->headingFont() ); 00053 } 00054 else if ( isOutputField ) 00055 { 00056 setFrameStyle ( QFrame::Panel | QFrame::Sunken ); 00057 setLineWidth(2); 00058 setMidLineWidth(2); 00059 } 00060 00061 setMargin( YQWidgetMargin ); 00062 setAlignment( Qt::AlignLeft | Qt::AlignTop ); 00063 } 00064 00065 00066 YQLabel::~YQLabel() 00067 { 00068 // NOP 00069 } 00070 00071 00072 void YQLabel::setText( const std::string & newText ) 00073 { 00074 YLabel::setText( newText ); 00075 QLabel::setText( fromUTF8( newText ) ); 00076 } 00077 00078 00079 void YQLabel::setUseBoldFont( bool useBold ) 00080 { 00081 setFont( useBold ? 00082 YQUI::yqApp()->boldFont() : 00083 YQUI::yqApp()->currentFont() ); 00084 00085 YLabel::setUseBoldFont( useBold ); 00086 } 00087 00088 00089 void YQLabel::setEnabled( bool enabled ) 00090 { 00091 QLabel::setEnabled( enabled ); 00092 YWidget::setEnabled( enabled ); 00093 } 00094 00095 00096 int YQLabel::preferredWidth() 00097 { 00098 return sizeHint().width(); 00099 } 00100 00101 00102 int YQLabel::preferredHeight() 00103 { 00104 return sizeHint().height(); 00105 } 00106 00107 00108 void YQLabel::setSize( int newWidth, int newHeight ) 00109 { 00110 resize( newWidth, newHeight ); 00111 } 00112 00113 00114 #include "YQLabel.moc"