metaemoji xcode project added, added hack to qt to fix window system handle

This commit is contained in:
John Preston 2014-06-20 13:49:22 +04:00
parent e0a364dd0f
commit bfe1ca92b8
6 changed files with 101 additions and 42 deletions

View File

@ -599,6 +599,7 @@
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)Lang$(EFFECTIVE_PLATFORM_NAME)";
COPY_PHASE_STRIP = YES;
DYLIB_COMPATIBILITY_VERSION = 1.0;
DYLIB_CURRENT_VERSION = 1.0.0;
@ -633,7 +634,7 @@
"/usr/local/Qt-5.3.0/plugins/imageformats",
);
MACOSX_DEPLOYMENT_TARGET = 10.7;
OBJROOT = ../Mac/DebugIntermediateLang/;
OBJROOT = ./../Mac/ReleaseIntermediateLang;
OTHER_CFLAGS = (
"-pipe",
"-g",
@ -669,7 +670,7 @@
PRODUCT_NAME = MetaLang;
QT_LIBRARY_SUFFIX = "";
SDKROOT = macosx;
SYMROOT = ../Mac/ReleaseLang;
SYMROOT = ./../Mac;
};
name = Release;
};
@ -683,6 +684,7 @@
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)Lang$(EFFECTIVE_PLATFORM_NAME)";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
DYLIB_COMPATIBILITY_VERSION = 1.0;
@ -719,7 +721,7 @@
"/usr/local/Qt-5.3.0/plugins/imageformats",
);
MACOSX_DEPLOYMENT_TARGET = 10.7;
OBJROOT = ../Mac/DebugIntermediateLang/;
OBJROOT = ./../Mac/DebugIntermediateLang;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = (
"-pipe",
@ -756,7 +758,7 @@
PRODUCT_NAME = MetaLang;
QT_LIBRARY_SUFFIX = _debug;
SDKROOT = macosx;
SYMROOT = ../Mac/DebugLang;
SYMROOT = ./../Mac;
};
name = Debug;
};
@ -764,7 +766,6 @@
isa = XCBuildConfiguration;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)Lang$(EFFECTIVE_PLATFORM_NAME)";
COPY_PHASE_STRIP = YES;
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
HEADER_SEARCH_PATHS = (
@ -779,11 +780,9 @@
"/usr/local/Qt-5.3.0/mkspecs/macx-clang",
);
INSTALL_DIR = ../Mac/ReleaseLang/;
OBJROOT = ../Mac/ReleaseIntermediateLang;
PRODUCT_NAME = MetaLang;
QT_LIBRARY_SUFFIX = "";
SDKROOT = macosx;
SYMROOT = ./../Mac;
};
name = Release;
};
@ -791,7 +790,6 @@
isa = XCBuildConfiguration;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)Lang$(EFFECTIVE_PLATFORM_NAME)";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
@ -808,11 +806,9 @@
"/usr/local/Qt-5.3.0/mkspecs/macx-clang",
);
INSTALL_DIR = ../Mac/DebugLang/;
OBJROOT = ../Mac/DebugIntermediateLang;
PRODUCT_NAME = MetaLang;
QT_LIBRARY_SUFFIX = _debug;
SDKROOT = macosx;
SYMROOT = ./../Mac;
};
name = Debug;
};

View File

@ -519,6 +519,7 @@
6DB9C3763D02B1415CD9D565 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0510;
};
buildConfigurationList = DAC4C1AA5EDEA1C85E9CA5E6 /* Build configuration list for PBXProject "MetaStyle" */;
compatibilityVersion = "Xcode 3.2";
@ -591,14 +592,26 @@
339EE1B2CC4FC24589A0EA95 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = x86_64;
CC = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)Style$(EFFECTIVE_PLATFORM_NAME)";
COPY_PHASE_STRIP = YES;
DYLIB_COMPATIBILITY_VERSION = 1.0;
DYLIB_CURRENT_VERSION = 1.0.0;
FRAMEWORK_SEARCH_PATHS = "";
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
../../Libraries/QtStatic/qtbase/include/QtGui/5.3.0/QtGui,
../../Libraries/QtStatic/qtbase/include/QtCore/5.3.0/QtCore,
@ -621,7 +634,7 @@
"/usr/local/Qt-5.3.0/plugins/imageformats",
);
MACOSX_DEPLOYMENT_TARGET = 10.7;
OBJROOT = ../Mac/DebugIntermediateStyle/;
OBJROOT = ./../Mac/ReleaseIntermediateStyle;
OTHER_CFLAGS = (
"-pipe",
"-g",
@ -657,15 +670,21 @@
PRODUCT_NAME = MetaStyle;
QT_LIBRARY_SUFFIX = "";
SDKROOT = macosx;
SYMROOT = ../Mac/ReleaseStyle;
SYMROOT = ./../Mac;
};
name = Release;
};
3AA6C32AC930069E80220CF1 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = x86_64;
CC = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)Style$(EFFECTIVE_PLATFORM_NAME)";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
DYLIB_COMPATIBILITY_VERSION = 1.0;
@ -674,6 +693,12 @@
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
../../Libraries/QtStatic/qtbase/include/QtGui/5.3.0/QtGui,
../../Libraries/QtStatic/qtbase/include/QtCore/5.3.0/QtCore,
@ -696,7 +721,8 @@
"/usr/local/Qt-5.3.0/plugins/imageformats",
);
MACOSX_DEPLOYMENT_TARGET = 10.7;
OBJROOT = ../Mac/DebugIntermediateStyle/;
OBJROOT = ./../Mac/DebugIntermediateStyle;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = (
"-pipe",
"-g",
@ -732,14 +758,14 @@
PRODUCT_NAME = MetaStyle;
QT_LIBRARY_SUFFIX = _debug;
SDKROOT = macosx;
SYMROOT = ../Mac/DebugStyle;
SYMROOT = ./../Mac;
};
name = Debug;
};
6666AA5E688052234F6758D8 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)Style$(EFFECTIVE_PLATFORM_NAME)";
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = YES;
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
HEADER_SEARCH_PATHS = (
@ -754,18 +780,16 @@
"/usr/local/Qt-5.3.0/mkspecs/macx-clang",
);
INSTALL_DIR = ./../Mac/ReleaseStyle/;
OBJROOT = ./../Mac/ReleaseIntermediateStyle;
PRODUCT_NAME = MetaStyle;
QT_LIBRARY_SUFFIX = "";
SDKROOT = macosx;
SYMROOT = ./../Mac;
};
name = Release;
};
77418F46922677BB04ED38DD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)Style$(EFFECTIVE_PLATFORM_NAME)";
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
@ -782,11 +806,9 @@
"/usr/local/Qt-5.3.0/mkspecs/macx-clang",
);
INSTALL_DIR = ./../Mac/DebugStyle/;
OBJROOT = ./../Mac/DebugIntermediateStyle;
PRODUCT_NAME = MetaStyle;
QT_LIBRARY_SUFFIX = _debug;
SDKROOT = macosx;
SYMROOT = ./../Mac;
};
name = Debug;
};

View File

@ -17,8 +17,10 @@ Copyright (c) 2014 John Preston, https://tdesktop.com
*/
#include "genemoji.h"
#ifdef Q_OS_WIN
#include <QtCore/QtPlugin>
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
#endif
typedef unsigned int uint32;
@ -938,7 +940,7 @@ void writeEmojiCategory(QTextStream &tcpp, uint32 *emojiCategory, uint32 size, c
tcpp << "\t\tstatic QVector<EmojiPtr> v" << name << ";\n";
tcpp << "\t\tif (v" << name << ".isEmpty()) {\n";
tcpp << "\t\t\tv" << name << ".resize(" << size << ");\n";
for (int i = 0; i < size; ++i) {
for (uint32 i = 0; i < size; ++i) {
int index = 0;
for (EmojisData::const_iterator j = emojisData.cbegin(), e = emojisData.cend(); j != e; ++j) {
if (j->code == emojiCategory[i]) {
@ -947,7 +949,7 @@ void writeEmojiCategory(QTextStream &tcpp, uint32 *emojiCategory, uint32 size, c
++index;
}
if (index == emojisData.size()) {
throw exception(QString("Could not find emoji from category '%1' with index %2, code %3").arg(name).arg(i).arg(emojiCategory[i]).toUtf8().constData());
throw Exception(QString("Could not find emoji from category '%1' with index %2, code %3").arg(name).arg(i).arg(emojiCategory[i]).toUtf8().constData());
}
tcpp << "\t\t\tv" << name << "[" << i << "] = &emojis[" << index << "];\n";
}
@ -956,7 +958,7 @@ void writeEmojiCategory(QTextStream &tcpp, uint32 *emojiCategory, uint32 size, c
tcpp << "\t} break;\n\n";
}
bool genEmoji(QString emoji_in, const QString &emoji_out) {
bool genEmoji(QString emoji_in, const QString &emoji_out, const QString &emoji_png) {
QDir d(emoji_in);
if (!d.exists()) {
cout << "Could not open emoji input dir '" << emoji_in.toUtf8().constData() << "'!\n";
@ -1012,7 +1014,7 @@ bool genEmoji(QString emoji_in, const QString &emoji_out) {
if (data.code < min1) min1 = data.code;
if (data.code > max1) max1 = data.code;
}
} else if (high == 35 || high >= 48 && high < 58) { // digits
} else if (high == 35 || (high >= 48 && high < 58)) { // digits
} else {
if (data.code < min2) min2 = data.code;
if (data.code > max2) max2 = data.code;
@ -1055,7 +1057,8 @@ bool genEmoji(QString emoji_in, const QString &emoji_out) {
cout << "Could not read image '" << name.toUtf8().constData() << "'!\n";
}
}
QString postfix = variantPostfix[variantIndex], emojif = "./SourceFiles/art/emoji" + postfix + ".png";
QString postfix = variantPostfix[variantIndex], emojif = emoji_png + postfix + ".png";
const char *tmp = emojif.toUtf8().constData();
QByteArray emojib;
{
QBuffer ebuf(&emojib);
@ -1126,7 +1129,8 @@ Copyright (c) 2014 John Preston, https://tdesktop.com\n\
tcpp << "void initEmoji() {\n";
tcpp << "\tEmojiData *toFill = emojis = (EmojiData*)emojisData;\n\n";
tcpp << "\tswitch (cScale()) {\n\n";
tcpp << "\tDBIScale emojiForScale = cRetina() ? dbisTwo : cScale();\n\n";
tcpp << "\tswitch (emojiForScale) {\n\n";
for (int variantIndex = 0; variantIndex < variantsCount; ++variantIndex) {
int imSize = imSizes[variantIndex];
tcpp << "\tcase " << variantNames[variantIndex] << ":\n";
@ -1165,7 +1169,7 @@ Copyright (c) 2014 John Preston, https://tdesktop.com\n\
tcpp << "\t\treturn 0;\n";
tcpp << "\t}\n\n";
tcpp << "\tif (highCode == 35 || highCode >= 48 && highCode < 58) {\n"; // digits
tcpp << "\tif (highCode == 35 || (highCode >= 48 && highCode < 58)) {\n"; // digits
tcpp << "\t\tif ((code & 0xFFFF) != 0x20E3) return 0;\n\n";
tcpp << "\t\tswitch (code) {\n";
for (; i != e; ++i) {
@ -1194,7 +1198,7 @@ Copyright (c) 2014 John Preston, https://tdesktop.com\n\
tcpp << "\tswitch (ch->unicode()) {\n";
QString tab("\t");
for (int i = 0; i < replacesCount; ++i) {
for (uint32 i = 0; i < replacesCount; ++i) {
QString key = QString::fromUtf8(replaces[i].replace);
replaceMap[key] = replaces[i].code;
}
@ -1268,8 +1272,8 @@ Copyright (c) 2014 John Preston, https://tdesktop.com\n\
}
if (write_cpp) {
cout << "Emoji updated, writing " << currentRow << " rows, full count " << emojisData.size() << " emojis.\n";
if (!cpp.open(QIODevice::WriteOnly)) throw exception("Could not open style_auto.cpp for writing!");
if (cpp.write(cppText) != cppText.size()) throw exception("Could not open style_auto.cpp for writing!");
if (!cpp.open(QIODevice::WriteOnly)) throw Exception("Could not open style_auto.cpp for writing!");
if (cpp.write(cppText) != cppText.size()) throw Exception("Could not open style_auto.cpp for writing!");
}/**/
} catch (exception &e) {
cout << e.what() << "\n";

View File

@ -37,19 +37,35 @@ using std::cout;
using std::cerr;
using std::exception;
bool genEmoji(QString emoji_in, const QString &emoji_out);
class Exception : public exception {
public:
Exception(const QString &msg) : _msg(msg) {
}
virtual const char *what() const throw() {
return _msg.toUtf8().constData();
}
virtual ~Exception() throw() {
}
private:
QString _msg;
};
bool genEmoji(QString emoji_in, const QString &emoji_out, const QString &emoji_png);
class GenEmoji : public QObject {
Q_OBJECT
public:
GenEmoji(const QString &emoji_in, const QString &emoji_out) : QObject(0),
_emoji_in(emoji_in), _emoji_out(emoji_out) {
GenEmoji(const QString &emoji_in, const QString &emoji_out, const QString &emoji_png) : QObject(0),
_emoji_in(emoji_in), _emoji_out(emoji_out), _emoji_png(emoji_png) {
}
public slots :
void run() {
if (genEmoji(_emoji_in, _emoji_out)) {
if (genEmoji(_emoji_in, _emoji_out, _emoji_png)) {
emit finished();
}
}
@ -59,5 +75,5 @@ signals:
private:
QString _emoji_in, _emoji_out;
QString _emoji_in, _emoji_out, _emoji_png;
};

View File

@ -18,15 +18,32 @@ Copyright (c) 2014 John Preston, https://tdesktop.com
#include "memain.h"
int main(int argc, char *argv[]) {
QString emoji_in("."), emoji_out("emoji_config.cpp");
QString emoji_in("."), emoji_out("emoji_config.cpp"), emoji_png("./SourceFiles/art/emoji");
for (int i = 0; i < argc; ++i) {
if (string("-emoji_in") == argv[i]) {
if (++i < argc) emoji_in = argv[i];
} else if (string("-emoji_out") == argv[i]) {
if (++i < argc) emoji_out = argv[i];
} else if (string("-emoji_png") == argv[i]) {
if (++i < argc) emoji_png = argv[i];
}
}
QObject *taskImpl = new GenEmoji(emoji_in, emoji_out);
#ifdef Q_OS_MAC
if (QDir(QString()).absolutePath() == "/") {
QString first = argc ? QString::fromLocal8Bit(argv[0]) : QString();
if (!first.isEmpty()) {
QFileInfo info(first);
if (info.exists()) {
QDir result(info.absolutePath() + "/../../..");
QString basePath = result.absolutePath() + '/';
emoji_in = basePath + emoji_in;
emoji_out = basePath + emoji_out;
emoji_png = basePath + emoji_png;
}
}
}
#endif
QObject *taskImpl = new GenEmoji(emoji_in, emoji_out, emoji_png);
QGuiApplication a(argc, argv);

View File

@ -1,5 +1,9 @@
/*
This file is part of Telegram Desktop,
Created from emoji config by '/MetaEmoji' project
WARNING! All changes made in this file will be lost!
This file is part of Telegram Desktop,
an unofficial desktop messaging app, see https://telegram.org
Telegram Desktop is free software: you can redistribute it and/or modify
@ -26,8 +30,8 @@ namespace {
void initEmoji() {
EmojiData *toFill = emojis = (EmojiData*)emojisData;
DBIScale emojiForScale = cRetina() ? dbisTwo : cScale();
DBIScale emojiForScale = cRetina() ? dbisTwo : cScale();
switch (emojiForScale) {
case dbisOne: