mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
Move GIF pausing methods to Window::Controller.
This commit is contained in:
parent
cd3c5e4ade
commit
570cd9bdfa
27 changed files with 214 additions and 127 deletions
|
@ -194,7 +194,8 @@ void BoxContent::paintEvent(QPaintEvent *e) {
|
|||
}
|
||||
}
|
||||
|
||||
AbstractBox::AbstractBox(QWidget *parent, object_ptr<BoxContent> content) : LayerWidget(parent)
|
||||
AbstractBox::AbstractBox(QWidget *parent, Window::Controller *controller, object_ptr<BoxContent> content) : LayerWidget(parent)
|
||||
, _controller(controller)
|
||||
, _content(std::move(content)) {
|
||||
_content->setParent(this);
|
||||
_content->setDelegate(this);
|
||||
|
|
|
@ -31,6 +31,10 @@ template <typename Widget>
|
|||
class WidgetFadeWrap;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Window {
|
||||
class Controller;
|
||||
} // namespace Window
|
||||
|
||||
class BoxLayerTitleShadow : public Ui::PlainShadow {
|
||||
public:
|
||||
BoxLayerTitleShadow(QWidget *parent);
|
||||
|
@ -39,6 +43,8 @@ public:
|
|||
|
||||
class BoxContentDelegate {
|
||||
public:
|
||||
virtual Window::Controller *controller() const = 0;
|
||||
|
||||
virtual void setLayerType(bool layerType) = 0;
|
||||
virtual void setTitle(const QString &title, const QString &additional) = 0;
|
||||
|
||||
|
@ -61,8 +67,6 @@ public:
|
|||
BoxContent() {
|
||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
}
|
||||
BoxContent(QWidget*) : BoxContent() {
|
||||
}
|
||||
|
||||
bool isBoxShown() const {
|
||||
return getDelegate()->isBoxShown();
|
||||
|
@ -107,6 +111,10 @@ public slots:
|
|||
protected:
|
||||
virtual void prepare() = 0;
|
||||
|
||||
Window::Controller *controller() {
|
||||
return getDelegate()->controller();
|
||||
}
|
||||
|
||||
void setLayerType(bool layerType) {
|
||||
getDelegate()->setLayerType(layerType);
|
||||
}
|
||||
|
@ -165,7 +173,7 @@ private:
|
|||
object_ptr<TWidget> doTakeInnerWidget();
|
||||
|
||||
BoxContentDelegate *getDelegate() const {
|
||||
t_assert(_delegate != nullptr);
|
||||
Expects(_delegate != nullptr);
|
||||
return _delegate;
|
||||
}
|
||||
BoxContentDelegate *_delegate = nullptr;
|
||||
|
@ -183,8 +191,11 @@ private:
|
|||
|
||||
class AbstractBox : public LayerWidget, public BoxContentDelegate, protected base::Subscriber {
|
||||
public:
|
||||
AbstractBox(QWidget *parent, object_ptr<BoxContent> content);
|
||||
AbstractBox(QWidget *parent, Window::Controller *controller, object_ptr<BoxContent> content);
|
||||
|
||||
Window::Controller *controller() const override {
|
||||
return _controller;
|
||||
}
|
||||
void parentResized() override;
|
||||
|
||||
void setLayerType(bool layerType) override;
|
||||
|
@ -235,6 +246,7 @@ private:
|
|||
int countRealHeight() const;
|
||||
void updateSize();
|
||||
|
||||
Window::Controller *_controller = nullptr;
|
||||
int _fullHeight = 0;
|
||||
|
||||
bool _noContentMargin = false;
|
||||
|
|
|
@ -31,7 +31,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
|||
#include "styles/style_history.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "media/media_clip_reader.h"
|
||||
#include "mainwindow.h"
|
||||
#include "window/window_controller.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -61,7 +61,7 @@ SendFilesBox::SendFilesBox(QWidget*, const QStringList &files, CompressConfirm c
|
|||
}
|
||||
|
||||
void SendFilesBox::prepareSingleFileLayout() {
|
||||
t_assert(_files.size() == 1);
|
||||
Expects(_files.size() == 1);
|
||||
if (!_files.front().isEmpty()) {
|
||||
tryToReadSingleFile();
|
||||
}
|
||||
|
@ -231,6 +231,8 @@ SendFilesBox::SendFilesBox(QWidget*, const QString &phone, const QString &firstn
|
|||
}
|
||||
|
||||
void SendFilesBox::prepare() {
|
||||
Expects(controller() != nullptr);
|
||||
|
||||
if (_files.size() > 1) {
|
||||
updateTitleText();
|
||||
}
|
||||
|
@ -331,7 +333,7 @@ void SendFilesBox::paintEvent(QPaintEvent *e) {
|
|||
}
|
||||
if (_gifPreview && _gifPreview->started()) {
|
||||
auto s = QSize(_previewWidth, _previewHeight);
|
||||
auto paused = App::wnd()->isGifPausedAtLeastFor(Window::GifPauseReason::Layer);
|
||||
auto paused = controller()->isGifPausedAtLeastFor(Window::GifPauseReason::Layer);
|
||||
auto frame = _gifPreview->current(s.width(), s.height(), s.width(), s.height(), ImageRoundRadius::None, ImageRoundCorner::None, paused ? 0 : getms());
|
||||
p.drawPixmap(_previewLeft, st::boxPhotoPadding.top(), frame);
|
||||
} else {
|
||||
|
@ -673,7 +675,7 @@ void EditCaptionBox::paintEvent(QPaintEvent *e) {
|
|||
}
|
||||
if (_gifPreview && _gifPreview->started()) {
|
||||
auto s = QSize(_thumbw, _thumbh);
|
||||
auto paused = App::wnd()->isGifPausedAtLeastFor(Window::GifPauseReason::Layer);
|
||||
auto paused = controller()->isGifPausedAtLeastFor(Window::GifPauseReason::Layer);
|
||||
auto frame = _gifPreview->current(s.width(), s.height(), s.width(), s.height(), ImageRoundRadius::None, ImageRoundCorner::None, paused ? 0 : getms());
|
||||
p.drawPixmap(_thumbx, st::boxPhotoPadding.top(), frame);
|
||||
} else {
|
||||
|
|
|
@ -302,7 +302,7 @@ void EmojiColorPicker::drawVariant(Painter &p, int variant) {
|
|||
p.drawPixmapLeft(w.x() + (st::emojiPanSize.width() - (esize / cIntRetinaFactor())) / 2, w.y() + (st::emojiPanSize.height() - (esize / cIntRetinaFactor())) / 2, width(), App::emojiLarge(), QRect(_variants[variant]->x() * esize, _variants[variant]->y() * esize, esize, esize));
|
||||
}
|
||||
|
||||
EmojiListWidget::EmojiListWidget(QWidget *parent) : Inner(parent)
|
||||
EmojiListWidget::EmojiListWidget(QWidget *parent, gsl::not_null<Window::Controller*> controller) : Inner(parent, controller)
|
||||
, _picker(this) {
|
||||
resize(st::emojiPanWidth - st::emojiScroll.width - st::buttonRadius, countHeight());
|
||||
|
||||
|
|
|
@ -22,6 +22,10 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
|||
|
||||
#include "chat_helpers/emoji_panel.h"
|
||||
|
||||
namespace Window {
|
||||
class Controller;
|
||||
} // namespace Window
|
||||
|
||||
namespace ChatHelpers {
|
||||
|
||||
constexpr auto kEmojiSectionCount = 8;
|
||||
|
@ -84,7 +88,7 @@ class EmojiListWidget : public EmojiPanel::Inner {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
EmojiListWidget(QWidget *parent);
|
||||
EmojiListWidget(QWidget *parent, gsl::not_null<Window::Controller*> controller);
|
||||
|
||||
using Section = Ui::Emoji::Section;
|
||||
|
||||
|
|
|
@ -279,15 +279,15 @@ void EmojiPanel::Tab::saveScrollTop() {
|
|||
_scrollTop = widget()->getVisibleTop();
|
||||
}
|
||||
|
||||
EmojiPanel::EmojiPanel(QWidget *parent) : TWidget(parent)
|
||||
EmojiPanel::EmojiPanel(QWidget *parent, gsl::not_null<Window::Controller*> controller) : TWidget(parent)
|
||||
, _tabsSlider(this, st::emojiTabs)
|
||||
, _topShadow(this, st::shadowFg)
|
||||
, _bottomShadow(this, st::shadowFg)
|
||||
, _scroll(this, st::emojiScroll)
|
||||
, _tabs { {
|
||||
Tab { TabType::Emoji, object_ptr<EmojiListWidget>(this) },
|
||||
Tab { TabType::Stickers, object_ptr<StickersListWidget>(this) },
|
||||
Tab { TabType::Gifs, object_ptr<GifsListWidget>(this) },
|
||||
Tab { TabType::Emoji, object_ptr<EmojiListWidget>(this, controller) },
|
||||
Tab { TabType::Stickers, object_ptr<StickersListWidget>(this, controller) },
|
||||
Tab { TabType::Gifs, object_ptr<GifsListWidget>(this, controller) },
|
||||
} }
|
||||
, _currentTabType(AuthSession::Current().data().emojiPanelTab()) {
|
||||
resize(QRect(0, 0, st::emojiPanWidth, st::emojiPanMaxHeight).marginsAdded(innerPadding()).size());
|
||||
|
@ -879,7 +879,8 @@ void EmojiPanel::scrollToY(int y) {
|
|||
_topShadow->update();
|
||||
}
|
||||
|
||||
EmojiPanel::Inner::Inner(QWidget *parent) : TWidget(parent) {
|
||||
EmojiPanel::Inner::Inner(QWidget *parent, gsl::not_null<Window::Controller*> controller) : TWidget(parent)
|
||||
, _controller(controller) {
|
||||
}
|
||||
|
||||
void EmojiPanel::Inner::setVisibleTopBottom(int visibleTop, int visibleBottom) {
|
||||
|
|
|
@ -36,6 +36,10 @@ class RippleAnimation;
|
|||
class SettingsSlider;
|
||||
} // namesapce Ui
|
||||
|
||||
namespace Window {
|
||||
class Controller;
|
||||
} // namespace Window
|
||||
|
||||
namespace ChatHelpers {
|
||||
|
||||
class EmojiListWidget;
|
||||
|
@ -46,7 +50,7 @@ class EmojiPanel : public TWidget {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
EmojiPanel(QWidget *parent);
|
||||
EmojiPanel(QWidget *parent, gsl::not_null<Window::Controller*> controller);
|
||||
|
||||
void moveBottom(int bottom);
|
||||
|
||||
|
@ -234,7 +238,7 @@ class EmojiPanel::Inner : public TWidget {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Inner(QWidget *parent);
|
||||
Inner(QWidget *parent, gsl::not_null<Window::Controller*> controller);
|
||||
|
||||
void setVisibleTopBottom(int visibleTop, int visibleBottom) override;
|
||||
|
||||
|
@ -265,6 +269,10 @@ signals:
|
|||
void saveConfigDelayed(int delay);
|
||||
|
||||
protected:
|
||||
gsl::not_null<Window::Controller*> controller() const {
|
||||
return _controller;
|
||||
}
|
||||
|
||||
virtual int countHeight() = 0;
|
||||
virtual InnerFooter *getFooter() const = 0;
|
||||
virtual void processHideFinished() {
|
||||
|
@ -273,6 +281,8 @@ protected:
|
|||
}
|
||||
|
||||
private:
|
||||
gsl::not_null<Window::Controller*> _controller;
|
||||
|
||||
int _visibleTop = 0;
|
||||
int _visibleBottom = 0;
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
|||
#include "storage/localstorage.h"
|
||||
#include "lang.h"
|
||||
#include "mainwindow.h"
|
||||
#include "window/window_controller.h"
|
||||
|
||||
namespace ChatHelpers {
|
||||
namespace {
|
||||
|
@ -115,7 +116,7 @@ void GifsListWidget::Footer::processPanelHideFinished() {
|
|||
_field->setText(QString());
|
||||
}
|
||||
|
||||
GifsListWidget::GifsListWidget(QWidget *parent) : Inner(parent)
|
||||
GifsListWidget::GifsListWidget(QWidget *parent, gsl::not_null<Window::Controller*> controller) : Inner(parent, controller)
|
||||
, _section(Section::Gifs) {
|
||||
resize(st::emojiPanWidth - st::emojiScroll.width - st::buttonRadius, countHeight());
|
||||
|
||||
|
@ -137,8 +138,8 @@ GifsListWidget::GifsListWidget(QWidget *parent) : Inner(parent)
|
|||
subscribe(AuthSession::CurrentDownloaderTaskFinished(), [this] {
|
||||
update();
|
||||
});
|
||||
subscribe(App::wnd()->gifPauseLevelChanged(), [this] {
|
||||
if (!App::wnd()->isGifPausedAtLeastFor(Window::GifPauseReason::SavedGifs)) {
|
||||
subscribe(controller->gifPauseLevelChanged(), [this] {
|
||||
if (!this->controller()->isGifPausedAtLeastFor(Window::GifPauseReason::SavedGifs)) {
|
||||
update();
|
||||
}
|
||||
});
|
||||
|
@ -253,7 +254,7 @@ void GifsListWidget::paintInlineItems(Painter &p, QRect clip) {
|
|||
p.drawText(QRect(0, 0, width(), (height() / 3) * 2 + st::normalFont->height), lang(lng_inline_bot_no_results), style::al_center);
|
||||
return;
|
||||
}
|
||||
auto gifPaused = App::wnd()->isGifPausedAtLeastFor(Window::GifPauseReason::SavedGifs);
|
||||
auto gifPaused = controller()->isGifPausedAtLeastFor(Window::GifPauseReason::SavedGifs);
|
||||
InlineBots::Layout::PaintContext context(getms(), false, gifPaused, false);
|
||||
|
||||
auto top = st::stickerPanPadding;
|
||||
|
@ -388,7 +389,7 @@ EmojiPanel::InnerFooter *GifsListWidget::getFooter() const {
|
|||
|
||||
void GifsListWidget::processHideFinished() {
|
||||
clearSelection();
|
||||
App::wnd()->disableGifPauseReason(Window::GifPauseReason::SavedGifs);
|
||||
controller()->disableGifPauseReason(Window::GifPauseReason::SavedGifs);
|
||||
}
|
||||
|
||||
void GifsListWidget::processPanelHideFinished() {
|
||||
|
@ -749,7 +750,7 @@ void GifsListWidget::afterShown() {
|
|||
if (_footer) {
|
||||
_footer->stealFocus();
|
||||
}
|
||||
App::wnd()->enableGifPauseReason(Window::GifPauseReason::SavedGifs);
|
||||
controller()->enableGifPauseReason(Window::GifPauseReason::SavedGifs);
|
||||
}
|
||||
|
||||
void GifsListWidget::beforeHiding() {
|
||||
|
|
|
@ -34,13 +34,17 @@ namespace Ui {
|
|||
class RoundButton;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Window {
|
||||
class Controller;
|
||||
} // namespace Window
|
||||
|
||||
namespace ChatHelpers {
|
||||
|
||||
class GifsListWidget : public EmojiPanel::Inner, public InlineBots::Layout::Context, private base::Subscriber, private MTP::Sender {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GifsListWidget(QWidget *parent);
|
||||
GifsListWidget(QWidget *parent, gsl::not_null<Window::Controller*> controller);
|
||||
|
||||
void refreshRecent() override;
|
||||
void preloadImages() override;
|
||||
|
|
|
@ -412,7 +412,7 @@ void StickersListWidget::Footer::step_icons(TimeMs ms, bool timer) {
|
|||
}
|
||||
}
|
||||
|
||||
StickersListWidget::StickersListWidget(QWidget *parent) : Inner(parent)
|
||||
StickersListWidget::StickersListWidget(QWidget *parent, gsl::not_null<Window::Controller*> controller) : Inner(parent, controller)
|
||||
, _section(Section::Stickers)
|
||||
, _addText(lang(lng_stickers_featured_add).toUpper())
|
||||
, _addWidth(st::stickersTrendingAdd.font->width(_addText))
|
||||
|
|
|
@ -23,6 +23,10 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
|||
#include "chat_helpers/emoji_panel.h"
|
||||
#include "base/variant.h"
|
||||
|
||||
namespace Window {
|
||||
class Controller;
|
||||
} // namespace Window
|
||||
|
||||
namespace Ui {
|
||||
class LinkButton;
|
||||
} // namespace Ui
|
||||
|
@ -35,7 +39,7 @@ class StickersListWidget : public EmojiPanel::Inner, private base::Subscriber, p
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
StickersListWidget(QWidget *parent);
|
||||
StickersListWidget(QWidget *parent, gsl::not_null<Window::Controller*> controller);
|
||||
|
||||
void refreshRecent() override;
|
||||
void preloadImages() override;
|
||||
|
|
|
@ -31,6 +31,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
|||
#include "boxes/add_contact_box.h"
|
||||
#include "core/click_handler_types.h"
|
||||
#include "history/history_location_manager.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "styles/style_history.h"
|
||||
|
||||
namespace {
|
||||
|
@ -1844,7 +1845,7 @@ void HistoryGif::draw(Painter &p, const QRect &r, TextSelection selection, TimeM
|
|||
auto roundCorners = inWebPage ? ImageRoundCorner::All : ((isBubbleTop() ? (ImageRoundCorner::TopLeft | ImageRoundCorner::TopRight) : ImageRoundCorner::None)
|
||||
| ((isBubbleBottom() && _caption.isEmpty()) ? (ImageRoundCorner::BottomLeft | ImageRoundCorner::BottomRight) : ImageRoundCorner::None));
|
||||
if (animating) {
|
||||
auto paused = App::wnd()->isGifPausedAtLeastFor(Window::GifPauseReason::Any);
|
||||
auto paused = App::wnd()->controller()->isGifPausedAtLeastFor(Window::GifPauseReason::Any);
|
||||
p.drawPixmap(rthumb.topLeft(), _gif->current(_thumbw, _thumbh, width, height, roundRadius, roundCorners, paused ? 0 : ms));
|
||||
} else {
|
||||
p.drawPixmap(rthumb.topLeft(), _data->thumb->pixBlurredSingle(_thumbw, _thumbh, width, height, roundRadius, roundCorners));
|
||||
|
|
|
@ -147,7 +147,8 @@ private:
|
|||
|
||||
// flick scroll taken from http://qt-project.org/doc/qt-4.8/demos-embedded-anomaly-src-flickcharm-cpp.html
|
||||
|
||||
HistoryInner::HistoryInner(HistoryWidget *historyWidget, Ui::ScrollArea *scroll, History *history) : TWidget(nullptr)
|
||||
HistoryInner::HistoryInner(HistoryWidget *historyWidget, gsl::not_null<Window::Controller*> controller, Ui::ScrollArea *scroll, History *history) : TWidget(nullptr)
|
||||
, _controller(controller)
|
||||
, _peer(history->peer)
|
||||
, _migrated(history->peer->migrateFrom() ? App::history(history->peer->migrateFrom()->id) : nullptr)
|
||||
, _history(history)
|
||||
|
@ -170,8 +171,8 @@ HistoryInner::HistoryInner(HistoryWidget *historyWidget, Ui::ScrollArea *scroll,
|
|||
subscribe(Global::RefItemRemoved(), [this](HistoryItem *item) {
|
||||
itemRemoved(item);
|
||||
});
|
||||
subscribe(App::wnd()->gifPauseLevelChanged(), [this] {
|
||||
if (!App::wnd()->isGifPausedAtLeastFor(Window::GifPauseReason::Any)) {
|
||||
subscribe(_controller->gifPauseLevelChanged(), [this] {
|
||||
if (!_controller->isGifPausedAtLeastFor(Window::GifPauseReason::Any)) {
|
||||
update();
|
||||
}
|
||||
});
|
||||
|
@ -3224,7 +3225,7 @@ HistoryWidget::HistoryWidget(QWidget *parent, gsl::not_null<Window::Controller*>
|
|||
, _recordCancelWidth(st::historyRecordFont->width(lang(lng_record_cancel)))
|
||||
, _a_recording(animation(this, &HistoryWidget::step_recording))
|
||||
, _kbScroll(this, st::botKbScroll)
|
||||
, _emojiPanel(this)
|
||||
, _emojiPanel(this, controller)
|
||||
, _attachDragDocument(this)
|
||||
, _attachDragPhoto(this)
|
||||
, _fileLoader(this, FileLoaderQueueStopTimeout)
|
||||
|
@ -3438,7 +3439,7 @@ void HistoryWidget::applyInlineBotQuery(UserData *bot, const QString &query) {
|
|||
inlineBotChanged();
|
||||
}
|
||||
if (!_inlineResults) {
|
||||
_inlineResults.create(this);
|
||||
_inlineResults.create(this, _controller);
|
||||
_inlineResults->setResultSelectedCallback([this](InlineBots::Result *result, UserData *bot) {
|
||||
onInlineResultSend(result, bot);
|
||||
});
|
||||
|
@ -4489,7 +4490,7 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re
|
|||
}
|
||||
|
||||
_scroll->hide();
|
||||
_list = _scroll->setOwnedWidget(object_ptr<HistoryInner>(this, _scroll, _history));
|
||||
_list = _scroll->setOwnedWidget(object_ptr<HistoryInner>(this, _controller, _scroll, _history));
|
||||
_list->show();
|
||||
|
||||
_updateHistoryItems.stop();
|
||||
|
|
|
@ -70,7 +70,7 @@ class HistoryInner : public TWidget, public Ui::AbstractTooltipShower, private b
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HistoryInner(HistoryWidget *historyWidget, Ui::ScrollArea *scroll, History *history);
|
||||
HistoryInner(HistoryWidget *historyWidget, gsl::not_null<Window::Controller*> controller, Ui::ScrollArea *scroll, History *history);
|
||||
|
||||
void messagesReceived(PeerData *peer, const QVector<MTPMessage> &messages);
|
||||
void messagesReceivedDown(PeerData *peer, const QVector<MTPMessage> &messages);
|
||||
|
@ -187,6 +187,8 @@ private:
|
|||
void scrollDateHide();
|
||||
void keepScrollDateForNow();
|
||||
|
||||
gsl::not_null<Window::Controller*> _controller;
|
||||
|
||||
PeerData *_peer = nullptr;
|
||||
History *_migrated = nullptr;
|
||||
History *_history = nullptr;
|
||||
|
|
|
@ -35,6 +35,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
|||
#include "apiwrap.h"
|
||||
#include "mainwidget.h"
|
||||
#include "auth_session.h"
|
||||
#include "window/window_controller.h"
|
||||
|
||||
namespace InlineBots {
|
||||
namespace Layout {
|
||||
|
@ -45,7 +46,8 @@ constexpr auto kInlineBotRequestDelay = 400;
|
|||
|
||||
} // namespace
|
||||
|
||||
Inner::Inner(QWidget *parent) : TWidget(parent) {
|
||||
Inner::Inner(QWidget *parent, gsl::not_null<Window::Controller*> controller) : TWidget(parent)
|
||||
, _controller(controller) {
|
||||
resize(st::emojiPanWidth - st::emojiScroll.width - st::buttonRadius, st::emojiPanMinHeight);
|
||||
|
||||
setMouseTracking(true);
|
||||
|
@ -60,8 +62,8 @@ Inner::Inner(QWidget *parent) : TWidget(parent) {
|
|||
subscribe(AuthSession::CurrentDownloaderTaskFinished(), [this] {
|
||||
update();
|
||||
});
|
||||
subscribe(App::wnd()->gifPauseLevelChanged(), [this] {
|
||||
if (!App::wnd()->isGifPausedAtLeastFor(Window::GifPauseReason::InlineResults)) {
|
||||
subscribe(controller->gifPauseLevelChanged(), [this] {
|
||||
if (!_controller->isGifPausedAtLeastFor(Window::GifPauseReason::InlineResults)) {
|
||||
update();
|
||||
}
|
||||
});
|
||||
|
@ -106,7 +108,7 @@ void Inner::paintInlineItems(Painter &p, const QRect &r) {
|
|||
p.drawText(QRect(0, 0, width(), (height() / 3) * 2 + st::normalFont->height), lang(lng_inline_bot_no_results), style::al_center);
|
||||
return;
|
||||
}
|
||||
auto gifPaused = App::wnd()->isGifPausedAtLeastFor(Window::GifPauseReason::InlineResults);
|
||||
auto gifPaused = _controller->isGifPausedAtLeastFor(Window::GifPauseReason::InlineResults);
|
||||
InlineBots::Layout::PaintContext context(getms(), false, gifPaused, false);
|
||||
|
||||
auto top = st::stickerPanPadding;
|
||||
|
@ -658,7 +660,8 @@ void Inner::onSwitchPm() {
|
|||
|
||||
} // namespace internal
|
||||
|
||||
Widget::Widget(QWidget *parent) : TWidget(parent)
|
||||
Widget::Widget(QWidget *parent, gsl::not_null<Window::Controller*> controller) : TWidget(parent)
|
||||
, _controller(controller)
|
||||
, _contentMaxHeight(st::emojiPanMaxHeight)
|
||||
, _contentHeight(_contentMaxHeight)
|
||||
, _scroll(this, st::inlineBotsScroll) {
|
||||
|
@ -669,7 +672,7 @@ Widget::Widget(QWidget *parent) : TWidget(parent)
|
|||
_scroll->resize(st::emojiPanWidth - st::buttonRadius, _contentHeight);
|
||||
|
||||
_scroll->move(verticalRect().topLeft());
|
||||
_inner = _scroll->setOwnedWidget(object_ptr<internal::Inner>(this));
|
||||
_inner = _scroll->setOwnedWidget(object_ptr<internal::Inner>(this, controller));
|
||||
|
||||
_inner->moveToLeft(0, 0, _scroll->width());
|
||||
|
||||
|
@ -872,7 +875,7 @@ Widget::~Widget() = default;
|
|||
|
||||
void Widget::hideFinished() {
|
||||
hide();
|
||||
App::wnd()->disableGifPauseReason(Window::GifPauseReason::InlineResults);
|
||||
_controller->disableGifPauseReason(Window::GifPauseReason::InlineResults);
|
||||
|
||||
_inner->hideFinish(true);
|
||||
_a_show.finish();
|
||||
|
@ -893,7 +896,7 @@ void Widget::showStarted() {
|
|||
recountContentMaxHeight();
|
||||
_inner->preloadImages();
|
||||
show();
|
||||
App::wnd()->enableGifPauseReason(Window::GifPauseReason::InlineResults);
|
||||
_controller->enableGifPauseReason(Window::GifPauseReason::InlineResults);
|
||||
startShowAnimation();
|
||||
} else if (_hiding) {
|
||||
startOpacityAnimation(false);
|
||||
|
|
|
@ -34,6 +34,10 @@ class RoundButton;
|
|||
class RippleAnimation;
|
||||
} // namesapce Ui
|
||||
|
||||
namespace Window {
|
||||
class Controller;
|
||||
} // namespace Window
|
||||
|
||||
namespace InlineBots {
|
||||
|
||||
class Result;
|
||||
|
@ -58,7 +62,7 @@ class Inner : public TWidget, public Context, private base::Subscriber {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Inner(QWidget *parent);
|
||||
Inner(QWidget *parent, gsl::not_null<Window::Controller*> controller);
|
||||
|
||||
void hideFinish(bool completely);
|
||||
|
||||
|
@ -111,6 +115,8 @@ private:
|
|||
|
||||
void refreshSwitchPmButton(const CacheEntry *entry);
|
||||
|
||||
gsl::not_null<Window::Controller*> _controller;
|
||||
|
||||
int _visibleTop = 0;
|
||||
int _visibleBottom = 0;
|
||||
|
||||
|
@ -158,7 +164,7 @@ class Widget : public TWidget, private MTP::Sender {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Widget(QWidget *parent);
|
||||
Widget(QWidget *parent, gsl::not_null<Window::Controller*> controller);
|
||||
|
||||
void moveBottom(int bottom);
|
||||
|
||||
|
@ -228,6 +234,8 @@ private:
|
|||
bool refreshInlineRows(int *added = nullptr);
|
||||
void inlineResultsDone(const MTPmessages_BotResults &result);
|
||||
|
||||
gsl::not_null<Window::Controller*> _controller;
|
||||
|
||||
int _contentMaxHeight = 0;
|
||||
int _contentHeight = 0;
|
||||
bool _horizontal = false;
|
||||
|
|
|
@ -33,6 +33,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
|||
#include "ui/widgets/shadow.h"
|
||||
#include "window/window_main_menu.h"
|
||||
#include "auth_session.h"
|
||||
#include "window/window_controller.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -311,7 +312,8 @@ void LayerStackWidget::BackgroundWidget::animationCallback() {
|
|||
checkIfDone();
|
||||
}
|
||||
|
||||
LayerStackWidget::LayerStackWidget(QWidget *parent) : TWidget(parent)
|
||||
LayerStackWidget::LayerStackWidget(QWidget *parent, Window::Controller *controller) : TWidget(parent)
|
||||
, _controller(controller)
|
||||
, _background(this) {
|
||||
setGeometry(parentWidget()->rect());
|
||||
hide();
|
||||
|
@ -565,7 +567,6 @@ void LayerStackWidget::animationDone() {
|
|||
}
|
||||
if (hidden) {
|
||||
App::wnd()->layerFinishedHide(this);
|
||||
App::wnd()->disableGifPauseReason(Window::GifPauseReason::Layer);
|
||||
} else {
|
||||
showFinished();
|
||||
}
|
||||
|
@ -622,7 +623,7 @@ LayerWidget *LayerStackWidget::pushBox(object_ptr<BoxContent> box) {
|
|||
if (oldLayer->inFocusChain()) setFocus();
|
||||
oldLayer->hide();
|
||||
}
|
||||
auto layer = object_ptr<AbstractBox>(this, std::move(box));
|
||||
auto layer = object_ptr<AbstractBox>(this, _controller, std::move(box));
|
||||
_layers.push_back(layer);
|
||||
initChildLayer(layer);
|
||||
|
||||
|
@ -644,7 +645,7 @@ void LayerStackWidget::prependBox(object_ptr<BoxContent> box) {
|
|||
if (_layers.empty()) {
|
||||
return showBox(std::move(box));
|
||||
}
|
||||
auto layer = object_ptr<AbstractBox>(this, std::move(box));
|
||||
auto layer = object_ptr<AbstractBox>(this, _controller, std::move(box));
|
||||
layer->hide();
|
||||
_layers.push_front(layer);
|
||||
initChildLayer(layer);
|
||||
|
@ -719,7 +720,8 @@ LayerStackWidget::~LayerStackWidget() {
|
|||
if (App::wnd()) App::wnd()->noLayerStack(this);
|
||||
}
|
||||
|
||||
MediaPreviewWidget::MediaPreviewWidget(QWidget *parent) : TWidget(parent)
|
||||
MediaPreviewWidget::MediaPreviewWidget(QWidget *parent, gsl::not_null<Window::Controller*> controller) : TWidget(parent)
|
||||
, _controller(controller)
|
||||
, _emojiSize(Ui::Emoji::Size(Ui::Emoji::Index() + 1) / cIntRetinaFactor()) {
|
||||
setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
subscribe(AuthSession::CurrentDownloaderTaskFinished(), [this] { update(); });
|
||||
|
@ -735,7 +737,7 @@ void MediaPreviewWidget::paintEvent(QPaintEvent *e) {
|
|||
if (!_a_shown.animating()) {
|
||||
if (_hiding) {
|
||||
hide();
|
||||
App::wnd()->disableGifPauseReason(Window::GifPauseReason::MediaPreview);
|
||||
_controller->disableGifPauseReason(Window::GifPauseReason::MediaPreview);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -792,7 +794,7 @@ void MediaPreviewWidget::startShow() {
|
|||
if (isHidden() || _a_shown.animating()) {
|
||||
if (isHidden()) {
|
||||
show();
|
||||
App::wnd()->enableGifPauseReason(Window::GifPauseReason::MediaPreview);
|
||||
_controller->enableGifPauseReason(Window::GifPauseReason::MediaPreview);
|
||||
}
|
||||
_hiding = false;
|
||||
_a_shown.start([this] { update(); }, 0., 1., st::stickerPreviewDuration);
|
||||
|
@ -926,7 +928,7 @@ QPixmap MediaPreviewWidget::currentImage() const {
|
|||
}
|
||||
if (_gif && _gif->started()) {
|
||||
auto s = currentDimensions();
|
||||
auto paused = App::wnd()->isGifPausedAtLeastFor(Window::GifPauseReason::MediaPreview);
|
||||
auto paused = _controller->isGifPausedAtLeastFor(Window::GifPauseReason::MediaPreview);
|
||||
return _gif->current(s.width(), s.height(), s.width(), s.height(), ImageRoundRadius::None, ImageRoundCorner::None, paused ? 0 : getms());
|
||||
}
|
||||
if (_cacheStatus != CacheThumbLoaded && _document->thumb->loaded()) {
|
||||
|
|
|
@ -22,6 +22,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
|||
|
||||
namespace Window {
|
||||
class MainMenu;
|
||||
class Controller;
|
||||
} // namespace Window
|
||||
|
||||
class LayerWidget : public TWidget {
|
||||
|
@ -83,8 +84,11 @@ class LayerStackWidget : public TWidget {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LayerStackWidget(QWidget *parent);
|
||||
LayerStackWidget(QWidget *parent, Window::Controller *controller);
|
||||
|
||||
Window::Controller *controller() const {
|
||||
return _controller;
|
||||
}
|
||||
void finishAnimation();
|
||||
|
||||
void showBox(object_ptr<BoxContent> box);
|
||||
|
@ -149,8 +153,9 @@ private:
|
|||
return const_cast<LayerStackWidget*>(this)->currentLayer();
|
||||
}
|
||||
|
||||
using Layers = QList<LayerWidget*>;
|
||||
Layers _layers;
|
||||
Window::Controller *_controller = nullptr;
|
||||
|
||||
QList<LayerWidget*> _layers;
|
||||
|
||||
object_ptr<LayerWidget> _specialLayer = { nullptr };
|
||||
object_ptr<Window::MainMenu> _mainMenu = { nullptr };
|
||||
|
@ -164,7 +169,7 @@ class MediaPreviewWidget : public TWidget, private base::Subscriber {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MediaPreviewWidget(QWidget *parent);
|
||||
MediaPreviewWidget(QWidget *parent, gsl::not_null<Window::Controller*> controller);
|
||||
|
||||
void showPreview(DocumentData *document);
|
||||
void showPreview(PhotoData *photo);
|
||||
|
@ -183,6 +188,8 @@ private:
|
|||
void fillEmojiString();
|
||||
void resetGifAndCache();
|
||||
|
||||
gsl::not_null<Window::Controller*> _controller;
|
||||
|
||||
Animation _a_shown;
|
||||
bool _hiding = false;
|
||||
DocumentData *_document = nullptr;
|
||||
|
|
|
@ -74,13 +74,13 @@ StackItemSection::StackItemSection(std::unique_ptr<Window::SectionMemento> &&mem
|
|||
StackItemSection::~StackItemSection() {
|
||||
}
|
||||
|
||||
MainWidget::MainWidget(QWidget *parent, std::unique_ptr<Window::Controller> controller) : TWidget(parent)
|
||||
, _controller(std::move(controller))
|
||||
MainWidget::MainWidget(QWidget *parent, gsl::not_null<Window::Controller*> controller) : TWidget(parent)
|
||||
, _controller(controller)
|
||||
, _dialogsWidth(st::dialogsWidthMin)
|
||||
, _sideShadow(this, st::shadowFg)
|
||||
, _sideResizeArea(this)
|
||||
, _dialogs(this, _controller.get())
|
||||
, _history(this, _controller.get())
|
||||
, _dialogs(this, _controller)
|
||||
, _history(this, _controller)
|
||||
, _playerPlaylist(this, Media::Player::Panel::Layout::OnlyPlaylist)
|
||||
, _playerPanel(this, Media::Player::Panel::Layout::Full) {
|
||||
Messenger::Instance().mtp()->setUpdatesHandler(rpcDone(&MainWidget::updateReceived));
|
||||
|
@ -1872,6 +1872,8 @@ void MainWidget::setInnerFocus() {
|
|||
_overview->activate();
|
||||
} else if (!_hider && _wideSection) {
|
||||
_wideSection->setInnerFocus();
|
||||
} else if (!_hider && _thirdSection) {
|
||||
_thirdSection->setInnerFocus();
|
||||
} else {
|
||||
dialogsActivate();
|
||||
}
|
||||
|
@ -1879,6 +1881,8 @@ void MainWidget::setInnerFocus() {
|
|||
_overview->activate();
|
||||
} else if (_wideSection) {
|
||||
_wideSection->setInnerFocus();
|
||||
} else if (_thirdSection) {
|
||||
_thirdSection->setInnerFocus();
|
||||
} else {
|
||||
_history->setInnerFocus();
|
||||
}
|
||||
|
@ -2372,7 +2376,7 @@ void MainWidget::showMediaOverview(PeerData *peer, MediaOverviewType type, bool
|
|||
_wideSection->deleteLater();
|
||||
_wideSection = nullptr;
|
||||
}
|
||||
_overview.create(this, _controller.get(), peer, type);
|
||||
_overview.create(this, _controller, peer, type);
|
||||
updateControlsGeometry();
|
||||
|
||||
// Send a fake update.
|
||||
|
@ -4198,8 +4202,6 @@ MainWidget::~MainWidget() {
|
|||
delete hider;
|
||||
}
|
||||
Messenger::Instance().mtp()->clearGlobalHandlers();
|
||||
|
||||
if (App::wnd()) App::wnd()->noMain(this);
|
||||
}
|
||||
|
||||
void MainWidget::updateOnline(bool gotOtherOffline) {
|
||||
|
|
|
@ -142,7 +142,7 @@ class MainWidget : public TWidget, public RPCSender, private base::Subscriber {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWidget(QWidget *parent, std::unique_ptr<Window::Controller> controller);
|
||||
MainWidget(QWidget *parent, gsl::not_null<Window::Controller*> controller);
|
||||
|
||||
bool needBackButton();
|
||||
|
||||
|
@ -495,7 +495,7 @@ private:
|
|||
|
||||
void saveSectionInStack();
|
||||
|
||||
std::unique_ptr<Window::Controller> _controller;
|
||||
gsl::not_null<Window::Controller*> _controller;
|
||||
bool _started = false;
|
||||
|
||||
SelectedItemSet _toForward;
|
||||
|
@ -570,6 +570,7 @@ private:
|
|||
object_ptr<DialogsWidget> _dialogs;
|
||||
object_ptr<HistoryWidget> _history;
|
||||
object_ptr<Window::SectionWidget> _wideSection = { nullptr };
|
||||
object_ptr<Window::SectionWidget> _thirdSection = { nullptr };
|
||||
object_ptr<OverviewWidget> _overview = { nullptr };
|
||||
|
||||
object_ptr<Window::PlayerWrapWidget> _player = { nullptr };
|
||||
|
|
|
@ -200,6 +200,7 @@ void MainWindow::clearWidgetsHook() {
|
|||
auto wasMain = (_main != nullptr);
|
||||
_passcode.destroyDelayed();
|
||||
_main.destroy();
|
||||
_controller.reset();
|
||||
_intro.destroy();
|
||||
if (wasMain) {
|
||||
App::clearHistories();
|
||||
|
@ -351,7 +352,8 @@ void MainWindow::setupMain(const MTPUser *self) {
|
|||
|
||||
t_assert(AuthSession::Exists());
|
||||
|
||||
_main.create(bodyWidget(), std::make_unique<Window::Controller>(this));
|
||||
_controller = std::make_unique<Window::Controller>(this);
|
||||
_main.create(bodyWidget(), controller());
|
||||
_main->show();
|
||||
updateControlsGeometry();
|
||||
|
||||
|
@ -391,15 +393,19 @@ void MainWindow::showMainMenu() {
|
|||
|
||||
void MainWindow::ensureLayerCreated() {
|
||||
if (!_layerBg) {
|
||||
_layerBg.create(bodyWidget());
|
||||
enableGifPauseReason(Window::GifPauseReason::Layer);
|
||||
_layerBg.create(bodyWidget(), _controller.get());
|
||||
if (_controller) {
|
||||
_controller->enableGifPauseReason(Window::GifPauseReason::Layer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::destroyLayerDelayed() {
|
||||
if (_layerBg) {
|
||||
_layerBg.destroyDelayed();
|
||||
disableGifPauseReason(Window::GifPauseReason::Layer);
|
||||
if (_controller) {
|
||||
_controller->disableGifPauseReason(Window::GifPauseReason::Layer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -474,7 +480,7 @@ bool MainWindow::ui_isLayerShown() {
|
|||
void MainWindow::ui_showMediaPreview(DocumentData *document) {
|
||||
if (!document || ((!document->isAnimation() || !document->loaded()) && !document->sticker())) return;
|
||||
if (!_mediaPreview) {
|
||||
_mediaPreview.create(bodyWidget());
|
||||
_mediaPreview.create(bodyWidget(), controller());
|
||||
updateControlsGeometry();
|
||||
}
|
||||
if (_mediaPreview->isHidden()) {
|
||||
|
@ -486,7 +492,7 @@ void MainWindow::ui_showMediaPreview(DocumentData *document) {
|
|||
void MainWindow::ui_showMediaPreview(PhotoData *photo) {
|
||||
if (!photo) return;
|
||||
if (!_mediaPreview) {
|
||||
_mediaPreview.create(bodyWidget());
|
||||
_mediaPreview.create(bodyWidget(), controller());
|
||||
updateControlsGeometry();
|
||||
}
|
||||
if (_mediaPreview->isHidden()) {
|
||||
|
@ -761,16 +767,12 @@ void MainWindow::noIntro(Intro::Widget *was) {
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::noMain(MainWidget *was) {
|
||||
if (was == _main) {
|
||||
_main = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::noLayerStack(LayerStackWidget *was) {
|
||||
if (was == _layerBg) {
|
||||
_layerBg = nullptr;
|
||||
disableGifPauseReason(Window::GifPauseReason::Layer);
|
||||
if (_controller) {
|
||||
_controller->disableGifPauseReason(Window::GifPauseReason::Layer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ namespace Theme {
|
|||
struct BackgroundUpdate;
|
||||
class WarningWidget;
|
||||
} // namespace Theme
|
||||
class Controller;
|
||||
} // namespace Window
|
||||
|
||||
namespace Ui {
|
||||
|
@ -78,6 +79,10 @@ public:
|
|||
MainWindow();
|
||||
~MainWindow();
|
||||
|
||||
Window::Controller *controller() const {
|
||||
return _controller.get();
|
||||
}
|
||||
|
||||
void firstShow();
|
||||
|
||||
void inactivePress(bool inactive);
|
||||
|
@ -103,7 +108,6 @@ public:
|
|||
void activate();
|
||||
|
||||
void noIntro(Intro::Widget *was);
|
||||
void noMain(MainWidget *was);
|
||||
void noLayerStack(LayerStackWidget *was);
|
||||
void layerFinishedHide(LayerStackWidget *was);
|
||||
|
||||
|
@ -218,6 +222,7 @@ private:
|
|||
QList<DelayedServiceMsg> _delayedServiceMsgs;
|
||||
mtpRequestId _serviceHistoryRequest = 0;
|
||||
|
||||
std::unique_ptr<Window::Controller> _controller;
|
||||
object_ptr<PasscodeWidget> _passcode = { nullptr };
|
||||
object_ptr<Intro::Widget> _intro = { nullptr };
|
||||
object_ptr<MainWidget> _main = { nullptr };
|
||||
|
|
|
@ -372,32 +372,6 @@ PeerData *MainWindow::ui_getPeerForMouseAction() {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void MainWindow::enableGifPauseReason(GifPauseReason reason) {
|
||||
if (!(_gifPauseReasons & reason)) {
|
||||
auto notify = (static_cast<int>(_gifPauseReasons) < static_cast<int>(reason));
|
||||
_gifPauseReasons |= reason;
|
||||
if (notify) {
|
||||
_gifPauseLevelChanged.notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::disableGifPauseReason(GifPauseReason reason) {
|
||||
if (_gifPauseReasons & reason) {
|
||||
_gifPauseReasons &= ~qFlags(reason);
|
||||
if (static_cast<int>(_gifPauseReasons) < static_cast<int>(reason)) {
|
||||
_gifPauseLevelChanged.notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool MainWindow::isGifPausedAtLeastFor(GifPauseReason reason) const {
|
||||
if (reason == GifPauseReason::Any) {
|
||||
return (_gifPauseReasons != 0) || !isActive();
|
||||
}
|
||||
return (static_cast<int>(_gifPauseReasons) >= 2 * static_cast<int>(reason)) || !isActive();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() = default;
|
||||
|
||||
} // namespace Window
|
||||
|
|
|
@ -26,16 +26,6 @@ class MediaView;
|
|||
|
||||
namespace Window {
|
||||
|
||||
enum class GifPauseReason {
|
||||
Any = 0,
|
||||
InlineResults = (1 << 0),
|
||||
SavedGifs = (1 << 1),
|
||||
Layer = (1 << 2),
|
||||
MediaPreview = (1 << 3),
|
||||
};
|
||||
Q_DECLARE_FLAGS(GifPauseReasons, GifPauseReason);
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(GifPauseReasons);
|
||||
|
||||
class TitleWidget;
|
||||
|
||||
class MainWindow : public QWidget, protected base::Subscriber {
|
||||
|
@ -94,13 +84,6 @@ public:
|
|||
}
|
||||
virtual PeerData *ui_getPeerForMouseAction();
|
||||
|
||||
void enableGifPauseReason(GifPauseReason reason);
|
||||
void disableGifPauseReason(GifPauseReason reason);
|
||||
base::Observable<void> &gifPauseLevelChanged() {
|
||||
return _gifPauseLevelChanged;
|
||||
}
|
||||
bool isGifPausedAtLeastFor(GifPauseReason reason) const;
|
||||
|
||||
public slots:
|
||||
bool minimizeToTray();
|
||||
void updateGlobalMenu() {
|
||||
|
@ -186,9 +169,6 @@ private:
|
|||
|
||||
object_ptr<MediaView> _mediaView = { nullptr };
|
||||
|
||||
GifPauseReasons _gifPauseReasons = { 0 };
|
||||
base::Observable<void> _gifPauseLevelChanged;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Window
|
||||
|
|
|
@ -20,3 +20,34 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
|||
*/
|
||||
#include "window/window_controller.h"
|
||||
|
||||
#include "window/main_window.h"
|
||||
|
||||
namespace Window {
|
||||
|
||||
void Controller::enableGifPauseReason(GifPauseReason reason) {
|
||||
if (!(_gifPauseReasons & reason)) {
|
||||
auto notify = (static_cast<int>(_gifPauseReasons) < static_cast<int>(reason));
|
||||
_gifPauseReasons |= reason;
|
||||
if (notify) {
|
||||
_gifPauseLevelChanged.notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Controller::disableGifPauseReason(GifPauseReason reason) {
|
||||
if (_gifPauseReasons & reason) {
|
||||
_gifPauseReasons &= ~qFlags(reason);
|
||||
if (static_cast<int>(_gifPauseReasons) < static_cast<int>(reason)) {
|
||||
_gifPauseLevelChanged.notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Controller::isGifPausedAtLeastFor(GifPauseReason reason) const {
|
||||
if (reason == GifPauseReason::Any) {
|
||||
return (_gifPauseReasons != 0) || !window()->isActive();
|
||||
}
|
||||
return (static_cast<int>(_gifPauseReasons) >= 2 * static_cast<int>(reason)) || !window()->isActive();
|
||||
}
|
||||
|
||||
} // namespace Window
|
||||
|
|
|
@ -22,9 +22,25 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
|||
|
||||
namespace Window {
|
||||
|
||||
enum class GifPauseReason {
|
||||
Any = 0,
|
||||
InlineResults = (1 << 0),
|
||||
SavedGifs = (1 << 1),
|
||||
Layer = (1 << 2),
|
||||
MediaPreview = (1 << 3),
|
||||
};
|
||||
Q_DECLARE_FLAGS(GifPauseReasons, GifPauseReason);
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(GifPauseReasons);
|
||||
|
||||
class MainWindow;
|
||||
|
||||
class Controller {
|
||||
public:
|
||||
Controller(MainWindow *window) : _window(window) {
|
||||
Controller(gsl::not_null<MainWindow*> window) : _window(window) {
|
||||
}
|
||||
|
||||
gsl::not_null<MainWindow*> window() const {
|
||||
return _window;
|
||||
}
|
||||
|
||||
// This is needed for History TopBar updating when searchInPeer
|
||||
|
@ -40,11 +56,22 @@ public:
|
|||
return _historyPeerChanged;
|
||||
}
|
||||
|
||||
void enableGifPauseReason(GifPauseReason reason);
|
||||
void disableGifPauseReason(GifPauseReason reason);
|
||||
base::Observable<void> &gifPauseLevelChanged() {
|
||||
return _gifPauseLevelChanged;
|
||||
}
|
||||
bool isGifPausedAtLeastFor(GifPauseReason reason) const;
|
||||
|
||||
private:
|
||||
gsl::not_null<MainWindow*> _window;
|
||||
|
||||
base::Observable<PeerData*> _searchInPeerChanged;
|
||||
base::Observable<PeerData*> _historyPeerChanged;
|
||||
|
||||
GifPauseReasons _gifPauseReasons = { 0 };
|
||||
base::Observable<void> _gifPauseLevelChanged;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Window
|
||||
|
|
|
@ -83,6 +83,8 @@
|
|||
<(src_loc)/chat_helpers/emoji_panel.h
|
||||
<(src_loc)/chat_helpers/emoji_list_widget.cpp
|
||||
<(src_loc)/chat_helpers/emoji_list_widget.h
|
||||
<(src_loc)/chat_helpers/emoji_section.cpp
|
||||
<(src_loc)/chat_helpers/emoji_section.h
|
||||
<(src_loc)/chat_helpers/field_autocomplete.cpp
|
||||
<(src_loc)/chat_helpers/field_autocomplete.h
|
||||
<(src_loc)/chat_helpers/gifs_list_widget.cpp
|
||||
|
|
Loading…
Add table
Reference in a new issue