Closed beta 1001007001: Fix build in Xcode.

This commit is contained in:
John Preston 2017-06-06 13:40:15 +03:00
parent 5d0e89db5d
commit 7dd50fa931
5 changed files with 25 additions and 29 deletions

View File

@ -78,14 +78,14 @@ QString PrepareCommandString(int index) {
} // namespace } // namespace
const std::array<QString, kPluralPartCount> kPluralParts = { const std::array<QString, kPluralPartCount> kPluralParts = { {
"zero", "zero",
"one", "one",
"two", "two",
"few", "few",
"many", "many",
"other", "other",
}; } };
const QString kPluralTag = "count"; const QString kPluralTag = "count";

View File

@ -181,7 +181,7 @@ QByteArray FileParser::ReadFile(const QString &absolutePath, const QString &rela
QByteArray data; QByteArray data;
int skip = 0; int skip = 0;
auto readUtf16Stream = [relativePath, absolutePath](auto &stream) { auto readUtf16Stream = [relativePath, absolutePath](auto &&stream) {
stream.setCodec("UTF-16"); stream.setCodec("UTF-16");
auto string = stream.readAll(); auto string = stream.readAll();
if (stream.status() != QTextStream::Ok) { if (stream.status() != QTextStream::Ok) {

View File

@ -26,9 +26,16 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "passcodewidget.h" #include "passcodewidget.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "history/history_location_manager.h" #include "history/history_location_manager.h"
#include "platform/mac/mac_utilities.h"
#include <execinfo.h> #include <execinfo.h>
#include <Cocoa/Cocoa.h>
#include <CoreFoundation/CFURL.h>
#include <IOKit/IOKitLib.h>
#include <IOKit/hidsystem/ev_keymap.h>
#include <SPMediaKeyTap.h>
namespace { namespace {
QStringList _initLogs; QStringList _initLogs;
@ -395,12 +402,24 @@ void StartTranslucentPaint(QPainter &p, QPaintEvent *e) {
} }
QString SystemCountry() { QString SystemCountry() {
QString country = objc_currentCountry(); NSLocale *currentLocale = [NSLocale currentLocale]; // get the current locale.
return country.isEmpty() ? QString::fromLatin1(DefaultCountry) : country; NSString *countryCode = [currentLocale objectForKey:NSLocaleCountryCode];
return countryCode ? NS2QString(countryCode) : QString();
} }
QString SystemLanguage() { QString SystemLanguage() {
return objc_currentLang(); if (auto currentLocale = [NSLocale currentLocale]) { // get the current locale.
if (NSString *collator = [currentLocale objectForKey:NSLocaleCollatorIdentifier]) {
return NS2QString(collator);
}
if (NSString *identifier = [currentLocale objectForKey:NSLocaleIdentifier]) {
return NS2QString(identifier);
}
if (NSString *language = [currentLocale objectForKey:NSLocaleLanguageCode]) {
return NS2QString(language);
}
}
return QString();
} }
} // namespace Platform } // namespace Platform

View File

@ -46,8 +46,6 @@ double objc_appkitVersion();
QString objc_documentsPath(); QString objc_documentsPath();
QString objc_appDataPath(); QString objc_appDataPath();
QString objc_downloadPath(); QString objc_downloadPath();
QString objc_currentCountry();
QString objc_currentLang();
QByteArray objc_downloadPathBookmark(const QString &path); QByteArray objc_downloadPathBookmark(const QString &path);
QByteArray objc_pathBookmark(const QString &path); QByteArray objc_pathBookmark(const QString &path);
void objc_downloadPathEnableAccess(const QByteArray &bookmark); void objc_downloadPathEnableAccess(const QByteArray &bookmark);

View File

@ -542,27 +542,6 @@ QString objc_downloadPath() {
return QString(); return QString();
} }
QString objc_currentCountry() {
NSLocale *currentLocale = [NSLocale currentLocale]; // get the current locale.
NSString *countryCode = [currentLocale objectForKey:NSLocaleCountryCode];
return countryCode ? NS2QString(countryCode) : QString();
}
QString objc_currentLang() {
if (auto currentLocale = [NSLocale currentLocale]) { // get the current locale.
if (NSString *collator = [currentLocale objectForKey:NSLocaleCollatorIdentifier]) {
return NS2QString(collator);
}
if (NSString *identifier = [currentLocale objectForKey:NSLocaleIdentifier]) {
return NS2QString(identifier);
}
if (NSString *language = [currentLocale objectForKey:NSLocaleLanguageCode]) {
return NS2QString(language);
}
}
return QString();
}
QByteArray objc_downloadPathBookmark(const QString &path) { QByteArray objc_downloadPathBookmark(const QString &path) {
#ifndef OS_MAC_STORE #ifndef OS_MAC_STORE
return QByteArray(); return QByteArray();