mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Make "Archived chats" a normal menu item.
This commit is contained in:
parent
3ad978fc72
commit
2e435f07a3
6 changed files with 26 additions and 32 deletions
BIN
Telegram/Resources/icons/settings/archive.png
Normal file
BIN
Telegram/Resources/icons/settings/archive.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 314 B |
BIN
Telegram/Resources/icons/settings/archive@2x.png
Normal file
BIN
Telegram/Resources/icons/settings/archive@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 446 B |
BIN
Telegram/Resources/icons/settings/archive@3x.png
Normal file
BIN
Telegram/Resources/icons/settings/archive@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 644 B |
|
@ -73,6 +73,7 @@ settingsIconKey: icon {{ "settings/key", settingsIconFg }};
|
||||||
settingsIconReload: icon {{ "settings/reload", settingsIconFg }};
|
settingsIconReload: icon {{ "settings/reload", settingsIconFg }};
|
||||||
settingsIconNight: icon {{ "settings/night", settingsIconFg }};
|
settingsIconNight: icon {{ "settings/night", settingsIconFg }};
|
||||||
settingsIconSettings: icon {{ "settings/settings", settingsIconFg }};
|
settingsIconSettings: icon {{ "settings/settings", settingsIconFg }};
|
||||||
|
settingsIconArchive: icon {{ "settings/archive", settingsIconFg }};
|
||||||
|
|
||||||
settingsSetPhotoSkip: 7px;
|
settingsSetPhotoSkip: 7px;
|
||||||
|
|
||||||
|
|
|
@ -580,7 +580,6 @@ MainMenu::MainMenu(
|
||||||
Ui::UserpicButton::Role::Custom,
|
Ui::UserpicButton::Role::Custom,
|
||||||
st::mainMenuUserpic)
|
st::mainMenuUserpic)
|
||||||
, _toggleAccounts(this)
|
, _toggleAccounts(this)
|
||||||
, _archiveButton(this, st::mainMenuCloudButton)
|
|
||||||
, _scroll(this, st::defaultSolidScroll)
|
, _scroll(this, st::defaultSolidScroll)
|
||||||
, _inner(_scroll->setOwnedWidget(
|
, _inner(_scroll->setOwnedWidget(
|
||||||
object_ptr<Ui::VerticalLayout>(_scroll.data())))
|
object_ptr<Ui::VerticalLayout>(_scroll.data())))
|
||||||
|
@ -602,10 +601,10 @@ MainMenu::MainMenu(
|
||||||
st::mainMenuVersionLabel)) {
|
st::mainMenuVersionLabel)) {
|
||||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||||
|
|
||||||
setupArchiveButton();
|
|
||||||
setupUserpicButton();
|
setupUserpicButton();
|
||||||
setupAccountsToggle();
|
setupAccountsToggle();
|
||||||
setupAccounts();
|
setupAccounts();
|
||||||
|
setupArchive();
|
||||||
setupMenu();
|
setupMenu();
|
||||||
|
|
||||||
_nightThemeSwitch.setCallback([this] {
|
_nightThemeSwitch.setCallback([this] {
|
||||||
|
@ -684,7 +683,9 @@ MainMenu::MainMenu(
|
||||||
initResetScaleButton();
|
initResetScaleButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainMenu::setupArchiveButton() {
|
void MainMenu::setupArchive() {
|
||||||
|
using namespace Settings;
|
||||||
|
|
||||||
const auto controller = _controller;
|
const auto controller = _controller;
|
||||||
const auto folder = [=] {
|
const auto folder = [=] {
|
||||||
return controller->session().data().folderLoaded(Data::Folder::kId);
|
return controller->session().data().folderLoaded(Data::Folder::kId);
|
||||||
|
@ -701,9 +702,24 @@ void MainMenu::setupArchiveButton() {
|
||||||
&& !f->chatsList()->empty()
|
&& !f->chatsList()->empty()
|
||||||
&& controller->session().settings().archiveInMainMenu();
|
&& controller->session().settings().archiveInMainMenu();
|
||||||
};
|
};
|
||||||
_archiveButton->setVisible(checkArchive());
|
|
||||||
_archiveButton->setAcceptBoth(true);
|
const auto wrap = _menu->add(
|
||||||
_archiveButton->clicks(
|
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||||
|
_menu,
|
||||||
|
object_ptr<Ui::VerticalLayout>(_menu)));
|
||||||
|
const auto inner = wrap->entity();
|
||||||
|
wrap->toggle(checkArchive(), anim::type::instant);
|
||||||
|
|
||||||
|
const auto button = AddButton(
|
||||||
|
inner,
|
||||||
|
tr::lng_archived_name(),
|
||||||
|
st::mainMenuButton,
|
||||||
|
{ &st::settingsIconArchive, kIconGray });
|
||||||
|
inner->add(
|
||||||
|
object_ptr<Ui::PlainShadow>(inner),
|
||||||
|
{ 0, st::mainMenuSkip, 0, st::mainMenuSkip });
|
||||||
|
button->setAcceptBoth(true);
|
||||||
|
button->clicks(
|
||||||
) | rpl::start_with_next([=](Qt::MouseButton which) {
|
) | rpl::start_with_next([=](Qt::MouseButton which) {
|
||||||
if (which == Qt::LeftButton) {
|
if (which == Qt::LeftButton) {
|
||||||
showArchive();
|
showArchive();
|
||||||
|
@ -739,14 +755,14 @@ void MainMenu::setupArchiveButton() {
|
||||||
addAction);
|
addAction);
|
||||||
|
|
||||||
_contextMenu->popup(QCursor::pos());
|
_contextMenu->popup(QCursor::pos());
|
||||||
}, _archiveButton->lifetime());
|
}, button->lifetime());
|
||||||
|
|
||||||
controller->session().data().chatsListChanges(
|
controller->session().data().chatsListChanges(
|
||||||
) | rpl::filter([](Data::Folder *folder) {
|
) | rpl::filter([](Data::Folder *folder) {
|
||||||
return folder && (folder->id() == Data::Folder::kId);
|
return folder && (folder->id() == Data::Folder::kId);
|
||||||
}) | rpl::start_with_next([=](Data::Folder *folder) {
|
}) | rpl::start_with_next([=](Data::Folder *folder) {
|
||||||
const auto isArchiveVisible = checkArchive();
|
const auto isArchiveVisible = checkArchive();
|
||||||
_archiveButton->setVisible(isArchiveVisible);
|
wrap->toggle(isArchiveVisible, anim::type::normal);
|
||||||
if (!isArchiveVisible) {
|
if (!isArchiveVisible) {
|
||||||
_contextMenu = nullptr;
|
_contextMenu = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -1130,13 +1146,6 @@ void MainMenu::updateControlsGeometry() {
|
||||||
st::mainMenuUserpicTop);
|
st::mainMenuUserpicTop);
|
||||||
if (_resetScaleButton) {
|
if (_resetScaleButton) {
|
||||||
_resetScaleButton->moveToRight(0, 0);
|
_resetScaleButton->moveToRight(0, 0);
|
||||||
_archiveButton->moveToRight(_resetScaleButton->width(), 0);
|
|
||||||
} else {
|
|
||||||
const auto right = st::mainMenuTogglePosition.x()
|
|
||||||
- (_archiveButton->width() / 2);
|
|
||||||
const auto top = st::mainMenuUserpicTop
|
|
||||||
- (_archiveButton->height() - st::mainMenuCloudSize) / 2;
|
|
||||||
_archiveButton->moveToRight(right, top);
|
|
||||||
}
|
}
|
||||||
_toggleAccounts->setGeometry(
|
_toggleAccounts->setGeometry(
|
||||||
0,
|
0,
|
||||||
|
@ -1201,21 +1210,6 @@ void MainMenu::paintEvent(QPaintEvent *e) {
|
||||||
st::mainMenuCoverStatusTop,
|
st::mainMenuCoverStatusTop,
|
||||||
width(),
|
width(),
|
||||||
_phoneText);
|
_phoneText);
|
||||||
|
|
||||||
// Draw Archive button.
|
|
||||||
if (!_archiveButton->isHidden()) {
|
|
||||||
const auto folder = _controller->session().data().folderLoaded(
|
|
||||||
Data::Folder::kId);
|
|
||||||
if (folder) {
|
|
||||||
folder->paintUserpic(
|
|
||||||
p,
|
|
||||||
_archiveButton->x() + (_archiveButton->width() - st::mainMenuCloudSize) / 2,
|
|
||||||
_archiveButton->y() + (_archiveButton->height() - st::mainMenuCloudSize) / 2,
|
|
||||||
st::mainMenuCloudSize,
|
|
||||||
isFill ? st::mainMenuCloudBg : st::msgServiceBg,
|
|
||||||
isFill ? st::mainMenuCloudFg : st::msgServiceFg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
auto other = QRect(0, st::mainMenuCoverHeight, width(), height() - st::mainMenuCoverHeight).intersected(clip);
|
auto other = QRect(0, st::mainMenuCoverHeight, width(), height() - st::mainMenuCoverHeight).intersected(clip);
|
||||||
if (!other.isEmpty()) {
|
if (!other.isEmpty()) {
|
||||||
|
|
|
@ -55,12 +55,12 @@ private:
|
||||||
class ToggleAccountsButton;
|
class ToggleAccountsButton;
|
||||||
class ResetScaleButton;
|
class ResetScaleButton;
|
||||||
|
|
||||||
void setupArchiveButton();
|
|
||||||
void setupUserpicButton();
|
void setupUserpicButton();
|
||||||
void setupAccounts();
|
void setupAccounts();
|
||||||
void setupAccountsToggle();
|
void setupAccountsToggle();
|
||||||
[[nodiscard]] not_null<Ui::SlideWrap<Ui::RippleButton>*> setupAddAccount(
|
[[nodiscard]] not_null<Ui::SlideWrap<Ui::RippleButton>*> setupAddAccount(
|
||||||
not_null<Ui::VerticalLayout*> container);
|
not_null<Ui::VerticalLayout*> container);
|
||||||
|
void setupArchive();
|
||||||
void setupMenu();
|
void setupMenu();
|
||||||
void rebuildAccounts();
|
void rebuildAccounts();
|
||||||
void updateControlsGeometry();
|
void updateControlsGeometry();
|
||||||
|
@ -73,7 +73,6 @@ private:
|
||||||
const not_null<SessionController*> _controller;
|
const not_null<SessionController*> _controller;
|
||||||
object_ptr<Ui::UserpicButton> _userpicButton;
|
object_ptr<Ui::UserpicButton> _userpicButton;
|
||||||
object_ptr<ToggleAccountsButton> _toggleAccounts;
|
object_ptr<ToggleAccountsButton> _toggleAccounts;
|
||||||
object_ptr<Ui::IconButton> _archiveButton;
|
|
||||||
object_ptr<ResetScaleButton> _resetScaleButton = { nullptr };
|
object_ptr<ResetScaleButton> _resetScaleButton = { nullptr };
|
||||||
object_ptr<Ui::ScrollArea> _scroll;
|
object_ptr<Ui::ScrollArea> _scroll;
|
||||||
not_null<Ui::VerticalLayout*> _inner;
|
not_null<Ui::VerticalLayout*> _inner;
|
||||||
|
|
Loading…
Add table
Reference in a new issue