mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +02:00
Added ability to switch tab in tabbed selector with swipe.
This commit is contained in:
parent
4c74cbbbe9
commit
acb0b029b9
2 changed files with 49 additions and 0 deletions
|
@ -35,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/stickers/data_stickers.h"
|
#include "data/stickers/data_stickers.h"
|
||||||
#include "data/stickers/data_custom_emoji.h" // AllowEmojiWithoutPremium.
|
#include "data/stickers/data_custom_emoji.h" // AllowEmojiWithoutPremium.
|
||||||
#include "boxes/premium_preview_box.h"
|
#include "boxes/premium_preview_box.h"
|
||||||
|
#include "history/history_view_swipe.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
|
@ -522,6 +523,7 @@ TabbedSelector::TabbedSelector(
|
||||||
if (hasEmojiTab()) {
|
if (hasEmojiTab()) {
|
||||||
emoji()->refreshEmoji();
|
emoji()->refreshEmoji();
|
||||||
}
|
}
|
||||||
|
setupSwipe();
|
||||||
//setAttribute(Qt::WA_AcceptTouchEvents);
|
//setAttribute(Qt::WA_AcceptTouchEvents);
|
||||||
setAttribute(Qt::WA_OpaquePaintEvent, false);
|
setAttribute(Qt::WA_OpaquePaintEvent, false);
|
||||||
showAll();
|
showAll();
|
||||||
|
@ -530,6 +532,48 @@ TabbedSelector::TabbedSelector(
|
||||||
|
|
||||||
TabbedSelector::~TabbedSelector() = default;
|
TabbedSelector::~TabbedSelector() = default;
|
||||||
|
|
||||||
|
void TabbedSelector::setupSwipe() {
|
||||||
|
HistoryView::SetupSwipeHandler(this, _scroll.data(), [=](
|
||||||
|
HistoryView::ChatPaintGestureHorizontalData data) {
|
||||||
|
if (data.translation != 0) {
|
||||||
|
if (!_swipeBackData.callback) {
|
||||||
|
_swipeBackData = HistoryView::SetupSwipeBack(
|
||||||
|
this,
|
||||||
|
[=]() -> std::pair<QColor, QColor> {
|
||||||
|
return {
|
||||||
|
st::historyForwardChooseBg->c,
|
||||||
|
st::historyForwardChooseFg->c,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
data.translation < 0);
|
||||||
|
}
|
||||||
|
_swipeBackData.callback(data);
|
||||||
|
return;
|
||||||
|
} else if (_swipeBackData.lifetime) {
|
||||||
|
_swipeBackData = {};
|
||||||
|
}
|
||||||
|
}, [=](int, Qt::LayoutDirection direction) {
|
||||||
|
if (!_tabsSlider) {
|
||||||
|
return HistoryView::SwipeHandlerFinishData();
|
||||||
|
}
|
||||||
|
const auto activeSection = _tabsSlider->activeSection();
|
||||||
|
const auto isToLeft = direction == Qt::RightToLeft;
|
||||||
|
if ((isToLeft && activeSection > 0)
|
||||||
|
|| (!isToLeft && activeSection < _tabs.size() - 1)) {
|
||||||
|
return HistoryView::DefaultSwipeBackHandlerFinishData([=] {
|
||||||
|
if (_tabsSlider
|
||||||
|
&& _tabsSlider->activeSection() == activeSection) {
|
||||||
|
_swipeBackData = {};
|
||||||
|
_tabsSlider->setActiveSection(isToLeft
|
||||||
|
? activeSection - 1
|
||||||
|
: activeSection + 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return HistoryView::SwipeHandlerFinishData();
|
||||||
|
}, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
const style::EmojiPan &TabbedSelector::st() const {
|
const style::EmojiPan &TabbedSelector::st() const {
|
||||||
return _st;
|
return _st;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/effects/animations.h"
|
#include "ui/effects/animations.h"
|
||||||
#include "ui/effects/message_sending_animation_common.h"
|
#include "ui/effects/message_sending_animation_common.h"
|
||||||
#include "ui/effects/panel_animation.h"
|
#include "ui/effects/panel_animation.h"
|
||||||
|
#include "history/history_view_swipe_data.h"
|
||||||
#include "ui/cached_round_corners.h"
|
#include "ui/cached_round_corners.h"
|
||||||
#include "mtproto/sender.h"
|
#include "mtproto/sender.h"
|
||||||
#include "base/object_ptr.h"
|
#include "base/object_ptr.h"
|
||||||
|
@ -287,12 +288,16 @@ private:
|
||||||
not_null<GifsListWidget*> gifs() const;
|
not_null<GifsListWidget*> gifs() const;
|
||||||
not_null<StickersListWidget*> masks() const;
|
not_null<StickersListWidget*> masks() const;
|
||||||
|
|
||||||
|
void setupSwipe();
|
||||||
|
|
||||||
const style::EmojiPan &_st;
|
const style::EmojiPan &_st;
|
||||||
const ComposeFeatures _features;
|
const ComposeFeatures _features;
|
||||||
const std::shared_ptr<Show> _show;
|
const std::shared_ptr<Show> _show;
|
||||||
const PauseReason _level = {};
|
const PauseReason _level = {};
|
||||||
const Fn<QColor()> _customTextColor;
|
const Fn<QColor()> _customTextColor;
|
||||||
|
|
||||||
|
HistoryView::SwipeBackResult _swipeBackData;
|
||||||
|
|
||||||
Mode _mode = Mode::Full;
|
Mode _mode = Mode::Full;
|
||||||
int _roundRadius = 0;
|
int _roundRadius = 0;
|
||||||
int _footerTop = 0;
|
int _footerTop = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue