diff options
Diffstat (limited to 'src/designer')
-rw-r--r-- | src/designer/src/components/formeditor/formwindowmanager.cpp | 16 | ||||
-rw-r--r-- | src/designer/src/designer/appfontdialog.cpp | 3 | ||||
-rw-r--r-- | src/designer/src/lib/shared/actioneditor.cpp | 20 | ||||
-rw-r--r-- | src/designer/src/lib/shared/iconloader.cpp | 22 | ||||
-rw-r--r-- | src/designer/src/lib/shared/iconloader_p.h | 7 | ||||
-rw-r--r-- | src/designer/src/lib/shared/qtresourceview.cpp | 12 |
6 files changed, 50 insertions, 30 deletions
diff --git a/src/designer/src/components/formeditor/formwindowmanager.cpp b/src/designer/src/components/formeditor/formwindowmanager.cpp index ad304014b..1d1b8f217 100644 --- a/src/designer/src/components/formeditor/formwindowmanager.cpp +++ b/src/designer/src/components/formeditor/formwindowmanager.cpp @@ -342,8 +342,8 @@ QWidget *FormWindowManager::findManagedWidget(FormWindow *fw, QWidget *w) void FormWindowManager::setupActions() { #if QT_CONFIG(clipboard) - const QIcon cutIcon = QIcon::fromTheme(QIcon::ThemeIcon::EditCut, - createIconSet(u"editcut.png"_s)); + const QIcon cutIcon = createIconSet(QIcon::ThemeIcon::EditCut, + "editcut.png"_L1); m_actionCut = new QAction(cutIcon, tr("Cu&t"), this); m_actionCut->setObjectName(u"__qt_cut_action"_s); m_actionCut->setShortcut(QKeySequence::Cut); @@ -352,8 +352,7 @@ void FormWindowManager::setupActions() connect(m_actionCut, &QAction::triggered, this, &FormWindowManager::slotActionCutActivated); m_actionCut->setEnabled(false); - const QIcon copyIcon = QIcon::fromTheme(QIcon::ThemeIcon::EditCopy, - createIconSet(u"editcopy.png"_s)); + const QIcon copyIcon = createIconSet(QIcon::ThemeIcon::EditCopy, "editcopy.png"_L1); m_actionCopy = new QAction(copyIcon, tr("&Copy"), this); m_actionCopy->setObjectName(u"__qt_copy_action"_s); m_actionCopy->setShortcut(QKeySequence::Copy); @@ -362,8 +361,7 @@ void FormWindowManager::setupActions() connect(m_actionCopy, &QAction::triggered, this, &FormWindowManager::slotActionCopyActivated); m_actionCopy->setEnabled(false); - const QIcon pasteIcon = QIcon::fromTheme(QIcon::ThemeIcon::EditPaste, - createIconSet(u"editpaste.png"_s)); + const QIcon pasteIcon = createIconSet(QIcon::ThemeIcon::EditPaste, "editpaste.png"_L1); m_actionPaste = new QAction(pasteIcon, tr("&Paste"), this); m_actionPaste->setObjectName(u"__qt_paste_action"_s); m_actionPaste->setShortcut(QKeySequence::Paste); @@ -507,12 +505,10 @@ void FormWindowManager::setupActions() m_actionUndo = m_undoGroup->createUndoAction(this); m_actionUndo->setEnabled(false); - m_actionUndo->setIcon(QIcon::fromTheme(QIcon::ThemeIcon::EditUndo, - createIconSet(u"undo.png"_s))); + m_actionUndo->setIcon(createIconSet(QIcon::ThemeIcon::EditUndo, "undo.png"_L1)); m_actionRedo = m_undoGroup->createRedoAction(this); m_actionRedo->setEnabled(false); - m_actionRedo->setIcon(QIcon::fromTheme(QIcon::ThemeIcon::EditRedo, - createIconSet(u"redo.png"_s))); + m_actionRedo->setIcon(createIconSet(QIcon::ThemeIcon::EditRedo, "redo.png"_L1)); m_actionShowFormWindowSettingsDialog = new QAction(tr("Form &Settings..."), this); m_actionShowFormWindowSettingsDialog->setObjectName(u"__qt_form_settings_action"_s); diff --git a/src/designer/src/designer/appfontdialog.cpp b/src/designer/src/designer/appfontdialog.cpp index d6ccd3b9b..6b8bf691d 100644 --- a/src/designer/src/designer/appfontdialog.cpp +++ b/src/designer/src/designer/appfontdialog.cpp @@ -261,7 +261,8 @@ AppFontWidget::AppFontWidget(QWidget *parent) : connect(m_removeButton, &QAbstractButton::clicked, this, &AppFontWidget::slotRemoveFiles); m_removeAllButton->setToolTip(tr("Remove all font files")); - m_removeAllButton->setIcon(qdesigner_internal::createIconSet(u"editdelete.png"_s)); + m_removeAllButton->setIcon(qdesigner_internal::createIconSet(QIcon::ThemeIcon::EditDelete, + "editdelete.png"_L1)); connect(m_removeAllButton, &QAbstractButton::clicked, this, &AppFontWidget::slotRemoveAll); QHBoxLayout *hLayout = new QHBoxLayout; diff --git a/src/designer/src/lib/shared/actioneditor.cpp b/src/designer/src/lib/shared/actioneditor.cpp index 7ae504fd4..36740da9b 100644 --- a/src/designer/src/lib/shared/actioneditor.cpp +++ b/src/designer/src/lib/shared/actioneditor.cpp @@ -114,8 +114,8 @@ ActionEditor::ActionEditor(QDesignerFormEditorInterface *core, QWidget *parent, toolbar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); l->addWidget(toolbar); // edit actions - QIcon documentNewIcon = QIcon::fromTheme(QIcon::ThemeIcon::DocumentNew, - createIconSet(u"filenew.png"_s)); + QIcon documentNewIcon = createIconSet(QIcon::ThemeIcon::DocumentNew, + "filenew.png"_L1); m_actionNew->setIcon(documentNewIcon); m_actionNew->setEnabled(false); connect(m_actionNew, &QAction::triggered, this, &ActionEditor::slotNewAction); @@ -126,20 +126,20 @@ ActionEditor::ActionEditor(QDesignerFormEditorInterface *core, QWidget *parent, #if QT_CONFIG(clipboard) m_actionCut->setEnabled(false); connect(m_actionCut, &QAction::triggered, this, &ActionEditor::slotCut); - QIcon editCutIcon = QIcon::fromTheme(QIcon::ThemeIcon::EditCut, - createIconSet(u"editcut.png"_s)); + QIcon editCutIcon = createIconSet(QIcon::ThemeIcon::EditCut, + "editcut.png"_L1); m_actionCut->setIcon(editCutIcon); m_actionCopy->setEnabled(false); connect(m_actionCopy, &QAction::triggered, this, &ActionEditor::slotCopy); - QIcon editCopyIcon = QIcon::fromTheme(QIcon::ThemeIcon::EditCopy, - createIconSet(u"editcopy.png"_s)); + QIcon editCopyIcon = createIconSet(QIcon::ThemeIcon::EditCopy, + "editcopy.png"_L1); m_actionCopy->setIcon(editCopyIcon); toolbar->addAction(m_actionCopy); connect(m_actionPaste, &QAction::triggered, this, &ActionEditor::slotPaste); - QIcon editPasteIcon = QIcon::fromTheme(QIcon::ThemeIcon::EditPaste, - createIconSet(u"editpaste.png"_s)); + QIcon editPasteIcon = createIconSet(QIcon::ThemeIcon::EditPaste, + "editpaste.png"_L1); m_actionPaste->setIcon(editPasteIcon); toolbar->addAction(m_actionPaste); #endif @@ -149,8 +149,8 @@ ActionEditor::ActionEditor(QDesignerFormEditorInterface *core, QWidget *parent, connect(m_actionNavigateToSlot, &QAction::triggered, this, &ActionEditor::navigateToSlotCurrentAction); - QIcon editDeleteIcon = QIcon::fromTheme(QIcon::ThemeIcon::EditDelete, - createIconSet(u"editdelete.png"_s)); + QIcon editDeleteIcon = createIconSet(QIcon::ThemeIcon::EditDelete, + "editdelete.png"_L1); m_actionDelete->setIcon(editDeleteIcon); m_actionDelete->setEnabled(false); connect(m_actionDelete, &QAction::triggered, this, &ActionEditor::slotDelete); diff --git a/src/designer/src/lib/shared/iconloader.cpp b/src/designer/src/lib/shared/iconloader.cpp index 4789548a6..042b3da34 100644 --- a/src/designer/src/lib/shared/iconloader.cpp +++ b/src/designer/src/lib/shared/iconloader.cpp @@ -13,7 +13,15 @@ using namespace Qt::StringLiterals; namespace qdesigner_internal { -QDESIGNER_SHARED_EXPORT QIcon createIconSet(const QString &name) +QDESIGNER_SHARED_EXPORT QIcon createIconSet(QIcon::ThemeIcon themeIcon, + QLatin1StringView name) +{ + return QIcon::hasThemeIcon(themeIcon) + ? QIcon::fromTheme(themeIcon) : createIconSet(name); +} + +template <class StringView> +static inline QIcon createIconSetHelper(StringView name) { constexpr QLatin1StringView prefixes[] = { ":/qt-project.org/formeditor/images/"_L1, @@ -31,7 +39,17 @@ QDESIGNER_SHARED_EXPORT QIcon createIconSet(const QString &name) return QIcon(f); } - return QIcon(); + return {}; +} + +QDESIGNER_SHARED_EXPORT QIcon createIconSet(QStringView name) +{ + return createIconSetHelper(name); +} + +QDESIGNER_SHARED_EXPORT QIcon createIconSet(QLatin1StringView name) +{ + return createIconSetHelper(name); } QDESIGNER_SHARED_EXPORT QIcon emptyIcon() diff --git a/src/designer/src/lib/shared/iconloader_p.h b/src/designer/src/lib/shared/iconloader_p.h index 14c7edeb5..c054d677c 100644 --- a/src/designer/src/lib/shared/iconloader_p.h +++ b/src/designer/src/lib/shared/iconloader_p.h @@ -17,6 +17,8 @@ #include "shared_global_p.h" +#include <QtGui/qicon.h> + QT_BEGIN_NAMESPACE class QString; @@ -24,7 +26,10 @@ class QIcon; namespace qdesigner_internal { -QDESIGNER_SHARED_EXPORT QIcon createIconSet(const QString &name); +QDESIGNER_SHARED_EXPORT QIcon createIconSet(QStringView name); +QDESIGNER_SHARED_EXPORT QIcon createIconSet(QLatin1StringView name); +QDESIGNER_SHARED_EXPORT QIcon createIconSet(QIcon::ThemeIcon themeIcon, + QLatin1StringView name); QDESIGNER_SHARED_EXPORT QIcon emptyIcon(); QDESIGNER_SHARED_EXPORT QIcon qtLogoIcon(); diff --git a/src/designer/src/lib/shared/qtresourceview.cpp b/src/designer/src/lib/shared/qtresourceview.cpp index d11000600..5663b0ddc 100644 --- a/src/designer/src/lib/shared/qtresourceview.cpp +++ b/src/designer/src/lib/shared/qtresourceview.cpp @@ -530,16 +530,16 @@ QtResourceView::QtResourceView(QDesignerFormEditorInterface *core, QWidget *pare { d_ptr->q_ptr = this; - QIcon editIcon = QIcon::fromTheme(QIcon::ThemeIcon::DocumentProperties, - qdesigner_internal::createIconSet(u"edit.png"_s)); + QIcon editIcon = qdesigner_internal::createIconSet(QIcon::ThemeIcon::DocumentProperties, + "edit.png"_L1); d_ptr->m_editResourcesAction = new QAction(editIcon, tr("Edit Resources..."), this); d_ptr->m_toolBar->addAction(d_ptr->m_editResourcesAction); connect(d_ptr->m_editResourcesAction, &QAction::triggered, this, [this] { d_ptr->slotEditResources(); }); d_ptr->m_editResourcesAction->setEnabled(false); - QIcon refreshIcon = QIcon::fromTheme(QIcon::ThemeIcon::ViewRefresh, - qdesigner_internal::createIconSet(u"reload.png"_s)); + QIcon refreshIcon = qdesigner_internal::createIconSet(QIcon::ThemeIcon::ViewRefresh, + "reload.png"_L1); d_ptr->m_reloadResourcesAction = new QAction(refreshIcon, tr("Reload"), this); d_ptr->m_toolBar->addAction(d_ptr->m_reloadResourcesAction); @@ -548,8 +548,8 @@ QtResourceView::QtResourceView(QDesignerFormEditorInterface *core, QWidget *pare d_ptr->m_reloadResourcesAction->setEnabled(false); #if QT_CONFIG(clipboard) - QIcon copyIcon = QIcon::fromTheme(QIcon::ThemeIcon::EditCopy, - qdesigner_internal::createIconSet(u"editcopy.png"_s)); + QIcon copyIcon = qdesigner_internal::createIconSet(QIcon::ThemeIcon::EditCopy, + "editcopy.png"_L1); d_ptr->m_copyResourcePathAction = new QAction(copyIcon, tr("Copy Path"), this); connect(d_ptr->m_copyResourcePathAction, &QAction::triggered, this, [this] { d_ptr->slotCopyResourcePath(); }); |