change style enum entries name because the entry "far" causes conflicts in some projects

This commit is contained in:
mbsanchez 2019-09-05 18:08:33 -04:00
parent 0fa06af758
commit 3bda39f70c
4 changed files with 47 additions and 47 deletions

View File

@ -119,7 +119,7 @@ public:
painter->drawText( textRect, flags, text); painter->drawText( textRect, flags, text);
#ifdef FONT_AWESOME_PRO #ifdef FONT_AWESOME_PRO
if(st == style::fad){ if(st == style::stfad){
QColor dcolor = optionValueForModeAndState("duotone-color", mode, state, options).value<QColor>(); QColor dcolor = optionValueForModeAndState("duotone-color", mode, state, options).value<QColor>();
int dcharacter = text.at(0).unicode() | QtAwesome::DUOTONE_HEX_ICON_VALUE; int dcharacter = text.at(0).unicode() | QtAwesome::DUOTONE_HEX_ICON_VALUE;
//Duotone is a 21-bits character, we need to use surrogate pairs //Duotone is a 21-bits character, we need to use surrogate pairs
@ -231,12 +231,12 @@ QtAwesome::QtAwesome( QObject* parent )
_fontIconPainter = new QtAwesomeCharIconPainter(); _fontIconPainter = new QtAwesomeCharIconPainter();
_fontDetails.insert(style::fas, FontData(FAS_FONT_FILENAME)); _fontDetails.insert(style::stfas, FontData(FAS_FONT_FILENAME));
_fontDetails.insert(style::far, FontData(FAR_FONT_FILENAME)); _fontDetails.insert(style::stfar, FontData(FAR_FONT_FILENAME));
_fontDetails.insert(style::fab, FontData(FAB_FONT_FILENAME)); _fontDetails.insert(style::stfab, FontData(FAB_FONT_FILENAME));
#ifdef FONT_AWESOME_PRO #ifdef FONT_AWESOME_PRO
_fontDetails.insert(style::fal, FontData(FAL_FONT_FILENAME)); _fontDetails.insert(style::stfal, FontData(FAL_FONT_FILENAME));
_fontDetails.insert(style::fad, FontData(FAD_FONT_FILENAME)); _fontDetails.insert(style::stfad, FontData(FAD_FONT_FILENAME));
#endif #endif
} }
@ -246,11 +246,11 @@ QtAwesome::~QtAwesome()
delete _fontIconPainter; delete _fontIconPainter;
qDeleteAll(_painterMap); qDeleteAll(_painterMap);
if(_namedCodepoints.contains(style::fab)) if(_namedCodepoints.contains(style::stfab))
delete _namedCodepoints[style::fab]; delete _namedCodepoints[style::stfab];
#ifdef FONT_AWESOME_PRO #ifdef FONT_AWESOME_PRO
if(_namedCodepoints.contains(style::fas)) if(_namedCodepoints.contains(style::stfas))
delete _namedCodepoints[style::fas]; delete _namedCodepoints[style::stfas];
#else #else
if(_namedCodepoints.contains(style::fas)) if(_namedCodepoints.contains(style::fas))
delete _namedCodepoints[style::fas]; delete _namedCodepoints[style::fas];
@ -2403,7 +2403,7 @@ bool QtAwesome::initFontAwesome( )
for (unsigned i = 0; i < sizeof(faBrandsIconArray)/sizeof(FANameIcon); ++i) { for (unsigned i = 0; i < sizeof(faBrandsIconArray)/sizeof(FANameIcon); ++i) {
brands->insert(faBrandsIconArray[i].name, faBrandsIconArray[i].icon); brands->insert(faBrandsIconArray[i].name, faBrandsIconArray[i].icon);
} }
_namedCodepoints.insert(style::fab, brands); _namedCodepoints.insert(style::stfab, brands);
//initialize others code icons maps //initialize others code icons maps
#ifdef FONT_AWESOME_PRO #ifdef FONT_AWESOME_PRO
@ -2416,10 +2416,10 @@ bool QtAwesome::initFontAwesome( )
commonMap->insert(faProIconArray[i].name, faProIconArray[i].icon); commonMap->insert(faProIconArray[i].name, faProIconArray[i].icon);
} }
_namedCodepoints.insert(style::far, commonMap); _namedCodepoints.insert(style::stfar, commonMap);
_namedCodepoints.insert(style::fas, commonMap); _namedCodepoints.insert(style::stfas, commonMap);
_namedCodepoints.insert(style::fal, commonMap); _namedCodepoints.insert(style::stfal, commonMap);
_namedCodepoints.insert(style::fad, commonMap); _namedCodepoints.insert(style::stfad, commonMap);
#else #else
QHash<QString, int> *farMap = new QHash<QString, int>(); QHash<QString, int> *farMap = new QHash<QString, int>();
for (unsigned i = 0; i < sizeof(faCommonIconArray)/sizeof(FANameIcon) && i < FREE_REGULAR_ICON_SIZE; ++i) { for (unsigned i = 0; i < sizeof(faCommonIconArray)/sizeof(FANameIcon) && i < FREE_REGULAR_ICON_SIZE; ++i) {
@ -2508,7 +2508,7 @@ QIcon QtAwesome::icon(const QString& name, const QVariantMap& options)
st = stringToStyleEnum(params[0]); st = stringToStyleEnum(params[0]);
ic = params[1]; ic = params[1];
} else if (params.size() == 1) { } else if (params.size() == 1) {
st = style::fas; st = style::stfas;
ic = params[0]; ic = params[0];
} else { } else {
return QIcon(); return QIcon();
@ -2587,34 +2587,34 @@ QString QtAwesome::fontName(style::styles st) const
int QtAwesome::stringToStyleEnum(const QString st) const int QtAwesome::stringToStyleEnum(const QString st) const
{ {
if(st == "fas") if(st == "fas")
return style::fas; return style::stfas;
else if (st == "far") else if (st == "far")
return style::far; return style::stfar;
else if (st == "fab") else if (st == "fab")
return style::fab; return style::stfab;
#ifdef FONT_AWESOME_PRO #ifdef FONT_AWESOME_PRO
else if (st == "fal") else if (st == "fal")
return style::fal; return style::stfal;
else if (st == "fad") else if (st == "fad")
return style::fad; return style::stfad;
#endif #endif
return style::fas; return style::stfas;
} }
const QString QtAwesome::styleEnumToString(int st) const const QString QtAwesome::styleEnumToString(int st) const
{ {
switch(st){ switch(st){
case style::fab: case style::stfab:
return "fab"; return "fab";
case style::far: case style::stfar:
return "far"; return "far";
case style::fas: case style::stfas:
return "fas"; return "fas";
#ifdef FONT_AWESOME_PRO #ifdef FONT_AWESOME_PRO
case style::fal: case style::stfal:
return "fal"; return "fal";
case style::fad: case style::stfad:
return "fad"; return "fad";
#endif #endif
} }

View File

@ -23,17 +23,17 @@
namespace style { namespace style {
enum styles { enum styles {
/// solid icons /// solid icons
fas, stfas,
/// regular icons /// regular icons
far, stfar,
#ifdef FONT_AWESOME_PRO #ifdef FONT_AWESOME_PRO
/// light icons /// light icons
fal, stfal,
/// duotone icons /// duotone icons
fad, stfad,
#endif #endif
/// brands icons /// brands icons
fab stfab
}; };
} }

View File

@ -19,8 +19,8 @@ HEADERS += \
# only one option must be enabled # only one option must be enabled
#CONFIG += fontAwesomePro CONFIG += fontAwesomePro
CONFIG += fontAwesomeFree #CONFIG += fontAwesomeFree
include(../QtAwesome/QtAwesome.pri) include(../QtAwesome/QtAwesome.pri)
FORMS += \ FORMS += \

View File

@ -12,23 +12,23 @@ MainWindow::MainWindow(QWidget *parent) :
awesome = new QtAwesome(this); awesome = new QtAwesome(this);
awesome->initFontAwesome(); awesome->initFontAwesome();
for(int st=style::fas; st<=style::fab; st++){ for(int st=style::stfas; st<=style::stfab; st++){
switch(st){ switch(st){
case style::fab: case style::stfab:
ui->comboBox->insertItem(style::fab, "Brands", style::fab); ui->comboBox->insertItem(style::stfab, "Brands", style::stfab);
break; break;
case style::far: case style::stfar:
ui->comboBox->insertItem(style::far, "Regular", style::far); ui->comboBox->insertItem(style::stfar, "Regular", style::stfar);
break; break;
case style::fas: case style::stfas:
ui->comboBox->insertItem(style::fas, "Solid", style::fas); ui->comboBox->insertItem(style::stfas, "Solid", style::stfas);
break; break;
#ifdef FONT_AWESOME_PRO #ifdef FONT_AWESOME_PRO
case style::fal: case style::stfal:
ui->comboBox->insertItem(style::fal, "Light", style::fal); ui->comboBox->insertItem(style::stfal, "Light", style::stfal);
break; break;
case style::fad: case style::stfad:
ui->comboBox->insertItem(style::fad, "Duotone", style::fad); ui->comboBox->insertItem(style::stfad, "Duotone", style::stfad);
break; break;
#endif #endif
} }
@ -61,8 +61,8 @@ MainWindow::MainWindow(QWidget *parent) :
ui->listView->setModel(model); ui->listView->setModel(model);
connect(ui->comboBox, SIGNAL(activated(int)), this, SLOT(styleChanged(int))); connect(ui->comboBox, SIGNAL(activated(int)), this, SLOT(styleChanged(int)));
ui->comboBox->setCurrentIndex(style::fab); ui->comboBox->setCurrentIndex(style::stfab);
styleChanged(style::fab); styleChanged(style::stfab);
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()