mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Moved contacts box preparing to single place.
This commit is contained in:
parent
8b27aa5331
commit
367b028094
5 changed files with 22 additions and 20 deletions
|
@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_histories.h"
|
#include "data/data_histories.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "dialogs/dialogs_main_list.h"
|
#include "dialogs/dialogs_main_list.h"
|
||||||
|
@ -104,6 +105,20 @@ void AddBotToGroup(not_null<UserData*> bot, not_null<PeerData*> chat) {
|
||||||
// return mapFromGlobal(QCursor::pos()) - _st.rippleAreaPosition;
|
// return mapFromGlobal(QCursor::pos()) - _st.rippleAreaPosition;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
object_ptr<Ui::BoxContent> PrepareContactsBox(
|
||||||
|
not_null<Window::SessionController*> sessionController) {
|
||||||
|
const auto controller = sessionController;
|
||||||
|
auto delegate = [=](not_null<PeerListBox*> box) {
|
||||||
|
box->addButton(tr::lng_close(), [=] { box->closeBox(); });
|
||||||
|
box->addLeftButton(
|
||||||
|
tr::lng_profile_add_contact(),
|
||||||
|
[=] { controller->widget()->onShowAddContact(); });
|
||||||
|
};
|
||||||
|
return Box<PeerListBox>(
|
||||||
|
std::make_unique<ContactsBoxController>(controller),
|
||||||
|
std::move(delegate));
|
||||||
|
}
|
||||||
|
|
||||||
void PeerListRowWithLink::setActionLink(const QString &action) {
|
void PeerListRowWithLink::setActionLink(const QString &action) {
|
||||||
_action = action;
|
_action = action;
|
||||||
refreshActionLink();
|
refreshActionLink();
|
||||||
|
|
|
@ -31,9 +31,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
class History;
|
class History;
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
|
class SessionController;
|
||||||
class SessionNavigation;
|
class SessionNavigation;
|
||||||
} // namespace Window
|
} // namespace Window
|
||||||
|
|
||||||
|
[[nodiscard]] object_ptr<Ui::BoxContent> PrepareContactsBox(
|
||||||
|
not_null<Window::SessionController*> sessionController);
|
||||||
|
|
||||||
class PeerListRowWithLink : public PeerListRow {
|
class PeerListRowWithLink : public PeerListRow {
|
||||||
public:
|
public:
|
||||||
using PeerListRow::PeerListRow;
|
using PeerListRow::PeerListRow;
|
||||||
|
|
|
@ -950,18 +950,7 @@ void MainWindow::createGlobalMenu() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ui::show(
|
Ui::show(PrepareContactsBox(sessionController()));
|
||||||
Box<PeerListBox>(std::make_unique<ContactsBoxController>(
|
|
||||||
sessionController()),
|
|
||||||
[](not_null<PeerListBox*> box) {
|
|
||||||
box->addButton(tr::lng_close(), [box] {
|
|
||||||
box->closeBox();
|
|
||||||
});
|
|
||||||
|
|
||||||
box->addLeftButton(tr::lng_profile_add_contact(), [] {
|
|
||||||
App::wnd()->onShowAddContact();
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
psAddContact = tools->addAction(
|
psAddContact = tools->addAction(
|
||||||
|
|
|
@ -721,10 +721,7 @@ void MainWindow::createGlobalMenu() {
|
||||||
if (!sessionController()) {
|
if (!sessionController()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Ui::show(Box<PeerListBox>(std::make_unique<ContactsBoxController>(sessionController()), [](not_null<PeerListBox*> box) {
|
Ui::show(PrepareContactsBox(sessionController()));
|
||||||
box->addButton(tr::lng_close(), [box] { box->closeBox(); });
|
|
||||||
box->addLeftButton(tr::lng_profile_add_contact(), [] { App::wnd()->onShowAddContact(); });
|
|
||||||
}));
|
|
||||||
}));
|
}));
|
||||||
psAddContact = window->addAction(tr::lng_mac_menu_add_contact(tr::now), App::wnd(), SLOT(onShowAddContact()));
|
psAddContact = window->addAction(tr::lng_mac_menu_add_contact(tr::now), App::wnd(), SLOT(onShowAddContact()));
|
||||||
window->addSeparator();
|
window->addSeparator();
|
||||||
|
|
|
@ -861,10 +861,7 @@ void MainMenu::refreshMenu() {
|
||||||
App::wnd()->onShowNewChannel();
|
App::wnd()->onShowNewChannel();
|
||||||
}, &st::mainMenuNewChannel, &st::mainMenuNewChannelOver);
|
}, &st::mainMenuNewChannel, &st::mainMenuNewChannelOver);
|
||||||
_menu->addAction(tr::lng_menu_contacts(tr::now), [=] {
|
_menu->addAction(tr::lng_menu_contacts(tr::now), [=] {
|
||||||
Ui::show(Box<PeerListBox>(std::make_unique<ContactsBoxController>(controller), [](not_null<PeerListBox*> box) {
|
Ui::show(PrepareContactsBox(controller));
|
||||||
box->addButton(tr::lng_close(), [box] { box->closeBox(); });
|
|
||||||
box->addLeftButton(tr::lng_profile_add_contact(), [] { App::wnd()->onShowAddContact(); });
|
|
||||||
}));
|
|
||||||
}, &st::mainMenuContacts, &st::mainMenuContactsOver);
|
}, &st::mainMenuContacts, &st::mainMenuContactsOver);
|
||||||
if (_controller->session().serverConfig().phoneCallsEnabled.current()) {
|
if (_controller->session().serverConfig().phoneCallsEnabled.current()) {
|
||||||
_menu->addAction(tr::lng_menu_calls(tr::now), [=] {
|
_menu->addAction(tr::lng_menu_calls(tr::now), [=] {
|
||||||
|
|
Loading…
Add table
Reference in a new issue