forked from qt-creator/qt-creator
TextEditorActionHandler: Reduce noise
By using namespace Core Change-Id: I97f4f6c42d5e0e9487b174b6837dc4cbb3452f2b Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -29,6 +29,8 @@
|
||||
|
||||
#include <functional>
|
||||
|
||||
using namespace Core;
|
||||
|
||||
namespace TextEditor {
|
||||
namespace Internal {
|
||||
|
||||
@@ -37,13 +39,17 @@ class TextEditorActionHandlerPrivate : public QObject
|
||||
public:
|
||||
TextEditorActionHandlerPrivate(Utils::Id editorId, Utils::Id contextId, uint optionalActions);
|
||||
|
||||
QAction *registerActionHelper(Utils::Id id, bool scriptable, const QString &title,
|
||||
const QKeySequence &keySequence, Utils::Id menueGroup,
|
||||
Core::ActionContainer *container,
|
||||
QAction *registerActionHelper(Utils::Id id,
|
||||
bool scriptable,
|
||||
const QString &title,
|
||||
const QKeySequence &keySequence,
|
||||
Utils::Id menueGroup,
|
||||
ActionContainer *container,
|
||||
std::function<void(bool)> slot)
|
||||
{
|
||||
auto result = new QAction(title, this);
|
||||
Core::Command *command = Core::ActionManager::registerAction(result, id, Core::Context(m_contextId), scriptable);
|
||||
Command *command
|
||||
= ActionManager::registerAction(result, id, Context(m_contextId), scriptable);
|
||||
if (!keySequence.isEmpty())
|
||||
command->setDefaultKeySequence(keySequence);
|
||||
|
||||
@@ -60,7 +66,7 @@ public:
|
||||
const QString &title = QString(),
|
||||
const QKeySequence &keySequence = QKeySequence(),
|
||||
Utils::Id menueGroup = Utils::Id(),
|
||||
Core::ActionContainer *container = nullptr)
|
||||
ActionContainer *container = nullptr)
|
||||
{
|
||||
return registerActionHelper(id,
|
||||
scriptable,
|
||||
@@ -82,7 +88,7 @@ public:
|
||||
const QString &title = QString(),
|
||||
const QKeySequence &keySequence = QKeySequence(),
|
||||
Utils::Id menueGroup = Utils::Id(),
|
||||
Core::ActionContainer *container = nullptr)
|
||||
ActionContainer *container = nullptr)
|
||||
{
|
||||
return registerActionHelper(id, scriptable, title, keySequence, menueGroup, container,
|
||||
[this, slot](bool on) { if (m_currentEditorWidget) slot(m_currentEditorWidget, on); });
|
||||
@@ -94,7 +100,7 @@ public:
|
||||
const QString &title = QString(),
|
||||
const QKeySequence &keySequence = QKeySequence(),
|
||||
Utils::Id menueGroup = Utils::Id(),
|
||||
Core::ActionContainer *container = nullptr)
|
||||
ActionContainer *container = nullptr)
|
||||
{
|
||||
return registerActionHelper(id, scriptable, title, keySequence, menueGroup, container,
|
||||
[this, slot](bool on) { if (m_currentEditorWidget) slot(m_currentEditorWidget, on); });
|
||||
@@ -108,7 +114,7 @@ public:
|
||||
void updateUndoAction(bool on);
|
||||
void updateCopyAction(bool on);
|
||||
|
||||
void updateCurrentEditor(Core::IEditor *editor);
|
||||
void updateCurrentEditor(IEditor *editor);
|
||||
|
||||
void setCanUndoCallback(const TextEditorActionHandler::Predicate &callback);
|
||||
void setCanRedoCallback(const TextEditorActionHandler::Predicate &callback);
|
||||
@@ -139,7 +145,7 @@ public:
|
||||
|
||||
uint m_optionalActions = TextEditorActionHandler::None;
|
||||
QPointer<TextEditorWidget> m_currentEditorWidget;
|
||||
QPointer<Core::IEditor> m_currentEditor;
|
||||
QPointer<IEditor> m_currentEditor;
|
||||
Utils::Id m_editorId;
|
||||
Utils::Id m_contextId;
|
||||
|
||||
@@ -156,8 +162,10 @@ TextEditorActionHandlerPrivate::TextEditorActionHandlerPrivate
|
||||
, m_contextId(contextId)
|
||||
{
|
||||
createActions();
|
||||
connect(Core::EditorManager::instance(), &Core::EditorManager::currentEditorChanged,
|
||||
this, &TextEditorActionHandlerPrivate::updateCurrentEditor);
|
||||
connect(EditorManager::instance(),
|
||||
&EditorManager::currentEditorChanged,
|
||||
this,
|
||||
&TextEditorActionHandlerPrivate::updateCurrentEditor);
|
||||
connect(TextEditorSettings::instance(), &TextEditorSettings::fontSettingsChanged,
|
||||
this, &TextEditorActionHandlerPrivate::updateActions);
|
||||
}
|
||||
@@ -179,11 +187,12 @@ void TextEditorActionHandlerPrivate::createActions()
|
||||
[] (TextEditorWidget *w) { w->paste(); }, true);
|
||||
registerAction(SELECTALL,
|
||||
[] (TextEditorWidget *w) { w->selectAll(); }, true);
|
||||
registerAction(GOTO, [] (TextEditorWidget *) {
|
||||
Core::LocatorManager::showFilter(TextEditorPlugin::lineNumberFilter());
|
||||
registerAction(GOTO, [](TextEditorWidget *) {
|
||||
LocatorManager::showFilter(TextEditorPlugin::lineNumberFilter());
|
||||
});
|
||||
m_modifyingActions << registerAction(PRINT, [](TextEditorWidget *widget) {
|
||||
widget->print(ICore::printer());
|
||||
});
|
||||
m_modifyingActions << registerAction(PRINT,
|
||||
[] (TextEditorWidget *widget) { widget->print(Core::ICore::printer()); });
|
||||
m_modifyingActions << registerAction(DELETE_LINE,
|
||||
[] (TextEditorWidget *w) { w->deleteLine(); }, true, Tr::tr("Delete &Line"));
|
||||
m_modifyingActions << registerAction(DELETE_END_OF_LINE,
|
||||
@@ -192,8 +201,11 @@ void TextEditorActionHandlerPrivate::createActions()
|
||||
[] (TextEditorWidget *w) { w->deleteEndOfWord(); }, true, Tr::tr("Delete Word from Cursor On"));
|
||||
m_modifyingActions << registerAction(DELETE_END_OF_WORD_CAMEL_CASE,
|
||||
[] (TextEditorWidget *w) { w->deleteEndOfWordCamelCase(); }, true, Tr::tr("Delete Word Camel Case from Cursor On"));
|
||||
m_modifyingActions << registerAction(DELETE_START_OF_LINE,
|
||||
[] (TextEditorWidget *w) { w->deleteStartOfLine(); }, true, Tr::tr("Delete Line up to Cursor"),
|
||||
m_modifyingActions << registerAction(
|
||||
DELETE_START_OF_LINE,
|
||||
[](TextEditorWidget *w) { w->deleteStartOfLine(); },
|
||||
true,
|
||||
Tr::tr("Delete Line up to Cursor"),
|
||||
Core::useMacShortcuts ? QKeySequence(Tr::tr("Ctrl+Backspace")) : QKeySequence());
|
||||
m_modifyingActions << registerAction(DELETE_START_OF_WORD,
|
||||
[] (TextEditorWidget *w) { w->deleteStartOfWord(); }, true, Tr::tr("Delete Word up to Cursor"));
|
||||
@@ -273,7 +285,7 @@ void TextEditorActionHandlerPrivate::createActions()
|
||||
QKeySequence(Tr::tr("Ctrl+Down")));
|
||||
|
||||
// register "Edit" Menu Actions
|
||||
Core::ActionContainer *editMenu = Core::ActionManager::actionContainer(M_EDIT);
|
||||
ActionContainer *editMenu = ActionManager::actionContainer(M_EDIT);
|
||||
registerAction(SELECT_ENCODING,
|
||||
[] (TextEditorWidget *w) { w->selectEncoding(); }, false, Tr::tr("Select Encoding..."),
|
||||
QKeySequence(), G_EDIT_OTHER, editMenu);
|
||||
@@ -285,7 +297,7 @@ void TextEditorActionHandlerPrivate::createActions()
|
||||
QKeySequence(Core::useMacShortcuts ? Tr::tr("Ctrl+Alt+Shift+V") : QString()), G_EDIT_COPYPASTE, editMenu);
|
||||
|
||||
// register "Edit -> Advanced" Menu Actions
|
||||
Core::ActionContainer *advancedEditMenu = Core::ActionManager::actionContainer(M_EDIT_ADVANCED);
|
||||
ActionContainer *advancedEditMenu = ActionManager::actionContainer(M_EDIT_ADVANCED);
|
||||
m_autoIndentAction = registerAction(AUTO_INDENT_SELECTION,
|
||||
[] (TextEditorWidget *w) { w->autoIndent(); }, true, Tr::tr("Auto-&indent Selection"),
|
||||
QKeySequence(Tr::tr("Ctrl+I")),
|
||||
@@ -567,7 +579,7 @@ void TextEditorActionHandlerPrivate::updateCopyAction(bool hasCopyableText)
|
||||
m_copyHtmlAction->setEnabled(hasCopyableText);
|
||||
}
|
||||
|
||||
void TextEditorActionHandlerPrivate::updateCurrentEditor(Core::IEditor *editor)
|
||||
void TextEditorActionHandlerPrivate::updateCurrentEditor(IEditor *editor)
|
||||
{
|
||||
if (m_currentEditorWidget)
|
||||
m_currentEditorWidget->disconnect(this);
|
||||
@@ -619,7 +631,7 @@ TextEditorActionHandler::~TextEditorActionHandler()
|
||||
|
||||
void TextEditorActionHandler::updateCurrentEditor()
|
||||
{
|
||||
d->updateCurrentEditor(Core::EditorManager::currentEditor());
|
||||
d->updateCurrentEditor(EditorManager::currentEditor());
|
||||
}
|
||||
|
||||
void TextEditorActionHandler::updateActions()
|
||||
|
Reference in New Issue
Block a user