GithubHelp home page GithubHelp logo

hellorge / qtsvgiconengine Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 457 KB

Qt based svg icon engine, to manage dynamic color and size of svg files while using them as icons.

CMake 1.97% C++ 25.94% CSS 72.09%
qicon qt svg qt-svg-icons cpp

qtsvgiconengine's Introduction

Demo uses the beautiful open source ionicons

Merge requests are welcome, I'll only work on or add functionality I deem required while working on other projects of mine.

Note

The CMakeLists.txt bundles all .svg files present in provided directory in a resource file resources.qrc located inside your build folder.

Usage

SvgIconEngine iconEngine(<path/to/svg/files/directory>, <options>);

SvgIcon icon = iconEngine.getIcon(<style>, <icon_name>, <options>);
// to get an icon

iconEngine.setDefaults(<options>);
// set new default options

iconEngine.setCachePolicy(CachePolicy::<policy>);
// {ALL, NONE, LRU}
// ALL: cache all, NONE: no caching, LRU: 100 pixmaps will be cache at once

iconEngine.clearCache();
// clear pixmap cache, without cache pixmaps are generated from svg paths again.

Arguments

  1. SvgIconEngine::SvgIconEngine SvgIconEngine constructor

    • path/to/svg/files/directory | QString | Required

      Folders path where icons are located,

    • options | QVariantMap

      Set default options for all new icons

    • policy | CachePolicy

      Set cache policy for SvgIconEngine, possible values are: ALL, NONE, LRU

  2. SvgIconEngine::getIcon get an icon

    • style | QString | Required

      Folders path between <path/to/svg/files/directory> and svg file,

    • icon_name | QString | Required

      Svg filename without extension

    • options | QVariantMap

      Set options for required icon

<options>

QVariant Value Type Default Value Ex. Value Use
color QColor QApplication::palette().text().color() QColor(Qt::red) Color used to fill icon
size QSize QSvgRenderer.defaultSize() QSize(64, 64) Icon size
default_colors bool false true/false If icon colors remain as in svg file
background QColor Qt::transparent QColor(Qt::red) Background fill for icons
opacity int 1 QColor(Qt::red) Icon opacity
border_color QColor QApplication::palette().text().color() QColor(Qt::black) Color for border around icon
border_width int 0 10 Border width

Example

An svg file at /home/user/pictures/svgs/regular/calendar.svg

path/to/svg/files/directory = "/home/user/pictures/svgs"
style = "regular"
icon_name = "calendar"

qtsvgiconengine's People

Contributors

hellorge avatar

Watchers

Lucian avatar  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.