Commit 714d56a3 authored by David Schulz's avatar David Schulz

Editor: Add actions for view page/line up/down.

Task-number: QTCREATORBUG-4994
Change-Id: Ia6ce1a01cd78dd1987404d77f6b0c0da41b4929e
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 40815028
......@@ -1487,6 +1487,26 @@ bool BaseTextEditorWidget::cursorMoveKeyEvent(QKeyEvent *e)
return true;
}
void BaseTextEditorWidget::viewPageUp()
{
verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepSub);
}
void BaseTextEditorWidget::viewPageDown()
{
verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepAdd);
}
void BaseTextEditorWidget::viewLineUp()
{
verticalScrollBar()->triggerAction(QAbstractSlider::SliderSingleStepSub);
}
void BaseTextEditorWidget::viewLineDown()
{
verticalScrollBar()->triggerAction(QAbstractSlider::SliderSingleStepAdd);
}
static inline bool isModifier(QKeyEvent *e)
{
if (!e)
......@@ -1729,14 +1749,6 @@ void BaseTextEditorWidget::keyPressEvent(QKeyEvent *e)
break;
case Qt::Key_Up:
case Qt::Key_Down:
if (e->modifiers() & Qt::ControlModifier) {
verticalScrollBar()->triggerAction(
e->key() == Qt::Key_Up ? QAbstractSlider::SliderSingleStepSub :
QAbstractSlider::SliderSingleStepAdd);
e->accept();
return;
}
// fall through
case Qt::Key_Right:
case Qt::Key_Left:
if (HostOsInfo::isMacHost())
......@@ -1765,16 +1777,6 @@ void BaseTextEditorWidget::keyPressEvent(QKeyEvent *e)
}
}
break;
case Qt::Key_PageUp:
case Qt::Key_PageDown:
if (e->modifiers() == Qt::ControlModifier) {
verticalScrollBar()->triggerAction(
e->key() == Qt::Key_PageUp ? QAbstractSlider::SliderPageStepSub :
QAbstractSlider::SliderPageStepAdd);
e->accept();
return;
}
break;
case Qt::Key_Insert:
if (ro) break;
if (e->modifiers() == Qt::NoModifier) {
......
......@@ -290,6 +290,11 @@ public slots:
void moveLineUp();
void moveLineDown();
void viewPageUp();
void viewPageDown();
void viewLineUp();
void viewLineDown();
void copyLineUp();
void copyLineDown();
......
......@@ -87,6 +87,10 @@ TextEditorActionHandler::TextEditorActionHandler(QObject *parent, Core::Id conte
m_gotoBlockEndWithSelectionAction(0),
m_selectBlockUpAction(0),
m_selectBlockDownAction(0),
m_viewPageUpAction(0),
m_viewPageDownAction(0),
m_viewLineUpAction(0),
m_viewLineDownAction(0),
m_moveLineUpAction(0),
m_moveLineDownAction(0),
m_copyLineUpAction(0),
......@@ -192,6 +196,19 @@ void TextEditorActionHandler::createActions()
SLOT(openLinkUnderCursorInNextSplit()), true,
QKeySequence(Utils::HostOsInfo::isMacHost() ? tr("Meta+E, F2") : tr("Ctrl+E, F2")));
m_viewPageUpAction = registerAction(VIEW_PAGE_UP,
SLOT(viewPageUp()), true, tr("Move the View a Page Up and Keep the Cursor Position"),
QKeySequence(tr("Ctrl+PgUp")));
m_viewPageDownAction = registerAction(VIEW_PAGE_DOWN,
SLOT(viewPageDown()), true, tr("Move the View a Page Down and Keep the Cursor Position"),
QKeySequence(tr("Ctrl+PgDown")));
m_viewLineUpAction = registerAction(VIEW_LINE_UP,
SLOT(viewLineUp()), true, tr("Move the View a Line Up and Keep the Cursor Position"),
QKeySequence(tr("Ctrl+Up")));
m_viewLineDownAction = registerAction(VIEW_LINE_DOWN,
SLOT(viewLineDown()), true, tr("Move the View a Line Down and Keep the Cursor Position"),
QKeySequence(tr("Ctrl+Down")));
// register "Edit" Menu Actions
Core::ActionContainer *editMenu = Core::ActionManager::actionContainer(M_EDIT);
m_selectEncodingAction = registerAction(SELECT_ENCODING,
......@@ -513,6 +530,10 @@ FUNCTION(indent)
FUNCTION(unindent)
FUNCTION(openLinkUnderCursor)
FUNCTION(openLinkUnderCursorInNextSplit)
FUNCTION(viewPageUp)
FUNCTION(viewPageDown)
FUNCTION(viewLineUp)
FUNCTION(viewLineDown)
FUNCTION(gotoLineStart)
FUNCTION(gotoLineStartWithSelection)
......
......@@ -124,6 +124,10 @@ private slots:
void gotoBlockEndWithSelection();
void selectBlockUp();
void selectBlockDown();
void viewPageUp();
void viewPageDown();
void viewLineUp();
void viewLineDown();
void moveLineUp();
void moveLineDown();
void copyLineUp();
......@@ -198,6 +202,10 @@ private:
QAction *m_gotoBlockEndWithSelectionAction;
QAction *m_selectBlockUpAction;
QAction *m_selectBlockDownAction;
QAction *m_viewPageUpAction;
QAction *m_viewPageDownAction;
QAction *m_viewLineUpAction;
QAction *m_viewLineDownAction;
QAction *m_moveLineUpAction;
QAction *m_moveLineDownAction;
QAction *m_copyLineUpAction;
......
......@@ -119,6 +119,10 @@ const char GOTO_BLOCK_END[] = "TextEditor.GotoBlockEnd";
const char GOTO_BLOCK_END_WITH_SELECTION[] = "TextEditor.GotoBlockEndWithSelection";
const char SELECT_BLOCK_UP[] = "TextEditor.SelectBlockUp";
const char SELECT_BLOCK_DOWN[] = "TextEditor.SelectBlockDown";
const char VIEW_PAGE_UP[] = "TextEditor.viewPageUp";
const char VIEW_PAGE_DOWN[] = "TextEditor.viewPageDown";
const char VIEW_LINE_UP[] = "TextEditor.viewLineUp";
const char VIEW_LINE_DOWN[] = "TextEditor.viewLineDown";
const char MOVE_LINE_UP[] = "TextEditor.MoveLineUp";
const char MOVE_LINE_DOWN[] = "TextEditor.MoveLineDown";
const char COPY_LINE_UP[] = "TextEditor.CopyLineUp";
......
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