Giter Site home page Giter Site logo

519984307 / xamgu-qss-loader Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mrkkrj/xamgu-qss-loader

0.0 0.0 0.0 506 KB

Loader for Qt's QSS style sheets adding CSS variables and imports.

License: GNU General Public License v3.0

C++ 83.48% CMake 16.52%

xamgu-qss-loader's Introduction

xamgu's logo

Xamgu QSS style sheets loader for Qt

How many times you wished that you could define a color once and wouldn't have to copy & paste it as RGB everywhere in your QSS style sheets? I saw several project implementing that extension again and again...

Xamgu is a loader for Qt's QSS style sheet files and file groups boasting some much needed syntactic sugar! Using these extensions you not only can avoid copy and paste but also define variants of your styling like the much needed Dark/Light styling themes as demonstrated in the "Demo App" section below!

The supported extensions are:

  1. QSS variables
    you define them like this:

      $default-font-size: 16px;
      $default-font-family: "Arial";
      $default-font-family-for-widgets: $default-font-family;
    

and then use them like that:

     QWidget { font-size: $default-font-size; color: red; }
  1. QSS file imports:
    you use them like this:

     @import "SomeStylesheetFile.qsse" 
    

Usage:

You just load the QSS file containing the extended syntax using the loader class and you will get a processed, valid QSS file as a result:

// where to look for the stylesheet files?
QsseFileLoader loader("path-to-your-stylesheet-directory");

// parametrize the files to be loaded
if (theme == "Light")
{      
    loader.createVariable("$Theme", "Light");
}
else if (theme == "Dark")
{
    loader.createVariable("$Theme", "Dark");
}     

// process files
QString stylesheet = loader.loadStyleSheet("MyAwsomeStylesheet.qsse");

// ok?
if (stylesheet.isEmpty())
{
    QMessageBox::critical(this, "ERROR", loader.messages().join('\n'));        
}
else
{
    // set the style for the app
    qApp->setStyleSheet(stylesheet);
}

In case of syntactic errors, you can examine the problem using loader's messages() method returning diagnostic and error messages.

Demo App:

For demo and example purposes a Demo App is also contained in this repository:

xamgu demo light

xamgu demo dark

xamgu demo native

Name

The problem in naming programs is that most good program names are already taken! A good program or project name should have following properties:

  • it shouldn't be used elsewhere
  • it should be short & pronounceable
  • it should have at least something to do with the program

Xamgu is Lojban for good - as in "a good QSS loader" :).

TODOs:

  • polish up the dark style icons
  • add support for C++ style comments (???)
  • correct styling of the slider knob in DemoApp (!!!)
  • correct styling of combo box's menu in DemoApp (!!!)

xamgu-qss-loader's People

Contributors

mrkkrj avatar marcelpetrick avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.