From cb3fd6eb0dd564b7ff9d58473fe00d83bd24011c Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 29 Mar 2023 15:58:56 +0200 Subject: [PATCH] Utils: Introduce Utils::Icons::PINNED_SMALL Replaces two duplicated pin.xpm in the pinnable debugger tooltip and the qmleditorwidgets with the new icon. Change-Id: I57b7adc5c0b92ffdf01da12dd832482d739cb86e Reviewed-by: Eike Ziller Reviewed-by: Qt CI Bot --- .../qmleditorwidgets/contextpanewidget.cpp | 29 ++----------------- src/libs/utils/utilsicons.cpp | 2 ++ src/libs/utils/utilsicons.h | 1 + src/plugins/debugger/debugger.qbs | 2 +- src/plugins/debugger/debugger.qrc | 1 - .../debugger/debuggertooltipmanager.cpp | 6 ++-- src/plugins/debugger/images/pin.xpm | 19 ------------ 7 files changed, 9 insertions(+), 51 deletions(-) delete mode 100644 src/plugins/debugger/images/pin.xpm diff --git a/src/libs/qmleditorwidgets/contextpanewidget.cpp b/src/libs/qmleditorwidgets/contextpanewidget.cpp index 688c65ad7b3..8d675bf95b1 100644 --- a/src/libs/qmleditorwidgets/contextpanewidget.cpp +++ b/src/libs/qmleditorwidgets/contextpanewidget.cpp @@ -6,6 +6,7 @@ #include "qmleditorwidgetstr.h" #include +#include #include #include @@ -27,26 +28,6 @@ using namespace Utils; namespace QmlEditorWidgets { -/* XPM */ -static const char * pin_xpm[] = { -"12 9 7 1", -" c None", -". c #000000", -"+ c #515151", -"@ c #A8A8A8", -"# c #A9A9A9", -"$ c #999999", -"% c #696969", -" . ", -" ......+", -" .@@@@@.", -" .#####.", -"+.....$$$$$.", -" .%%%%%.", -" .......", -" ......+", -" . "}; - DragWidget::DragWidget(QWidget *parent) : QFrame(parent) { setFrameStyle(QFrame::NoFrame); @@ -143,7 +124,7 @@ ContextPaneWidget::ContextPaneWidget(QWidget *parent) : DragWidget(parent), m_cu m_toolButton->setIcon(style()->standardIcon(QStyle::SP_DockWidgetCloseButton)); m_toolButton->setToolButtonStyle(Qt::ToolButtonIconOnly); - m_toolButton->setFixedSize(16, 16); + m_toolButton->setFixedSize(20, 20); m_toolButton->setToolTip(Tr::tr("Hides this toolbar.")); connect(m_toolButton, &QToolButton::clicked, this, &ContextPaneWidget::onTogglePane); @@ -464,9 +445,7 @@ void ContextPaneWidget::setPinButton() m_toolButton->setAutoRaise(true); m_pinned = true; - m_toolButton->setIcon(QPixmap::fromImage(QImage(pin_xpm))); - m_toolButton->setToolButtonStyle(Qt::ToolButtonIconOnly); - m_toolButton->setFixedSize(20, 20); + m_toolButton->setIcon(Utils::Icons::PINNED_SMALL.icon()); m_toolButton->setToolTip(Tr::tr("Unpins the toolbar and moves it to the default position.")); emit pinnedChanged(true); @@ -481,8 +460,6 @@ void ContextPaneWidget::setLineButton() m_pinned = false; m_toolButton->setAutoRaise(true); m_toolButton->setIcon(style()->standardIcon(QStyle::SP_DockWidgetCloseButton)); - m_toolButton->setToolButtonStyle(Qt::ToolButtonIconOnly); - m_toolButton->setFixedSize(20, 20); m_toolButton->setToolTip(Tr::tr("Hides this toolbar. This toolbar can be" " permanently disabled in the options page or in the context menu.")); diff --git a/src/libs/utils/utilsicons.cpp b/src/libs/utils/utilsicons.cpp index 7263b285946..cbc2ddf64fb 100644 --- a/src/libs/utils/utilsicons.cpp +++ b/src/libs/utils/utilsicons.cpp @@ -24,6 +24,8 @@ const Icon UNLOCKED({ {":/utils/images/unlocked.png", Theme::PanelTextColorDark}}, Icon::Tint); const Icon PINNED({ {":/utils/images/pinned.png", Theme::PanelTextColorDark}}, Icon::Tint); +const Icon PINNED_SMALL({ + {":/utils/images/pinned_small.png", Theme::PanelTextColorDark}}, Icon::Tint); const Icon NEXT({ {":/utils/images/next.png", Theme::IconsWarningColor}}, Icon::MenuTintedStyle); const Icon NEXT_TOOLBAR({ diff --git a/src/libs/utils/utilsicons.h b/src/libs/utils/utilsicons.h index b8fda0c53fd..3e5009c94c2 100644 --- a/src/libs/utils/utilsicons.h +++ b/src/libs/utils/utilsicons.h @@ -19,6 +19,7 @@ QTCREATOR_UTILS_EXPORT extern const Icon LOCKED; QTCREATOR_UTILS_EXPORT extern const Icon UNLOCKED_TOOLBAR; QTCREATOR_UTILS_EXPORT extern const Icon UNLOCKED; QTCREATOR_UTILS_EXPORT extern const Icon PINNED; +QTCREATOR_UTILS_EXPORT extern const Icon PINNED_SMALL; QTCREATOR_UTILS_EXPORT extern const Icon NEXT; QTCREATOR_UTILS_EXPORT extern const Icon NEXT_TOOLBAR; QTCREATOR_UTILS_EXPORT extern const Icon PREV; diff --git a/src/plugins/debugger/debugger.qbs b/src/plugins/debugger/debugger.qbs index 8319bea822b..03b57c5885a 100644 --- a/src/plugins/debugger/debugger.qbs +++ b/src/plugins/debugger/debugger.qbs @@ -175,7 +175,7 @@ Project { Group { name: "Images" prefix: "images/" - files: ["*.png", "*.xpm"] + files: ["*.png"] } Group { diff --git a/src/plugins/debugger/debugger.qrc b/src/plugins/debugger/debugger.qrc index 86a05a73ff1..6fc31bb4fbb 100644 --- a/src/plugins/debugger/debugger.qrc +++ b/src/plugins/debugger/debugger.qrc @@ -42,7 +42,6 @@ images/mode_debug@2x.png images/mode_debug_mask.png images/mode_debug_mask@2x.png - images/pin.xpm images/debugger_restart_small.png images/debugger_restart_small@2x.png images/recordfill.png diff --git a/src/plugins/debugger/debuggertooltipmanager.cpp b/src/plugins/debugger/debuggertooltipmanager.cpp index f5e9933fbef..40f12f5470a 100644 --- a/src/plugins/debugger/debuggertooltipmanager.cpp +++ b/src/plugins/debugger/debuggertooltipmanager.cpp @@ -519,7 +519,7 @@ DebuggerToolTipWidget::DebuggerToolTipWidget() setAttribute(Qt::WA_DeleteOnClose); isPinned = false; - const QIcon pinIcon(":/debugger/images/pin.xpm"); + const QIcon pinIcon = Utils::Icons::PINNED_SMALL.icon(); pinButton = new QToolButton; pinButton->setIcon(pinIcon); @@ -534,9 +534,7 @@ DebuggerToolTipWidget::DebuggerToolTipWidget() auto toolBar = new QToolBar(this); toolBar->setProperty("_q_custom_style_disabled", QVariant(true)); - const QList pinIconSizes = pinIcon.availableSizes(); - if (!pinIconSizes.isEmpty()) - toolBar->setIconSize(pinIconSizes.front()); + toolBar->setIconSize({12, 12}); toolBar->addWidget(pinButton); toolBar->addWidget(copyButton); toolBar->addWidget(titleLabel); diff --git a/src/plugins/debugger/images/pin.xpm b/src/plugins/debugger/images/pin.xpm deleted file mode 100644 index 0759becb67f..00000000000 --- a/src/plugins/debugger/images/pin.xpm +++ /dev/null @@ -1,19 +0,0 @@ -/* XPM */ -static const char * pin_xpm[] = { -"12 9 7 1", -" c None", -". c #000000", -"+ c #515151", -"@ c #A8A8A8", -"# c #A9A9A9", -"$ c #999999", -"% c #696969", -" . ", -" ......+", -" .@@@@@.", -" .#####.", -"+.....$$$$$.", -" .%%%%%.", -" .......", -" ......+", -" . "};