mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Completely removed common and platform code for tray from main window.
This commit is contained in:
parent
9de372d715
commit
0e16a50bbc
12 changed files with 4 additions and 244 deletions
|
@ -433,9 +433,9 @@ void Application::startTray() {
|
|||
_tray->showFromTrayRequests(
|
||||
) | rpl::start_with_next([=] {
|
||||
const auto last = _lastActiveWindow;
|
||||
enumerate([&](WindowRaw w) { w->widget()->showFromTrayMenu(); });
|
||||
enumerate([&](WindowRaw w) { w->widget()->showFromTray(); });
|
||||
if (last) {
|
||||
last->widget()->showFromTrayMenu();
|
||||
last->widget()->showFromTray();
|
||||
}
|
||||
}, _primaryWindow->widget()->lifetime());
|
||||
|
||||
|
|
|
@ -123,9 +123,6 @@ void MainWindow::initHook() {
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::createTrayIconMenu() {
|
||||
}
|
||||
|
||||
void MainWindow::applyInitialWorkMode() {
|
||||
const auto workMode = Core::App().settings().workMode();
|
||||
workmodeUpdated(workMode);
|
||||
|
@ -150,7 +147,6 @@ void MainWindow::applyInitialWorkMode() {
|
|||
}
|
||||
|
||||
void MainWindow::finishFirstShow() {
|
||||
createTrayIconMenu();
|
||||
applyInitialWorkMode();
|
||||
createGlobalMenu();
|
||||
|
||||
|
@ -634,15 +630,6 @@ bool MainWindow::eventFilter(QObject *object, QEvent *e) {
|
|||
return Platform::MainWindow::eventFilter(object, e);
|
||||
}
|
||||
|
||||
void MainWindow::updateTrayMenu() {
|
||||
if (!trayIconMenu) {
|
||||
return;
|
||||
}
|
||||
_updateTrayMenuTextActions.fire({});
|
||||
|
||||
psTrayMenuUpdated();
|
||||
}
|
||||
|
||||
bool MainWindow::takeThirdSectionFromLayer() {
|
||||
return _layer ? _layer->takeToThirdSection() : false;
|
||||
}
|
||||
|
@ -654,91 +641,6 @@ void MainWindow::fixOrder() {
|
|||
if (_testingThemeWarning) _testingThemeWarning->raise();
|
||||
}
|
||||
|
||||
void MainWindow::handleTrayIconActication(
|
||||
QSystemTrayIcon::ActivationReason reason) {
|
||||
updateIsActive();
|
||||
if (Platform::IsMac() && isActive()) {
|
||||
if (trayIcon && !trayIcon->contextMenu()) {
|
||||
showFromTray();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (reason == QSystemTrayIcon::Context) {
|
||||
updateTrayMenu();
|
||||
InvokeQueued(this, [=] {
|
||||
psShowTrayMenu();
|
||||
});
|
||||
} else if (!skipTrayClick()) {
|
||||
if (isActiveForTrayMenu()) {
|
||||
minimizeToTray();
|
||||
} else {
|
||||
showFromTray();
|
||||
}
|
||||
_lastTrayClickTime = crl::now();
|
||||
}
|
||||
}
|
||||
|
||||
bool MainWindow::skipTrayClick() const {
|
||||
return (_lastTrayClickTime > 0)
|
||||
&& (crl::now() - _lastTrayClickTime
|
||||
< QApplication::doubleClickInterval());
|
||||
}
|
||||
|
||||
void MainWindow::toggleDisplayNotifyFromTray() {
|
||||
if (controller().locked()) {
|
||||
if (!isActive()) showFromTray();
|
||||
Ui::show(Ui::MakeInformBox(tr::lng_passcode_need_unblock()));
|
||||
return;
|
||||
}
|
||||
if (!sessionController()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto soundNotifyChanged = false;
|
||||
auto flashBounceNotifyChanged = false;
|
||||
auto &settings = Core::App().settings();
|
||||
settings.setDesktopNotify(!settings.desktopNotify());
|
||||
if (settings.desktopNotify()) {
|
||||
if (settings.rememberedSoundNotifyFromTray()
|
||||
&& !settings.soundNotify()) {
|
||||
settings.setSoundNotify(true);
|
||||
settings.setRememberedSoundNotifyFromTray(false);
|
||||
soundNotifyChanged = true;
|
||||
}
|
||||
if (settings.rememberedFlashBounceNotifyFromTray()
|
||||
&& !settings.flashBounceNotify()) {
|
||||
settings.setFlashBounceNotify(true);
|
||||
settings.setRememberedFlashBounceNotifyFromTray(false);
|
||||
flashBounceNotifyChanged = true;
|
||||
}
|
||||
} else {
|
||||
if (settings.soundNotify()) {
|
||||
settings.setSoundNotify(false);
|
||||
settings.setRememberedSoundNotifyFromTray(true);
|
||||
soundNotifyChanged = true;
|
||||
} else {
|
||||
settings.setRememberedSoundNotifyFromTray(false);
|
||||
}
|
||||
if (settings.flashBounceNotify()) {
|
||||
settings.setFlashBounceNotify(false);
|
||||
settings.setRememberedFlashBounceNotifyFromTray(true);
|
||||
flashBounceNotifyChanged = true;
|
||||
} else {
|
||||
settings.setRememberedFlashBounceNotifyFromTray(false);
|
||||
}
|
||||
}
|
||||
Core::App().saveSettingsDelayed();
|
||||
using Change = Window::Notifications::ChangeType;
|
||||
auto ¬ifications = Core::App().notifications();
|
||||
notifications.notifySettingsChanged(Change::DesktopEnabled);
|
||||
if (soundNotifyChanged) {
|
||||
notifications.notifySettingsChanged(Change::SoundEnabled);
|
||||
}
|
||||
if (flashBounceNotifyChanged) {
|
||||
notifications.notifySettingsChanged(Change::FlashBounceEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent *e) {
|
||||
if (Core::Sandbox::Instance().isSavingSession() || Core::Quitting()) {
|
||||
e->accept();
|
||||
|
@ -807,10 +709,7 @@ void MainWindow::activeChangedHook() {
|
|||
}
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
delete trayIcon;
|
||||
delete trayIconMenu;
|
||||
}
|
||||
MainWindow::~MainWindow() = default;
|
||||
|
||||
namespace App {
|
||||
|
||||
|
|
|
@ -80,7 +80,6 @@ public:
|
|||
}
|
||||
|
||||
void showMainMenu();
|
||||
void updateTrayMenu() override;
|
||||
void fixOrder() override;
|
||||
|
||||
void showLayer(
|
||||
|
@ -119,12 +118,6 @@ protected:
|
|||
void clearWidgetsHook() override;
|
||||
|
||||
private:
|
||||
[[nodiscard]] bool skipTrayClick() const;
|
||||
|
||||
void createTrayIconMenu();
|
||||
void handleTrayIconActication(
|
||||
QSystemTrayIcon::ActivationReason reason) override;
|
||||
|
||||
void applyInitialWorkMode();
|
||||
void ensureLayerCreated();
|
||||
void destroyLayer();
|
||||
|
@ -139,15 +132,11 @@ private:
|
|||
|
||||
void themeUpdated(const Window::Theme::BackgroundUpdate &data);
|
||||
|
||||
void toggleDisplayNotifyFromTray();
|
||||
|
||||
QPixmap grabInner();
|
||||
|
||||
std::unique_ptr<Media::SystemMediaControlsManager> _mediaControlsManager;
|
||||
|
||||
crl::time _lastTrayClickTime = 0;
|
||||
QPoint _lastMousePosition;
|
||||
bool _activeForTrayIconAction = true;
|
||||
|
||||
object_ptr<Window::PasscodeLockWidget> _passcodeLock = { nullptr };
|
||||
object_ptr<Intro::Widget> _intro = { nullptr };
|
||||
|
@ -157,8 +146,6 @@ private:
|
|||
|
||||
object_ptr<Window::Theme::WarningWidget> _testingThemeWarning = { nullptr };
|
||||
|
||||
rpl::event_stream<> _updateTrayMenuTextActions;
|
||||
|
||||
};
|
||||
|
||||
namespace App {
|
||||
|
|
|
@ -255,24 +255,11 @@ void MainWindow::initHook() {
|
|||
LOG(("System tray available: %1").arg(Logs::b(TrayIconSupported())));
|
||||
}
|
||||
|
||||
bool MainWindow::hasTrayIcon() const {
|
||||
return trayIcon;
|
||||
}
|
||||
|
||||
bool MainWindow::isActiveForTrayMenu() {
|
||||
updateIsActive();
|
||||
return Platform::IsWayland() ? isVisible() : isActive();
|
||||
}
|
||||
|
||||
void MainWindow::psShowTrayMenu() {
|
||||
}
|
||||
|
||||
void MainWindow::psTrayMenuUpdated() {
|
||||
}
|
||||
|
||||
void MainWindow::psSetupTrayIcon() {
|
||||
}
|
||||
|
||||
void MainWindow::workmodeUpdated(Core::Settings::WorkMode mode) {
|
||||
if (!TrayIconSupported()) {
|
||||
return;
|
||||
|
@ -329,9 +316,6 @@ void MainWindow::updateIconCounters() {
|
|||
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||
}
|
||||
|
||||
void MainWindow::initTrayMenuHook() {
|
||||
}
|
||||
|
||||
void MainWindow::createGlobalMenu() {
|
||||
const auto ensureWindowShown = [=] {
|
||||
if (isHidden()) {
|
||||
|
|
|
@ -22,8 +22,6 @@ class MainWindow : public Window::MainWindow {
|
|||
public:
|
||||
explicit MainWindow(not_null<Window::Controller*> controller);
|
||||
|
||||
void psShowTrayMenu();
|
||||
|
||||
bool isActiveForTrayMenu() override;
|
||||
|
||||
~MainWindow();
|
||||
|
@ -35,21 +33,10 @@ protected:
|
|||
void unreadCounterChangedHook() override;
|
||||
void updateGlobalMenuHook() override;
|
||||
|
||||
void initTrayMenuHook() override;
|
||||
bool hasTrayIcon() const override;
|
||||
|
||||
void workmodeUpdated(Core::Settings::WorkMode mode) override;
|
||||
void createGlobalMenu() override;
|
||||
|
||||
QSystemTrayIcon *trayIcon = nullptr;
|
||||
QMenu *trayIconMenu = nullptr;
|
||||
|
||||
void psTrayMenuUpdated();
|
||||
void psSetupTrayIcon();
|
||||
|
||||
private:
|
||||
base::unique_qptr<Ui::PopupMenu> _trayIconMenuXEmbed;
|
||||
|
||||
QMenuBar *psMainMenu = nullptr;
|
||||
QAction *psLogout = nullptr;
|
||||
QAction *psUndo = nullptr;
|
||||
|
|
|
@ -33,6 +33,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
|
||||
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtWidgets/QSystemTrayIcon>
|
||||
#include <QtCore/QStandardPaths>
|
||||
#include <QtCore/QProcess>
|
||||
#include <QtGui/QWindow>
|
||||
|
|
|
@ -30,8 +30,6 @@ public:
|
|||
|
||||
void updateWindowIcon() override;
|
||||
|
||||
void psShowTrayMenu();
|
||||
|
||||
bool preventsQuit(Core::QuitReason reason) override;
|
||||
|
||||
class Private;
|
||||
|
@ -39,25 +37,12 @@ public:
|
|||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *evt) override;
|
||||
|
||||
void handleActiveChangedHook() override;
|
||||
void stateChangedHook(Qt::WindowState state) override;
|
||||
void initHook() override;
|
||||
void unreadCounterChangedHook() override;
|
||||
|
||||
bool hasTrayIcon() const override {
|
||||
return trayIcon;
|
||||
}
|
||||
|
||||
void updateGlobalMenuHook() override;
|
||||
|
||||
void workmodeUpdated(Core::Settings::WorkMode mode) override;
|
||||
|
||||
QSystemTrayIcon *trayIcon = nullptr;
|
||||
QMenu *trayIconMenu = nullptr;
|
||||
|
||||
void psTrayMenuUpdated();
|
||||
void psSetupTrayIcon();
|
||||
|
||||
void closeWithoutDestroy() override;
|
||||
void createGlobalMenu() override;
|
||||
|
||||
|
|
|
@ -237,9 +237,6 @@ void MainWindow::stateChangedHook(Qt::WindowState state) {
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::handleActiveChangedHook() {
|
||||
}
|
||||
|
||||
void MainWindow::initHook() {
|
||||
_customTitleHeight = 0;
|
||||
if (auto view = reinterpret_cast<NSView*>(winId())) {
|
||||
|
@ -260,9 +257,6 @@ void MainWindow::hideAndDeactivate() {
|
|||
hide();
|
||||
}
|
||||
|
||||
void MainWindow::psShowTrayMenu() {
|
||||
}
|
||||
|
||||
bool MainWindow::preventsQuit(Core::QuitReason reason) {
|
||||
// Thanks Chromium, see
|
||||
// chromium.org/developers/design-documents/confirm-to-quit-experiment
|
||||
|
@ -276,15 +270,6 @@ bool MainWindow::preventsQuit(Core::QuitReason reason) {
|
|||
Platform::ConfirmQuit::QuitKeysString()));
|
||||
}
|
||||
|
||||
void MainWindow::psTrayMenuUpdated() {
|
||||
}
|
||||
|
||||
void MainWindow::psSetupTrayIcon() {
|
||||
}
|
||||
|
||||
void MainWindow::workmodeUpdated(Core::Settings::WorkMode mode) {
|
||||
}
|
||||
|
||||
void MainWindow::unreadCounterChangedHook() {
|
||||
updateIconCounters();
|
||||
}
|
||||
|
|
|
@ -215,9 +215,6 @@ void MainWindow::shadowsDeactivate() {
|
|||
_hasActiveFrame = false;
|
||||
}
|
||||
|
||||
void MainWindow::psShowTrayMenu() {
|
||||
}
|
||||
|
||||
void MainWindow::destroyedFromSystem() {
|
||||
Core::Quit();
|
||||
}
|
||||
|
@ -247,15 +244,6 @@ void MainWindow::forceIconRefresh() {
|
|||
updateIconCounters();
|
||||
}
|
||||
|
||||
void MainWindow::psTrayMenuUpdated() {
|
||||
}
|
||||
|
||||
void MainWindow::psSetupTrayIcon() {
|
||||
}
|
||||
|
||||
void MainWindow::showTrayTooltip() {
|
||||
}
|
||||
|
||||
void MainWindow::workmodeUpdated(Core::Settings::WorkMode mode) {
|
||||
using WorkMode = Core::Settings::WorkMode;
|
||||
|
||||
|
@ -515,10 +503,6 @@ void MainWindow::validateWindowTheme(bool native, bool night) {
|
|||
SendMessage(_hWnd, WM_NCACTIVATE, _hasActiveFrame ? 1 : 0, 0);
|
||||
}
|
||||
|
||||
void MainWindow::showFromTrayMenu() {
|
||||
showFromTray();
|
||||
}
|
||||
|
||||
HWND MainWindow::psHwnd() const {
|
||||
return _hWnd;
|
||||
}
|
||||
|
|
|
@ -21,8 +21,6 @@ class MainWindow : public Window::MainWindow {
|
|||
public:
|
||||
explicit MainWindow(not_null<Window::Controller*> controller);
|
||||
|
||||
void showFromTrayMenu() override;
|
||||
|
||||
HWND psHwnd() const;
|
||||
|
||||
void updateWindowIcon() override;
|
||||
|
@ -34,8 +32,6 @@ public:
|
|||
|
||||
[[nodiscard]] bool hasTabletView() const;
|
||||
|
||||
void psShowTrayMenu();
|
||||
|
||||
void destroyedFromSystem();
|
||||
|
||||
~MainWindow();
|
||||
|
@ -45,18 +41,6 @@ protected:
|
|||
int32 screenNameChecksum(const QString &name) const override;
|
||||
void unreadCounterChangedHook() override;
|
||||
|
||||
bool hasTrayIcon() const override {
|
||||
return trayIcon;
|
||||
}
|
||||
|
||||
QSystemTrayIcon *trayIcon = nullptr;
|
||||
Ui::PopupMenu *trayIconMenu = nullptr;
|
||||
|
||||
void psTrayMenuUpdated();
|
||||
void psSetupTrayIcon();
|
||||
|
||||
void showTrayTooltip() override;
|
||||
|
||||
void workmodeUpdated(Core::Settings::WorkMode mode) override;
|
||||
|
||||
bool initGeometryFromSystem() override;
|
||||
|
@ -83,7 +67,6 @@ private:
|
|||
|
||||
// Workarounds for activation from tray icon.
|
||||
crl::time _lastDeactivateTime = 0;
|
||||
rpl::lifetime _showFromTrayLifetime;
|
||||
|
||||
bool _hasActiveFrame = false;
|
||||
|
||||
|
|
|
@ -491,9 +491,6 @@ void MainWindow::handleActiveChanged() {
|
|||
if (isActiveWindow()) {
|
||||
Core::App().checkMediaViewActivation();
|
||||
}
|
||||
InvokeQueued(this, [=] {
|
||||
handleActiveChangedHook();
|
||||
});
|
||||
}
|
||||
|
||||
void MainWindow::handleVisibleChanged(bool visible) {
|
||||
|
@ -765,16 +762,6 @@ void MainWindow::setPositionInited() {
|
|||
_positionInited = true;
|
||||
}
|
||||
|
||||
void MainWindow::attachToTrayIcon(not_null<QSystemTrayIcon*> icon) {
|
||||
icon->setToolTip(AppName.utf16());
|
||||
connect(icon, &QSystemTrayIcon::activated, this, [=](
|
||||
QSystemTrayIcon::ActivationReason reason) {
|
||||
Core::Sandbox::Instance().customEnterFromEventLoop([&] {
|
||||
handleTrayIconActication(reason);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
rpl::producer<> MainWindow::leaveEvents() const {
|
||||
return _leaveEvents.events();
|
||||
}
|
||||
|
@ -903,7 +890,6 @@ bool MainWindow::minimizeToTray() {
|
|||
closeWithoutDestroy();
|
||||
controller().updateIsActiveBlur();
|
||||
updateGlobalMenu();
|
||||
showTrayTooltip();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,8 +13,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "core/core_settings.h"
|
||||
#include "base/required.h"
|
||||
|
||||
#include <QtWidgets/QSystemTrayIcon>
|
||||
|
||||
namespace Main {
|
||||
class Session;
|
||||
class Account;
|
||||
|
@ -75,9 +73,6 @@ public:
|
|||
void showFromTray();
|
||||
void quitFromTray();
|
||||
void activate();
|
||||
virtual void showFromTrayMenu() {
|
||||
showFromTray();
|
||||
}
|
||||
|
||||
[[nodiscard]] QRect desktopRect() const;
|
||||
|
||||
|
@ -107,8 +102,6 @@ public:
|
|||
// Returns how much could the window get extended.
|
||||
int tryToExtendWidthBy(int addToWidth);
|
||||
|
||||
virtual void updateTrayMenu() {
|
||||
}
|
||||
virtual void fixOrder() {
|
||||
}
|
||||
virtual void setInnerFocus() {
|
||||
|
@ -156,9 +149,6 @@ protected:
|
|||
virtual void activeChangedHook() {
|
||||
}
|
||||
|
||||
virtual void handleActiveChangedHook() {
|
||||
}
|
||||
|
||||
virtual void handleVisibleChangedHook(bool visible) {
|
||||
}
|
||||
|
||||
|
@ -178,14 +168,6 @@ protected:
|
|||
virtual void updateGlobalMenuHook() {
|
||||
}
|
||||
|
||||
virtual void initTrayMenuHook() {
|
||||
}
|
||||
virtual bool hasTrayIcon() const {
|
||||
return false;
|
||||
}
|
||||
virtual void showTrayTooltip() {
|
||||
}
|
||||
|
||||
virtual void workmodeUpdated(Core::Settings::WorkMode mode) {
|
||||
}
|
||||
|
||||
|
@ -200,9 +182,6 @@ protected:
|
|||
virtual int32 screenNameChecksum(const QString &name) const;
|
||||
|
||||
void setPositionInited();
|
||||
void attachToTrayIcon(not_null<QSystemTrayIcon*> icon);
|
||||
virtual void handleTrayIconActication(
|
||||
QSystemTrayIcon::ActivationReason reason) = 0;
|
||||
void updateUnreadCounter();
|
||||
|
||||
virtual QRect computeDesktopRect() const;
|
||||
|
|
Loading…
Add table
Reference in a new issue