mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-08-08 20:53:54 +00:00
Added ability to open personal channel and "view channel" in window.
This commit is contained in:
@@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "base/call_delayed.h"
|
||||
#include "base/event_filter.h"
|
||||
#include "base/options.h"
|
||||
#include "base/qt/qt_key_modifiers.h"
|
||||
#include "base/timer_rpl.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "boxes/peers/add_bot_to_chat_box.h"
|
||||
@@ -97,6 +98,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
#include "window/window_controller.h" // Window::Controller::show.
|
||||
#include "window/window_peer_menu.h"
|
||||
#include "window/window_separate_id.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_channel_earn.h" // st::channelEarnCurrencyCommonMargins
|
||||
@@ -1026,7 +1028,7 @@ auto AddActionButton(
|
||||
};
|
||||
|
||||
template <typename Text, typename ToggleOn, typename Callback>
|
||||
[[nodiscard]] auto AddMainButton(
|
||||
auto AddMainButton(
|
||||
not_null<Ui::VerticalLayout*> parent,
|
||||
Text &&text,
|
||||
ToggleOn &&toggleOn,
|
||||
@@ -1045,6 +1047,7 @@ template <typename Text, typename ToggleOn, typename Callback>
|
||||
if (buttonTracker) {
|
||||
buttonTracker->track(button);
|
||||
}
|
||||
return button->entity();
|
||||
}
|
||||
|
||||
rpl::producer<CreditsAmount> AddCurrencyAction(
|
||||
@@ -2120,11 +2123,47 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupPersonalChannel(
|
||||
) | rpl::on_next([=](const QRect &rect) {
|
||||
button->setGeometry(rect);
|
||||
}, button->lifetime());
|
||||
button->setClickedCallback([=, msg = item->fullId().msg] {
|
||||
const auto channelPeer = item->history()->peer;
|
||||
const auto msg = item->fullId().msg;
|
||||
const auto openInWindow = [=] {
|
||||
window->showInNewWindow(
|
||||
Window::SeparateId(channelPeer),
|
||||
msg);
|
||||
};
|
||||
const auto openInCurrent = [=] {
|
||||
window->showPeerHistory(
|
||||
item->history()->peer,
|
||||
channelPeer,
|
||||
Window::SectionShow::Way::Forward,
|
||||
msg);
|
||||
};
|
||||
button->setAcceptBoth();
|
||||
struct State {
|
||||
base::unique_qptr<Ui::PopupMenu> menu;
|
||||
};
|
||||
const auto state
|
||||
= button->lifetime().make_state<State>();
|
||||
button->addClickHandler([=](Qt::MouseButton mouse) {
|
||||
if (mouse == Qt::RightButton) {
|
||||
state->menu = base::make_unique_q<Ui::PopupMenu>(
|
||||
button,
|
||||
st::popupMenuWithIcons);
|
||||
state->menu->addAction(
|
||||
tr::lng_context_new_window(tr::now),
|
||||
[=] {
|
||||
base::call_delayed(
|
||||
st::popupMenuWithIcons.showDuration,
|
||||
crl::guard(button, openInWindow));
|
||||
},
|
||||
&st::menuIconNewWindow);
|
||||
state->menu->popup(QCursor::pos());
|
||||
return;
|
||||
}
|
||||
if (base::IsCtrlPressed()
|
||||
|| mouse == Qt::MiddleButton) {
|
||||
openInWindow();
|
||||
} else {
|
||||
openInCurrent();
|
||||
}
|
||||
});
|
||||
button->lower();
|
||||
inner->lifetime().make_state<base::unique_qptr<Ui::RpWidget>>(
|
||||
@@ -2380,19 +2419,54 @@ void DetailsFiller::addViewChannelButton(
|
||||
_controller->wrapValue(),
|
||||
std::move(activePeerValue),
|
||||
(_1 != Wrap::Side) || (_2 != channel));
|
||||
auto viewChannel = [=] {
|
||||
const auto openInWindow = [=] {
|
||||
window->showInNewWindow(Window::SeparateId(channel));
|
||||
};
|
||||
const auto openInCurrent = [=] {
|
||||
window->showPeerHistory(
|
||||
channel,
|
||||
Window::SectionShow::Way::Forward);
|
||||
};
|
||||
struct State {
|
||||
base::unique_qptr<Ui::PopupMenu> menu;
|
||||
};
|
||||
const auto state = wrap->lifetime().make_state<State>();
|
||||
auto viewChannel = [=](Qt::MouseButton mouse) {
|
||||
if (mouse == Qt::RightButton) {
|
||||
return;
|
||||
}
|
||||
if (base::IsCtrlPressed() || mouse == Qt::MiddleButton) {
|
||||
openInWindow();
|
||||
} else {
|
||||
openInCurrent();
|
||||
}
|
||||
};
|
||||
wrap->toggleOn(rpl::duplicate(viewChannelVisible));
|
||||
AddMainButton(
|
||||
const auto button = AddMainButton(
|
||||
wrap->entity(),
|
||||
tr::lng_profile_view_channel(),
|
||||
std::move(viewChannelVisible),
|
||||
std::move(viewChannel),
|
||||
tracker,
|
||||
buttonTracker);
|
||||
button->setAcceptBoth();
|
||||
button->addClickHandler([=](Qt::MouseButton mouse) {
|
||||
if (mouse != Qt::RightButton) {
|
||||
return;
|
||||
}
|
||||
state->menu = base::make_unique_q<Ui::PopupMenu>(
|
||||
button,
|
||||
st::popupMenuWithIcons);
|
||||
state->menu->addAction(
|
||||
tr::lng_context_new_window(tr::now),
|
||||
[=] {
|
||||
base::call_delayed(
|
||||
st::popupMenuWithIcons.showDuration,
|
||||
crl::guard(button, openInWindow));
|
||||
},
|
||||
&st::menuIconNewWindow);
|
||||
state->menu->popup(QCursor::pos());
|
||||
});
|
||||
}
|
||||
|
||||
void DetailsFiller::addShowTopicsListButton(
|
||||
|
||||
Reference in New Issue
Block a user