summaryrefslogtreecommitdiff
path: root/src/plugins/emacskeys
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2016-06-04 22:49:38 +0300
committerOrgad Shaneh <orgads@gmail.com>2016-06-06 07:54:57 +0000
commit38a13f09c22c4b9c412687c26aaaee5e8580889f (patch)
tree9c3c885201f14ea51cfbbc4db2ada23ca7f70506 /src/plugins/emacskeys
parenta9f73d079a3874c4034e03555758aac4c4602cbb (diff)
downloadqt-creator-38a13f09c22c4b9c412687c26aaaee5e8580889f.tar.gz
EmacsKeys: Use Qt5-style connects
The heavy lifting was done by clazy. Change-Id: Ib5fda624ef6d776fd238e15b562c9fc0dd6cab58 Reviewed-by: hjk <hjk@theqtcompany.com>
Diffstat (limited to 'src/plugins/emacskeys')
-rw-r--r--src/plugins/emacskeys/emacskeysplugin.cpp78
-rw-r--r--src/plugins/emacskeys/emacskeysplugin.h7
-rw-r--r--src/plugins/emacskeys/emacskeysstate.cpp18
-rw-r--r--src/plugins/emacskeys/emacskeysstate.h5
4 files changed, 53 insertions, 55 deletions
diff --git a/src/plugins/emacskeys/emacskeysplugin.cpp b/src/plugins/emacskeys/emacskeysplugin.cpp
index 470da4f00c..de26f42166 100644
--- a/src/plugins/emacskeys/emacskeysplugin.cpp
+++ b/src/plugins/emacskeys/emacskeysplugin.cpp
@@ -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
diff --git a/src/plugins/emacskeys/emacskeysplugin.h b/src/plugins/emacskeys/emacskeysplugin.h
index ec95a6a39a..96561b75f9 100644
--- a/src/plugins/emacskeys/emacskeysplugin.h
+++ b/src/plugins/emacskeys/emacskeysplugin.h
@@ -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);
diff --git a/src/plugins/emacskeys/emacskeysstate.cpp b/src/plugins/emacskeys/emacskeysstate.cpp
index 2306369e4c..ab3257e71e 100644
--- a/src/plugins/emacskeys/emacskeysstate.cpp
+++ b/src/plugins/emacskeys/emacskeysstate.cpp
@@ -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
diff --git a/src/plugins/emacskeys/emacskeysstate.h b/src/plugins/emacskeys/emacskeysstate.h
index ff9f7a9b82..28dc74e1c7 100644
--- a/src/plugins/emacskeys/emacskeysstate.h
+++ b/src/plugins/emacskeys/emacskeysstate.h
@@ -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;