mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added initial implementation of display sections prevent.
This commit is contained in:
parent
c8643aa1ee
commit
24b8377a2a
13 changed files with 95 additions and 4 deletions
|
@ -3914,6 +3914,14 @@ void HistoryWidget::setTabbedPanel(std::unique_ptr<TabbedPanel> panel) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool HistoryWidget::preventsClose(Fn<void()> &&continueCallback) const {
|
||||||
|
if (isRecording()) {
|
||||||
|
_voiceRecordBar->showDiscardRecordingBox(std::move(continueCallback));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void HistoryWidget::toggleTabbedSelectorMode() {
|
void HistoryWidget::toggleTabbedSelectorMode() {
|
||||||
if (!_peer) {
|
if (!_peer) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -119,6 +119,8 @@ public:
|
||||||
|
|
||||||
void historyLoaded();
|
void historyLoaded();
|
||||||
|
|
||||||
|
[[nodiscard]] bool preventsClose(Fn<void()> &&continueCallback) const;
|
||||||
|
|
||||||
// When resizing the widget with top edge moved up or down and we
|
// When resizing the widget with top edge moved up or down and we
|
||||||
// want to add this top movement to the scroll position, so inner
|
// want to add this top movement to the scroll position, so inner
|
||||||
// content will not move.
|
// content will not move.
|
||||||
|
|
|
@ -2138,6 +2138,14 @@ bool ComposeControls::isRecording() const {
|
||||||
return _voiceRecordBar->isRecording();
|
return _voiceRecordBar->isRecording();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ComposeControls::preventsClose(Fn<void()> &&continueCallback) const {
|
||||||
|
if (isRecording()) {
|
||||||
|
_voiceRecordBar->showDiscardRecordingBox(std::move(continueCallback));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void ComposeControls::updateInlineBotQuery() {
|
void ComposeControls::updateInlineBotQuery() {
|
||||||
if (!_history) {
|
if (!_history) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -135,6 +135,8 @@ public:
|
||||||
[[nodiscard]] bool isEditingMessage() const;
|
[[nodiscard]] bool isEditingMessage() const;
|
||||||
[[nodiscard]] FullMsgId replyingToMessage() const;
|
[[nodiscard]] FullMsgId replyingToMessage() const;
|
||||||
|
|
||||||
|
[[nodiscard]] bool preventsClose(Fn<void()> &&continueCallback) const;
|
||||||
|
|
||||||
void showForGrab();
|
void showForGrab();
|
||||||
void showStarted();
|
void showStarted();
|
||||||
void showFinished();
|
void showFinished();
|
||||||
|
|
|
@ -1536,9 +1536,10 @@ void VoiceRecordBar::installClickOutsideFilter() {
|
||||||
} else if (type == QEvent::ContextMenu || type == QEvent::Shortcut) {
|
} else if (type == QEvent::ContextMenu || type == QEvent::Shortcut) {
|
||||||
return Type::ShowBox;
|
return Type::ShowBox;
|
||||||
} else if (type == QEvent::MouseButtonPress) {
|
} else if (type == QEvent::MouseButtonPress) {
|
||||||
return (noBox && !_inField.current() && !_lock->underMouse())
|
return Type::Continue;
|
||||||
? Type::ShowBox
|
// return (noBox && !_inField.current() && !_lock->underMouse())
|
||||||
: Type::Continue;
|
// ? Type::ShowBox
|
||||||
|
// : Type::Continue;
|
||||||
}
|
}
|
||||||
return Type::Continue;
|
return Type::Continue;
|
||||||
};
|
};
|
||||||
|
@ -1609,4 +1610,22 @@ void VoiceRecordBar::installListenStateFilter() {
|
||||||
std::move(keyFilter));
|
std::move(keyFilter));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VoiceRecordBar::showDiscardRecordingBox(Fn<void()> &&callback) {
|
||||||
|
if (!isRecording()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto sure = [=, callback = std::move(callback)](Fn<void()> &&close) {
|
||||||
|
hideFast();
|
||||||
|
close();
|
||||||
|
if (callback) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Ui::show(Box<ConfirmBox>(
|
||||||
|
tr::lng_record_lock_cancel_sure(tr::now),
|
||||||
|
tr::lng_record_lock_discard(tr::now),
|
||||||
|
st::attentionBoxButton,
|
||||||
|
std::move(sure)));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace HistoryView::Controls
|
} // namespace HistoryView::Controls
|
||||||
|
|
|
@ -47,6 +47,8 @@ public:
|
||||||
int recorderHeight);
|
int recorderHeight);
|
||||||
~VoiceRecordBar();
|
~VoiceRecordBar();
|
||||||
|
|
||||||
|
void showDiscardRecordingBox(Fn<void()> &&callback);
|
||||||
|
|
||||||
void startRecording();
|
void startRecording();
|
||||||
void finishAnimating();
|
void finishAnimating();
|
||||||
void hideAnimated();
|
void hideAnimated();
|
||||||
|
|
|
@ -1315,6 +1315,10 @@ Dialogs::RowDescriptor RepliesWidget::activeChat() const {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RepliesWidget::preventsClose(Fn<void()> &&continueCallback) const {
|
||||||
|
return _composeControls->preventsClose(std::move(continueCallback));
|
||||||
|
}
|
||||||
|
|
||||||
QPixmap RepliesWidget::grabForShowAnimation(const Window::SectionSlideParams ¶ms) {
|
QPixmap RepliesWidget::grabForShowAnimation(const Window::SectionSlideParams ¶ms) {
|
||||||
_topBar->updateControlsVisibility();
|
_topBar->updateControlsVisibility();
|
||||||
if (params.withTopBarShadow) _topBarShadow->hide();
|
if (params.withTopBarShadow) _topBarShadow->hide();
|
||||||
|
|
|
@ -75,6 +75,7 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] not_null<History*> history() const;
|
[[nodiscard]] not_null<History*> history() const;
|
||||||
Dialogs::RowDescriptor activeChat() const override;
|
Dialogs::RowDescriptor activeChat() const override;
|
||||||
|
bool preventsClose(Fn<void()> &&continueCallback) const override;
|
||||||
|
|
||||||
bool hasTopBarShadow() const override {
|
bool hasTopBarShadow() const override {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -894,6 +894,10 @@ Dialogs::RowDescriptor ScheduledWidget::activeChat() const {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ScheduledWidget::preventsClose(Fn<void()> &&continueCallback) const {
|
||||||
|
return _composeControls->preventsClose(std::move(continueCallback));
|
||||||
|
}
|
||||||
|
|
||||||
QPixmap ScheduledWidget::grabForShowAnimation(const Window::SectionSlideParams ¶ms) {
|
QPixmap ScheduledWidget::grabForShowAnimation(const Window::SectionSlideParams ¶ms) {
|
||||||
_topBar->updateControlsVisibility();
|
_topBar->updateControlsVisibility();
|
||||||
if (params.withTopBarShadow) _topBarShadow->hide();
|
if (params.withTopBarShadow) _topBarShadow->hide();
|
||||||
|
|
|
@ -60,6 +60,7 @@ public:
|
||||||
|
|
||||||
not_null<History*> history() const;
|
not_null<History*> history() const;
|
||||||
Dialogs::RowDescriptor activeChat() const override;
|
Dialogs::RowDescriptor activeChat() const override;
|
||||||
|
bool preventsClose(Fn<void()> &&continueCallback) const override;
|
||||||
|
|
||||||
bool hasTopBarShadow() const override {
|
bool hasTopBarShadow() const override {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1403,6 +1403,7 @@ void MainWidget::ui_showPeerHistory(
|
||||||
PeerId peerId,
|
PeerId peerId,
|
||||||
const SectionShow ¶ms,
|
const SectionShow ¶ms,
|
||||||
MsgId showAtMsgId) {
|
MsgId showAtMsgId) {
|
||||||
|
|
||||||
if (auto peer = session().data().peerLoaded(peerId)) {
|
if (auto peer = session().data().peerLoaded(peerId)) {
|
||||||
if (peer->migrateTo()) {
|
if (peer->migrateTo()) {
|
||||||
peer = peer->migrateTo();
|
peer = peer->migrateTo();
|
||||||
|
@ -1423,6 +1424,13 @@ void MainWidget::ui_showPeerHistory(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(_history->peer() && _history->peer()->id == peerId)
|
||||||
|
&& preventsCloseSection(
|
||||||
|
[=] { ui_showPeerHistory(peerId, params, showAtMsgId); },
|
||||||
|
params)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
using OriginMessage = SectionShow::OriginMessage;
|
using OriginMessage = SectionShow::OriginMessage;
|
||||||
if (const auto origin = std::get_if<OriginMessage>(¶ms.origin)) {
|
if (const auto origin = std::get_if<OriginMessage>(¶ms.origin)) {
|
||||||
if (const auto returnTo = session().data().message(origin->id)) {
|
if (const auto returnTo = session().data().message(origin->id)) {
|
||||||
|
@ -1618,13 +1626,22 @@ void MainWidget::showSection(
|
||||||
// return;
|
// return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using MementoPtr = std::unique_ptr<Window::SectionMemento>;
|
||||||
|
const auto sharedMemento = std::make_shared<MementoPtr>(
|
||||||
|
std::move(memento));
|
||||||
|
if (preventsCloseSection(
|
||||||
|
[=] { showSection(base::take(*sharedMemento), params); },
|
||||||
|
params)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If the window was not resized, but we've enabled
|
// If the window was not resized, but we've enabled
|
||||||
// tabbedSelectorSectionEnabled or thirdSectionInfoEnabled
|
// tabbedSelectorSectionEnabled or thirdSectionInfoEnabled
|
||||||
// we need to update adaptive layout to Adaptive::ThirdColumn().
|
// we need to update adaptive layout to Adaptive::ThirdColumn().
|
||||||
updateColumnLayout();
|
updateColumnLayout();
|
||||||
|
|
||||||
showNewSection(
|
showNewSection(
|
||||||
std::move(memento),
|
std::move(*sharedMemento),
|
||||||
params);
|
params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1880,8 +1897,24 @@ bool MainWidget::stackIsEmpty() const {
|
||||||
return _stack.empty();
|
return _stack.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MainWidget::preventsCloseSection(
|
||||||
|
Fn<void()> callback,
|
||||||
|
const SectionShow ¶ms) const {
|
||||||
|
if (params.thirdColumn || Core::App().passcodeLocked()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
auto copy = callback;
|
||||||
|
return (_mainSection && _mainSection->preventsClose(std::move(copy)))
|
||||||
|
|| (_history && _history->preventsClose(std::move(callback)));
|
||||||
|
}
|
||||||
|
|
||||||
void MainWidget::showBackFromStack(
|
void MainWidget::showBackFromStack(
|
||||||
const SectionShow ¶ms) {
|
const SectionShow ¶ms) {
|
||||||
|
|
||||||
|
if (preventsCloseSection([=] { showBackFromStack(params); }, params)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (selectingPeer()) {
|
if (selectingPeer()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -274,6 +274,9 @@ private:
|
||||||
std::unique_ptr<Window::SectionMemento> &&memento,
|
std::unique_ptr<Window::SectionMemento> &&memento,
|
||||||
const SectionShow ¶ms);
|
const SectionShow ¶ms);
|
||||||
void dropMainSection(Window::SectionWidget *widget);
|
void dropMainSection(Window::SectionWidget *widget);
|
||||||
|
bool preventsCloseSection(
|
||||||
|
Fn<void()> callback,
|
||||||
|
const SectionShow ¶ms) const;
|
||||||
|
|
||||||
Window::SectionSlideParams prepareThirdSectionAnimation(Window::SectionWidget *section);
|
Window::SectionSlideParams prepareThirdSectionAnimation(Window::SectionWidget *section);
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,10 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual bool preventsClose(Fn<void()> &&continueCallback) const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Create a memento of that section to store it in the history stack.
|
// Create a memento of that section to store it in the history stack.
|
||||||
// This method may modify the section ("take" heavy items).
|
// This method may modify the section ("take" heavy items).
|
||||||
virtual std::unique_ptr<SectionMemento> createMemento();
|
virtual std::unique_ptr<SectionMemento> createMemento();
|
||||||
|
|
Loading…
Add table
Reference in a new issue