Commit 38a13f09 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

EmacsKeys: Use Qt5-style connects

The heavy lifting was done by clazy.

Change-Id: Ib5fda624ef6d776fd238e15b562c9fc0dd6cab58
Reviewed-by: default avatarhjk <hjk@theqtcompany.com>
parent a9f73d07
......@@ -46,12 +46,13 @@
#include <QtPlugin>
QT_BEGIN_NAMESPACE
extern void qt_set_sequence_auto_mnemonic(bool enable);
QT_END_NAMESPACE
using namespace EmacsKeys::Internal;
using namespace Core;
namespace EmacsKeys {
namespace Internal {
//---------------------------------------------------------------------------
// EmacsKeysPlugin
......@@ -76,60 +77,56 @@ bool EmacsKeysPlugin::initialize(const QStringList &arguments, QString *errorStr
// Alt+W (Window).
qt_set_sequence_auto_mnemonic(false);
connect(Core::EditorManager::instance(),
SIGNAL(editorAboutToClose(Core::IEditor*)),
this,
SLOT(editorAboutToClose(Core::IEditor*)));
connect(Core::EditorManager::instance(),
SIGNAL(currentEditorChanged(Core::IEditor*)),
this,
SLOT(currentEditorChanged(Core::IEditor*)));
connect(EditorManager::instance(), &EditorManager::editorAboutToClose,
this, &EmacsKeysPlugin::editorAboutToClose);
connect(EditorManager::instance(), &EditorManager::currentEditorChanged,
this, &EmacsKeysPlugin::currentEditorChanged);
registerAction(Constants::DELETE_CHARACTER,
SLOT(deleteCharacter()), tr("Delete Character"));
&EmacsKeysPlugin::deleteCharacter, tr("Delete Character"));
registerAction(Constants::KILL_WORD,
SLOT(killWord()), tr("Kill Word"));
&EmacsKeysPlugin::killWord, tr("Kill Word"));
registerAction(Constants::KILL_LINE,
SLOT(killLine()), tr("Kill Line"));
&EmacsKeysPlugin::killLine, tr("Kill Line"));
registerAction(Constants::INSERT_LINE_AND_INDENT,
SLOT(insertLineAndIndent()), tr("Insert New Line and Indent"));
&EmacsKeysPlugin::insertLineAndIndent, tr("Insert New Line and Indent"));
registerAction(Constants::GOTO_FILE_START,
SLOT(gotoFileStart()), tr("Go to File Start"));
&EmacsKeysPlugin::gotoFileStart, tr("Go to File Start"));
registerAction(Constants::GOTO_FILE_END,
SLOT(gotoFileEnd()), tr("Go to File End"));
&EmacsKeysPlugin::gotoFileEnd, tr("Go to File End"));
registerAction(Constants::GOTO_LINE_START,
SLOT(gotoLineStart()), tr("Go to Line Start"));
&EmacsKeysPlugin::gotoLineStart, tr("Go to Line Start"));
registerAction(Constants::GOTO_LINE_END,
SLOT(gotoLineEnd()), tr("Go to Line End"));
&EmacsKeysPlugin::gotoLineEnd, tr("Go to Line End"));
registerAction(Constants::GOTO_NEXT_LINE,
SLOT(gotoNextLine()), tr("Go to Next Line"));
&EmacsKeysPlugin::gotoNextLine, tr("Go to Next Line"));
registerAction(Constants::GOTO_PREVIOUS_LINE,
SLOT(gotoPreviousLine()), tr("Go to Previous Line"));
&EmacsKeysPlugin::gotoPreviousLine, tr("Go to Previous Line"));
registerAction(Constants::GOTO_NEXT_CHARACTER,
SLOT(gotoNextCharacter()), tr("Go to Next Character"));
&EmacsKeysPlugin::gotoNextCharacter, tr("Go to Next Character"));
registerAction(Constants::GOTO_PREVIOUS_CHARACTER,
SLOT(gotoPreviousCharacter()), tr("Go to Previous Character"));
&EmacsKeysPlugin::gotoPreviousCharacter, tr("Go to Previous Character"));
registerAction(Constants::GOTO_NEXT_WORD,
SLOT(gotoNextWord()), tr("Go to Next Word"));
&EmacsKeysPlugin::gotoNextWord, tr("Go to Next Word"));
registerAction(Constants::GOTO_PREVIOUS_WORD,
SLOT(gotoPreviousWord()), tr("Go to Previous Word"));
&EmacsKeysPlugin::gotoPreviousWord, tr("Go to Previous Word"));
registerAction(Constants::MARK,
SLOT(mark()), tr("Mark"));
&EmacsKeysPlugin::mark, tr("Mark"));
registerAction(Constants::EXCHANGE_CURSOR_AND_MARK,
SLOT(exchangeCursorAndMark()), tr("Exchange Cursor and Mark"));
&EmacsKeysPlugin::exchangeCursorAndMark, tr("Exchange Cursor and Mark"));
registerAction(Constants::COPY,
SLOT(copy()), tr("Copy"));
&EmacsKeysPlugin::copy, tr("Copy"));
registerAction(Constants::CUT,
SLOT(cut()), tr("Cut"));
&EmacsKeysPlugin::cut, tr("Cut"));
registerAction(Constants::YANK,
SLOT(yank()), tr("Yank"));
&EmacsKeysPlugin::yank, tr("Yank"));
registerAction(Constants::SCROLL_HALF_DOWN,
SLOT(scrollHalfDown()), tr("Scroll Half Screen Down"));
&EmacsKeysPlugin::scrollHalfDown, tr("Scroll Half Screen Down"));
registerAction(Constants::SCROLL_HALF_UP,
SLOT(scrollHalfUp()), tr("Scroll Half Screen Up"));
&EmacsKeysPlugin::scrollHalfUp, tr("Scroll Half Screen Up"));
return true;
}
......@@ -142,7 +139,7 @@ ExtensionSystem::IPlugin::ShutdownFlag EmacsKeysPlugin::aboutToShutdown()
return SynchronousShutdown;
}
void EmacsKeysPlugin::editorAboutToClose(Core::IEditor *editor)
void EmacsKeysPlugin::editorAboutToClose(IEditor *editor)
{
QPlainTextEdit *w = qobject_cast<QPlainTextEdit*>(editor->widget());
if (!w)
......@@ -154,7 +151,7 @@ void EmacsKeysPlugin::editorAboutToClose(Core::IEditor *editor)
}
}
void EmacsKeysPlugin::currentEditorChanged(Core::IEditor *editor)
void EmacsKeysPlugin::currentEditorChanged(IEditor *editor)
{
if (!editor) {
m_currentEditorWidget = 0;
......@@ -324,14 +321,12 @@ void EmacsKeysPlugin::insertLineAndIndent()
m_currentState->endOwnAction(KeysActionOther);
}
QAction *EmacsKeysPlugin::registerAction(Core::Id id, const char *slot,
const QString &title)
QAction *EmacsKeysPlugin::registerAction(Id id, void (EmacsKeysPlugin::*callback)(),
const QString &title)
{
QAction *result = new QAction(title, this);
Core::ActionManager::registerAction(result, id,
Core::Context(Core::Constants::C_GLOBAL), true);
connect(result, SIGNAL(triggered(bool)), this, slot);
ActionManager::registerAction(result, id, Context(Core::Constants::C_GLOBAL), true);
connect(result, &QAction::triggered, this, callback);
return result;
}
......@@ -382,3 +377,6 @@ void EmacsKeysPlugin::genericVScroll(int direction)
m_currentEditorWidget->setTextCursor(cursor);
m_currentState->endOwnAction(KeysActionOther);
}
} // namespace Internal
} // namespace EmacsKeys
......@@ -58,7 +58,7 @@ public:
void extensionsInitialized();
ShutdownFlag aboutToShutdown();
private slots:
private:
void editorAboutToClose(Core::IEditor *editor);
void currentEditorChanged(Core::IEditor *editor);
......@@ -87,9 +87,8 @@ private slots:
void scrollHalfDown(); // C-v
void scrollHalfUp(); // M-v
private:
QAction *registerAction(Core::Id id, const char *slot,
const QString &title);
QAction *registerAction(Core::Id id, void (EmacsKeysPlugin::*callback)(),
const QString &title);
void genericGoto(QTextCursor::MoveOperation op, bool abortAssist = true);
void genericVScroll(int direction);
......
......@@ -27,7 +27,8 @@
#include <QTextCursor>
#include <QPlainTextEdit>
using namespace EmacsKeys::Internal;
namespace EmacsKeys {
namespace Internal {
//---------------------------------------------------------------------------
// EmacsKeysState
......@@ -39,12 +40,12 @@ EmacsKeysState::EmacsKeysState(QPlainTextEdit *edit):
m_lastAction(KeysAction3rdParty),
m_editorWidget(edit)
{
connect(edit, SIGNAL(cursorPositionChanged()),
this, SLOT(cursorPositionChanged()));
connect(edit, SIGNAL(textChanged()),
this, SLOT(textChanged()));
connect(edit, SIGNAL(selectionChanged()),
this, SLOT(selectionChanged()));
connect(edit, &QPlainTextEdit::cursorPositionChanged,
this, &EmacsKeysState::cursorPositionChanged);
connect(edit, &QPlainTextEdit::textChanged,
this, &EmacsKeysState::textChanged);
connect(edit, &QPlainTextEdit::selectionChanged,
this, &EmacsKeysState::selectionChanged);
}
EmacsKeysState::~EmacsKeysState() {}
......@@ -79,3 +80,6 @@ void EmacsKeysState::selectionChanged()
if (!m_ignore3rdParty)
setLastAction(KeysAction3rdParty);
}
} // namespace Internal
} // namespace EmacsKeys
......@@ -40,8 +40,6 @@ enum EmacsKeysAction {
class EmacsKeysState : public QObject
{
Q_OBJECT
public:
EmacsKeysState(QPlainTextEdit *edit);
~EmacsKeysState();
......@@ -56,12 +54,11 @@ public:
int mark() const { return m_mark; }
void setMark(int mark) { m_mark = mark; }
private slots:
private:
void cursorPositionChanged();
void textChanged();
void selectionChanged();
private:
bool m_ignore3rdParty;
int m_mark;
EmacsKeysAction m_lastAction;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment