mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Remove some App::wnd() calls.
This commit is contained in:
parent
204dd0a869
commit
54f06740d5
27 changed files with 137 additions and 106 deletions
|
@ -17,11 +17,16 @@ namespace HistoryView {
|
|||
class ElementDelegate;
|
||||
} // namespace HistoryView
|
||||
|
||||
namespace Window {
|
||||
class SessionController;
|
||||
} // namespace Window
|
||||
|
||||
[[nodiscard]] bool UrlRequiresConfirmation(const QUrl &url);
|
||||
|
||||
struct ClickHandlerContext {
|
||||
FullMsgId itemId;
|
||||
Fn<HistoryView::ElementDelegate*()> elementDelegate;
|
||||
base::weak_ptr<Window::SessionController> sessionWindow;
|
||||
};
|
||||
Q_DECLARE_METATYPE(ClickHandlerContext);
|
||||
|
||||
|
|
|
@ -1351,6 +1351,7 @@ void HistoryInner::mouseActionFinish(
|
|||
? HistoryInner::ElementDelegate().get()
|
||||
: nullptr;
|
||||
},
|
||||
.sessionWindow = base::make_weak(_controller.get()),
|
||||
})
|
||||
});
|
||||
return;
|
||||
|
|
|
@ -2220,6 +2220,7 @@ void ListWidget::mouseActionFinish(
|
|||
? (ElementDelegate*)weak
|
||||
: nullptr;
|
||||
},
|
||||
.sessionWindow = base::make_weak(_controller.get()),
|
||||
})
|
||||
});
|
||||
return;
|
||||
|
|
|
@ -19,10 +19,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/emoji_config.h"
|
||||
#include "core/application.h"
|
||||
#include "core/core_settings.h"
|
||||
#include "core/click_handler_types.h"
|
||||
#include "main/main_session.h"
|
||||
#include "main/main_account.h"
|
||||
#include "main/main_app_config.h"
|
||||
#include "mainwindow.h" // App::wnd()->sessionController.
|
||||
#include "window/window_session_controller.h" // isGifPausedAtLeastFor.
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_document.h"
|
||||
|
@ -270,8 +270,11 @@ void Sticker::refreshLink() {
|
|||
that->_parent);
|
||||
});
|
||||
} else if (sticker && sticker->set.type() != mtpc_inputStickerSetEmpty) {
|
||||
_link = std::make_shared<LambdaClickHandler>([document = _data] {
|
||||
StickerSetBox::Show(App::wnd()->sessionController(), document);
|
||||
_link = std::make_shared<LambdaClickHandler>([document = _data](ClickContext context) {
|
||||
const auto my = context.other.value<ClickHandlerContext>();
|
||||
if (const auto window = my.sessionWindow.get()) {
|
||||
StickerSetBox::Show(window, document);
|
||||
}
|
||||
});
|
||||
} else if (sticker
|
||||
&& (_data->dimensions.width() > kStickerSideSize
|
||||
|
|
|
@ -1591,8 +1591,8 @@ void MainWidget::ui_showPeerHistory(
|
|||
animationParams);
|
||||
} else {
|
||||
_history->show();
|
||||
crl::on_main(App::wnd(), [] {
|
||||
App::wnd()->setInnerFocus();
|
||||
crl::on_main(this, [=] {
|
||||
_controller->widget()->setInnerFocus();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1948,11 +1948,10 @@ void MainWidget::showBackFromStack(
|
|||
|
||||
if (selectingPeer()) {
|
||||
return;
|
||||
}
|
||||
if (_stack.empty()) {
|
||||
} else if (_stack.empty()) {
|
||||
_controller->clearSectionStack(params);
|
||||
crl::on_main(App::wnd(), [] {
|
||||
App::wnd()->setInnerFocus();
|
||||
crl::on_main(this, [=] {
|
||||
_controller->widget()->setInnerFocus();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
@ -2236,7 +2235,7 @@ void MainWidget::showAll() {
|
|||
updateControlsGeometry();
|
||||
floatPlayerCheckVisibility();
|
||||
|
||||
App::wnd()->checkHistoryActivation();
|
||||
_controller->widget()->checkHistoryActivation();
|
||||
}
|
||||
|
||||
void MainWidget::resizeEvent(QResizeEvent *e) {
|
||||
|
@ -2720,7 +2719,7 @@ void MainWidget::activate() {
|
|||
} else if (!_mainSection) {
|
||||
if (_hider) {
|
||||
_dialogs->setInnerFocus();
|
||||
} else if (App::wnd() && !Ui::isLayerShown()) {
|
||||
} else if (!Ui::isLayerShown()) {
|
||||
if (!cSendPaths().isEmpty()) {
|
||||
const auto interpret = qstr("interpret://");
|
||||
const auto path = cSendPaths()[0];
|
||||
|
@ -2742,7 +2741,7 @@ void MainWidget::activate() {
|
|||
}
|
||||
}
|
||||
}
|
||||
App::wnd()->fixOrder();
|
||||
_controller->widget()->fixOrder();
|
||||
}
|
||||
|
||||
bool MainWidget::isActive() const {
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
|
||||
void showSettings();
|
||||
|
||||
void setInnerFocus();
|
||||
void setInnerFocus() override;
|
||||
|
||||
MainWidget *sessionContent() const;
|
||||
|
||||
|
|
|
@ -928,8 +928,8 @@ void MainWindow::createGlobalMenu() {
|
|||
|
||||
auto quit = file->addAction(
|
||||
tr::lng_mac_menu_quit_telegram(tr::now, lt_telegram, qsl("Telegram")),
|
||||
App::wnd(),
|
||||
[=] { App::wnd()->quitFromTray(); },
|
||||
this,
|
||||
[=] { quitFromTray(); },
|
||||
QKeySequence::Quit);
|
||||
|
||||
quit->setMenuRole(QAction::QuitRole);
|
||||
|
@ -1037,7 +1037,7 @@ void MainWindow::createGlobalMenu() {
|
|||
tr::lng_mac_menu_contacts(tr::now),
|
||||
crl::guard(this, [=] {
|
||||
if (isHidden()) {
|
||||
App::wnd()->showFromTray();
|
||||
showFromTray();
|
||||
}
|
||||
|
||||
if (!sessionController()) {
|
||||
|
@ -1154,7 +1154,9 @@ void MainWindow::psLinuxClearFormat() {
|
|||
}
|
||||
|
||||
void MainWindow::updateGlobalMenuHook() {
|
||||
if (!App::wnd() || !positionInited()) return;
|
||||
if (!positionInited()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto focused = QApplication::focusWidget();
|
||||
auto canUndo = false;
|
||||
|
@ -1189,7 +1191,7 @@ void MainWindow::updateGlobalMenuHook() {
|
|||
canCopy = list->canCopySelected();
|
||||
canDelete = list->canDeleteSelected();
|
||||
}
|
||||
App::wnd()->updateIsActive();
|
||||
updateIsActive();
|
||||
const auto logged = (sessionController() != nullptr);
|
||||
const auto inactive = !logged || controller().locked();
|
||||
const auto support = logged && account().session().supportMode();
|
||||
|
|
|
@ -545,7 +545,7 @@ std::optional<bool> IsDarkMode() {
|
|||
if (integration->checkVersion(3, 0, 0)) {
|
||||
const auto preferDarkTheme = integration->getBoolSetting(
|
||||
qsl("gtk-application-prefer-dark-theme"));
|
||||
|
||||
|
||||
if (!preferDarkTheme.has_value()) {
|
||||
return std::nullopt;
|
||||
} else if (*preferDarkTheme) {
|
||||
|
@ -588,17 +588,6 @@ bool SkipTaskbarSupported() {
|
|||
|
||||
} // namespace Platform
|
||||
|
||||
QRect psDesktopRect() {
|
||||
static QRect _monitorRect;
|
||||
static auto _monitorLastGot = 0LL;
|
||||
auto tnow = crl::now();
|
||||
if (tnow > _monitorLastGot + 1000LL || tnow < _monitorLastGot) {
|
||||
_monitorLastGot = tnow;
|
||||
_monitorRect = QApplication::desktop()->availableGeometry(App::wnd());
|
||||
}
|
||||
return _monitorRect;
|
||||
}
|
||||
|
||||
void psWriteDump() {
|
||||
}
|
||||
|
||||
|
|
|
@ -48,8 +48,6 @@ QString psAppDataPath();
|
|||
void psAutoStart(bool start, bool silent = false);
|
||||
void psSendToMenu(bool send, bool silent = false);
|
||||
|
||||
QRect psDesktopRect();
|
||||
|
||||
int psCleanup();
|
||||
int psFixPrevious();
|
||||
|
||||
|
|
|
@ -59,8 +59,6 @@ QString psAppDataPath();
|
|||
void psAutoStart(bool start, bool silent = false);
|
||||
void psSendToMenu(bool send, bool silent = false);
|
||||
|
||||
QRect psDesktopRect();
|
||||
|
||||
int psCleanup();
|
||||
int psFixPrevious();
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "core/application.h"
|
||||
#include "core/core_settings.h"
|
||||
#include "storage/localstorage.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "mainwindow.h"
|
||||
#include "history/history_location_manager.h"
|
||||
#include "base/platform/mac/base_utilities_mac.h"
|
||||
|
@ -36,17 +37,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include <mach-o/dyld.h>
|
||||
#include <AVFoundation/AVFoundation.h>
|
||||
|
||||
QRect psDesktopRect() {
|
||||
static QRect _monitorRect;
|
||||
static crl::time _monitorLastGot = 0;
|
||||
auto tnow = crl::now();
|
||||
if (tnow > _monitorLastGot + 1000 || tnow < _monitorLastGot) {
|
||||
_monitorLastGot = tnow;
|
||||
_monitorRect = QApplication::desktop()->availableGeometry(App::wnd());
|
||||
}
|
||||
return _monitorRect;
|
||||
}
|
||||
|
||||
void psWriteDump() {
|
||||
#ifndef DESKTOP_APP_DISABLE_CRASH_REPORTS
|
||||
double v = objc_appkitVersion();
|
||||
|
@ -56,7 +46,8 @@ void psWriteDump() {
|
|||
|
||||
void psActivateProcess(uint64 pid) {
|
||||
if (!pid) {
|
||||
objc_activateProgram(App::wnd() ? App::wnd()->winId() : 0);
|
||||
const auto window = Core::App().activeWindow();
|
||||
objc_activateProgram(window ? window->widget()->winId() : 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "storage/localstorage.h"
|
||||
#include "media/audio/media_audio.h"
|
||||
#include "media/player/media_player_instance.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "base/platform/mac/base_utilities_mac.h"
|
||||
#include "base/platform/base_platform_info.h"
|
||||
#include "lang/lang_keys.h"
|
||||
|
@ -114,7 +115,11 @@ ApplicationDelegate *_sharedDelegate = nil;
|
|||
}
|
||||
|
||||
- (BOOL) applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag {
|
||||
if (App::wnd() && App::wnd()->isHidden()) App::wnd()->showFromTray();
|
||||
if (const auto window = Core::App().activeWindow()) {
|
||||
if (window->widget()->isHidden()) {
|
||||
window->widget()->showFromTray();
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
@ -143,9 +148,9 @@ ApplicationDelegate *_sharedDelegate = nil;
|
|||
Core::Sandbox::Instance().customEnterFromEventLoop([&] {
|
||||
if (Core::IsAppLaunched() && !_ignoreActivation) {
|
||||
Core::App().handleAppActivated();
|
||||
if (auto window = App::wnd()) {
|
||||
if (window->isHidden()) {
|
||||
window->showFromTray();
|
||||
if (auto window = Core::App().activeWindow()) {
|
||||
if (window->widget()->isHidden()) {
|
||||
window->widget()->showFromTray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ void TitleWidget::mouseDoubleClickEvent(QMouseEvent *e) {
|
|||
}
|
||||
|
||||
object_ptr<Window::TitleWidget> CreateTitleWidget(QWidget *parent) {
|
||||
if (auto window = qobject_cast<Platform::MainWindow*>(parent)) {
|
||||
if (auto window = Core::App().activeWindow()) {
|
||||
if (auto height = window->getCustomTitleHeight()) {
|
||||
return object_ptr<TitleWidget>(window, height);
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ object_ptr<Window::TitleWidget> CreateTitleWidget(QWidget *parent) {
|
|||
// account, with 100% scale and without "px" dimensions, because thats
|
||||
// how it will look in real launched macOS app.
|
||||
int PreviewTitleHeight() {
|
||||
if (auto window = qobject_cast<Platform::MainWindow*>(App::wnd())) {
|
||||
if (auto window = Core::App().activeWindow()) {
|
||||
if (auto height = window->getCustomTitleHeight()) {
|
||||
return height;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "lang/lang_keys.h"
|
||||
#include "core/application.h"
|
||||
#include "core/crash_reports.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "app.h"
|
||||
|
||||
#include <QtWidgets/QFileDialog>
|
||||
|
@ -139,12 +140,12 @@ bool UnsafeShowOpenWithDropdown(const QString &filepath, QPoint menuPosition) {
|
|||
return false;
|
||||
}
|
||||
|
||||
auto window = App::wnd();
|
||||
auto window = Core::App().activeWindow();
|
||||
if (!window) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto parentHWND = window->psHwnd();
|
||||
auto parentHWND = window->widget()->psHwnd();
|
||||
auto wstringPath = QDir::toNativeSeparators(filepath).toStdWString();
|
||||
|
||||
auto result = false;
|
||||
|
|
|
@ -247,7 +247,7 @@ void MainWindow::psSetupTrayIcon() {
|
|||
trayIcon,
|
||||
&QSystemTrayIcon::messageClicked,
|
||||
this,
|
||||
[=] { App::wnd()->showFromTray(); });
|
||||
[=] { showFromTray(); });
|
||||
attachToTrayIcon(trayIcon);
|
||||
}
|
||||
updateIconCounters();
|
||||
|
@ -328,6 +328,21 @@ bool MainWindow::initSizeFromSystem() {
|
|||
return true;
|
||||
}
|
||||
|
||||
QRect MainWindow::computeDesktopRect() const {
|
||||
const auto flags = MONITOR_DEFAULTTONEAREST;
|
||||
if (const auto monitor = MonitorFromWindow(psHwnd(), flags)) {
|
||||
MONITORINFOEX info;
|
||||
info.cbSize = sizeof(info);
|
||||
GetMonitorInfo(monitor, &info);
|
||||
return QRect(
|
||||
info.rcWork.left,
|
||||
info.rcWork.top,
|
||||
info.rcWork.right - info.rcWork.left,
|
||||
info.rcWork.bottom - info.rcWork.top);
|
||||
}
|
||||
return Window::MainWindow::computeDesktopRect();
|
||||
}
|
||||
|
||||
void MainWindow::updateWindowIcon() {
|
||||
updateIconCounters();
|
||||
}
|
||||
|
|
|
@ -89,6 +89,8 @@ protected:
|
|||
|
||||
bool initSizeFromSystem() override;
|
||||
|
||||
QRect computeDesktopRect() const override;
|
||||
|
||||
QTimer psUpdatedPositionTimer;
|
||||
|
||||
private:
|
||||
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "platform/win/notifications_manager_win.h"
|
||||
|
||||
#include "window/notifications_utilities.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "base/platform/win/base_windows_wrl.h"
|
||||
#include "base/platform/base_platform_info.h"
|
||||
#include "platform/win/windows_app_user_model_id.h"
|
||||
|
@ -311,7 +312,9 @@ public:
|
|||
void clearFromHistory(not_null<History*> history);
|
||||
void clearFromSession(not_null<Main::Session*> session);
|
||||
void beforeNotificationActivated(NotificationId id);
|
||||
void afterNotificationActivated(NotificationId id);
|
||||
void afterNotificationActivated(
|
||||
NotificationId id,
|
||||
not_null<Window::SessionController*> window);
|
||||
void clearNotification(NotificationId id);
|
||||
|
||||
~Private();
|
||||
|
@ -423,10 +426,10 @@ void Manager::Private::beforeNotificationActivated(NotificationId id) {
|
|||
clearNotification(id);
|
||||
}
|
||||
|
||||
void Manager::Private::afterNotificationActivated(NotificationId id) {
|
||||
if (auto window = App::wnd()) {
|
||||
SetForegroundWindow(window->psHwnd());
|
||||
}
|
||||
void Manager::Private::afterNotificationActivated(
|
||||
NotificationId id,
|
||||
not_null<Window::SessionController*> window) {
|
||||
SetForegroundWindow(window->widget()->psHwnd());
|
||||
}
|
||||
|
||||
void Manager::Private::clearNotification(NotificationId id) {
|
||||
|
@ -617,8 +620,10 @@ void Manager::onBeforeNotificationActivated(NotificationId id) {
|
|||
_private->beforeNotificationActivated(id);
|
||||
}
|
||||
|
||||
void Manager::onAfterNotificationActivated(NotificationId id) {
|
||||
_private->afterNotificationActivated(id);
|
||||
void Manager::onAfterNotificationActivated(
|
||||
NotificationId id,
|
||||
not_null<Window::SessionController*> window) {
|
||||
_private->afterNotificationActivated(id, window);
|
||||
}
|
||||
#endif // !__MINGW32__
|
||||
|
||||
|
|
|
@ -36,7 +36,9 @@ protected:
|
|||
void doClearFromHistory(not_null<History*> history) override;
|
||||
void doClearFromSession(not_null<Main::Session*> session) override;
|
||||
void onBeforeNotificationActivated(NotificationId id) override;
|
||||
void onAfterNotificationActivated(NotificationId id) override;
|
||||
void onAfterNotificationActivated(
|
||||
NotificationId id,
|
||||
not_null<Window::SessionController*> window) override;
|
||||
|
||||
private:
|
||||
class Private;
|
||||
|
|
|
@ -145,25 +145,6 @@ void psDoCleanup() {
|
|||
}
|
||||
}
|
||||
|
||||
QRect psDesktopRect() {
|
||||
static QRect _monitorRect;
|
||||
static crl::time _monitorLastGot = 0;
|
||||
auto tnow = crl::now();
|
||||
if (tnow > _monitorLastGot + 1000LL || tnow < _monitorLastGot) {
|
||||
_monitorLastGot = tnow;
|
||||
HMONITOR hMonitor = MonitorFromWindow(App::wnd()->psHwnd(), MONITOR_DEFAULTTONEAREST);
|
||||
if (hMonitor) {
|
||||
MONITORINFOEX info;
|
||||
info.cbSize = sizeof(info);
|
||||
GetMonitorInfo(hMonitor, &info);
|
||||
_monitorRect = QRect(info.rcWork.left, info.rcWork.top, info.rcWork.right - info.rcWork.left, info.rcWork.bottom - info.rcWork.top);
|
||||
} else {
|
||||
_monitorRect = QApplication::desktop()->availableGeometry(App::wnd());
|
||||
}
|
||||
}
|
||||
return _monitorRect;
|
||||
}
|
||||
|
||||
int psCleanup() {
|
||||
__try
|
||||
{
|
||||
|
|
|
@ -55,8 +55,6 @@ QString psAppDataPathOld();
|
|||
void psAutoStart(bool start, bool silent = false);
|
||||
void psSendToMenu(bool send, bool silent = false);
|
||||
|
||||
QRect psDesktopRect();
|
||||
|
||||
int psCleanup();
|
||||
int psFixPrevious();
|
||||
|
||||
|
|
|
@ -370,7 +370,7 @@ void NotificationsCount::setOverCorner(ScreenCorner corner) {
|
|||
samples[i]->showFast();
|
||||
}
|
||||
if (samplesNeeded > samplesLeave) {
|
||||
auto r = psDesktopRect();
|
||||
auto r = _controller->widget()->desktopRect();
|
||||
auto isLeft = Core::Settings::IsLeftCorner(_overCorner);
|
||||
auto isTop = Core::Settings::IsTopCorner(_overCorner);
|
||||
auto sampleLeft = (isLeft == rtl()) ? (r.x() + r.width() - st::notifyWidth - st::notifyDeltaX) : (r.x() + st::notifyDeltaX);
|
||||
|
|
|
@ -218,6 +218,15 @@ void MainWindow::updateWindowIcon() {
|
|||
setWindowIcon(_icon);
|
||||
}
|
||||
|
||||
QRect MainWindow::desktopRect() const {
|
||||
const auto now = crl::now();
|
||||
if (now >= _monitorLastGot && now <= _monitorLastGot + crl::time(1000)) {
|
||||
_monitorLastGot = now;
|
||||
_monitorRect = computeDesktopRect();
|
||||
}
|
||||
return _monitorRect;
|
||||
}
|
||||
|
||||
void MainWindow::init() {
|
||||
Expects(!windowHandle());
|
||||
|
||||
|
@ -612,6 +621,10 @@ void MainWindow::updateUnreadCounter() {
|
|||
unreadCounterChangedHook();
|
||||
}
|
||||
|
||||
QRect MainWindow::computeDesktopRect() const {
|
||||
return QApplication::desktop()->availableGeometry(this);
|
||||
}
|
||||
|
||||
void MainWindow::savePosition(Qt::WindowState state) {
|
||||
if (state == Qt::WindowActive) {
|
||||
state = windowHandle()->windowState();
|
||||
|
@ -698,8 +711,9 @@ bool MainWindow::minimizeToTray() {
|
|||
|
||||
void MainWindow::reActivateWindow() {
|
||||
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto reActivate = [=] {
|
||||
if (const auto w = App::wnd()) {
|
||||
if (const auto w = weak.data()) {
|
||||
if (auto f = QApplication::focusWidget()) {
|
||||
f->clearFocus();
|
||||
}
|
||||
|
@ -723,8 +737,8 @@ void MainWindow::showRightColumn(object_ptr<TWidget> widget) {
|
|||
_rightColumn->setParent(this);
|
||||
_rightColumn->show();
|
||||
_rightColumn->setFocus();
|
||||
} else if (App::wnd()) {
|
||||
App::wnd()->setInnerFocus();
|
||||
} else {
|
||||
setInnerFocus();
|
||||
}
|
||||
const auto nowRightWidth = _rightColumn ? _rightColumn->width() : 0;
|
||||
const auto wasMaximized = isMaximized();
|
||||
|
@ -777,7 +791,7 @@ int MainWindow::tryToExtendWidthBy(int addToWidth) {
|
|||
|
||||
void MainWindow::launchDrag(std::unique_ptr<QMimeData> data) {
|
||||
auto weak = QPointer<MainWindow>(this);
|
||||
auto drag = std::make_unique<QDrag>(App::wnd());
|
||||
auto drag = std::make_unique<QDrag>(this);
|
||||
drag->setMimeData(data.release());
|
||||
drag->exec(Qt::CopyAction);
|
||||
|
||||
|
|
|
@ -37,10 +37,9 @@ QIcon CreateIcon(Main::Session *session = nullptr);
|
|||
void ConvertIconToBlack(QImage &image);
|
||||
|
||||
class MainWindow : public Ui::RpWidget, protected base::Subscriber {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(not_null<Controller*> controller);
|
||||
virtual ~MainWindow();
|
||||
|
||||
[[nodiscard]] Window::Controller &controller() const {
|
||||
return *_controller;
|
||||
|
@ -57,15 +56,17 @@ public:
|
|||
showFromTray();
|
||||
}
|
||||
|
||||
[[nodiscard]] QRect desktopRect() const;
|
||||
|
||||
void init();
|
||||
HitTestResult hitTest(const QPoint &p) const;
|
||||
[[nodiscard]] HitTestResult hitTest(const QPoint &p) const;
|
||||
|
||||
void updateIsActive();
|
||||
|
||||
bool isActive() const {
|
||||
[[nodiscard]] bool isActive() const {
|
||||
return _isActive;
|
||||
}
|
||||
virtual bool isActiveForTrayMenu() {
|
||||
[[nodiscard]] virtual bool isActiveForTrayMenu() {
|
||||
updateIsActive();
|
||||
return isActive();
|
||||
}
|
||||
|
@ -94,8 +95,9 @@ public:
|
|||
}
|
||||
virtual void fixOrder() {
|
||||
}
|
||||
|
||||
virtual ~MainWindow();
|
||||
virtual void setInnerFocus() {
|
||||
setFocus();
|
||||
}
|
||||
|
||||
Ui::RpWidget *bodyWidget() {
|
||||
return _body.data();
|
||||
|
@ -121,7 +123,6 @@ public:
|
|||
|
||||
bool hasShadow() const;
|
||||
|
||||
public slots:
|
||||
bool minimizeToTray();
|
||||
void updateGlobalMenu() {
|
||||
updateGlobalMenuHook();
|
||||
|
@ -199,6 +200,8 @@ protected:
|
|||
QSystemTrayIcon::ActivationReason reason) = 0;
|
||||
void updateUnreadCounter();
|
||||
|
||||
virtual QRect computeDesktopRect() const;
|
||||
|
||||
private:
|
||||
void refreshTitleWidget();
|
||||
void updateMinimumSize();
|
||||
|
@ -231,6 +234,9 @@ private:
|
|||
|
||||
bool _maximizedBeforeHide = false;
|
||||
|
||||
mutable QRect _monitorRect;
|
||||
mutable crl::time _monitorLastGot = 0;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Window
|
||||
|
|
|
@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_channel.h"
|
||||
#include "data/data_user.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "core/application.h"
|
||||
#include "mainwindow.h"
|
||||
|
@ -391,10 +392,10 @@ void System::showNext() {
|
|||
const auto &settings = Core::App().settings();
|
||||
if (alert) {
|
||||
if (settings.flashBounceNotify() && !Platform::Notifications::SkipFlashBounce()) {
|
||||
if (const auto widget = App::wnd()) {
|
||||
if (const auto window = widget->windowHandle()) {
|
||||
window->alert(kSystemAlertDuration);
|
||||
// (window, SLOT(_q_clearAlert())); in the future.
|
||||
if (const auto window = Core::App().activeWindow()) {
|
||||
if (const auto handle = window->widget()->windowHandle()) {
|
||||
handle->alert(kSystemAlertDuration);
|
||||
// (handle, SLOT(_q_clearAlert())); in the future.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -635,9 +636,9 @@ void Manager::notificationActivated(NotificationId id) {
|
|||
} else {
|
||||
openNotificationMessage(history, id.msgId);
|
||||
}
|
||||
onAfterNotificationActivated(id, window);
|
||||
}
|
||||
}
|
||||
onAfterNotificationActivated(id);
|
||||
}
|
||||
|
||||
void Manager::openNotificationMessage(
|
||||
|
|
|
@ -32,6 +32,9 @@ class Track;
|
|||
} // namespace Media
|
||||
|
||||
namespace Window {
|
||||
|
||||
class SessionController;
|
||||
|
||||
namespace Notifications {
|
||||
|
||||
enum class ManagerType {
|
||||
|
@ -217,7 +220,9 @@ protected:
|
|||
virtual void doClearFromSession(not_null<Main::Session*> session) = 0;
|
||||
virtual void onBeforeNotificationActivated(NotificationId id) {
|
||||
}
|
||||
virtual void onAfterNotificationActivated(NotificationId id) {
|
||||
virtual void onAfterNotificationActivated(
|
||||
NotificationId id,
|
||||
not_null<SessionController*> window) {
|
||||
}
|
||||
[[nodiscard]] virtual QString accountNameSeparator();
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/ui_utility.h"
|
||||
#include "dialogs/dialogs_layout.h"
|
||||
#include "window/themes/window_theme.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "storage/file_download.h"
|
||||
#include "main/main_session.h"
|
||||
#include "main/main_account.h"
|
||||
|
@ -34,7 +35,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "styles/style_layers.h"
|
||||
#include "styles/style_window.h"
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtGui/QGuiApplication>
|
||||
#include <QtGui/QScreen>
|
||||
|
||||
namespace Window {
|
||||
namespace Notifications {
|
||||
|
@ -47,7 +49,10 @@ int notificationMaxHeight() {
|
|||
|
||||
QPoint notificationStartPosition() {
|
||||
const auto corner = Core::App().settings().notificationsCorner();
|
||||
const auto r = psDesktopRect();
|
||||
const auto window = Core::App().activeWindow();
|
||||
const auto r = window
|
||||
? window->widget()->desktopRect()
|
||||
: QGuiApplication::primaryScreen()->availableGeometry();
|
||||
const auto isLeft = Core::Settings::IsLeftCorner(corner);
|
||||
const auto isTop = Core::Settings::IsTopCorner(corner);
|
||||
const auto x = (isLeft == rtl()) ? (r.x() + r.width() - st::notifyWidth - st::notifyDeltaX) : (r.x() + st::notifyDeltaX);
|
||||
|
|
|
@ -33,6 +33,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "core/shortcuts.h"
|
||||
#include "core/application.h"
|
||||
#include "core/core_settings.h"
|
||||
#include "core/click_handler_types.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "ui/layers/generic_box.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
|
@ -78,7 +79,10 @@ void DateClickHandler::setDate(QDate date) {
|
|||
}
|
||||
|
||||
void DateClickHandler::onClick(ClickContext context) const {
|
||||
App::wnd()->sessionController()->showJumpToDate(_chat, _date);
|
||||
const auto my = context.other.value<ClickHandlerContext>();
|
||||
if (const auto window = my.sessionWindow.get()) {
|
||||
window->showJumpToDate(_chat, _date);
|
||||
}
|
||||
}
|
||||
|
||||
SessionNavigation::SessionNavigation(not_null<Main::Session*> session)
|
||||
|
|
Loading…
Add table
Reference in a new issue