mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-08-10 21:53:50 +00:00
Allowed closing emoji status panel with click outside main menu.
This commit is contained in:
@@ -180,6 +180,16 @@ void EmojiStatusPanel::hideFast() {
|
||||
}
|
||||
}
|
||||
|
||||
void EmojiStatusPanel::hideAnimated() {
|
||||
if (_panel) {
|
||||
_panel->hideAnimated();
|
||||
}
|
||||
}
|
||||
|
||||
bool EmojiStatusPanel::shown() const {
|
||||
return _panel && !_panel->isHidden();
|
||||
}
|
||||
|
||||
bool EmojiStatusPanel::hasFocus() const {
|
||||
return _panel && Ui::InFocusChain(_panel.get());
|
||||
}
|
||||
|
||||
@@ -60,6 +60,8 @@ public:
|
||||
};
|
||||
void show(Descriptor &&descriptor);
|
||||
void hideFast();
|
||||
void hideAnimated();
|
||||
[[nodiscard]] bool shown() const;
|
||||
void repaint();
|
||||
|
||||
struct CustomChosen {
|
||||
|
||||
@@ -829,12 +829,30 @@ void MainMenu::chooseEmojiStatus() {
|
||||
if (_controller->showFrozenError()) {
|
||||
return;
|
||||
} else if (const auto widget = _badge->widget()) {
|
||||
setupEmojiStatusDismiss();
|
||||
_emojiStatusPanel->show(_controller, widget, _badge->sizeTag());
|
||||
} else {
|
||||
ShowPremiumPreviewBox(_controller, PremiumFeature::EmojiStatus);
|
||||
}
|
||||
}
|
||||
|
||||
void MainMenu::setupEmojiStatusDismiss() {
|
||||
if (_emojiStatusDismissSetup) {
|
||||
return;
|
||||
}
|
||||
_emojiStatusDismissSetup = true;
|
||||
|
||||
base::install_event_filter(this, parentWidget(), [=](
|
||||
not_null<QEvent*> e) {
|
||||
if (e->type() != QEvent::MouseButtonPress
|
||||
|| !_emojiStatusPanel->shown()) {
|
||||
return base::EventFilterResult::Continue;
|
||||
}
|
||||
_emojiStatusPanel->hideAnimated();
|
||||
return base::EventFilterResult::Cancel;
|
||||
});
|
||||
}
|
||||
|
||||
bool MainMenu::eventHook(QEvent *event) {
|
||||
const auto type = event->type();
|
||||
if (type == QEvent::TouchBegin
|
||||
|
||||
@@ -72,6 +72,7 @@ private:
|
||||
void setupAccounts();
|
||||
void setupAccountsToggle();
|
||||
void setupSetEmojiStatus();
|
||||
void setupEmojiStatusDismiss();
|
||||
void setupArchive();
|
||||
void setupMenu();
|
||||
void updateControlsGeometry();
|
||||
@@ -113,6 +114,7 @@ private:
|
||||
|
||||
rpl::variable<bool> _showFinished = false;
|
||||
bool _insideEventRedirect = false;
|
||||
bool _emojiStatusDismissSetup = false;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user