mirror of
https://github.com/vale981/tdesktop
synced 2025-03-05 09:41:41 -05:00
Use install_base_filter for lib_base.
This commit is contained in:
parent
a6b96662c4
commit
f677b116f9
14 changed files with 43 additions and 124 deletions
|
@ -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<QEvent*> event) {
|
||||
base::install_event_filter(field, [=](not_null<QEvent*> event) {
|
||||
if (event->type() != QEvent::KeyPress
|
||||
|| !field->getLastText().isEmpty()) {
|
||||
return Core::EventFilter::Result::Continue;
|
||||
return base::EventFilterResult::Continue;
|
||||
}
|
||||
const auto key = static_cast<QKeyEvent*>(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(
|
||||
|
|
|
@ -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<QEvent*> 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);
|
||||
|
|
|
@ -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<QEvent*> 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());
|
||||
|
|
|
@ -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<QEvent*> 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<QEvent*> 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,
|
||||
|
|
|
@ -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<QEvent*> e) {
|
||||
base::install_event_filter(button, [=](not_null<QEvent*> 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;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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<QObject*> parent,
|
||||
not_null<QObject*> object,
|
||||
Fn<EventFilter::Result(not_null<QEvent*>)> filter)
|
||||
: QObject(parent)
|
||||
, _filter(std::move(filter)) {
|
||||
object->installEventFilter(this);
|
||||
}
|
||||
|
||||
bool EventFilter::eventFilter(QObject *watched, QEvent *event) {
|
||||
return (_filter(event) == Result::Cancel);
|
||||
}
|
||||
|
||||
not_null<QObject*> InstallEventFilter(
|
||||
not_null<QObject*> object,
|
||||
Fn<EventFilter::Result(not_null<QEvent*>)> filter) {
|
||||
return InstallEventFilter(object, object, std::move(filter));
|
||||
}
|
||||
|
||||
not_null<QObject*> InstallEventFilter(
|
||||
not_null<QObject*> context,
|
||||
not_null<QObject*> object,
|
||||
Fn<EventFilter::Result(not_null<QEvent*>)> filter) {
|
||||
return new EventFilter(context, object, std::move(filter));
|
||||
}
|
||||
|
||||
} // namespace Core
|
|
@ -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<QObject*> parent,
|
||||
not_null<QObject*> object,
|
||||
Fn<Result(not_null<QEvent*>)> filter);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
|
||||
private:
|
||||
Fn<Result(not_null<QEvent*>)> _filter;
|
||||
|
||||
};
|
||||
|
||||
not_null<QObject*> InstallEventFilter(
|
||||
not_null<QObject*> object,
|
||||
Fn<EventFilter::Result(not_null<QEvent*>)> filter);
|
||||
|
||||
not_null<QObject*> InstallEventFilter(
|
||||
not_null<QObject*> context,
|
||||
not_null<QObject*> object,
|
||||
Fn<EventFilter::Result(not_null<QEvent*>)> filter);
|
||||
|
||||
} // namespace Core
|
|
@ -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<QEvent*> event) {
|
||||
base::install_event_filter(_scrollToTop, [=](not_null<QEvent*> 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();
|
||||
}
|
||||
|
|
|
@ -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<QEvent*> e) {
|
||||
base::install_event_filter(this, selector, [=](not_null<QEvent*> e) {
|
||||
if (_tabbedPanel && e->type() == QEvent::ParentChange) {
|
||||
setTabbedPanel(nullptr);
|
||||
}
|
||||
return Core::EventFilter::Result::Continue;
|
||||
return base::EventFilterResult::Continue;
|
||||
});
|
||||
|
||||
selector->emojiChosen(
|
||||
|
|
|
@ -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<QEvent*> e) {
|
||||
base::install_event_filter(wrap, selector, [=](not_null<QEvent*> e) {
|
||||
if (_tabbedPanel && e->type() == QEvent::ParentChange) {
|
||||
setTabbedPanel(nullptr);
|
||||
}
|
||||
return Core::EventFilter::Result::Continue;
|
||||
return base::EventFilterResult::Continue;
|
||||
});
|
||||
|
||||
selector->emojiChosen(
|
||||
|
|
|
@ -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<QEvent*> event) {
|
||||
base::install_event_filter(_scrollDown, [=](not_null<QEvent*> 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();
|
||||
}
|
||||
|
|
|
@ -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<QEvent*> event) {
|
||||
base::install_event_filter(box, box, [=](not_null<QEvent*> event) {
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
const auto key = static_cast<QKeyEvent*>(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(); });
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit ec7852a1cc36c45550074cd98f292f61f056ecf2
|
||||
Subproject commit be556099605f1ee83e3ca444b75dd90b950b6a36
|
Loading…
Add table
Reference in a new issue