Details
-
Suggestion
-
Resolution: Unresolved
-
P2: Important
-
4.3.4, 5.5.0
Description
It would be useful if it was possible to include external files to stylesheets. In this way it would be easier to work on Designer since you do changes in one file and this file is included in many ui forms in Designer.
That could be done using the CSS @import syntax
Whilst not complete the offered patch to provide this functionality is:
--- src/gui/text/qcssparser.cpp 2008-04-23 14:39:39.000000000 -0600 +++ src/gui/text/qcssparser.cpp 2008-04-30 12:47:54.000000000 -0600 @@ -1684,6 +1684,35 @@ if (hasEscapeSequences) *hasEscapeSequences = false; + QRegExp findIncludes( "#include \\<([^\\<]*)\\>", Qt::CaseInsensitive ); + + // Used to guard against multiple/infinitely recursive inclusion + QStringList includedFiles; + + int pos = 0; + while( (pos = findIncludes.indexIn(output)) != -1 ) + { + QString fileName = findIncludes.cap( 1 ); + QString importedStyleSheet; + + if( fileName.startsWith(":/") ) + { + QFile styleSheetFile( fileName ); + + if( !includedFiles.contains(styleSheetFile.fileName()) ) + { + if( styleSheetFile.open(QIODevice::ReadOnly) ) + importedStyleSheet = QString( styleSheetFile.readAll() ); + else + qWarning() << "QCss::Scanner - Failed to load import file" << styleSheetFile.fileName(); + } + } + else + qWarning() << "QCss::Scanner - Import file must be a resource"; + + output.replace( pos, findIncludes.matchedLength(), importedStyleSheet ); + } + int i = 0; while (i < output.size()) { if (output.at(i) == QLatin1Char('\\')) {
Attachments
Issue Links
- relates to
-
QTCREATORBUG-12066 Add support for external style sheets in Qt Widget Designer
-
- Reported
-
-
QTBUG-517 Loading style sheets in Designer
-
- Open
-