Utils: Cache theme icon access

These trigger over 120k file exist check on my machine on startup,
just for a handful icons.

Change-Id: Ic73f0783142ed329c2f8c8b852f622e69fc306da
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
hjk
2023-09-01 12:28:51 +02:00
parent c2a69683cf
commit 67212a31ee
17 changed files with 92 additions and 45 deletions

View File

@@ -431,13 +431,9 @@ void FancyLineEdit::setFiltering(bool on)
// KDE has custom icons for this. Notice that icon namings are counter intuitive. // KDE has custom icons for this. Notice that icon namings are counter intuitive.
// If these icons are not available we use the freedesktop standard name before // If these icons are not available we use the freedesktop standard name before
// falling back to a bundled resource. // falling back to a bundled resource.
QIcon icon = QIcon::fromTheme(layoutDirection() == Qt::LeftToRight ? static const QIcon rtl = Icon::fromTheme("edit-clear-locationbar-rtl");
QLatin1String("edit-clear-locationbar-rtl") : static const QIcon ltr = Icon::fromTheme("edit-clear-locationbar-ltr");
QLatin1String("edit-clear-locationbar-ltr"), setButtonIcon(Right, layoutDirection() == Qt::LeftToRight ? ltr : rtl);
QIcon::fromTheme(QLatin1String("edit-clear"),
Icons::EDIT_CLEAR.icon()));
setButtonIcon(Right, icon);
setButtonVisible(Right, true); setButtonVisible(Right, true);
setPlaceholderText(Tr::tr("Filter")); setPlaceholderText(Tr::tr("Filter"));
setButtonToolTip(Right, Tr::tr("Clear text")); setButtonToolTip(Right, Tr::tr("Clear text"));

View File

@@ -6,6 +6,7 @@
#include "qtcassert.h" #include "qtcassert.h"
#include "theme/theme.h" #include "theme/theme.h"
#include "stylehelper.h" #include "stylehelper.h"
#include "utilsicons.h"
#include <QApplication> #include <QApplication>
#include <QDebug> #include <QDebug>
@@ -234,4 +235,51 @@ QIcon Icon::combinedIcon(const QList<Icon> &icons)
return combinedIcon(qIcons); return combinedIcon(qIcons);
} }
QIcon Icon::fromTheme(const QString &name)
{
static QHash<QString, QIcon> cache;
auto found = cache.find(name);
if (found != cache.end())
return *found;
QIcon icon = QIcon::fromTheme(name);
if (name == "go-next") {
cache.insert(name, !icon.isNull() ? icon : QIcon(":/utils/images/arrow.png"));
} else if (name == "document-open") {
cache.insert(name, !icon.isNull() ? icon : Icons::OPENFILE.icon());
} else if (name == "edit-copy") {
cache.insert(name, !icon.isNull() ? icon : Icons::COPY.icon());
} else if (name == "document-new") {
cache.insert(name, !icon.isNull() ? icon : Icons::NEWFILE.icon());
} else if (name == "document-save") {
cache.insert(name, !icon.isNull() ? icon : Icons::SAVEFILE.icon());
} else if (name == "edit-undo") {
cache.insert(name, !icon.isNull() ? icon : Icons::UNDO.icon());
} else if (name == "edit-redo") {
cache.insert(name, !icon.isNull() ? icon : Icons::REDO.icon());
} else if (name == "edit-cut") {
cache.insert(name, !icon.isNull() ? icon : Icons::CUT.icon());
} else if (name == "edit-paste") {
cache.insert(name, !icon.isNull() ? icon : Icons::PASTE.icon());
} else if (name == "zoom-in") {
cache.insert(name, !icon.isNull() ? icon : Icons::ZOOMIN_TOOLBAR.icon());
} else if (name == "zoom-out") {
cache.insert(name, !icon.isNull() ? icon : Icons::ZOOMOUT_TOOLBAR.icon());
} else if (name == "zoom-original") {
cache.insert(name, !icon.isNull() ? icon : Icons::EYE_OPEN_TOOLBAR.icon());
} else if (name == "edit-clear-locationbar-rtl") {
// KDE has custom icons for this. Notice that icon namings are counter intuitive.
// If these icons are not available we use the freedesktop standard name before
// falling back to a bundled resource.
cache.insert(name, !icon.isNull() ? icon : Icons::EDIT_CLEAR.icon());
} else if (name == "edit-clear-locationbar-ltr") {
cache.insert(name, !icon.isNull() ? icon : Icons::EDIT_CLEAR.icon());
} else {
cache.insert(name, icon);
}
return cache[name];
}
} // namespace Utils } // namespace Utils

View File

@@ -61,6 +61,8 @@ public:
static QIcon combinedIcon(const QList<QIcon> &icons); static QIcon combinedIcon(const QList<QIcon> &icons);
static QIcon combinedIcon(const QList<Icon> &icons); static QIcon combinedIcon(const QList<Icon> &icons);
static QIcon fromTheme(const QString &name);
private: private:
QList<IconMaskAndColor> m_iconSourceList; QList<IconMaskAndColor> m_iconSourceList;
IconStyleOptions m_style = None; IconStyleOptions m_style = None;

View File

@@ -288,6 +288,7 @@ const Icon MACOS_TOUCHBAR_BOOKMARK(
":/utils/images/macos_touchbar_bookmark.png"); ":/utils/images/macos_touchbar_bookmark.png");
const Icon MACOS_TOUCHBAR_CLEAR( const Icon MACOS_TOUCHBAR_CLEAR(
":/utils/images/macos_touchbar_clear.png"); ":/utils/images/macos_touchbar_clear.png");
} // namespace Icons } // namespace Icons
QIcon CodeModelIcon::iconForType(CodeModelIcon::Type type) QIcon CodeModelIcon::iconForType(CodeModelIcon::Type type)

View File

@@ -148,6 +148,7 @@ QTCREATOR_UTILS_EXPORT extern const Icon CODEMODEL_FIXIT;
QTCREATOR_UTILS_EXPORT extern const Icon MACOS_TOUCHBAR_BOOKMARK; QTCREATOR_UTILS_EXPORT extern const Icon MACOS_TOUCHBAR_BOOKMARK;
QTCREATOR_UTILS_EXPORT extern const Icon MACOS_TOUCHBAR_CLEAR; QTCREATOR_UTILS_EXPORT extern const Icon MACOS_TOUCHBAR_CLEAR;
} // namespace Icons } // namespace Icons
namespace CodeModelIcon { namespace CodeModelIcon {

View File

@@ -5,6 +5,7 @@
#include "algorithm.h" #include "algorithm.h"
#include "hostosinfo.h" #include "hostosinfo.h"
#include "icon.h"
#include "qtcassert.h" #include "qtcassert.h"
#include "theme/theme.h" #include "theme/theme.h"
#include "utilstr.h" #include "utilstr.h"
@@ -110,7 +111,7 @@ LinearProgressWidget::LinearProgressWidget(WizardProgress *progress, QWidget *pa
m_dotsItemWidget(nullptr), m_dotsItemWidget(nullptr),
m_disableUpdatesCount(0) m_disableUpdatesCount(0)
{ {
m_indicatorPixmap = QIcon::fromTheme(QLatin1String("go-next"), QIcon(QLatin1String(":/utils/images/arrow.png"))).pixmap(16); m_indicatorPixmap = Icon::fromTheme("go-next").pixmap(16);
m_wizardProgress = progress; m_wizardProgress = progress;
m_mainLayout = new QVBoxLayout(this); m_mainLayout = new QVBoxLayout(this);
m_itemWidgetLayout = new QVBoxLayout(); m_itemWidgetLayout = new QVBoxLayout();

View File

@@ -10,10 +10,11 @@
#include <QFrame> #include <QFrame>
#include <QHBoxLayout> #include <QHBoxLayout>
using namespace Utils;
namespace Android { namespace Android {
namespace Internal { namespace Internal {
namespace {
const char extraExtraExtraHighDpiIconPath[] = "/res/drawable-xxxhdpi/"; const char extraExtraExtraHighDpiIconPath[] = "/res/drawable-xxxhdpi/";
const char extraExtraHighDpiIconPath[] = "/res/drawable-xxhdpi/"; const char extraExtraHighDpiIconPath[] = "/res/drawable-xxhdpi/";
const char extraHighDpiIconPath[] = "/res/drawable-xhdpi/"; const char extraHighDpiIconPath[] = "/res/drawable-xhdpi/";
@@ -27,7 +28,6 @@ const QSize highDpiIconSize{72, 72};
const QSize extraHighDpiIconSize{96, 96}; const QSize extraHighDpiIconSize{96, 96};
const QSize extraExtraHighDpiIconSize{144, 144}; const QSize extraExtraHighDpiIconSize{144, 144};
const QSize extraExtraExtraHighDpiIconSize{192, 192}; const QSize extraExtraExtraHighDpiIconSize{192, 192};
}
AndroidManifestEditorIconContainerWidget::AndroidManifestEditorIconContainerWidget( AndroidManifestEditorIconContainerWidget::AndroidManifestEditorIconContainerWidget(
QWidget *parent, QWidget *parent,
@@ -40,7 +40,7 @@ AndroidManifestEditorIconContainerWidget::AndroidManifestEditorIconContainerWidg
lowDpiIconSize, lowDpiIconSize,
Tr::tr("Master icon"), Tr::tr("Master icon"),
Tr::tr("Select master icon.")); Tr::tr("Select master icon."));
masterIconButton->setIcon(QIcon::fromTheme(QLatin1String("document-open"), Utils::Icons::OPENFILE.icon())); masterIconButton->setIcon(Icon::fromTheme("document-open"));
iconLayout->addWidget(masterIconButton); iconLayout->addWidget(masterIconButton);
iconLayout->addStretch(1); iconLayout->addStretch(1);

View File

@@ -185,17 +185,17 @@ SplashScreenContainerWidget::SplashScreenContainerWidget(
m_masterImage = new QToolButton(this); m_masterImage = new QToolButton(this);
m_masterImage->setToolTip(Tr::tr("Select master image to use.")); m_masterImage->setToolTip(Tr::tr("Select master image to use."));
m_masterImage->setIcon(QIcon::fromTheme(QLatin1String("document-open"), Utils::Icons::OPENFILE.icon())); m_masterImage->setIcon(Icon::fromTheme("document-open"));
formLayout->addRow(Tr::tr("Master image:"), m_masterImage); formLayout->addRow(Tr::tr("Master image:"), m_masterImage);
m_portraitMasterImage = new QToolButton(this); m_portraitMasterImage = new QToolButton(this);
m_portraitMasterImage->setToolTip(Tr::tr("Select portrait master image to use.")); m_portraitMasterImage->setToolTip(Tr::tr("Select portrait master image to use."));
m_portraitMasterImage->setIcon(QIcon::fromTheme(QLatin1String("document-open"), Utils::Icons::OPENFILE.icon())); m_portraitMasterImage->setIcon(Icon::fromTheme("document-open"));
formLayout->addRow(Tr::tr("Portrait master image:"), m_portraitMasterImage); formLayout->addRow(Tr::tr("Portrait master image:"), m_portraitMasterImage);
m_landscapeMasterImage = new QToolButton(this); m_landscapeMasterImage = new QToolButton(this);
m_landscapeMasterImage->setToolTip(Tr::tr("Select landscape master image to use.")); m_landscapeMasterImage->setToolTip(Tr::tr("Select landscape master image to use."));
m_landscapeMasterImage->setIcon(QIcon::fromTheme(QLatin1String("document-open"), Utils::Icons::OPENFILE.icon())); m_landscapeMasterImage->setIcon(Icon::fromTheme("document-open"));
formLayout->addRow(Tr::tr("Landscape master image:"), m_landscapeMasterImage); formLayout->addRow(Tr::tr("Landscape master image:"), m_landscapeMasterImage);
auto clearAllButton = new QToolButton(this); auto clearAllButton = new QToolButton(this);

View File

@@ -265,7 +265,7 @@ ClangdTextMark::ClangdTextMark(TextEditor::TextDocument *doc,
// Copy to clipboard action // Copy to clipboard action
QList<QAction *> actions; QList<QAction *> actions;
QAction *action = new QAction(); QAction *action = new QAction();
action->setIcon(QIcon::fromTheme("edit-copy", Icons::COPY.icon())); action->setIcon(Icon::fromTheme("edit-copy"));
action->setToolTip(Tr::tr("Copy to Clipboard", "Clang Code Model Marks")); action->setToolTip(Tr::tr("Copy to Clipboard", "Clang Code Model Marks"));
QObject::connect(action, &QAction::triggered, [diag] { QObject::connect(action, &QAction::triggered, [diag] {
const QString text = ClangDiagnosticWidget::createText({diag}, const QString text = ClangDiagnosticWidget::createText({diag},

View File

@@ -39,7 +39,7 @@ DiagnosticMark::DiagnosticMark(const Diagnostic &diagnostic, TextDocument *docum
// Copy to clipboard action // Copy to clipboard action
QList<QAction *> actions; QList<QAction *> actions;
QAction *action = new QAction(); QAction *action = new QAction();
action->setIcon(QIcon::fromTheme("edit-copy", Icons::COPY.icon())); action->setIcon(Icon::fromTheme("edit-copy"));
action->setToolTip(Tr::tr("Copy to Clipboard")); action->setToolTip(Tr::tr("Copy to Clipboard"));
QObject::connect(action, &QAction::triggered, [diagnostic] { QObject::connect(action, &QAction::triggered, [diagnostic] {
const QString text = createFullLocationString(diagnostic.location) const QString text = createFullLocationString(diagnostic.location)

View File

@@ -15,7 +15,7 @@
#include <utils/mimeutils.h> #include <utils/mimeutils.h>
#include <utils/process.h> #include <utils/process.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/utilsicons.h> #include <utils/icon.h>
#include <projectexplorer/projecttree.h> #include <projectexplorer/projecttree.h>
@@ -516,8 +516,7 @@ FolderNode *createSourceGroupNode(const QString &sourceGroupName,
if (!existingNode) { if (!existingNode) {
auto node = createCMakeVFolder(sourceDirectory, Node::DefaultFolderPriority + 5, p); auto node = createCMakeVFolder(sourceDirectory, Node::DefaultFolderPriority + 5, p);
node->setListInProject(false); node->setListInProject(false);
node->setIcon( node->setIcon([] { return Icon::fromTheme("edit-copy"); });
[] { return QIcon::fromTheme("edit-copy", ::Utils::Icons::COPY.icon()); });
existingNode = node.get(); existingNode = node.get();

View File

@@ -431,7 +431,7 @@ void EditorManagerPrivate::init()
ActionContainer *mfile = ActionManager::actionContainer(Constants::M_FILE); ActionContainer *mfile = ActionManager::actionContainer(Constants::M_FILE);
// Revert to saved // Revert to saved
m_revertToSavedAction->setIcon(QIcon::fromTheme("document-revert")); m_revertToSavedAction->setIcon(Icon::fromTheme("document-revert"));
Command *cmd = ActionManager::registerAction(m_revertToSavedAction, Command *cmd = ActionManager::registerAction(m_revertToSavedAction,
Constants::REVERTTOSAVED, editManagerContext); Constants::REVERTTOSAVED, editManagerContext);
cmd->setAttribute(Command::CA_UpdateText); cmd->setAttribute(Command::CA_UpdateText);

View File

@@ -256,7 +256,7 @@ FindToolBar::FindToolBar(CurrentDocumentFind *currentDocumentFind)
connect(m_goToCurrentFindAction, &QAction::triggered, connect(m_goToCurrentFindAction, &QAction::triggered,
this, &FindToolBar::setFocusToCurrentFindSupport); this, &FindToolBar::setFocusToCurrentFindSupport);
QIcon icon = QIcon::fromTheme(QLatin1String("edit-find-replace")); QIcon icon = Icon::fromTheme("edit-find-replace");
m_findInDocumentAction = new QAction(icon, Tr::tr("Find/Replace"), this); m_findInDocumentAction = new QAction(icon, Tr::tr("Find/Replace"), this);
cmd = ActionManager::registerAction(m_findInDocumentAction, Constants::FIND_IN_DOCUMENT); cmd = ActionManager::registerAction(m_findInDocumentAction, Constants::FIND_IN_DOCUMENT);
cmd->setDefaultKeySequence(QKeySequence::Find); cmd->setDefaultKeySequence(QKeySequence::Find);

View File

@@ -548,7 +548,7 @@ void MainWindow::registerDefaultActions()
connect(m_focusToEditor, &QAction::triggered, this, &MainWindow::setFocusToEditor); connect(m_focusToEditor, &QAction::triggered, this, &MainWindow::setFocusToEditor);
// New File Action // New File Action
QIcon icon = QIcon::fromTheme(QLatin1String("document-new"), Utils::Icons::NEWFILE.icon()); QIcon icon = Icon::fromTheme("document-new");
m_newAction = new QAction(icon, Tr::tr("&New Project..."), this); m_newAction = new QAction(icon, Tr::tr("&New Project..."), this);
cmd = ActionManager::registerAction(m_newAction, Constants::NEW); cmd = ActionManager::registerAction(m_newAction, Constants::NEW);
@@ -584,7 +584,7 @@ void MainWindow::registerDefaultActions()
}); });
// Open Action // Open Action
icon = QIcon::fromTheme(QLatin1String("document-open"), Utils::Icons::OPENFILE.icon()); icon = Icon::fromTheme("document-open");
m_openAction = new QAction(icon, Tr::tr("&Open File or Project..."), this); m_openAction = new QAction(icon, Tr::tr("&Open File or Project..."), this);
cmd = ActionManager::registerAction(m_openAction, Constants::OPEN); cmd = ActionManager::registerAction(m_openAction, Constants::OPEN);
cmd->setDefaultKeySequence(QKeySequence::Open); cmd->setDefaultKeySequence(QKeySequence::Open);
@@ -612,7 +612,7 @@ void MainWindow::registerDefaultActions()
ac->setOnAllDisabledBehavior(ActionContainer::Show); ac->setOnAllDisabledBehavior(ActionContainer::Show);
// Save Action // Save Action
icon = QIcon::fromTheme(QLatin1String("document-save"), Utils::Icons::SAVEFILE.icon()); icon = Icon::fromTheme("document-save");
QAction *tmpaction = new QAction(icon, Tr::tr("&Save"), this); QAction *tmpaction = new QAction(icon, Tr::tr("&Save"), this);
tmpaction->setEnabled(false); tmpaction->setEnabled(false);
cmd = ActionManager::registerAction(tmpaction, Constants::SAVE); cmd = ActionManager::registerAction(tmpaction, Constants::SAVE);
@@ -622,7 +622,7 @@ void MainWindow::registerDefaultActions()
mfile->addAction(cmd, Constants::G_FILE_SAVE); mfile->addAction(cmd, Constants::G_FILE_SAVE);
// Save As Action // Save As Action
icon = QIcon::fromTheme(QLatin1String("document-save-as")); icon = Icon::fromTheme("document-save-as");
tmpaction = new QAction(icon, Tr::tr("Save &As..."), this); tmpaction = new QAction(icon, Tr::tr("Save &As..."), this);
tmpaction->setEnabled(false); tmpaction->setEnabled(false);
cmd = ActionManager::registerAction(tmpaction, Constants::SAVEAS); cmd = ActionManager::registerAction(tmpaction, Constants::SAVEAS);
@@ -635,7 +635,7 @@ void MainWindow::registerDefaultActions()
DocumentManager::registerSaveAllAction(); DocumentManager::registerSaveAllAction();
// Print Action // Print Action
icon = QIcon::fromTheme(QLatin1String("document-print")); icon = Icon::fromTheme("document-print");
tmpaction = new QAction(icon, Tr::tr("&Print..."), this); tmpaction = new QAction(icon, Tr::tr("&Print..."), this);
tmpaction->setEnabled(false); tmpaction->setEnabled(false);
cmd = ActionManager::registerAction(tmpaction, Constants::PRINT); cmd = ActionManager::registerAction(tmpaction, Constants::PRINT);
@@ -643,7 +643,7 @@ void MainWindow::registerDefaultActions()
mfile->addAction(cmd, Constants::G_FILE_PRINT); mfile->addAction(cmd, Constants::G_FILE_PRINT);
// Exit Action // Exit Action
icon = QIcon::fromTheme(QLatin1String("application-exit")); icon = Icon::fromTheme("application-exit");
m_exitAction = new QAction(icon, Tr::tr("E&xit"), this); m_exitAction = new QAction(icon, Tr::tr("E&xit"), this);
m_exitAction->setMenuRole(QAction::QuitRole); m_exitAction->setMenuRole(QAction::QuitRole);
cmd = ActionManager::registerAction(m_exitAction, Constants::EXIT); cmd = ActionManager::registerAction(m_exitAction, Constants::EXIT);
@@ -652,7 +652,7 @@ void MainWindow::registerDefaultActions()
connect(m_exitAction, &QAction::triggered, this, &MainWindow::exit); connect(m_exitAction, &QAction::triggered, this, &MainWindow::exit);
// Undo Action // Undo Action
icon = QIcon::fromTheme(QLatin1String("edit-undo"), Utils::Icons::UNDO.icon()); icon = Icon::fromTheme("edit-undo");
tmpaction = new QAction(icon, Tr::tr("&Undo"), this); tmpaction = new QAction(icon, Tr::tr("&Undo"), this);
cmd = ActionManager::registerAction(tmpaction, Constants::UNDO); cmd = ActionManager::registerAction(tmpaction, Constants::UNDO);
cmd->setDefaultKeySequence(QKeySequence::Undo); cmd->setDefaultKeySequence(QKeySequence::Undo);
@@ -662,7 +662,7 @@ void MainWindow::registerDefaultActions()
tmpaction->setEnabled(false); tmpaction->setEnabled(false);
// Redo Action // Redo Action
icon = QIcon::fromTheme(QLatin1String("edit-redo"), Utils::Icons::REDO.icon()); icon = Icon::fromTheme("edit-redo");
tmpaction = new QAction(icon, Tr::tr("&Redo"), this); tmpaction = new QAction(icon, Tr::tr("&Redo"), this);
cmd = ActionManager::registerAction(tmpaction, Constants::REDO); cmd = ActionManager::registerAction(tmpaction, Constants::REDO);
cmd->setDefaultKeySequence(QKeySequence::Redo); cmd->setDefaultKeySequence(QKeySequence::Redo);
@@ -672,7 +672,7 @@ void MainWindow::registerDefaultActions()
tmpaction->setEnabled(false); tmpaction->setEnabled(false);
// Cut Action // Cut Action
icon = QIcon::fromTheme(QLatin1String("edit-cut"), Utils::Icons::CUT.icon()); icon = Icon::fromTheme("edit-cut");
tmpaction = new QAction(icon, Tr::tr("Cu&t"), this); tmpaction = new QAction(icon, Tr::tr("Cu&t"), this);
cmd = ActionManager::registerAction(tmpaction, Constants::CUT); cmd = ActionManager::registerAction(tmpaction, Constants::CUT);
cmd->setDefaultKeySequence(QKeySequence::Cut); cmd->setDefaultKeySequence(QKeySequence::Cut);
@@ -680,7 +680,7 @@ void MainWindow::registerDefaultActions()
tmpaction->setEnabled(false); tmpaction->setEnabled(false);
// Copy Action // Copy Action
icon = QIcon::fromTheme(QLatin1String("edit-copy"), Utils::Icons::COPY.icon()); icon = Icon::fromTheme("edit-copy");
tmpaction = new QAction(icon, Tr::tr("&Copy"), this); tmpaction = new QAction(icon, Tr::tr("&Copy"), this);
cmd = ActionManager::registerAction(tmpaction, Constants::COPY); cmd = ActionManager::registerAction(tmpaction, Constants::COPY);
cmd->setDefaultKeySequence(QKeySequence::Copy); cmd->setDefaultKeySequence(QKeySequence::Copy);
@@ -688,7 +688,7 @@ void MainWindow::registerDefaultActions()
tmpaction->setEnabled(false); tmpaction->setEnabled(false);
// Paste Action // Paste Action
icon = QIcon::fromTheme(QLatin1String("edit-paste"), Utils::Icons::PASTE.icon()); icon = Icon::fromTheme("edit-paste");
tmpaction = new QAction(icon, Tr::tr("&Paste"), this); tmpaction = new QAction(icon, Tr::tr("&Paste"), this);
cmd = ActionManager::registerAction(tmpaction, Constants::PASTE); cmd = ActionManager::registerAction(tmpaction, Constants::PASTE);
cmd->setDefaultKeySequence(QKeySequence::Paste); cmd->setDefaultKeySequence(QKeySequence::Paste);
@@ -696,7 +696,7 @@ void MainWindow::registerDefaultActions()
tmpaction->setEnabled(false); tmpaction->setEnabled(false);
// Select All // Select All
icon = QIcon::fromTheme(QLatin1String("edit-select-all")); icon = Icon::fromTheme("edit-select-all");
tmpaction = new QAction(icon, Tr::tr("Select &All"), this); tmpaction = new QAction(icon, Tr::tr("Select &All"), this);
cmd = ActionManager::registerAction(tmpaction, Constants::SELECTALL); cmd = ActionManager::registerAction(tmpaction, Constants::SELECTALL);
cmd->setDefaultKeySequence(QKeySequence::SelectAll); cmd->setDefaultKeySequence(QKeySequence::SelectAll);
@@ -704,7 +704,7 @@ void MainWindow::registerDefaultActions()
tmpaction->setEnabled(false); tmpaction->setEnabled(false);
// Goto Action // Goto Action
icon = QIcon::fromTheme(QLatin1String("go-jump")); icon = Icon::fromTheme("go-jump");
tmpaction = new QAction(icon, Tr::tr("&Go to Line..."), this); tmpaction = new QAction(icon, Tr::tr("&Go to Line..."), this);
cmd = ActionManager::registerAction(tmpaction, Constants::GOTO); cmd = ActionManager::registerAction(tmpaction, Constants::GOTO);
cmd->setDefaultKeySequence(QKeySequence(Tr::tr("Ctrl+L"))); cmd->setDefaultKeySequence(QKeySequence(Tr::tr("Ctrl+L")));
@@ -712,16 +712,14 @@ void MainWindow::registerDefaultActions()
tmpaction->setEnabled(false); tmpaction->setEnabled(false);
// Zoom In Action // Zoom In Action
icon = QIcon::hasThemeIcon("zoom-in") ? QIcon::fromTheme("zoom-in") icon = Icon::fromTheme("zoom-in");
: Utils::Icons::ZOOMIN_TOOLBAR.icon();
tmpaction = new QAction(icon, Tr::tr("Zoom In"), this); tmpaction = new QAction(icon, Tr::tr("Zoom In"), this);
cmd = ActionManager::registerAction(tmpaction, Constants::ZOOM_IN); cmd = ActionManager::registerAction(tmpaction, Constants::ZOOM_IN);
cmd->setDefaultKeySequence(QKeySequence(Tr::tr("Ctrl++"))); cmd->setDefaultKeySequence(QKeySequence(Tr::tr("Ctrl++")));
tmpaction->setEnabled(false); tmpaction->setEnabled(false);
// Zoom Out Action // Zoom Out Action
icon = QIcon::hasThemeIcon("zoom-out") ? QIcon::fromTheme("zoom-out") icon = Icon::fromTheme("zoom-out");
: Utils::Icons::ZOOMOUT_TOOLBAR.icon();
tmpaction = new QAction(icon, Tr::tr("Zoom Out"), this); tmpaction = new QAction(icon, Tr::tr("Zoom Out"), this);
cmd = ActionManager::registerAction(tmpaction, Constants::ZOOM_OUT); cmd = ActionManager::registerAction(tmpaction, Constants::ZOOM_OUT);
if (useMacShortcuts) if (useMacShortcuts)
@@ -731,8 +729,7 @@ void MainWindow::registerDefaultActions()
tmpaction->setEnabled(false); tmpaction->setEnabled(false);
// Zoom Reset Action // Zoom Reset Action
icon = QIcon::hasThemeIcon("zoom-original") ? QIcon::fromTheme("zoom-original") icon = Icon::fromTheme("zoom-original");
: Utils::Icons::EYE_OPEN_TOOLBAR.icon();
tmpaction = new QAction(icon, Tr::tr("Original Size"), this); tmpaction = new QAction(icon, Tr::tr("Original Size"), this);
cmd = ActionManager::registerAction(tmpaction, Constants::ZOOM_RESET); cmd = ActionManager::registerAction(tmpaction, Constants::ZOOM_RESET);
cmd->setDefaultKeySequence(QKeySequence(Core::useMacShortcuts ? Tr::tr("Meta+0") : Tr::tr("Ctrl+0"))); cmd->setDefaultKeySequence(QKeySequence(Core::useMacShortcuts ? Tr::tr("Meta+0") : Tr::tr("Ctrl+0")));
@@ -844,7 +841,7 @@ void MainWindow::registerDefaultActions()
mhelp->addSeparator(Constants::G_HELP_ABOUT); mhelp->addSeparator(Constants::G_HELP_ABOUT);
// About IDE Action // About IDE Action
icon = QIcon::fromTheme(QLatin1String("help-about")); icon = Icon::fromTheme("help-about");
if (HostOsInfo::isMacHost()) if (HostOsInfo::isMacHost())
tmpaction = new QAction(icon, tmpaction = new QAction(icon,
Tr::tr("About &%1").arg(QGuiApplication::applicationDisplayName()), Tr::tr("About &%1").arg(QGuiApplication::applicationDisplayName()),

View File

@@ -65,7 +65,7 @@ CppcheckTextMark::CppcheckTextMark(const Diagnostic &diagnostic)
setActionsProvider([diagnostic] { setActionsProvider([diagnostic] {
// Copy to clipboard action // Copy to clipboard action
QAction *action = new QAction; QAction *action = new QAction;
action->setIcon(QIcon::fromTheme("edit-copy", Icons::COPY.icon())); action->setIcon(Icon::fromTheme("edit-copy"));
action->setToolTip(TextEditor::Tr::tr("Copy to Clipboard")); action->setToolTip(TextEditor::Tr::tr("Copy to Clipboard"));
QObject::connect(action, &QAction::triggered, [diagnostic]() { QObject::connect(action, &QAction::triggered, [diagnostic]() {
const QString text = QString("%1:%2: %3") const QString text = QString("%1:%2: %3")

View File

@@ -120,7 +120,7 @@ TextEditor::TextMark *DiagnosticManager::createTextMark(TextDocument *doc,
const Diagnostic &diagnostic, const Diagnostic &diagnostic,
bool /*isProjectFile*/) const bool /*isProjectFile*/) const
{ {
static const auto icon = QIcon::fromTheme("edit-copy", Utils::Icons::COPY.icon()); static const QIcon icon = Icon::fromTheme("edit-copy");
static const QString tooltip = Tr::tr("Copy to Clipboard"); static const QString tooltip = Tr::tr("Copy to Clipboard");
auto mark = new TextMark(doc, diagnostic, m_client); auto mark = new TextMark(doc, diagnostic, m_client);
mark->setActionsProvider([text = diagnostic.message()] { mark->setActionsProvider([text = diagnostic.message()] {

View File

@@ -13,11 +13,13 @@
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
#include <utils/utilsicons.h> #include <utils/icon.h>
#include <QApplication> #include <QApplication>
#include <QClipboard> #include <QClipboard>
using namespace Utils;
namespace TextEditor { namespace TextEditor {
namespace Internal { namespace Internal {
@@ -65,7 +67,7 @@ class ClipboardAssistProcessor: public IAssistProcessor
public: public:
IAssistProposal *perform() override IAssistProposal *perform() override
{ {
QIcon icon = QIcon::fromTheme(QLatin1String("edit-paste"), Utils::Icons::PASTE.icon()).pixmap(16); QIcon icon = Icon::fromTheme("edit-paste");
CircularClipboard * clipboard = CircularClipboard::instance(); CircularClipboard * clipboard = CircularClipboard::instance();
QList<AssistProposalItemInterface *> items; QList<AssistProposalItemInterface *> items;
items.reserve(clipboard->size()); items.reserve(clipboard->size());