mirror of https://github.com/procxx/kepka.git
Rename EmojiPanelTab to ChatHelpers::SelectorTab.
This commit is contained in:
parent
75dcce0b3c
commit
18195f9c4e
|
@ -29,6 +29,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
|||
#include "platform/platform_specific.h"
|
||||
#include "calls/calls_instance.h"
|
||||
#include "window/section_widget.h"
|
||||
#include "chat_helpers/tabbed_selector.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -37,7 +38,8 @@ constexpr auto kAutoLockTimeoutLateMs = TimeMs(3000);
|
|||
} // namespace
|
||||
|
||||
AuthSessionData::Variables::Variables()
|
||||
: floatPlayerColumn(Window::Column::Second)
|
||||
: selectorTab(ChatHelpers::SelectorTab::Emoji)
|
||||
, floatPlayerColumn(Window::Column::Second)
|
||||
, floatPlayerCorner(Window::Corner::TopRight) {
|
||||
}
|
||||
|
||||
|
@ -57,7 +59,7 @@ QByteArray AuthSessionData::serialize() const {
|
|||
|
||||
QDataStream stream(&buffer);
|
||||
stream.setVersion(QDataStream::Qt_5_1);
|
||||
stream << static_cast<qint32>(_variables.emojiPanelTab);
|
||||
stream << static_cast<qint32>(_variables.selectorTab);
|
||||
stream << qint32(_variables.lastSeenWarningSeen ? 1 : 0);
|
||||
stream << qint32(_variables.tabbedSelectorSectionEnabled ? 1 : 0);
|
||||
stream << qint32(_variables.soundOverrides.size());
|
||||
|
@ -83,14 +85,14 @@ void AuthSessionData::constructFromSerialized(const QByteArray &serialized) {
|
|||
}
|
||||
QDataStream stream(&buffer);
|
||||
stream.setVersion(QDataStream::Qt_5_1);
|
||||
qint32 emojiPanTab = static_cast<qint32>(EmojiPanelTab::Emoji);
|
||||
qint32 selectorTab = static_cast<qint32>(ChatHelpers::SelectorTab::Emoji);
|
||||
qint32 lastSeenWarningSeen = 0;
|
||||
qint32 tabbedSelectorSectionEnabled = 1;
|
||||
qint32 tabbedSelectorSectionTooltipShown = 0;
|
||||
qint32 floatPlayerColumn = static_cast<qint32>(Window::Column::Second);
|
||||
qint32 floatPlayerCorner = static_cast<qint32>(Window::Corner::TopRight);
|
||||
QMap<QString, QString> soundOverrides;
|
||||
stream >> emojiPanTab;
|
||||
stream >> selectorTab;
|
||||
stream >> lastSeenWarningSeen;
|
||||
if (!stream.atEnd()) {
|
||||
stream >> tabbedSelectorSectionEnabled;
|
||||
|
@ -117,11 +119,11 @@ void AuthSessionData::constructFromSerialized(const QByteArray &serialized) {
|
|||
return;
|
||||
}
|
||||
|
||||
auto uncheckedTab = static_cast<EmojiPanelTab>(emojiPanTab);
|
||||
auto uncheckedTab = static_cast<ChatHelpers::SelectorTab>(selectorTab);
|
||||
switch (uncheckedTab) {
|
||||
case EmojiPanelTab::Emoji:
|
||||
case EmojiPanelTab::Stickers:
|
||||
case EmojiPanelTab::Gifs: _variables.emojiPanelTab = uncheckedTab; break;
|
||||
case ChatHelpers::SelectorTab::Emoji:
|
||||
case ChatHelpers::SelectorTab::Stickers:
|
||||
case ChatHelpers::SelectorTab::Gifs: _variables.selectorTab = uncheckedTab; break;
|
||||
}
|
||||
_variables.lastSeenWarningSeen = (lastSeenWarningSeen == 1);
|
||||
_variables.tabbedSelectorSectionEnabled = (tabbedSelectorSectionEnabled == 1);
|
||||
|
|
|
@ -38,13 +38,11 @@ namespace Calls {
|
|||
class Instance;
|
||||
} // namespace Calls
|
||||
|
||||
class ApiWrap;
|
||||
namespace ChatHelpers {
|
||||
enum class SelectorTab;
|
||||
} // namespace ChatHelpers
|
||||
|
||||
enum class EmojiPanelTab {
|
||||
Emoji,
|
||||
Stickers,
|
||||
Gifs,
|
||||
};
|
||||
class ApiWrap;
|
||||
|
||||
class AuthSessionData final {
|
||||
public:
|
||||
|
@ -73,11 +71,11 @@ public:
|
|||
void setLastSeenWarningSeen(bool lastSeenWarningSeen) {
|
||||
_variables.lastSeenWarningSeen = lastSeenWarningSeen;
|
||||
}
|
||||
EmojiPanelTab emojiPanelTab() const {
|
||||
return _variables.emojiPanelTab;
|
||||
ChatHelpers::SelectorTab selectorTab() const {
|
||||
return _variables.selectorTab;
|
||||
}
|
||||
void setEmojiPanelTab(EmojiPanelTab tab) {
|
||||
_variables.emojiPanelTab = tab;
|
||||
void setSelectorTab(ChatHelpers::SelectorTab tab) {
|
||||
_variables.selectorTab = tab;
|
||||
}
|
||||
bool tabbedSelectorSectionEnabled() const {
|
||||
return _variables.tabbedSelectorSectionEnabled;
|
||||
|
@ -122,7 +120,7 @@ private:
|
|||
Variables();
|
||||
|
||||
bool lastSeenWarningSeen = false;
|
||||
EmojiPanelTab emojiPanelTab = EmojiPanelTab::Emoji;
|
||||
ChatHelpers::SelectorTab selectorTab;
|
||||
bool tabbedSelectorSectionEnabled = true;
|
||||
int tabbedSelectorSectionTooltipShown = 0;
|
||||
QMap<QString, QString> soundOverrides;
|
||||
|
|
|
@ -42,13 +42,13 @@ TabbedPanel::TabbedPanel(QWidget *parent, gsl::not_null<Window::Controller*> con
|
|||
, _selector(std::move(selector)) {
|
||||
_selector->setParent(this);
|
||||
_selector->setRoundRadius(st::buttonRadius);
|
||||
_selector->setAfterShownCallback([this](EmojiPanelTab tab) {
|
||||
if (tab == EmojiPanelTab::Gifs) {
|
||||
_selector->setAfterShownCallback([this](SelectorTab tab) {
|
||||
if (tab == SelectorTab::Gifs) {
|
||||
_controller->enableGifPauseReason(Window::GifPauseReason::SavedGifs);
|
||||
}
|
||||
});
|
||||
_selector->setBeforeHidingCallback([this](EmojiPanelTab tab) {
|
||||
if (tab == EmojiPanelTab::Gifs) {
|
||||
_selector->setBeforeHidingCallback([this](SelectorTab tab) {
|
||||
if (tab == SelectorTab::Gifs) {
|
||||
_controller->disableGifPauseReason(Window::GifPauseReason::SavedGifs);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -42,8 +42,8 @@ TabbedSection::TabbedSection(QWidget *parent, gsl::not_null<Window::Controller*>
|
|||
_cancelledCallback();
|
||||
}
|
||||
});
|
||||
_selector->setAfterShownCallback(base::lambda<void(EmojiPanelTab)>());
|
||||
_selector->setBeforeHidingCallback(base::lambda<void(EmojiPanelTab)>());
|
||||
_selector->setAfterShownCallback(base::lambda<void(SelectorTab)>());
|
||||
_selector->setBeforeHidingCallback(base::lambda<void(SelectorTab)>());
|
||||
|
||||
setAttribute(Qt::WA_OpaquePaintEvent, true);
|
||||
}
|
||||
|
|
|
@ -258,7 +258,7 @@ void TabbedSelector::SlideAnimation::paintFrame(QPainter &p, float64 dt, float64
|
|||
p.drawImage(outerLeft / cIntRetinaFactor(), outerTop / cIntRetinaFactor(), _frame, outerLeft, outerTop, outerRight - outerLeft, outerBottom - outerTop);
|
||||
}
|
||||
|
||||
TabbedSelector::Tab::Tab(TabType type, object_ptr<Inner> widget)
|
||||
TabbedSelector::Tab::Tab(SelectorTab type, object_ptr<Inner> widget)
|
||||
: _type(type)
|
||||
, _widget(std::move(widget))
|
||||
, _weak(_widget)
|
||||
|
@ -285,11 +285,11 @@ TabbedSelector::TabbedSelector(QWidget *parent, gsl::not_null<Window::Controller
|
|||
, _bottomShadow(this, st::shadowFg)
|
||||
, _scroll(this, st::emojiScroll)
|
||||
, _tabs { {
|
||||
Tab { TabType::Emoji, object_ptr<EmojiListWidget>(this, controller) },
|
||||
Tab { TabType::Stickers, object_ptr<StickersListWidget>(this, controller) },
|
||||
Tab { TabType::Gifs, object_ptr<GifsListWidget>(this, controller) },
|
||||
Tab { SelectorTab::Emoji, object_ptr<EmojiListWidget>(this, controller) },
|
||||
Tab { SelectorTab::Stickers, object_ptr<StickersListWidget>(this, controller) },
|
||||
Tab { SelectorTab::Gifs, object_ptr<GifsListWidget>(this, controller) },
|
||||
} }
|
||||
, _currentTabType(AuthSession::Current().data().emojiPanelTab()) {
|
||||
, _currentTabType(AuthSession::Current().data().selectorTab()) {
|
||||
resize(st::emojiPanWidth, st::emojiPanMaxHeight);
|
||||
|
||||
for (auto &tab : _tabs) {
|
||||
|
@ -394,7 +394,7 @@ void TabbedSelector::paintSlideFrame(Painter &p, TimeMs ms) {
|
|||
}
|
||||
|
||||
void TabbedSelector::paintContent(Painter &p) {
|
||||
auto showSectionIcons = (_currentTabType != TabType::Gifs);
|
||||
auto showSectionIcons = (_currentTabType != SelectorTab::Gifs);
|
||||
auto &bottomBg = showSectionIcons ? st::emojiPanCategories : st::emojiPanBg;
|
||||
if (_roundRadius > 0) {
|
||||
auto topPart = QRect(0, 0, width(), _tabsSlider->height() + _roundRadius);
|
||||
|
@ -424,7 +424,7 @@ int TabbedSelector::marginBottom() const {
|
|||
|
||||
void TabbedSelector::refreshStickers() {
|
||||
stickers()->refreshStickers();
|
||||
if (isHidden() || _currentTabType != TabType::Stickers) {
|
||||
if (isHidden() || _currentTabType != SelectorTab::Stickers) {
|
||||
stickers()->preloadImages();
|
||||
}
|
||||
}
|
||||
|
@ -500,7 +500,7 @@ void TabbedSelector::afterShown() {
|
|||
}
|
||||
|
||||
void TabbedSelector::stickersInstalled(uint64 setId) {
|
||||
_tabsSlider->setActiveSection(static_cast<int>(TabType::Stickers));
|
||||
_tabsSlider->setActiveSection(static_cast<int>(SelectorTab::Stickers));
|
||||
stickers()->showStickerSet(setId);
|
||||
}
|
||||
|
||||
|
@ -512,7 +512,7 @@ void TabbedSelector::showAll() {
|
|||
currentTab()->footer()->show();
|
||||
_scroll->show();
|
||||
_topShadow->show();
|
||||
_bottomShadow->setVisible(_currentTabType == TabType::Gifs);
|
||||
_bottomShadow->setVisible(_currentTabType == SelectorTab::Gifs);
|
||||
_tabsSlider->show();
|
||||
}
|
||||
|
||||
|
@ -554,7 +554,7 @@ void TabbedSelector::createTabsSlider() {
|
|||
void TabbedSelector::switchTab() {
|
||||
auto tab = _tabsSlider->activeSection();
|
||||
t_assert(tab >= 0 && tab < Tab::kCount);
|
||||
auto newTabType = static_cast<TabType>(tab);
|
||||
auto newTabType = static_cast<SelectorTab>(tab);
|
||||
if (_currentTabType == newTabType) {
|
||||
return;
|
||||
}
|
||||
|
@ -597,20 +597,20 @@ void TabbedSelector::switchTab() {
|
|||
_a_slide.start([this] { update(); }, 0., 1., st::emojiPanSlideDuration, anim::linear);
|
||||
update();
|
||||
|
||||
AuthSession::Current().data().setEmojiPanelTab(_currentTabType);
|
||||
AuthSession::Current().data().setSelectorTab(_currentTabType);
|
||||
AuthSession::Current().saveDataDelayed(kSaveChosenTabTimeout);
|
||||
}
|
||||
|
||||
gsl::not_null<EmojiListWidget*> TabbedSelector::emoji() const {
|
||||
return static_cast<EmojiListWidget*>(getTab(TabType::Emoji)->widget().get());
|
||||
return static_cast<EmojiListWidget*>(getTab(SelectorTab::Emoji)->widget().get());
|
||||
}
|
||||
|
||||
gsl::not_null<StickersListWidget*> TabbedSelector::stickers() const {
|
||||
return static_cast<StickersListWidget*>(getTab(TabType::Stickers)->widget().get());
|
||||
return static_cast<StickersListWidget*>(getTab(SelectorTab::Stickers)->widget().get());
|
||||
}
|
||||
|
||||
gsl::not_null<GifsListWidget*> TabbedSelector::gifs() const {
|
||||
return static_cast<GifsListWidget*>(getTab(TabType::Gifs)->widget().get());
|
||||
return static_cast<GifsListWidget*>(getTab(SelectorTab::Gifs)->widget().get());
|
||||
}
|
||||
|
||||
void TabbedSelector::setWidgetToScrollArea() {
|
||||
|
|
|
@ -41,6 +41,12 @@ class Controller;
|
|||
|
||||
namespace ChatHelpers {
|
||||
|
||||
enum class SelectorTab {
|
||||
Emoji,
|
||||
Stickers,
|
||||
Gifs,
|
||||
};
|
||||
|
||||
class EmojiListWidget;
|
||||
class StickersListWidget;
|
||||
class GifsListWidget;
|
||||
|
@ -69,11 +75,10 @@ public:
|
|||
return _a_slide.animating();
|
||||
}
|
||||
|
||||
using TabType = EmojiPanelTab;
|
||||
void setAfterShownCallback(base::lambda<void(TabType)> callback) {
|
||||
void setAfterShownCallback(base::lambda<void(SelectorTab)> callback) {
|
||||
_afterShownCallback = std::move(callback);
|
||||
}
|
||||
void setBeforeHidingCallback(base::lambda<void(TabType)> callback) {
|
||||
void setBeforeHidingCallback(base::lambda<void(SelectorTab)> callback) {
|
||||
_beforeHidingCallback = std::move(callback);
|
||||
}
|
||||
|
||||
|
@ -110,12 +115,12 @@ private:
|
|||
public:
|
||||
static constexpr auto kCount = 3;
|
||||
|
||||
Tab(TabType type, object_ptr<Inner> widget);
|
||||
Tab(SelectorTab type, object_ptr<Inner> widget);
|
||||
|
||||
object_ptr<Inner> takeWidget();
|
||||
void returnWidget(object_ptr<Inner> widget);
|
||||
|
||||
TabType type() const {
|
||||
SelectorTab type() const {
|
||||
return _type;
|
||||
}
|
||||
gsl::not_null<Inner*> widget() const {
|
||||
|
@ -134,7 +139,7 @@ private:
|
|||
}
|
||||
|
||||
private:
|
||||
TabType _type = TabType::Emoji;
|
||||
SelectorTab _type = SelectorTab::Emoji;
|
||||
object_ptr<Inner> _widget = { nullptr };
|
||||
QPointer<Inner> _weak;
|
||||
object_ptr<InnerFooter> _footer;
|
||||
|
@ -155,10 +160,10 @@ private:
|
|||
void setWidgetToScrollArea();
|
||||
void createTabsSlider();
|
||||
void switchTab();
|
||||
gsl::not_null<Tab*> getTab(TabType type) {
|
||||
gsl::not_null<Tab*> getTab(SelectorTab type) {
|
||||
return &_tabs[static_cast<int>(type)];
|
||||
}
|
||||
gsl::not_null<const Tab*> getTab(TabType type) const {
|
||||
gsl::not_null<const Tab*> getTab(SelectorTab type) const {
|
||||
return &_tabs[static_cast<int>(type)];
|
||||
}
|
||||
gsl::not_null<Tab*> currentTab() {
|
||||
|
@ -183,10 +188,10 @@ private:
|
|||
object_ptr<Ui::PlainShadow> _bottomShadow;
|
||||
object_ptr<Ui::ScrollArea> _scroll;
|
||||
std::array<Tab, Tab::kCount> _tabs;
|
||||
TabType _currentTabType = TabType::Emoji;
|
||||
SelectorTab _currentTabType = SelectorTab::Emoji;
|
||||
|
||||
base::lambda<void(TabType)> _afterShownCallback;
|
||||
base::lambda<void(TabType)> _beforeHidingCallback;
|
||||
base::lambda<void(SelectorTab)> _afterShownCallback;
|
||||
base::lambda<void(SelectorTab)> _beforeHidingCallback;
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue