diff --git a/Telegram/SourceFiles/boxes/mute_settings_box.cpp b/Telegram/SourceFiles/boxes/mute_settings_box.cpp index e7d078ed6a..8797d43ef8 100644 --- a/Telegram/SourceFiles/boxes/mute_settings_box.cpp +++ b/Telegram/SourceFiles/boxes/mute_settings_box.cpp @@ -21,6 +21,10 @@ constexpr auto kForeverHours = 24 * 365; } // namespace +MuteSettingsBox::MuteSettingsBox(QWidget *parent, not_null peer) +: _peer(peer) { +} + void MuteSettingsBox::prepare() { setTitle(langFactory(lng_disable_notifications_from_tray)); auto y = 0; @@ -67,15 +71,25 @@ void MuteSettingsBox::prepare() { - st::boxOptionListSkip + st::defaultCheckbox.margin.bottom(); - addButton(langFactory(lng_box_ok), [this, group] { - auto muteForSeconds = group->value() * 3600; + _save = [=] { + const auto muteForSeconds = group->value() * 3600; Auth().data().updateNotifySettings( _peer, muteForSeconds); closeBox(); - }); + }; + addButton(langFactory(lng_box_ok), _save); addButton(langFactory(lng_cancel), [this] { closeBox(); }); setDimensions(st::boxWidth, y); } + +void MuteSettingsBox::keyPressEvent(QKeyEvent *e) { + if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) { + if (_save) { + _save(); + } + } +} + // vi: ts=4 tw=80 diff --git a/Telegram/SourceFiles/boxes/mute_settings_box.h b/Telegram/SourceFiles/boxes/mute_settings_box.h index 3688e9433d..fe5c1efc6b 100644 --- a/Telegram/SourceFiles/boxes/mute_settings_box.h +++ b/Telegram/SourceFiles/boxes/mute_settings_box.h @@ -13,17 +13,17 @@ Copyright (C) 2017, Nicholas Guriev * turning off notifications from a chat. The widget is opened by a context menu * in the left list of dialogues. */ class MuteSettingsBox : public BoxContent { - Q_OBJECT +public: + MuteSettingsBox(QWidget *parent, not_null peer); - public: - MuteSettingsBox(QWidget *parent, not_null peer) - : _peer(peer) { - } - - protected: +protected: void prepare() override; - private: + void keyPressEvent(QKeyEvent *e) override; + +private: not_null _peer; + Fn _save; + }; // vi: ts=4 tw=80