diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 9233f2adf7263d389fa348d2789ba677bb21dc65..12885a14bb9a40b2b35f2bfc732d03074aa786c9 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -1063,6 +1063,16 @@ void BaseTextEditorWidget::lowercaseSelection() transformSelection(&QString::toLower); } +void BaseTextEditorWidget::indent() +{ + indentOrUnindent(true); +} + +void BaseTextEditorWidget::unindent() +{ + indentOrUnindent(false); +} + void BaseTextEditorWidget::moveLineUpDown(bool up) { QTextCursor cursor = textCursor(); diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h index 4a39f9c62648ebe53473bd4a9ccd698ae513bbe2..708d82c867f0e33768dff328742b2c8c8f87998d 100644 --- a/src/plugins/texteditor/basetexteditor.h +++ b/src/plugins/texteditor/basetexteditor.h @@ -322,6 +322,9 @@ public slots: void cleanWhitespace(); + void indent(); + void unindent(); + signals: void changed(); diff --git a/src/plugins/texteditor/texteditoractionhandler.cpp b/src/plugins/texteditor/texteditoractionhandler.cpp index 3685d5e75fd267f2c01bafa41325aa210a0e945f..17d180c2c08eaaab1f9b8a45021d2e0cec7c76af 100644 --- a/src/plugins/texteditor/texteditoractionhandler.cpp +++ b/src/plugins/texteditor/texteditoractionhandler.cpp @@ -102,6 +102,8 @@ TextEditorActionHandler::TextEditorActionHandler(const char *context, m_insertLineBelowAction(0), m_upperCaseSelectionAction(0), m_lowerCaseSelectionAction(0), + m_indentAction(0), + m_unindentAction(0), m_optionalActions(optionalActions), m_currentEditor(0), m_contextId(context), @@ -377,6 +379,16 @@ void TextEditorActionHandler::createActions() connect(m_circularPasteAction, SIGNAL(triggered()), this, SLOT(circularPasteAction())); medit->addAction(command, Core::Constants::G_EDIT_COPYPASTE); + m_indentAction = new QAction(tr("Indent"), this); + m_modifyingActions << m_indentAction; + command = am->registerAction(m_indentAction, Constants::INDENT, m_contextId, true); + connect(m_indentAction, SIGNAL(triggered()), this, SLOT(indent())); + + m_unindentAction = new QAction(tr("Unindent"), this); + m_modifyingActions << m_unindentAction; + command = am->registerAction(m_unindentAction, Constants::UNINDENT, m_contextId, true); + connect(m_unindentAction, SIGNAL(triggered()), this, SLOT(unindent())); + QAction *a = 0; a = new QAction(tr("Go to Line Start"), this); command = am->registerAction(a, Constants::GOTO_LINE_START, m_contextId, true); @@ -611,6 +623,8 @@ FUNCTION(uppercaseSelection) FUNCTION(lowercaseSelection) FUNCTION(insertLineAbove) FUNCTION(insertLineBelow) +FUNCTION(indent) +FUNCTION(unindent) FUNCTION(gotoLineStart) FUNCTION(gotoLineStartWithSelection) diff --git a/src/plugins/texteditor/texteditoractionhandler.h b/src/plugins/texteditor/texteditoractionhandler.h index f24e4ec845cbdee476cbeb98ecdfedb5154ff64e..70ff79237afb9278d4a986df8c6ded1d4ad7f440 100644 --- a/src/plugins/texteditor/texteditoractionhandler.h +++ b/src/plugins/texteditor/texteditoractionhandler.h @@ -138,6 +138,8 @@ private slots: void uppercaseSelection(); void lowercaseSelection(); void updateCurrentEditor(Core::IEditor *editor); + void indent(); + void unindent(); void gotoLineStart(); void gotoLineStartWithSelection(); @@ -206,6 +208,8 @@ private: QAction *m_insertLineBelowAction; QAction *m_upperCaseSelectionAction; QAction *m_lowerCaseSelectionAction; + QAction *m_indentAction; + QAction *m_unindentAction; QList<QAction *> m_modifyingActions; uint m_optionalActions; diff --git a/src/plugins/texteditor/texteditorconstants.h b/src/plugins/texteditor/texteditorconstants.h index 513a9604837ed319f8aa5b644020b88197e596b6..0f26a6f7830211de6dda4c0fa6ad2e4ee0d91dc1 100644 --- a/src/plugins/texteditor/texteditorconstants.h +++ b/src/plugins/texteditor/texteditorconstants.h @@ -102,6 +102,8 @@ const char TASK_DOWNLOAD_DEFINITIONS[] = "TextEditor.Task.Download"; const char TASK_REGISTER_DEFINITIONS[] = "TextEditor.Task.Register"; const char TASK_OPEN_FILE[] = "TextEditor.Task.OpenFile"; const char CIRCULAR_PASTE[] = "TextEditor.CircularPaste"; +const char INDENT[] = "TextEditor.Indent"; +const char UNINDENT[] = "TextEditor.Unindent"; // Text color and style categories const char C_TEXT[] = "Text";