mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 06:26:18 +00:00
Pass modifiers inside InputField submitted signal.
Also use non-MOC connections for all InputFields. Also use Ctrl/Cmd + Enter to submit fast share box. Fixes #4769.
This commit is contained in:
@@ -1010,7 +1010,7 @@ void FlatInput::keyPressEvent(QKeyEvent *e) {
|
||||
if (e->key() == Qt::Key_Escape) {
|
||||
emit cancelled();
|
||||
} else if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) {
|
||||
emit submitted(ctrl && shift);
|
||||
emit submitted(e->modifiers());
|
||||
#ifdef Q_OS_MAC
|
||||
} else if (e->key() == Qt::Key_E && e->modifiers().testFlag(Qt::ControlModifier)) {
|
||||
auto selected = selectedText();
|
||||
@@ -2249,7 +2249,7 @@ void InputField::keyPressEventInner(QKeyEvent *e) {
|
||||
&& revertFormatReplace()) {
|
||||
e->accept();
|
||||
} else if (enter && enterSubmit) {
|
||||
emit submitted(ctrl && shift);
|
||||
emit submitted(e->modifiers());
|
||||
} else if (e->key() == Qt::Key_Escape) {
|
||||
e->ignore();
|
||||
emit cancelled();
|
||||
@@ -3505,7 +3505,7 @@ void MaskedInputField::keyPressEvent(QKeyEvent *e) {
|
||||
e->ignore();
|
||||
emit cancelled();
|
||||
} else if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) {
|
||||
emit submitted(ctrl && shift);
|
||||
emit submitted(e->modifiers());
|
||||
#ifdef Q_OS_MAC
|
||||
} else if (e->key() == Qt::Key_E && e->modifiers().testFlag(Qt::ControlModifier)) {
|
||||
auto selected = selectedText();
|
||||
|
@@ -67,7 +67,7 @@ public slots:
|
||||
signals:
|
||||
void changed();
|
||||
void cancelled();
|
||||
void submitted(bool ctrlShiftEnter);
|
||||
void submitted(Qt::KeyboardModifiers);
|
||||
void focused();
|
||||
void blurred();
|
||||
|
||||
@@ -298,7 +298,7 @@ private slots:
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
void submitted(bool ctrlShiftEnter);
|
||||
void submitted(Qt::KeyboardModifiers);
|
||||
void cancelled();
|
||||
void tabbed();
|
||||
void focused();
|
||||
@@ -518,7 +518,7 @@ public slots:
|
||||
signals:
|
||||
void changed();
|
||||
void cancelled();
|
||||
void submitted(bool ctrlShiftEnter);
|
||||
void submitted(Qt::KeyboardModifiers);
|
||||
void focused();
|
||||
void blurred();
|
||||
|
||||
|
@@ -289,7 +289,7 @@ void MultiSelect::setQueryChangedCallback(base::lambda<void(const QString &query
|
||||
_queryChangedCallback = std::move(callback);
|
||||
}
|
||||
|
||||
void MultiSelect::setSubmittedCallback(base::lambda<void(bool ctrlShiftEnter)> callback) {
|
||||
void MultiSelect::setSubmittedCallback(base::lambda<void(Qt::KeyboardModifiers)> callback) {
|
||||
_inner->setSubmittedCallback(std::move(callback));
|
||||
}
|
||||
|
||||
@@ -359,17 +359,17 @@ MultiSelect::Inner::Inner(QWidget *parent, const style::MultiSelect &st, base::l
|
||||
, _field(this, _st.field, std::move(placeholder))
|
||||
, _cancel(this, _st.fieldCancel) {
|
||||
_field->customUpDown(true);
|
||||
connect(_field, SIGNAL(focused()), this, SLOT(onFieldFocused()));
|
||||
connect(_field, SIGNAL(changed()), this, SLOT(onQueryChanged()));
|
||||
connect(_field, SIGNAL(submitted(bool)), this, SLOT(onSubmitted(bool)));
|
||||
_cancel->setClickedCallback([this] {
|
||||
connect(_field, &Ui::InputField::focused, [=] { fieldFocused(); });
|
||||
connect(_field, &Ui::InputField::changed, [=] { queryChanged(); });
|
||||
connect(_field, &Ui::InputField::submitted, this, &Inner::submitted);
|
||||
_cancel->setClickedCallback([=] {
|
||||
clearQuery();
|
||||
_field->setFocus();
|
||||
});
|
||||
setMouseTracking(true);
|
||||
}
|
||||
|
||||
void MultiSelect::Inner::onQueryChanged() {
|
||||
void MultiSelect::Inner::queryChanged() {
|
||||
auto query = getQuery();
|
||||
_cancel->toggle(!query.isEmpty(), anim::type::normal);
|
||||
updateFieldGeometry();
|
||||
@@ -400,7 +400,8 @@ void MultiSelect::Inner::setQueryChangedCallback(base::lambda<void(const QString
|
||||
_queryChangedCallback = std::move(callback);
|
||||
}
|
||||
|
||||
void MultiSelect::Inner::setSubmittedCallback(base::lambda<void(bool ctrlShiftEnter)> callback) {
|
||||
void MultiSelect::Inner::setSubmittedCallback(
|
||||
base::lambda<void(Qt::KeyboardModifiers)> callback) {
|
||||
_submittedCallback = std::move(callback);
|
||||
}
|
||||
|
||||
@@ -563,7 +564,13 @@ void MultiSelect::Inner::keyPressEvent(QKeyEvent *e) {
|
||||
}
|
||||
}
|
||||
|
||||
void MultiSelect::Inner::onFieldFocused() {
|
||||
void MultiSelect::Inner::submitted(Qt::KeyboardModifiers modifiers) {
|
||||
if (_submittedCallback) {
|
||||
_submittedCallback(modifiers);
|
||||
}
|
||||
}
|
||||
|
||||
void MultiSelect::Inner::fieldFocused() {
|
||||
setActiveItem(-1, ChangeActiveWay::SkipSetFocus);
|
||||
}
|
||||
|
||||
|
@@ -25,7 +25,7 @@ public:
|
||||
void clearQuery();
|
||||
|
||||
void setQueryChangedCallback(base::lambda<void(const QString &query)> callback);
|
||||
void setSubmittedCallback(base::lambda<void(bool ctrlShiftEnter)> callback);
|
||||
void setSubmittedCallback(base::lambda<void(Qt::KeyboardModifiers)> callback);
|
||||
void setResizedCallback(base::lambda<void()> callback);
|
||||
|
||||
enum class AddItemWay {
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
void clearQuery();
|
||||
|
||||
void setQueryChangedCallback(base::lambda<void(const QString &query)> callback);
|
||||
void setSubmittedCallback(base::lambda<void(bool ctrlShiftEnter)> callback);
|
||||
void setSubmittedCallback(base::lambda<void(Qt::KeyboardModifiers)> callback);
|
||||
|
||||
void addItemInBunch(std::unique_ptr<Item> item);
|
||||
void finishItemsBunch(AddItemWay way);
|
||||
@@ -105,16 +105,10 @@ protected:
|
||||
void mousePressEvent(QMouseEvent *e) override;
|
||||
void keyPressEvent(QKeyEvent *e) override;
|
||||
|
||||
private slots:
|
||||
void onQueryChanged();
|
||||
void onSubmitted(bool ctrlShiftEnter) {
|
||||
if (_submittedCallback) {
|
||||
_submittedCallback(ctrlShiftEnter);
|
||||
}
|
||||
}
|
||||
void onFieldFocused();
|
||||
|
||||
private:
|
||||
void submitted(Qt::KeyboardModifiers modifiers);
|
||||
void queryChanged();
|
||||
void fieldFocused();
|
||||
void computeItemsGeometry(int newWidth);
|
||||
void updateItemsGeometry();
|
||||
void updateFieldGeometry();
|
||||
@@ -159,7 +153,7 @@ private:
|
||||
Animation _height;
|
||||
|
||||
base::lambda<void(const QString &query)> _queryChangedCallback;
|
||||
base::lambda<void(bool ctrlShiftEnter)> _submittedCallback;
|
||||
base::lambda<void(Qt::KeyboardModifiers)> _submittedCallback;
|
||||
base::lambda<void(uint64 itemId)> _itemRemovedCallback;
|
||||
base::lambda<void(int heightDelta)> _resizedCallback;
|
||||
|
||||
|
Reference in New Issue
Block a user