diff --git a/src/plugins/scxmleditor/common/mainwidget.cpp b/src/plugins/scxmleditor/common/mainwidget.cpp index 3952b35812c..d67003eb8b3 100644 --- a/src/plugins/scxmleditor/common/mainwidget.cpp +++ b/src/plugins/scxmleditor/common/mainwidget.cpp @@ -77,6 +77,7 @@ #include #include #include +#include using namespace ScxmlEditor::PluginInterface; using namespace ScxmlEditor::Common; @@ -120,6 +121,47 @@ void msgHandler(QtMsgType type, const QMessageLogContext &context, const QString abort(); } +static QIcon toolButtonIcon(ActionType actionType) +{ + QString iconFileName; + + switch (actionType) { + case ActionAlignLeft: + iconFileName = ":/scxmleditor/images/align_left.png"; + break; + case ActionAlignRight: + iconFileName = ":/scxmleditor/images/align_right.png"; + break; + case ActionAlignTop: + iconFileName = ":/scxmleditor/images/align_top.png"; + break; + case ActionAlignBottom: + iconFileName = ":/scxmleditor/images/align_bottom.png"; + break; + case ActionAlignHorizontal: + iconFileName = ":/scxmleditor/images/align_horizontal.png"; + break; + case ActionAlignVertical: + iconFileName = ":/scxmleditor/images/align_vertical.png"; + break; + + case ActionAdjustWidth: + iconFileName = ":/scxmleditor/images/adjust_width.png"; + break; + case ActionAdjustHeight: + iconFileName = ":/scxmleditor/images/adjust_height.png"; + break; + case ActionAdjustSize: + iconFileName = ":/scxmleditor/images/adjust_size.png"; + break; + + default: + return QIcon(); + } + + return Utils::Icon({{iconFileName, Utils::Theme::IconsBaseColor}}).icon(); +} + MainWidget::MainWidget(QWidget *parent) : QWidget(parent) { @@ -289,8 +331,8 @@ void MainWidget::init() // Init ToolButtons auto stateColorButton = new ColorToolButton("StateColor", ":/scxmleditor/images/state_color.png", tr("State Color")); auto fontColorButton = new ColorToolButton("FontColor", ":/scxmleditor/images/font_color.png", tr("Font Color")); - QToolButton *alignToolButton = createToolButton(m_actionHandler->action(ActionAlignLeft)->icon(), tr("Align Left"), QToolButton::MenuButtonPopup); - QToolButton *adjustToolButton = createToolButton(m_actionHandler->action(ActionAdjustWidth)->icon(), tr("Adjust Width"), QToolButton::MenuButtonPopup); + QToolButton *alignToolButton = createToolButton(toolButtonIcon(ActionAlignLeft), tr("Align Left"), QToolButton::MenuButtonPopup); + QToolButton *adjustToolButton = createToolButton(toolButtonIcon(ActionAdjustWidth), tr("Adjust Width"), QToolButton::MenuButtonPopup); // Connect state color change connect(stateColorButton, &ColorToolButton::colorSelected, [this](const QString &color) { @@ -738,7 +780,7 @@ QToolButton *MainWidget::createToolButton(const QIcon &icon, const QString &tool void MainWidget::alignButtonClicked(ActionType alignType) { if (alignType >= ActionAlignLeft && alignType <= ActionAlignVertical) { - m_toolButtons[ToolButtonAlignment]->setIcon(m_actionHandler->action(alignType)->icon()); + m_toolButtons[ToolButtonAlignment]->setIcon(toolButtonIcon(alignType)); m_toolButtons[ToolButtonAlignment]->setToolTip(m_actionHandler->action(alignType)->toolTip()); m_toolButtons[ToolButtonAlignment]->setProperty("currentAlignment", alignType); StateView *view = m_views.last(); @@ -750,7 +792,7 @@ void MainWidget::alignButtonClicked(ActionType alignType) void MainWidget::adjustButtonClicked(ActionType adjustType) { if (adjustType >= ActionAdjustWidth && adjustType <= ActionAdjustSize) { - m_toolButtons[ToolButtonAdjustment]->setIcon(m_actionHandler->action(adjustType)->icon()); + m_toolButtons[ToolButtonAdjustment]->setIcon(toolButtonIcon(adjustType)); m_toolButtons[ToolButtonAdjustment]->setToolTip(m_actionHandler->action(adjustType)->toolTip()); m_toolButtons[ToolButtonAdjustment]->setProperty("currentAdjustment", adjustType); StateView *view = m_views.last(); diff --git a/src/plugins/scxmleditor/plugin_interface/actionhandler.cpp b/src/plugins/scxmleditor/plugin_interface/actionhandler.cpp index 660293186f6..e8067fd0165 100644 --- a/src/plugins/scxmleditor/plugin_interface/actionhandler.cpp +++ b/src/plugins/scxmleditor/plugin_interface/actionhandler.cpp @@ -59,15 +59,15 @@ ActionHandler::ActionHandler(QObject *parent) { Utils::Icon({{":/scxmleditor/images/icon-export-canvas.png", Utils::Theme::IconsBaseColor}}), AH::tr("Export to Image"), AH::tr("Export to Image"), "Ctrl+Shift+E", false }, { Utils::Icon({{":/utils/images/namespace.png", Utils::Theme::IconsBaseColor}}), AH::tr("Toggle Full Namespace"), AH::tr("Toggle Full Namespace"), "Ctrl+Shift+N", true }, - { Utils::Icon({{":/scxmleditor/images/align_left.png", Utils::Theme::IconsBaseColor}}), AH::tr("Align Left"), AH::tr("Align Left (Ctrl+L,1)"), "Ctrl+L,1", false }, - { Utils::Icon({{":/scxmleditor/images/align_right.png", Utils::Theme::IconsBaseColor}}), AH::tr("Align Right"), AH::tr("Align Right (Ctrl+L,2)"), "Ctrl+L,2", false }, - { Utils::Icon({{":/scxmleditor/images/align_top.png", Utils::Theme::IconsBaseColor}}), AH::tr("Align Top"), AH::tr("Align Top (Ctrl+L,3)"), "Ctrl+L,3", false }, - { Utils::Icon({{":/scxmleditor/images/align_bottom.png", Utils::Theme::IconsBaseColor}}), AH::tr("Align Bottom"), AH::tr("Align Bottom (Ctrl+L,4)"), "Ctrl+L,4", false }, - { Utils::Icon({{":/scxmleditor/images/align_horizontal.png", Utils::Theme::IconsBaseColor}}), AH::tr("Align Horizontal"), AH::tr("Align Horizontal (Ctrl+L,5)"), "Ctrl+L,5", false }, - { Utils::Icon({{":/scxmleditor/images/align_vertical.png", Utils::Theme::IconsBaseColor}}), AH::tr("Align Vertical"), AH::tr("Align Vertical (Ctrl+L,6)"), "Ctrl+L,6", false }, - { Utils::Icon({{":/scxmleditor/images/adjust_width.png", Utils::Theme::IconsBaseColor}}), AH::tr("Adjust Width"), AH::tr("Adjust Width (Ctrl+L,7)"), "Ctrl+L,7", false }, - { Utils::Icon({{":/scxmleditor/images/adjust_height.png", Utils::Theme::IconsBaseColor}}), AH::tr("Adjust Height"), AH::tr("Adjust Height (Ctrl+L,8)"), "Ctrl+L,8", false }, - { Utils::Icon({{":/scxmleditor/images/adjust_size.png", Utils::Theme::IconsBaseColor}}), AH::tr("Adjust Size"), AH::tr("Adjust Size (Ctrl+L,9)"), "Ctrl+L,9", false }, + { Utils::Icon({{":/scxmleditor/images/align_left.png", Utils::Theme::PanelTextColorMid}}, Utils::Icon::Tint), AH::tr("Align Left"), AH::tr("Align Left (Ctrl+L,1)"), "Ctrl+L,1", false }, + { Utils::Icon({{":/scxmleditor/images/align_right.png", Utils::Theme::PanelTextColorMid}}, Utils::Icon::Tint), AH::tr("Align Right"), AH::tr("Align Right (Ctrl+L,2)"), "Ctrl+L,2", false }, + { Utils::Icon({{":/scxmleditor/images/align_top.png", Utils::Theme::PanelTextColorMid}}, Utils::Icon::Tint), AH::tr("Align Top"), AH::tr("Align Top (Ctrl+L,3)"), "Ctrl+L,3", false }, + { Utils::Icon({{":/scxmleditor/images/align_bottom.png", Utils::Theme::PanelTextColorMid}}, Utils::Icon::Tint), AH::tr("Align Bottom"), AH::tr("Align Bottom (Ctrl+L,4)"), "Ctrl+L,4", false }, + { Utils::Icon({{":/scxmleditor/images/align_horizontal.png", Utils::Theme::PanelTextColorMid}}, Utils::Icon::Tint), AH::tr("Align Horizontal"), AH::tr("Align Horizontal (Ctrl+L,5)"), "Ctrl+L,5", false }, + { Utils::Icon({{":/scxmleditor/images/align_vertical.png", Utils::Theme::PanelTextColorMid}}, Utils::Icon::Tint), AH::tr("Align Vertical"), AH::tr("Align Vertical (Ctrl+L,6)"), "Ctrl+L,6", false }, + { Utils::Icon({{":/scxmleditor/images/adjust_width.png", Utils::Theme::PanelTextColorMid}}, Utils::Icon::Tint), AH::tr("Adjust Width"), AH::tr("Adjust Width (Ctrl+L,7)"), "Ctrl+L,7", false }, + { Utils::Icon({{":/scxmleditor/images/adjust_height.png", Utils::Theme::PanelTextColorMid}}, Utils::Icon::Tint), AH::tr("Adjust Height"), AH::tr("Adjust Height (Ctrl+L,8)"), "Ctrl+L,8", false }, + { Utils::Icon({{":/scxmleditor/images/adjust_size.png", Utils::Theme::PanelTextColorMid}}, Utils::Icon::Tint), AH::tr("Adjust Size"), AH::tr("Adjust Size (Ctrl+L,9)"), "Ctrl+L,9", false }, { Utils::Icon(":/scxmleditor/images/statistics.png"), AH::tr("Show Statistics..."), AH::tr("Show Statistics"), "", false } };