Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-2047

It would be useful if it was possible to include external files to stylesheets (@import)

    XMLWordPrintable

Details

    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

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              Unassigned Unassigned
              admin Administrator
              Votes:
              22 Vote for this issue
              Watchers:
              19 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes