[yast-commit] r42654 - in /branches/tmp/coolo/qt4-port: src/QY2Styler.cc src/QY2Styler.h src/YQUI_core.cc src/YQWizard.cc theme/g22503.png theme/style.qss
Author: coolo Date: Tue Dec 4 13:59:13 2007 New Revision: 42654 URL: http://svn.opensuse.org/viewcvs/yast?rev=42654&view=rev Log: disabling the style for now as the theming causes terrible performance penalty ;( Modified: branches/tmp/coolo/qt4-port/src/QY2Styler.cc branches/tmp/coolo/qt4-port/src/QY2Styler.h branches/tmp/coolo/qt4-port/src/YQUI_core.cc branches/tmp/coolo/qt4-port/src/YQWizard.cc branches/tmp/coolo/qt4-port/theme/g22503.png branches/tmp/coolo/qt4-port/theme/style.qss Modified: branches/tmp/coolo/qt4-port/src/QY2Styler.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/coolo/qt4-port/src/QY2Styler.cc?rev=42654&r1=42653&r2=42654&view=diff ============================================================================== --- branches/tmp/coolo/qt4-port/src/QY2Styler.cc (original) +++ branches/tmp/coolo/qt4-port/src/QY2Styler.cc Tue Dec 4 13:59:13 2007 @@ -3,10 +3,14 @@ #include <QString> #include <QStringList> #include <QApplication> +#include <QWidget> + +QY2Styler *QY2Styler::_self = 0; QY2Styler::QY2Styler( QObject *parent ) : QObject( parent ) { + _self = this; } void QY2Styler::setStyleSheet( const QString &filename ) @@ -16,7 +20,7 @@ { QString content = file.readAll(); processUrls( content ); - qApp->setStyleSheet( content ); + //qApp->setStyleSheet( content ); } } @@ -33,7 +37,7 @@ line.replace( urlx, ": url(" + themeDir() + urlx.cap( 1 ) + ")"); if ( backgroundx.exactMatch( line ) ) - _backgrounds[backgroundx.cap( 1 )] = backgroundx.cap( 2 ); + _backgroundFn[backgroundx.cap( 1 )] = themeDir() + backgroundx.cap( 2 ); result += line; } @@ -45,4 +49,39 @@ return THEMEDIR "/openSUSE/wizard/"; } +void QY2Styler::registerWidget( QWidget *widget ) +{ + return; + widget->installEventFilter( this ); +} + +bool QY2Styler::eventFilter( QObject * obj, QEvent * ev ) +{ + if ( ev->type() != QEvent::Resize ) + return QObject::eventFilter( obj, ev ); + + QString name = obj->objectName(); + + qDebug( "eventFilter %s", qPrintable( name ) ); + + if ( !_backgroundFn.contains( name ) ) + return QObject::eventFilter( obj, ev ); + + QWidget *wid = qobject_cast<QWidget*>( obj ); + if ( !_backgroundPx.contains( name ) ) + { + QString back = _backgroundFn[ name ]; + _backgroundPx[ name ] = QImage( back ); + wid->setAutoFillBackground( true ); + qDebug( "loading %s for %s", qPrintable( back ), qPrintable( name ) ); + } + + QPixmap img = QPixmap::fromImage( _backgroundPx[name].scaled( wid->contentsRect().width(), wid->contentsRect().height() ) ); + QPalette p = wid->palette(); + p.setBrush(QPalette::Window, img ); + wid->setPalette( p ); + + return QObject::eventFilter( obj, ev ); +} + #include "QY2Styler.moc" Modified: branches/tmp/coolo/qt4-port/src/QY2Styler.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/coolo/qt4-port/src/QY2Styler.h?rev=42654&r1=42653&r2=42654&view=diff ============================================================================== --- branches/tmp/coolo/qt4-port/src/QY2Styler.h (original) +++ branches/tmp/coolo/qt4-port/src/QY2Styler.h Tue Dec 4 13:59:13 2007 @@ -4,6 +4,7 @@ #include <QObject> #include <QHash> #include <QString> +#include <QImage> class QY2Styler : public QObject { @@ -14,12 +15,24 @@ void setStyleSheet( const QString &file ); QString themeDir() const; + void registerWidget( QWidget *widget ); + + static QY2Styler *self() { + return _self; + } protected: void processUrls(QString &text); + /* + * Reimplemented from QObject. + **/ + bool eventFilter( QObject * obj, QEvent * ev ); private: - QHash<QString,QString> _backgrounds; + QHash<QString,QString> _backgroundFn; + QHash<QString,QImage> _backgroundPx; + + static QY2Styler *_self; }; #endif 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=42654&r1=42653&r2=42654&view=diff ============================================================================== --- branches/tmp/coolo/qt4-port/src/YQUI_core.cc (original) +++ branches/tmp/coolo/qt4-port/src/YQUI_core.cc Tue Dec 4 13:59:13 2007 @@ -119,7 +119,7 @@ processCommandLineArgs( _ui_argc, _ui_argv ); calcDefaultSize(); - _styler = new QY2Styler( this ); + _styler = new QY2Styler( qApp ); _styler->setStyleSheet( "style.qss" ); // Event loop object. Required since a YaST2 UI needs to react to commands @@ -143,6 +143,7 @@ _main_win = new QWidget( 0, wflags ); // parent, wflags _main_win->setFocusPolicy( Qt::StrongFocus ); _main_win->setObjectName( "main_window" ); + _styler->registerWidget( _main_win ); // Create widget stack for `opt(`defaultsize) dialogs QVBoxLayout *vbox = new QVBoxLayout( _main_win ); Modified: branches/tmp/coolo/qt4-port/src/YQWizard.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/coolo/qt4-port/src/YQWizard.cc?rev=42654&r1=42653&r2=42654&view=diff ============================================================================== --- branches/tmp/coolo/qt4-port/src/YQWizard.cc (original) +++ branches/tmp/coolo/qt4-port/src/YQWizard.cc Tue Dec 4 13:59:13 2007 @@ -45,6 +45,7 @@ #include <qtoolbutton.h> #include "QY2ListView.h" +#include "QY2Styler.h" #include <QGridLayout> #include <qevent.h> @@ -209,6 +210,7 @@ _stepsPanel = new QFrame( _sideBar ); _sideBar->addWidget( _stepsPanel ); _sideBar->setObjectName( "steps" ); + QY2Styler::self()->registerWidget( _sideBar ); _stepsPanel->setProperty( "class", "steps QFrame" ); // Steps panel bottom buttons ("Help", "Release Notes") @@ -625,6 +627,8 @@ QFrame *workArea = new QFrame( parent ); workArea->setObjectName( "work_area" ); + QY2Styler::self()->registerWidget( workArea ); + QVBoxLayout *vbox = new QVBoxLayout( workArea ); _menuBar = new QMenuBar( workArea ); Modified: branches/tmp/coolo/qt4-port/theme/g22503.png URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/coolo/qt4-port/theme/g22503.png?rev=42654&r1=42653&r2=42654&view=diff ============================================================================== Binary files - no diff available. 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=42654&r1=42653&r2=42654&view=diff ============================================================================== --- branches/tmp/coolo/qt4-port/theme/style.qss (original) +++ branches/tmp/coolo/qt4-port/theme/style.qss Tue Dec 4 13:59:13 2007 @@ -1,28 +1,13 @@ -/* Background: main_window background.svg */ +/* Background: main_window background-1024x768.png */ /* Background: work_area g22503.png */ /* Background: steps rect2174.png */ -#main_window { - background-image: url(background-1024x768.png); - background-position: bottom; - background-repeat: none; - background-position: top left; - min-width: 1024px; - max-width: 1024px; - min-height: 768px; -} - #work_area { - background-image: url(g22503.png); - background-position: top left; - background-repeat: none; - background-origin: border; - background-clip: padding; border-style: none; - padding-left: 0px; - padding-top: 50px; - padding-right: 110px; - padding-bottom: 80px; + margin-top: 50px; + margin-right: 110px; + margin-bottom: 80px; + margin-left: 0px; } QDWidget { border-style: solid; border-width: 5px; } @@ -31,11 +16,6 @@ #steps { - background-image: url(rect2174.png); - background-position: top right; - background-repeat: none; - background-origin: border; - background-clip: padding; border-style: none; padding-left: 20px; padding-top: 10px; -- 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