From 3bda39f70c15f49ca75dd2cde38b1eb74259d54e Mon Sep 17 00:00:00 2001 From: mbsanchez Date: Thu, 5 Sep 2019 18:08:33 -0400 Subject: [PATCH] change style enum entries name because the entry "far" causes conflicts in some projects --- QtAwesome/QtAwesome.cpp | 54 ++++++++++++++--------------- QtAwesome/QtAwesome.h | 10 +++--- QtAwesomeSample/QtAwesomeSample.pro | 4 +-- QtAwesomeSample/mainwindow.cpp | 26 +++++++------- 4 files changed, 47 insertions(+), 47 deletions(-) diff --git a/QtAwesome/QtAwesome.cpp b/QtAwesome/QtAwesome.cpp index 63b6167..9e33a0b 100644 --- a/QtAwesome/QtAwesome.cpp +++ b/QtAwesome/QtAwesome.cpp @@ -119,7 +119,7 @@ public: painter->drawText( textRect, flags, text); #ifdef FONT_AWESOME_PRO - if(st == style::fad){ + if(st == style::stfad){ QColor dcolor = optionValueForModeAndState("duotone-color", mode, state, options).value(); int dcharacter = text.at(0).unicode() | QtAwesome::DUOTONE_HEX_ICON_VALUE; //Duotone is a 21-bits character, we need to use surrogate pairs @@ -231,12 +231,12 @@ QtAwesome::QtAwesome( QObject* parent ) _fontIconPainter = new QtAwesomeCharIconPainter(); - _fontDetails.insert(style::fas, FontData(FAS_FONT_FILENAME)); - _fontDetails.insert(style::far, FontData(FAR_FONT_FILENAME)); - _fontDetails.insert(style::fab, FontData(FAB_FONT_FILENAME)); + _fontDetails.insert(style::stfas, FontData(FAS_FONT_FILENAME)); + _fontDetails.insert(style::stfar, FontData(FAR_FONT_FILENAME)); + _fontDetails.insert(style::stfab, FontData(FAB_FONT_FILENAME)); #ifdef FONT_AWESOME_PRO - _fontDetails.insert(style::fal, FontData(FAL_FONT_FILENAME)); - _fontDetails.insert(style::fad, FontData(FAD_FONT_FILENAME)); + _fontDetails.insert(style::stfal, FontData(FAL_FONT_FILENAME)); + _fontDetails.insert(style::stfad, FontData(FAD_FONT_FILENAME)); #endif } @@ -246,11 +246,11 @@ QtAwesome::~QtAwesome() delete _fontIconPainter; qDeleteAll(_painterMap); - if(_namedCodepoints.contains(style::fab)) - delete _namedCodepoints[style::fab]; + if(_namedCodepoints.contains(style::stfab)) + delete _namedCodepoints[style::stfab]; #ifdef FONT_AWESOME_PRO - if(_namedCodepoints.contains(style::fas)) - delete _namedCodepoints[style::fas]; + if(_namedCodepoints.contains(style::stfas)) + delete _namedCodepoints[style::stfas]; #else if(_namedCodepoints.contains(style::fas)) delete _namedCodepoints[style::fas]; @@ -2403,7 +2403,7 @@ bool QtAwesome::initFontAwesome( ) for (unsigned i = 0; i < sizeof(faBrandsIconArray)/sizeof(FANameIcon); ++i) { brands->insert(faBrandsIconArray[i].name, faBrandsIconArray[i].icon); } - _namedCodepoints.insert(style::fab, brands); + _namedCodepoints.insert(style::stfab, brands); //initialize others code icons maps #ifdef FONT_AWESOME_PRO @@ -2416,10 +2416,10 @@ bool QtAwesome::initFontAwesome( ) commonMap->insert(faProIconArray[i].name, faProIconArray[i].icon); } - _namedCodepoints.insert(style::far, commonMap); - _namedCodepoints.insert(style::fas, commonMap); - _namedCodepoints.insert(style::fal, commonMap); - _namedCodepoints.insert(style::fad, commonMap); + _namedCodepoints.insert(style::stfar, commonMap); + _namedCodepoints.insert(style::stfas, commonMap); + _namedCodepoints.insert(style::stfal, commonMap); + _namedCodepoints.insert(style::stfad, commonMap); #else QHash *farMap = new QHash(); 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]); ic = params[1]; } else if (params.size() == 1) { - st = style::fas; + st = style::stfas; ic = params[0]; } else { return QIcon(); @@ -2587,34 +2587,34 @@ QString QtAwesome::fontName(style::styles st) const int QtAwesome::stringToStyleEnum(const QString st) const { if(st == "fas") - return style::fas; + return style::stfas; else if (st == "far") - return style::far; + return style::stfar; else if (st == "fab") - return style::fab; + return style::stfab; #ifdef FONT_AWESOME_PRO else if (st == "fal") - return style::fal; + return style::stfal; else if (st == "fad") - return style::fad; + return style::stfad; #endif - return style::fas; + return style::stfas; } const QString QtAwesome::styleEnumToString(int st) const { switch(st){ - case style::fab: + case style::stfab: return "fab"; - case style::far: + case style::stfar: return "far"; - case style::fas: + case style::stfas: return "fas"; #ifdef FONT_AWESOME_PRO - case style::fal: + case style::stfal: return "fal"; - case style::fad: + case style::stfad: return "fad"; #endif } diff --git a/QtAwesome/QtAwesome.h b/QtAwesome/QtAwesome.h index 99db974..3154449 100644 --- a/QtAwesome/QtAwesome.h +++ b/QtAwesome/QtAwesome.h @@ -23,17 +23,17 @@ namespace style { enum styles { /// solid icons - fas, + stfas, /// regular icons - far, + stfar, #ifdef FONT_AWESOME_PRO /// light icons - fal, + stfal, /// duotone icons - fad, + stfad, #endif /// brands icons - fab + stfab }; } diff --git a/QtAwesomeSample/QtAwesomeSample.pro b/QtAwesomeSample/QtAwesomeSample.pro index 67dcb71..c619551 100644 --- a/QtAwesomeSample/QtAwesomeSample.pro +++ b/QtAwesomeSample/QtAwesomeSample.pro @@ -19,8 +19,8 @@ HEADERS += \ # only one option must be enabled -#CONFIG += fontAwesomePro -CONFIG += fontAwesomeFree +CONFIG += fontAwesomePro +#CONFIG += fontAwesomeFree include(../QtAwesome/QtAwesome.pri) FORMS += \ diff --git a/QtAwesomeSample/mainwindow.cpp b/QtAwesomeSample/mainwindow.cpp index c10f14c..713ffce 100644 --- a/QtAwesomeSample/mainwindow.cpp +++ b/QtAwesomeSample/mainwindow.cpp @@ -12,23 +12,23 @@ MainWindow::MainWindow(QWidget *parent) : awesome = new QtAwesome(this); awesome->initFontAwesome(); - for(int st=style::fas; st<=style::fab; st++){ + for(int st=style::stfas; st<=style::stfab; st++){ switch(st){ - case style::fab: - ui->comboBox->insertItem(style::fab, "Brands", style::fab); + case style::stfab: + ui->comboBox->insertItem(style::stfab, "Brands", style::stfab); break; - case style::far: - ui->comboBox->insertItem(style::far, "Regular", style::far); + case style::stfar: + ui->comboBox->insertItem(style::stfar, "Regular", style::stfar); break; - case style::fas: - ui->comboBox->insertItem(style::fas, "Solid", style::fas); + case style::stfas: + ui->comboBox->insertItem(style::stfas, "Solid", style::stfas); break; #ifdef FONT_AWESOME_PRO - case style::fal: - ui->comboBox->insertItem(style::fal, "Light", style::fal); + case style::stfal: + ui->comboBox->insertItem(style::stfal, "Light", style::stfal); break; - case style::fad: - ui->comboBox->insertItem(style::fad, "Duotone", style::fad); + case style::stfad: + ui->comboBox->insertItem(style::stfad, "Duotone", style::stfad); break; #endif } @@ -61,8 +61,8 @@ MainWindow::MainWindow(QWidget *parent) : ui->listView->setModel(model); connect(ui->comboBox, SIGNAL(activated(int)), this, SLOT(styleChanged(int))); - ui->comboBox->setCurrentIndex(style::fab); - styleChanged(style::fab); + ui->comboBox->setCurrentIndex(style::stfab); + styleChanged(style::stfab); } MainWindow::~MainWindow()