Author: coolo Date: Fri Apr 11 21:13:42 2008 New Revision: 46456 URL: http://svn.opensuse.org/viewcvs/yast?rev=46456&view=rev Log: support richtext stylesheet Modified: trunk/qt/src/QY2Styler.cc trunk/qt/src/QY2Styler.h trunk/qt/src/YQRichText.cc Modified: trunk/qt/src/QY2Styler.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/src/QY2Styler.cc?rev=46456&... ============================================================================== --- trunk/qt/src/QY2Styler.cc (original) +++ trunk/qt/src/QY2Styler.cc Fri Apr 11 21:13:42 2008 @@ -33,7 +33,7 @@ processUrls( _style ); yuiMilestone() << "set stylesheet " << qPrintable(filename) << endl; } - else + else yuiMilestone() << "could not open " << qPrintable(filename) << endl; } @@ -43,6 +43,7 @@ QStringList lines = text.split( '\n' ); QRegExp urlx( ": *url\((.*)\)" ); QRegExp backgroundx( "^ */\* *Background: *([^ ]*) *([^ ]*) *\*/$" ); + QRegExp richtextx( "^ */\* *Richtext: *([^ ]*) *\*/$" ); for ( QStringList::const_iterator it = lines.begin(); it != lines.end(); ++it ) { QString line = *it; @@ -59,6 +60,16 @@ _backgrounds[ name[0] ].full = ( name[1] == "full" ); } + if ( richtextx.exactMatch( line ) ) + { + QString filename = richtextx.cap( 1 ); + QFile file( themeDir() + "/" + filename ); + if ( file.open( QIODevice::ReadOnly ) ) + { + _textStyle = file.readAll(); + } + } + result += line; } text = result; Modified: trunk/qt/src/QY2Styler.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/src/QY2Styler.h?rev=46456&... ============================================================================== --- trunk/qt/src/QY2Styler.h (original) +++ trunk/qt/src/QY2Styler.h Fri Apr 11 21:13:42 2008 @@ -18,6 +18,7 @@ QString themeDir() const; void registerWidget( QWidget *widget ); void registerChildWidget( QWidget *parent, QWidget *widget ); + QString textStyle() const { return _textStyle; } static QY2Styler *self() { return _self; @@ -50,6 +51,7 @@ static QY2Styler *_self; QString _style; + QString _textStyle; }; #endif Modified: trunk/qt/src/YQRichText.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/src/YQRichText.cc?rev=46456&am... ============================================================================== --- trunk/qt/src/YQRichText.cc (original) +++ trunk/qt/src/YQRichText.cc Fri Apr 11 21:13:42 2008 @@ -28,6 +28,7 @@ #include "YApplication.h" #include "YEvent.h" #include "utf8.h" +#include "QY2Styler.h" #include "YQUI.h" #include "YQDialog.h" #include "YQRichText.h" @@ -53,14 +54,13 @@ if ( plainTextMode ) { - _textBrowser->setPlainText( fromUTF8( text ) ); _textBrowser->setWordWrapMode( QTextOption::NoWrap ); } else { - _textBrowser->setHtml( fromUTF8( text ) ); + _textBrowser->document()->setDefaultStyleSheet( QY2Styler::self()->textStyle() ); } - + setValue( text ); // Propagate clicks on hyperlinks @@ -78,6 +78,8 @@ void YQRichText::setValue( const string & newText ) { + yuiMilestone() << newText << endl; + if ( _textBrowser->horizontalScrollBar() ) _textBrowser->horizontalScrollBar()->setValue(0); -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org