Added method for directly creating dynamically painted icons.

Removed the license info from the source files (it's already in LICENSE.md)
This commit is contained in:
Rick Blommers 2013-04-22 07:02:24 +02:00
parent fd58f84cde
commit 464669949a
2 changed files with 12 additions and 35 deletions

View File

@ -1,24 +1,8 @@
/** /**
* QtAwesome - use font-awesome (or other font icons) in your c++ / Qt Application * QtAwesome - use font-awesome (or other font icons) in your c++ / Qt Application
* *
* MIT License:
*
* Copyright 2013 - Reliable Bits Software by Blommers IT. All Rights Reserved. * Copyright 2013 - Reliable Bits Software by Blommers IT. All Rights Reserved.
* Author Rick Blommers * Author Rick Blommers
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
* THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
* OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* I would appriciate it if you let me know which projects you are using this for
*/ */
#include "QtAwesome.h" #include "QtAwesome.h"
@ -505,8 +489,7 @@ QIcon QtAwesome::icon(int character, const QVariantMap &options)
QVariantMap optionMap = mergeOptions( defaultOptions_, options ); QVariantMap optionMap = mergeOptions( defaultOptions_, options );
optionMap.insert("text", QString( QChar(character) ) ); optionMap.insert("text", QString( QChar(character) ) );
QtAwesomeIconPainterIconEngine* engine = new QtAwesomeIconPainterIconEngine( this, fontIconPainter_, optionMap ); return icon( fontIconPainter_, optionMap );
return QIcon( engine );
} }
@ -533,10 +516,19 @@ QIcon QtAwesome::icon(const QString& name, const QVariantMap& options)
return QIcon(); return QIcon();
} }
return icon( painter, optionMap );
}
/// Create a dynamic icon by simlpy supplying a painter object
/// The ownership of the painter is NOT transfered.
/// @param painter a dynamic painter that is going to paint the icon
/// @param optionmap the options to pass to the painter
QIcon QtAwesome::icon(QtAwesomeIconPainter* painter, const QVariantMap& optionMap )
{
// Warning, when you use memoryleak detection. You should turn it of for the next call // Warning, when you use memoryleak detection. You should turn it of for the next call
// QIcon's placed in gui items are often cached and not deleted when my memory-leak detection checks for leaks. // QIcon's placed in gui items are often cached and not deleted when my memory-leak detection checks for leaks.
// I'm not sure if it's a Qt bug or something I do wrong // I'm not sure if it's a Qt bug or something I do wrong
QtAwesomeIconPainterIconEngine* engine = new QtAwesomeIconPainterIconEngine( this, painter, optionMap ); QtAwesomeIconPainterIconEngine* engine = new QtAwesomeIconPainterIconEngine( this, painter, optionMap );
return QIcon( engine ); return QIcon( engine );
} }

View File

@ -1,24 +1,8 @@
/** /**
* QtAwesome - use font-awesome (or other font icons) in your c++ / Qt Application * QtAwesome - use font-awesome (or other font icons) in your c++ / Qt Application
* *
* MIT License:
*
* Copyright 2013 - Reliable Bits Software by Blommers IT. All Rights Reserved. * Copyright 2013 - Reliable Bits Software by Blommers IT. All Rights Reserved.
* Author Rick Blommers * Author Rick Blommers
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
* THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
* OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* I would appriciate it if you let me know which projects you are using this for.
*/ */
#ifndef QTAWESOME_H #ifndef QTAWESOME_H
@ -330,6 +314,7 @@ public:
QIcon icon( int character, const QVariantMap& options = QVariantMap() ); QIcon icon( int character, const QVariantMap& options = QVariantMap() );
QIcon icon( const QString& name, const QVariantMap& options = QVariantMap() ); QIcon icon( const QString& name, const QVariantMap& options = QVariantMap() );
QIcon icon(QtAwesomeIconPainter* painter, const QVariantMap& optionMap = QVariantMap() );
void give( const QString& name, QtAwesomeIconPainter* painter ); void give( const QString& name, QtAwesomeIconPainter* painter );