Mention by name with Ctrl+click and Ctrl+Enter
This commit is contained in:
parent
7da62db8c3
commit
8b1a42bbb1
3 changed files with 20 additions and 3 deletions
|
|
@ -576,6 +576,10 @@ bool FieldAutocomplete::eventFilter(QObject *obj, QEvent *e) {
|
||||||
emit moderateKeyActivate(ev->key(), &handled);
|
emit moderateKeyActivate(ev->key(), &handled);
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
} else if (ev->modifiers() & Qt::ControlModifier) {
|
||||||
|
if (ev->key() == Qt::Key_Enter || ev->key() == Qt::Key_Return) {
|
||||||
|
return _inner->chooseSelected(ChooseMethod::ByCtrlEnter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return QWidget::eventFilter(obj, e);
|
return QWidget::eventFilter(obj, e);
|
||||||
|
|
@ -913,7 +917,11 @@ void FieldAutocompleteInner::mousePressEvent(QMouseEvent *e) {
|
||||||
selectByMouse(e->globalPos());
|
selectByMouse(e->globalPos());
|
||||||
} else if (_srows->empty()) {
|
} else if (_srows->empty()) {
|
||||||
if (e->button() == Qt::LeftButton) {
|
if (e->button() == Qt::LeftButton) {
|
||||||
chooseSelected(FieldAutocomplete::ChooseMethod::ByClick);
|
if (e->modifiers() & Qt::ControlModifier) {
|
||||||
|
chooseSelected(FieldAutocomplete::ChooseMethod::ByCtrlClick);
|
||||||
|
} else {
|
||||||
|
chooseSelected(FieldAutocomplete::ChooseMethod::ByClick);
|
||||||
|
}
|
||||||
} else if (e->button() == Qt::RightButton) {
|
} else if (e->button() == Qt::RightButton) {
|
||||||
chooseSelected(FieldAutocomplete::ChooseMethod::ByRightClick);
|
chooseSelected(FieldAutocomplete::ChooseMethod::ByRightClick);
|
||||||
}
|
}
|
||||||
|
|
@ -940,7 +948,11 @@ void FieldAutocompleteInner::mouseReleaseEvent(QMouseEvent *e) {
|
||||||
if (_sel < 0 || _sel != pressed || _srows->empty()) return;
|
if (_sel < 0 || _sel != pressed || _srows->empty()) return;
|
||||||
|
|
||||||
if (e->button() == Qt::LeftButton) {
|
if (e->button() == Qt::LeftButton) {
|
||||||
chooseSelected(FieldAutocomplete::ChooseMethod::ByClick);
|
if (e->modifiers() & Qt::ControlModifier) {
|
||||||
|
chooseSelected(FieldAutocomplete::ChooseMethod::ByCtrlClick);
|
||||||
|
} else {
|
||||||
|
chooseSelected(FieldAutocomplete::ChooseMethod::ByClick);
|
||||||
|
}
|
||||||
} else if (e->button() == Qt::RightButton) {
|
} else if (e->button() == Qt::RightButton) {
|
||||||
chooseSelected(FieldAutocomplete::ChooseMethod::ByRightClick);
|
chooseSelected(FieldAutocomplete::ChooseMethod::ByRightClick);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,8 @@ public:
|
||||||
ByTab,
|
ByTab,
|
||||||
ByClick,
|
ByClick,
|
||||||
ByRightClick,
|
ByRightClick,
|
||||||
|
ByCtrlEnter,
|
||||||
|
ByCtrlClick,
|
||||||
};
|
};
|
||||||
bool chooseSelected(ChooseMethod method) const;
|
bool chooseSelected(ChooseMethod method) const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1013,7 +1013,10 @@ void HistoryWidget::start() {
|
||||||
|
|
||||||
void HistoryWidget::onMentionInsert(UserData *user, FieldAutocomplete::ChooseMethod method) {
|
void HistoryWidget::onMentionInsert(UserData *user, FieldAutocomplete::ChooseMethod method) {
|
||||||
QString replacement, entityTag;
|
QString replacement, entityTag;
|
||||||
if (method == FieldAutocomplete::ChooseMethod::ByRightClick || user->username.isEmpty()) {
|
if (user->username.isEmpty()
|
||||||
|
|| method == FieldAutocomplete::ChooseMethod::ByRightClick
|
||||||
|
|| method == FieldAutocomplete::ChooseMethod::ByCtrlEnter
|
||||||
|
|| method == FieldAutocomplete::ChooseMethod::ByCtrlClick) {
|
||||||
replacement = user->firstName;
|
replacement = user->firstName;
|
||||||
if (replacement.isEmpty()) {
|
if (replacement.isEmpty()) {
|
||||||
replacement = user->name;
|
replacement = user->name;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue