Skip to content

Commit

Permalink
Add some logs.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Jun 24, 2018
1 parent 2522e66 commit fcd2e28
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Telegram/SourceFiles/data/data_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ void Session::startExport() {

_exportPanel->stopRequests(
) | rpl::start_with_next([=] {
LOG(("Export Info: Stop requested."));
stopExport();
}, _export->lifetime());
}
Expand Down Expand Up @@ -129,6 +130,7 @@ void Session::stopExportWithConfirmation(FnMut<void()> callback) {
}
auto closeAndCall = [=, callback = std::move(callback)]() mutable {
auto saved = std::move(callback);
LOG(("Export Info: Stop With Confirmation."));
stopExport();
if (saved) {
saved();
Expand All @@ -139,6 +141,7 @@ void Session::stopExportWithConfirmation(FnMut<void()> callback) {

void Session::stopExport() {
if (_exportPanel) {
LOG(("Export Info: Destroying."));
_exportPanel = nullptr;
_exportViewChanges.fire(nullptr);
}
Expand Down
11 changes: 11 additions & 0 deletions Telegram/SourceFiles/export/view/export_view_panel_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ void PanelController::createPanel() {
_panel->setInnerSize(st::exportPanelSize);
_panel->closeRequests(
) | rpl::start_with_next([=] {
LOG(("Export Info: Panel Hide By Close."));
_panel->hideGetDuration();
}, _panel->lifetime());
_panelCloseEvents.fire(_panel->closeEvents());
Expand All @@ -157,6 +158,7 @@ void PanelController::showSettings() {

settings->cancelClicks(
) | rpl::start_with_next([=] {
LOG(("Export Info: Panel Hide By Cancel."));
_panel->hideGetDuration();
}, settings->lifetime());

Expand All @@ -170,6 +172,8 @@ void PanelController::showSettings() {
}

void PanelController::showError(const ApiErrorState &error) {
LOG(("Export Info: API Error '%1'.").arg(error.data.type()));

if (error.data.type() == qstr("TAKEOUT_INVALID")) {
showError(lang(lng_export_invalid));
} else if (error.data.type().startsWith(qstr("TAKEOUT_INIT_DELAY_"))) {
Expand Down Expand Up @@ -236,6 +240,7 @@ void PanelController::showError(const QString &text) {
weak->setCloseByOutsideClick(false);
weak->boxClosing(
) | rpl::start_with_next([=] {
LOG(("Export Info: Panel Hide By Error: %1.").arg(text));
_panel->hideGetDuration();
}, weak->lifetime());
if (hidden) {
Expand Down Expand Up @@ -265,6 +270,8 @@ void PanelController::showProgress() {
) | rpl::start_with_next([=] {
if (const auto finished = base::get_if<FinishedState>(&_state)) {
File::ShowInFolder(finished->path);
LOG(("Export Info: Panel Hide By Done: %1."
).arg(finished->path));
_panel->hideGetDuration();
}
}, progress->lifetime());
Expand All @@ -275,12 +282,14 @@ void PanelController::showProgress() {

void PanelController::stopWithConfirmation(FnMut<void()> callback) {
if (!_state.is<ProcessingState>()) {
LOG(("Export Info: Stop Panel Without Confirmation."));
stopExport();
callback();
return;
}
auto stop = [=, callback = std::move(callback)]() mutable {
if (auto saved = std::move(callback)) {
LOG(("Export Info: Stop Panel With Confirmation."));
stopExport();
saved();
} else {
Expand Down Expand Up @@ -310,6 +319,7 @@ void PanelController::stopWithConfirmation(FnMut<void()> callback) {
void PanelController::stopExport() {
_stopRequested = true;
_panel->showAndActivate();
LOG(("Export Info: Panel Hide By Stop"));
_panel->hideGetDuration();
}

Expand All @@ -334,6 +344,7 @@ void PanelController::updateState(State &&state) {
_panel->setTitle(Lang::Viewer(lng_export_title));
_panel->setHideOnDeactivate(false);
} else if (_state.is<CancelledState>()) {
LOG(("Export Info: Stop Panel After Cancel."));
stopExport();
}
}
Expand Down
3 changes: 3 additions & 0 deletions Telegram/SourceFiles/mainwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1696,14 +1696,17 @@ void MainWidget::setCurrentExportView(Export::View::PanelController *view) {
) | rpl::start_with_next([=](Export::View::Content &&data) {
if (!data.rows.empty()
&& data.rows[0].id == Export::View::Content::kDoneId) {
LOG(("Export Info: Destroy top bar by Done."));
destroyExportTopBar();
} else if (!_exportTopBar) {
LOG(("Export Info: Create top bar by State."));
createExportTopBar(std::move(data));
} else {
_exportTopBar->entity()->updateData(std::move(data));
}
}, _currentExportView->lifetime());
} else {
LOG(("Export Info: Destroy top bar by controller removal."));
destroyExportTopBar();
}
}
Expand Down
5 changes: 5 additions & 0 deletions Telegram/SourceFiles/ui/widgets/separate_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ void SeparatePanel::setHideOnDeactivate(bool hideOnDeactivate) {
if (!_hideOnDeactivate) {
showAndActivate();
} else if (!isActiveWindow()) {
LOG(("Export Info: Panel Hide On Inactive Change."));
hideGetDuration();
}
}
Expand All @@ -132,6 +133,7 @@ void SeparatePanel::keyPressEvent(QKeyEvent *e) {

bool SeparatePanel::eventHook(QEvent *e) {
if (e->type() == QEvent::WindowDeactivate && _hideOnDeactivate) {
LOG(("Export Info: Panel Hide On Inactive Window."));
hideGetDuration();
}
return RpWidget::eventHook(e);
Expand Down Expand Up @@ -230,12 +232,14 @@ void SeparatePanel::finishClose() {
hide();
crl::on_main(this, [=] {
if (isHidden() && !_visible && !_opacityAnimation.animating()) {
LOG(("Export Info: Panel Closed."));
_closeEvents.fire({});
}
});
}

int SeparatePanel::hideGetDuration() {
LOG(("Export Info: Panel Hide Requested."));
toggleOpacityAnimation(false);
if (_animationCache.isNull()) {
finishClose();
Expand Down Expand Up @@ -529,6 +533,7 @@ void SeparatePanel::mousePressEvent(QMouseEvent *e) {
_dragStartMousePosition = e->globalPos();
_dragStartMyPosition = QPoint(x(), y());
} else if (!rect().contains(e->pos()) && _hideOnDeactivate) {
LOG(("Export Info: Panel Hide On Click."));
hideGetDuration();
}
}
Expand Down

0 comments on commit fcd2e28

Please sign in to comment.