From 070327a259f2958562351742a41be62ef48f802a Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Thu, 25 Apr 2024 11:57:43 +0400 Subject: [PATCH 1/2] Change SVG color in the editor --- CHANGELOG.md | 1 + apps/opencs/main.cpp | 4 + apps/opencs/view/doc/startup.cpp | 6 +- apps/opencs/view/doc/view.cpp | 11 +- apps/opencs/view/filter/editwidget.cpp | 3 +- apps/opencs/view/render/instancemode.cpp | 5 +- apps/opencs/view/render/instancemovemode.cpp | 4 +- .../view/render/pagedworldspacewidget.cpp | 5 +- apps/opencs/view/render/pathgridmode.cpp | 3 +- apps/opencs/view/render/terrainshapemode.cpp | 5 +- .../opencs/view/render/terraintexturemode.cpp | 5 +- apps/opencs/view/render/worldspacewidget.cpp | 3 +- apps/opencs/view/widget/scenetoolmode.cpp | 4 +- apps/opencs/view/widget/scenetoolrun.cpp | 4 +- .../view/widget/scenetoolshapebrush.cpp | 18 ++- .../view/widget/scenetooltexturebrush.cpp | 18 ++- apps/opencs/view/widget/scenetooltoggle2.cpp | 8 +- .../opencs/view/world/datadisplaydelegate.cpp | 4 +- apps/opencs/view/world/dragrecordtable.cpp | 4 +- apps/opencs/view/world/recordbuttonbar.cpp | 18 ++- .../view/world/referenceablecreator.cpp | 5 +- apps/opencs/view/world/table.cpp | 27 ++-- apps/opencs/view/world/tablesubview.cpp | 4 +- components/CMakeLists.txt | 2 +- components/misc/scalableicon.cpp | 101 +++++++++++++ components/misc/scalableicon.hpp | 36 +++++ files/opencs/brush-circle.svg | 2 +- files/opencs/brush-custom.svg | 2 +- files/opencs/brush-point.svg | 4 +- files/opencs/brush-square.svg | 2 +- files/opencs/camera-first-person.svg | 2 +- files/opencs/camera-free.svg | 6 +- files/opencs/camera-orbit.svg | 2 +- files/opencs/editing-pathgrid.svg | 6 +- files/opencs/editing-terrain-movement.svg | 18 +-- files/opencs/editing-terrain-shape.svg | 32 +++- files/opencs/editing-terrain-vertex-paint.svg | 8 +- files/opencs/lighting-moon.svg | 6 +- files/opencs/resources.qrc | 2 +- files/opencs/scene-exterior-arrows.svg | 14 +- files/opencs/scene-exterior-borders.svg | 14 +- files/opencs/scene-exterior-markers.svg | 18 +-- files/opencs/scene-exterior-status-0.svg | 71 ++++++--- files/opencs/scene-exterior-status-1.svg | 71 ++++++--- files/opencs/scene-exterior-status-2.svg | 71 ++++++--- files/opencs/scene-exterior-status-3.svg | 71 ++++++--- files/opencs/scene-exterior-status-4.svg | 71 ++++++--- files/opencs/scene-exterior-status-5.svg | 86 ++++++++--- files/opencs/scene-exterior-status-6.svg | 86 ++++++++--- files/opencs/scene-exterior-status-7.svg | 35 +++-- files/opencs/scene-view-instance.svg | 2 +- files/opencs/scene-view-status-0.svg | 143 +----------------- files/opencs/scene-view-status-1.svg | 2 +- files/opencs/scene-view-status-10.svg | 14 +- files/opencs/scene-view-status-11.svg | 30 ++-- files/opencs/scene-view-status-12.svg | 24 +-- files/opencs/scene-view-status-13.svg | 16 +- files/opencs/scene-view-status-14.svg | 14 +- files/opencs/scene-view-status-15.svg | 8 +- files/opencs/scene-view-status-3.svg | 2 +- files/opencs/scene-view-status-5.svg | 2 +- files/opencs/scene-view-status-7.svg | 2 +- files/opencs/scene-view-status-8.svg | 6 +- files/opencs/scene-view-status-9.svg | 16 +- files/opencs/scene-view-terrain.svg | 4 +- files/opencs/selection-mode-cube-corner.svg | 30 ++-- files/opencs/selection-mode-cube.svg | 16 +- files/opencs/selection-mode-sphere.svg | 34 ++--- files/opencs/transform-move.svg | 2 +- files/opencs/transform-rotate.svg | 2 +- files/opencs/transform-scale.svg | 2 +- 71 files changed, 854 insertions(+), 525 deletions(-) create mode 100644 components/misc/scalableicon.cpp create mode 100644 components/misc/scalableicon.hpp diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e0d96dec1..43037c945e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -230,6 +230,7 @@ Feature #7923: Don't show non-existent higher ranks for factions with fewer than 9 ranks Feature #7932: Support two-channel normal maps Feature #7936: Scalable icons in Qt applications + Feature #7953: Allow to change SVG icons colors depending on color scheme Task #5896: Do not use deprecated MyGUI properties Task #6085: Replace boost::filesystem with std::filesystem Task #6149: Dehardcode Lua API_REVISION diff --git a/apps/opencs/main.cpp b/apps/opencs/main.cpp index 62fb29e600..b3fd60b657 100644 --- a/apps/opencs/main.cpp +++ b/apps/opencs/main.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include "model/doc/messages.hpp" @@ -32,6 +33,9 @@ private: { try { + if (event->type() == QEvent::ThemeChange || event->type() == QEvent::PaletteChange) + Misc::ScalableIcon::updateAllIcons(); + return QApplication::notify(receiver, event); } catch (const std::exception& exception) diff --git a/apps/opencs/view/doc/startup.cpp b/apps/opencs/view/doc/startup.cpp index e6323bf1a1..c6e109355f 100644 --- a/apps/opencs/view/doc/startup.cpp +++ b/apps/opencs/view/doc/startup.cpp @@ -1,5 +1,7 @@ #include "startup.hpp" +#include + #include #include #include @@ -16,7 +18,7 @@ QPushButton* CSVDoc::StartupDialogue::addButton(const QString& label, const QStr QPushButton* button = new QPushButton(this); - button->setIcon(QIcon(icon)); + button->setIcon(Misc::ScalableIcon::load(icon)); button->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)); @@ -78,7 +80,7 @@ QWidget* CSVDoc::StartupDialogue::createTools() QPushButton* config = new QPushButton(widget); config->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); - config->setIcon(QIcon(":startup/configure")); + config->setIcon(Misc::ScalableIcon::load(":startup/configure")); config->setToolTip("Open user settings"); layout->addWidget(config); diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 88a33108c0..f6ef02ad6d 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -36,6 +36,7 @@ #include #include +#include #include #include @@ -140,13 +141,13 @@ void CSVDoc::View::setupEditMenu() mUndo = mDocument->getUndoStack().createUndoAction(this, tr("Undo")); setupShortcut("document-edit-undo", mUndo); connect(mUndo, &QAction::changed, this, &View::undoActionChanged); - mUndo->setIcon(QIcon(QString::fromStdString(":menu-undo"))); + mUndo->setIcon(Misc::ScalableIcon::load(":menu-undo")); edit->addAction(mUndo); mRedo = mDocument->getUndoStack().createRedoAction(this, tr("Redo")); connect(mRedo, &QAction::changed, this, &View::redoActionChanged); setupShortcut("document-edit-redo", mRedo); - mRedo->setIcon(QIcon(QString::fromStdString(":menu-redo"))); + mRedo->setIcon(Misc::ScalableIcon::load(":menu-redo")); edit->addAction(mRedo); QAction* userSettings = createMenuEntry("Preferences", ":menu-preferences", edit, "document-edit-preferences"); @@ -340,7 +341,7 @@ void CSVDoc::View::setupDebugMenu() QAction* runDebug = debug->addMenu(mGlobalDebugProfileMenu); runDebug->setText(tr("Run OpenMW")); setupShortcut("document-debug-run", runDebug); - runDebug->setIcon(QIcon(QString::fromStdString(":run-openmw"))); + runDebug->setIcon(Misc::ScalableIcon::load(":run-openmw")); QAction* stopDebug = createMenuEntry("Stop OpenMW", ":stop-openmw", debug, "document-debug-shutdown"); connect(stopDebug, &QAction::triggered, this, &View::stop); @@ -374,7 +375,7 @@ QAction* CSVDoc::View::createMenuEntry(CSMWorld::UniversalId::Type type, QMenu* setupShortcut(shortcutName, entry); const std::string iconName = CSMWorld::UniversalId(type).getIcon(); if (!iconName.empty() && iconName != ":placeholder") - entry->setIcon(QIcon(QString::fromStdString(iconName))); + entry->setIcon(Misc::ScalableIcon::load(QString::fromStdString(iconName))); menu->addAction(entry); @@ -387,7 +388,7 @@ QAction* CSVDoc::View::createMenuEntry( QAction* entry = new QAction(QString::fromStdString(title), this); setupShortcut(shortcutName, entry); if (!iconName.empty() && iconName != ":placeholder") - entry->setIcon(QIcon(QString::fromStdString(iconName))); + entry->setIcon(Misc::ScalableIcon::load(QString::fromStdString(iconName))); menu->addAction(entry); diff --git a/apps/opencs/view/filter/editwidget.cpp b/apps/opencs/view/filter/editwidget.cpp index 0d7ab679b2..8076e99e63 100644 --- a/apps/opencs/view/filter/editwidget.cpp +++ b/apps/opencs/view/filter/editwidget.cpp @@ -18,6 +18,7 @@ #include #include +#include #include "../../model/prefs/shortcut.hpp" #include "../../model/world/columns.hpp" @@ -44,7 +45,7 @@ CSVFilter::EditWidget::EditWidget(CSMWorld::Data& data, QWidget* parent) mHelpAction = new QAction(tr("Help"), this); connect(mHelpAction, &QAction::triggered, this, &EditWidget::openHelp); - mHelpAction->setIcon(QIcon(":info")); + mHelpAction->setIcon(Misc::ScalableIcon::load(":info")); addAction(mHelpAction); auto* openHelpShortcut = new CSMPrefs::Shortcut("help", this); openHelpShortcut->associateAction(mHelpAction); diff --git a/apps/opencs/view/render/instancemode.cpp b/apps/opencs/view/render/instancemode.cpp index 2d79c912f6..bc821ee25a 100644 --- a/apps/opencs/view/render/instancemode.cpp +++ b/apps/opencs/view/render/instancemode.cpp @@ -40,6 +40,7 @@ #include #include +#include #include "../../model/prefs/shortcut.hpp" #include "../../model/world/commandmacro.hpp" @@ -253,8 +254,8 @@ void CSVRender::InstanceMode::getSelectionGroup(const int group) CSVRender::InstanceMode::InstanceMode( WorldspaceWidget* worldspaceWidget, osg::ref_ptr parentNode, QWidget* parent) - : EditMode(worldspaceWidget, QIcon(":scenetoolbar/editing-instance"), Mask_Reference | Mask_Terrain, - "Instance editing", parent) + : EditMode(worldspaceWidget, Misc::ScalableIcon::load(":scenetoolbar/editing-instance"), + Mask_Reference | Mask_Terrain, "Instance editing", parent) , mSubMode(nullptr) , mSubModeId("move") , mSelectionMode(nullptr) diff --git a/apps/opencs/view/render/instancemovemode.cpp b/apps/opencs/view/render/instancemovemode.cpp index bc999eb633..bf0ef9d181 100644 --- a/apps/opencs/view/render/instancemovemode.cpp +++ b/apps/opencs/view/render/instancemovemode.cpp @@ -5,10 +5,12 @@ #include +#include + class QWidget; CSVRender::InstanceMoveMode::InstanceMoveMode(QWidget* parent) - : ModeButton(QIcon(":scenetoolbar/transform-move"), + : ModeButton(Misc::ScalableIcon::load(":scenetoolbar/transform-move"), "Move selected instances" "
  • Use {scene-edit-primary} to move instances around freely
  • " "
  • Use {scene-edit-secondary} to move instances around within the grid
  • " diff --git a/apps/opencs/view/render/pagedworldspacewidget.cpp b/apps/opencs/view/render/pagedworldspacewidget.cpp index 58523ab595..062882bd04 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.cpp +++ b/apps/opencs/view/render/pagedworldspacewidget.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -169,8 +170,8 @@ void CSVRender::PagedWorldspaceWidget::addEditModeSelectorButtons(CSVWidget::Sce /// \todo replace EditMode with suitable subclasses tool->addButton(new TerrainShapeMode(this, mRootNode, tool), "terrain-shape"); tool->addButton(new TerrainTextureMode(this, mRootNode, tool), "terrain-texture"); - const QIcon vertexIcon = QIcon(":scenetoolbar/editing-terrain-vertex-paint"); - const QIcon movementIcon = QIcon(":scenetoolbar/editing-terrain-movement"); + const QIcon vertexIcon = Misc::ScalableIcon::load(":scenetoolbar/editing-terrain-vertex-paint"); + const QIcon movementIcon = Misc::ScalableIcon::load(":scenetoolbar/editing-terrain-movement"); tool->addButton(new EditMode(this, vertexIcon, Mask_Reference, "Terrain vertex paint editing"), "terrain-vertex"); tool->addButton(new EditMode(this, movementIcon, Mask_Reference, "Terrain movement"), "terrain-move"); } diff --git a/apps/opencs/view/render/pathgridmode.cpp b/apps/opencs/view/render/pathgridmode.cpp index 8550195e8c..8d68ef9650 100644 --- a/apps/opencs/view/render/pathgridmode.cpp +++ b/apps/opencs/view/render/pathgridmode.cpp @@ -2,6 +2,7 @@ #include +#include #include #include "../../model/prefs/state.hpp" @@ -36,7 +37,7 @@ class QWidget; namespace CSVRender { PathgridMode::PathgridMode(WorldspaceWidget* worldspaceWidget, QWidget* parent) - : EditMode(worldspaceWidget, QIcon(":scenetoolbar/editing-pathgrid"), + : EditMode(worldspaceWidget, Misc::ScalableIcon::load(":scenetoolbar/editing-pathgrid"), Mask_Pathgrid | Mask_Terrain | Mask_Reference, getTooltip(), parent) , mDragMode(DragMode_None) , mFromNode(0) diff --git a/apps/opencs/view/render/terrainshapemode.cpp b/apps/opencs/view/render/terrainshapemode.cpp index 6e1a216816..eee1f20ec6 100644 --- a/apps/opencs/view/render/terrainshapemode.cpp +++ b/apps/opencs/view/render/terrainshapemode.cpp @@ -31,6 +31,7 @@ #include #include +#include #include "../widget/scenetoolbar.hpp" #include "../widget/scenetoolshapebrush.hpp" @@ -62,8 +63,8 @@ namespace osg CSVRender::TerrainShapeMode::TerrainShapeMode( WorldspaceWidget* worldspaceWidget, osg::Group* parentNode, QWidget* parent) - : EditMode( - worldspaceWidget, QIcon{ ":scenetoolbar/editing-terrain-shape" }, Mask_Terrain, "Terrain land editing", parent) + : EditMode(worldspaceWidget, Misc::ScalableIcon::load(":scenetoolbar/editing-terrain-shape"), Mask_Terrain, + "Terrain land editing", parent) , mParentNode(parentNode) { } diff --git a/apps/opencs/view/render/terraintexturemode.cpp b/apps/opencs/view/render/terraintexturemode.cpp index 684958da34..d89261aa1e 100644 --- a/apps/opencs/view/render/terraintexturemode.cpp +++ b/apps/opencs/view/render/terraintexturemode.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include "../widget/scenetoolbar.hpp" @@ -49,8 +50,8 @@ CSVRender::TerrainTextureMode::TerrainTextureMode( WorldspaceWidget* worldspaceWidget, osg::Group* parentNode, QWidget* parent) - : EditMode(worldspaceWidget, QIcon{ ":scenetoolbar/editing-terrain-texture" }, Mask_Terrain | Mask_Reference, - "Terrain texture editing", parent) + : EditMode(worldspaceWidget, Misc::ScalableIcon::load(":scenetoolbar/editing-terrain-texture"), + Mask_Terrain | Mask_Reference, "Terrain texture editing", parent) , mBrushTexture("L0#0") , mBrushSize(1) , mBrushShape(CSVWidget::BrushShape_Point) diff --git a/apps/opencs/view/render/worldspacewidget.cpp b/apps/opencs/view/render/worldspacewidget.cpp index 2af84fb36d..089cb01f07 100644 --- a/apps/opencs/view/render/worldspacewidget.cpp +++ b/apps/opencs/view/render/worldspacewidget.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -220,7 +221,7 @@ CSVWidget::SceneToolMode* CSVRender::WorldspaceWidget::makeNavigationSelector(CS "
  • Hold {free-forward:mod} to speed up movement
  • " "
"); tool->addButton( - new CSVRender::OrbitCameraMode(this, QIcon(":scenetoolbar/orbiting-camera"), + new CSVRender::OrbitCameraMode(this, Misc::ScalableIcon::load(":scenetoolbar/orbiting-camera"), "Orbiting Camera" "
  • Always facing the centre point
  • " "
  • Rotate around the centre point via {orbit-up}, {orbit-left}, {orbit-down}, {orbit-right} or by moving " diff --git a/apps/opencs/view/widget/scenetoolmode.cpp b/apps/opencs/view/widget/scenetoolmode.cpp index 1fa7cfb690..f11d7489a8 100644 --- a/apps/opencs/view/widget/scenetoolmode.cpp +++ b/apps/opencs/view/widget/scenetoolmode.cpp @@ -10,6 +10,8 @@ #include #include +#include + #include #include @@ -94,7 +96,7 @@ void CSVWidget::SceneToolMode::showPanel(const QPoint& position) void CSVWidget::SceneToolMode::addButton(const std::string& icon, const std::string& id, const QString& tooltip) { - ModeButton* button = new ModeButton(QIcon(icon.c_str()), tooltip, mPanel); + ModeButton* button = new ModeButton(Misc::ScalableIcon::load(icon.c_str()), tooltip, mPanel); addButton(button, id); } diff --git a/apps/opencs/view/widget/scenetoolrun.cpp b/apps/opencs/view/widget/scenetoolrun.cpp index 6313f10fa9..59d5bf4d5e 100644 --- a/apps/opencs/view/widget/scenetoolrun.cpp +++ b/apps/opencs/view/widget/scenetoolrun.cpp @@ -8,6 +8,8 @@ #include #include +#include + #include #include @@ -60,7 +62,7 @@ CSVWidget::SceneToolRun::SceneToolRun( , mSelected(mProfiles.begin()) , mToolTip(toolTip) { - setIcon(QIcon(icon)); + setIcon(Misc::ScalableIcon::load(icon)); updateIcon(); adjustToolTips(); diff --git a/apps/opencs/view/widget/scenetoolshapebrush.cpp b/apps/opencs/view/widget/scenetoolshapebrush.cpp index 0e040c2385..1430300622 100644 --- a/apps/opencs/view/widget/scenetoolshapebrush.cpp +++ b/apps/opencs/view/widget/scenetoolshapebrush.cpp @@ -16,6 +16,8 @@ #include #include +#include + #include #include #include @@ -60,10 +62,10 @@ CSVWidget::ShapeBrushWindow::ShapeBrushWindow(CSMDoc::Document& document, QWidge : QFrame(parent, Qt::Popup) , mDocument(document) { - mButtonPoint = new QPushButton(QIcon(":scenetoolbar/brush-point"), "", this); - mButtonSquare = new QPushButton(QIcon(":scenetoolbar/brush-square"), "", this); - mButtonCircle = new QPushButton(QIcon(":scenetoolbar/brush-circle"), "", this); - mButtonCustom = new QPushButton(QIcon(":scenetoolbar/brush-custom"), "", this); + mButtonPoint = new QPushButton(Misc::ScalableIcon::load(":scenetoolbar/brush-point"), "", this); + mButtonSquare = new QPushButton(Misc::ScalableIcon::load(":scenetoolbar/brush-square"), "", this); + mButtonCircle = new QPushButton(Misc::ScalableIcon::load(":scenetoolbar/brush-circle"), "", this); + mButtonCustom = new QPushButton(Misc::ScalableIcon::load(":scenetoolbar/brush-custom"), "", this); mSizeSliders = new ShapeBrushSizeControls("Brush size", this); @@ -201,25 +203,25 @@ void CSVWidget::SceneToolShapeBrush::setButtonIcon(CSVWidget::BrushShape brushSh { case BrushShape_Point: - setIcon(QIcon(":scenetoolbar/brush-point")); + setIcon(Misc::ScalableIcon::load(":scenetoolbar/brush-point")); tooltip += mShapeBrushWindow->toolTipPoint; break; case BrushShape_Square: - setIcon(QIcon(":scenetoolbar/brush-square")); + setIcon(Misc::ScalableIcon::load(":scenetoolbar/brush-square")); tooltip += mShapeBrushWindow->toolTipSquare; break; case BrushShape_Circle: - setIcon(QIcon(":scenetoolbar/brush-circle")); + setIcon(Misc::ScalableIcon::load(":scenetoolbar/brush-circle")); tooltip += mShapeBrushWindow->toolTipCircle; break; case BrushShape_Custom: - setIcon(QIcon(":scenetoolbar/brush-custom")); + setIcon(Misc::ScalableIcon::load(":scenetoolbar/brush-custom")); tooltip += mShapeBrushWindow->toolTipCustom; break; } diff --git a/apps/opencs/view/widget/scenetooltexturebrush.cpp b/apps/opencs/view/widget/scenetooltexturebrush.cpp index 2e002aaf2e..e2cb241cb3 100644 --- a/apps/opencs/view/widget/scenetooltexturebrush.cpp +++ b/apps/opencs/view/widget/scenetooltexturebrush.cpp @@ -31,6 +31,8 @@ #include #include +#include + #include "../../model/doc/document.hpp" #include "../../model/prefs/state.hpp" #include "../../model/world/commands.hpp" @@ -90,10 +92,10 @@ CSVWidget::TextureBrushWindow::TextureBrushWindow(CSMDoc::Document& document, QW mSelectedBrush = new QLabel(QString::fromStdString(mBrushTextureLabel)); } - mButtonPoint = new QPushButton(QIcon(":scenetoolbar/brush-point"), "", this); - mButtonSquare = new QPushButton(QIcon(":scenetoolbar/brush-square"), "", this); - mButtonCircle = new QPushButton(QIcon(":scenetoolbar/brush-circle"), "", this); - mButtonCustom = new QPushButton(QIcon(":scenetoolbar/brush-custom"), "", this); + mButtonPoint = new QPushButton(Misc::ScalableIcon::load(":scenetoolbar/brush-point"), "", this); + mButtonSquare = new QPushButton(Misc::ScalableIcon::load(":scenetoolbar/brush-square"), "", this); + mButtonCircle = new QPushButton(Misc::ScalableIcon::load(":scenetoolbar/brush-circle"), "", this); + mButtonCustom = new QPushButton(Misc::ScalableIcon::load(":scenetoolbar/brush-custom"), "", this); mSizeSliders = new BrushSizeControls("Brush size", this); @@ -282,25 +284,25 @@ void CSVWidget::SceneToolTextureBrush::setButtonIcon(CSVWidget::BrushShape brush { case BrushShape_Point: - setIcon(QIcon(":scenetoolbar/brush-point")); + setIcon(Misc::ScalableIcon::load(":scenetoolbar/brush-point")); tooltip += mTextureBrushWindow->toolTipPoint; break; case BrushShape_Square: - setIcon(QIcon(":scenetoolbar/brush-square")); + setIcon(Misc::ScalableIcon::load(":scenetoolbar/brush-square")); tooltip += mTextureBrushWindow->toolTipSquare; break; case BrushShape_Circle: - setIcon(QIcon(":scenetoolbar/brush-circle")); + setIcon(Misc::ScalableIcon::load(":scenetoolbar/brush-circle")); tooltip += mTextureBrushWindow->toolTipCircle; break; case BrushShape_Custom: - setIcon(QIcon(":scenetoolbar/brush-custom")); + setIcon(Misc::ScalableIcon::load(":scenetoolbar/brush-custom")); tooltip += mTextureBrushWindow->toolTipCustom; break; } diff --git a/apps/opencs/view/widget/scenetooltoggle2.cpp b/apps/opencs/view/widget/scenetooltoggle2.cpp index 44bffa34a6..9e1e8b11c6 100644 --- a/apps/opencs/view/widget/scenetooltoggle2.cpp +++ b/apps/opencs/view/widget/scenetooltoggle2.cpp @@ -10,6 +10,8 @@ #include +#include + #include "pushbutton.hpp" #include "scenetoolbar.hpp" @@ -50,7 +52,7 @@ void CSVWidget::SceneToolToggle2::adjustIcon() std::ostringstream stream; stream << mCompositeIcon << buttonIds; - setIcon(QIcon(QString::fromUtf8(stream.str().c_str()))); + setIcon(Misc::ScalableIcon::load(QString::fromUtf8(stream.str().c_str()))); } CSVWidget::SceneToolToggle2::SceneToolToggle2( @@ -87,8 +89,8 @@ void CSVWidget::SceneToolToggle2::addButton( std::ostringstream stream; stream << mSingleIcon << id; - PushButton* button = new PushButton( - QIcon(stream.str().c_str()), PushButton::Type_Toggle, tooltip.isEmpty() ? name : tooltip, mPanel); + PushButton* button = new PushButton(Misc::ScalableIcon::load(stream.str().c_str()), PushButton::Type_Toggle, + tooltip.isEmpty() ? name : tooltip, mPanel); button->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); button->setIconSize(QSize(mIconSize, mIconSize)); diff --git a/apps/opencs/view/world/datadisplaydelegate.cpp b/apps/opencs/view/world/datadisplaydelegate.cpp index fc6a2b7d80..989d1af464 100644 --- a/apps/opencs/view/world/datadisplaydelegate.cpp +++ b/apps/opencs/view/world/datadisplaydelegate.cpp @@ -17,6 +17,8 @@ #include #include +#include + class QModelIndex; class QObject; @@ -161,7 +163,7 @@ void CSVWorld::DataDisplayDelegateFactory::add(int enumValue, const QString& enu Icon icon; icon.mValue = enumValue; icon.mName = enumName; - icon.mIcon = QIcon(iconFilename); + icon.mIcon = Misc::ScalableIcon::load(iconFilename); for (auto it = mIcons.begin(); it != mIcons.end(); ++it) { diff --git a/apps/opencs/view/world/dragrecordtable.cpp b/apps/opencs/view/world/dragrecordtable.cpp index a8a3df309c..a006779ba4 100644 --- a/apps/opencs/view/world/dragrecordtable.cpp +++ b/apps/opencs/view/world/dragrecordtable.cpp @@ -14,6 +14,8 @@ #include #include +#include + #include "dragdroputils.hpp" void CSVWorld::DragRecordTable::startDragFromTable(const CSVWorld::DragRecordTable& table, const QModelIndex& index) @@ -29,7 +31,7 @@ void CSVWorld::DragRecordTable::startDragFromTable(const CSVWorld::DragRecordTab mime->setIndexAtDragStart(index); QDrag* drag = new QDrag(this); drag->setMimeData(mime); - drag->setPixmap(QIcon(mime->getIcon().c_str()).pixmap(QSize(16, 16))); + drag->setPixmap(Misc::ScalableIcon::load(mime->getIcon().c_str()).pixmap(QSize(16, 16))); drag->exec(Qt::CopyAction); } diff --git a/apps/opencs/view/world/recordbuttonbar.cpp b/apps/opencs/view/world/recordbuttonbar.cpp index 1333a4a7da..e2655136a1 100644 --- a/apps/opencs/view/world/recordbuttonbar.cpp +++ b/apps/opencs/view/world/recordbuttonbar.cpp @@ -12,6 +12,8 @@ #include "../world/tablebottombox.hpp" +#include + #include #include #include @@ -68,12 +70,12 @@ CSVWorld::RecordButtonBar::RecordButtonBar(const CSMWorld::UniversalId& id, CSMW // left section mPrevButton = new QToolButton(this); - mPrevButton->setIcon(QIcon(":record-previous")); + mPrevButton->setIcon(Misc::ScalableIcon::load(":record-previous")); mPrevButton->setToolTip("Switch to previous record"); buttonsLayout->addWidget(mPrevButton, 0); mNextButton = new QToolButton(this); - mNextButton->setIcon(QIcon(":/record-next")); + mNextButton->setIcon(Misc::ScalableIcon::load(":/record-next")); mNextButton->setToolTip("Switch to next record"); buttonsLayout->addWidget(mNextButton, 1); @@ -83,7 +85,7 @@ CSVWorld::RecordButtonBar::RecordButtonBar(const CSMWorld::UniversalId& id, CSMW if (mTable.getFeatures() & CSMWorld::IdTable::Feature_Preview) { QToolButton* previewButton = new QToolButton(this); - previewButton->setIcon(QIcon(":edit-preview")); + previewButton->setIcon(Misc::ScalableIcon::load(":edit-preview")); previewButton->setToolTip("Open a preview of this record"); buttonsLayout->addWidget(previewButton); connect(previewButton, &QToolButton::clicked, this, &RecordButtonBar::showPreview); @@ -92,7 +94,7 @@ CSVWorld::RecordButtonBar::RecordButtonBar(const CSMWorld::UniversalId& id, CSMW if (mTable.getFeatures() & CSMWorld::IdTable::Feature_View) { QToolButton* viewButton = new QToolButton(this); - viewButton->setIcon(QIcon(":cell")); + viewButton->setIcon(Misc::ScalableIcon::load(":cell")); viewButton->setToolTip("Open a scene view of the cell this record is located in"); buttonsLayout->addWidget(viewButton); connect(viewButton, &QToolButton::clicked, this, &RecordButtonBar::viewRecord); @@ -100,22 +102,22 @@ CSVWorld::RecordButtonBar::RecordButtonBar(const CSMWorld::UniversalId& id, CSMW // right section mCloneButton = new QToolButton(this); - mCloneButton->setIcon(QIcon(":edit-clone")); + mCloneButton->setIcon(Misc::ScalableIcon::load(":edit-clone")); mCloneButton->setToolTip("Clone record"); buttonsLayout->addWidget(mCloneButton); mAddButton = new QToolButton(this); - mAddButton->setIcon(QIcon(":edit-add")); + mAddButton->setIcon(Misc::ScalableIcon::load(":edit-add")); mAddButton->setToolTip("Add new record"); buttonsLayout->addWidget(mAddButton); mDeleteButton = new QToolButton(this); - mDeleteButton->setIcon(QIcon(":edit-delete")); + mDeleteButton->setIcon(Misc::ScalableIcon::load(":edit-delete")); mDeleteButton->setToolTip("Delete record"); buttonsLayout->addWidget(mDeleteButton); mRevertButton = new QToolButton(this); - mRevertButton->setIcon(QIcon(":edit-undo")); + mRevertButton->setIcon(Misc::ScalableIcon::load(":edit-undo")); mRevertButton->setToolTip("Revert record"); buttonsLayout->addWidget(mRevertButton); diff --git a/apps/opencs/view/world/referenceablecreator.cpp b/apps/opencs/view/world/referenceablecreator.cpp index e13648d637..c4e20adf72 100644 --- a/apps/opencs/view/world/referenceablecreator.cpp +++ b/apps/opencs/view/world/referenceablecreator.cpp @@ -7,6 +7,8 @@ #include +#include + #include "../../model/world/commands.hpp" #include "../../model/world/universalid.hpp" @@ -38,7 +40,8 @@ CSVWorld::ReferenceableCreator::ReferenceableCreator( { CSMWorld::UniversalId id2(*iter, ""); - mType->addItem(QIcon(id2.getIcon().c_str()), id2.getTypeName().c_str(), static_cast(id2.getType())); + mType->addItem(Misc::ScalableIcon::load(id2.getIcon().c_str()), id2.getTypeName().c_str(), + static_cast(id2.getType())); } mType->model()->sort(0); diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index b7be2b90c8..86a1e93bbd 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include "../../model/doc/document.hpp" @@ -323,7 +324,7 @@ CSVWorld::Table::Table(const CSMWorld::UniversalId& id, bool createAndDelete, bo mEditAction = new QAction(tr("Edit Record"), this); connect(mEditAction, &QAction::triggered, this, &Table::editRecord); - mEditAction->setIcon(QIcon(":edit-edit")); + mEditAction->setIcon(Misc::ScalableIcon::load(":edit-edit")); addAction(mEditAction); CSMPrefs::Shortcut* editShortcut = new CSMPrefs::Shortcut("table-edit", this); editShortcut->associateAction(mEditAction); @@ -332,14 +333,14 @@ CSVWorld::Table::Table(const CSMWorld::UniversalId& id, bool createAndDelete, bo { mCreateAction = new QAction(tr("Add Record"), this); connect(mCreateAction, &QAction::triggered, this, &Table::createRequest); - mCreateAction->setIcon(QIcon(":edit-add")); + mCreateAction->setIcon(Misc::ScalableIcon::load(":edit-add")); addAction(mCreateAction); CSMPrefs::Shortcut* createShortcut = new CSMPrefs::Shortcut("table-add", this); createShortcut->associateAction(mCreateAction); mCloneAction = new QAction(tr("Clone Record"), this); connect(mCloneAction, &QAction::triggered, this, &Table::cloneRecord); - mCloneAction->setIcon(QIcon(":edit-clone")); + mCloneAction->setIcon(Misc::ScalableIcon::load(":edit-clone")); addAction(mCloneAction); CSMPrefs::Shortcut* cloneShortcut = new CSMPrefs::Shortcut("table-clone", this); cloneShortcut->associateAction(mCloneAction); @@ -349,7 +350,7 @@ CSVWorld::Table::Table(const CSMWorld::UniversalId& id, bool createAndDelete, bo { mTouchAction = new QAction(tr("Touch Record"), this); connect(mTouchAction, &QAction::triggered, this, &Table::touchRecord); - mTouchAction->setIcon(QIcon(":edit-touch")); + mTouchAction->setIcon(Misc::ScalableIcon::load(":edit-touch")); addAction(mTouchAction); CSMPrefs::Shortcut* touchShortcut = new CSMPrefs::Shortcut("table-touch", this); touchShortcut->associateAction(mTouchAction); @@ -357,56 +358,56 @@ CSVWorld::Table::Table(const CSMWorld::UniversalId& id, bool createAndDelete, bo mRevertAction = new QAction(tr("Revert Record"), this); connect(mRevertAction, &QAction::triggered, mDispatcher, &CSMWorld::CommandDispatcher::executeRevert); - mRevertAction->setIcon(QIcon(":edit-undo")); + mRevertAction->setIcon(Misc::ScalableIcon::load(":edit-undo")); addAction(mRevertAction); CSMPrefs::Shortcut* revertShortcut = new CSMPrefs::Shortcut("table-revert", this); revertShortcut->associateAction(mRevertAction); mDeleteAction = new QAction(tr("Delete Record"), this); connect(mDeleteAction, &QAction::triggered, mDispatcher, &CSMWorld::CommandDispatcher::executeDelete); - mDeleteAction->setIcon(QIcon(":edit-delete")); + mDeleteAction->setIcon(Misc::ScalableIcon::load(":edit-delete")); addAction(mDeleteAction); CSMPrefs::Shortcut* deleteShortcut = new CSMPrefs::Shortcut("table-remove", this); deleteShortcut->associateAction(mDeleteAction); mMoveUpAction = new QAction(tr("Move Up"), this); connect(mMoveUpAction, &QAction::triggered, this, &Table::moveUpRecord); - mMoveUpAction->setIcon(QIcon(":record-up")); + mMoveUpAction->setIcon(Misc::ScalableIcon::load(":record-up")); addAction(mMoveUpAction); CSMPrefs::Shortcut* moveUpShortcut = new CSMPrefs::Shortcut("table-moveup", this); moveUpShortcut->associateAction(mMoveUpAction); mMoveDownAction = new QAction(tr("Move Down"), this); connect(mMoveDownAction, &QAction::triggered, this, &Table::moveDownRecord); - mMoveDownAction->setIcon(QIcon(":record-down")); + mMoveDownAction->setIcon(Misc::ScalableIcon::load(":record-down")); addAction(mMoveDownAction); CSMPrefs::Shortcut* moveDownShortcut = new CSMPrefs::Shortcut("table-movedown", this); moveDownShortcut->associateAction(mMoveDownAction); mViewAction = new QAction(tr("View"), this); connect(mViewAction, &QAction::triggered, this, &Table::viewRecord); - mViewAction->setIcon(QIcon(":cell")); + mViewAction->setIcon(Misc::ScalableIcon::load(":cell")); addAction(mViewAction); CSMPrefs::Shortcut* viewShortcut = new CSMPrefs::Shortcut("table-view", this); viewShortcut->associateAction(mViewAction); mPreviewAction = new QAction(tr("Preview"), this); connect(mPreviewAction, &QAction::triggered, this, &Table::previewRecord); - mPreviewAction->setIcon(QIcon(":edit-preview")); + mPreviewAction->setIcon(Misc::ScalableIcon::load(":edit-preview")); addAction(mPreviewAction); CSMPrefs::Shortcut* previewShortcut = new CSMPrefs::Shortcut("table-preview", this); previewShortcut->associateAction(mPreviewAction); mExtendedDeleteAction = new QAction(tr("Extended Delete Record"), this); connect(mExtendedDeleteAction, &QAction::triggered, this, &Table::executeExtendedDelete); - mExtendedDeleteAction->setIcon(QIcon(":edit-delete")); + mExtendedDeleteAction->setIcon(Misc::ScalableIcon::load(":edit-delete")); addAction(mExtendedDeleteAction); CSMPrefs::Shortcut* extendedDeleteShortcut = new CSMPrefs::Shortcut("table-extendeddelete", this); extendedDeleteShortcut->associateAction(mExtendedDeleteAction); mExtendedRevertAction = new QAction(tr("Extended Revert Record"), this); connect(mExtendedRevertAction, &QAction::triggered, this, &Table::executeExtendedRevert); - mExtendedRevertAction->setIcon(QIcon(":edit-undo")); + mExtendedRevertAction->setIcon(Misc::ScalableIcon::load(":edit-undo")); addAction(mExtendedRevertAction); CSMPrefs::Shortcut* extendedRevertShortcut = new CSMPrefs::Shortcut("table-extendedrevert", this); extendedRevertShortcut->associateAction(mExtendedRevertAction); @@ -417,7 +418,7 @@ CSVWorld::Table::Table(const CSMWorld::UniversalId& id, bool createAndDelete, bo mHelpAction = new QAction(tr("Help"), this); connect(mHelpAction, &QAction::triggered, this, &Table::openHelp); - mHelpAction->setIcon(QIcon(":info")); + mHelpAction->setIcon(Misc::ScalableIcon::load(":info")); addAction(mHelpAction); CSMPrefs::Shortcut* openHelpShortcut = new CSMPrefs::Shortcut("help", this); openHelpShortcut->associateAction(mHelpAction); diff --git a/apps/opencs/view/world/tablesubview.cpp b/apps/opencs/view/world/tablesubview.cpp index b48eaec31d..e7701ee778 100644 --- a/apps/opencs/view/world/tablesubview.cpp +++ b/apps/opencs/view/world/tablesubview.cpp @@ -17,6 +17,8 @@ #include +#include + #include "../../model/doc/document.hpp" #include "../../model/world/tablemimedata.hpp" @@ -60,7 +62,7 @@ CSVWorld::TableSubView::TableSubView( mOptions->hide(); QPushButton* opt = new QPushButton(); - opt->setIcon(QIcon(":startup/configure")); + opt->setIcon(Misc::ScalableIcon::load(":startup/configure")); opt->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); opt->setToolTip("Open additional options for this subview."); connect(opt, &QPushButton::clicked, this, &TableSubView::toggleOptions); diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 1235072de5..0926f738af 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -534,7 +534,7 @@ if (USE_QT) ) add_component_qt_dir (misc - helpviewer utf8qtextstream hash + helpviewer utf8qtextstream hash scalableicon ) add_component_qt_dir (files diff --git a/components/misc/scalableicon.cpp b/components/misc/scalableicon.cpp new file mode 100644 index 0000000000..c9062a64d0 --- /dev/null +++ b/components/misc/scalableicon.cpp @@ -0,0 +1,101 @@ +#include "scalableicon.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Misc +{ + Q_GLOBAL_STATIC(QSet, ScalableIconInstances) + + ScalableIcon::ScalableIcon(const QByteArray& svgContent) + : mTemplate(svgContent) + { + update(); + ScalableIconInstances->insert(this); + } + + ScalableIcon::~ScalableIcon() + { + if (!ScalableIconInstances.isDestroyed()) + { + ScalableIconInstances->remove(this); + } + } + + QIcon Misc::ScalableIcon::load(const QString& fileName) + { + if (fileName.isEmpty()) + return QIcon(); + + QFile iconFile(fileName); + iconFile.open(QIODevice::ReadOnly); + auto content = iconFile.readAll(); + if (!content.startsWith("update(); + } + } + + void ScalableIcon::paint(QPainter* painter, const QRect& rect, QIcon::Mode mode, QIcon::State state) + { + Q_UNUSED(mode); + Q_UNUSED(state); + + QSvgRenderer renderer(mContent); + renderer.render(painter, rect); + } + + QIconEngine* ScalableIcon::clone() const + { + return new ScalableIcon(*this); + } + + QPixmap ScalableIcon::pixmap(const QSize& size, QIcon::Mode mode, QIcon::State state) + { + QImage img(size, QImage::Format_ARGB32); + img.fill(qRgba(0, 0, 0, 0)); + QPixmap pix = QPixmap::fromImage(img, Qt::NoFormatConversion); + { + QPainter painter(&pix); + QRect r(QPoint(0.0, 0.0), size); + this->paint(&painter, r, mode, state); + } + + if (mode != QIcon::Disabled) + return pix; + + QPixmap output(pix.size()); + output.fill(Qt::transparent); + QPainter p(&output); + p.setOpacity(0.5); + p.drawPixmap(0, 0, pix); + p.end(); + + return output; + } +} diff --git a/components/misc/scalableicon.hpp b/components/misc/scalableicon.hpp new file mode 100644 index 0000000000..06cac9e39d --- /dev/null +++ b/components/misc/scalableicon.hpp @@ -0,0 +1,36 @@ +#ifndef SCALABLEICON_HPP +#define SCALABLEICON_HPP + +#include +#include +#include +#include + +namespace Misc +{ + class ScalableIcon : public QIconEngine + { + public: + QIconEngine* clone() const override; + + QPixmap pixmap(const QSize& size, QIcon::Mode mode, QIcon::State state) override; + + void paint(QPainter* painter, const QRect& rect, QIcon::Mode mode, QIcon::State state) override; + + static void updateAllIcons(); + + virtual ~ScalableIcon(); + + static QIcon load(const QString& fileName); + + private: + explicit ScalableIcon(const QByteArray& svgContent); + + void update(); + + QByteArray mTemplate; + QByteArray mContent; + }; +} + +#endif // SCALABLEICON_HPP diff --git a/files/opencs/brush-circle.svg b/files/opencs/brush-circle.svg index 8bb2491173..9a7334055d 100644 --- a/files/opencs/brush-circle.svg +++ b/files/opencs/brush-circle.svg @@ -41,7 +41,7 @@ style="fill:#4d4d4d;fill-opacity:1;stroke:#808080;stroke-width:8.21086;stroke-dasharray:none;stroke-opacity:1" /> @@ -43,12 +43,12 @@ style="display:inline" transform="matrix(1.3333345,0,0,1.333334,-63.852829,-127.35283)"> + + + + + + @@ -25,12 +49,12 @@ style="display:inline" transform="matrix(1.3333345,0,0,1.333334,-21.519464,-127.35283)"> levelled-creature.svg levelled-item.svg light.svg - list-base.svg list-added.svg + list-base.svg list-modified.svg list-removed.svg lockpick.svg diff --git a/files/opencs/scene-exterior-arrows.svg b/files/opencs/scene-exterior-arrows.svg index 1f923c91bf..c99eb6fc8a 100644 --- a/files/opencs/scene-exterior-arrows.svg +++ b/files/opencs/scene-exterior-arrows.svg @@ -15,7 +15,7 @@ @@ -31,7 +31,7 @@ id="mask-powermask-path-effect3119"> @@ -95,7 +95,7 @@ id="mask-powermask-path-effect1105"> diff --git a/files/opencs/scene-exterior-borders.svg b/files/opencs/scene-exterior-borders.svg index 4a9c2ea4fa..3c63b135bc 100644 --- a/files/opencs/scene-exterior-borders.svg +++ b/files/opencs/scene-exterior-borders.svg @@ -14,7 +14,7 @@ @@ -30,7 +30,7 @@ id="mask-powermask-path-effect3119"> @@ -94,7 +94,7 @@ id="mask-powermask-path-effect1105"> diff --git a/files/opencs/scene-exterior-markers.svg b/files/opencs/scene-exterior-markers.svg index 63900d752f..5203fed48d 100644 --- a/files/opencs/scene-exterior-markers.svg +++ b/files/opencs/scene-exterior-markers.svg @@ -14,7 +14,7 @@ @@ -30,7 +30,7 @@ id="mask-powermask-path-effect3119"> @@ -94,7 +94,7 @@ id="mask-powermask-path-effect1105"> @@ -31,7 +31,7 @@ id="mask-powermask-path-effect3119"> @@ -95,7 +95,7 @@ id="mask-powermask-path-effect1105"> + + + + + + + + - - + + diff --git a/files/opencs/scene-exterior-status-1.svg b/files/opencs/scene-exterior-status-1.svg index f699d767c2..cabf1f75e0 100644 --- a/files/opencs/scene-exterior-status-1.svg +++ b/files/opencs/scene-exterior-status-1.svg @@ -16,7 +16,7 @@ id="Main" gradientTransform="translate(31.749998)"> @@ -32,7 +32,7 @@ id="mask-powermask-path-effect3119"> @@ -96,7 +96,7 @@ id="mask-powermask-path-effect1105"> + + + + + + + + - - + + diff --git a/files/opencs/scene-exterior-status-2.svg b/files/opencs/scene-exterior-status-2.svg index 2d1ab9bbf8..2a1234e667 100644 --- a/files/opencs/scene-exterior-status-2.svg +++ b/files/opencs/scene-exterior-status-2.svg @@ -16,7 +16,7 @@ id="Main" gradientTransform="translate(95.249992)"> @@ -32,7 +32,7 @@ id="mask-powermask-path-effect3119"> @@ -96,7 +96,7 @@ id="mask-powermask-path-effect1105"> + + + + + + + + - - + + diff --git a/files/opencs/scene-exterior-status-3.svg b/files/opencs/scene-exterior-status-3.svg index 401f19a5fa..b76cf0dac0 100644 --- a/files/opencs/scene-exterior-status-3.svg +++ b/files/opencs/scene-exterior-status-3.svg @@ -16,7 +16,7 @@ id="Main" gradientTransform="translate(190.49998)"> @@ -32,7 +32,7 @@ id="mask-powermask-path-effect3119"> @@ -96,7 +96,7 @@ id="mask-powermask-path-effect1105"> + + + + + + + + + + - - diff --git a/files/opencs/scene-exterior-status-4.svg b/files/opencs/scene-exterior-status-4.svg index aebc14b932..afe0215302 100644 --- a/files/opencs/scene-exterior-status-4.svg +++ b/files/opencs/scene-exterior-status-4.svg @@ -16,7 +16,7 @@ id="Main" gradientTransform="translate(317.49996)"> @@ -32,7 +32,7 @@ id="mask-powermask-path-effect3119"> @@ -96,7 +96,7 @@ id="mask-powermask-path-effect1105"> + + + + + + + + - - + + diff --git a/files/opencs/scene-exterior-status-5.svg b/files/opencs/scene-exterior-status-5.svg index 3fb8b98a5f..fc3a7eb7f3 100644 --- a/files/opencs/scene-exterior-status-5.svg +++ b/files/opencs/scene-exterior-status-5.svg @@ -16,7 +16,7 @@ id="Main" gradientTransform="translate(476.24994)"> @@ -32,7 +32,7 @@ id="mask-powermask-path-effect3119"> @@ -96,7 +96,7 @@ id="mask-powermask-path-effect1105"> + + + + + + + + + - - - + + + diff --git a/files/opencs/scene-exterior-status-6.svg b/files/opencs/scene-exterior-status-6.svg index 93c905935a..2a73b15bb1 100644 --- a/files/opencs/scene-exterior-status-6.svg +++ b/files/opencs/scene-exterior-status-6.svg @@ -16,7 +16,7 @@ id="Main" gradientTransform="translate(666.74992)"> @@ -32,7 +32,7 @@ id="mask-powermask-path-effect3119"> @@ -96,7 +96,7 @@ id="mask-powermask-path-effect1105"> + + + + + + + + + - - - + + + diff --git a/files/opencs/scene-exterior-status-7.svg b/files/opencs/scene-exterior-status-7.svg index 89b97866d8..221c69050b 100644 --- a/files/opencs/scene-exterior-status-7.svg +++ b/files/opencs/scene-exterior-status-7.svg @@ -13,10 +13,19 @@ + + + @@ -32,7 +41,7 @@ id="mask-powermask-path-effect3119"> @@ -96,7 +105,7 @@ id="mask-powermask-path-effect1105"> diff --git a/files/opencs/scene-view-instance.svg b/files/opencs/scene-view-instance.svg index 771432bebf..8fe27a1bab 100644 --- a/files/opencs/scene-view-instance.svg +++ b/files/opencs/scene-view-instance.svg @@ -145,7 +145,7 @@ cy="116.15208" r="1.5875" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/files/opencs/scene-view-status-1.svg b/files/opencs/scene-view-status-1.svg index 3dbfa1622a..cfcc7203c2 100644 --- a/files/opencs/scene-view-status-1.svg +++ b/files/opencs/scene-view-status-1.svg @@ -144,7 +144,7 @@ cy="116.15208" r="1.5875" /> + transform="translate(158.81609,-0.529153)"> - - - - + + + + + - + transform="translate(127.06613,15.345815)"> diff --git a/files/opencs/scene-view-status-13.svg b/files/opencs/scene-view-status-13.svg index 1f2b3ab398..e83dded670 100644 --- a/files/opencs/scene-view-status-13.svg +++ b/files/opencs/scene-view-status-13.svg @@ -117,7 +117,7 @@ + transform="matrix(1.0000013,0,0,1,190.56606,-0.529153)"> + transform="translate(206.44103,-0.529153)"> diff --git a/files/opencs/scene-view-status-9.svg b/files/opencs/scene-view-status-9.svg index 5d101ad1f4..598b408732 100644 --- a/files/opencs/scene-view-status-9.svg +++ b/files/opencs/scene-view-status-9.svg @@ -117,7 +117,7 @@ + transform="matrix(0.99999702,0,0,0.99997478,142.87492,0.00291574)"> diff --git a/files/opencs/selection-mode-cube-corner.svg b/files/opencs/selection-mode-cube-corner.svg index 63d5f73c56..21c28e1fc3 100644 --- a/files/opencs/selection-mode-cube-corner.svg +++ b/files/opencs/selection-mode-cube-corner.svg @@ -29,34 +29,34 @@ + transform="matrix(0.95633709,0,0,0.97689208,-70.343751,-63.444673)"> diff --git a/files/opencs/selection-mode-cube.svg b/files/opencs/selection-mode-cube.svg index e03138bafe..d237a7746a 100644 --- a/files/opencs/selection-mode-cube.svg +++ b/files/opencs/selection-mode-cube.svg @@ -28,30 +28,30 @@ + style="display:inline;stroke-width:0.183665;stroke-dasharray:none" + transform="matrix(0.94403189,0,0,0.96988505,-69.504358,-62.928849)"> diff --git a/files/opencs/selection-mode-sphere.svg b/files/opencs/selection-mode-sphere.svg index 9f8ed79340..64bfbb0916 100644 --- a/files/opencs/selection-mode-sphere.svg +++ b/files/opencs/selection-mode-sphere.svg @@ -31,15 +31,13 @@ style="display:inline" transform="matrix(0.95633709,0,0,0.97689208,-70.52014,-63.444673)"> + style="display:inline;fill:none;fill-opacity:1;stroke:#4d4d4d;stroke-width:0.18246;stroke-dasharray:none;stroke-opacity:1" + d="m 76.860371,76.010117 8.085388,-1.488233 3.370361,3.890874 -8.140511,1.599832 z" + id="path6-9" /> + style="display:inline;fill:none;stroke:#4d4d4d;stroke-width:0.18246;stroke-dasharray:none;stroke-opacity:1" + d="m 84.948261,67.211494 0.0099,7.346147" + id="path9" /> + rx="3.5277777" + ry="3.5277779" /> diff --git a/files/opencs/transform-move.svg b/files/opencs/transform-move.svg index 1b9490f001..0cbe1c89f4 100644 --- a/files/opencs/transform-move.svg +++ b/files/opencs/transform-move.svg @@ -26,7 +26,7 @@ gradientTransform="matrix(0.26458333,0,0,0.26458333,-13.80713,103.48169)" osb:paint="solid"> diff --git a/files/opencs/transform-rotate.svg b/files/opencs/transform-rotate.svg index 29bc3fdad5..83f2ca19a7 100644 --- a/files/opencs/transform-rotate.svg +++ b/files/opencs/transform-rotate.svg @@ -18,7 +18,7 @@ gradientTransform="matrix(0.26458333,0,0,0.26458333,-13.80713,103.48169)" osb:paint="solid"> diff --git a/files/opencs/transform-scale.svg b/files/opencs/transform-scale.svg index e4d1d16422..14a8062daf 100644 --- a/files/opencs/transform-scale.svg +++ b/files/opencs/transform-scale.svg @@ -18,7 +18,7 @@ gradientTransform="matrix(0.26458333,0,0,0.26458333,-13.80713,103.48169)" osb:paint="solid"> From 98abfcfe00ce0e09f431f39bea28aafbfc9a4d8b Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sat, 27 Apr 2024 11:25:56 +0400 Subject: [PATCH 2/2] Use grayscale images for disabled icons --- components/misc/scalableicon.cpp | 34 ++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/components/misc/scalableicon.cpp b/components/misc/scalableicon.cpp index c9062a64d0..0b30eaf2ab 100644 --- a/components/misc/scalableicon.cpp +++ b/components/misc/scalableicon.cpp @@ -77,25 +77,29 @@ namespace Misc QPixmap ScalableIcon::pixmap(const QSize& size, QIcon::Mode mode, QIcon::State state) { - QImage img(size, QImage::Format_ARGB32); - img.fill(qRgba(0, 0, 0, 0)); - QPixmap pix = QPixmap::fromImage(img, Qt::NoFormatConversion); - { - QPainter painter(&pix); - QRect r(QPoint(0.0, 0.0), size); - this->paint(&painter, r, mode, state); - } + QPixmap pix = QPixmap(size); + pix.fill(Qt::transparent); + + QPainter painter(&pix); + QRect r(QPoint(0.0, 0.0), size); + this->paint(&painter, r, mode, state); if (mode != QIcon::Disabled) return pix; - QPixmap output(pix.size()); - output.fill(Qt::transparent); - QPainter p(&output); - p.setOpacity(0.5); - p.drawPixmap(0, 0, pix); - p.end(); + // For disabled icons use grayscale icons with 50% transparency + QImage img = pix.toImage(); - return output; + for (int x = 0; x < img.width(); x++) + { + for (int y = 0; y < img.height(); y++) + { + QColor n = img.pixelColor(x, y); + int gray = qGray(n.red(), n.green(), n.blue()); + img.setPixelColor(x, y, QColor(gray, gray, gray, n.alpha() / 2)); + } + } + + return QPixmap::fromImage(img, Qt::NoFormatConversion); } }