mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-20 18:28:11 +00:00
Export panel minimizes to a top bar, like a Call.
This commit is contained in:
parent
eaf3ea9289
commit
329db0d8e9
@ -1654,6 +1654,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_passport_bad_name" = "Please use latin characters only.";
|
||||
|
||||
"lng_export_title" = "Personal data export";
|
||||
"lng_export_progress_title" = "Exporting personal data";
|
||||
"lng_export_option_info" = "Personal information";
|
||||
"lng_export_option_contacts" = "Contacts list";
|
||||
"lng_export_option_sessions" = "Sessions list";
|
||||
|
@ -10,6 +10,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "observer_peer.h"
|
||||
#include "auth_session.h"
|
||||
#include "apiwrap.h"
|
||||
#include "export/export_controller.h"
|
||||
#include "export/view/export_view_panel_controller.h"
|
||||
#include "window/notifications_manager.h"
|
||||
#include "history/history.h"
|
||||
#include "history/history_item_components.h"
|
||||
@ -68,6 +70,32 @@ Session::Session(not_null<AuthSession*> session)
|
||||
setupChannelLeavingViewer();
|
||||
}
|
||||
|
||||
void Session::startExport() {
|
||||
_export = std::make_unique<Export::ControllerWrap>();
|
||||
_exportPanel = std::make_unique<Export::View::PanelController>(
|
||||
_export.get());
|
||||
|
||||
_exportViewChanges.fire(_exportPanel.get());
|
||||
|
||||
_exportPanel->closed(
|
||||
) | rpl::start_with_next([=] {
|
||||
clearExport();
|
||||
}, _export->lifetime());
|
||||
}
|
||||
|
||||
rpl::producer<Export::View::PanelController*> Session::currentExportView(
|
||||
) const {
|
||||
return _exportViewChanges.events_starting_with(_exportPanel.get());
|
||||
}
|
||||
|
||||
void Session::clearExport() {
|
||||
if (_exportPanel) {
|
||||
_exportPanel = nullptr;
|
||||
_exportViewChanges.fire(nullptr);
|
||||
}
|
||||
_export = nullptr;
|
||||
}
|
||||
|
||||
void Session::setupContactViewsViewer() {
|
||||
Notify::PeerUpdateViewer(
|
||||
Notify::PeerUpdate::Flag::UserIsContact
|
||||
|
@ -27,6 +27,13 @@ class Reader;
|
||||
} // namespace Clip
|
||||
} // namespace Media
|
||||
|
||||
namespace Export {
|
||||
class ControllerWrap;
|
||||
namespace View {
|
||||
class PanelController;
|
||||
} // namespace View
|
||||
} // namespace Export
|
||||
|
||||
namespace Data {
|
||||
|
||||
class Feed;
|
||||
@ -44,6 +51,9 @@ public:
|
||||
return *_session;
|
||||
}
|
||||
|
||||
void startExport();
|
||||
rpl::producer<Export::View::PanelController*> currentExportView() const;
|
||||
|
||||
[[nodiscard]] base::Variable<bool> &contactsLoaded() {
|
||||
return _contactsLoaded;
|
||||
}
|
||||
@ -395,6 +405,8 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void clearExport();
|
||||
|
||||
void setupContactViewsViewer();
|
||||
void setupChannelLeavingViewer();
|
||||
void photoApplyFields(
|
||||
@ -489,6 +501,10 @@ private:
|
||||
|
||||
not_null<AuthSession*> _session;
|
||||
|
||||
std::unique_ptr<Export::ControllerWrap> _export;
|
||||
std::unique_ptr<Export::View::PanelController> _exportPanel;
|
||||
rpl::event_stream<Export::View::PanelController*> _exportViewChanges;
|
||||
|
||||
base::Variable<bool> _contactsLoaded = { false };
|
||||
base::Variable<bool> _allChatsLoaded = { false };
|
||||
base::Observable<void> _moreChatsLoaded;
|
||||
|
@ -699,6 +699,7 @@ void ApiWrap::requestMessages(
|
||||
void ApiWrap::requestDialogsSlice() {
|
||||
Expects(_dialogsProcess != nullptr);
|
||||
|
||||
LOG(("REQUEST %1 %2").arg(_dialogsProcess->offsetDate).arg(_dialogsProcess->offsetId));
|
||||
mainRequest(MTPmessages_GetDialogs(
|
||||
MTP_flags(0),
|
||||
MTP_int(_dialogsProcess->offsetDate),
|
||||
@ -722,6 +723,10 @@ void ApiWrap::requestDialogsSlice() {
|
||||
_dialogsProcess->offsetDate = last.topMessageDate;
|
||||
_dialogsProcess->offsetPeer = last.input;
|
||||
|
||||
for (const auto &item : info.list) {
|
||||
LOG(("RESULT: %1 %2").arg(item.topMessageDate).arg(item.topMessageId));
|
||||
}
|
||||
|
||||
appendDialogsSlice(std::move(info));
|
||||
|
||||
const auto count = _dialogsProcess->info.list.size();
|
||||
|
@ -62,3 +62,10 @@ exportProgressInfoLabel: FlatLabel(boxLabel) {
|
||||
exportProgressWidth: 3px;
|
||||
exportProgressFg: mediaPlayerActiveFg;
|
||||
exportProgressBg: mediaPlayerInactiveFg;
|
||||
|
||||
exportTopBarLabel: FlatLabel(defaultFlatLabel) {
|
||||
maxHeight: 20px;
|
||||
palette: TextPalette(defaultTextPalette) {
|
||||
linkFg: windowSubTextFg;
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ Content ContentFromState(const ProcessingState &state) {
|
||||
pushMain(lang(lng_export_state_userpics));
|
||||
pushBytes(
|
||||
"userpic" + QString::number(state.entityIndex),
|
||||
"Photo_" + QString::number(state.entityIndex + 1) + ".jpg");
|
||||
state.bytesName);
|
||||
break;
|
||||
case Step::Contacts:
|
||||
pushMain(lang(lng_export_option_contacts));
|
||||
|
@ -27,14 +27,16 @@ struct Content {
|
||||
Content ContentFromState(const ProcessingState &state);
|
||||
|
||||
inline auto ContentFromState(rpl::producer<State> state) {
|
||||
return rpl::single(Content()) | rpl::then(std::move(
|
||||
return std::move(
|
||||
state
|
||||
) | rpl::filter([](const State &state) {
|
||||
return state.template is<ProcessingState>();
|
||||
return state.is<ProcessingState>() || state.is<FinishedState>();
|
||||
}) | rpl::map([](const State &state) {
|
||||
return ContentFromState(
|
||||
state.template get_unchecked<ProcessingState>());
|
||||
}));
|
||||
if (const auto process = base::get_if<ProcessingState>(&state)) {
|
||||
return ContentFromState(*process);
|
||||
}
|
||||
return Content();
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace View
|
||||
|
@ -28,6 +28,10 @@ PanelController::PanelController(not_null<ControllerWrap*> process)
|
||||
}, _lifetime);
|
||||
}
|
||||
|
||||
void PanelController::activatePanel() {
|
||||
_panel->showAndActivate();
|
||||
}
|
||||
|
||||
void PanelController::createPanel() {
|
||||
_panel = base::make_unique_q<Ui::SeparatePanel>();
|
||||
_panel->setTitle(Lang::Viewer(lng_export_title));
|
||||
@ -84,12 +88,17 @@ void PanelController::showError(const QString &text) {
|
||||
}, container->lifetime());
|
||||
|
||||
_panel->showInner(std::move(container));
|
||||
_panel->setHideOnDeactivate(false);
|
||||
}
|
||||
|
||||
void PanelController::showProgress() {
|
||||
_panel->setTitle(Lang::Viewer(lng_export_progress_title));
|
||||
|
||||
auto progress = base::make_unique_q<ProgressWidget>(
|
||||
_panel.get(),
|
||||
ContentFromState(_process->state()));
|
||||
rpl::single(
|
||||
ContentFromState(ProcessingState())
|
||||
) | rpl::then(progressState()));
|
||||
|
||||
progress->cancelClicks(
|
||||
) | rpl::start_with_next([=] {
|
||||
@ -97,9 +106,12 @@ void PanelController::showProgress() {
|
||||
}, progress->lifetime());
|
||||
|
||||
_panel->showInner(std::move(progress));
|
||||
_panel->setHideOnDeactivate(true);
|
||||
}
|
||||
|
||||
void PanelController::showDone(const QString &path) {
|
||||
_panel->setTitle(Lang::Viewer(lng_export_title));
|
||||
|
||||
auto done = base::make_unique_q<DoneWidget>(_panel.get());
|
||||
|
||||
done->showClicks(
|
||||
@ -114,6 +126,7 @@ void PanelController::showDone(const QString &path) {
|
||||
}, done->lifetime());
|
||||
|
||||
_panel->showInner(std::move(done));
|
||||
_panel->setHideOnDeactivate(false);
|
||||
}
|
||||
|
||||
rpl::producer<> PanelController::closed() const {
|
||||
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#pragma once
|
||||
|
||||
#include "export/export_controller.h"
|
||||
#include "export/view/export_view_content.h"
|
||||
#include "base/unique_qptr.h"
|
||||
|
||||
namespace Ui {
|
||||
@ -23,8 +24,18 @@ class PanelController {
|
||||
public:
|
||||
PanelController(not_null<ControllerWrap*> process);
|
||||
|
||||
void activatePanel();
|
||||
|
||||
rpl::producer<> closed() const;
|
||||
|
||||
rpl::lifetime &lifetime() {
|
||||
return _lifetime;
|
||||
}
|
||||
|
||||
auto progressState() const {
|
||||
return ContentFromState(_process->state());
|
||||
}
|
||||
|
||||
~PanelController();
|
||||
|
||||
private:
|
||||
|
91
Telegram/SourceFiles/export/view/export_view_top_bar.cpp
Normal file
91
Telegram/SourceFiles/export/view/export_view_top_bar.cpp
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "export/view/export_view_top_bar.h"
|
||||
|
||||
#include "export/view/export_view_content.h"
|
||||
#include "ui/widgets/continuous_sliders.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/shadow.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "styles/style_export.h"
|
||||
#include "styles/style_media_player.h"
|
||||
|
||||
namespace Export {
|
||||
namespace View {
|
||||
|
||||
TopBar::TopBar(QWidget *parent, Content &&content)
|
||||
: RpWidget(parent)
|
||||
, _info(this, st::exportTopBarLabel)
|
||||
, _shadow(this)
|
||||
, _progress(this, st::mediaPlayerPlayback)
|
||||
, _button(this) {
|
||||
resize(width(), st::mediaPlayerHeight + st::lineWidth);
|
||||
_progress->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
updateData(std::move(content));
|
||||
}
|
||||
|
||||
rpl::producer<> TopBar::clicks() const {
|
||||
return _button->clicks();
|
||||
}
|
||||
|
||||
void TopBar::updateData(Content &&content) {
|
||||
if (content.rows.empty()) {
|
||||
return;
|
||||
}
|
||||
const auto &row = content.rows[0];
|
||||
const auto clean = &TextUtilities::Clean;
|
||||
_info->setRichText(textcmdStartSemibold()
|
||||
+ clean(lang(lng_export_progress_title))
|
||||
+ textcmdStopSemibold()
|
||||
+ QString::fromUtf8(" \xe2\x80\x93 ")
|
||||
+ clean(row.label)
|
||||
+ ' '
|
||||
+ textcmdLink(1, clean(row.info)));
|
||||
_progress->setValue(row.progress);
|
||||
}
|
||||
|
||||
void TopBar::resizeEvent(QResizeEvent *e) {
|
||||
_info->moveToLeft(
|
||||
st::mediaPlayerPlayLeft + st::mediaPlayerPadding,
|
||||
st::mediaPlayerNameTop - st::mediaPlayerName.style.font->ascent);
|
||||
_button->setGeometry(0, 0, width(), height() - st::lineWidth);
|
||||
_progress->setGeometry(
|
||||
0,
|
||||
height() - st::mediaPlayerPlayback.fullWidth,
|
||||
width(),
|
||||
st::mediaPlayerPlayback.fullWidth);
|
||||
}
|
||||
|
||||
void TopBar::paintEvent(QPaintEvent *e) {
|
||||
Painter p(this);
|
||||
auto fill = e->rect().intersected(
|
||||
QRect(0, 0, width(), st::mediaPlayerHeight));
|
||||
if (!fill.isEmpty()) {
|
||||
p.fillRect(fill, st::mediaPlayerBg);
|
||||
}
|
||||
}
|
||||
|
||||
void TopBar::setShadowGeometryToLeft(int x, int y, int w, int h) {
|
||||
_shadow->setGeometryToLeft(x, y, w, h);
|
||||
}
|
||||
|
||||
void TopBar::showShadow() {
|
||||
_shadow->show();
|
||||
_progress->show();
|
||||
}
|
||||
|
||||
void TopBar::hideShadow() {
|
||||
_shadow->hide();
|
||||
_progress->hide();
|
||||
}
|
||||
|
||||
TopBar::~TopBar() = default;
|
||||
|
||||
} // namespace View
|
||||
} // namespace Export
|
51
Telegram/SourceFiles/export/view/export_view_top_bar.h
Normal file
51
Telegram/SourceFiles/export/view/export_view_top_bar.h
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "ui/rp_widget.h"
|
||||
|
||||
namespace Ui {
|
||||
class FlatLabel;
|
||||
class FilledSlider;
|
||||
class AbstractButton;
|
||||
class PlainShadow;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Export {
|
||||
namespace View {
|
||||
|
||||
struct Content;
|
||||
|
||||
class TopBar : public Ui::RpWidget {
|
||||
public:
|
||||
TopBar(QWidget *parent, Content &&content);
|
||||
|
||||
rpl::producer<> clicks() const;
|
||||
|
||||
void updateData(Content &&content);
|
||||
|
||||
void setShadowGeometryToLeft(int x, int y, int w, int h);
|
||||
void showShadow();
|
||||
void hideShadow();
|
||||
|
||||
~TopBar();
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
|
||||
private:
|
||||
object_ptr<Ui::FlatLabel> _info;
|
||||
object_ptr<Ui::PlainShadow> _shadow = { nullptr };
|
||||
object_ptr<Ui::FilledSlider> _progress;
|
||||
object_ptr<Ui::AbstractButton> _button;
|
||||
|
||||
};
|
||||
|
||||
} // namespace View
|
||||
} // namespace Export
|
@ -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) {
|
||||
|
@ -40,6 +40,14 @@ class Float;
|
||||
} // namespace Player
|
||||
} // namespace Media
|
||||
|
||||
namespace Export {
|
||||
namespace View {
|
||||
class TopBar;
|
||||
class PanelController;
|
||||
struct Content;
|
||||
} // namespace View
|
||||
} // namespace Export
|
||||
|
||||
namespace Ui {
|
||||
class ResizeArea;
|
||||
class PlainShadow;
|
||||
@ -50,7 +58,8 @@ class SlideWrap;
|
||||
|
||||
namespace Window {
|
||||
class Controller;
|
||||
class PlayerWrapWidget;
|
||||
template <typename Inner>
|
||||
class TopBarWrapWidget;
|
||||
class SectionMemento;
|
||||
class SectionWidget;
|
||||
class AbstractSectionWidget;
|
||||
@ -422,6 +431,11 @@ private:
|
||||
void destroyCallTopBar();
|
||||
void callTopBarHeightUpdated(int callTopBarHeight);
|
||||
|
||||
void setCurrentExportView(Export::View::PanelController *view);
|
||||
void createExportTopBar(Export::View::Content &&data);
|
||||
void destroyExportTopBar();
|
||||
void exportTopBarHeightUpdated();
|
||||
|
||||
void messagesAffected(
|
||||
not_null<PeerData*> peer,
|
||||
const MTPmessages_AffectedMessages &result);
|
||||
@ -545,7 +559,12 @@ private:
|
||||
base::weak_ptr<Calls::Call> _currentCall;
|
||||
object_ptr<Ui::SlideWrap<Calls::TopBar>> _callTopBar = { nullptr };
|
||||
|
||||
object_ptr<Window::PlayerWrapWidget> _player = { nullptr };
|
||||
Export::View::PanelController *_currentExportView = nullptr;
|
||||
object_ptr<Window::TopBarWrapWidget<Export::View::TopBar>> _exportTopBar
|
||||
= { nullptr };
|
||||
|
||||
object_ptr<Window::TopBarWrapWidget<Media::Player::Widget>> _player
|
||||
= { nullptr };
|
||||
object_ptr<Media::Player::VolumeWidget> _playerVolume = { nullptr };
|
||||
object_ptr<Media::Player::Panel> _playerPlaylist;
|
||||
object_ptr<Media::Player::Panel> _playerPanel;
|
||||
@ -558,6 +577,7 @@ private:
|
||||
|
||||
int _playerHeight = 0;
|
||||
int _callTopBarHeight = 0;
|
||||
int _exportTopBarHeight = 0;
|
||||
int _contentScrollAddToY = 0;
|
||||
|
||||
int32 updDate = 0;
|
||||
|
@ -9,15 +9,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
#include "settings/settings_inner_widget.h"
|
||||
#include "settings/settings_fixed_bar.h"
|
||||
#include "styles/style_settings.h"
|
||||
#include "styles/style_window.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "platform/platform_specific.h"
|
||||
#include "ui/widgets/scroll_area.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/toast/toast.h"
|
||||
#include "mainwindow.h"
|
||||
#include "mainwidget.h"
|
||||
#include "data/data_session.h"
|
||||
#include "storage/localstorage.h"
|
||||
#include "boxes/confirm_box.h"
|
||||
#include "lang/lang_keys.h"
|
||||
@ -32,6 +30,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "media/media_audio_track.h"
|
||||
#include "mainwindow.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "styles/style_settings.h"
|
||||
#include "styles/style_window.h"
|
||||
#include "styles/style_boxes.h"
|
||||
|
||||
namespace Settings {
|
||||
namespace {
|
||||
@ -128,7 +129,7 @@ void fillCodes() {
|
||||
Ui::Toast::Show("Forced custom scheme register.");
|
||||
});
|
||||
Codes.insert(qsl("export"), [] {
|
||||
App::wnd()->controller()->startDataExport();
|
||||
Auth().data().startExport();
|
||||
});
|
||||
|
||||
auto audioFilters = qsl("Audio files (*.wav *.mp3);;") + FileDialog::AllFilesFilter();
|
||||
|
@ -37,6 +37,8 @@ SeparatePanel::SeparatePanel()
|
||||
void SeparatePanel::setTitle(rpl::producer<QString> title) {
|
||||
_title.create(this, std::move(title), st::separatePanelTitle);
|
||||
_title->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
_title->show();
|
||||
updateTitleGeometry(width());
|
||||
}
|
||||
|
||||
void SeparatePanel::initControls() {
|
||||
@ -45,10 +47,7 @@ void SeparatePanel::initControls() {
|
||||
_back->moveToLeft(_padding.left(), _padding.top());
|
||||
_close->moveToRight(_padding.right(), _padding.top());
|
||||
if (_title) {
|
||||
_title->resizeToWidth(width
|
||||
- _padding.left() - _back->width()
|
||||
- _padding.right() - _close->width());
|
||||
updateTitlePosition();
|
||||
updateTitleGeometry(width);
|
||||
}
|
||||
}, lifetime());
|
||||
|
||||
@ -64,6 +63,13 @@ void SeparatePanel::initControls() {
|
||||
_titleLeft.finish();
|
||||
}
|
||||
|
||||
void SeparatePanel::updateTitleGeometry(int newWidth) {
|
||||
_title->resizeToWidth(newWidth
|
||||
- _padding.left() - _back->width()
|
||||
- _padding.right() - _close->width());
|
||||
updateTitlePosition();
|
||||
}
|
||||
|
||||
void SeparatePanel::updateTitlePosition() {
|
||||
if (!_title) {
|
||||
return;
|
||||
@ -100,6 +106,15 @@ void SeparatePanel::setBackAllowed(bool allowed) {
|
||||
}
|
||||
}
|
||||
|
||||
void SeparatePanel::setHideOnDeactivate(bool hideOnDeactivate) {
|
||||
_hideOnDeactivate = hideOnDeactivate;
|
||||
if (!_hideOnDeactivate) {
|
||||
showAndActivate();
|
||||
} else if (!isActiveWindow()) {
|
||||
hideGetDuration();
|
||||
}
|
||||
}
|
||||
|
||||
void SeparatePanel::showAndActivate() {
|
||||
toggleOpacityAnimation(true);
|
||||
raise();
|
||||
@ -115,6 +130,13 @@ void SeparatePanel::keyPressEvent(QKeyEvent *e) {
|
||||
return RpWidget::keyPressEvent(e);
|
||||
}
|
||||
|
||||
bool SeparatePanel::eventHook(QEvent *e) {
|
||||
if (e->type() == QEvent::WindowDeactivate && _hideOnDeactivate) {
|
||||
hideGetDuration();
|
||||
}
|
||||
return RpWidget::eventHook(e);
|
||||
}
|
||||
|
||||
void SeparatePanel::initLayout() {
|
||||
setWindowFlags(Qt::WindowFlags(Qt::FramelessWindowHint)
|
||||
| Qt::WindowStaysOnTopHint
|
||||
@ -506,7 +528,8 @@ void SeparatePanel::mousePressEvent(QMouseEvent *e) {
|
||||
_dragging = true;
|
||||
_dragStartMousePosition = e->globalPos();
|
||||
_dragStartMyPosition = QPoint(x(), y());
|
||||
} else if (!rect().contains(e->pos())) {
|
||||
} else if (!rect().contains(e->pos()) && _hideOnDeactivate) {
|
||||
hideGetDuration();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ public:
|
||||
void setTitle(rpl::producer<QString> title);
|
||||
void setInnerSize(QSize size);
|
||||
|
||||
void setHideOnDeactivate(bool hideOnDeactivate);
|
||||
void showAndActivate();
|
||||
int hideGetDuration();
|
||||
|
||||
@ -56,6 +57,7 @@ protected:
|
||||
void leaveEventHook(QEvent *e) override;
|
||||
void leaveToChildEvent(QEvent *e, QWidget *child) override;
|
||||
void keyPressEvent(QKeyEvent *e) override;
|
||||
bool eventHook(QEvent *e) override;
|
||||
|
||||
private:
|
||||
void initControls();
|
||||
@ -68,6 +70,7 @@ private:
|
||||
void opacityCallback();
|
||||
void ensureLayerCreated();
|
||||
|
||||
void updateTitleGeometry(int newWidth);
|
||||
void updateTitlePosition();
|
||||
void paintShadowBorder(Painter &p) const;
|
||||
void paintOpaqueBorder(Painter &p) const;
|
||||
@ -86,6 +89,7 @@ private:
|
||||
rpl::event_stream<> _userCloseRequests;
|
||||
rpl::event_stream<> _closeEvents;
|
||||
|
||||
bool _hideOnDeactivate = false;
|
||||
bool _useTransparency = true;
|
||||
style::margins _padding;
|
||||
|
||||
|
@ -1,31 +0,0 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "window/player_wrap_widget.h"
|
||||
|
||||
#include "ui/widgets/shadow.h"
|
||||
|
||||
namespace Window {
|
||||
|
||||
PlayerWrapWidget::PlayerWrapWidget(QWidget *parent)
|
||||
: Parent(parent, object_ptr<Media::Player::Widget>(parent)) {
|
||||
sizeValue(
|
||||
) | rpl::start_with_next([this](const QSize &size) {
|
||||
updateShadowGeometry(size);
|
||||
}, lifetime());
|
||||
}
|
||||
|
||||
void PlayerWrapWidget::updateShadowGeometry(const QSize &size) {
|
||||
auto skip = Adaptive::OneColumn() ? 0 : st::lineWidth;
|
||||
entity()->setShadowGeometryToLeft(
|
||||
skip,
|
||||
size.height() - st::lineWidth,
|
||||
size.width() - skip,
|
||||
st::lineWidth);
|
||||
}
|
||||
|
||||
} // namespace Window
|
@ -1,36 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "ui/wrap/slide_wrap.h"
|
||||
#include "media/player/media_player_widget.h"
|
||||
|
||||
namespace Ui {
|
||||
class PlainShadow;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Window {
|
||||
|
||||
class PlayerWrapWidget : public Ui::SlideWrap<Media::Player::Widget> {
|
||||
using Parent = Ui::SlideWrap<Media::Player::Widget>;
|
||||
|
||||
public:
|
||||
PlayerWrapWidget(QWidget *parent);
|
||||
|
||||
void updateAdaptiveLayout() {
|
||||
updateShadowGeometry(size());
|
||||
}
|
||||
void showShadow() {
|
||||
entity()->showShadow();
|
||||
}
|
||||
void hideShadow() {
|
||||
entity()->hideShadow();
|
||||
}
|
||||
int contentHeight() const {
|
||||
return qMax(height() - st::lineWidth, 0);
|
||||
}
|
||||
|
||||
private:
|
||||
void updateShadowGeometry(const QSize &size);
|
||||
|
||||
};
|
||||
|
||||
} // namespace Window
|
@ -16,8 +16,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_feed.h"
|
||||
#include "passport/passport_form_controller.h"
|
||||
#include "export/export_controller.h"
|
||||
#include "export/view/export_view_panel_controller.h"
|
||||
#include "boxes/calendar_box.h"
|
||||
#include "mainwidget.h"
|
||||
#include "mainwindow.h"
|
||||
@ -418,24 +416,6 @@ void Controller::clearPassportForm() {
|
||||
_passportForm = nullptr;
|
||||
}
|
||||
|
||||
void Controller::startDataExport() {
|
||||
using namespace Export;
|
||||
|
||||
_export = std::make_unique<Export::ControllerWrap>();
|
||||
_exportPanel = std::make_unique<Export::View::PanelController>(
|
||||
_export.get());
|
||||
|
||||
_exportPanel->closed(
|
||||
) | rpl::start_with_next([=] {
|
||||
clearDataExport();
|
||||
}, _export->lifetime());
|
||||
}
|
||||
|
||||
void Controller::clearDataExport() {
|
||||
_exportPanel = nullptr;
|
||||
_export = nullptr;
|
||||
}
|
||||
|
||||
void Controller::updateColumnLayout() {
|
||||
App::main()->updateColumnLayout();
|
||||
}
|
||||
|
@ -26,13 +26,6 @@ struct FormRequest;
|
||||
class FormController;
|
||||
} // namespace Passport
|
||||
|
||||
namespace Export {
|
||||
class ControllerWrap;
|
||||
namespace View {
|
||||
class PanelController;
|
||||
} // namespace View
|
||||
} // namespace Export
|
||||
|
||||
namespace Window {
|
||||
|
||||
class LayerWidget;
|
||||
@ -215,8 +208,6 @@ public:
|
||||
void showPassportForm(const Passport::FormRequest &request);
|
||||
void clearPassportForm();
|
||||
|
||||
void startDataExport();
|
||||
|
||||
base::Variable<bool> &dialogsListFocused() {
|
||||
return _dialogsListFocused;
|
||||
}
|
||||
@ -260,13 +251,10 @@ private:
|
||||
int dialogsWidth,
|
||||
int thirdWidth,
|
||||
int bodyWidth) const;
|
||||
void clearDataExport();
|
||||
|
||||
not_null<MainWindow*> _window;
|
||||
|
||||
std::unique_ptr<Passport::FormController> _passportForm;
|
||||
std::unique_ptr<Export::ControllerWrap> _export;
|
||||
std::unique_ptr<Export::View::PanelController> _exportPanel;
|
||||
|
||||
GifPauseReasons _gifPauseReasons = 0;
|
||||
base::Observable<void> _gifPauseLevelChanged;
|
||||
|
45
Telegram/SourceFiles/window/window_top_bar_wrap.h
Normal file
45
Telegram/SourceFiles/window/window_top_bar_wrap.h
Normal file
@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
|
||||
#include "ui/wrap/slide_wrap.h"
|
||||
|
||||
namespace Window {
|
||||
|
||||
template <typename Inner>
|
||||
class TopBarWrapWidget : public Ui::SlideWrap<Inner> {
|
||||
using Parent = Ui::SlideWrap<Inner>;
|
||||
|
||||
public:
|
||||
TopBarWrapWidget(QWidget *parent, object_ptr<Inner> inner)
|
||||
: Parent(parent, std::move(inner)) {
|
||||
this->sizeValue(
|
||||
) | rpl::start_with_next([this](const QSize &size) {
|
||||
updateShadowGeometry(size);
|
||||
}, this->lifetime());
|
||||
}
|
||||
|
||||
void updateAdaptiveLayout() {
|
||||
updateShadowGeometry(this->size());
|
||||
}
|
||||
void showShadow() {
|
||||
this->entity()->showShadow();
|
||||
}
|
||||
void hideShadow() {
|
||||
this->entity()->hideShadow();
|
||||
}
|
||||
int contentHeight() const {
|
||||
return qMax(this->height() - st::lineWidth, 0);
|
||||
}
|
||||
|
||||
private:
|
||||
void updateShadowGeometry(const QSize &size) {
|
||||
auto skip = Adaptive::OneColumn() ? 0 : st::lineWidth;
|
||||
this->entity()->setShadowGeometryToLeft(
|
||||
skip,
|
||||
size.height() - st::lineWidth,
|
||||
size.width() - skip,
|
||||
st::lineWidth);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace Window
|
@ -235,6 +235,8 @@
|
||||
<(src_loc)/export/view/export_view_progress.h
|
||||
<(src_loc)/export/view/export_view_settings.cpp
|
||||
<(src_loc)/export/view/export_view_settings.h
|
||||
<(src_loc)/export/view/export_view_top_bar.cpp
|
||||
<(src_loc)/export/view/export_view_top_bar.h
|
||||
<(src_loc)/history/admin_log/history_admin_log_filter.cpp
|
||||
<(src_loc)/history/admin_log/history_admin_log_filter.h
|
||||
<(src_loc)/history/admin_log/history_admin_log_inner.cpp
|
||||
@ -735,8 +737,6 @@
|
||||
<(src_loc)/window/notifications_manager_default.h
|
||||
<(src_loc)/window/notifications_utilities.cpp
|
||||
<(src_loc)/window/notifications_utilities.h
|
||||
<(src_loc)/window/player_wrap_widget.cpp
|
||||
<(src_loc)/window/player_wrap_widget.h
|
||||
<(src_loc)/window/section_memento.h
|
||||
<(src_loc)/window/section_widget.cpp
|
||||
<(src_loc)/window/section_widget.h
|
||||
@ -753,6 +753,7 @@
|
||||
<(src_loc)/window/window_slide_animation.cpp
|
||||
<(src_loc)/window/window_slide_animation.h
|
||||
<(src_loc)/window/window_title.h
|
||||
<(src_loc)/window/window_top_bar_wrap.h
|
||||
<(src_loc)/window/themes/window_theme.cpp
|
||||
<(src_loc)/window/themes/window_theme.h
|
||||
<(src_loc)/window/themes/window_theme_editor.cpp
|
||||
|
Loading…
Reference in New Issue
Block a user