mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 06:26:18 +00:00
Export panel minimizes to a top bar, like a Call.
This commit is contained in:
@@ -69,7 +69,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "base/qthelp_regex.h"
|
||||
#include "base/qthelp_url.h"
|
||||
#include "base/flat_set.h"
|
||||
#include "window/player_wrap_widget.h"
|
||||
#include "window/window_top_bar_wrap.h"
|
||||
#include "window/notifications_manager.h"
|
||||
#include "window/window_slide_animation.h"
|
||||
#include "window/window_controller.h"
|
||||
@@ -79,6 +79,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "core/update_checker.h"
|
||||
#include "calls/calls_instance.h"
|
||||
#include "calls/calls_top_bar.h"
|
||||
#include "export/view/export_view_top_bar.h"
|
||||
#include "export/view/export_view_panel_controller.h"
|
||||
#include "auth_session.h"
|
||||
#include "storage/storage_facade.h"
|
||||
#include "storage/storage_shared_media.h"
|
||||
@@ -269,6 +271,12 @@ MainWidget::MainWidget(
|
||||
}
|
||||
});
|
||||
subscribe(Auth().calls().currentCallChanged(), [this](Calls::Call *call) { setCurrentCall(call); });
|
||||
|
||||
Auth().data().currentExportView(
|
||||
) | rpl::start_with_next([=](Export::View::PanelController *view) {
|
||||
setCurrentExportView(view);
|
||||
}, lifetime());
|
||||
|
||||
subscribe(_controller->dialogsListFocused(), [this](bool) {
|
||||
updateDialogsWidthAnimated();
|
||||
});
|
||||
@@ -1578,7 +1586,7 @@ void MainWidget::createPlayer() {
|
||||
return;
|
||||
}
|
||||
if (!_player) {
|
||||
_player.create(this);
|
||||
_player.create(this, object_ptr<Media::Player::Widget>(this));
|
||||
rpl::merge(
|
||||
_player->heightValue() | rpl::map([] { return true; }),
|
||||
_player->shownValue()
|
||||
@@ -1645,6 +1653,7 @@ void MainWidget::setCurrentCall(Calls::Call *call) {
|
||||
|
||||
void MainWidget::createCallTopBar() {
|
||||
Expects(_currentCall != nullptr);
|
||||
|
||||
_callTopBar.create(this, object_ptr<Calls::TopBar>(this, _currentCall));
|
||||
_callTopBar->heightValue(
|
||||
) | rpl::start_with_next([this](int value) {
|
||||
@@ -1679,6 +1688,74 @@ void MainWidget::callTopBarHeightUpdated(int callTopBarHeight) {
|
||||
}
|
||||
}
|
||||
|
||||
void MainWidget::setCurrentExportView(Export::View::PanelController *view) {
|
||||
_currentExportView = view;
|
||||
if (_currentExportView) {
|
||||
_currentExportView->progressState(
|
||||
) | rpl::start_with_next([=](Export::View::Content &&data) {
|
||||
if (data.rows.empty()) {
|
||||
destroyExportTopBar();
|
||||
} else if (!_exportTopBar) {
|
||||
createExportTopBar(std::move(data));
|
||||
} else {
|
||||
_exportTopBar->entity()->updateData(std::move(data));
|
||||
}
|
||||
}, _currentExportView->lifetime());
|
||||
} else {
|
||||
destroyExportTopBar();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWidget::createExportTopBar(Export::View::Content &&data) {
|
||||
_exportTopBar.create(
|
||||
this,
|
||||
object_ptr<Export::View::TopBar>(this, std::move(data)));
|
||||
rpl::merge(
|
||||
_exportTopBar->heightValue() | rpl::map([] { return true; }),
|
||||
_exportTopBar->shownValue()
|
||||
) | rpl::start_with_next([=] {
|
||||
exportTopBarHeightUpdated();
|
||||
}, _exportTopBar->lifetime());
|
||||
_exportTopBar->entity()->clicks(
|
||||
) | rpl::start_with_next([=] {
|
||||
if (_currentExportView) {
|
||||
_currentExportView->activatePanel();
|
||||
}
|
||||
}, _exportTopBar->lifetime());
|
||||
orderWidgets();
|
||||
if (_a_show.animating()) {
|
||||
_exportTopBar->show(anim::type::instant);
|
||||
_exportTopBar->setVisible(false);
|
||||
} else {
|
||||
_exportTopBar->hide(anim::type::instant);
|
||||
_exportTopBar->show(anim::type::normal);
|
||||
_exportTopBarHeight = _contentScrollAddToY = _exportTopBar->contentHeight();
|
||||
updateControlsGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWidget::destroyExportTopBar() {
|
||||
if (_exportTopBar) {
|
||||
_exportTopBar->hide(anim::type::normal);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWidget::exportTopBarHeightUpdated() {
|
||||
if (!_exportTopBar) {
|
||||
// Player could be already "destroyDelayed", but still handle events.
|
||||
return;
|
||||
}
|
||||
const auto exportTopBarHeight = _exportTopBar->contentHeight();
|
||||
if (exportTopBarHeight != _exportTopBarHeight) {
|
||||
_contentScrollAddToY += exportTopBarHeight - _exportTopBarHeight;
|
||||
_exportTopBarHeight = exportTopBarHeight;
|
||||
updateControlsGeometry();
|
||||
}
|
||||
if (!_exportTopBarHeight && _exportTopBar->isHidden()) {
|
||||
_exportTopBar.destroyDelayed();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWidget::documentLoadProgress(FileLoader *loader) {
|
||||
if (auto documentId = loader ? loader->objId() : 0) {
|
||||
documentLoadProgress(Auth().data().document(documentId));
|
||||
@@ -2560,12 +2637,15 @@ void MainWidget::showBackFromStack(
|
||||
|
||||
void MainWidget::orderWidgets() {
|
||||
_dialogs->raise();
|
||||
if (_callTopBar) {
|
||||
_callTopBar->raise();
|
||||
}
|
||||
if (_player) {
|
||||
_player->raise();
|
||||
}
|
||||
if (_exportTopBar) {
|
||||
_exportTopBar->raise();
|
||||
}
|
||||
if (_callTopBar) {
|
||||
_callTopBar->raise();
|
||||
}
|
||||
if (_playerVolume) {
|
||||
_playerVolume->raise();
|
||||
}
|
||||
@@ -2767,7 +2847,7 @@ void MainWidget::paintEvent(QPaintEvent *e) {
|
||||
}
|
||||
|
||||
int MainWidget::getMainSectionTop() const {
|
||||
return _callTopBarHeight + _playerHeight;
|
||||
return _callTopBarHeight + _exportTopBarHeight + _playerHeight;
|
||||
}
|
||||
|
||||
int MainWidget::getThirdSectionTop() const {
|
||||
@@ -2916,9 +2996,13 @@ void MainWidget::updateControlsGeometry() {
|
||||
_callTopBar->resizeToWidth(dialogsWidth);
|
||||
_callTopBar->moveToLeft(0, 0);
|
||||
}
|
||||
if (_exportTopBar) {
|
||||
_exportTopBar->resizeToWidth(dialogsWidth);
|
||||
_exportTopBar->moveToLeft(0, _callTopBarHeight);
|
||||
}
|
||||
if (_player) {
|
||||
_player->resizeToWidth(dialogsWidth);
|
||||
_player->moveToLeft(0, _callTopBarHeight);
|
||||
_player->moveToLeft(0, _callTopBarHeight + _exportTopBarHeight);
|
||||
}
|
||||
auto mainSectionGeometry = QRect(
|
||||
0,
|
||||
@@ -2954,9 +3038,15 @@ void MainWidget::updateControlsGeometry() {
|
||||
_callTopBar->resizeToWidth(mainSectionWidth);
|
||||
_callTopBar->moveToLeft(dialogsWidth, 0);
|
||||
}
|
||||
if (_exportTopBar) {
|
||||
_exportTopBar->resizeToWidth(mainSectionWidth);
|
||||
_exportTopBar->moveToLeft(dialogsWidth, _callTopBarHeight);
|
||||
}
|
||||
if (_player) {
|
||||
_player->resizeToWidth(mainSectionWidth);
|
||||
_player->moveToLeft(dialogsWidth, _callTopBarHeight);
|
||||
_player->moveToLeft(
|
||||
dialogsWidth,
|
||||
_callTopBarHeight + _exportTopBarHeight);
|
||||
}
|
||||
_history->setGeometryToLeft(dialogsWidth, mainSectionTop, mainSectionWidth, height() - mainSectionTop);
|
||||
if (_hider) {
|
||||
|
Reference in New Issue
Block a user