mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Added accounts list to dock menu on macOS.
This commit is contained in:
@@ -7433,6 +7433,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
"lng_mac_menu_player_resume" = "Resume";
|
"lng_mac_menu_player_resume" = "Resume";
|
||||||
"lng_mac_menu_player_next" = "Next";
|
"lng_mac_menu_player_next" = "Next";
|
||||||
"lng_mac_menu_player_previous" = "Previous";
|
"lng_mac_menu_player_previous" = "Previous";
|
||||||
|
"lng_mac_menu_profiles" = "Profiles";
|
||||||
|
|
||||||
"lng_mac_touchbar_favorite_stickers" = "Favorite stickers";
|
"lng_mac_touchbar_favorite_stickers" = "Favorite stickers";
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
|
#include "main/main_account.h"
|
||||||
|
#include "main/main_domain.h"
|
||||||
|
#include "main/main_session.h"
|
||||||
|
#include "data/data_user.h"
|
||||||
#include "calls/calls_instance.h"
|
#include "calls/calls_instance.h"
|
||||||
#include "core/sandbox.h"
|
#include "core/sandbox.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
@@ -223,6 +227,40 @@ ApplicationDelegate *_sharedDelegate = nil;
|
|||||||
RpMenu* dockMenu = [[[RpMenu alloc] initWithTitle: @""] autorelease];
|
RpMenu* dockMenu = [[[RpMenu alloc] initWithTitle: @""] autorelease];
|
||||||
[dockMenu setAutoenablesItems:false];
|
[dockMenu setAutoenablesItems:false];
|
||||||
|
|
||||||
|
const auto accounts = Core::App().domain().orderedAccounts();
|
||||||
|
if (accounts.size() > 1) {
|
||||||
|
[dockMenu addItem:[NSMenuItem separatorItem]];
|
||||||
|
NSMenuItem *profilesHeader = [[NSMenuItem alloc]
|
||||||
|
initWithTitle:@"" action:nil keyEquivalent:@""];
|
||||||
|
NSDictionary *attributes = @{
|
||||||
|
NSFontAttributeName: [NSFont
|
||||||
|
menuFontOfSize:[NSFont smallSystemFontSize]],
|
||||||
|
NSForegroundColorAttributeName: [NSColor secondaryLabelColor]
|
||||||
|
};
|
||||||
|
NSAttributedString *attrTitle = [[NSAttributedString alloc]
|
||||||
|
initWithString:Q2NSString(tr::lng_mac_menu_profiles(tr::now))
|
||||||
|
attributes:attributes];
|
||||||
|
[profilesHeader setAttributedTitle:attrTitle];
|
||||||
|
[attrTitle release];
|
||||||
|
[profilesHeader setEnabled:NO];
|
||||||
|
[dockMenu addItem:[profilesHeader autorelease]];
|
||||||
|
constexpr auto kMaxLength = 30;
|
||||||
|
for (const auto &account : accounts) {
|
||||||
|
if (account->sessionExists()) {
|
||||||
|
auto name = account->session().user()->name();
|
||||||
|
[dockMenu addItem:CreateMenuItem(
|
||||||
|
(name.size() > kMaxLength)
|
||||||
|
? (name.mid(0, kMaxLength) + Ui::kQEllipsis)
|
||||||
|
: name,
|
||||||
|
[dockMenu lifetime],
|
||||||
|
[account] {
|
||||||
|
Core::App().ensureSeparateWindowFor(account);
|
||||||
|
})];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[dockMenu addItem:[NSMenuItem separatorItem]];
|
||||||
|
}
|
||||||
|
|
||||||
auto notifyCallback = [] {
|
auto notifyCallback = [] {
|
||||||
auto &settings = Core::App().settings();
|
auto &settings = Core::App().settings();
|
||||||
settings.setDesktopNotify(!settings.desktopNotify());
|
settings.setDesktopNotify(!settings.desktopNotify());
|
||||||
|
|||||||
Reference in New Issue
Block a user