merge SVN commit 633860 by adridg:

When the message is set to a composer with a specific cursor position,
(ie. not 0, eg. from a template containing %CURSOR) then don't reset the
cursor position when appending the signature. This makes it possible
to use %CURSOR to place the cursor anywhere in a template. Useful
for reply templates, at any rate.

svn path=/branches/KDE/3.5/kdepim/; revision=639750
wilder-work
Allen Winter 19 years ago
parent ad1d5c27ca
commit 12fa15af1f
  1. 18
      kmcomposewin.cpp
  2. 9
      kmcomposewin.h

@ -176,7 +176,8 @@ KMComposeWin::KMComposeWin( KMMessage *aMsg, uint id )
mEncryptWithChiasmus( false ),
mComposer( 0 ),
mLabelWidth( 0 ),
mAutoSaveTimer( 0 ), mLastAutoSaveErrno( 0 )
mAutoSaveTimer( 0 ), mLastAutoSaveErrno( 0 ),
mPreserveUserCursorPosition( false )
{
mClassicalRecipients = GlobalSettings::self()->recipientsEditorType() ==
GlobalSettings::EnumRecipientsEditorType::Classic;
@ -1973,6 +1974,12 @@ void KMComposeWin::setMsg(KMMessage* newMsg, bool mayAutoSign,
//
QTimer::singleShot( 200, this, SLOT(slotAppendSignature()) );
}
if ( mMsg->getCursorPos() > 0 ) {
// The message has a cursor position explicitly set, so avoid
// changing it when appending the signature.
mPreserveUserCursorPosition = true;
}
setModified( isModified );
// do this even for new messages
@ -4049,7 +4056,14 @@ void KMComposeWin::slotAppendSignature()
mEditor->append(mOldSigText);
mEditor->setModified(mod);
// mEditor->setContentsPos( 0, 0 );
mEditor->setCursorPositionFromStart( (unsigned int) mMsg->getCursorPos() );
if ( mPreserveUserCursorPosition ) {
mEditor->setCursorPositionFromStart( (unsigned int) mMsg->getCursorPos() );
// Only keep the cursor from the mMsg *once* based on the
// preserve-cursor-position setting; this handles the case where
// the message comes from a template with a specific cursor
// position set and the signature is appended automatically.
mPreserveUserCursorPosition = false;
}
mEditor->sync();
}
}

@ -838,6 +838,15 @@ private:
QPopupMenu *mActNowMenu;
QPopupMenu *mActLaterMenu;
/** If the message in this composer has a cursor position set (for
* instance because it comes from a template containing %CURSOR)
* then we need to preserve that cursor position even when auto-
* appending (or prepending) the signature during composer setup.
* Set to true *once* (and only in setMsg() at that) to avoid
* accidentally moving the cursor.
*/
bool mPreserveUserCursorPosition;
};
#endif

Loading…
Cancel
Save