diff --git a/src/dialogs/editconfigwidget.ui b/src/dialogs/editconfigwidget.ui --- a/src/dialogs/editconfigwidget.ui +++ b/src/dialogs/editconfigwidget.ui @@ -6,12 +6,21 @@ 0 0 - 275 - 344 + 459 + 458 - + + 0 + + + 0 + + + 0 + + 0 @@ -159,6 +168,13 @@ + + + + Paste by mouse at cursor position + + + diff --git a/src/dialogs/katedialogs.cpp b/src/dialogs/katedialogs.cpp --- a/src/dialogs/katedialogs.cpp +++ b/src/dialogs/katedialogs.cpp @@ -463,6 +463,7 @@ connect(ui->sbWordWrap, SIGNAL(valueChanged(int)), this, SLOT(slotChanged())); connect(ui->chkAutoBrackets, SIGNAL(toggled(bool)), this, SLOT(slotChanged())); connect(ui->chkSmartCopyCut, SIGNAL(toggled(bool)), this, SLOT(slotChanged())); + connect(ui->chkMousePasteAtCursorPosition, SIGNAL(toggled(bool)), this, SLOT(slotChanged())); connect(ui->cmbInputMode, SIGNAL(currentIndexChanged(int)), this, SLOT(slotChanged())); // "What's this?" help is in the ui-file @@ -494,6 +495,7 @@ KateViewConfig::global()->setAutoBrackets(ui->chkAutoBrackets->isChecked()); KateViewConfig::global()->setSmartCopyCut(ui->chkSmartCopyCut->isChecked()); + KateViewConfig::global()->setMousePasteAtCursorPosition(ui->chkMousePasteAtCursorPosition->isChecked()); KateViewConfig::global()->setInputModeRaw(ui->cmbInputMode->currentData().toInt()); @@ -509,6 +511,7 @@ ui->sbWordWrap->setValue(KateDocumentConfig::global()->wordWrapAt()); ui->chkAutoBrackets->setChecked(KateViewConfig::global()->autoBrackets()); ui->chkSmartCopyCut->setChecked(KateViewConfig::global()->smartCopyCut()); + ui->chkMousePasteAtCursorPosition->setChecked(KateViewConfig::global()->mousePasteAtCursorPosition()); const int id = static_cast(KateViewConfig::global()->inputMode()); ui->cmbInputMode->setCurrentIndex(ui->cmbInputMode->findData(id)); diff --git a/src/utils/kateconfig.h b/src/utils/kateconfig.h --- a/src/utils/kateconfig.h +++ b/src/utils/kateconfig.h @@ -566,6 +566,9 @@ bool smartCopyCut() const; void setSmartCopyCut(bool on); + bool mousePasteAtCursorPosition() const; + void setMousePasteAtCursorPosition(bool on); + bool scrollPastEnd() const; void setScrollPastEnd(bool on); @@ -615,6 +618,7 @@ int m_wordCompletionMinimalWordLength; bool m_wordCompletionRemoveTail; bool m_smartCopyCut; + bool m_mousePasteAtCursorPosition = false; bool m_scrollPastEnd; bool m_foldFirstLine; bool m_showWordCount = false; @@ -650,6 +654,7 @@ bool m_keywordCompletionSet : 1; bool m_wordCompletionMinimalWordLengthSet : 1; bool m_smartCopyCutSet : 1; + bool m_mousePasteAtCursorPositionSet : 1; bool m_scrollPastEndSet : 1; bool m_allowMarkMenu : 1; bool m_wordCompletionRemoveTailSet : 1; diff --git a/src/utils/kateconfig.cpp b/src/utils/kateconfig.cpp --- a/src/utils/kateconfig.cpp +++ b/src/utils/kateconfig.cpp @@ -1256,6 +1256,7 @@ m_keywordCompletionSet(false), m_wordCompletionMinimalWordLengthSet(false), m_smartCopyCutSet(false), + m_mousePasteAtCursorPositionSet(false), m_scrollPastEndSet(false), m_allowMarkMenu(true), m_wordCompletionRemoveTailSet(false), @@ -1306,6 +1307,7 @@ m_keywordCompletionSet(false), m_wordCompletionMinimalWordLengthSet(false), m_smartCopyCutSet(false), + m_mousePasteAtCursorPositionSet(false), m_scrollPastEndSet(false), m_allowMarkMenu(true), m_wordCompletionRemoveTailSet(false), @@ -1355,6 +1357,7 @@ const char KEY_WORD_COMPLETION_MINIMAL_WORD_LENGTH[] = "Word Completion Minimal Word Length"; const char KEY_WORD_COMPLETION_REMOVE_TAIL[] = "Word Completion Remove Tail"; const char KEY_SMART_COPY_CUT[] = "Smart Copy Cut"; +const char KEY_MOUSE_PASTE_AT_CURSOR_POSITION[] = "Mouse Paste At Cursor Position"; const char KEY_SCROLL_PAST_END[] = "Scroll Past End"; const char KEY_FOLD_FIRST_LINE[] = "Fold First Line"; const char KEY_SHOW_LINE_COUNT[] = "Show Line Count"; @@ -1419,6 +1422,7 @@ setWordCompletionMinimalWordLength(config.readEntry(KEY_WORD_COMPLETION_MINIMAL_WORD_LENGTH, 3)); setWordCompletionRemoveTail(config.readEntry(KEY_WORD_COMPLETION_REMOVE_TAIL, true)); setSmartCopyCut(config.readEntry(KEY_SMART_COPY_CUT, false)); + setMousePasteAtCursorPosition(config.readEntry(KEY_MOUSE_PASTE_AT_CURSOR_POSITION, false)); setScrollPastEnd(config.readEntry(KEY_SCROLL_PAST_END, false)); setFoldFirstLine(config.readEntry(KEY_FOLD_FIRST_LINE, false)); setShowLineCount(config.readEntry(KEY_SHOW_LINE_COUNT, false)); @@ -1480,6 +1484,7 @@ config.writeEntry(KEY_WORD_COMPLETION_REMOVE_TAIL, wordCompletionRemoveTail()); config.writeEntry(KEY_SMART_COPY_CUT, smartCopyCut()); + config.writeEntry(KEY_MOUSE_PASTE_AT_CURSOR_POSITION, mousePasteAtCursorPosition()); config.writeEntry(KEY_SCROLL_PAST_END, scrollPastEnd()); config.writeEntry(KEY_FOLD_FIRST_LINE, foldFirstLine()); @@ -2211,6 +2216,29 @@ configEnd(); } +bool KateViewConfig::mousePasteAtCursorPosition() const +{ + if (m_mousePasteAtCursorPositionSet|| isGlobal()) { + return m_mousePasteAtCursorPosition; + } + + return s_global->mousePasteAtCursorPosition(); +} + +void KateViewConfig::setMousePasteAtCursorPosition(bool on) +{ + if (m_mousePasteAtCursorPositionSet && m_mousePasteAtCursorPosition == on) { + return; + } + + configStart(); + + m_mousePasteAtCursorPositionSet = true; + m_mousePasteAtCursorPosition = on; + + configEnd(); +} + bool KateViewConfig::scrollPastEnd() const { if (m_scrollPastEndSet || isGlobal()) { diff --git a/src/view/kateviewinternal.cpp b/src/view/kateviewinternal.cpp --- a/src/view/kateviewinternal.cpp +++ b/src/view/kateviewinternal.cpp @@ -2759,7 +2759,9 @@ break; case Qt::MidButton: - placeCursor(e->pos()); + if (!view()->config()->mousePasteAtCursorPosition()) { + placeCursor(e->pos()); + } if (doc()->isReadWrite()) { QString clipboard = QApplication::clipboard()->text(QClipboard::Selection);