mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +02:00
Added initial handler for middle mouse click on dialogs.
This commit is contained in:
parent
418dcedc4e
commit
c332b7cb40
5 changed files with 80 additions and 26 deletions
|
@ -791,3 +791,4 @@ dialogsPopularAppsAbout: FlatLabel(boxDividerLabel) {
|
||||||
}
|
}
|
||||||
|
|
||||||
dialogsQuickActionSize: 20px;
|
dialogsQuickActionSize: 20px;
|
||||||
|
dialogsQuickActionRippleSize: 80px;
|
||||||
|
|
|
@ -840,9 +840,9 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
context.rightButton = maybeCacheRightButton(row);
|
context.rightButton = maybeCacheRightButton(row);
|
||||||
if (key.history()) {
|
if (key.history()) {
|
||||||
const auto it = _quickActions.find(key.history()->peer->id.value);
|
const auto it = _quickActions.find(key.history()->peer->id.value);
|
||||||
if (it != _quickActions.end()) {
|
context.quickActionContext = (it != _quickActions.end())
|
||||||
context.quickActionContext = it->second.get();
|
? it->second.get()
|
||||||
}
|
: nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
context.st = (forum ? &st::forumDialogRow : _st.get());
|
context.st = (forum ? &st::forumDialogRow : _st.get());
|
||||||
|
@ -1850,7 +1850,9 @@ void InnerWidget::mousePressEvent(QMouseEvent *e) {
|
||||||
};
|
};
|
||||||
const auto origin = e->pos()
|
const auto origin = e->pos()
|
||||||
- QPoint(0, dialogsOffset() + _pressed->top());
|
- QPoint(0, dialogsOffset() + _pressed->top());
|
||||||
if (addBotAppRipple(origin, updateCallback)) {
|
if ((_pressButton == Qt::MiddleButton)
|
||||||
|
&& addQuickActionRipple(row, updateCallback)) {
|
||||||
|
} else if (addBotAppRipple(origin, updateCallback)) {
|
||||||
} else if (_pressedTopicJump) {
|
} else if (_pressedTopicJump) {
|
||||||
row->addTopicJumpRipple(
|
row->addTopicJumpRipple(
|
||||||
origin,
|
origin,
|
||||||
|
@ -1922,7 +1924,7 @@ bool InnerWidget::addBotAppRipple(QPoint origin, Fn<void()> updateCallback) {
|
||||||
_pressedBotAppData->ripple = std::make_unique<Ui::RippleAnimation>(
|
_pressedBotAppData->ripple = std::make_unique<Ui::RippleAnimation>(
|
||||||
st::defaultRippleAnimation,
|
st::defaultRippleAnimation,
|
||||||
Ui::RippleAnimation::RoundRectMask(size, size.height() / 2),
|
Ui::RippleAnimation::RoundRectMask(size, size.height() / 2),
|
||||||
updateCallback);
|
std::move(updateCallback));
|
||||||
}
|
}
|
||||||
const auto shift = QPoint(
|
const auto shift = QPoint(
|
||||||
width() - size.width() - st::dialogRowOpenBotRight,
|
width() - size.width() - st::dialogRowOpenBotRight,
|
||||||
|
@ -1931,6 +1933,43 @@ bool InnerWidget::addBotAppRipple(QPoint origin, Fn<void()> updateCallback) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool InnerWidget::addQuickActionRipple(
|
||||||
|
not_null<Row*> row,
|
||||||
|
Fn<void()> updateCallback) {
|
||||||
|
const auto action = Core::App().settings().quickDialogAction();
|
||||||
|
if (action == Dialogs::Ui::QuickDialogAction::Disabled) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const auto history = row->history();
|
||||||
|
if (!history) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const auto key = history->peer->id.value;
|
||||||
|
const auto context = ensureQuickAction(key);
|
||||||
|
|
||||||
|
auto name = ResolveQuickDialogLottieIconName(
|
||||||
|
history->peer,
|
||||||
|
action,
|
||||||
|
_filterId);
|
||||||
|
context->icon = Lottie::MakeIcon({
|
||||||
|
.name = std::move(name),
|
||||||
|
.sizeOverride = Size(st::dialogsQuickActionSize),
|
||||||
|
});
|
||||||
|
context->action = action;
|
||||||
|
const auto size = QSize(
|
||||||
|
st::dialogsQuickActionRippleSize,
|
||||||
|
row->height());
|
||||||
|
if (!context->ripple) {
|
||||||
|
context->ripple = std::make_unique<Ui::RippleAnimation>(
|
||||||
|
st::defaultRippleAnimation,
|
||||||
|
Ui::RippleAnimation::RectMask(size),
|
||||||
|
std::move(updateCallback));
|
||||||
|
}
|
||||||
|
context->ripple->add(QPoint(size.width() / 2, size.height() / 2));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
const std::vector<Key> &InnerWidget::pinnedChatsOrder() const {
|
const std::vector<Key> &InnerWidget::pinnedChatsOrder() const {
|
||||||
const auto owner = &session().data();
|
const auto owner = &session().data();
|
||||||
return _savedSublists
|
return _savedSublists
|
||||||
|
@ -2236,6 +2275,16 @@ void InnerWidget::mousePressReleased(
|
||||||
if (_pressedBotAppData && _pressedBotAppData->ripple) {
|
if (_pressedBotAppData && _pressedBotAppData->ripple) {
|
||||||
_pressedBotAppData->ripple->lastStop();
|
_pressedBotAppData->ripple->lastStop();
|
||||||
}
|
}
|
||||||
|
if (!_quickActions.empty() && pressed) {
|
||||||
|
if (const auto history = pressed->history()) {
|
||||||
|
const auto it = _quickActions.find(history->peer->id.value);
|
||||||
|
if (it != _quickActions.end()) {
|
||||||
|
if (it->second->ripple) {
|
||||||
|
it->second->ripple->lastStop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
updateSelectedRow();
|
updateSelectedRow();
|
||||||
if (!wasDragging && button == Qt::LeftButton) {
|
if (!wasDragging && button == Qt::LeftButton) {
|
||||||
if ((collapsedPressed >= 0 && collapsedPressed == _collapsedSelected)
|
if ((collapsedPressed >= 0 && collapsedPressed == _collapsedSelected)
|
||||||
|
@ -5010,15 +5059,7 @@ void InnerWidget::setSwipeContextData(
|
||||||
_quickActions.remove(key);
|
_quickActions.remove(key);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto it = _quickActions.find(key);
|
const auto context = ensureQuickAction(key);
|
||||||
auto context = (Ui::QuickActionContext*)(nullptr);
|
|
||||||
if (it == _quickActions.end()) {
|
|
||||||
context = _quickActions.emplace(
|
|
||||||
key,
|
|
||||||
std::make_unique<Ui::QuickActionContext>()).first->second.get();
|
|
||||||
} else {
|
|
||||||
context = it->second.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
context->data = base::take(*data);
|
context->data = base::take(*data);
|
||||||
if (context->data.msgBareId) {
|
if (context->data.msgBareId) {
|
||||||
|
@ -5043,6 +5084,19 @@ void InnerWidget::setSwipeContextData(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
not_null<Ui::QuickActionContext*> InnerWidget::ensureQuickAction(int64 key) {
|
||||||
|
Expects(key != 0);
|
||||||
|
|
||||||
|
const auto it = _quickActions.find(key);
|
||||||
|
if (it == _quickActions.end()) {
|
||||||
|
return _quickActions.emplace(
|
||||||
|
key,
|
||||||
|
std::make_unique<Ui::QuickActionContext>()).first->second.get();
|
||||||
|
} else {
|
||||||
|
return it->second.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int64 InnerWidget::calcSwipeKey(int top) {
|
int64 InnerWidget::calcSwipeKey(int top) {
|
||||||
top -= dialogsOffset();
|
top -= dialogsOffset();
|
||||||
for (auto it = _shownList->begin(); it != _shownList->end(); ++it) {
|
for (auto it = _shownList->begin(); it != _shownList->end(); ++it) {
|
||||||
|
@ -5064,21 +5118,12 @@ void InnerWidget::prepareQuickAction(
|
||||||
Dialogs::Ui::QuickDialogAction action) {
|
Dialogs::Ui::QuickDialogAction action) {
|
||||||
Expects(key != 0);
|
Expects(key != 0);
|
||||||
|
|
||||||
const auto it = _quickActions.find(key);
|
const auto context = ensureQuickAction(key);
|
||||||
auto context = (Ui::QuickActionContext*)(nullptr);
|
|
||||||
if (it == _quickActions.end()) {
|
|
||||||
context = _quickActions.emplace(
|
|
||||||
key,
|
|
||||||
std::make_unique<Ui::QuickActionContext>()).first->second.get();
|
|
||||||
} else {
|
|
||||||
context = it->second.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto peer = session().data().peer(PeerId(key));
|
const auto peer = session().data().peer(PeerId(key));
|
||||||
auto name = ResolveQuickDialogLottieIconName(peer, action, _filterId);
|
auto name = ResolveQuickDialogLottieIconName(peer, action, _filterId);
|
||||||
context->icon = Lottie::MakeIcon({
|
context->icon = Lottie::MakeIcon({
|
||||||
.name = std::move(name),
|
.name = std::move(name),
|
||||||
.sizeOverride = Size(st::dialogsSwipeActionSize),
|
.sizeOverride = Size(st::dialogsQuickActionSize),
|
||||||
});
|
});
|
||||||
context->action = action;
|
context->action = action;
|
||||||
}
|
}
|
||||||
|
|
|
@ -352,6 +352,7 @@ private:
|
||||||
void repaintDialogRowCornerStatus(not_null<History*> history);
|
void repaintDialogRowCornerStatus(not_null<History*> history);
|
||||||
|
|
||||||
bool addBotAppRipple(QPoint origin, Fn<void()> updateCallback);
|
bool addBotAppRipple(QPoint origin, Fn<void()> updateCallback);
|
||||||
|
bool addQuickActionRipple(not_null<Row*> row, Fn<void()> updateCallback);
|
||||||
|
|
||||||
void setupShortcuts();
|
void setupShortcuts();
|
||||||
RowDescriptor computeJump(
|
RowDescriptor computeJump(
|
||||||
|
@ -482,7 +483,8 @@ private:
|
||||||
void saveChatsFilterScrollState(FilterId filterId);
|
void saveChatsFilterScrollState(FilterId filterId);
|
||||||
void restoreChatsFilterScrollState(FilterId filterId);
|
void restoreChatsFilterScrollState(FilterId filterId);
|
||||||
|
|
||||||
[[nodiscard]] Ui::QuickActionContext *ensureQuickAction(int64 key);
|
[[nodiscard]] not_null<Ui::QuickActionContext*> ensureQuickAction(
|
||||||
|
int64 key);
|
||||||
|
|
||||||
[[nodiscard]] bool lookupIsInBotAppButton(
|
[[nodiscard]] bool lookupIsInBotAppButton(
|
||||||
Row *row,
|
Row *row,
|
||||||
|
|
|
@ -396,6 +396,7 @@ void PaintRow(
|
||||||
auto swipeTranslation = 0;
|
auto swipeTranslation = 0;
|
||||||
if (history
|
if (history
|
||||||
&& context.quickActionContext
|
&& context.quickActionContext
|
||||||
|
&& !context.quickActionContext->ripple
|
||||||
&& (history->peer->id.value
|
&& (history->peer->id.value
|
||||||
== context.quickActionContext->data.msgBareId)) {
|
== context.quickActionContext->data.msgBareId)) {
|
||||||
if (context.quickActionContext->data.translation != 0) {
|
if (context.quickActionContext->data.translation != 0) {
|
||||||
|
|
|
@ -14,6 +14,10 @@ namespace Lottie {
|
||||||
class Icon;
|
class Icon;
|
||||||
} // namespace Lottie
|
} // namespace Lottie
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class RippleAnimation;
|
||||||
|
} // namespace Ui
|
||||||
|
|
||||||
namespace Dialogs::Ui {
|
namespace Dialogs::Ui {
|
||||||
|
|
||||||
using namespace ::Ui;
|
using namespace ::Ui;
|
||||||
|
@ -34,6 +38,7 @@ enum class QuickDialogActionLabel {
|
||||||
struct QuickActionContext {
|
struct QuickActionContext {
|
||||||
::Ui::Controls::SwipeContextData data;
|
::Ui::Controls::SwipeContextData data;
|
||||||
std::unique_ptr<Lottie::Icon> icon;
|
std::unique_ptr<Lottie::Icon> icon;
|
||||||
|
std::unique_ptr<Ui::RippleAnimation> ripple;
|
||||||
QuickDialogAction action;
|
QuickDialogAction action;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue