forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -11,8 +11,6 @@ add_qtc_plugin(Core
|
|||||||
actionmanager/command.cpp
|
actionmanager/command.cpp
|
||||||
actionmanager/command.h
|
actionmanager/command.h
|
||||||
actionmanager/command_p.h
|
actionmanager/command_p.h
|
||||||
actionmanager/commandbutton.cpp
|
|
||||||
actionmanager/commandbutton.h
|
|
||||||
actionmanager/commandmappings.cpp
|
actionmanager/commandmappings.cpp
|
||||||
actionmanager/commandmappings.h
|
actionmanager/commandmappings.h
|
||||||
actionmanager/commandsfile.cpp
|
actionmanager/commandsfile.cpp
|
||||||
|
|||||||
@@ -570,6 +570,21 @@ QAction *Command::createActionWithShortcutToolTip(Id commandId, QObject *parent)
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
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.
|
Returns a tool button for \a action.
|
||||||
|
|
||||||
@@ -584,4 +599,15 @@ QToolButton *Command::toolButtonWithAppendedShortcut(QAction *action, Command *c
|
|||||||
return button;
|
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
|
} // namespace Core
|
||||||
|
|||||||
@@ -72,7 +72,10 @@ public:
|
|||||||
void augmentActionWithShortcutToolTip(QAction *action) const;
|
void augmentActionWithShortcutToolTip(QAction *action) const;
|
||||||
|
|
||||||
static QAction *createActionWithShortcutToolTip(Utils::Id commandId, QObject *parent);
|
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, Command *cmd);
|
||||||
|
static QToolButton *toolButtonWithAppendedShortcut(QAction *action, Utils::Id commandId);
|
||||||
|
|
||||||
bool isScriptable() const;
|
bool isScriptable() const;
|
||||||
bool isScriptable(const Context &) const;
|
bool isScriptable(const Context &) const;
|
||||||
|
|||||||
@@ -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()));
|
|
||||||
}
|
|
||||||
@@ -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;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -186,7 +186,6 @@ QtcPlugin {
|
|||||||
"actioncontainer.cpp", "actioncontainer.h", "actioncontainer_p.h",
|
"actioncontainer.cpp", "actioncontainer.h", "actioncontainer_p.h",
|
||||||
"actionmanager.cpp", "actionmanager.h", "actionmanager_p.h",
|
"actionmanager.cpp", "actionmanager.h", "actionmanager_p.h",
|
||||||
"command.cpp", "command.h", "command_p.h",
|
"command.cpp", "command.h", "command_p.h",
|
||||||
"commandbutton.cpp", "commandbutton.h",
|
|
||||||
"commandmappings.cpp", "commandmappings.h",
|
"commandmappings.cpp", "commandmappings.h",
|
||||||
"commandsfile.cpp", "commandsfile.h",
|
"commandsfile.cpp", "commandsfile.h",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
#include <utils/id.h>
|
#include <utils/id.h>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class CommandButton;
|
|
||||||
class IContext;
|
class IContext;
|
||||||
class OutputWindow;
|
class OutputWindow;
|
||||||
|
|
||||||
@@ -103,8 +102,8 @@ private:
|
|||||||
Utils::Id m_id;
|
Utils::Id m_id;
|
||||||
QString m_displayName;
|
QString m_displayName;
|
||||||
int m_priority = -1;
|
int m_priority = -1;
|
||||||
Core::CommandButton * const m_zoomInButton;
|
QToolButton *m_zoomInButton;
|
||||||
Core::CommandButton * const m_zoomOutButton;
|
QToolButton *m_zoomOutButton;
|
||||||
Utils::FancyLineEdit *m_filterOutputLineEdit = nullptr;
|
Utils::FancyLineEdit *m_filterOutputLineEdit = nullptr;
|
||||||
bool m_filterRegexp = false;
|
bool m_filterRegexp = false;
|
||||||
bool m_invertFilter = false;
|
bool m_invertFilter = false;
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
#include "actionmanager/actioncontainer.h"
|
#include "actionmanager/actioncontainer.h"
|
||||||
#include "actionmanager/actionmanager.h"
|
#include "actionmanager/actionmanager.h"
|
||||||
#include "actionmanager/command.h"
|
#include "actionmanager/command.h"
|
||||||
#include "actionmanager/commandbutton.h"
|
|
||||||
#include "coreplugintr.h"
|
#include "coreplugintr.h"
|
||||||
#include "editormanager/editormanager.h"
|
#include "editormanager/editormanager.h"
|
||||||
#include "editormanager/ieditor.h"
|
#include "editormanager/ieditor.h"
|
||||||
@@ -67,20 +66,18 @@ static bool g_managerConstructed = false; // For debugging reasons.
|
|||||||
// OutputPane
|
// OutputPane
|
||||||
|
|
||||||
IOutputPane::IOutputPane(QObject *parent)
|
IOutputPane::IOutputPane(QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent)
|
||||||
m_zoomInButton(new Core::CommandButton),
|
|
||||||
m_zoomOutButton(new Core::CommandButton)
|
|
||||||
{
|
{
|
||||||
// We need all pages first. Ignore latecomers and shout.
|
// We need all pages first. Ignore latecomers and shout.
|
||||||
QTC_ASSERT(!g_managerConstructed, return);
|
QTC_ASSERT(!g_managerConstructed, return);
|
||||||
g_outputPanes.append(OutputPaneData(this));
|
g_outputPanes.append(OutputPaneData(this));
|
||||||
|
|
||||||
|
m_zoomInButton = Command::createToolButtonWithShortcutToolTip(Constants::ZOOM_IN);
|
||||||
m_zoomInButton->setIcon(Utils::Icons::PLUS_TOOLBAR.icon());
|
m_zoomInButton->setIcon(Utils::Icons::PLUS_TOOLBAR.icon());
|
||||||
m_zoomInButton->setCommandId(Constants::ZOOM_IN);
|
|
||||||
connect(m_zoomInButton, &QToolButton::clicked, this, [this] { emit zoomInRequested(1); });
|
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->setIcon(Utils::Icons::MINUS_TOOLBAR.icon());
|
||||||
m_zoomOutButton->setCommandId(Constants::ZOOM_OUT);
|
|
||||||
connect(m_zoomOutButton, &QToolButton::clicked, this, [this] { emit zoomOutRequested(1); });
|
connect(m_zoomOutButton, &QToolButton::clicked, this, [this] { emit zoomOutRequested(1); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#include "haskellmanager.h"
|
#include "haskellmanager.h"
|
||||||
#include "haskelltr.h"
|
#include "haskelltr.h"
|
||||||
|
|
||||||
#include <coreplugin/actionmanager/commandbutton.h>
|
#include <coreplugin/actionmanager/command.h>
|
||||||
#include <coreplugin/coreplugintr.h>
|
#include <coreplugin/coreplugintr.h>
|
||||||
|
|
||||||
#include <texteditor/textdocument.h>
|
#include <texteditor/textdocument.h>
|
||||||
@@ -23,8 +23,8 @@ namespace Haskell::Internal {
|
|||||||
static QWidget *createEditorWidget()
|
static QWidget *createEditorWidget()
|
||||||
{
|
{
|
||||||
auto widget = new TextEditorWidget;
|
auto widget = new TextEditorWidget;
|
||||||
auto ghciButton = new Core::CommandButton(Constants::A_RUN_GHCI, widget);
|
auto ghciButton = Core::Command::createToolButtonWithShortcutToolTip(Constants::A_RUN_GHCI);
|
||||||
ghciButton->setText(Tr::tr("GHCi"));
|
ghciButton->defaultAction()->setIconText(Tr::tr("GHCi"));
|
||||||
QObject::connect(ghciButton, &QToolButton::clicked, widget, [widget] {
|
QObject::connect(ghciButton, &QToolButton::clicked, widget, [widget] {
|
||||||
openGhci(widget->textDocument()->filePath());
|
openGhci(widget->textDocument()->filePath());
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -52,7 +52,6 @@
|
|||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <coreplugin/minisplitter.h>
|
#include <coreplugin/minisplitter.h>
|
||||||
#include <coreplugin/actionmanager/commandbutton.h>
|
|
||||||
#include <utils/fadingindicator.h>
|
#include <utils/fadingindicator.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/layoutbuilder.h>
|
#include <utils/layoutbuilder.h>
|
||||||
@@ -71,18 +70,19 @@
|
|||||||
#include <QImageWriter>
|
#include <QImageWriter>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
#include <QMenu>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
|
#include <QScrollBar>
|
||||||
#include <QStackedWidget>
|
#include <QStackedWidget>
|
||||||
#include <QStyleFactory>
|
#include <QStyleFactory>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QToolBox>
|
#include <QToolBox>
|
||||||
|
#include <QToolButton>
|
||||||
#include <QUndoStack>
|
#include <QUndoStack>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QMenu>
|
|
||||||
#include <QScrollBar>
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@@ -297,8 +297,9 @@ void ModelEditor::init()
|
|||||||
toolbarLayout->setContentsMargins(0, 0, 0, 0);
|
toolbarLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
toolbarLayout->setSpacing(0);
|
toolbarLayout->setSpacing(0);
|
||||||
|
|
||||||
auto openParentButton = new CommandButton(Constants::OPEN_PARENT_DIAGRAM, d->toolbar);
|
auto openParentButton
|
||||||
openParentButton->setDefaultAction(d->actionHandler->openParentDiagramAction());
|
= Command::toolButtonWithAppendedShortcut(d->actionHandler->openParentDiagramAction(),
|
||||||
|
Constants::OPEN_PARENT_DIAGRAM);
|
||||||
toolbarLayout->addWidget(openParentButton);
|
toolbarLayout->addWidget(openParentButton);
|
||||||
|
|
||||||
d->diagramSelector = new QComboBox(d->toolbar);
|
d->diagramSelector = new QComboBox(d->toolbar);
|
||||||
@@ -327,8 +328,9 @@ void ModelEditor::init()
|
|||||||
d->toolbar));
|
d->toolbar));
|
||||||
toolbarLayout->addSpacing(20);
|
toolbarLayout->addSpacing(20);
|
||||||
|
|
||||||
auto syncToggleButton = new CommandButton(Constants::ACTION_SYNC_BROWSER, d->toolbar);
|
auto syncToggleButton
|
||||||
syncToggleButton->setDefaultAction(d->actionHandler->synchronizeBrowserAction());
|
= Command::toolButtonWithAppendedShortcut(d->actionHandler->synchronizeBrowserAction(),
|
||||||
|
Constants::ACTION_SYNC_BROWSER);
|
||||||
QMenu *syncMenu = new QMenu(syncToggleButton);
|
QMenu *syncMenu = new QMenu(syncToggleButton);
|
||||||
QActionGroup *syncGroup = new QActionGroup(syncMenu);
|
QActionGroup *syncGroup = new QActionGroup(syncMenu);
|
||||||
d->syncBrowserWithDiagramAction = syncMenu->addAction(Tr::tr("Synchronize Structure with Diagram"));
|
d->syncBrowserWithDiagramAction = syncMenu->addAction(Tr::tr("Synchronize Structure with Diagram"));
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
#include "targetsettingspanel.h"
|
#include "targetsettingspanel.h"
|
||||||
|
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
#include <coreplugin/actionmanager/commandbutton.h>
|
#include <coreplugin/actionmanager/command.h>
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
#include <coreplugin/coreicons.h>
|
#include <coreplugin/coreicons.h>
|
||||||
#include <coreplugin/coreplugintr.h>
|
#include <coreplugin/coreplugintr.h>
|
||||||
@@ -56,6 +56,7 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QStyledItemDelegate>
|
#include <QStyledItemDelegate>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QToolButton>
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
@@ -136,12 +137,14 @@ BuildSystemOutputWindow::BuildSystemOutputWindow()
|
|||||||
setBaseFont(TextEditor::TextEditorSettings::fontSettings().font());
|
setBaseFont(TextEditor::TextEditorSettings::fontSettings().font());
|
||||||
|
|
||||||
m_zoomIn.setIcon(Utils::Icons::PLUS_TOOLBAR.icon());
|
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(); });
|
connect(&m_zoomIn, &QAction::triggered, this, [this] { zoomIn(); });
|
||||||
ActionManager::registerAction(&m_zoomIn,
|
ActionManager::registerAction(&m_zoomIn,
|
||||||
Core::Constants::ZOOM_IN,
|
Core::Constants::ZOOM_IN,
|
||||||
Context(kBuildSystemOutputContext));
|
Context(kBuildSystemOutputContext));
|
||||||
|
|
||||||
m_zoomOut.setIcon(Utils::Icons::MINUS_TOOLBAR.icon());
|
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(); });
|
connect(&m_zoomOut, &QAction::triggered, this, [this] { zoomOut(); });
|
||||||
ActionManager::registerAction(&m_zoomOut,
|
ActionManager::registerAction(&m_zoomOut,
|
||||||
Core::Constants::ZOOM_OUT,
|
Core::Constants::ZOOM_OUT,
|
||||||
@@ -152,9 +155,8 @@ QWidget *BuildSystemOutputWindow::toolBar()
|
|||||||
{
|
{
|
||||||
if (!m_toolBar) {
|
if (!m_toolBar) {
|
||||||
m_toolBar = new StyledBar(this);
|
m_toolBar = new StyledBar(this);
|
||||||
auto clearButton = new CommandButton(Core::Constants::OUTPUTPANE_CLEAR);
|
auto clearButton
|
||||||
clearButton->setDefaultAction(&m_clear);
|
= Command::toolButtonWithAppendedShortcut(&m_clear, Core::Constants::OUTPUTPANE_CLEAR);
|
||||||
clearButton->setToolTipBase(m_clear.text());
|
|
||||||
|
|
||||||
m_filterOutputLineEdit = new FancyLineEdit;
|
m_filterOutputLineEdit = new FancyLineEdit;
|
||||||
m_filterOutputLineEdit->setButtonVisible(FancyLineEdit::Left, true);
|
m_filterOutputLineEdit->setButtonVisible(FancyLineEdit::Left, true);
|
||||||
@@ -178,10 +180,10 @@ QWidget *BuildSystemOutputWindow::toolBar()
|
|||||||
popup->show();
|
popup->show();
|
||||||
});
|
});
|
||||||
|
|
||||||
auto zoomInButton = new CommandButton(Core::Constants::ZOOM_IN);
|
auto zoomInButton = Command::toolButtonWithAppendedShortcut(&m_zoomIn,
|
||||||
zoomInButton->setDefaultAction(&m_zoomIn);
|
Core::Constants::ZOOM_IN);
|
||||||
auto zoomOutButton = new CommandButton(Core::Constants::ZOOM_OUT);
|
auto zoomOutButton = Command::toolButtonWithAppendedShortcut(&m_zoomOut,
|
||||||
zoomOutButton->setDefaultAction(&m_zoomOut);
|
Core::Constants::ZOOM_OUT);
|
||||||
|
|
||||||
auto layout = new QHBoxLayout;
|
auto layout = new QHBoxLayout;
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
#include "pythonutils.h"
|
#include "pythonutils.h"
|
||||||
|
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
#include <coreplugin/actionmanager/commandbutton.h>
|
|
||||||
#include <coreplugin/coreplugintr.h>
|
#include <coreplugin/coreplugintr.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#include "qrceditor/resourcefile_p.h"
|
#include "qrceditor/resourcefile_p.h"
|
||||||
|
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
#include <coreplugin/actionmanager/commandbutton.h>
|
#include <coreplugin/actionmanager/command.h>
|
||||||
#include <coreplugin/coreplugintr.h>
|
#include <coreplugin/coreplugintr.h>
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <coreplugin/editormanager/ieditorfactory.h>
|
#include <coreplugin/editormanager/ieditorfactory.h>
|
||||||
@@ -27,6 +27,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
|
#include <QToolButton>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
@@ -143,8 +144,8 @@ ResourceEditorImpl::ResourceEditorImpl()
|
|||||||
setContext(Context(Constants::C_RESOURCEEDITOR));
|
setContext(Context(Constants::C_RESOURCEEDITOR));
|
||||||
setWidget(m_resourceEditor);
|
setWidget(m_resourceEditor);
|
||||||
|
|
||||||
CommandButton *refreshButton = new CommandButton(Constants::REFRESH, m_toolBar);
|
QToolButton *refreshButton = Command::createToolButtonWithShortcutToolTip(Constants::REFRESH);
|
||||||
refreshButton->setIcon(QIcon(QLatin1String(":/texteditor/images/finddocuments.png")));
|
refreshButton->defaultAction()->setIcon(QIcon(":/texteditor/images/finddocuments.png"));
|
||||||
connect(refreshButton, &QAbstractButton::clicked, m_resourceEditor, &QrcEditor::refresh);
|
connect(refreshButton, &QAbstractButton::clicked, m_resourceEditor, &QrcEditor::refresh);
|
||||||
m_toolBar->addWidget(refreshButton);
|
m_toolBar->addWidget(refreshButton);
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
#include <aggregation/aggregate.h>
|
#include <aggregation/aggregate.h>
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
#include <coreplugin/actionmanager/commandbutton.h>
|
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
#include <coreplugin/coreplugintr.h>
|
#include <coreplugin/coreplugintr.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
@@ -134,33 +133,31 @@ public:
|
|||||||
}
|
}
|
||||||
agg->add(m_widget.get());
|
agg->add(m_widget.get());
|
||||||
|
|
||||||
m_togglePreviewVisible = new CommandButton(TOGGLEPREVIEW_ACTION);
|
m_togglePreviewVisible = Command::createToolButtonWithShortcutToolTip(TOGGLEPREVIEW_ACTION);
|
||||||
m_togglePreviewVisible->setText(m_togglePreviewVisible->toolTipBase());
|
|
||||||
m_togglePreviewVisible->setCheckable(true);
|
m_togglePreviewVisible->setCheckable(true);
|
||||||
m_togglePreviewVisible->setChecked(showPreview);
|
m_togglePreviewVisible->setChecked(showPreview);
|
||||||
m_previewWidget->setVisible(showPreview);
|
m_previewWidget->setVisible(showPreview);
|
||||||
|
|
||||||
m_toggleEditorVisible = new CommandButton(TOGGLEEDITOR_ACTION);
|
m_toggleEditorVisible = Command::createToolButtonWithShortcutToolTip(TOGGLEEDITOR_ACTION);
|
||||||
m_toggleEditorVisible->setText(m_toggleEditorVisible->toolTipBase());
|
|
||||||
m_toggleEditorVisible->setCheckable(true);
|
m_toggleEditorVisible->setCheckable(true);
|
||||||
m_toggleEditorVisible->setChecked(showEditor);
|
m_toggleEditorVisible->setChecked(showEditor);
|
||||||
m_textEditorWidget->setVisible(showEditor);
|
m_textEditorWidget->setVisible(showEditor);
|
||||||
|
|
||||||
auto button = new CommandButton(EMPHASIS_ACTION);
|
auto button = Command::createToolButtonWithShortcutToolTip(EMPHASIS_ACTION);
|
||||||
button->setText("i");
|
button->defaultAction()->setIconText("i");
|
||||||
button->setFont([button]{ auto f = button->font(); f.setItalic(true); return f; }());
|
button->setFont([button]{ auto f = button->font(); f.setItalic(true); return f; }());
|
||||||
connect(button, &QToolButton::clicked, this, &MarkdownEditor::triggerEmphasis);
|
connect(button, &QToolButton::clicked, this, &MarkdownEditor::triggerEmphasis);
|
||||||
m_markDownButtons.append(button);
|
m_markDownButtons.append(button);
|
||||||
button = new CommandButton(STRONG_ACTION);
|
button = Command::createToolButtonWithShortcutToolTip(STRONG_ACTION);
|
||||||
button->setText("b");
|
button->defaultAction()->setIconText("b");
|
||||||
button->setFont([button]{ auto f = button->font(); f.setBold(true); return f; }());
|
button->setFont([button]{ auto f = button->font(); f.setBold(true); return f; }());
|
||||||
connect(button, &QToolButton::clicked, this, &MarkdownEditor::triggerStrong);
|
connect(button, &QToolButton::clicked, this, &MarkdownEditor::triggerStrong);
|
||||||
m_markDownButtons.append(button);
|
m_markDownButtons.append(button);
|
||||||
button = new CommandButton(INLINECODE_ACTION);
|
button = Command::createToolButtonWithShortcutToolTip(INLINECODE_ACTION);
|
||||||
button->setText("`");
|
button->defaultAction()->setIconText("`");
|
||||||
connect(button, &QToolButton::clicked, this, &MarkdownEditor::triggerInlineCode);
|
connect(button, &QToolButton::clicked, this, &MarkdownEditor::triggerInlineCode);
|
||||||
m_markDownButtons.append(button);
|
m_markDownButtons.append(button);
|
||||||
button = new CommandButton(LINK_ACTION);
|
button = Command::createToolButtonWithShortcutToolTip(LINK_ACTION);
|
||||||
button->setIcon(Utils::Icons::LINK_TOOLBAR.icon());
|
button->setIcon(Utils::Icons::LINK_TOOLBAR.icon());
|
||||||
connect(button, &QToolButton::clicked, this, &MarkdownEditor::triggerLink);
|
connect(button, &QToolButton::clicked, this, &MarkdownEditor::triggerLink);
|
||||||
m_markDownButtons.append(button);
|
m_markDownButtons.append(button);
|
||||||
@@ -173,8 +170,7 @@ public:
|
|||||||
for (auto button : m_markDownButtons | Utils::views::reverse)
|
for (auto button : m_markDownButtons | Utils::views::reverse)
|
||||||
m_textEditorWidget->insertExtraToolBarWidget(TextEditorWidget::Left, button);
|
m_textEditorWidget->insertExtraToolBarWidget(TextEditorWidget::Left, button);
|
||||||
|
|
||||||
m_swapViews = new CommandButton(SWAPVIEWS_ACTION);
|
m_swapViews = Command::createToolButtonWithShortcutToolTip(SWAPVIEWS_ACTION);
|
||||||
m_swapViews->setText(m_swapViews->toolTipBase());
|
|
||||||
m_swapViews->setEnabled(showEditor && showPreview);
|
m_swapViews->setEnabled(showEditor && showPreview);
|
||||||
|
|
||||||
m_swapViewsAction = m_textEditorWidget->insertExtraToolBarWidget(TextEditorWidget::Right, m_swapViews);
|
m_swapViewsAction = m_textEditorWidget->insertExtraToolBarWidget(TextEditorWidget::Right, m_swapViews);
|
||||||
@@ -486,9 +482,9 @@ private:
|
|||||||
TextEditorWidget *m_textEditorWidget;
|
TextEditorWidget *m_textEditorWidget;
|
||||||
TextDocumentPtr m_document;
|
TextDocumentPtr m_document;
|
||||||
QList<QToolButton *> m_markDownButtons;
|
QList<QToolButton *> m_markDownButtons;
|
||||||
CommandButton *m_toggleEditorVisible;
|
QToolButton *m_toggleEditorVisible;
|
||||||
CommandButton *m_togglePreviewVisible;
|
QToolButton *m_togglePreviewVisible;
|
||||||
CommandButton *m_swapViews;
|
QToolButton *m_swapViews;
|
||||||
QAction *m_toggleEditorVisibleAction;
|
QAction *m_toggleEditorVisibleAction;
|
||||||
QAction *m_togglePreviewVisibleAction;
|
QAction *m_togglePreviewVisibleAction;
|
||||||
QAction *m_swapViewsAction;
|
QAction *m_swapViewsAction;
|
||||||
|
|||||||
Reference in New Issue
Block a user