mirror of
https://github.com/Qz3rK/tdesktop.git
synced 2026-07-03 14:15:08 +02:00
Use separate TopBar for History and Overview.
Move TopBar widget to History and Overview from MainWidget.
This commit is contained in:
@@ -31,10 +31,12 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/dropdown_menu.h"
|
||||
#include "dialogs/dialogs_layout.h"
|
||||
#include "window/window_controller.h"
|
||||
|
||||
namespace Window {
|
||||
|
||||
TopBarWidget::TopBarWidget(MainWidget *w) : TWidget(w)
|
||||
TopBarWidget::TopBarWidget(QWidget *parent, gsl::not_null<Window::Controller*> controller) : TWidget(parent)
|
||||
, _controller(controller)
|
||||
, _clearSelection(this, lang(lng_selected_clear), st::topBarClearButton)
|
||||
, _forward(this, lang(lng_selected_forward), st::defaultActiveButton)
|
||||
, _delete(this, lang(lng_selected_delete), st::defaultActiveButton)
|
||||
@@ -51,12 +53,12 @@ TopBarWidget::TopBarWidget(MainWidget *w) : TWidget(w)
|
||||
_search->setClickedCallback([this] { onSearch(); });
|
||||
_menuToggle->setClickedCallback([this] { showMenu(); });
|
||||
|
||||
subscribe(w->searchInPeerChanged(), [this](PeerData *peer) {
|
||||
subscribe(_controller->searchInPeerChanged(), [this](PeerData *peer) {
|
||||
_searchInPeer = peer;
|
||||
auto historyPeer = App::main() ? App::main()->historyPeer() : nullptr;
|
||||
_search->setForceRippled(historyPeer && historyPeer == _searchInPeer);
|
||||
});
|
||||
subscribe(w->historyPeerChanged(), [this](PeerData *peer) {
|
||||
subscribe(_controller->historyPeerChanged(), [this](PeerData *peer) {
|
||||
_search->setForceRippled(peer && peer == _searchInPeer, Ui::IconButton::SetForceRippledWay::SkipAnimation);
|
||||
update();
|
||||
});
|
||||
@@ -143,11 +145,11 @@ bool TopBarWidget::eventFilter(QObject *obj, QEvent *e) {
|
||||
return true;
|
||||
|
||||
case QEvent::Enter:
|
||||
main()->setMembersShowAreaActive(true);
|
||||
App::main()->setMembersShowAreaActive(true);
|
||||
break;
|
||||
|
||||
case QEvent::Leave:
|
||||
main()->setMembersShowAreaActive(false);
|
||||
App::main()->setMembersShowAreaActive(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -178,7 +180,7 @@ void TopBarWidget::paintEvent(QPaintEvent *e) {
|
||||
if (!_search->isHidden()) {
|
||||
decreaseWidth += _search->width();
|
||||
}
|
||||
auto paintCounter = main()->paintTopBar(p, decreaseWidth, ms);
|
||||
auto paintCounter = App::main()->paintTopBar(p, decreaseWidth, ms);
|
||||
p.restore();
|
||||
|
||||
if (paintCounter) {
|
||||
@@ -256,33 +258,12 @@ void TopBarWidget::updateControlsGeometry() {
|
||||
_search->moveToRight(_info->isHidden() ? _menuToggle->width() : _info->width(), otherButtonsTop);
|
||||
}
|
||||
|
||||
void TopBarWidget::startAnim() {
|
||||
_info->hide();
|
||||
_clearSelection->hide();
|
||||
_delete->hide();
|
||||
_forward->hide();
|
||||
_mediaType->hide();
|
||||
_search->hide();
|
||||
_menuToggle->hide();
|
||||
_menu.destroy();
|
||||
if (_membersShowArea) {
|
||||
_membersShowArea->hide();
|
||||
}
|
||||
|
||||
_animating = true;
|
||||
}
|
||||
|
||||
void TopBarWidget::stopAnim() {
|
||||
_animating = false;
|
||||
void TopBarWidget::animationFinished() {
|
||||
updateMembersShowArea();
|
||||
showAll();
|
||||
}
|
||||
|
||||
void TopBarWidget::showAll() {
|
||||
if (_animating) {
|
||||
updateControlsGeometry();
|
||||
return;
|
||||
}
|
||||
auto historyPeer = App::main() ? App::main()->historyPeer() : nullptr;
|
||||
auto overviewPeer = App::main() ? App::main()->overviewPeer() : nullptr;
|
||||
|
||||
@@ -290,7 +271,7 @@ void TopBarWidget::showAll() {
|
||||
_delete->setVisible(_canDelete);
|
||||
_forward->show();
|
||||
|
||||
_mediaType->setVisible(App::main() ? App::main()->mediaTypeSwitch() : false);
|
||||
_mediaType->setVisible(App::main() ? App::main()->showMediaTypeSwitch() : false);
|
||||
if (historyPeer && !overviewPeer) {
|
||||
if (Adaptive::OneColumn() || !App::main()->stackIsEmpty()) {
|
||||
_info->setPeer(historyPeer);
|
||||
@@ -330,7 +311,7 @@ void TopBarWidget::updateMembersShowArea() {
|
||||
};
|
||||
if (!membersShowAreaNeeded()) {
|
||||
if (_membersShowArea) {
|
||||
main()->setMembersShowAreaActive(false);
|
||||
App::main()->setMembersShowAreaActive(false);
|
||||
_membersShowArea.destroy();
|
||||
}
|
||||
return;
|
||||
@@ -397,8 +378,4 @@ Ui::RoundButton *TopBarWidget::mediaTypeButton() {
|
||||
return _mediaType;
|
||||
}
|
||||
|
||||
MainWidget *TopBarWidget::main() {
|
||||
return static_cast<MainWidget*>(parentWidget());
|
||||
}
|
||||
|
||||
} // namespace Window
|
||||
|
||||
@@ -31,17 +31,17 @@ class DropdownMenu;
|
||||
|
||||
namespace Window {
|
||||
|
||||
class Controller;
|
||||
|
||||
class TopBarWidget : public TWidget, private base::Subscriber {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TopBarWidget(MainWidget *w);
|
||||
TopBarWidget(QWidget *parent, gsl::not_null<Window::Controller*> controller);
|
||||
|
||||
void startAnim();
|
||||
void stopAnim();
|
||||
void showAll();
|
||||
void showSelected(int selectedCount, bool canDelete = false);
|
||||
|
||||
void animationFinished();
|
||||
void updateMembersShowArea();
|
||||
|
||||
Ui::RoundButton *mediaTypeButton();
|
||||
@@ -71,14 +71,12 @@ private:
|
||||
void updateAdaptiveLayout();
|
||||
int countSelectedButtonsTop(float64 selectedShown);
|
||||
|
||||
MainWidget *main();
|
||||
gsl::not_null<Window::Controller*> _controller;
|
||||
|
||||
PeerData *_searchInPeer = nullptr;
|
||||
int _selectedCount = 0;
|
||||
bool _canDelete = false;
|
||||
|
||||
bool _animating = false;
|
||||
|
||||
Animation _selectedShown;
|
||||
|
||||
object_ptr<Ui::RoundButton> _clearSelection;
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop version of Telegram messaging app, see https://telegram.org
|
||||
|
||||
Telegram Desktop is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
It is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
In addition, as a special exception, the copyright holders give permission
|
||||
to link the code of portions of this program with the OpenSSL library.
|
||||
|
||||
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
||||
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||
*/
|
||||
#include "window/window_controller.h"
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop version of Telegram messaging app, see https://telegram.org
|
||||
|
||||
Telegram Desktop is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
It is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
In addition, as a special exception, the copyright holders give permission
|
||||
to link the code of portions of this program with the OpenSSL library.
|
||||
|
||||
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
||||
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
namespace Window {
|
||||
|
||||
class Controller {
|
||||
public:
|
||||
Controller(MainWindow *window) : _window(window) {
|
||||
}
|
||||
|
||||
// This is needed for History TopBar updating when searchInPeer
|
||||
// is changed in the DialogsWidget of the current window.
|
||||
base::Observable<PeerData*> &searchInPeerChanged() {
|
||||
return _searchInPeerChanged;
|
||||
}
|
||||
|
||||
// This is needed while we have one HistoryWidget and one TopBarWidget
|
||||
// for all histories we show in a window. Once each history is shown
|
||||
// in its own HistoryWidget with its own TopBarWidget this can be removed.
|
||||
base::Observable<PeerData*> &historyPeerChanged() {
|
||||
return _historyPeerChanged;
|
||||
}
|
||||
|
||||
private:
|
||||
gsl::not_null<MainWindow*> _window;
|
||||
base::Observable<PeerData*> _searchInPeerChanged;
|
||||
base::Observable<PeerData*> _historyPeerChanged;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Window
|
||||
Reference in New Issue
Block a user