[yast-commit] r42648 - in /branches/tmp/coolo/qt4-port: src/CMakeLists.txt src/QY2Styler.cc src/QY2Styler.h src/YQUI.h src/YQUI_core.cc theme/style.qss
Author: coolo Date: Tue Dec 4 12:20:33 2007 New Revision: 42648 URL: http://svn.opensuse.org/viewcvs/yast?rev=42648&view=rev Log: parse the stylesheet in an extra class Added: branches/tmp/coolo/qt4-port/src/QY2Styler.cc branches/tmp/coolo/qt4-port/src/QY2Styler.h Modified: branches/tmp/coolo/qt4-port/src/CMakeLists.txt branches/tmp/coolo/qt4-port/src/YQUI.h branches/tmp/coolo/qt4-port/src/YQUI_core.cc branches/tmp/coolo/qt4-port/theme/style.qss Modified: branches/tmp/coolo/qt4-port/src/CMakeLists.txt URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/coolo/qt4-port/src/CMakeLists.txt?rev=42648&r1=42647&r2=42648&view=diff ============================================================================== --- branches/tmp/coolo/qt4-port/src/CMakeLists.txt (original) +++ branches/tmp/coolo/qt4-port/src/CMakeLists.txt Tue Dec 4 12:20:33 2007 @@ -26,7 +26,8 @@ YQRichText.cc YQSelectionBox.cc YQSignalBlocker.cc YQSlider.cc YQSpacing.cc YQSquash.cc YQTable.cc YQTimeField.cc YQTree.cc YQUI_builtins.cc YQUI_core.cc YQUI_widgets.cc YQUI_x11.cc - YQWidgetCaption.cc YQWidgetFactory.cc YQWizardButton.cc YQWizard.cc + YQWidgetCaption.cc YQWidgetFactory.cc YQWizardButton.cc + YQWizard.cc QY2Styler.cc ) QT4_AUTOMOC(${qt4_yast_plugin_SRCS}) Added: branches/tmp/coolo/qt4-port/src/QY2Styler.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/coolo/qt4-port/src/QY2Styler.cc?rev=42648&view=auto ============================================================================== --- branches/tmp/coolo/qt4-port/src/QY2Styler.cc (added) +++ branches/tmp/coolo/qt4-port/src/QY2Styler.cc Tue Dec 4 12:20:33 2007 @@ -0,0 +1,48 @@ +#include "QY2Styler.h" +#include <QFile> +#include <QString> +#include <QStringList> +#include <QApplication> + +QY2Styler::QY2Styler( QObject *parent ) + : QObject( parent ) +{ +} + +void QY2Styler::setStyleSheet( const QString &filename ) +{ + QFile file( themeDir() + filename ); + if ( file.open( QIODevice::ReadOnly ) ) + { + QString content = file.readAll(); + processUrls( content ); + qApp->setStyleSheet( content ); + } +} + +void QY2Styler::processUrls(QString &text) const +{ + QString result; + QStringList lines = text.split( '\n' ); + QRegExp urlx( ": *url\\((.*)\\)" ); + QRegExp backgroundx( "^ */\\* *Background: *([^ ]*) *([^ ]*) *\\*/$" ); + for ( QStringList::const_iterator it = lines.begin(); it != lines.end(); ++it ) + { + QString line = *it; + if ( urlx.indexIn( line ) >= 0 ) + line.replace( urlx, ": url(" + themeDir() + urlx.cap( 1 ) + ")"); + + if ( backgroundx.exactMatch( line ) ) + _backgrounds[backgroundx.cap( 1 )] = backgroundx.cap( 2 ); + + result += line; + } + text = result; +} + +QString QY2Styler::themeDir() const +{ + return THEMEDIR "/openSUSE/wizard/"; +} + +#include "QY2Styler.moc" Added: branches/tmp/coolo/qt4-port/src/QY2Styler.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/coolo/qt4-port/src/QY2Styler.h?rev=42648&view=auto ============================================================================== --- branches/tmp/coolo/qt4-port/src/QY2Styler.h (added) +++ branches/tmp/coolo/qt4-port/src/QY2Styler.h Tue Dec 4 12:20:33 2007 @@ -0,0 +1,25 @@ +#ifndef QY2STYLER_H +#define QY2STYLER_H + +#include <QObject> +#include <QHash> +#include <QString> + +class QY2Styler : public QObject +{ + Q_OBJECT + +public: + QY2Styler( QObject *parent ); + + void setStyleSheet( const QString &file ); + QString themeDir() const; + +protected: + void processUrls(QString &text) const; + +private: + QHash<QString,QString> _backgrounds; +}; + +#endif Modified: branches/tmp/coolo/qt4-port/src/YQUI.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/coolo/qt4-port/src/YQUI.h?rev=42648&r1=42647&r2=42648&view=diff ============================================================================== --- branches/tmp/coolo/qt4-port/src/YQUI.h (original) +++ branches/tmp/coolo/qt4-port/src/YQUI.h Tue Dec 4 12:20:33 2007 @@ -32,6 +32,7 @@ #define YQWidgetSpacing 4 #define YQButtonBorder 3 +class QY2Styler; class QCursor; class QFrame; class QStackedWidget; @@ -654,6 +655,11 @@ bool _ui_inited; int _ui_argc; char **_ui_argv; + + /* + * Reads the style sheet, parses some comments and passes it to qapp + */ + QY2Styler *_styler; }; #endif // YQUI_h Modified: branches/tmp/coolo/qt4-port/src/YQUI_core.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/coolo/qt4-port/src/YQUI_core.cc?rev=42648&r1=42647&r2=42648&view=diff ============================================================================== --- branches/tmp/coolo/qt4-port/src/YQUI_core.cc (original) +++ branches/tmp/coolo/qt4-port/src/YQUI_core.cc Tue Dec 4 12:20:33 2007 @@ -35,6 +35,7 @@ #include <ycp/y2log.h> #include "YQUI.h" +#include "QY2Styler.h" #include "YQApplication.h" #include "YQWidgetFactory.h" #include "YQOptionalWidgetFactory.h" @@ -46,7 +47,6 @@ #include "YQDialog.h" #include "QY2Settings.h" -#define PIXMAP_DIR THEMEDIR "/openSUSE/wizard/" #define BUSY_CURSOR_TIMEOUT 200 // milliseconds YQUI * YQUI::_ui = 0; @@ -119,7 +119,8 @@ processCommandLineArgs( _ui_argc, _ui_argv ); calcDefaultSize(); - qApp->setStyleSheet( "file:///" PIXMAP_DIR "/style.qss" ); + _styler = new QY2Styler( this ); + _styler->setStyleSheet( "style.qss" ); // Event loop object. Required since a YaST2 UI needs to react to commands // from the YCP command stream as well as to X11 / Qt events. Modified: branches/tmp/coolo/qt4-port/theme/style.qss URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/coolo/qt4-port/theme/style.qss?rev=42648&r1=42647&r2=42648&view=diff ============================================================================== --- branches/tmp/coolo/qt4-port/theme/style.qss (original) +++ branches/tmp/coolo/qt4-port/theme/style.qss Tue Dec 4 12:20:33 2007 @@ -1,3 +1,6 @@ +/* Background: main_window background.svg */ +/* Background: work_area g22503.png */ +/* Background: steps rect2174.png */ #main_window { background-image: url(background-1024x768.png); -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
coolo@svn.opensuse.org