mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 03:00:46 +03:00
parent
1716502eff
commit
1b7816f7ca
5 changed files with 63 additions and 2 deletions
|
@ -376,8 +376,8 @@ else()
|
|||
endif()
|
||||
|
||||
if (APPLE)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Foundation")
|
||||
set(SRC_FILES ${SRC_FILES} src/notifications/ManagerMac.mm)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Foundation -framework Cocoa")
|
||||
set(SRC_FILES ${SRC_FILES} src/notifications/ManagerMac.mm src/emoji/MacHelper.mm)
|
||||
elseif (WIN32)
|
||||
file(DOWNLOAD
|
||||
"https://raw.githubusercontent.com/mohabouje/WinToast/41ed1c58d5dce0ee9c01dbdeac05be45358d4f57/src/wintoastlib.cpp"
|
||||
|
|
|
@ -37,6 +37,10 @@
|
|||
#include "ui/FlatButton.h"
|
||||
#include "ui/LoadingIndicator.h"
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
#include "emoji/MacHelper.h"
|
||||
#endif
|
||||
|
||||
static constexpr size_t INPUT_HISTORY_SIZE = 127;
|
||||
static constexpr int MAX_TEXTINPUT_HEIGHT = 120;
|
||||
static constexpr int InputHeight = 26;
|
||||
|
@ -124,6 +128,12 @@ FilteredTextEdit::keyPressEvent(QKeyEvent *event)
|
|||
{
|
||||
const bool isModifier = (event->modifiers() != Qt::NoModifier);
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
if (event->modifiers() == (Qt::ControlModifier | Qt::MetaModifier) &&
|
||||
event->key() == Qt::Key_Space)
|
||||
MacHelper::showEmojiWindow();
|
||||
#endif
|
||||
|
||||
if (!isModifier) {
|
||||
if (!typingTimer_->isActive())
|
||||
emit startedTyping();
|
||||
|
@ -503,6 +513,11 @@ TextInputWidget::TextInputWidget(QWidget *parent)
|
|||
emojiBtn_ = new emoji::PickButton(this);
|
||||
emojiBtn_->setToolTip(tr("Emoji"));
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
// macOS has a native emoji picker.
|
||||
emojiBtn_->hide();
|
||||
#endif
|
||||
|
||||
QIcon emoji_icon;
|
||||
emoji_icon.addFile(":/icons/icons/ui/smile.png");
|
||||
emojiBtn_->setIcon(emoji_icon);
|
||||
|
|
10
src/emoji/MacHelper.h
Normal file
10
src/emoji/MacHelper.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include <QMenuBar>
|
||||
|
||||
class MacHelper
|
||||
{
|
||||
public:
|
||||
static void showEmojiWindow();
|
||||
static void initializeMenus();
|
||||
};
|
26
src/emoji/MacHelper.mm
Normal file
26
src/emoji/MacHelper.mm
Normal file
|
@ -0,0 +1,26 @@
|
|||
#include "MacHelper.h"
|
||||
|
||||
#include <Cocoa/Cocoa.h>
|
||||
#include <Foundation/Foundation.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <QCoreApplication>
|
||||
|
||||
void
|
||||
MacHelper::showEmojiWindow()
|
||||
{
|
||||
NSApplication *theNSApplication = [NSApplication sharedApplication];
|
||||
[theNSApplication orderFrontCharacterPalette:nil];
|
||||
}
|
||||
|
||||
void
|
||||
MacHelper::initializeMenus()
|
||||
{
|
||||
NSApplication *theNSApplication = [NSApplication sharedApplication];
|
||||
|
||||
NSArray<NSMenuItem *> *menus = [theNSApplication mainMenu].itemArray;
|
||||
NSUInteger size = menus.count;
|
||||
for (NSUInteger i = 0; i < size; i++) {
|
||||
NSMenuItem *item = [menus objectAtIndex:i];
|
||||
[item setTitle:@"Edit"];
|
||||
}
|
||||
}
|
10
src/main.cpp
10
src/main.cpp
|
@ -38,6 +38,10 @@
|
|||
#include "Utils.h"
|
||||
#include "version.h"
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
#include "emoji/MacHelper.h"
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
#include <boost/stacktrace.hpp>
|
||||
#include <signal.h>
|
||||
|
@ -186,6 +190,12 @@ main(int argc, char *argv[])
|
|||
}
|
||||
});
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
// Temporary solution for the emoji picker until
|
||||
// nheko has a proper menu bar with more functionality.
|
||||
MacHelper::initializeMenus();
|
||||
#endif
|
||||
|
||||
nhlog::ui()->info("starting nheko {}", nheko::version);
|
||||
|
||||
return app.exec();
|
||||
|
|
Loading…
Reference in a new issue