mirror of https://github.com/procxx/kepka.git
Refactored code.
This commit is contained in:
parent
9059b2e617
commit
92ff237c2d
|
@ -25,11 +25,7 @@ static NSTouchBarCustomizationIdentifier _Nullable customIDMain = @"telegram.tou
|
|||
static NSTouchBarItemIdentifier _Nullable savedMessages = [NSString stringWithFormat:@"%@.savedMessages", customIDMain];
|
||||
static NSTouchBarItemIdentifier _Nullable archiveFolder = [NSString stringWithFormat:@"%@.archiveFolder", customIDMain];
|
||||
|
||||
static NSTouchBarItemIdentifier _Nullable pinnedDialog1 = [NSString stringWithFormat:@"%@.pinnedDialog1", customIDMain];
|
||||
static NSTouchBarItemIdentifier _Nullable pinnedDialog2 = [NSString stringWithFormat:@"%@.pinnedDialog2", customIDMain];
|
||||
static NSTouchBarItemIdentifier _Nullable pinnedDialog3 = [NSString stringWithFormat:@"%@.pinnedDialog3", customIDMain];
|
||||
static NSTouchBarItemIdentifier _Nullable pinnedDialog4 = [NSString stringWithFormat:@"%@.pinnedDialog4", customIDMain];
|
||||
static NSTouchBarItemIdentifier _Nullable pinnedDialog5 = [NSString stringWithFormat:@"%@.pinnedDialog5", customIDMain];
|
||||
static NSTouchBarItemIdentifier _Nullable pinnedPanel = [NSString stringWithFormat:@"%@.pinnedPanel", customIDMain];
|
||||
|
||||
static NSTouchBarItemIdentifier _Nullable seekBar = [NSString stringWithFormat:@"%@.seekbar", BASE_ID];
|
||||
static NSTouchBarItemIdentifier _Nullable play = [NSString stringWithFormat:@"%@.play", BASE_ID];
|
||||
|
|
|
@ -159,7 +159,6 @@ auto lifetime = rpl::lifetime();
|
|||
self.peer = nil;
|
||||
return;
|
||||
}
|
||||
// Order is reversed.
|
||||
const auto pinned = order.at(self.number - 1);
|
||||
if (const auto history = pinned.history()) {
|
||||
self.peer = history->peer;
|
||||
|
@ -219,32 +218,9 @@ auto lifetime = rpl::lifetime();
|
|||
if (self) {
|
||||
self.view = view;
|
||||
self.touchbarItems = @{
|
||||
// savedMessages: [NSMutableDictionary dictionaryWithDictionary:@{
|
||||
// @"type": @"button",
|
||||
// @"name": @"Saved Messages",
|
||||
// @"cmd": [NSNumber numberWithInt:kSavedMessages],
|
||||
// @"image": static_cast<NSImage*>(qt_mac_create_nsimage(*pix)),
|
||||
// }],
|
||||
pinnedDialog1: [NSMutableDictionary dictionaryWithDictionary:@{
|
||||
pinnedPanel: [NSMutableDictionary dictionaryWithDictionary:@{
|
||||
@"type": @"pinned",
|
||||
@"num": @1,
|
||||
}],
|
||||
// pinnedDialog2: [NSMutableDictionary dictionaryWithDictionary:@{
|
||||
// @"type": @"pinned",
|
||||
// @"num": @2,
|
||||
// }],
|
||||
// pinnedDialog3: [NSMutableDictionary dictionaryWithDictionary:@{
|
||||
// @"type": @"pinned",
|
||||
// @"num": @3,
|
||||
// }],
|
||||
// pinnedDialog4: [NSMutableDictionary dictionaryWithDictionary:@{
|
||||
// @"type": @"pinned",
|
||||
// @"num": @4,
|
||||
// }],
|
||||
// pinnedDialog5: [NSMutableDictionary dictionaryWithDictionary:@{
|
||||
// @"type": @"pinned",
|
||||
// @"num": @5,
|
||||
// }],
|
||||
seekBar: [NSMutableDictionary dictionaryWithDictionary:@{
|
||||
@"type": @"slider",
|
||||
@"name": @"Seek Bar"
|
||||
|
@ -300,8 +276,7 @@ auto lifetime = rpl::lifetime();
|
|||
_touchBarMain.delegate = self;
|
||||
|
||||
_touchBarMain.customizationIdentifier = customIDMain;
|
||||
_touchBarMain.defaultItemIdentifiers = @[savedMessages, pinnedDialog1, pinnedDialog2, pinnedDialog3, pinnedDialog4, pinnedDialog5];
|
||||
_touchBarMain.customizationAllowedItemIdentifiers = @[savedMessages];
|
||||
_touchBarMain.defaultItemIdentifiers = @[pinnedPanel];
|
||||
|
||||
_touchBarAudioPlayer = [[NSTouchBar alloc] init];
|
||||
_touchBarAudioPlayer.delegate = self;
|
||||
|
@ -334,7 +309,7 @@ auto lifetime = rpl::lifetime();
|
|||
return item;
|
||||
} else if ([self.touchbarItems[identifier][@"type"] isEqualToString:@"text"]) {
|
||||
NSCustomTouchBarItem *item = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
|
||||
NSTextField *text = [NSTextField labelWithString:@"0:00"];
|
||||
NSTextField *text = [NSTextField labelWithString:@"00:00 / 00:00"];
|
||||
text.alignment = NSTextAlignmentCenter;
|
||||
item.view = text;
|
||||
item.customizationLabel = self.touchbarItems[identifier][@"name"];
|
||||
|
@ -344,7 +319,7 @@ auto lifetime = rpl::lifetime();
|
|||
NSCustomTouchBarItem *item = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
|
||||
NSMutableArray *pins = [[NSMutableArray alloc] init];
|
||||
|
||||
for (auto i = -1; i <= 5; i++) {
|
||||
for (auto i = kArchiveId; i <= Global::PinnedDialogsCountMax(); i++) {
|
||||
[pins addObject:[[PinnedDialogButton alloc] init:i].view];
|
||||
}
|
||||
NSStackView *stackView = [NSStackView stackViewWithViews:[pins copy]];
|
||||
|
@ -468,9 +443,7 @@ auto lifetime = rpl::lifetime();
|
|||
const auto command = [self.touchbarItems[identifier][@"cmd"] intValue];
|
||||
|
||||
Core::Sandbox::Instance().customEnterFromEventLoop([=] {
|
||||
if (command == kSavedMessages) {
|
||||
App::main()->choosePeer(Auth().userPeerId(), ShowAtUnreadMsgId);
|
||||
} else if (command == kPlayPause) {
|
||||
if (command == kPlayPause) {
|
||||
Media::Player::instance()->playPause();
|
||||
} else if (command == kPlaylistPrevious) {
|
||||
Media::Player::instance()->previous();
|
||||
|
|
Loading…
Reference in New Issue