mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 04:58:49 +03:00
parent
1716502eff
commit
1b7816f7ca
5 changed files with 63 additions and 2 deletions
|
@ -376,8 +376,8 @@ else()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Foundation")
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Foundation -framework Cocoa")
|
||||||
set(SRC_FILES ${SRC_FILES} src/notifications/ManagerMac.mm)
|
set(SRC_FILES ${SRC_FILES} src/notifications/ManagerMac.mm src/emoji/MacHelper.mm)
|
||||||
elseif (WIN32)
|
elseif (WIN32)
|
||||||
file(DOWNLOAD
|
file(DOWNLOAD
|
||||||
"https://raw.githubusercontent.com/mohabouje/WinToast/41ed1c58d5dce0ee9c01dbdeac05be45358d4f57/src/wintoastlib.cpp"
|
"https://raw.githubusercontent.com/mohabouje/WinToast/41ed1c58d5dce0ee9c01dbdeac05be45358d4f57/src/wintoastlib.cpp"
|
||||||
|
|
|
@ -37,6 +37,10 @@
|
||||||
#include "ui/FlatButton.h"
|
#include "ui/FlatButton.h"
|
||||||
#include "ui/LoadingIndicator.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 size_t INPUT_HISTORY_SIZE = 127;
|
||||||
static constexpr int MAX_TEXTINPUT_HEIGHT = 120;
|
static constexpr int MAX_TEXTINPUT_HEIGHT = 120;
|
||||||
static constexpr int InputHeight = 26;
|
static constexpr int InputHeight = 26;
|
||||||
|
@ -124,6 +128,12 @@ FilteredTextEdit::keyPressEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
const bool isModifier = (event->modifiers() != Qt::NoModifier);
|
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 (!isModifier) {
|
||||||
if (!typingTimer_->isActive())
|
if (!typingTimer_->isActive())
|
||||||
emit startedTyping();
|
emit startedTyping();
|
||||||
|
@ -503,6 +513,11 @@ TextInputWidget::TextInputWidget(QWidget *parent)
|
||||||
emojiBtn_ = new emoji::PickButton(this);
|
emojiBtn_ = new emoji::PickButton(this);
|
||||||
emojiBtn_->setToolTip(tr("Emoji"));
|
emojiBtn_->setToolTip(tr("Emoji"));
|
||||||
|
|
||||||
|
#if defined(Q_OS_MAC)
|
||||||
|
// macOS has a native emoji picker.
|
||||||
|
emojiBtn_->hide();
|
||||||
|
#endif
|
||||||
|
|
||||||
QIcon emoji_icon;
|
QIcon emoji_icon;
|
||||||
emoji_icon.addFile(":/icons/icons/ui/smile.png");
|
emoji_icon.addFile(":/icons/icons/ui/smile.png");
|
||||||
emojiBtn_->setIcon(emoji_icon);
|
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 "Utils.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
|
#if defined(Q_OS_MAC)
|
||||||
|
#include "emoji/MacHelper.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(Q_OS_LINUX)
|
#if defined(Q_OS_LINUX)
|
||||||
#include <boost/stacktrace.hpp>
|
#include <boost/stacktrace.hpp>
|
||||||
#include <signal.h>
|
#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);
|
nhlog::ui()->info("starting nheko {}", nheko::version);
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
|
|
Loading…
Reference in a new issue