diff --git a/NEWS.md b/NEWS.md index 15c804d4..814fdbb5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -13,6 +13,7 @@ Red Panda C++ Version 0.14.1 - fix: wrong icons for file associations - fix: editor's font size set by ctrl+mouse wheel will be reset by open the option dialog - fix: actions not correctly disabled when compile + - fix: can't differentiate disabled and enabled buttons, when using contrast icon set Red Panda C++ Version 0.14.0 - enhancement: custom icon set ( in the configuration folder) diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro index 2d68307c..f4db34bf 100644 --- a/RedPandaIDE/RedPandaIDE.pro +++ b/RedPandaIDE/RedPandaIDE.pro @@ -134,6 +134,7 @@ SOURCES += \ utils.cpp \ widgets/coloredit.cpp \ widgets/consolewidget.cpp \ + widgets/customdisablediconengine.cpp \ widgets/custommakefileinfodialog.cpp \ widgets/darkfusionstyle.cpp \ widgets/editorstabwidget.cpp \ @@ -260,6 +261,7 @@ HEADERS += \ common.h \ widgets/coloredit.h \ widgets/consolewidget.h \ + widgets/customdisablediconengine.h \ widgets/custommakefileinfodialog.h \ widgets/darkfusionstyle.h \ widgets/editorstabwidget.h \ diff --git a/RedPandaIDE/iconsmanager.cpp b/RedPandaIDE/iconsmanager.cpp index c1a6141b..3bb14ded 100644 --- a/RedPandaIDE/iconsmanager.cpp +++ b/RedPandaIDE/iconsmanager.cpp @@ -29,6 +29,7 @@ #include #include "utils.h" #include "settings.h" +#include "widgets/customdisablediconengine.h" IconsManager* pIconsManager; @@ -36,11 +37,13 @@ IconsManager::IconsManager(QObject *parent) : QObject(parent) { mDefaultIconPixmap = std::make_shared(); mIconSetTemplate = "%1/%2/%3/"; + mMakeDisabledIconDarker = false; } void IconsManager::updateEditorGuttorIcons(const QString& iconSet,int size) { QString iconFolder = mIconSetTemplate.arg( iconSetsFolder(),iconSet,"editor"); + updateMakeDisabledIconDarker(iconSet); mIconPixmaps.insert(GUTTER_BREAKPOINT, createSVGIcon(iconFolder+"breakpoint.svg",size,size)); mIconPixmaps.insert(GUTTER_SYNTAX_ERROR, createSVGIcon(iconFolder+"syntaxerror.svg",size,size)); mIconPixmaps.insert(GUTTER_SYNTAX_WARNING,createSVGIcon(iconFolder+"syntaxwarning.svg",size,size)); @@ -51,6 +54,7 @@ void IconsManager::updateEditorGuttorIcons(const QString& iconSet,int size) void IconsManager::updateParserIcons(const QString &iconSet, int size) { QString iconFolder = mIconSetTemplate.arg( iconSetsFolder(),iconSet,"classparser"); + updateMakeDisabledIconDarker(iconSet); mIconPixmaps.insert(PARSER_TYPE, createSVGIcon(iconFolder+"type.svg",size,size)); mIconPixmaps.insert(PARSER_CLASS, createSVGIcon(iconFolder+"class.svg",size,size)); mIconPixmaps.insert(PARSER_NAMESPACE, createSVGIcon(iconFolder+"namespace.svg",size,size)); @@ -77,6 +81,7 @@ void IconsManager::updateParserIcons(const QString &iconSet, int size) void IconsManager::updateActionIcons(const QString& iconSet, int size) { QString iconFolder = mIconSetTemplate.arg( iconSetsFolder(),iconSet,"actions"); + updateMakeDisabledIconDarker(iconSet); mActionIconSize = QSize(size,size); mIconPixmaps.insert(ACTION_MISC_BACK, createSVGIcon(iconFolder+"00Misc-01Back.svg",size,size)); mIconPixmaps.insert(ACTION_MISC_FORWARD, createSVGIcon(iconFolder+"00Misc-02Forward.svg",size,size)); @@ -177,7 +182,12 @@ IconsManager::PPixmap IconsManager::getPixmap(IconName iconName) const QIcon IconsManager::getIcon(IconName iconName) const { - return QIcon(*getPixmap(iconName)); + if (mMakeDisabledIconDarker) { + QIcon icon(new CustomDisabledIconEngine()); + icon.addPixmap(*getPixmap(iconName)); + return icon; + } else + return QIcon(*getPixmap(iconName)); } void IconsManager::setIcon(QToolButton *btn, IconName iconName) const @@ -326,3 +336,8 @@ QList IconsManager::listIconSets() } return result; } + +void IconsManager::updateMakeDisabledIconDarker(const QString& iconset ) +{ + mMakeDisabledIconDarker = (iconset == "contrast"); +} diff --git a/RedPandaIDE/iconsmanager.h b/RedPandaIDE/iconsmanager.h index 76a1bff1..ef96a88e 100644 --- a/RedPandaIDE/iconsmanager.h +++ b/RedPandaIDE/iconsmanager.h @@ -178,7 +178,8 @@ public: void setIconSetsFolder(const QString &newIconSetsFolder); QList listIconSets(); - +private: + void updateMakeDisabledIconDarker(const QString& iconset); signals: void actionIconsUpdated(); private: @@ -187,6 +188,7 @@ private: QSize mActionIconSize; QString mIconSetTemplate; QString mIconSetsFolder; + bool mMakeDisabledIconDarker; }; extern IconsManager* pIconsManager; diff --git a/RedPandaIDE/widgets/customdisablediconengine.cpp b/RedPandaIDE/widgets/customdisablediconengine.cpp new file mode 100644 index 00000000..c1176a67 --- /dev/null +++ b/RedPandaIDE/widgets/customdisablediconengine.cpp @@ -0,0 +1,64 @@ +#include "customdisablediconengine.h" + +#include +#include +#include +#include + +CustomDisabledIconEngine::CustomDisabledIconEngine() +{ + +} + +void CustomDisabledIconEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) +{ +// if (mode == QIcon::Active && state == QIcon::On) +// painter->drawPixmap(rect,mPixmap); +// else +// painter->drawPixmap(rect,mDisabledPixmap); +} + +QIconEngine *CustomDisabledIconEngine::clone() const +{ + return new CustomDisabledIconEngine(); +} + +QPixmap CustomDisabledIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) +{ + if (mode == QIcon::Mode::Disabled) + return mDisabledPixmap; + else + return mPixmap; +} + +void CustomDisabledIconEngine::addPixmap(const QPixmap &pixmap, QIcon::Mode mode, QIcon::State state) +{ + setPixmap(pixmap); +} + +void CustomDisabledIconEngine::addFile(const QString &fileName, const QSize &size, QIcon::Mode mode, QIcon::State state) +{ + setPixmap(QPixmap(fileName)); +} + +void CustomDisabledIconEngine::setPixmap(const QPixmap &pixmap) +{ + mPixmap = pixmap; + if (pixmap.isNull()) + mDisabledPixmap = pixmap; + else { + QImage oldImage = mPixmap.toImage(); + QImage image(mPixmap.size(), QImage::Format_ARGB32); + for (int x=0;x + +class CustomDisabledIconEngine : public QIconEngine +{ +public: + CustomDisabledIconEngine(); + + // QIconEngine interface +public: + void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) override; + QIconEngine *clone() const override; + QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) override; + void addPixmap(const QPixmap &pixmap, QIcon::Mode mode, QIcon::State state) override; + void addFile(const QString &fileName, const QSize &size, QIcon::Mode mode, QIcon::State state) override; + +private: + void setPixmap(const QPixmap& pixmap); +private: + QPixmap mPixmap; + QPixmap mDisabledPixmap; +}; + +#endif // CUSTOMDISABLEDICONENGINE_H