mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-01-30 11:45:08 +00:00
Some global string constants "static const *" -> "constexpr str_const".
This commit is contained in:
parent
58e185012c
commit
5f5109f1c4
@ -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
|
||||
|
@ -213,6 +213,10 @@ private:
|
||||
|
||||
};
|
||||
|
||||
inline QString str_const_toString(const str_const &str) {
|
||||
return QString::fromUtf8(str.c_str(), str.size());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void accumulate_max(T &a, const T &b) { if (a < b) a = b; }
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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[]) {
|
||||
|
@ -116,7 +116,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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -1075,7 +1075,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();
|
||||
@ -1829,7 +1829,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();
|
||||
}
|
||||
@ -1839,13 +1839,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[]) {
|
||||
@ -1903,7 +1903,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);
|
||||
@ -2305,7 +2305,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));
|
||||
@ -2368,9 +2368,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;
|
||||
|
@ -1088,7 +1088,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();
|
||||
@ -1843,7 +1843,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();
|
||||
}
|
||||
@ -1853,13 +1853,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[]) {
|
||||
@ -1917,7 +1917,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);
|
||||
@ -2319,7 +2319,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));
|
||||
@ -2382,9 +2382,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() {
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user