setEnableSpellCheck(s.value("EnableSpellCheck", false));
#endif
+ s.notify("EnableEmacsMode", this, SLOT(setEnableEmacsMode(QVariant)));
+ setEnableEmacsMode(s.value("EnableEmacsMode", false));
+
s.notify("ShowNickSelector", this, SLOT(setShowNickSelector(QVariant)));
setShowNickSelector(s.value("ShowNickSelector", true));
ui.inputEdit->setSpellCheckEnabled(v.toBool());
}
+void InputWidget::setEnableEmacsMode(const QVariant &v) {
+ ui.inputEdit->setEmacsMode(v.toBool());
+}
+
void InputWidget::setShowNickSelector(const QVariant &v) {
ui.ownNick->setVisible(v.toBool());
}
void setCustomFont(const QVariant &font);
void setUseCustomFont(const QVariant &);
void setEnableSpellCheck(const QVariant &);
+ void setEnableEmacsMode(const QVariant &);
void setShowNickSelector(const QVariant &);
void setShowStyleButtons(const QVariant &);
void setEnablePerChatHistory(const QVariant &);
</property>
</widget>
</item>
+ <item>
+ <widget class="QCheckBox" name="enableEmacsMode">
+ <property name="toolTip">
+ <string>Enables (limited) Emacs key bindings in the input field.</string>
+ </property>
+ <property name="text">
+ <string>Emacs key bindings</string>
+ </property>
+ <property name="settingsKey" stdset="0">
+ <string notr="true">EnableEmacsMode</string>
+ </property>
+ <property name="defaultValue" stdset="0">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
return sizeHint();
}
+void MultiLineEdit::setEmacsMode(bool enable) {
+ _emacsMode = enable;
+}
+
void MultiLineEdit::setSpellCheckEnabled(bool enable) {
#ifdef HAVE_KDE
setCheckSpellingEnabled(enable);
;
}
+ if(_emacsMode) {
+ if(event->modifiers() & Qt::ControlModifier) {
+ switch(event->key()) {
+ // move
+ case Qt::Key_A:
+ moveCursor(QTextCursor::StartOfLine);
+ return;
+ case Qt::Key_E:
+ moveCursor(QTextCursor::EndOfLine);
+ return;
+ case Qt::Key_F:
+ moveCursor(QTextCursor::Right);
+ return;
+ case Qt::Key_B:
+ moveCursor(QTextCursor::Left);
+ return;
+ case Qt::Key_Right:
+ moveCursor(QTextCursor::WordRight);
+ return;
+ case Qt::Key_Left:
+ moveCursor(QTextCursor::WordLeft);
+ return;
+
+ // modify
+ case Qt::Key_Y:
+ paste();
+ return;
+ case Qt::Key_K:
+ moveCursor(QTextCursor::EndOfLine, QTextCursor::KeepAnchor);
+ cut();
+ return;
+ }
+ }
+ else if(event->modifiers() & Qt::MetaModifier) {
+ switch(event->key()) {
+ case Qt::Key_Right:
+ moveCursor(QTextCursor::WordRight);
+ return;
+ case Qt::Key_Left:
+ moveCursor(QTextCursor::WordLeft);
+ return;
+ case Qt::Key_F:
+ moveCursor(QTextCursor::WordRight);
+ return;
+ case Qt::Key_B:
+ moveCursor(QTextCursor::WordLeft);
+ return;
+ case Qt::Key_Less:
+ moveCursor(QTextCursor::Start);
+ return;
+ case Qt::Key_Greater:
+ moveCursor(QTextCursor::End);
+ return;
+ }
+ }
+ }
#ifdef HAVE_KDE
KTextEdit::keyPressEvent(event);
inline QStringList history() const { return _history; }
inline QHash<int, QString> tempHistory() const { return _tempHistory; }
inline qint32 idx() const { return _idx; }
+ inline bool emacsMode() const { return _emacsMode; }
public slots:
void setMode(Mode mode);
void setMinHeight(int numLines);
void setMaxHeight(int numLines);
+ void setEmacsMode(bool enable = true);
void setScrollBarsEnabled(bool enable = true);
void setSpellCheckEnabled(bool enable = true);
void setPasteProtectionEnabled(bool enable = true, QWidget *msgBoxParent = 0);
int _maxHeight;
bool _scrollBarsEnabled;
bool _pasteProtectionEnabled;
+ bool _emacsMode;
QSize _sizeHint;
qreal _lastDocumentHeight;