mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +02:00
Moved out active quick action from total list of quick dialog actions.
This commit is contained in:
parent
47506d70ed
commit
c085691c54
4 changed files with 106 additions and 64 deletions
|
@ -831,18 +831,34 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
bool mayBeActive) {
|
bool mayBeActive) {
|
||||||
const auto &key = row->key();
|
const auto &key = row->key();
|
||||||
const auto active = mayBeActive && isRowActive(row, activeEntry);
|
const auto active = mayBeActive && isRowActive(row, activeEntry);
|
||||||
const auto forum = key.history() && key.history()->isForum();
|
const auto history = key.history();
|
||||||
|
const auto forum = history && history->isForum();
|
||||||
if (forum && !_topicJumpCache) {
|
if (forum && !_topicJumpCache) {
|
||||||
_topicJumpCache = std::make_unique<Ui::TopicJumpCache>();
|
_topicJumpCache = std::make_unique<Ui::TopicJumpCache>();
|
||||||
}
|
}
|
||||||
const auto expanding = forum
|
const auto expanding = forum
|
||||||
&& (key.history()->peer->id == childListShown.peerId);
|
&& (history->peer->id == childListShown.peerId);
|
||||||
context.rightButton = maybeCacheRightButton(row);
|
context.rightButton = maybeCacheRightButton(row);
|
||||||
if (key.history()) {
|
if (history) {
|
||||||
const auto it = _quickActions.find(key.history()->peer->id.value);
|
if (_activeQuickAction
|
||||||
context.quickActionContext = (it != _quickActions.end())
|
&& (_activeQuickAction->data.msgBareId
|
||||||
? it->second.get()
|
== history->peer->id.value)) {
|
||||||
: nullptr;
|
context.quickActionContext = _activeQuickAction.get();
|
||||||
|
} else if (!_inactiveQuickActions.empty()) {
|
||||||
|
auto it = _inactiveQuickActions.begin();
|
||||||
|
while (it != _inactiveQuickActions.end()) {
|
||||||
|
const auto raw = it->get();
|
||||||
|
if ((!raw->ripple || raw->ripple->empty())
|
||||||
|
&& (!raw->rippleFg || raw->rippleFg->empty())) {
|
||||||
|
_inactiveQuickActions.erase(it);
|
||||||
|
} else {
|
||||||
|
if (raw->data.msgBareId == history->peer->id.value) {
|
||||||
|
context.quickActionContext = raw;
|
||||||
|
}
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
context.st = (forum ? &st::forumDialogRow : _st.get());
|
context.st = (forum ? &st::forumDialogRow : _st.get());
|
||||||
|
@ -868,7 +884,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
}
|
}
|
||||||
if (active
|
if (active
|
||||||
&& (filter.flags() & Data::ChatFilter::Flag::NoRead)
|
&& (filter.flags() & Data::ChatFilter::Flag::NoRead)
|
||||||
&& !filter.contains(key.history(), true)) {
|
&& !filter.contains(history, true)) {
|
||||||
// Hack for History::fakeUnreadWhileOpened().
|
// Hack for History::fakeUnreadWhileOpened().
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -923,6 +939,9 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
&& _selectedTopicJump
|
&& _selectedTopicJump
|
||||||
&& (!_pressed || _pressedTopicJump);
|
&& (!_pressed || _pressedTopicJump);
|
||||||
Ui::RowPainter::Paint(p, row, validateVideoUserpic(row), context);
|
Ui::RowPainter::Paint(p, row, validateVideoUserpic(row), context);
|
||||||
|
if (context.quickActionContext) {
|
||||||
|
context.quickActionContext = nullptr;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
if (_state == WidgetState::Default) {
|
if (_state == WidgetState::Default) {
|
||||||
const auto collapsedSkip = collapsedRowsOffset();
|
const auto collapsedSkip = collapsedRowsOffset();
|
||||||
|
@ -1936,6 +1955,9 @@ bool InnerWidget::addBotAppRipple(QPoint origin, Fn<void()> updateCallback) {
|
||||||
bool InnerWidget::addQuickActionRipple(
|
bool InnerWidget::addQuickActionRipple(
|
||||||
not_null<Row*> row,
|
not_null<Row*> row,
|
||||||
Fn<void()> updateCallback) {
|
Fn<void()> updateCallback) {
|
||||||
|
if (_activeQuickAction) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
const auto action = Core::App().settings().quickDialogAction();
|
const auto action = Core::App().settings().quickDialogAction();
|
||||||
if (action == Dialogs::Ui::QuickDialogAction::Disabled) {
|
if (action == Dialogs::Ui::QuickDialogAction::Disabled) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1950,6 +1972,9 @@ bool InnerWidget::addQuickActionRipple(
|
||||||
}
|
}
|
||||||
const auto key = history->peer->id.value;
|
const auto key = history->peer->id.value;
|
||||||
const auto context = ensureQuickAction(key);
|
const auto context = ensureQuickAction(key);
|
||||||
|
if (context->data) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
auto name = ResolveQuickDialogLottieIconName(type);
|
auto name = ResolveQuickDialogLottieIconName(type);
|
||||||
context->icon = Lottie::MakeIcon({
|
context->icon = Lottie::MakeIcon({
|
||||||
|
@ -2305,22 +2330,25 @@ void InnerWidget::mousePressReleased(
|
||||||
if (_pressedBotAppData && _pressedBotAppData->ripple) {
|
if (_pressedBotAppData && _pressedBotAppData->ripple) {
|
||||||
_pressedBotAppData->ripple->lastStop();
|
_pressedBotAppData->ripple->lastStop();
|
||||||
}
|
}
|
||||||
if (!_quickActions.empty() && pressed) {
|
if (_activeQuickAction && pressed && !_activeQuickAction->data) {
|
||||||
if (const auto history = pressed->history()) {
|
if (const auto history = pressed->history()) {
|
||||||
const auto it = _quickActions.find(history->peer->id.value);
|
const auto raw = _activeQuickAction.get();
|
||||||
if (it != _quickActions.end()) {
|
if (raw->ripple) {
|
||||||
if (it->second->ripple) {
|
raw->ripple->lastStop();
|
||||||
it->second->ripple->lastStop();
|
|
||||||
it->second->rippleFg->lastStop();
|
|
||||||
}
|
|
||||||
if (pressed == _selected) {
|
|
||||||
PerformQuickDialogAction(
|
|
||||||
_controller,
|
|
||||||
history->peer,
|
|
||||||
it->second->action,
|
|
||||||
_filterId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (raw->rippleFg) {
|
||||||
|
raw->rippleFg->lastStop();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pressed == _selected) {
|
||||||
|
PerformQuickDialogAction(
|
||||||
|
_controller,
|
||||||
|
history->peer,
|
||||||
|
raw->action,
|
||||||
|
_filterId);
|
||||||
|
}
|
||||||
|
_inactiveQuickActions.push_back(
|
||||||
|
QuickActionPtr{ _activeQuickAction.release() });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateSelectedRow();
|
updateSelectedRow();
|
||||||
|
@ -5094,7 +5122,7 @@ void InnerWidget::setSwipeContextData(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!data) {
|
if (!data) {
|
||||||
_quickActions.remove(key);
|
_activeQuickAction = nullptr;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto context = ensureQuickAction(key);
|
const auto context = ensureQuickAction(key);
|
||||||
|
@ -5125,14 +5153,17 @@ void InnerWidget::setSwipeContextData(
|
||||||
not_null<Ui::QuickActionContext*> InnerWidget::ensureQuickAction(int64 key) {
|
not_null<Ui::QuickActionContext*> InnerWidget::ensureQuickAction(int64 key) {
|
||||||
Expects(key != 0);
|
Expects(key != 0);
|
||||||
|
|
||||||
const auto it = _quickActions.find(key);
|
if (_activeQuickAction) {
|
||||||
if (it == _quickActions.end()) {
|
if (_activeQuickAction->data.msgBareId == key) {
|
||||||
return _quickActions.emplace(
|
return _activeQuickAction.get();
|
||||||
key,
|
} else {
|
||||||
std::make_unique<Ui::QuickActionContext>()).first->second.get();
|
_inactiveQuickActions.push_back(
|
||||||
} else {
|
QuickActionPtr{ _activeQuickAction.release() });
|
||||||
return it->second.get();
|
}
|
||||||
}
|
}
|
||||||
|
_activeQuickAction = std::make_unique<Ui::QuickActionContext>();
|
||||||
|
_activeQuickAction->data.msgBareId = key;
|
||||||
|
return _activeQuickAction.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
int64 InnerWidget::calcSwipeKey(int top) {
|
int64 InnerWidget::calcSwipeKey(int top) {
|
||||||
|
@ -5169,4 +5200,8 @@ void InnerWidget::prepareQuickAction(
|
||||||
context->action = action;
|
context->action = action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InnerWidget::clearQuickActions() {
|
||||||
|
_inactiveQuickActions.clear();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Dialogs
|
} // namespace Dialogs
|
||||||
|
|
|
@ -221,6 +221,7 @@ public:
|
||||||
std::optional<Ui::Controls::SwipeContextData> data);
|
std::optional<Ui::Controls::SwipeContextData> data);
|
||||||
[[nodiscard]] int64 calcSwipeKey(int top);
|
[[nodiscard]] int64 calcSwipeKey(int top);
|
||||||
void prepareQuickAction(int64 key, Dialogs::Ui::QuickDialogAction);
|
void prepareQuickAction(int64 key, Dialogs::Ui::QuickDialogAction);
|
||||||
|
void clearQuickActions();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void visibleTopBottomUpdated(
|
void visibleTopBottomUpdated(
|
||||||
|
@ -630,7 +631,8 @@ private:
|
||||||
rpl::event_stream<UserId> _openBotMainAppRequests;
|
rpl::event_stream<UserId> _openBotMainAppRequests;
|
||||||
|
|
||||||
using QuickActionPtr = std::unique_ptr<Ui::QuickActionContext>;
|
using QuickActionPtr = std::unique_ptr<Ui::QuickActionContext>;
|
||||||
base::flat_map<int64, QuickActionPtr> _quickActions;
|
QuickActionPtr _activeQuickAction;
|
||||||
|
std::vector<QuickActionPtr> _inactiveQuickActions;
|
||||||
|
|
||||||
RowDescriptor _chatPreviewRow;
|
RowDescriptor _chatPreviewRow;
|
||||||
bool _chatPreviewScheduled = false;
|
bool _chatPreviewScheduled = false;
|
||||||
|
|
|
@ -729,30 +729,33 @@ void Widget::setupSwipeBack() {
|
||||||
const auto isRightToLeft = direction == Qt::RightToLeft;
|
const auto isRightToLeft = direction == Qt::RightToLeft;
|
||||||
const auto action = Core::App().settings().quickDialogAction();
|
const auto action = Core::App().settings().quickDialogAction();
|
||||||
const auto isDisabled = action == Ui::QuickDialogAction::Disabled;
|
const auto isDisabled = action == Ui::QuickDialogAction::Disabled;
|
||||||
if (!isRightToLeft && _inner) {
|
if (_inner) {
|
||||||
if (const auto key = _inner->calcSwipeKey(top);
|
_inner->clearQuickActions();
|
||||||
key && !isDisabled) {
|
if (!isRightToLeft) {
|
||||||
_inner->prepareQuickAction(key, action);
|
if (const auto key = _inner->calcSwipeKey(top);
|
||||||
return Ui::Controls::SwipeHandlerFinishData{
|
key && !isDisabled) {
|
||||||
.callback = [=, session = &session()] {
|
_inner->prepareQuickAction(key, action);
|
||||||
auto callback = [=, peerId = PeerId(key)] {
|
return Ui::Controls::SwipeHandlerFinishData{
|
||||||
const auto peer = session->data().peer(peerId);
|
.callback = [=, session = &session()] {
|
||||||
PerformQuickDialogAction(
|
auto callback = [=, peerId = PeerId(key)] {
|
||||||
controller(),
|
PerformQuickDialogAction(
|
||||||
peer,
|
controller(),
|
||||||
action,
|
session->data().peer(peerId),
|
||||||
_inner->filterId());
|
action,
|
||||||
};
|
_inner->filterId());
|
||||||
base::call_delayed(
|
};
|
||||||
st::slideWrapDuration,
|
base::call_delayed(
|
||||||
session,
|
st::slideWrapDuration,
|
||||||
std::move(callback));
|
session,
|
||||||
},
|
std::move(callback));
|
||||||
.msgBareId = key,
|
},
|
||||||
.speedRatio = 1.,
|
.msgBareId = key,
|
||||||
.reachRatioDuration = crl::time(st::slideWrapDuration),
|
.speedRatio = 1.,
|
||||||
.provideReachOutRatio = true,
|
.reachRatioDuration = crl::time(
|
||||||
};
|
st::slideWrapDuration),
|
||||||
|
.provideReachOutRatio = true,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (controller()->openedFolder().current()) {
|
if (controller()->openedFolder().current()) {
|
||||||
|
|
|
@ -898,15 +898,17 @@ void PaintRow(
|
||||||
p.drawEllipse(QPointF(geometry.width() - offset, offset), r, r);
|
p.drawEllipse(QPointF(geometry.width() - offset, offset), r, r);
|
||||||
}
|
}
|
||||||
const auto quickWidth = st::dialogsQuickActionSize * 3;
|
const auto quickWidth = st::dialogsQuickActionSize * 3;
|
||||||
DrawQuickAction(
|
if (context.quickActionContext->icon) {
|
||||||
p,
|
DrawQuickAction(
|
||||||
QRect(
|
p,
|
||||||
rect::right(geometry) - quickWidth,
|
QRect(
|
||||||
geometry.y(),
|
rect::right(geometry) - quickWidth,
|
||||||
quickWidth,
|
geometry.y(),
|
||||||
geometry.height()),
|
quickWidth,
|
||||||
context.quickActionContext->icon.get(),
|
geometry.height()),
|
||||||
labelType);
|
context.quickActionContext->icon.get(),
|
||||||
|
labelType);
|
||||||
|
}
|
||||||
p.setClipping(false);
|
p.setClipping(false);
|
||||||
}
|
}
|
||||||
if (const auto quick = context.quickActionContext;
|
if (const auto quick = context.quickActionContext;
|
||||||
|
|
Loading…
Add table
Reference in a new issue