mirror of https://github.com/procxx/kepka.git
Added buttons for Underline and Strike-through text to touchbar.
This commit is contained in:
parent
2d62c9b083
commit
821bd3c65b
|
@ -52,9 +52,11 @@ constexpr auto kCommandClosePlayer = 0x005;
|
||||||
|
|
||||||
constexpr auto kCommandBold = 0x010;
|
constexpr auto kCommandBold = 0x010;
|
||||||
constexpr auto kCommandItalic = 0x011;
|
constexpr auto kCommandItalic = 0x011;
|
||||||
constexpr auto kCommandMonospace = 0x012;
|
constexpr auto kCommandUnderline = 0x012;
|
||||||
constexpr auto kCommandClear = 0x013;
|
constexpr auto kCommandStrikeOut = 0x013;
|
||||||
constexpr auto kCommandLink = 0x014;
|
constexpr auto kCommandMonospace = 0x014;
|
||||||
|
constexpr auto kCommandClear = 0x015;
|
||||||
|
constexpr auto kCommandLink = 0x016;
|
||||||
|
|
||||||
constexpr auto kCommandScrubberStickers = 0x020;
|
constexpr auto kCommandScrubberStickers = 0x020;
|
||||||
constexpr auto kCommandScrubberEmoji = 0x021;
|
constexpr auto kCommandScrubberEmoji = 0x021;
|
||||||
|
@ -297,6 +299,13 @@ void SendKeyEvent(int command) {
|
||||||
case kCommandLink:
|
case kCommandLink:
|
||||||
key = Qt::Key_K;
|
key = Qt::Key_K;
|
||||||
break;
|
break;
|
||||||
|
case kCommandUnderline:
|
||||||
|
key = Qt::Key_U;
|
||||||
|
break;
|
||||||
|
case kCommandStrikeOut:
|
||||||
|
key = Qt::Key_X;
|
||||||
|
modifier |= Qt::ShiftModifier;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
QApplication::postEvent(focused, new QKeyEvent(QEvent::KeyPress, key, modifier));
|
QApplication::postEvent(focused, new QKeyEvent(QEvent::KeyPress, key, modifier));
|
||||||
QApplication::postEvent(focused, new QKeyEvent(QEvent::KeyRelease, key, modifier));
|
QApplication::postEvent(focused, new QKeyEvent(QEvent::KeyRelease, key, modifier));
|
||||||
|
@ -991,28 +1000,36 @@ void AppendEmojiPacks(std::vector<PickerScrubberItem> &to) {
|
||||||
NSTouchBar *secondaryTouchBar = [[NSTouchBar alloc] init];
|
NSTouchBar *secondaryTouchBar = [[NSTouchBar alloc] init];
|
||||||
secondaryTouchBar.delegate = self;
|
secondaryTouchBar.delegate = self;
|
||||||
secondaryTouchBar.defaultItemIdentifiers = @[kPopoverInputFormatterItemIdentifier];
|
secondaryTouchBar.defaultItemIdentifiers = @[kPopoverInputFormatterItemIdentifier];
|
||||||
item.pressAndHoldTouchBar = secondaryTouchBar;
|
|
||||||
item.popoverTouchBar = secondaryTouchBar;
|
item.popoverTouchBar = secondaryTouchBar;
|
||||||
return item;
|
return item;
|
||||||
} else if (isType(kTypeFormatterSegment)) {
|
} else if (isType(kTypeFormatterSegment)) {
|
||||||
NSCustomTouchBarItem *item = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
|
NSCustomTouchBarItem *item = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
|
||||||
|
NSScrollView *scroll = [[NSScrollView alloc] init];
|
||||||
NSSegmentedControl *segment = [[NSSegmentedControl alloc] init];
|
NSSegmentedControl *segment = [[NSSegmentedControl alloc] init];
|
||||||
segment.segmentStyle = NSSegmentStyleRounded;
|
segment.segmentStyle = NSSegmentStyleRounded;
|
||||||
|
segment.target = self;
|
||||||
|
segment.action = @selector(formatterClicked:);
|
||||||
|
|
||||||
static const auto strings = {
|
static const auto strings = {
|
||||||
tr::lng_menu_formatting_bold,
|
tr::lng_menu_formatting_bold,
|
||||||
tr::lng_menu_formatting_italic,
|
tr::lng_menu_formatting_italic,
|
||||||
|
tr::lng_menu_formatting_underline,
|
||||||
|
tr::lng_menu_formatting_strike_out,
|
||||||
tr::lng_menu_formatting_monospace,
|
tr::lng_menu_formatting_monospace,
|
||||||
tr::lng_menu_formatting_clear,
|
tr::lng_menu_formatting_clear,
|
||||||
tr::lng_info_link_label,
|
tr::lng_info_link_label,
|
||||||
};
|
};
|
||||||
segment.segmentCount = strings.size();
|
segment.segmentCount = strings.size();
|
||||||
|
auto width = 0;
|
||||||
auto count = 0;
|
auto count = 0;
|
||||||
for (const auto s : strings) {
|
for (const auto s : strings) {
|
||||||
[segment setLabel:Q2NSString(s(tr::now)) forSegment:count++];
|
const auto string = Q2NSString(s(tr::now));
|
||||||
|
width += WidthFromString(string) * 1.4;
|
||||||
|
[segment setLabel:string forSegment:count++];
|
||||||
}
|
}
|
||||||
segment.target = self;
|
segment.frame = NSMakeRect(0, 0, width, kScrubberHeight);
|
||||||
segment.action = @selector(formatterClicked:);
|
[scroll setDocumentView:segment];
|
||||||
item.view = segment;
|
item.view = scroll;
|
||||||
return item;
|
return item;
|
||||||
} else if (isType(kTypeScrubber)) {
|
} else if (isType(kTypeScrubber)) {
|
||||||
const auto isSticker = ([dictionaryItem[@"cmd"] intValue]
|
const auto isSticker = ([dictionaryItem[@"cmd"] intValue]
|
||||||
|
|
Loading…
Reference in New Issue