diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index 4d3dbf8f49..1cb5d7e691 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -21,9 +21,9 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "stdafx.h" #include "app.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0) +#ifdef OS_MAC_OLD #include <libexif/exif-data.h> -#endif +#endif // OS_MAC_OLD #include "styles/style_overview.h" #include "styles/style_mediaview.h" @@ -2395,9 +2395,9 @@ namespace { } { QImageReader reader(&buffer, *format); -#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) +#ifndef OS_MAC_OLD reader.setAutoTransform(true); -#endif +#endif // OS_MAC_OLD if (animated) *animated = reader.supportsAnimation() && reader.imageCount() > 1; QByteArray fmt = reader.format(); if (!fmt.isEmpty()) *format = fmt; @@ -2410,7 +2410,7 @@ namespace { buffer.seek(0); QString fmt = QString::fromUtf8(*format).toLower(); if (fmt == "jpg" || fmt == "jpeg") { -#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0) +#ifdef OS_MAC_OLD ExifData *exifData = exif_data_new_from_data((const uchar*)(data.constData()), data.size()); if (exifData) { ExifByteOrder byteOrder = exif_data_get_byte_order(exifData); @@ -2431,7 +2431,7 @@ namespace { } exif_data_free(exifData); } -#endif +#endif // OS_MAC_OLD } else if (opaque && result.hasAlphaChannel()) { QImage solid(result.width(), result.height(), QImage::Format_ARGB32_Premultiplied); solid.fill(st::white->c); diff --git a/Telegram/SourceFiles/codegen/style/generator.cpp b/Telegram/SourceFiles/codegen/style/generator.cpp index 286cd7cfc5..4dbd47fc1b 100644 --- a/Telegram/SourceFiles/codegen/style/generator.cpp +++ b/Telegram/SourceFiles/codegen/style/generator.cpp @@ -664,7 +664,7 @@ bool Generator::writeIconValues() { if (maskData.isEmpty()) { return false; } - source_->stream() << "const uchar iconMask" << i.value() << "Data[] = " << stringToBinaryArray(maskData.toStdString()) << ";\n"; + source_->stream() << "const uchar iconMask" << i.value() << "Data[] = " << stringToBinaryArray(std::string(maskData.constData(), maskData.size())) << ";\n"; source_->stream() << "IconMask iconMask" << i.value() << "(iconMask" << i.value() << "Data);\n\n"; } return true; diff --git a/Telegram/SourceFiles/core/basic_types.h b/Telegram/SourceFiles/core/basic_types.h index 18958f2f62..2a734a79ae 100644 --- a/Telegram/SourceFiles/core/basic_types.h +++ b/Telegram/SourceFiles/core/basic_types.h @@ -175,6 +175,8 @@ template <typename T, size_t N> char(&ArraySizeHelper(T(&array)[N]))[N]; // For QFlags<> declared in private section of a class we need to declare // operators from Q_DECLARE_OPERATORS_FOR_FLAGS as friend functions. +#ifndef OS_MAC_OLD + #define Q_DECLARE_FRIEND_INCOMPATIBLE_FLAGS(Flags) \ friend Q_DECL_CONSTEXPR QIncompatibleFlag operator|(Flags::enum_type f1, int f2) Q_DECL_NOTHROW; @@ -183,6 +185,18 @@ friend Q_DECL_CONSTEXPR QFlags<Flags::enum_type> operator|(Flags::enum_type f1, friend Q_DECL_CONSTEXPR QFlags<Flags::enum_type> operator|(Flags::enum_type f1, QFlags<Flags::enum_type> f2) Q_DECL_NOTHROW; \ Q_DECLARE_FRIEND_INCOMPATIBLE_FLAGS(Flags) +#else // OS_MAC_OLD + +#define Q_DECLARE_FRIEND_INCOMPATIBLE_FLAGS(Flags) \ +friend Q_DECL_CONSTEXPR QIncompatibleFlag operator|(Flags::enum_type f1, int f2); + +#define Q_DECLARE_FRIEND_OPERATORS_FOR_FLAGS(Flags) \ +friend Q_DECL_CONSTEXPR QFlags<Flags::enum_type> operator|(Flags::enum_type f1, Flags::enum_type f2); \ +friend Q_DECL_CONSTEXPR QFlags<Flags::enum_type> operator|(Flags::enum_type f1, QFlags<Flags::enum_type> f2); \ +Q_DECLARE_FRIEND_INCOMPATIBLE_FLAGS(Flags) + +#endif // OS_MAC_OLD + // using for_const instead of plain range-based for loop to ensure usage of const_iterator // it is important for the copy-on-write Qt containers // if you have "QVector<T*> v" then "for (T * const p : v)" will still call QVector::detach(), @@ -219,7 +233,11 @@ public: } constexpr char operator[](std::size_t n) const { return (n < _size) ? _str[n] : +#ifndef OS_MAC_OLD throw std::out_of_range(""); +#else // OS_MAC_OLD + throw std::exception(); +#endif // OS_MAC_OLD } constexpr std::size_t size() const { return _size; } const char *c_str() const { return _str; } @@ -257,6 +275,11 @@ typedef double float64; using std::string; using std::exception; +#ifdef OS_MAC_OLD +namespace std { +using nullptr_t = decltype(nullptr); +} +#endif // OS_MAC_OLD // we copy some parts of C++11/14/17 std:: library, because on OS X 10.6+ // version we can use C++11/14/17, but we can not use its library :( @@ -873,7 +896,7 @@ public: template <typename... Args> void makeIfNull(Args&&... args) { if (isNull()) { - reset(new T(std::forward<Args>(args)...)); + reset(new T(std_::forward<Args>(args)...)); } }; diff --git a/Telegram/SourceFiles/core/qthelp_regex.h b/Telegram/SourceFiles/core/qthelp_regex.h index 6ecd20a4f8..899e88b173 100644 --- a/Telegram/SourceFiles/core/qthelp_regex.h +++ b/Telegram/SourceFiles/core/qthelp_regex.h @@ -52,8 +52,10 @@ enum class RegExOption { InvertedGreediness = QRegularExpression::InvertedGreedinessOption, DontCapture = QRegularExpression::DontCaptureOption, UseUnicodeProperties = QRegularExpression::UseUnicodePropertiesOption, +#ifndef OS_MAC_OLD OptimizeOnFirstUsage = QRegularExpression::OptimizeOnFirstUsageOption, DontAutomaticallyOptimize = QRegularExpression::DontAutomaticallyOptimizeOption, +#endif // OS_MAC_OLD }; Q_DECLARE_FLAGS(RegExOptions, RegExOption); Q_DECLARE_OPERATORS_FOR_FLAGS(RegExOptions); @@ -65,7 +67,11 @@ inline RegularExpressionMatch regex_match(const QString &string, const QString & inline RegularExpressionMatch regex_match(const QString &string, const QStringRef &subjectRef, RegExOptions options = 0) { auto qtOptions = QRegularExpression::PatternOptions(static_cast<int>(options)); +#ifndef OS_MAC_OLD return RegularExpressionMatch(QRegularExpression(string, qtOptions).match(subjectRef)); +#else // OS_MAC_OLD + return RegularExpressionMatch(QRegularExpression(string, qtOptions).match(subjectRef.toString())); +#endif // OS_MAC_OLD } } // namespace qthelp diff --git a/Telegram/SourceFiles/core/vector_of_moveable.h b/Telegram/SourceFiles/core/vector_of_moveable.h index 608bb07965..198a752ee8 100644 --- a/Telegram/SourceFiles/core/vector_of_moveable.h +++ b/Telegram/SourceFiles/core/vector_of_moveable.h @@ -128,7 +128,11 @@ public: } inline const T &at(int index) const { if (index < 0 || index >= _size) { +#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0) + throw std::exception(); +#else // QT_VERSION < 5.5.0 throw std::out_of_range(""); +#endif // QT_VERSION < 5.5.0 } return data()[index]; } diff --git a/Telegram/SourceFiles/history.cpp b/Telegram/SourceFiles/history.cpp index fe109c6558..a193c4f79e 100644 --- a/Telegram/SourceFiles/history.cpp +++ b/Telegram/SourceFiles/history.cpp @@ -6028,9 +6028,9 @@ void LocationManager::onFinished(QNetworkReply *reply) { { QBuffer buffer(&data); QImageReader reader(&buffer); -#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) +#ifndef OS_MAC_OLD reader.setAutoTransform(true); -#endif +#endif // OS_MAC_OLD thumb = QPixmap::fromImageReader(&reader, Qt::ColorOnly); format = reader.format(); thumb.setDevicePixelRatio(cRetinaFactor()); diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index a5624d7572..95dd87bd3f 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -47,6 +47,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "window/top_bar_widget.h" #include "observer_peer.h" #include "playerwidget.h" +#include "core/qthelp_regex.h" namespace { @@ -2971,9 +2972,8 @@ EntitiesInText entitiesFromTextTags(const FlatTextarea::TagList &tags) { auto mentionStart = qstr("mention://user."); for_const (auto &tag, tags) { if (tag.id.startsWith(mentionStart)) { - auto match = QRegularExpression("^(\\d+\\.\\d+)(/|$)").match(tag.id.midRef(mentionStart.size())); - if (match.hasMatch()) { - result.push_back(EntityInText(EntityInTextMentionName, tag.offset, tag.length, match.captured(1))); + if (auto match = qthelp::regex_match("^(\\d+\\.\\d+)(/|$)", tag.id.midRef(mentionStart.size()))) { + result.push_back(EntityInText(EntityInTextMentionName, tag.offset, tag.length, match->captured(1))); } } } @@ -8111,7 +8111,12 @@ void HistoryWidget::updatePreview() { updateMouseTracking(); if (_previewData->pendingTill) { _previewTitle.setText(st::msgServiceNameFont, lang(lng_preview_loading), _textNameOptions); - _previewDescription.setText(st::msgFont, textClean(_previewLinks.splitRef(' ').at(0).toString()), _textDlgOptions); +#ifndef OS_MAC_OLD + auto linkText = _previewLinks.splitRef(' ').at(0).toString(); +#else // OS_MAC_OLD + auto linkText = _previewLinks.split(' ').at(0); +#endif // OS_MAC_OLD + _previewDescription.setText(st::msgFont, textClean(linkText), _textDlgOptions); int32 t = (_previewData->pendingTill - unixtime()) * 1000; if (t <= 0) t = 1; diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.cpp b/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.cpp index af11f174f9..af03a20f04 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.cpp @@ -173,9 +173,13 @@ ClickHandlerPtr ItemBase::getResultContentUrlHandler() const { } QString ItemBase::getResultThumbLetter() const { - QVector<QStringRef> parts = _result->_url.splitRef('/'); +#ifndef OS_MAC_OLD + auto parts = _result->_url.splitRef('/'); +#else // OS_MAC_OLD + auto parts = _result->_url.split('/'); +#endif // OS_MAC_OLD if (!parts.isEmpty()) { - QStringRef domain = parts.at(0); + auto domain = parts.at(0); if (parts.size() > 2 && domain.endsWith(':') && parts.at(1).isEmpty()) { // http:// and others domain = parts.at(2); } diff --git a/Telegram/SourceFiles/localstorage.cpp b/Telegram/SourceFiles/localstorage.cpp index f8d4a1786f..87b069fec4 100644 --- a/Telegram/SourceFiles/localstorage.cpp +++ b/Telegram/SourceFiles/localstorage.cpp @@ -3621,9 +3621,9 @@ namespace Local { QImage img; QBuffer buf(&pngData); QImageReader reader(&buf); -#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) +#ifndef OS_MAC_OLD reader.setAutoTransform(true); -#endif +#endif // OS_MAC_OLD if (reader.read(&img)) { App::initBackground(id, img, true); return true; diff --git a/Telegram/SourceFiles/media/media_audio.cpp b/Telegram/SourceFiles/media/media_audio.cpp index f16d9de2aa..8a3854e08d 100644 --- a/Telegram/SourceFiles/media/media_audio.cpp +++ b/Telegram/SourceFiles/media/media_audio.cpp @@ -31,6 +31,8 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #define AL_ALEXT_PROTOTYPES #include <AL/alext.h> +#include <numeric> + extern "C" { #ifdef Q_OS_MAC #include <iconv.h> diff --git a/Telegram/SourceFiles/media/media_clip_qtgif.cpp b/Telegram/SourceFiles/media/media_clip_qtgif.cpp index b5209d0ccb..6ab82b1e26 100644 --- a/Telegram/SourceFiles/media/media_clip_qtgif.cpp +++ b/Telegram/SourceFiles/media/media_clip_qtgif.cpp @@ -118,9 +118,9 @@ bool QtGifReaderImplementation::jumpToStart() { delete _reader; initDevice(); _reader = new QImageReader(_device); -#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) +#ifndef OS_MAC_OLD _reader->setAutoTransform(true); -#endif +#endif // OS_MAC_OLD if (!_reader->canRead() || !_reader->supportsAnimation()) { return false; } diff --git a/Telegram/SourceFiles/overview/overview_layout.cpp b/Telegram/SourceFiles/overview/overview_layout.cpp index 242d7a4737..752546ac0e 100644 --- a/Telegram/SourceFiles/overview/overview_layout.cpp +++ b/Telegram/SourceFiles/overview/overview_layout.cpp @@ -984,9 +984,14 @@ Link::Link(HistoryMedia *media, HistoryItem *parent) : ItemBase(parent) { if (_page) { _title = _page->title; } - QVector<QStringRef> parts = mainUrl.splitRef('/'); + +#ifndef OS_MAC_OLD + auto parts = mainUrl.splitRef('/'); +#else // OS_MAC_OLD + auto parts = mainUrl.split('/'); +#endif // OS_MAC_OLD if (!parts.isEmpty()) { - QStringRef domain = parts.at(0); + auto domain = parts.at(0); if (parts.size() > 2 && domain.endsWith(':') && parts.at(1).isEmpty()) { // http:// and others domain = parts.at(2); } diff --git a/Telegram/SourceFiles/settings.cpp b/Telegram/SourceFiles/settings.cpp index f24dcbb361..89e3de7852 100644 --- a/Telegram/SourceFiles/settings.cpp +++ b/Telegram/SourceFiles/settings.cpp @@ -160,12 +160,14 @@ bool gAutoPlayGif = true; void settingsParseArgs(int argc, char *argv[]) { #ifdef Q_OS_MAC +#ifndef OS_MAC_OLD if (QSysInfo::macVersion() >= QSysInfo::MV_10_11) { gIsElCapitan = true; - } else if (QSysInfo::macVersion() < QSysInfo::MV_10_8) { - gPlatform = dbipMacOld; } -#endif +#else // OS_MAC_OLD + gPlatform = dbipMacOld; +#endif // OS_MAC_OLD +#endif // Q_OS_MAC switch (cPlatform()) { case dbipWindows: diff --git a/Telegram/SourceFiles/shortcuts.cpp b/Telegram/SourceFiles/shortcuts.cpp index 9f782ea35e..37d4554c52 100644 --- a/Telegram/SourceFiles/shortcuts.cpp +++ b/Telegram/SourceFiles/shortcuts.cpp @@ -253,6 +253,22 @@ struct DataStruct { t_assert(DataPtr == nullptr); DataPtr = this; + if (autoRepeatCommands.isEmpty()) { + autoRepeatCommands.insert(qsl("media_previous")); + autoRepeatCommands.insert(qsl("media_next")); + autoRepeatCommands.insert(qsl("next_chat")); + autoRepeatCommands.insert(qsl("previous_chat")); + } + + if (mediaCommands.isEmpty()) { + mediaCommands.insert(qsl("media_play")); + mediaCommands.insert(qsl("media_playpause")); + mediaCommands.insert(qsl("media_play")); + mediaCommands.insert(qsl("media_stop")); + mediaCommands.insert(qsl("media_previous")); + mediaCommands.insert(qsl("media_next")); + } + #define DeclareAlias(keys, command) setShortcut(qsl(keys), qsl(#command)) #define DeclareCommand(keys, command) createCommand(qsl(#command), ShortcutCommands::command); DeclareAlias(keys, command) @@ -305,22 +321,9 @@ struct DataStruct { QMap<int, ShortcutCommands::Handler> handlers; QSet<QShortcut*> mediaShortcuts; + QSet<QString> autoRepeatCommands; + QSet<QString> mediaCommands; - QSet<QString> autoRepeatCommands = { - qsl("media_previous"), - qsl("media_next"), - qsl("next_chat"), - qsl("previous_chat"), - }; - - QSet<QString> mediaCommands = { - qsl("media_play"), - qsl("media_pause"), - qsl("media_playpause"), - qsl("media_stop"), - qsl("media_previous"), - qsl("media_next") - }; }; namespace { diff --git a/Telegram/SourceFiles/stdafx.h b/Telegram/SourceFiles/stdafx.h index 51bf3598e9..f366d554ca 100644 --- a/Telegram/SourceFiles/stdafx.h +++ b/Telegram/SourceFiles/stdafx.h @@ -45,6 +45,9 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #pragma clang diagnostic pop #endif // __clang__ +#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0) +#define OS_MAC_OLD +#endif // QT_VERSION < 5.5.0 #include <QtWidgets/QtWidgets> #include <QtNetwork/QtNetwork> diff --git a/Telegram/SourceFiles/structs.cpp b/Telegram/SourceFiles/structs.cpp index b971ddd3eb..331017b81e 100644 --- a/Telegram/SourceFiles/structs.cpp +++ b/Telegram/SourceFiles/structs.cpp @@ -798,6 +798,22 @@ void PhotoCancelClickHandler::onClickImpl() const { } } +QString joinList(const QStringList &list, const QString &sep) { + QString result; + if (list.isEmpty()) return result; + + int32 l = list.size(), s = sep.size() * (l - 1); + for (int32 i = 0; i < l; ++i) { + s += list.at(i).size(); + } + result.reserve(s); + result.append(list.at(0)); + for (int32 i = 1; i < l; ++i) { + result.append(sep).append(list.at(i)); + } + return result; +} + QString saveFileName(const QString &title, const QString &filter, const QString &prefix, QString name, bool savingAs, const QDir &dir) { #ifdef Q_OS_WIN name = name.replace(QRegularExpression(qsl("[\\\\\\/\\:\\*\\?\\\"\\<\\>\\|]")), qsl("_")); @@ -832,9 +848,9 @@ QString saveFileName(const QString &title, const QString &filter, const QString QRegularExpressionMatch m = QRegularExpression(qsl(" \\*\\.") + ext + qsl("[\\)\\s]"), QRegularExpression::CaseInsensitiveOption).match(first); if (m.hasMatch() && m.capturedStart() > start + 3) { int32 oldpos = m.capturedStart(), oldend = m.capturedEnd(); - fil = first.mid(0, start + 3) + ext + qsl(" *.") + first.mid(start + 3, oldpos - start - 3) + first.mid(oldend - 1) + sep + filters.mid(1).join(sep); + fil = first.mid(0, start + 3) + ext + qsl(" *.") + first.mid(start + 3, oldpos - start - 3) + first.mid(oldend - 1) + sep + joinList(filters.mid(1), sep); } else { - fil = first.mid(0, start + 3) + ext + qsl(" *.") + first.mid(start + 3) + sep + filters.mid(1).join(sep); + fil = first.mid(0, start + 3) + ext + qsl(" *.") + first.mid(start + 3) + sep + joinList(filters.mid(1), sep); } } } else { diff --git a/Telegram/SourceFiles/structs.h b/Telegram/SourceFiles/structs.h index 2a88d23c87..3fc4cec2ef 100644 --- a/Telegram/SourceFiles/structs.h +++ b/Telegram/SourceFiles/structs.h @@ -1417,7 +1417,13 @@ inline bool operator<(const LocationCoords &a, const LocationCoords &b) { return (a.lat < b.lat) || ((a.lat == b.lat) && (a.lon < b.lon)); } inline uint qHash(const LocationCoords &t, uint seed = 0) { +#ifndef OS_MAC_OLD return qHash(QtPrivate::QHashCombine().operator()(qHash(t.lat), t.lon), seed); +#else // OS_MAC_OLD + uint h1 = qHash(t.lat, seed); + uint h2 = qHash(t.lon, seed); + return ((h1 << 16) | (h1 >> 16)) ^ h2 ^ seed; +#endif // OS_MAC_OLD } struct LocationData { diff --git a/Telegram/SourceFiles/ui/images.cpp b/Telegram/SourceFiles/ui/images.cpp index a9aa79389a..25e9199593 100644 --- a/Telegram/SourceFiles/ui/images.cpp +++ b/Telegram/SourceFiles/ui/images.cpp @@ -644,9 +644,9 @@ void Image::restore() const { QBuffer buffer(&_saved); QImageReader reader(&buffer, _format); -#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) +#ifndef OS_MAC_OLD reader.setAutoTransform(true); -#endif +#endif // OS_MAC_OLD _data = QPixmap::fromImageReader(&reader, Qt::ColorOnly); if (!_data.isNull()) { diff --git a/Telegram/SourceFiles/ui/style/style_core.cpp b/Telegram/SourceFiles/ui/style/style_core.cpp index 3d490d63a3..d56b9714cd 100644 --- a/Telegram/SourceFiles/ui/style/style_core.cpp +++ b/Telegram/SourceFiles/ui/style/style_core.cpp @@ -106,7 +106,11 @@ namespace internal { QImage createCircleMask(int size, const QColor &bg, const QColor &fg) { int realSize = size * cIntRetinaFactor(); +#ifndef OS_MAC_OLD auto result = QImage(realSize, realSize, QImage::Format::Format_Grayscale8); +#else // OS_MAC_OLD + auto result = QImage(realSize, realSize, QImage::Format::Format_RGB32); +#endif // OS_MAC_OLD { QPainter pcircle(&result); pcircle.setRenderHint(QPainter::HighQualityAntialiasing, true); diff --git a/Telegram/SourceFiles/ui/twidget.cpp b/Telegram/SourceFiles/ui/twidget.cpp index 54af7cc611..8a676aabc3 100644 --- a/Telegram/SourceFiles/ui/twidget.cpp +++ b/Telegram/SourceFiles/ui/twidget.cpp @@ -123,7 +123,17 @@ void ToggleableShadow::paintEvent(QPaintEvent *e) { void sendSynteticMouseEvent(QWidget *widget, QEvent::Type type, Qt::MouseButton button, const QPoint &globalPoint) { auto windowHandle = widget->window()->windowHandle(); auto localPoint = windowHandle->mapFromGlobal(globalPoint); - QMouseEvent ev(type, localPoint, localPoint, globalPoint, button, QGuiApplication::mouseButtons() | button, QGuiApplication::keyboardModifiers(), Qt::MouseEventSynthesizedByApplication); + QMouseEvent ev(type + , localPoint + , localPoint + , globalPoint + , button + , QGuiApplication::mouseButtons() | button + , QGuiApplication::keyboardModifiers() +#ifndef OS_MAC_OLD + , Qt::MouseEventSynthesizedByApplication +#endif // OS_MAC_OLD + ); ev.setTimestamp(getms()); QGuiApplication::sendEvent(windowHandle, &ev); } diff --git a/Telegram/gyp/Telegram.gyp b/Telegram/gyp/Telegram.gyp index ff7d296bd7..3be6f5f329 100644 --- a/Telegram/gyp/Telegram.gyp +++ b/Telegram/gyp/Telegram.gyp @@ -48,7 +48,6 @@ 'ko', 'pt-BR', ], - 'mac_target': '10.8', }, 'includes': [ 'common_executable.gypi', @@ -75,8 +74,6 @@ '<(src_loc)', '<(SHARED_INTERMEDIATE_DIR)', '<(libs_loc)/breakpad/src', - '<(libs_loc)/crashpad/crashpad', - '<(libs_loc)/crashpad/crashpad/third_party/mini_chromium/mini_chromium', '<(libs_loc)/lzma/C', '<(libs_loc)/libexif-0.6.20', '<(libs_loc)/zlib-1.2.8', @@ -84,9 +81,6 @@ '<(libs_loc)/openal-soft/include', '<(minizip_loc)', ], - 'library_dirs': [ - '<(libs_loc)/ffmpeg', - ], 'sources': [ '<@(qrc_files)', '<@(style_files)', diff --git a/Telegram/gyp/common.gypi b/Telegram/gyp/common.gypi index b7d1c3d929..d012514924 100644 --- a/Telegram/gyp/common.gypi +++ b/Telegram/gyp/common.gypi @@ -65,7 +65,6 @@ 'build_mac%': '<(build_mac)', 'build_linux%': '<(build_linux)', 'official_build_target%': '<(official_build_target)', - 'mac_target%': '10.8', # GYP does not support per-configuration libraries :( # So they will be emulated through additional link flags, @@ -82,10 +81,10 @@ }], [ '"<(official_build_target)" == "mac32"', { 'mac_target%': '10.6', - 'build_mac32': 1, + 'build_macold': 1, }, { 'mac_target%': '10.8', - 'build_mac32': 0, + 'build_macold': 0, }] ], 'ld_lib_prefix': '<(ld_lib_prefix)', diff --git a/Telegram/gyp/qt.gypi b/Telegram/gyp/qt.gypi index d3ae26b1bd..35175128b6 100644 --- a/Telegram/gyp/qt.gypi +++ b/Telegram/gyp/qt.gypi @@ -24,9 +24,7 @@ 'variables': { 'qt_libs': [ 'Qt5Core', - 'qtpcre', 'Qt5Gui', - 'qtfreetype', 'Qt5Widgets', 'qtharfbuzzng', 'Qt5Network', @@ -34,8 +32,15 @@ 'Qt5PrintSupport', 'qwebp', ], + 'conditions': [ + [ 'build_macold', { + 'qt_version%': '5.3.2', + }, { + 'qt_version%': '5.6.0', + }] + ], }, - 'qt_version%': '5.6.0', + 'qt_version%': '<(qt_version)', 'conditions': [ [ 'build_win', { 'qt_lib_prefix': '<(ld_lib_prefix)', @@ -57,9 +62,20 @@ 'qcocoa', ], }], + [ 'build_macold', { + 'qt_loc_unix': '/usr/local/Qt-<(qt_version)' + }, { + 'qt_loc_unix': '/usr/local/tdesktop/Qt-<(qt_version)', + 'qt_libs': [ + '<@(qt_libs)', + 'qtfreetype', + 'qtpcre', + ], + }] ], }, 'qt_version%': '<(qt_version)', + 'qt_loc_unix': '<(qt_loc_unix)', 'qt_version_loc': '<!(python -c "print(\'<(qt_version)\'.replace(\'.\', \'_\'))")', 'qt_libs_debug': [ '<!@(python -c "for s in \'<@(qt_libs)\'.split(\' \'): print(\'<(qt_lib_prefix)\' + s + \'<(qt_lib_debug_postfix)\')")', @@ -75,7 +91,7 @@ [ 'build_win', { 'qt_loc': '../../../Libraries/qt<(qt_version_loc)/qtbase', }, { - 'qt_loc': '/usr/local/tdesktop/Qt-<(qt_version)', + 'qt_loc': '<(qt_loc_unix)', }], ], }, diff --git a/Telegram/gyp/settings_mac.gypi b/Telegram/gyp/settings_mac.gypi index 5ecad28182..649f2011c9 100644 --- a/Telegram/gyp/settings_mac.gypi +++ b/Telegram/gyp/settings_mac.gypi @@ -28,8 +28,6 @@ 'CoreText', 'CoreGraphics', 'OpenGL', - 'VideoToolbox', - 'VideoDecodeAcceleration', 'AudioUnit', 'ApplicationServices', 'Foundation', @@ -40,8 +38,6 @@ 'AudioToolbox', 'CoreAudio', 'QuartzCore', - 'AVFoundation', - 'CoreMedia', 'AppKit', 'CoreWLAN', 'IOKit', @@ -69,14 +65,40 @@ '<@(mac_common_flags)', ], 'OTHER_LDFLAGS': [ - '-stdlib=libc++', '<!@(python -c "for s in \'<@(mac_frameworks)\'.split(\' \'): print(\'-framework \' + s)")', ], 'MACOSX_DEPLOYMENT_TARGET': '<(mac_target)', 'COMBINE_HIDPI_IMAGES': 'YES', 'COPY_PHASE_STRIP': 'NO', 'CLANG_CXX_LANGUAGE_STANDARD': 'c++14', + }, + 'configurations': { + 'Debug': { + 'xcode_settings': { + 'ENABLE_TESTABILITY': 'YES', + 'ONLY_ACTIVE_ARCH': 'YES', + }, + }, + }, + }], + [ 'build_macold', { + 'xcode_settings': { + 'OTHER_CFLAGS': [ + '-Wno-inconsistent-missing-override', + ], + 'OTHER_CPLUSPLUSFLAGS': [ + '-Wno-inconsistent-missing-override', + ], + }, + }, { + 'xcode_settings': { 'CLANG_CXX_LIBRARY': 'libc++', + 'OTHER_LDFLAGS': [ + '-framework VideoToolbox', + '-framework VideoDecodeAcceleration', + '-framework AVFoundation', + '-framework CoreMedia', + ], }, }], ], diff --git a/Telegram/gyp/telegram_mac.gypi b/Telegram/gyp/telegram_mac.gypi index 71d46d80b2..c282d997c3 100644 --- a/Telegram/gyp/telegram_mac.gypi +++ b/Telegram/gyp/telegram_mac.gypi @@ -32,15 +32,8 @@ '-lssl', '-lcrypto', '/usr/local/lib/liblzma.a', - '/usr/local/lib/libopenal.a', '/usr/local/lib/libopus.a', '/usr/local/lib/libexif.a', - '-lavcodec', - '-lavformat', - '-lswscale', - '-lswresample', - '-lavutil', - '/usr/local/lib/libiconv.a', '-lbase', '-lcrashpad_client', '-lcrashpad_util', @@ -57,17 +50,11 @@ ], 'configurations': { 'Debug': { - 'library_dirs': [ - '<(libs_loc)/crashpad/crashpad/out/Debug', - ], 'xcode_settings': { 'GCC_OPTIMIZATION_LEVEL': '0', }, }, 'Release': { - 'library_dirs': [ - '<(libs_loc)/crashpad/crashpad/out/Release', - ], 'xcode_settings': { 'DEBUG_INFORMATION_FORMAT': 'dwarf-with-dsym', 'LLVM_LTO': 'YES', @@ -97,7 +84,80 @@ 'action': [ 'mkdir', '-p', '${BUILT_PRODUCTS_DIR}/Telegram.app/Contents/Helpers/' ], - }, { + }], + }], [ 'build_macold', { + 'xcode_settings': { + 'OTHER_LDFLAGS': [ + '/usr/local/openal_old/lib/libopenal.a', + '/usr/local/zlib_old/lib/libz.a', + '/usr/local/iconv_old/lib/libiconv.a', + '/usr/local/ffmpeg_old/lib/libavcodec.a', + '/usr/local/ffmpeg_old/lib/libavformat.a', + '/usr/local/ffmpeg_old/lib/libavutil.a', + '/usr/local/ffmpeg_old/lib/libswscale.a', + '/usr/local/ffmpeg_old/lib/libswresample.a', + ], + }, + 'include_dirs': [ + '<(libs_loc)/crashpad_oldmac/crashpad', + '<(libs_loc)/crashpad_oldmac/crashpad/third_party/mini_chromium/mini_chromium', + ], + 'library_dirs': [ + '/usr/local/ffmpeg_old', + ], + 'configurations': { + 'Debug': { + 'library_dirs': [ + '<(libs_loc)/crashpad_oldmac/crashpad/out/Debug', + ], + }, + 'Release': { + 'library_dirs': [ + '<(libs_loc)/crashpad_oldmac/crashpad/out/Release', + ], + }, + }, + 'postbuilds': [{ + 'postbuild_name': 'Copy crashpad_client to Helpers', + 'action': [ + 'cp', + '<(libs_loc)/crashpad_oldmac/crashpad/out/${CONFIGURATION}/crashpad_handler', + '${BUILT_PRODUCTS_DIR}/Telegram.app/Contents/Helpers/', + ], + }], + }, { + 'xcode_settings': { + 'OTHER_LDFLAGS': [ + '/usr/local/lib/libz.a', + '/usr/local/lib/libopenal.a', + '/usr/local/lib/libiconv.a', + '/usr/local/lib/libavcodec.a', + '/usr/local/lib/libavformat.a', + '/usr/local/lib/libavutil.a', + '/usr/local/lib/libswscale.a', + '/usr/local/lib/libswresample.a', + ], + }, + 'include_dirs': [ + '<(libs_loc)/crashpad/crashpad', + '<(libs_loc)/crashpad/crashpad/third_party/mini_chromium/mini_chromium', + ], + 'library_dirs': [ + '/usr/local/ffmpeg', + ], + 'configurations': { + 'Debug': { + 'library_dirs': [ + '<(libs_loc)/crashpad/crashpad/out/Debug', + ], + }, + 'Release': { + 'library_dirs': [ + '<(libs_loc)/crashpad/crashpad/out/Release', + ], + }, + }, + 'postbuilds': [{ 'postbuild_name': 'Copy crashpad_client to Helpers', 'action': [ 'cp', diff --git a/Telegram/gyp/telegram_win.gypi b/Telegram/gyp/telegram_win.gypi index 3122e624bb..1973d650c0 100644 --- a/Telegram/gyp/telegram_win.gypi +++ b/Telegram/gyp/telegram_win.gypi @@ -25,6 +25,9 @@ 'sources': [ '<(res_loc)/winrc/Telegram.rc', ], + 'library_dirs': [ + '<(libs_loc)/ffmpeg', + ], 'libraries': [ 'libeay32', 'ssleay32',