forked from qt-creator/qt-creator
ScxmlEditor: Fix the align* and adjust* icons
Use toolbar variants in the toolbar and menu variants in the menu. Change-Id: Ie79631d80ff0f2c4c3b19b216def10d79bdd8454 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -77,6 +77,7 @@
|
|||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/minisplitter.h>
|
#include <coreplugin/minisplitter.h>
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
|
#include <utils/icon.h>
|
||||||
|
|
||||||
using namespace ScxmlEditor::PluginInterface;
|
using namespace ScxmlEditor::PluginInterface;
|
||||||
using namespace ScxmlEditor::Common;
|
using namespace ScxmlEditor::Common;
|
||||||
@@ -120,6 +121,47 @@ void msgHandler(QtMsgType type, const QMessageLogContext &context, const QString
|
|||||||
abort();
|
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)
|
MainWidget::MainWidget(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
@@ -289,8 +331,8 @@ void MainWidget::init()
|
|||||||
// Init ToolButtons
|
// Init ToolButtons
|
||||||
auto stateColorButton = new ColorToolButton("StateColor", ":/scxmleditor/images/state_color.png", tr("State Color"));
|
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"));
|
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 *alignToolButton = createToolButton(toolButtonIcon(ActionAlignLeft), tr("Align Left"), QToolButton::MenuButtonPopup);
|
||||||
QToolButton *adjustToolButton = createToolButton(m_actionHandler->action(ActionAdjustWidth)->icon(), tr("Adjust Width"), QToolButton::MenuButtonPopup);
|
QToolButton *adjustToolButton = createToolButton(toolButtonIcon(ActionAdjustWidth), tr("Adjust Width"), QToolButton::MenuButtonPopup);
|
||||||
|
|
||||||
// Connect state color change
|
// Connect state color change
|
||||||
connect(stateColorButton, &ColorToolButton::colorSelected, [this](const QString &color) {
|
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)
|
void MainWidget::alignButtonClicked(ActionType alignType)
|
||||||
{
|
{
|
||||||
if (alignType >= ActionAlignLeft && alignType <= ActionAlignVertical) {
|
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]->setToolTip(m_actionHandler->action(alignType)->toolTip());
|
||||||
m_toolButtons[ToolButtonAlignment]->setProperty("currentAlignment", alignType);
|
m_toolButtons[ToolButtonAlignment]->setProperty("currentAlignment", alignType);
|
||||||
StateView *view = m_views.last();
|
StateView *view = m_views.last();
|
||||||
@@ -750,7 +792,7 @@ void MainWidget::alignButtonClicked(ActionType alignType)
|
|||||||
void MainWidget::adjustButtonClicked(ActionType adjustType)
|
void MainWidget::adjustButtonClicked(ActionType adjustType)
|
||||||
{
|
{
|
||||||
if (adjustType >= ActionAdjustWidth && adjustType <= ActionAdjustSize) {
|
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]->setToolTip(m_actionHandler->action(adjustType)->toolTip());
|
||||||
m_toolButtons[ToolButtonAdjustment]->setProperty("currentAdjustment", adjustType);
|
m_toolButtons[ToolButtonAdjustment]->setProperty("currentAdjustment", adjustType);
|
||||||
StateView *view = m_views.last();
|
StateView *view = m_views.last();
|
||||||
|
@@ -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({{":/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({{":/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_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::IconsBaseColor}}), AH::tr("Align Right"), AH::tr("Align Right (Ctrl+L,2)"), "Ctrl+L,2", 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::IconsBaseColor}}), AH::tr("Align Top"), AH::tr("Align Top (Ctrl+L,3)"), "Ctrl+L,3", 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::IconsBaseColor}}), AH::tr("Align Bottom"), AH::tr("Align Bottom (Ctrl+L,4)"), "Ctrl+L,4", 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::IconsBaseColor}}), AH::tr("Align Horizontal"), AH::tr("Align Horizontal (Ctrl+L,5)"), "Ctrl+L,5", 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::IconsBaseColor}}), AH::tr("Align Vertical"), AH::tr("Align Vertical (Ctrl+L,6)"), "Ctrl+L,6", 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::IconsBaseColor}}), AH::tr("Adjust Width"), AH::tr("Adjust Width (Ctrl+L,7)"), "Ctrl+L,7", 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::IconsBaseColor}}), AH::tr("Adjust Height"), AH::tr("Adjust Height (Ctrl+L,8)"), "Ctrl+L,8", 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::IconsBaseColor}}), AH::tr("Adjust Size"), AH::tr("Adjust Size (Ctrl+L,9)"), "Ctrl+L,9", 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 }
|
{ Utils::Icon(":/scxmleditor/images/statistics.png"), AH::tr("Show Statistics..."), AH::tr("Show Statistics"), "", false }
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user