diff --git a/Telegram/SourceFiles/boxes/create_poll_box.cpp b/Telegram/SourceFiles/boxes/create_poll_box.cpp index eb46cc606..e93824ba2 100644 --- a/Telegram/SourceFiles/boxes/create_poll_box.cpp +++ b/Telegram/SourceFiles/boxes/create_poll_box.cpp @@ -17,12 +17,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/labels.h" #include "ui/widgets/buttons.h" #include "main/main_session.h" -#include "core/event_filter.h" #include "chat_helpers/emoji_suggestions_widget.h" #include "chat_helpers/message_field.h" #include "history/view/history_view_schedule_box.h" #include "settings/settings_common.h" #include "base/unique_qptr.h" +#include "base/event_filter.h" #include "facades.h" #include "styles/style_layers.h" #include "styles/style_boxes.h" @@ -522,14 +522,14 @@ void Options::addEmptyOption() { QObject::connect(field, &Ui::InputField::focused, [=] { _scrollToWidget.fire_copy(field); }); - Core::InstallEventFilter(field, [=](not_null event) { + base::install_event_filter(field, [=](not_null event) { if (event->type() != QEvent::KeyPress || !field->getLastText().isEmpty()) { - return Core::EventFilter::Result::Continue; + return base::EventFilterResult::Continue; } const auto key = static_cast(event.get())->key(); if (key != Qt::Key_Backspace) { - return Core::EventFilter::Result::Continue; + return base::EventFilterResult::Continue; } const auto index = findField(field); @@ -538,7 +538,7 @@ void Options::addEmptyOption() { } else { _backspaceInFront.fire({}); } - return Core::EventFilter::Result::Cancel; + return base::EventFilterResult::Cancel; }); _list.back().removeClicks( diff --git a/Telegram/SourceFiles/boxes/edit_caption_box.cpp b/Telegram/SourceFiles/boxes/edit_caption_box.cpp index 47f80eb78..8870d947b 100644 --- a/Telegram/SourceFiles/boxes/edit_caption_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_caption_box.cpp @@ -14,7 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "chat_helpers/message_field.h" #include "chat_helpers/tabbed_panel.h" #include "chat_helpers/tabbed_selector.h" -#include "core/event_filter.h" +#include "base/event_filter.h" #include "core/file_utilities.h" #include "core/mime_type.h" #include "data/data_document.h" @@ -725,9 +725,9 @@ void EditCaptionBox::setupEmojiPanel() { const auto filterCallback = [=](not_null event) { emojiFilterForGeometry(event); - return Core::EventFilter::Result::Continue; + return base::EventFilterResult::Continue; }; - _emojiFilter.reset(Core::InstallEventFilter(container, filterCallback)); + _emojiFilter.reset(base::install_event_filter(container, filterCallback)); _emojiToggle.create(this, st::boxAttachEmoji); _emojiToggle->installEventFilter(_emojiPanel); diff --git a/Telegram/SourceFiles/boxes/send_files_box.cpp b/Telegram/SourceFiles/boxes/send_files_box.cpp index afc842773..2a458900e 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.cpp +++ b/Telegram/SourceFiles/boxes/send_files_box.cpp @@ -18,7 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/view/history_view_schedule_box.h" #include "core/file_utilities.h" #include "core/mime_type.h" -#include "core/event_filter.h" +#include "base/event_filter.h" #include "ui/effects/animations.h" #include "ui/widgets/checkbox.h" #include "ui/widgets/buttons.h" @@ -1706,9 +1706,9 @@ void SendFilesBox::setupEmojiPanel() { const auto filterCallback = [=](not_null event) { emojiFilterForGeometry(event); - return Core::EventFilter::Result::Continue; + return base::EventFilterResult::Continue; }; - _emojiFilter.reset(Core::InstallEventFilter(container, filterCallback)); + _emojiFilter.reset(base::install_event_filter(container, filterCallback)); _emojiToggle.create(this, st::boxAttachEmoji); _emojiToggle->setVisible(!_caption->isHidden()); diff --git a/Telegram/SourceFiles/chat_helpers/emoji_suggestions_widget.cpp b/Telegram/SourceFiles/chat_helpers/emoji_suggestions_widget.cpp index 394691007..f5bee20f8 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_suggestions_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_suggestions_widget.cpp @@ -17,7 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/ui_utility.h" #include "platform/platform_specific.h" #include "core/application.h" -#include "core/event_filter.h" +#include "base/event_filter.h" #include "main/main_session.h" #include "app.h" #include "styles/style_chat_helpers.h" @@ -525,17 +525,17 @@ SuggestionsController::SuggestionsController( const auto fieldCallback = [=](not_null event) { return fieldFilter(event) - ? Core::EventFilter::Result::Cancel - : Core::EventFilter::Result::Continue; + ? base::EventFilterResult::Cancel + : base::EventFilterResult::Continue; }; - _fieldFilter.reset(Core::InstallEventFilter(_field, fieldCallback)); + _fieldFilter.reset(base::install_event_filter(_field, fieldCallback)); const auto outerCallback = [=](not_null event) { return outerFilter(event) - ? Core::EventFilter::Result::Cancel - : Core::EventFilter::Result::Continue; + ? base::EventFilterResult::Cancel + : base::EventFilterResult::Continue; }; - _outerFilter.reset(Core::InstallEventFilter(outer, outerCallback)); + _outerFilter.reset(base::install_event_filter(outer, outerCallback)); QObject::connect( _field, diff --git a/Telegram/SourceFiles/chat_helpers/message_field.cpp b/Telegram/SourceFiles/chat_helpers/message_field.cpp index a3b1f94b4..43fb29500 100644 --- a/Telegram/SourceFiles/chat_helpers/message_field.cpp +++ b/Telegram/SourceFiles/chat_helpers/message_field.cpp @@ -12,13 +12,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/history_item.h" // HistoryItem::originalText #include "base/qthelp_regex.h" #include "base/qthelp_url.h" +#include "base/event_filter.h" #include "boxes/abstract_box.h" #include "ui/wrap/vertical_layout.h" #include "ui/widgets/popup_menu.h" #include "ui/ui_utility.h" #include "data/data_session.h" #include "data/data_user.h" -#include "core/event_filter.h" #include "chat_helpers/emoji_suggestions_widget.h" #include "window/window_session_controller.h" #include "lang/lang_keys.h" @@ -676,10 +676,10 @@ void SetupSendMenu( (*menu)->popup(QCursor::pos()); return true; }; - Core::InstallEventFilter(button, [=](not_null e) { + base::install_event_filter(button, [=](not_null e) { if (e->type() == QEvent::ContextMenu && showMenu()) { - return Core::EventFilter::Result::Cancel; + return base::EventFilterResult::Cancel; } - return Core::EventFilter::Result::Continue; + return base::EventFilterResult::Continue; }); } diff --git a/Telegram/SourceFiles/core/event_filter.cpp b/Telegram/SourceFiles/core/event_filter.cpp deleted file mode 100644 index 37e3e7cf3..000000000 --- a/Telegram/SourceFiles/core/event_filter.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* -This file is part of Telegram Desktop, -the official desktop application for the Telegram messaging service. - -For license and copyright information please follow this link: -https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL -*/ -#include "core/event_filter.h" - -namespace Core { - -EventFilter::EventFilter( - not_null parent, - not_null object, - Fn)> filter) -: QObject(parent) -, _filter(std::move(filter)) { - object->installEventFilter(this); -} - -bool EventFilter::eventFilter(QObject *watched, QEvent *event) { - return (_filter(event) == Result::Cancel); -} - -not_null InstallEventFilter( - not_null object, - Fn)> filter) { - return InstallEventFilter(object, object, std::move(filter)); -} - -not_null InstallEventFilter( - not_null context, - not_null object, - Fn)> filter) { - return new EventFilter(context, object, std::move(filter)); -} - -} // namespace Core diff --git a/Telegram/SourceFiles/core/event_filter.h b/Telegram/SourceFiles/core/event_filter.h deleted file mode 100644 index d6c847af2..000000000 --- a/Telegram/SourceFiles/core/event_filter.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -This file is part of Telegram Desktop, -the official desktop application for the Telegram messaging service. - -For license and copyright information please follow this link: -https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL -*/ -#pragma once - -namespace Core { - -class EventFilter : public QObject { -public: - enum Result { - Continue, - Cancel, - }; - - EventFilter( - not_null parent, - not_null object, - Fn)> filter); - -protected: - bool eventFilter(QObject *watched, QEvent *event); - -private: - Fn)> _filter; - -}; - -not_null InstallEventFilter( - not_null object, - Fn)> filter); - -not_null InstallEventFilter( - not_null context, - not_null object, - Fn)> filter); - -} // namespace Core diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index 020dfed4c..86b305d83 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -23,8 +23,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mainwidget.h" #include "main/main_session.h" #include "apiwrap.h" +#include "base/event_filter.h" #include "core/application.h" -#include "core/event_filter.h" #include "core/update_checker.h" #include "boxes/peer_list_box.h" #include "boxes/peers/edit_participants_box.h" @@ -314,13 +314,13 @@ void Widget::setupScrollUpButton() { } scrollToTop(); }); - Core::InstallEventFilter(_scrollToTop, [=](not_null event) { + base::install_event_filter(_scrollToTop, [=](not_null event) { if (event->type() != QEvent::Wheel) { - return Core::EventFilter::Result::Continue; + return base::EventFilterResult::Continue; } return _scroll->viewportEvent(event) - ? Core::EventFilter::Result::Cancel - : Core::EventFilter::Result::Continue; + ? base::EventFilterResult::Cancel + : base::EventFilterResult::Continue; }); updateScrollUpVisibility(); } diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index c1bd89f43..20fbd79a0 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -14,7 +14,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/share_box.h" #include "boxes/edit_caption_box.h" #include "core/file_utilities.h" -#include "core/event_filter.h" #include "ui/toast/toast.h" #include "ui/special_buttons.h" #include "ui/emoji_config.h" @@ -28,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/image/image.h" #include "ui/special_buttons.h" #include "inline_bots/inline_bot_result.h" +#include "base/event_filter.h" #include "base/unixtime.h" #include "data/data_drafts.h" #include "data/data_session.h" @@ -680,11 +680,11 @@ void HistoryWidget::initTabbedSelector() { const auto selector = controller()->tabbedSelector(); - Core::InstallEventFilter(this, selector, [=](not_null e) { + base::install_event_filter(this, selector, [=](not_null e) { if (_tabbedPanel && e->type() == QEvent::ParentChange) { setTabbedPanel(nullptr); } - return Core::EventFilter::Result::Continue; + return base::EventFilterResult::Continue; }); selector->emojiChosen( diff --git a/Telegram/SourceFiles/history/view/history_view_compose_controls.cpp b/Telegram/SourceFiles/history/view/history_view_compose_controls.cpp index 41e8e143e..7bb12d966 100644 --- a/Telegram/SourceFiles/history/view/history_view_compose_controls.cpp +++ b/Telegram/SourceFiles/history/view/history_view_compose_controls.cpp @@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/special_buttons.h" #include "ui/ui_utility.h" #include "lang/lang_keys.h" -#include "core/event_filter.h" +#include "base/event_filter.h" #include "base/qt_signal_producer.h" #include "history/history.h" #include "chat_helpers/tabbed_panel.h" @@ -228,11 +228,11 @@ void ComposeControls::initTabbedSelector() { const auto selector = _window->tabbedSelector(); const auto wrap = _wrap.get(); - Core::InstallEventFilter(wrap, selector, [=](not_null e) { + base::install_event_filter(wrap, selector, [=](not_null e) { if (_tabbedPanel && e->type() == QEvent::ParentChange) { setTabbedPanel(nullptr); } - return Core::EventFilter::Result::Continue; + return base::EventFilterResult::Continue; }); selector->emojiChosen( diff --git a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp index e1409ad36..6b9d7fbd3 100644 --- a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp @@ -27,7 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/send_files_box.h" #include "window/window_session_controller.h" #include "window/window_peer_menu.h" -#include "core/event_filter.h" +#include "base/event_filter.h" #include "core/file_utilities.h" #include "main/main_session.h" #include "data/data_session.h" @@ -551,13 +551,13 @@ void ScheduledWidget::setupScrollDownButton() { _scrollDown->setClickedCallback([=] { scrollDownClicked(); }); - Core::InstallEventFilter(_scrollDown, [=](not_null event) { + base::install_event_filter(_scrollDown, [=](not_null event) { if (event->type() != QEvent::Wheel) { - return Core::EventFilter::Result::Continue; + return base::EventFilterResult::Continue; } return _scroll->viewportEvent(event) - ? Core::EventFilter::Result::Cancel - : Core::EventFilter::Result::Continue; + ? base::EventFilterResult::Cancel + : base::EventFilterResult::Continue; }); updateScrollDownVisibility(); } diff --git a/Telegram/SourceFiles/window/themes/window_theme_editor_box.cpp b/Telegram/SourceFiles/window/themes/window_theme_editor_box.cpp index 60cf87441..31d5af17f 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_editor_box.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_editor_box.cpp @@ -26,8 +26,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "storage/localstorage.h" #include "core/file_utilities.h" #include "core/application.h" -#include "core/event_filter.h" #include "lang/lang_keys.h" +#include "base/event_filter.h" #include "base/zlib_help.h" #include "base/unixtime.h" #include "data/data_session.h" @@ -717,15 +717,15 @@ void CreateForExistingBox( box->closeBox(); StartEditor(window, cloud); }; - Core::InstallEventFilter(box, box, [=](not_null event) { + base::install_event_filter(box, box, [=](not_null event) { if (event->type() == QEvent::KeyPress) { const auto key = static_cast(event.get())->key(); if (key == Qt::Key_Enter || key == Qt::Key_Return) { done(); - return Core::EventFilter::Result::Cancel; + return base::EventFilterResult::Cancel; } } - return Core::EventFilter::Result::Continue; + return base::EventFilterResult::Continue; }); box->addButton(tr::lng_theme_editor_create(), done); box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); diff --git a/Telegram/gyp/telegram/sources.txt b/Telegram/gyp/telegram/sources.txt index 1a7fecd2b..effb6c0ed 100644 --- a/Telegram/gyp/telegram/sources.txt +++ b/Telegram/gyp/telegram/sources.txt @@ -150,8 +150,6 @@ <(src_loc)/core/crash_report_window.h <(src_loc)/core/crash_reports.cpp <(src_loc)/core/crash_reports.h -<(src_loc)/core/event_filter.cpp -<(src_loc)/core/event_filter.h <(src_loc)/core/file_utilities.cpp <(src_loc)/core/file_utilities.h <(src_loc)/core/launcher.cpp diff --git a/Telegram/lib_base b/Telegram/lib_base index ec7852a1c..be5560996 160000 --- a/Telegram/lib_base +++ b/Telegram/lib_base @@ -1 +1 @@ -Subproject commit ec7852a1cc36c45550074cd98f292f61f056ecf2 +Subproject commit be556099605f1ee83e3ca444b75dd90b950b6a36