Merge branch 'dev' into mentions

Conflicts:
	Telegram/SourceFiles/core/basic_types.h
This commit is contained in:
John Preston 2016-05-04 13:45:23 +03:00
commit 5300962ef3
10 changed files with 28 additions and 38 deletions

View File

@ -23,11 +23,11 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "core/version.h"
#include "settings.h"
static const wchar_t *AppNameOld = L"Telegram Win (Unofficial)";
static const wchar_t *AppName = L"Telegram Desktop";
constexpr str_const AppNameOld = "Telegram Win (Unofficial)";
constexpr str_const AppName = "Telegram Desktop";
static const wchar_t *AppId = L"{53F49750-6209-4FBF-9CA8-7A333C87D1ED}"; // used in updater.cpp and Setup.iss for Windows
static const wchar_t *AppFile = L"Telegram";
constexpr str_const AppId = "{53F49750-6209-4FBF-9CA8-7A333C87D1ED}"; // used in updater.cpp and Setup.iss for Windows
constexpr str_const AppFile = "Telegram";
enum {
MTPShortBufferSize = 65535, // of ints, 256 kb

View File

@ -213,11 +213,7 @@ private:
};
inline QString str_const_latin1_toString(const str_const &str) {
return QString::fromLatin1(str.c_str(), str.size());
}
inline QString str_const_utf8_toString(const str_const &str) {
inline QString str_const_toString(const str_const &str) {
return QString::fromUtf8(str.c_str(), str.size());
}

View File

@ -24,7 +24,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#define BETA_VERSION_MACRO (0ULL)
static constexpr int AppVersion = 9047;
static constexpr str_const AppVersionStr = "0.9.47";
static constexpr bool AppAlphaVersion = true;
static constexpr uint64 AppBetaVersion = BETA_VERSION_MACRO;
constexpr int AppVersion = 9047;
constexpr str_const AppVersionStr = "0.9.47";
constexpr bool AppAlphaVersion = true;
constexpr uint64 AppBetaVersion = BETA_VERSION_MACRO;

View File

@ -1110,7 +1110,7 @@ bool MainWindow::minimizeToTray() {
hide();
if (cPlatform() == dbipWindows && trayIcon && !cSeenTrayTooltip()) {
trayIcon->showMessage(QString::fromStdWString(AppName), lang(lng_tray_icon_text), QSystemTrayIcon::Information, 10000);
trayIcon->showMessage(str_const_toString(AppName), lang(lng_tray_icon_text), QSystemTrayIcon::Information, 10000);
cSetSeenTrayTooltip(true);
Local::writeSettings();
}

View File

@ -563,7 +563,7 @@ void PsMainWindow::psSetupTrayIcon() {
QIcon icon(QPixmap::fromImage(App::wnd()->iconLarge(), Qt::ColorOnly));
trayIcon->setIcon(icon);
trayIcon->setToolTip(QString::fromStdWString(AppName));
trayIcon->setToolTip(str_const_toString(AppName));
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(toggleTray(QSystemTrayIcon::ActivationReason)), Qt::UniqueConnection);
connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(showFromTray()));
App::wnd()->updateTrayMenu();
@ -1171,7 +1171,7 @@ QString psAppDataPath() {
}
QString psDownloadPath() {
return QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + '/' + QString::fromWCharArray(AppName) + '/';
return QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + '/' + str_const_toString(AppName) + '/';
}
QString psCurrentExeDirectory(int argc, char *argv[]) {

View File

@ -122,7 +122,7 @@ void PsMainWindow::psSetupTrayIcon() {
icon.addPixmap(QPixmap::fromImage(psTrayIcon(true), Qt::ColorOnly), QIcon::Selected);
trayIcon->setIcon(icon);
trayIcon->setToolTip(QString::fromStdWString(AppName));
trayIcon->setToolTip(str_const_toString(AppName));
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(toggleTray(QSystemTrayIcon::ActivationReason)), Qt::UniqueConnection);
App::wnd()->updateTrayMenu();
}

View File

@ -1041,7 +1041,7 @@ double objc_appkitVersion() {
QString objc_appDataPath() {
NSURL *url = [[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:nil];
if (url) {
return QString::fromUtf8([[url path] fileSystemRepresentation]) + '/' + QString::fromWCharArray(AppName) + '/';
return QString::fromUtf8([[url path] fileSystemRepresentation]) + '/' + str_const_toString(AppName) + '/';
}
return QString();
}
@ -1049,7 +1049,7 @@ QString objc_appDataPath() {
QString objc_downloadPath() {
NSURL *url = [[NSFileManager defaultManager] URLForDirectory:NSDownloadsDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:nil];
if (url) {
return QString::fromUtf8([[url path] fileSystemRepresentation]) + '/' + QString::fromWCharArray(AppName) + '/';
return QString::fromUtf8([[url path] fileSystemRepresentation]) + '/' + str_const_toString(AppName) + '/';
}
return QString();
}

View File

@ -1074,7 +1074,7 @@ void PsMainWindow::psSetupTrayIcon() {
QIcon icon(QPixmap::fromImage(App::wnd()->iconLarge(), Qt::ColorOnly));
trayIcon->setIcon(icon);
trayIcon->setToolTip(QString::fromStdWString(AppName));
trayIcon->setToolTip(str_const_toString(AppName));
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(toggleTray(QSystemTrayIcon::ActivationReason)), Qt::UniqueConnection);
connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(showFromTray()));
App::wnd()->updateTrayMenu();
@ -1828,7 +1828,7 @@ QString psAppDataPath() {
WCHAR wstrPath[maxFileLen];
if (GetEnvironmentVariable(L"APPDATA", wstrPath, maxFileLen)) {
QDir appData(QString::fromStdWString(std::wstring(wstrPath)));
return appData.absolutePath() + '/' + QString::fromWCharArray(AppName) + '/';
return appData.absolutePath() + '/' + str_const_toString(AppName) + '/';
}
return QString();
}
@ -1838,13 +1838,13 @@ QString psAppDataPathOld() {
WCHAR wstrPath[maxFileLen];
if (GetEnvironmentVariable(L"APPDATA", wstrPath, maxFileLen)) {
QDir appData(QString::fromStdWString(std::wstring(wstrPath)));
return appData.absolutePath() + '/' + QString::fromWCharArray(AppNameOld) + '/';
return appData.absolutePath() + '/' + str_const_toString(AppNameOld) + '/';
}
return QString();
}
QString psDownloadPath() {
return QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + '/' + QString::fromWCharArray(AppName) + '/';
return QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + '/' + str_const_toString(AppName) + '/';
}
QString psCurrentExeDirectory(int argc, char *argv[]) {
@ -1902,7 +1902,7 @@ void psDoFixPrevious() {
DWORD checkType, checkSize = bufSize * 2;
WCHAR checkStr[bufSize];
QString appId = QString::fromStdWString(AppId);
QString appId = str_const_toString(AppId);
QString newKeyStr1 = QString("Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%1_is1").arg(appId);
QString newKeyStr2 = QString("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%1_is1").arg(appId);
QString oldKeyStr1 = QString("SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%1_is1").arg(appId);
@ -2304,7 +2304,7 @@ void _manageAppLnk(bool create, bool silent, int path_csidl, const wchar_t *args
WCHAR startupFolder[MAX_PATH];
HRESULT hr = SHGetFolderPath(0, path_csidl, 0, SHGFP_TYPE_CURRENT, startupFolder);
if (SUCCEEDED(hr)) {
QString lnk = QString::fromWCharArray(startupFolder) + '\\' + QString::fromWCharArray(AppFile) + qsl(".lnk");
QString lnk = QString::fromWCharArray(startupFolder) + '\\' + str_const_toString(AppFile) + qsl(".lnk");
if (create) {
ComPtr<IShellLink> shellLink;
hr = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&shellLink));
@ -2367,9 +2367,6 @@ void psUpdateOverlayed(TWidget *widget) {
if (!wv) widget->setAttribute(Qt::WA_WState_Visible, false);
}
static const WCHAR *_programName = AppName; // folder in APPDATA, if current path is unavailable for writing
static const WCHAR *_exeName = L"Telegram.exe";
// Stack walk code is inspired by http://www.codeproject.com/Articles/11132/Walking-the-callstack
static const int StackEntryMaxNameLength = MAX_SYM_NAME + 1;

View File

@ -1087,7 +1087,7 @@ void PsMainWindow::psSetupTrayIcon() {
QIcon icon(QPixmap::fromImage(App::wnd()->iconLarge(), Qt::ColorOnly));
trayIcon->setIcon(icon);
trayIcon->setToolTip(QString::fromStdWString(AppName));
trayIcon->setToolTip(str_const_toString(AppName));
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(toggleTray(QSystemTrayIcon::ActivationReason)), Qt::UniqueConnection);
connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(showFromTray()));
App::wnd()->updateTrayMenu();
@ -1842,7 +1842,7 @@ QString psAppDataPath() {
//WCHAR wstrPath[maxFileLen];
//if (GetEnvironmentVariable(L"APPDATA", wstrPath, maxFileLen)) {
// QDir appData(QString::fromStdWString(std::wstring(wstrPath)));
// return appData.absolutePath() + '/' + QString::fromWCharArray(AppName) + '/';
// return appData.absolutePath() + '/' + str_const_toString(AppName) + '/';
//}
return QString();
}
@ -1852,13 +1852,13 @@ QString psAppDataPathOld() {
//WCHAR wstrPath[maxFileLen];
//if (GetEnvironmentVariable(L"APPDATA", wstrPath, maxFileLen)) {
// QDir appData(QString::fromStdWString(std::wstring(wstrPath)));
// return appData.absolutePath() + '/' + QString::fromWCharArray(AppNameOld) + '/';
// return appData.absolutePath() + '/' + str_const_toString(AppNameOld) + '/';
//}
return QString();
}
QString psDownloadPath() {
return QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + '/' + QString::fromWCharArray(AppName) + '/';
return QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + '/' + str_const_toString(AppName) + '/';
}
QString psCurrentExeDirectory(int argc, char *argv[]) {
@ -1916,7 +1916,7 @@ void psDoFixPrevious() {
//DWORD checkType, checkSize = bufSize * 2;
//WCHAR checkStr[bufSize];
//QString appId = QString::fromStdWString(AppId);
//QString appId = str_const_toString(AppId);
//QString newKeyStr1 = QString("Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%1_is1").arg(appId);
//QString newKeyStr2 = QString("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%1_is1").arg(appId);
//QString oldKeyStr1 = QString("SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%1_is1").arg(appId);
@ -2318,7 +2318,7 @@ void _manageAppLnk(bool create, bool silent, int path_csidl, const wchar_t *args
//WCHAR startupFolder[MAX_PATH];
//HRESULT hr = SHGetFolderPath(0, path_csidl, 0, SHGFP_TYPE_CURRENT, startupFolder);
//if (SUCCEEDED(hr)) {
// QString lnk = QString::fromWCharArray(startupFolder) + '\\' + QString::fromWCharArray(AppFile) + qsl(".lnk");
// QString lnk = QString::fromWCharArray(startupFolder) + '\\' + str_const_toString(AppFile) + qsl(".lnk");
// if (create) {
// ComPtr<IShellLink> shellLink;
// hr = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&shellLink));
@ -2381,9 +2381,6 @@ void psUpdateOverlayed(TWidget *widget) {
if (!wv) widget->setAttribute(Qt::WA_WState_Visible, false);
}
static const WCHAR *_programName = AppName; // folder in APPDATA, if current path is unavailable for writing
static const WCHAR *_exeName = L"Telegram.exe";
void psWriteDump() {
}

View File

@ -791,7 +791,7 @@ QStringList FlatTextarea::linksList() const {
}
void FlatTextarea::insertFromMimeData(const QMimeData *source) {
auto mime = str_const_latin1_toString(TagsMimeType);
auto mime = str_const_toString(TagsMimeType);
if (source->hasFormat(mime)) {
auto tagsData = source->data(mime);
_settingTags = deserializeTagsList(tagsData, source->text().size());