mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added support of switching accounts to touchbar.
This commit is contained in:
parent
1248cef86b
commit
2e7a89d9c4
1 changed files with 25 additions and 13 deletions
|
@ -477,24 +477,36 @@ void MainWindow::initTouchBar() {
|
||||||
if (!IsMac10_13OrGreater()) {
|
if (!IsMac10_13OrGreater()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
[NSApplication sharedApplication]
|
||||||
|
.automaticCustomizeTouchBarMenuItemEnabled = true;
|
||||||
|
const auto createNewTouchBar = [=](not_null<Main::Session*> session) {
|
||||||
|
if (_private->_touchBar) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (auto view = reinterpret_cast<NSView*>(winId())) {
|
||||||
|
_private->_touchBar = [[TouchBar alloc]
|
||||||
|
init:view
|
||||||
|
session:session];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Core::App().domain().activeSessionValue(
|
const auto destroyCurrentTouchBar = [=] {
|
||||||
|
if (_private->_touchBar) {
|
||||||
|
[_private->_touchBar setTouchBar:Platform::TouchBarType::None];
|
||||||
|
[_private->_touchBar release];
|
||||||
|
}
|
||||||
|
_private->_touchBar = nil;
|
||||||
|
};
|
||||||
|
|
||||||
|
Core::App().domain().activeSessionChanges(
|
||||||
) | rpl::start_with_next([=](Main::Session *session) {
|
) | rpl::start_with_next([=](Main::Session *session) {
|
||||||
if (session) {
|
if (session) {
|
||||||
// We need only common pinned dialogs.
|
|
||||||
if (!_private->_touchBar) {
|
|
||||||
if (auto view = reinterpret_cast<NSView*>(winId())) {
|
|
||||||
// Create TouchBar.
|
|
||||||
[NSApplication sharedApplication].automaticCustomizeTouchBarMenuItemEnabled = YES;
|
|
||||||
_private->_touchBar = [[TouchBar alloc] init:view session:session];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (_private->_touchBar) {
|
if (_private->_touchBar) {
|
||||||
[_private->_touchBar setTouchBar:Platform::TouchBarType::None];
|
destroyCurrentTouchBar();
|
||||||
[_private->_touchBar release];
|
|
||||||
}
|
}
|
||||||
_private->_touchBar = nil;
|
createNewTouchBar(session);
|
||||||
|
} else {
|
||||||
|
destroyCurrentTouchBar();
|
||||||
}
|
}
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue