aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2024-01-25 08:59:18 +0100
committerEike Ziller <eike.ziller@qt.io>2024-01-26 12:25:26 +0000
commitacedf93ba32467a9848cebe25da35c096a5993ae (patch)
tree9940beda3e74168bab3cdde7c8dc08857940fe0c
parent34087df11e93a3624e64e4a8079f1b9af20e3d58 (diff)
Remove CommandButton
The same can be achieve with a factory method in `Command`, similar to the existing ones for actions and buttons which synchronize their tool tips with the shortcut. Change-Id: I7e17654706b902dfa14f37b958fc2a60705d5cb5 Reviewed-by: hjk <hjk@qt.io>
-rw-r--r--src/plugins/coreplugin/CMakeLists.txt2
-rw-r--r--src/plugins/coreplugin/actionmanager/command.cpp26
-rw-r--r--src/plugins/coreplugin/actionmanager/command.h3
-rw-r--r--src/plugins/coreplugin/actionmanager/commandbutton.cpp88
-rw-r--r--src/plugins/coreplugin/actionmanager/commandbutton.h36
-rw-r--r--src/plugins/coreplugin/coreplugin.qbs1
-rw-r--r--src/plugins/coreplugin/ioutputpane.h5
-rw-r--r--src/plugins/coreplugin/outputpanemanager.cpp9
-rw-r--r--src/plugins/haskell/haskelleditorfactory.cpp6
-rw-r--r--src/plugins/modeleditor/modeleditor.cpp16
-rw-r--r--src/plugins/projectexplorer/projectwindow.cpp18
-rw-r--r--src/plugins/python/pythoneditor.cpp1
-rw-r--r--src/plugins/resourceeditor/resourceeditor.cpp7
-rw-r--r--src/plugins/texteditor/markdowneditor.cpp30
14 files changed, 73 insertions, 175 deletions
diff --git a/src/plugins/coreplugin/CMakeLists.txt b/src/plugins/coreplugin/CMakeLists.txt
index 6079989c71..22fe02eec7 100644
--- a/src/plugins/coreplugin/CMakeLists.txt
+++ b/src/plugins/coreplugin/CMakeLists.txt
@@ -11,8 +11,6 @@ add_qtc_plugin(Core
actionmanager/command.cpp
actionmanager/command.h
actionmanager/command_p.h
- actionmanager/commandbutton.cpp
- actionmanager/commandbutton.h
actionmanager/commandmappings.cpp
actionmanager/commandmappings.h
actionmanager/commandsfile.cpp
diff --git a/src/plugins/coreplugin/actionmanager/command.cpp b/src/plugins/coreplugin/actionmanager/command.cpp
index 415e9ea730..34fb37458f 100644
--- a/src/plugins/coreplugin/actionmanager/command.cpp
+++ b/src/plugins/coreplugin/actionmanager/command.cpp
@@ -571,6 +571,21 @@ QAction *Command::createActionWithShortcutToolTip(Id commandId, QObject *parent)
}
/*!
+ Returns a new QToolButton with the command's icon, icon text, and text, that
+ given by \a commandId. Sets the button's parent to \a parent.
+ The action's tool tip is the action's text, augmented with the command's
+ main keyboard shortcut. Other properties of the button are not updated
+ automatically.
+ \sa createActionWithShortcutToolTip()
+*/
+QToolButton *Command::createToolButtonWithShortcutToolTip(Utils::Id commandId, QWidget *parent)
+{
+ auto button = new QToolButton(parent);
+ button->setDefaultAction(createActionWithShortcutToolTip(commandId, button));
+ return button;
+}
+
+/*!
Returns a tool button for \a action.
Appends the main keyboard shortcut \a cmd to the tool tip of the action.
@@ -584,4 +599,15 @@ QToolButton *Command::toolButtonWithAppendedShortcut(QAction *action, Command *c
return button;
}
+/*!
+ Returns a tool button for \a action.
+
+ Appends the main keyboard shortcut of the command with ID \a commandId
+ to the tool tip of the button.
+*/
+QToolButton *Command::toolButtonWithAppendedShortcut(QAction *action, Utils::Id commandId)
+{
+ return toolButtonWithAppendedShortcut(action, ActionManager::command(commandId));
+}
+
} // namespace Core
diff --git a/src/plugins/coreplugin/actionmanager/command.h b/src/plugins/coreplugin/actionmanager/command.h
index 944ca083a7..03f2d594bd 100644
--- a/src/plugins/coreplugin/actionmanager/command.h
+++ b/src/plugins/coreplugin/actionmanager/command.h
@@ -72,7 +72,10 @@ public:
void augmentActionWithShortcutToolTip(QAction *action) const;
static QAction *createActionWithShortcutToolTip(Utils::Id commandId, QObject *parent);
+ static QToolButton *createToolButtonWithShortcutToolTip(Utils::Id commandId,
+ QWidget *parent = nullptr);
static QToolButton *toolButtonWithAppendedShortcut(QAction *action, Command *cmd);
+ static QToolButton *toolButtonWithAppendedShortcut(QAction *action, Utils::Id commandId);
bool isScriptable() const;
bool isScriptable(const Context &) const;
diff --git a/src/plugins/coreplugin/actionmanager/commandbutton.cpp b/src/plugins/coreplugin/actionmanager/commandbutton.cpp
deleted file mode 100644
index 96bb21099b..0000000000
--- a/src/plugins/coreplugin/actionmanager/commandbutton.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-// Copyright (C) 2016 Konstantin Tokarev.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-
-#include "commandbutton.h"
-#include "actionmanager.h"
-#include "command.h"
-
-#include <utils/proxyaction.h>
-#include <utils/qtcassert.h>
-
-using namespace Core;
-using namespace Utils;
-
-/*!
- \class Core::CommandButton
- \inheaderfile coreplugin/actionmanager/commandbutton.h
- \inmodule QtCreator
-
- \brief The CommandButton class is an action associated with one of
- the registered Command objects.
-
- The tooltip of the button consists of toolTipBase property value and Command's
- key sequence which is automatically updated when user changes it.
- */
-
-/*!
- \internal
-*/
-CommandButton::CommandButton(QWidget *parent)
- : QToolButton(parent)
-{}
-
-/*!
- \internal
-*/
-CommandButton::CommandButton(Utils::Id id, QWidget *parent)
- : QToolButton(parent)
-{
- setCommandId(id);
-}
-
-void CommandButton::setCommandId(Utils::Id id)
-{
- if (m_command)
- disconnect(m_command.data(),
- &Command::keySequenceChanged,
- this,
- &CommandButton::updateToolTip);
-
- m_command = ActionManager::command(id);
- QTC_ASSERT(m_command, return);
-
- if (m_toolTipBase.isEmpty())
- m_toolTipBase = m_command->description();
-
- updateToolTip();
- connect(m_command.data(), &Command::keySequenceChanged, this, &CommandButton::updateToolTip);
-}
-
-/*!
- The base tool tip that is extended with the command's shortcut.
- Defaults to the command's description.
-
- \sa Command::description()
-*/
-QString CommandButton::toolTipBase() const
-{
- return m_toolTipBase;
-}
-
-/*!
- Sets the base tool tip that is extended with the command's shortcut to
- \a toolTipBase.
-
- \sa toolTipBase()
-*/
-void CommandButton::setToolTipBase(const QString &toolTipBase)
-{
- m_toolTipBase = toolTipBase;
- updateToolTip();
-}
-
-void CommandButton::updateToolTip()
-{
- if (m_command)
- setToolTip(Utils::ProxyAction::stringWithAppendedShortcut(m_toolTipBase,
- m_command->keySequence()));
-}
diff --git a/src/plugins/coreplugin/actionmanager/commandbutton.h b/src/plugins/coreplugin/actionmanager/commandbutton.h
deleted file mode 100644
index 70ec6e7ab8..0000000000
--- a/src/plugins/coreplugin/actionmanager/commandbutton.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (C) 2016 Konstantin Tokarev.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-
-#pragma once
-
-#include "../core_global.h"
-
-#include <utils/id.h>
-
-#include <QAction>
-#include <QPointer>
-#include <QString>
-#include <QToolButton>
-
-namespace Core {
-
-class Command;
-
-class CORE_EXPORT CommandButton : public QToolButton
-{
- Q_OBJECT
-
-public:
- explicit CommandButton(QWidget *parent = nullptr);
- explicit CommandButton(Utils::Id id, QWidget *parent = nullptr);
- void setCommandId(Utils::Id id);
- QString toolTipBase() const;
- void setToolTipBase(const QString &toolTipBase);
-
-private:
- void updateToolTip();
-
- QPointer<Command> m_command;
- QString m_toolTipBase;
-};
-}
diff --git a/src/plugins/coreplugin/coreplugin.qbs b/src/plugins/coreplugin/coreplugin.qbs
index 9bd3923a6f..3c1dd74063 100644
--- a/src/plugins/coreplugin/coreplugin.qbs
+++ b/src/plugins/coreplugin/coreplugin.qbs
@@ -186,7 +186,6 @@ QtcPlugin {
"actioncontainer.cpp", "actioncontainer.h", "actioncontainer_p.h",
"actionmanager.cpp", "actionmanager.h", "actionmanager_p.h",
"command.cpp", "command.h", "command_p.h",
- "commandbutton.cpp", "commandbutton.h",
"commandmappings.cpp", "commandmappings.h",
"commandsfile.cpp", "commandsfile.h",
]
diff --git a/src/plugins/coreplugin/ioutputpane.h b/src/plugins/coreplugin/ioutputpane.h
index 353bd63b0a..18cf530005 100644
--- a/src/plugins/coreplugin/ioutputpane.h
+++ b/src/plugins/coreplugin/ioutputpane.h
@@ -10,7 +10,6 @@
#include <utils/id.h>
namespace Core {
-class CommandButton;
class IContext;
class OutputWindow;
@@ -103,8 +102,8 @@ private:
Utils::Id m_id;
QString m_displayName;
int m_priority = -1;
- Core::CommandButton * const m_zoomInButton;
- Core::CommandButton * const m_zoomOutButton;
+ QToolButton *m_zoomInButton;
+ QToolButton *m_zoomOutButton;
Utils::FancyLineEdit *m_filterOutputLineEdit = nullptr;
bool m_filterRegexp = false;
bool m_invertFilter = false;
diff --git a/src/plugins/coreplugin/outputpanemanager.cpp b/src/plugins/coreplugin/outputpanemanager.cpp
index c1eac2ade8..a6e83474cf 100644
--- a/src/plugins/coreplugin/outputpanemanager.cpp
+++ b/src/plugins/coreplugin/outputpanemanager.cpp
@@ -6,7 +6,6 @@
#include "actionmanager/actioncontainer.h"
#include "actionmanager/actionmanager.h"
#include "actionmanager/command.h"
-#include "actionmanager/commandbutton.h"
#include "coreplugintr.h"
#include "editormanager/editormanager.h"
#include "editormanager/ieditor.h"
@@ -67,20 +66,18 @@ static bool g_managerConstructed = false; // For debugging reasons.
// OutputPane
IOutputPane::IOutputPane(QObject *parent)
- : QObject(parent),
- m_zoomInButton(new Core::CommandButton),
- m_zoomOutButton(new Core::CommandButton)
+ : QObject(parent)
{
// We need all pages first. Ignore latecomers and shout.
QTC_ASSERT(!g_managerConstructed, return);
g_outputPanes.append(OutputPaneData(this));
+ m_zoomInButton = Command::createToolButtonWithShortcutToolTip(Constants::ZOOM_IN);
m_zoomInButton->setIcon(Utils::Icons::PLUS_TOOLBAR.icon());
- m_zoomInButton->setCommandId(Constants::ZOOM_IN);
connect(m_zoomInButton, &QToolButton::clicked, this, [this] { emit zoomInRequested(1); });
+ m_zoomOutButton = Command::createToolButtonWithShortcutToolTip(Constants::ZOOM_OUT);
m_zoomOutButton->setIcon(Utils::Icons::MINUS_TOOLBAR.icon());
- m_zoomOutButton->setCommandId(Constants::ZOOM_OUT);
connect(m_zoomOutButton, &QToolButton::clicked, this, [this] { emit zoomOutRequested(1); });
}
diff --git a/src/plugins/haskell/haskelleditorfactory.cpp b/src/plugins/haskell/haskelleditorfactory.cpp
index 3371a8734c..5ddcb11e51 100644
--- a/src/plugins/haskell/haskelleditorfactory.cpp
+++ b/src/plugins/haskell/haskelleditorfactory.cpp
@@ -8,7 +8,7 @@
#include "haskellmanager.h"
#include "haskelltr.h"
-#include <coreplugin/actionmanager/commandbutton.h>
+#include <coreplugin/actionmanager/command.h>
#include <coreplugin/coreplugintr.h>
#include <texteditor/textdocument.h>
@@ -23,8 +23,8 @@ namespace Haskell::Internal {
static QWidget *createEditorWidget()
{
auto widget = new TextEditorWidget;
- auto ghciButton = new Core::CommandButton(Constants::A_RUN_GHCI, widget);
- ghciButton->setText(Tr::tr("GHCi"));
+ auto ghciButton = Core::Command::createToolButtonWithShortcutToolTip(Constants::A_RUN_GHCI);
+ ghciButton->defaultAction()->setIconText(Tr::tr("GHCi"));
QObject::connect(ghciButton, &QToolButton::clicked, widget, [widget] {
openGhci(widget->textDocument()->filePath());
});
diff --git a/src/plugins/modeleditor/modeleditor.cpp b/src/plugins/modeleditor/modeleditor.cpp
index 0fdeb83b29..f17a35e434 100644
--- a/src/plugins/modeleditor/modeleditor.cpp
+++ b/src/plugins/modeleditor/modeleditor.cpp
@@ -52,7 +52,6 @@
#include <coreplugin/icore.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/minisplitter.h>
-#include <coreplugin/actionmanager/commandbutton.h>
#include <utils/fadingindicator.h>
#include <utils/fileutils.h>
#include <utils/layoutbuilder.h>
@@ -71,18 +70,19 @@
#include <QImageWriter>
#include <QLabel>
#include <QMap>
+#include <QMenu>
#include <QMessageBox>
#include <QPainter>
#include <QPixmap>
#include <QScrollArea>
+#include <QScrollBar>
#include <QStackedWidget>
#include <QStyleFactory>
#include <QTimer>
#include <QToolBox>
+#include <QToolButton>
#include <QUndoStack>
#include <QVBoxLayout>
-#include <QMenu>
-#include <QScrollBar>
#include <algorithm>
@@ -297,8 +297,9 @@ void ModelEditor::init()
toolbarLayout->setContentsMargins(0, 0, 0, 0);
toolbarLayout->setSpacing(0);
- auto openParentButton = new CommandButton(Constants::OPEN_PARENT_DIAGRAM, d->toolbar);
- openParentButton->setDefaultAction(d->actionHandler->openParentDiagramAction());
+ auto openParentButton
+ = Command::toolButtonWithAppendedShortcut(d->actionHandler->openParentDiagramAction(),
+ Constants::OPEN_PARENT_DIAGRAM);
toolbarLayout->addWidget(openParentButton);
d->diagramSelector = new QComboBox(d->toolbar);
@@ -327,8 +328,9 @@ void ModelEditor::init()
d->toolbar));
toolbarLayout->addSpacing(20);
- auto syncToggleButton = new CommandButton(Constants::ACTION_SYNC_BROWSER, d->toolbar);
- syncToggleButton->setDefaultAction(d->actionHandler->synchronizeBrowserAction());
+ auto syncToggleButton
+ = Command::toolButtonWithAppendedShortcut(d->actionHandler->synchronizeBrowserAction(),
+ Constants::ACTION_SYNC_BROWSER);
QMenu *syncMenu = new QMenu(syncToggleButton);
QActionGroup *syncGroup = new QActionGroup(syncMenu);
d->syncBrowserWithDiagramAction = syncMenu->addAction(Tr::tr("Synchronize Structure with Diagram"));
diff --git a/src/plugins/projectexplorer/projectwindow.cpp b/src/plugins/projectexplorer/projectwindow.cpp
index 547faa9157..c0577c5c52 100644
--- a/src/plugins/projectexplorer/projectwindow.cpp
+++ b/src/plugins/projectexplorer/projectwindow.cpp
@@ -21,7 +21,7 @@
#include "targetsettingspanel.h"
#include <coreplugin/actionmanager/actionmanager.h>
-#include <coreplugin/actionmanager/commandbutton.h>
+#include <coreplugin/actionmanager/command.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/coreicons.h>
#include <coreplugin/coreplugintr.h>
@@ -56,6 +56,7 @@
#include <QPushButton>
#include <QStyledItemDelegate>
#include <QTimer>
+#include <QToolButton>
#include <QTreeView>
#include <QVBoxLayout>
@@ -136,12 +137,14 @@ BuildSystemOutputWindow::BuildSystemOutputWindow()
setBaseFont(TextEditor::TextEditorSettings::fontSettings().font());
m_zoomIn.setIcon(Utils::Icons::PLUS_TOOLBAR.icon());
+ m_zoomIn.setText(ActionManager::command(Core::Constants::ZOOM_IN)->action()->text());
connect(&m_zoomIn, &QAction::triggered, this, [this] { zoomIn(); });
ActionManager::registerAction(&m_zoomIn,
Core::Constants::ZOOM_IN,
Context(kBuildSystemOutputContext));
m_zoomOut.setIcon(Utils::Icons::MINUS_TOOLBAR.icon());
+ m_zoomOut.setText(ActionManager::command(Core::Constants::ZOOM_OUT)->action()->text());
connect(&m_zoomOut, &QAction::triggered, this, [this] { zoomOut(); });
ActionManager::registerAction(&m_zoomOut,
Core::Constants::ZOOM_OUT,
@@ -152,9 +155,8 @@ QWidget *BuildSystemOutputWindow::toolBar()
{
if (!m_toolBar) {
m_toolBar = new StyledBar(this);
- auto clearButton = new CommandButton(Core::Constants::OUTPUTPANE_CLEAR);
- clearButton->setDefaultAction(&m_clear);
- clearButton->setToolTipBase(m_clear.text());
+ auto clearButton
+ = Command::toolButtonWithAppendedShortcut(&m_clear, Core::Constants::OUTPUTPANE_CLEAR);
m_filterOutputLineEdit = new FancyLineEdit;
m_filterOutputLineEdit->setButtonVisible(FancyLineEdit::Left, true);
@@ -178,10 +180,10 @@ QWidget *BuildSystemOutputWindow::toolBar()
popup->show();
});
- auto zoomInButton = new CommandButton(Core::Constants::ZOOM_IN);
- zoomInButton->setDefaultAction(&m_zoomIn);
- auto zoomOutButton = new CommandButton(Core::Constants::ZOOM_OUT);
- zoomOutButton->setDefaultAction(&m_zoomOut);
+ auto zoomInButton = Command::toolButtonWithAppendedShortcut(&m_zoomIn,
+ Core::Constants::ZOOM_IN);
+ auto zoomOutButton = Command::toolButtonWithAppendedShortcut(&m_zoomOut,
+ Core::Constants::ZOOM_OUT);
auto layout = new QHBoxLayout;
layout->setContentsMargins(0, 0, 0, 0);
diff --git a/src/plugins/python/pythoneditor.cpp b/src/plugins/python/pythoneditor.cpp
index f8d6a83a4a..ddd30f2acf 100644
--- a/src/plugins/python/pythoneditor.cpp
+++ b/src/plugins/python/pythoneditor.cpp
@@ -15,7 +15,6 @@
#include "pythonutils.h"
#include <coreplugin/actionmanager/actionmanager.h>
-#include <coreplugin/actionmanager/commandbutton.h>
#include <coreplugin/coreplugintr.h>
#include <coreplugin/icore.h>
diff --git a/src/plugins/resourceeditor/resourceeditor.cpp b/src/plugins/resourceeditor/resourceeditor.cpp
index 54ea676713..2bc7d443bc 100644
--- a/src/plugins/resourceeditor/resourceeditor.cpp
+++ b/src/plugins/resourceeditor/resourceeditor.cpp
@@ -10,7 +10,7 @@
#include "qrceditor/resourcefile_p.h"
#include <coreplugin/actionmanager/actionmanager.h>
-#include <coreplugin/actionmanager/commandbutton.h>
+#include <coreplugin/actionmanager/command.h>
#include <coreplugin/coreplugintr.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/ieditorfactory.h>
@@ -27,6 +27,7 @@
#include <QDebug>
#include <QMenu>
#include <QToolBar>
+#include <QToolButton>
using namespace Core;
using namespace Utils;
@@ -143,8 +144,8 @@ ResourceEditorImpl::ResourceEditorImpl()
setContext(Context(Constants::C_RESOURCEEDITOR));
setWidget(m_resourceEditor);
- CommandButton *refreshButton = new CommandButton(Constants::REFRESH, m_toolBar);
- refreshButton->setIcon(QIcon(QLatin1String(":/texteditor/images/finddocuments.png")));
+ QToolButton *refreshButton = Command::createToolButtonWithShortcutToolTip(Constants::REFRESH);
+ refreshButton->defaultAction()->setIcon(QIcon(":/texteditor/images/finddocuments.png"));
connect(refreshButton, &QAbstractButton::clicked, m_resourceEditor, &QrcEditor::refresh);
m_toolBar->addWidget(refreshButton);
diff --git a/src/plugins/texteditor/markdowneditor.cpp b/src/plugins/texteditor/markdowneditor.cpp
index 6f250d23eb..9612b9a001 100644
--- a/src/plugins/texteditor/markdowneditor.cpp
+++ b/src/plugins/texteditor/markdowneditor.cpp
@@ -9,7 +9,6 @@
#include <aggregation/aggregate.h>
#include <coreplugin/actionmanager/actionmanager.h>
-#include <coreplugin/actionmanager/commandbutton.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/coreplugintr.h>
#include <coreplugin/icore.h>
@@ -134,33 +133,31 @@ public:
}
agg->add(m_widget.get());
- m_togglePreviewVisible = new CommandButton(TOGGLEPREVIEW_ACTION);
- m_togglePreviewVisible->setText(m_togglePreviewVisible->toolTipBase());
+ m_togglePreviewVisible = Command::createToolButtonWithShortcutToolTip(TOGGLEPREVIEW_ACTION);
m_togglePreviewVisible->setCheckable(true);
m_togglePreviewVisible->setChecked(showPreview);
m_previewWidget->setVisible(showPreview);
- m_toggleEditorVisible = new CommandButton(TOGGLEEDITOR_ACTION);
- m_toggleEditorVisible->setText(m_toggleEditorVisible->toolTipBase());
+ m_toggleEditorVisible = Command::createToolButtonWithShortcutToolTip(TOGGLEEDITOR_ACTION);
m_toggleEditorVisible->setCheckable(true);
m_toggleEditorVisible->setChecked(showEditor);
m_textEditorWidget->setVisible(showEditor);
- auto button = new CommandButton(EMPHASIS_ACTION);
- button->setText("i");
+ auto button = Command::createToolButtonWithShortcutToolTip(EMPHASIS_ACTION);
+ button->defaultAction()->setIconText("i");
button->setFont([button]{ auto f = button->font(); f.setItalic(true); return f; }());
connect(button, &QToolButton::clicked, this, &MarkdownEditor::triggerEmphasis);
m_markDownButtons.append(button);
- button = new CommandButton(STRONG_ACTION);
- button->setText("b");
+ button = Command::createToolButtonWithShortcutToolTip(STRONG_ACTION);
+ button->defaultAction()->setIconText("b");
button->setFont([button]{ auto f = button->font(); f.setBold(true); return f; }());
connect(button, &QToolButton::clicked, this, &MarkdownEditor::triggerStrong);
m_markDownButtons.append(button);
- button = new CommandButton(INLINECODE_ACTION);
- button->setText("`");
+ button = Command::createToolButtonWithShortcutToolTip(INLINECODE_ACTION);
+ button->defaultAction()->setIconText("`");
connect(button, &QToolButton::clicked, this, &MarkdownEditor::triggerInlineCode);
m_markDownButtons.append(button);
- button = new CommandButton(LINK_ACTION);
+ button = Command::createToolButtonWithShortcutToolTip(LINK_ACTION);
button->setIcon(Utils::Icons::LINK_TOOLBAR.icon());
connect(button, &QToolButton::clicked, this, &MarkdownEditor::triggerLink);
m_markDownButtons.append(button);
@@ -173,8 +170,7 @@ public:
for (auto button : m_markDownButtons | Utils::views::reverse)
m_textEditorWidget->insertExtraToolBarWidget(TextEditorWidget::Left, button);
- m_swapViews = new CommandButton(SWAPVIEWS_ACTION);
- m_swapViews->setText(m_swapViews->toolTipBase());
+ m_swapViews = Command::createToolButtonWithShortcutToolTip(SWAPVIEWS_ACTION);
m_swapViews->setEnabled(showEditor && showPreview);
m_swapViewsAction = m_textEditorWidget->insertExtraToolBarWidget(TextEditorWidget::Right, m_swapViews);
@@ -486,9 +482,9 @@ private:
TextEditorWidget *m_textEditorWidget;
TextDocumentPtr m_document;
QList<QToolButton *> m_markDownButtons;
- CommandButton *m_toggleEditorVisible;
- CommandButton *m_togglePreviewVisible;
- CommandButton *m_swapViews;
+ QToolButton *m_toggleEditorVisible;
+ QToolButton *m_togglePreviewVisible;
+ QToolButton *m_swapViews;
QAction *m_toggleEditorVisibleAction;
QAction *m_togglePreviewVisibleAction;
QAction *m_swapViewsAction;