Removed App::wnd from classes that have pointer to Window::Controller.

This commit is contained in:
23rd 2021-02-03 06:31:11 +03:00 committed by John Preston
parent 0783a682dc
commit 0b4d0b83c2
12 changed files with 71 additions and 79 deletions

View file

@ -473,14 +473,12 @@ void StickerSetBox::Inner::mouseMoveEvent(QMouseEvent *e) {
int index = stickerFromGlobalPos(e->globalPos());
if (index >= 0 && index < _pack.size() && index != _previewShown) {
_previewShown = index;
if (const auto w = App::wnd()) {
w->showMediaPreview(
_controller->widget()->showMediaPreview(
Data::FileOriginStickerSet(_setId, _setAccess),
_pack[_previewShown]);
}
}
}
}
void StickerSetBox::Inner::leaveEventHook(QEvent *e) {
setSelected(-1);
@ -536,13 +534,11 @@ void StickerSetBox::Inner::showPreview() {
int index = stickerFromGlobalPos(QCursor::pos());
if (index >= 0 && index < _pack.size()) {
_previewShown = index;
if (const auto w = App::wnd()) {
w->showMediaPreview(
_controller->widget()->showMediaPreview(
Data::FileOriginStickerSet(_setId, _setAccess),
_pack[_previewShown]);
}
}
}
not_null<Lottie::MultiPlayer*> StickerSetBox::Inner::getLottiePlayer() {
if (!_lottiePlayer) {

View file

@ -1280,15 +1280,13 @@ void FieldAutocomplete::Inner::selectByMouse(QPoint globalPosition) {
if (_down >= 0 && _sel >= 0 && _down != _sel) {
_down = _sel;
if (_down >= 0 && _down < _srows->size()) {
if (const auto w = App::wnd()) {
w->showMediaPreview(
_controller->widget()->showMediaPreview(
(*_srows)[_down].document->stickerSetOrigin(),
(*_srows)[_down].document);
}
}
}
}
}
void FieldAutocomplete::Inner::onParentGeometryChanged() {
const auto globalPosition = QCursor::pos();
@ -1302,14 +1300,12 @@ void FieldAutocomplete::Inner::onParentGeometryChanged() {
void FieldAutocomplete::Inner::showPreview() {
if (_down >= 0 && _down < _srows->size()) {
if (const auto w = App::wnd()) {
w->showMediaPreview(
_controller->widget()->showMediaPreview(
(*_srows)[_down].document->stickerSetOrigin(),
(*_srows)[_down].document);
_previewShown = true;
}
}
}
void FieldAutocomplete::Inner::setSendMenuType(
Fn<SendMenu::Type()> &&callback) {

View file

@ -1078,20 +1078,18 @@ void GifsListWidget::updateSelected() {
_pressed = _selected;
if (row >= 0 && col >= 0) {
auto layout = _rows[row].items[col];
if (const auto w = App::wnd()) {
if (const auto previewDocument = layout->getPreviewDocument()) {
w->showMediaPreview(
controller()->widget()->showMediaPreview(
Data::FileOriginSavedGifs(),
previewDocument);
} else if (const auto previewPhoto = layout->getPreviewPhoto()) {
w->showMediaPreview(
controller()->widget()->showMediaPreview(
Data::FileOrigin(),
previewPhoto);
}
}
}
}
}
if (ClickHandler::setActive(lnk, lnkhost)) {
setCursor(lnk ? style::cur_pointer : style::cur_default);
}
@ -1104,19 +1102,17 @@ void GifsListWidget::showPreview() {
int row = _pressed / MatrixRowShift, col = _pressed % MatrixRowShift;
if (row < _rows.size() && col < _rows[row].items.size()) {
auto layout = _rows[row].items[col];
if (const auto w = App::wnd()) {
if (const auto previewDocument = layout->getPreviewDocument()) {
_previewShown = w->showMediaPreview(
_previewShown = controller()->widget()->showMediaPreview(
Data::FileOriginSavedGifs(),
previewDocument);
} else if (const auto previewPhoto = layout->getPreviewPhoto()) {
_previewShown = w->showMediaPreview(
_previewShown = controller()->widget()->showMediaPreview(
Data::FileOrigin(),
previewPhoto);
}
}
}
}
void GifsListWidget::updateInlineItems() {
auto ms = crl::now();

View file

@ -2883,9 +2883,9 @@ void StickersListWidget::setSelected(OverState newSelected) {
const auto &set = sets[sticker->section];
Assert(sticker->index >= 0 && sticker->index < set.stickers.size());
const auto document = set.stickers[sticker->index].document;
if (const auto w = App::wnd()) {
w->showMediaPreview(document->stickerSetOrigin(), document);
}
controller()->widget()->showMediaPreview(
document->stickerSetOrigin(),
document);
}
}
}
@ -2898,12 +2898,12 @@ void StickersListWidget::showPreview() {
const auto &set = sets[sticker->section];
Assert(sticker->index >= 0 && sticker->index < set.stickers.size());
const auto document = set.stickers[sticker->index].document;
if (const auto w = App::wnd()) {
w->showMediaPreview(document->stickerSetOrigin(), document);
controller()->widget()->showMediaPreview(
document->stickerSetOrigin(),
document);
_previewShown = true;
}
}
}
auto StickersListWidget::getLottieRenderer()
-> std::shared_ptr<Lottie::FrameRenderer> {

View file

@ -414,7 +414,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
Painter p(this);
const auto r = e->rect();
if (App::wnd()->contentOverlapped(this, r)) {
if (_controller->widget()->contentOverlapped(this, r)) {
return;
}
const auto activeEntry = _controller->activeChatEntryCurrent();

View file

@ -711,7 +711,7 @@ void Widget::animationCallback() {
updateControlsVisibility(true);
if (!_filter->hasFocus()) {
if (App::wnd()) App::wnd()->setInnerFocus();
controller()->widget()->setInnerFocus();
}
}
}
@ -957,7 +957,7 @@ void Widget::onChooseByDrag() {
}
void Widget::showMainMenu() {
App::wnd()->showMainMenu();
controller()->widget()->showMainMenu();
}
void Widget::searchMessages(
@ -1704,7 +1704,9 @@ void Widget::keyPressEvent(QKeyEvent *e) {
}
void Widget::paintEvent(QPaintEvent *e) {
if (App::wnd() && App::wnd()->contentOverlapped(this, e)) return;
if (controller()->widget()->contentOverlapped(this, e)) {
return;
}
Painter p(this);
QRect r(e->rect());

View file

@ -1515,7 +1515,7 @@ void InnerWidget::mouseActionFinish(const QPoint &screenPos, Qt::MouseButton but
if (_selectedItem && !_pressWasInactive) {
if (_selectedText.from == _selectedText.to) {
_selectedItem = nullptr;
App::wnd()->setInnerFocus();
_controller->widget()->setInnerFocus();
}
}
}

View file

@ -1392,7 +1392,7 @@ void HistoryInner::mouseActionFinish(
auto sel = _selected.cbegin()->second;
if (sel != FullSelection && sel.from == sel.to) {
_selected.clear();
App::wnd()->setInnerFocus();
_controller->widget()->setInnerFocus();
}
}
}

View file

@ -260,9 +260,11 @@ HistoryWidget::HistoryWidget(
connect(_field, &Ui::InputField::changed, [=] {
fieldChanged();
});
connect(App::wnd()->windowHandle(), &QWindow::visibleChanged, this, [=] {
windowIsVisibleChanged();
});
connect(
controller->widget()->windowHandle(),
&QWindow::visibleChanged,
this,
[=] { windowIsVisibleChanged(); });
initTabbedSelector();
@ -2006,7 +2008,7 @@ void HistoryWidget::showHistory(
update();
controller()->floatPlayerAreaUpdated();
crl::on_main(App::wnd(), [] { App::wnd()->setInnerFocus(); });
crl::on_main(this, [=] { controller()->widget()->setInnerFocus(); });
}
void HistoryWidget::clearDelayedShowAt() {

View file

@ -2254,7 +2254,7 @@ void ListWidget::mouseActionFinish(
} else if (_selectedTextItem && !_pressWasInactive) {
if (_selectedTextRange.from == _selectedTextRange.to) {
clearTextSelection();
App::wnd()->setInnerFocus();
_controller->widget()->setInnerFocus();
}
}
}

View file

@ -713,14 +713,14 @@ void Inner::updateSelected() {
_pressed = _selected;
if (row >= 0 && col >= 0) {
auto layout = _rows.at(row).items.at(col);
if (const auto w = App::wnd()) {
if (const auto previewDocument = layout->getPreviewDocument()) {
w->showMediaPreview(
_controller->widget()->showMediaPreview(
Data::FileOrigin(),
previewDocument);
} else if (auto previewPhoto = layout->getPreviewPhoto()) {
w->showMediaPreview(Data::FileOrigin(), previewPhoto);
}
_controller->widget()->showMediaPreview(
Data::FileOrigin(),
previewPhoto);
}
}
}
@ -740,12 +740,14 @@ void Inner::showPreview() {
int row = _pressed / MatrixRowShift, col = _pressed % MatrixRowShift;
if (row < _rows.size() && col < _rows.at(row).items.size()) {
auto layout = _rows.at(row).items.at(col);
if (const auto w = App::wnd()) {
if (const auto previewDocument = layout->getPreviewDocument()) {
_previewShown = w->showMediaPreview(Data::FileOrigin(), previewDocument);
_previewShown = _controller->widget()->showMediaPreview(
Data::FileOrigin(),
previewDocument);
} else if (const auto previewPhoto = layout->getPreviewPhoto()) {
_previewShown = w->showMediaPreview(Data::FileOrigin(), previewPhoto);
}
_previewShown = _controller->widget()->showMediaPreview(
Data::FileOrigin(),
previewPhoto);
}
}
}

View file

@ -858,8 +858,8 @@ void Editor::keyPressEvent(QKeyEvent *e) {
if (e->key() == Qt::Key_Escape) {
if (!_select->getQuery().isEmpty()) {
_select->clearQuery();
} else if (auto window = App::wnd()) {
window->setInnerFocus();
} else {
_window->widget()->setInnerFocus();
}
} else if (e->key() == Qt::Key_Down) {
_inner->selectSkip(1);
@ -904,11 +904,9 @@ void Editor::closeWithConfirmation() {
}
void Editor::closeEditor() {
if (const auto window = App::wnd()) {
window->showRightColumn(nullptr);
_window->widget()->showRightColumn(nullptr);
Background()->clearEditingTheme();
}
}
} // namespace Theme
} // namespace Window