Hello community, here is the log from the commit of package libyui-qt for openSUSE:Factory checked in at 2016-10-18 13:28:27 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libyui-qt (Old) and /work/SRC/openSUSE:Factory/.libyui-qt.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libyui-qt" Changes: -------- --- /work/SRC/openSUSE:Factory/libyui-qt/libyui-qt.changes 2016-10-13 11:25:23.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.libyui-qt.new/libyui-qt.changes 2016-10-18 13:28:26.000000000 +0200 @@ -1,0 +2,23 @@ +Mon Oct 17 21:22:16 UTC 2016 - [email protected] + +- Add support for @import directive in QSS + (related to bsc#768112 and bsc#780621) +- 2.46.30 + +------------------------------------------------------------------- +Fri Oct 14 10:38:29 UTC 2016 - [email protected] + +- Rename Y2COLORMODE to Y2ALTSTYLE for consistency + (related to bsc#768112 and bsc#780621) +- 2.46.29 + +------------------------------------------------------------------- +Thu Oct 13 11:01:57 UTC 2016 - [email protected] + +- Rename Y2HIGHCONTRAST environment variable to Y2COLORMODE +- Use 'alternate' instead of 'high-contrast' +- Load default style sheet if alternate style sheet does not exist +- All these changes are related to bsc#768112 and bsc#780621 +- 2.46.28 + +------------------------------------------------------------------- Old: ---- libyui-qt-2.46.27.tar.bz2 New: ---- libyui-qt-2.46.30.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libyui-qt-doc.spec ++++++ --- /var/tmp/diff_new_pack.RNqDAH/_old 2016-10-18 13:28:27.000000000 +0200 +++ /var/tmp/diff_new_pack.RNqDAH/_new 2016-10-18 13:28:27.000000000 +0200 @@ -20,7 +20,7 @@ %define so_version 7 Name: %{parent}-doc -Version: 2.46.27 +Version: 2.46.30 Release: 0 Source: %{parent}-%{version}.tar.bz2 ++++++ libyui-qt.spec ++++++ --- /var/tmp/diff_new_pack.RNqDAH/_old 2016-10-18 13:28:27.000000000 +0200 +++ /var/tmp/diff_new_pack.RNqDAH/_new 2016-10-18 13:28:27.000000000 +0200 @@ -17,7 +17,7 @@ Name: libyui-qt -Version: 2.46.27 +Version: 2.46.30 Release: 0 Source: %{name}-%{version}.tar.bz2 ++++++ libyui-qt-2.46.27.tar.bz2 -> libyui-qt-2.46.30.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libyui-qt-2.46.27/VERSION.cmake new/libyui-qt-2.46.30/VERSION.cmake --- old/libyui-qt-2.46.27/VERSION.cmake 2016-10-11 12:04:11.000000000 +0200 +++ new/libyui-qt-2.46.30/VERSION.cmake 2016-10-18 09:59:12.000000000 +0200 @@ -1,6 +1,6 @@ SET(VERSION_MAJOR "2") SET(VERSION_MINOR "46") -SET(VERSION_PATCH "27") +SET(VERSION_PATCH "30") SET( VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${GIT_SHA1_VERSION}" ) ##### This is need for the libyui core, ONLY. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libyui-qt-2.46.27/package/libyui-qt-doc.spec new/libyui-qt-2.46.30/package/libyui-qt-doc.spec --- old/libyui-qt-2.46.27/package/libyui-qt-doc.spec 2016-10-11 12:04:11.000000000 +0200 +++ new/libyui-qt-2.46.30/package/libyui-qt-doc.spec 2016-10-18 09:59:12.000000000 +0200 @@ -20,7 +20,7 @@ %define so_version 7 Name: %{parent}-doc -Version: 2.46.27 +Version: 2.46.30 Release: 0 Source: %{parent}-%{version}.tar.bz2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libyui-qt-2.46.27/package/libyui-qt.changes new/libyui-qt-2.46.30/package/libyui-qt.changes --- old/libyui-qt-2.46.27/package/libyui-qt.changes 2016-10-11 12:04:11.000000000 +0200 +++ new/libyui-qt-2.46.30/package/libyui-qt.changes 2016-10-18 09:59:12.000000000 +0200 @@ -1,4 +1,27 @@ ------------------------------------------------------------------- +Mon Oct 17 21:22:16 UTC 2016 - [email protected] + +- Add support for @import directive in QSS + (related to bsc#768112 and bsc#780621) +- 2.46.30 + +------------------------------------------------------------------- +Fri Oct 14 10:38:29 UTC 2016 - [email protected] + +- Rename Y2COLORMODE to Y2ALTSTYLE for consistency + (related to bsc#768112 and bsc#780621) +- 2.46.29 + +------------------------------------------------------------------- +Thu Oct 13 11:01:57 UTC 2016 - [email protected] + +- Rename Y2HIGHCONTRAST environment variable to Y2COLORMODE +- Use 'alternate' instead of 'high-contrast' +- Load default style sheet if alternate style sheet does not exist +- All these changes are related to bsc#768112 and bsc#780621 +- 2.46.28 + +------------------------------------------------------------------- Mon Oct 10 16:56:41 UTC 2016 - [email protected] - Fix high-contrast support (bsc#76811 and related to bsc#780621) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libyui-qt-2.46.27/package/libyui-qt.spec new/libyui-qt-2.46.30/package/libyui-qt.spec --- old/libyui-qt-2.46.27/package/libyui-qt.spec 2016-10-11 12:04:11.000000000 +0200 +++ new/libyui-qt-2.46.30/package/libyui-qt.spec 2016-10-18 09:59:12.000000000 +0200 @@ -17,7 +17,7 @@ Name: libyui-qt -Version: 2.46.27 +Version: 2.46.30 Release: 0 Source: %{name}-%{version}.tar.bz2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libyui-qt-2.46.27/src/QY2Styler.cc new/libyui-qt-2.46.30/src/QY2Styler.cc --- old/libyui-qt-2.46.27/src/QY2Styler.cc 2016-10-11 12:04:11.000000000 +0200 +++ new/libyui-qt-2.46.30/src/QY2Styler.cc 2016-10-18 09:59:12.000000000 +0200 @@ -41,6 +41,7 @@ #include <iostream> #include <QPixmapCache> #include <QFileInfo> +#include <QRegularExpression> #define LOGGING_CAUSES_QT4_THREADING_PROBLEMS 1 @@ -53,13 +54,13 @@ QY2Styler::QY2Styler( QObject * parent, const QString & defaultStyleSheet, - const QString & highContrastStyleSheet) + const QString & alternateStyleSheet) : QObject( parent ) { QPixmapCache::setCacheLimit( 5 * 1024 ); yuiDebug() << "Styler created" << std::endl; setDefaultStyleSheet(defaultStyleSheet); - setHighContrastStyleSheet(highContrastStyleSheet); + setAlternateStyleSheet(alternateStyleSheet); _currentStyleSheet = QString( "" ); } @@ -70,56 +71,57 @@ static QY2Styler * styler = 0; if ( ! styler ) - { - yuiDebug() << "Creating QY2Styler singleton" << std::endl; + { + yuiDebug() << "Creating QY2Styler singleton" << std::endl; - QString y2style = getenv("Y2STYLE"); - QString y2highcontrast = getenv("Y2HIGHCONTRAST"); - styler = new QY2Styler( qApp, y2style, y2highcontrast ); - - YUI_CHECK_NEW( styler ); - if (y2highcontrast.isEmpty()) - styler->loadDefaultStyleSheet(); - else - styler->loadHighContrastStyleSheet(); - } + QString y2style = getenv("Y2STYLE"); + QString y2altstyle = getenv("Y2ALTSTYLE"); + QString y2alttheme = y2altstyle + ".qss"; + styler = new QY2Styler( qApp, y2style, y2alttheme ); + + YUI_CHECK_NEW( styler ); + if (y2altstyle.isEmpty() || !styler->styleSheetExists(y2alttheme)) + styler->loadDefaultStyleSheet(); + else + styler->loadAlternateStyleSheet(); + } return styler; } -void QY2Styler::setDefaultStyleSheet(const QString & styleSheet) +bool QY2Styler::styleSheetExists(const QString & styleSheet) { QFileInfo fileInfo(themeDir() + styleSheet); - - if (fileInfo.isFile()) - { - _defaultStyleSheet = styleSheet; - yuiDebug() << "Setting high-contrast style sheet to " - << _defaultStyleSheet << std::endl; - } + return fileInfo.isFile(); } -void QY2Styler::setHighContrastStyleSheet(const QString & styleSheet) +void QY2Styler::setDefaultStyleSheet(const QString & styleSheet) { - QFileInfo fileInfo(themeDir() + styleSheet); + if (!styleSheetExists(styleSheet)) return; + _defaultStyleSheet = styleSheet; + yuiDebug() << "Setting high-contrast style sheet to " + << _defaultStyleSheet << std::endl; +} - if (fileInfo.isFile()) - { - _highContrastStyleSheet = styleSheet; - yuiDebug() << "Setting default style sheet to " - << _highContrastStyleSheet << std::endl; - } +void QY2Styler::setAlternateStyleSheet(const QString & styleSheet) +{ + if (!styleSheetExists(styleSheet)) return; + _alternateStyleSheet = styleSheet; + yuiDebug() << "Setting default style sheet to " + << _alternateStyleSheet << std::endl; } -void QY2Styler::loadDefaultStyleSheet() +bool QY2Styler::loadDefaultStyleSheet() { - if (loadStyleSheet(_defaultStyleSheet)) - _usingHighContrastStyleSheet = false; + if (!loadStyleSheet(_defaultStyleSheet)) return false; + _usingAlternateStyleSheet = false; + return true; } -void QY2Styler::loadHighContrastStyleSheet() +bool QY2Styler::loadAlternateStyleSheet() { - if (loadStyleSheet(_highContrastStyleSheet)) - _usingHighContrastStyleSheet = true; + if (!loadStyleSheet(_alternateStyleSheet)) return false; + _usingAlternateStyleSheet = true; + return true; } bool QY2Styler::loadStyleSheet( const QString & filename ) @@ -141,9 +143,40 @@ } } +const QString QY2Styler::buildStyleSheet(QString content) +{ + QStringList alreadyImportedFilenames; + return buildStyleSheet(content, alreadyImportedFilenames); +} + +const QString QY2Styler::buildStyleSheet(QString content, QStringList & alreadyImportedFilenames) +{ + QRegularExpression re(" *@import +url\\(\"(.+)\"\\);"); + + QRegularExpressionMatchIterator it = re.globalMatch(content); + while (it.hasNext()) { + QRegularExpressionMatch match = it.next(); + QString fullPath = themeDir() + match.captured(1); + content.replace(match.captured(0), buildStyleSheetFromFile(fullPath, alreadyImportedFilenames)); + } + return content; +} + +const QString QY2Styler::buildStyleSheetFromFile(const QString & filename, QStringList & alreadyImportedFilenames) +{ + QFile file(filename); + + if ( !alreadyImportedFilenames.contains(filename) && file.open( QIODevice::ReadOnly ) ) { + alreadyImportedFilenames << filename; + return buildStyleSheet(QString(file.readAll()), alreadyImportedFilenames); + } + else + return ""; +} + void QY2Styler::setStyleSheet( const QString & text ) { - _style = text; + _style = buildStyleSheet(text); processUrls( _style ); QWidget *child; @@ -157,12 +190,12 @@ registered_widget->setStyleSheet( _style ); } -void QY2Styler::toggleHighContrastStyleSheet() +void QY2Styler::toggleAlternateStyleSheet() { - if (usingHighContrastStyleSheet()) + if (usingAlternateStyleSheet()) loadDefaultStyleSheet(); else - loadHighContrastStyleSheet(); + loadAlternateStyleSheet(); } void QY2Styler::processUrls( QString & text ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libyui-qt-2.46.27/src/QY2Styler.h new/libyui-qt-2.46.30/src/QY2Styler.h --- old/libyui-qt-2.46.27/src/QY2Styler.h 2016-10-11 12:04:11.000000000 +0200 +++ new/libyui-qt-2.46.30/src/QY2Styler.h 2016-10-18 09:59:12.000000000 +0200 @@ -47,13 +47,21 @@ **/ QY2Styler( QObject * parent, const QString & defaultStyleSheet = "", - const QString & highContrastStyleSheet = "" ); + const QString & alternateStyleSheet = "" ); public: static QY2Styler * styler(); /** + * Determines if an style sheet exists. + * + * \param file Filename. It should live in the themeDir() directory. + * \return true if the file was found; false otherwise. + */ + bool styleSheetExists( const QString & file ); + + /** * Loads and apply a style sheet from a file. * * \param file Filename. It should live in the themeDir() directory. @@ -73,13 +81,20 @@ * * The default stylesheet is determined by the environment variable Y2STYLE. * If this variable is not set, the DEFAULT_STYLE_SHEET style sheet will be used. + * + * \return true if the stylesheet was loaded; false otherwise. */ - void loadDefaultStyleSheet(); + bool loadDefaultStyleSheet(); /** - * Loads the high-contrast stylesheet. + * Loads the alternate stylesheet + * + * The alternate stylesheet is determined by the environment variable Y2ALTSTYLE. + * If this variable is not set, the HIGH_COLOR_STYLE_SHEET style sheet will be used. + * + * \return true if the stylesheet was loaded; false otherwise. */ - void loadHighContrastStyleSheet(); + bool loadAlternateStyleSheet(); /** * Returns the path to the style sheets directory. @@ -121,23 +136,23 @@ void setDefaultStyleSheet(const QString & styleSheet); /** - * Set style sheet for the high contrast theme + * Set style sheet for the alternate theme * * If the style sheet does not exists, it won't be changed. * * \param styleSheet Style sheet file name */ - void setHighContrastStyleSheet(const QString & styleSheet); + void setAlternateStyleSheet(const QString & styleSheet); /** - * Toggle between default/high-contrast style sheets. + * Toggle between default/alternate style sheets. */ - void toggleHighContrastStyleSheet(); + void toggleAlternateStyleSheet(); /** - * Determines if the high-contrast style is being used. + * Determines if the alternate style is being used. */ - bool usingHighContrastStyleSheet() { return _usingHighContrastStyleSheet; } + bool usingAlternateStyleSheet() { return _usingAlternateStyleSheet; } bool updateRendering( QWidget *wid ); @@ -152,6 +167,25 @@ **/ void processUrls( QString & text ); + /** + * Build a stylesheet from a string. + */ + const QString buildStyleSheet(QString content); + + /** + * Build a stylesheet from a string. + * + * Receives a list of already imported files. + */ + const QString buildStyleSheet(QString content, QStringList & alreadyImportedFilenames); + + /** + * Build a stylesheet from a file. + * + * Receives a list of already imported files. + */ + const QString buildStyleSheetFromFile(const QString & filename, QStringList & alreadyImportedFilenames); + /* * Reimplemented from QObject. **/ @@ -159,8 +193,8 @@ QString _currentStyleSheet; QString _defaultStyleSheet = DEFAULT_STYLE_SHEET; - QString _highContrastStyleSheet = HIGH_CONTRAST_STYLE_SHEET; - bool _usingHighContrastStyleSheet = false; + QString _alternateStyleSheet = HIGH_CONTRAST_STYLE_SHEET; + bool _usingAlternateStyleSheet = false; private: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libyui-qt-2.46.27/src/YQDialog.cc new/libyui-qt-2.46.30/src/YQDialog.cc --- old/libyui-qt-2.46.27/src/YQDialog.cc 2016-10-11 12:04:11.000000000 +0200 +++ new/libyui-qt-2.46.30/src/YQDialog.cc 2016-10-18 09:59:13.000000000 +0200 @@ -615,9 +615,9 @@ else if ( event->key() == Qt::Key_F4 && // Shift-F4: toggle colors for vision impaired users event->modifiers() == Qt::ShiftModifier ) { - QY2Styler::styler()->toggleHighContrastStyleSheet(); + QY2Styler::styler()->toggleAlternateStyleSheet(); - if ( QY2Styler::styler()->usingHighContrastStyleSheet() ) + if ( QY2Styler::styler()->usingAlternateStyleSheet() ) { QWidget* parent = 0; YDialog * currentDialog = YDialog::currentDialog( false );
