Skip to content

Commit

Permalink
Merge pull request #12 from GaZaTu:feature/remove-icu
Browse files Browse the repository at this point in the history
replace ICU with utf8.h
  • Loading branch information
GaZaTu authored Jul 29, 2023
2 parents 1a8e351 + 778c4d9 commit cda1692
Show file tree
Hide file tree
Showing 4 changed files with 1,706 additions and 18 deletions.
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${PROJECT_SOURCE_DIR}/postinst")
include(FindPkgConfig)

find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets)
find_package(ICU REQUIRED COMPONENTS uc)

include_directories(${PROJECT_SOURCE_DIR}/src)

Expand Down Expand Up @@ -106,7 +105,6 @@ if (NOT SKIP_IBUS)
Qt5::Core
Qt5::Gui
Qt5::Widgets
ICU::uc
PkgConfig::IBus
PkgConfig::GLib
PkgConfig::GObject
Expand Down Expand Up @@ -146,7 +144,6 @@ if (NOT SKIP_FCITX5)
Qt5::Core
Qt5::Gui
Qt5::Widgets
ICU::uc
Fcitx5::Core
)

Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,19 +207,18 @@ size=1
### Dependencies

- Qt5 (core, gui, widgets)
- ICU (uc)
- fcitx5 or ibus

### Example Commands To Install Dependencies (probably)

**Arch**:
`sudo pacman -S gcc make cmake qt5-base icu fcitx5 fcitx5-qt fcitx5-gtk`
`sudo pacman -S gcc make cmake qt5-base fcitx5 fcitx5-qt fcitx5-gtk`

**Debian**:
`sudo apt install gcc make cmake qtbase5-dev libicu-dev fcitx5 fcitx5-frontend-gtk3 fcitx5-frontend-qt5 im-config`
`sudo apt install gcc make cmake qtbase5-dev fcitx5 fcitx5-frontend-gtk3 fcitx5-frontend-qt5 im-config`

**openSUSE**:
`sudo zypper install gcc make cmake libqt5-qtbase-devel libicu-devel ibus-devel`
`sudo zypper install gcc make cmake libqt5-qtbase-devel ibus-devel`

### CMake

Expand Down
24 changes: 13 additions & 11 deletions src/EmojiLabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
#include <QScreen>
#include <QWindow>
#include <sstream>
#include <unicode/schriter.h>
#include <unicode/unistr.h>
#include "utf8.h"

EmojiLabel::EmojiLabel(QWidget* parent, const EmojiPickerSettings& settings) : QLabel(parent), _settings(settings) {
setProperty("class", "EmojiLabel");
Expand All @@ -27,15 +26,18 @@ EmojiLabel::EmojiLabel(QWidget* parent, const EmojiPickerSettings& settings, con
}

void getCodepointsByEmojiStr(const std::string& emojiStr, const std::string& separator, std::stringstream& emojiHexCodeStream) {
bool firstCodepoint = true;
icu::UnicodeString emojiUStr(emojiStr.data(), emojiStr.length(), "utf-8");
icu::StringCharacterIterator emojiUStrIterator(emojiUStr);
while (emojiUStrIterator.hasNext()) {
int32_t codepoint = emojiUStrIterator.next32PostInc();

if (firstCodepoint) {
firstCodepoint = false;
} else {
const utf8_int8_t* ptr = emojiStr.data();
utf8_int32_t codepoint = 0;

while (true) {
bool first = codepoint == 0;

ptr = utf8codepoint(ptr, &codepoint);
if (codepoint == 0) {
break;
}

if (!first) {
emojiHexCodeStream << separator;
}

Expand Down
Loading

0 comments on commit cda1692

Please sign in to comment.