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