mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 15:43:55 +02:00
Eliminate the need of Q_OBJECT in main_window_linux and main_window_win
This commit is contained in:
parent
612e0d4a10
commit
3c8c059447
5 changed files with 69 additions and 67 deletions
|
@ -764,7 +764,9 @@ void MainWindow::handleTrayIconActication(
|
||||||
}
|
}
|
||||||
if (reason == QSystemTrayIcon::Context) {
|
if (reason == QSystemTrayIcon::Context) {
|
||||||
updateTrayMenu(true);
|
updateTrayMenu(true);
|
||||||
QTimer::singleShot(1, this, SLOT(psShowTrayMenu()));
|
base::call_delayed(1, this, [=] {
|
||||||
|
psShowTrayMenu();
|
||||||
|
});
|
||||||
} else if (!skipTrayClick()) {
|
} else if (!skipTrayClick()) {
|
||||||
if (Platform::IsWayland() ? isVisible() : isActive()) {
|
if (Platform::IsWayland() ? isVisible() : isActive()) {
|
||||||
minimizeToTray();
|
minimizeToTray();
|
||||||
|
|
|
@ -435,7 +435,12 @@ void MainWindow::initHook() {
|
||||||
sniWatcher,
|
sniWatcher,
|
||||||
&QDBusServiceWatcher::serviceOwnerChanged,
|
&QDBusServiceWatcher::serviceOwnerChanged,
|
||||||
this,
|
this,
|
||||||
&MainWindow::onSNIOwnerChanged);
|
[=](
|
||||||
|
const QString &service,
|
||||||
|
const QString &oldOwner,
|
||||||
|
const QString &newOwner) {
|
||||||
|
handleSNIOwnerChanged(service, oldOwner, newOwner);
|
||||||
|
});
|
||||||
|
|
||||||
AppMenuSupported = IsAppMenuSupported();
|
AppMenuSupported = IsAppMenuSupported();
|
||||||
|
|
||||||
|
@ -449,13 +454,18 @@ void MainWindow::initHook() {
|
||||||
appMenuWatcher,
|
appMenuWatcher,
|
||||||
&QDBusServiceWatcher::serviceOwnerChanged,
|
&QDBusServiceWatcher::serviceOwnerChanged,
|
||||||
this,
|
this,
|
||||||
&MainWindow::onAppMenuOwnerChanged);
|
[=](
|
||||||
|
const QString &service,
|
||||||
|
const QString &oldOwner,
|
||||||
|
const QString &newOwner) {
|
||||||
|
handleAppMenuOwnerChanged(service, oldOwner, newOwner);
|
||||||
|
});
|
||||||
|
|
||||||
connect(
|
connect(
|
||||||
windowHandle(),
|
windowHandle(),
|
||||||
&QWindow::visibleChanged,
|
&QWindow::visibleChanged,
|
||||||
this,
|
this,
|
||||||
&MainWindow::onVisibleChanged);
|
[=](bool visible) { handleVisibleChanged(visible); });
|
||||||
|
|
||||||
if (AppMenuSupported) {
|
if (AppMenuSupported) {
|
||||||
LOG(("Using D-Bus global menu."));
|
LOG(("Using D-Bus global menu."));
|
||||||
|
@ -560,7 +570,7 @@ void MainWindow::attachToSNITrayIcon() {
|
||||||
updateTrayMenu();
|
updateTrayMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onSNIOwnerChanged(
|
void MainWindow::handleSNIOwnerChanged(
|
||||||
const QString &service,
|
const QString &service,
|
||||||
const QString &oldOwner,
|
const QString &oldOwner,
|
||||||
const QString &newOwner) {
|
const QString &newOwner) {
|
||||||
|
@ -596,7 +606,7 @@ void MainWindow::onSNIOwnerChanged(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onAppMenuOwnerChanged(
|
void MainWindow::handleAppMenuOwnerChanged(
|
||||||
const QString &service,
|
const QString &service,
|
||||||
const QString &oldOwner,
|
const QString &oldOwner,
|
||||||
const QString &newOwner) {
|
const QString &newOwner) {
|
||||||
|
@ -780,7 +790,7 @@ void MainWindow::createGlobalMenu() {
|
||||||
auto quit = file->addAction(
|
auto quit = file->addAction(
|
||||||
tr::lng_mac_menu_quit_telegram(tr::now, lt_telegram, qsl("Telegram")),
|
tr::lng_mac_menu_quit_telegram(tr::now, lt_telegram, qsl("Telegram")),
|
||||||
App::wnd(),
|
App::wnd(),
|
||||||
SLOT(quitFromTray()),
|
[=] { App::wnd()->quitFromTray(); },
|
||||||
QKeySequence::Quit);
|
QKeySequence::Quit);
|
||||||
|
|
||||||
quit->setMenuRole(QAction::QuitRole);
|
quit->setMenuRole(QAction::QuitRole);
|
||||||
|
@ -790,13 +800,13 @@ void MainWindow::createGlobalMenu() {
|
||||||
psUndo = edit->addAction(
|
psUndo = edit->addAction(
|
||||||
tr::lng_linux_menu_undo(tr::now),
|
tr::lng_linux_menu_undo(tr::now),
|
||||||
this,
|
this,
|
||||||
SLOT(psLinuxUndo()),
|
[=] { psLinuxUndo(); },
|
||||||
QKeySequence::Undo);
|
QKeySequence::Undo);
|
||||||
|
|
||||||
psRedo = edit->addAction(
|
psRedo = edit->addAction(
|
||||||
tr::lng_linux_menu_redo(tr::now),
|
tr::lng_linux_menu_redo(tr::now),
|
||||||
this,
|
this,
|
||||||
SLOT(psLinuxRedo()),
|
[=] { psLinuxRedo(); },
|
||||||
QKeySequence::Redo);
|
QKeySequence::Redo);
|
||||||
|
|
||||||
edit->addSeparator();
|
edit->addSeparator();
|
||||||
|
@ -804,24 +814,24 @@ void MainWindow::createGlobalMenu() {
|
||||||
psCut = edit->addAction(
|
psCut = edit->addAction(
|
||||||
tr::lng_mac_menu_cut(tr::now),
|
tr::lng_mac_menu_cut(tr::now),
|
||||||
this,
|
this,
|
||||||
SLOT(psLinuxCut()),
|
[=] { psLinuxCut(); },
|
||||||
QKeySequence::Cut);
|
QKeySequence::Cut);
|
||||||
psCopy = edit->addAction(
|
psCopy = edit->addAction(
|
||||||
tr::lng_mac_menu_copy(tr::now),
|
tr::lng_mac_menu_copy(tr::now),
|
||||||
this,
|
this,
|
||||||
SLOT(psLinuxCopy()),
|
[=] { psLinuxCopy(); },
|
||||||
QKeySequence::Copy);
|
QKeySequence::Copy);
|
||||||
|
|
||||||
psPaste = edit->addAction(
|
psPaste = edit->addAction(
|
||||||
tr::lng_mac_menu_paste(tr::now),
|
tr::lng_mac_menu_paste(tr::now),
|
||||||
this,
|
this,
|
||||||
SLOT(psLinuxPaste()),
|
[=] { psLinuxPaste(); },
|
||||||
QKeySequence::Paste);
|
QKeySequence::Paste);
|
||||||
|
|
||||||
psDelete = edit->addAction(
|
psDelete = edit->addAction(
|
||||||
tr::lng_mac_menu_delete(tr::now),
|
tr::lng_mac_menu_delete(tr::now),
|
||||||
this,
|
this,
|
||||||
SLOT(psLinuxDelete()),
|
[=] { psLinuxDelete(); },
|
||||||
QKeySequence(Qt::ControlModifier | Qt::Key_Backspace));
|
QKeySequence(Qt::ControlModifier | Qt::Key_Backspace));
|
||||||
|
|
||||||
edit->addSeparator();
|
edit->addSeparator();
|
||||||
|
@ -829,44 +839,44 @@ void MainWindow::createGlobalMenu() {
|
||||||
psBold = edit->addAction(
|
psBold = edit->addAction(
|
||||||
tr::lng_menu_formatting_bold(tr::now),
|
tr::lng_menu_formatting_bold(tr::now),
|
||||||
this,
|
this,
|
||||||
SLOT(psLinuxBold()),
|
[=] { psLinuxBold(); },
|
||||||
QKeySequence::Bold);
|
QKeySequence::Bold);
|
||||||
|
|
||||||
psItalic = edit->addAction(
|
psItalic = edit->addAction(
|
||||||
tr::lng_menu_formatting_italic(tr::now),
|
tr::lng_menu_formatting_italic(tr::now),
|
||||||
this,
|
this,
|
||||||
SLOT(psLinuxItalic()),
|
[=] { psLinuxItalic(); },
|
||||||
QKeySequence::Italic);
|
QKeySequence::Italic);
|
||||||
|
|
||||||
psUnderline = edit->addAction(
|
psUnderline = edit->addAction(
|
||||||
tr::lng_menu_formatting_underline(tr::now),
|
tr::lng_menu_formatting_underline(tr::now),
|
||||||
this,
|
this,
|
||||||
SLOT(psLinuxUnderline()),
|
[=] { psLinuxUnderline(); },
|
||||||
QKeySequence::Underline);
|
QKeySequence::Underline);
|
||||||
|
|
||||||
psStrikeOut = edit->addAction(
|
psStrikeOut = edit->addAction(
|
||||||
tr::lng_menu_formatting_strike_out(tr::now),
|
tr::lng_menu_formatting_strike_out(tr::now),
|
||||||
this,
|
this,
|
||||||
SLOT(psLinuxStrikeOut()),
|
[=] { psLinuxStrikeOut(); },
|
||||||
Ui::kStrikeOutSequence);
|
Ui::kStrikeOutSequence);
|
||||||
|
|
||||||
psMonospace = edit->addAction(
|
psMonospace = edit->addAction(
|
||||||
tr::lng_menu_formatting_monospace(tr::now),
|
tr::lng_menu_formatting_monospace(tr::now),
|
||||||
this,
|
this,
|
||||||
SLOT(psLinuxMonospace()),
|
[=] { psLinuxMonospace(); },
|
||||||
Ui::kMonospaceSequence);
|
Ui::kMonospaceSequence);
|
||||||
|
|
||||||
psClearFormat = edit->addAction(
|
psClearFormat = edit->addAction(
|
||||||
tr::lng_menu_formatting_clear(tr::now),
|
tr::lng_menu_formatting_clear(tr::now),
|
||||||
this,
|
this,
|
||||||
SLOT(psLinuxClearFormat()),
|
[=] { psLinuxClearFormat(); },
|
||||||
Ui::kClearFormatSequence);
|
Ui::kClearFormatSequence);
|
||||||
|
|
||||||
edit->addSeparator();
|
edit->addSeparator();
|
||||||
|
|
||||||
psSelectAll = edit->addAction(
|
psSelectAll = edit->addAction(
|
||||||
tr::lng_mac_menu_select_all(tr::now),
|
tr::lng_mac_menu_select_all(tr::now),
|
||||||
this, SLOT(psLinuxSelectAll()),
|
this, [=] { psLinuxSelectAll(); },
|
||||||
QKeySequence::SelectAll);
|
QKeySequence::SelectAll);
|
||||||
|
|
||||||
edit->addSeparator();
|
edit->addSeparator();
|
||||||
|
@ -874,7 +884,7 @@ void MainWindow::createGlobalMenu() {
|
||||||
auto prefs = edit->addAction(
|
auto prefs = edit->addAction(
|
||||||
tr::lng_mac_menu_preferences(tr::now),
|
tr::lng_mac_menu_preferences(tr::now),
|
||||||
App::wnd(),
|
App::wnd(),
|
||||||
SLOT(showSettings()),
|
[=] { App::wnd()->showSettings(); },
|
||||||
QKeySequence(Qt::ControlModifier | Qt::Key_Comma));
|
QKeySequence(Qt::ControlModifier | Qt::Key_Comma));
|
||||||
|
|
||||||
prefs->setMenuRole(QAction::PreferencesRole);
|
prefs->setMenuRole(QAction::PreferencesRole);
|
||||||
|
@ -909,19 +919,19 @@ void MainWindow::createGlobalMenu() {
|
||||||
psAddContact = tools->addAction(
|
psAddContact = tools->addAction(
|
||||||
tr::lng_mac_menu_add_contact(tr::now),
|
tr::lng_mac_menu_add_contact(tr::now),
|
||||||
App::wnd(),
|
App::wnd(),
|
||||||
SLOT(onShowAddContact()));
|
[=] { App::wnd()->onShowAddContact(); });
|
||||||
|
|
||||||
tools->addSeparator();
|
tools->addSeparator();
|
||||||
|
|
||||||
psNewGroup = tools->addAction(
|
psNewGroup = tools->addAction(
|
||||||
tr::lng_mac_menu_new_group(tr::now),
|
tr::lng_mac_menu_new_group(tr::now),
|
||||||
App::wnd(),
|
App::wnd(),
|
||||||
SLOT(onShowNewGroup()));
|
[=] { App::wnd()->onShowNewGroup(); });
|
||||||
|
|
||||||
psNewChannel = tools->addAction(
|
psNewChannel = tools->addAction(
|
||||||
tr::lng_mac_menu_new_channel(tr::now),
|
tr::lng_mac_menu_new_channel(tr::now),
|
||||||
App::wnd(),
|
App::wnd(),
|
||||||
SLOT(onShowNewChannel()));
|
[=] { App::wnd()->onShowNewChannel(); });
|
||||||
|
|
||||||
auto help = psMainMenu->addMenu(tr::lng_linux_menu_help(tr::now));
|
auto help = psMainMenu->addMenu(tr::lng_linux_menu_help(tr::now));
|
||||||
|
|
||||||
|
@ -1066,7 +1076,7 @@ void MainWindow::updateGlobalMenuHook() {
|
||||||
ForceDisabled(psClearFormat, !markdownEnabled);
|
ForceDisabled(psClearFormat, !markdownEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onVisibleChanged(bool visible) {
|
void MainWindow::handleVisibleChanged(bool visible) {
|
||||||
if (AppMenuSupported && !_mainMenuPath.path().isEmpty()) {
|
if (AppMenuSupported && !_mainMenuPath.path().isEmpty()) {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
RegisterAppMenu(winId(), _mainMenuPath);
|
RegisterAppMenu(winId(), _mainMenuPath);
|
||||||
|
|
|
@ -21,8 +21,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace Platform {
|
namespace Platform {
|
||||||
|
|
||||||
class MainWindow : public Window::MainWindow {
|
class MainWindow : public Window::MainWindow {
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(not_null<Window::Controller*> controller);
|
explicit MainWindow(not_null<Window::Controller*> controller);
|
||||||
|
|
||||||
|
@ -33,43 +31,12 @@ public:
|
||||||
style::color fg,
|
style::color fg,
|
||||||
bool smallIcon) = 0;
|
bool smallIcon) = 0;
|
||||||
|
|
||||||
|
void psShowTrayMenu();
|
||||||
|
|
||||||
static void LibsLoaded();
|
static void LibsLoaded();
|
||||||
|
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
public slots:
|
|
||||||
void psShowTrayMenu();
|
|
||||||
|
|
||||||
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
|
||||||
void onSNIOwnerChanged(
|
|
||||||
const QString &service,
|
|
||||||
const QString &oldOwner,
|
|
||||||
const QString &newOwner);
|
|
||||||
|
|
||||||
void onAppMenuOwnerChanged(
|
|
||||||
const QString &service,
|
|
||||||
const QString &oldOwner,
|
|
||||||
const QString &newOwner);
|
|
||||||
|
|
||||||
void psLinuxUndo();
|
|
||||||
void psLinuxRedo();
|
|
||||||
void psLinuxCut();
|
|
||||||
void psLinuxCopy();
|
|
||||||
void psLinuxPaste();
|
|
||||||
void psLinuxDelete();
|
|
||||||
void psLinuxSelectAll();
|
|
||||||
|
|
||||||
void psLinuxBold();
|
|
||||||
void psLinuxItalic();
|
|
||||||
void psLinuxUnderline();
|
|
||||||
void psLinuxStrikeOut();
|
|
||||||
void psLinuxMonospace();
|
|
||||||
void psLinuxClearFormat();
|
|
||||||
|
|
||||||
void onVisibleChanged(bool visible);
|
|
||||||
|
|
||||||
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void initHook() override;
|
void initHook() override;
|
||||||
void unreadCounterChangedHook() override;
|
void unreadCounterChangedHook() override;
|
||||||
|
@ -100,6 +67,7 @@ private:
|
||||||
|
|
||||||
void updateIconCounters();
|
void updateIconCounters();
|
||||||
void updateWaylandDecorationColors();
|
void updateWaylandDecorationColors();
|
||||||
|
void handleVisibleChanged(bool visible);
|
||||||
|
|
||||||
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||||
StatusNotifierItem *_sniTrayIcon = nullptr;
|
StatusNotifierItem *_sniTrayIcon = nullptr;
|
||||||
|
@ -131,6 +99,31 @@ private:
|
||||||
|
|
||||||
void setSNITrayIcon(int counter, bool muted);
|
void setSNITrayIcon(int counter, bool muted);
|
||||||
void attachToSNITrayIcon();
|
void attachToSNITrayIcon();
|
||||||
|
|
||||||
|
void handleSNIOwnerChanged(
|
||||||
|
const QString &service,
|
||||||
|
const QString &oldOwner,
|
||||||
|
const QString &newOwner);
|
||||||
|
|
||||||
|
void handleAppMenuOwnerChanged(
|
||||||
|
const QString &service,
|
||||||
|
const QString &oldOwner,
|
||||||
|
const QString &newOwner);
|
||||||
|
|
||||||
|
void psLinuxUndo();
|
||||||
|
void psLinuxRedo();
|
||||||
|
void psLinuxCut();
|
||||||
|
void psLinuxCopy();
|
||||||
|
void psLinuxPaste();
|
||||||
|
void psLinuxDelete();
|
||||||
|
void psLinuxSelectAll();
|
||||||
|
|
||||||
|
void psLinuxBold();
|
||||||
|
void psLinuxItalic();
|
||||||
|
void psLinuxUnderline();
|
||||||
|
void psLinuxStrikeOut();
|
||||||
|
void psLinuxMonospace();
|
||||||
|
void psLinuxClearFormat();
|
||||||
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,11 +35,11 @@ public:
|
||||||
|
|
||||||
void updateWindowIcon() override;
|
void updateWindowIcon() override;
|
||||||
|
|
||||||
|
void psShowTrayMenu();
|
||||||
|
|
||||||
class Private;
|
class Private;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void psShowTrayMenu();
|
|
||||||
|
|
||||||
void psMacUndo();
|
void psMacUndo();
|
||||||
void psMacRedo();
|
void psMacRedo();
|
||||||
void psMacCut();
|
void psMacCut();
|
||||||
|
|
|
@ -21,8 +21,6 @@ class PopupMenu;
|
||||||
namespace Platform {
|
namespace Platform {
|
||||||
|
|
||||||
class MainWindow : public Window::MainWindow {
|
class MainWindow : public Window::MainWindow {
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(not_null<Window::Controller*> controller);
|
explicit MainWindow(not_null<Window::Controller*> controller);
|
||||||
|
|
||||||
|
@ -58,11 +56,10 @@ public:
|
||||||
return _deltaTop;
|
return _deltaTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
~MainWindow();
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void psShowTrayMenu();
|
void psShowTrayMenu();
|
||||||
|
|
||||||
|
~MainWindow();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void initHook() override;
|
void initHook() override;
|
||||||
int32 screenNameChecksum(const QString &name) const override;
|
int32 screenNameChecksum(const QString &name) const override;
|
||||||
|
|
Loading…
Add table
Reference in a new issue