mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 22:27:20 +02:00
Added new Adaptive class to replace legacy Adaptive namespace.
Temporarily named class as AdaptiveModern.
This commit is contained in:
parent
d2c8780c0f
commit
2d90a06078
7 changed files with 111 additions and 0 deletions
|
@ -1086,6 +1086,8 @@ PRIVATE
|
|||
window/section_memento.h
|
||||
window/section_widget.cpp
|
||||
window/section_widget.h
|
||||
window/window_adaptive.cpp
|
||||
window/window_adaptive.h
|
||||
window/window_connecting_widget.cpp
|
||||
window/window_connecting_widget.h
|
||||
window/window_controller.cpp
|
||||
|
|
51
Telegram/SourceFiles/window/window_adaptive.cpp
Normal file
51
Telegram/SourceFiles/window/window_adaptive.cpp
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
|
||||
*/
|
||||
#include "window/window_adaptive.h"
|
||||
|
||||
#include "history/history_item.h"
|
||||
#include "data/data_media_types.h"
|
||||
#include "data/data_session.h"
|
||||
|
||||
namespace Window {
|
||||
|
||||
AdaptiveModern::AdaptiveModern() = default;
|
||||
|
||||
void AdaptiveModern::setWindowLayout(WindowLayout value) {
|
||||
_layout = value;
|
||||
}
|
||||
|
||||
void AdaptiveModern::setChatLayout(ChatLayout value) {
|
||||
_chatLayout = value;
|
||||
}
|
||||
|
||||
rpl::producer<> AdaptiveModern::changed() const {
|
||||
return rpl::merge(
|
||||
_chatLayout.changes() | rpl::to_empty,
|
||||
_layout.changes() | rpl::to_empty);
|
||||
}
|
||||
|
||||
rpl::producer<bool> AdaptiveModern::oneColumnValue() const {
|
||||
return _layout.value(
|
||||
) | rpl::map([=] {
|
||||
return isOneColumn();
|
||||
});
|
||||
}
|
||||
|
||||
bool AdaptiveModern::isOneColumn() const {
|
||||
return _layout.current() == WindowLayout::OneColumn;
|
||||
}
|
||||
|
||||
bool AdaptiveModern::isNormal() const {
|
||||
return _layout.current() == WindowLayout::Normal;
|
||||
}
|
||||
|
||||
bool AdaptiveModern::isThreeColumn() const {
|
||||
return _layout.current() == WindowLayout::ThreeColumn;
|
||||
}
|
||||
|
||||
} // namespace Window
|
43
Telegram/SourceFiles/window/window_adaptive.h
Normal file
43
Telegram/SourceFiles/window/window_adaptive.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
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
|
||||
|
||||
namespace Window {
|
||||
|
||||
class AdaptiveModern {
|
||||
public:
|
||||
enum class WindowLayout {
|
||||
OneColumn,
|
||||
Normal,
|
||||
ThreeColumn,
|
||||
};
|
||||
|
||||
enum class ChatLayout {
|
||||
Normal,
|
||||
Wide,
|
||||
};
|
||||
|
||||
AdaptiveModern();
|
||||
|
||||
void setWindowLayout(WindowLayout value);
|
||||
void setChatLayout(ChatLayout value);
|
||||
|
||||
[[nodiscard]] rpl::producer<> changed() const;
|
||||
[[nodiscard]] rpl::producer<bool> oneColumnValue() const;
|
||||
|
||||
[[nodiscard]] bool isOneColumn() const;
|
||||
[[nodiscard]] bool isNormal() const;
|
||||
[[nodiscard]] bool isThreeColumn() const;
|
||||
|
||||
private:
|
||||
rpl::variable<ChatLayout> _chatLayout;
|
||||
rpl::variable<WindowLayout> _layout;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Window
|
|
@ -41,6 +41,7 @@ namespace Window {
|
|||
|
||||
Controller::Controller()
|
||||
: _widget(this)
|
||||
, _adaptive(std::make_unique<AdaptiveModern>())
|
||||
, _isActiveTimer([=] { updateIsActive(); }) {
|
||||
_widget.init();
|
||||
}
|
||||
|
@ -367,4 +368,8 @@ void Controller::showLogoutConfirmation() {
|
|||
callback));
|
||||
}
|
||||
|
||||
Window::AdaptiveModern &Controller::adaptive() const {
|
||||
return *_adaptive;
|
||||
}
|
||||
|
||||
} // namespace Window
|
||||
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#pragma once
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "window/window_adaptive.h"
|
||||
#include "ui/layers/layer_widget.h"
|
||||
|
||||
namespace Main {
|
||||
|
@ -39,6 +40,8 @@ public:
|
|||
}
|
||||
[[nodiscard]] bool locked() const;
|
||||
|
||||
[[nodiscard]] AdaptiveModern &adaptive() const;
|
||||
|
||||
void finishFirstShow();
|
||||
|
||||
void setupPasscodeLock();
|
||||
|
@ -90,6 +93,7 @@ private:
|
|||
|
||||
Main::Account *_account = nullptr;
|
||||
::MainWindow _widget;
|
||||
const std::unique_ptr<AdaptiveModern> _adaptive;
|
||||
std::unique_ptr<SessionController> _sessionController;
|
||||
base::Timer _isActiveTimer;
|
||||
QPointer<Ui::BoxContent> _termsBox;
|
||||
|
|
|
@ -1205,6 +1205,10 @@ void SessionController::showNewChannel() {
|
|||
Ui::LayerOption::KeepOther);
|
||||
}
|
||||
|
||||
Window::AdaptiveModern &SessionController::adaptive() const {
|
||||
return _window->adaptive();
|
||||
}
|
||||
|
||||
SessionController::~SessionController() = default;
|
||||
|
||||
} // namespace Window
|
||||
|
|
|
@ -53,6 +53,7 @@ class MainWindow;
|
|||
class SectionMemento;
|
||||
class Controller;
|
||||
class FiltersMenu;
|
||||
class AdaptiveModern;
|
||||
|
||||
enum class GifPauseReason {
|
||||
Any = 0,
|
||||
|
@ -238,6 +239,7 @@ public:
|
|||
}
|
||||
[[nodiscard]] not_null<::MainWindow*> widget() const;
|
||||
[[nodiscard]] not_null<MainWidget*> content() const;
|
||||
[[nodiscard]] AdaptiveModern &adaptive() const;
|
||||
|
||||
// We need access to this from MainWidget::MainWidget, where
|
||||
// we can't call content() yet.
|
||||
|
|
Loading…
Add table
Reference in a new issue