Move system versions to platform/platform_info.

This commit is contained in:
John Preston 2019-06-03 17:41:23 +03:00
parent 0467401635
commit 9c613fe2f7
56 changed files with 784 additions and 488 deletions

View File

@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/labels.h"
#include "styles/style_boxes.h"
#include "platform/platform_file_utilities.h"
#include "platform/platform_info.h"
#include "core/click_handler_types.h"
#include "core/update_checker.h"
@ -60,12 +61,18 @@ void AboutBox::resizeEvent(QResizeEvent *e) {
void AboutBox::showVersionHistory() {
if (cRealAlphaVersion()) {
auto url = qsl("https://tdesktop.com/");
switch (cPlatform()) {
case dbipWindows: url += qsl("win/%1.zip"); break;
case dbipMac: url += qsl("mac/%1.zip"); break;
case dbipMacOld: url += qsl("mac32/%1.zip"); break;
case dbipLinux32: url += qsl("linux32/%1.tar.xz"); break;
case dbipLinux64: url += qsl("linux/%1.tar.xz"); break;
if (Platform::IsWindows()) {
url += qsl("win/%1.zip");
} else if (Platform::IsMacOldBuild()) {
url += qsl("mac32/%1.zip");
} else if (Platform::IsMac()) {
url += qsl("mac/%1.zip");
} else if (Platform::IsLinux32Bit()) {
url += qsl("linux32/%1.tar.xz");
} else if (Platform::IsLinux64Bit()) {
url += qsl("linux/%1.tar.xz");
} else {
Unexpected("Platform value.");
}
url = url.arg(qsl("talpha%1_%2").arg(cRealAlphaVersion()).arg(Core::countAlphaVersionSignature(cRealAlphaVersion())));

View File

@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h"
#include "styles/style_boxes.h"
#include "ui/widgets/shadow.h"
#include "platform/platform_info.h"
#include "styles/style_mediaview.h"
#include "ui/widgets/input_fields.h"
@ -517,7 +518,7 @@ void EditColorBox::Field::wheelEvent(QWheelEvent *e) {
}
auto deltaX = e->angleDelta().x(), deltaY = e->angleDelta().y();
if (cPlatform() == dbipMac || cPlatform() == dbipMacOld) {
if (Platform::IsMac()) {
deltaY *= -1;
} else {
deltaX *= -1;

View File

@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/openssl_help.h"
#include "mtproto/connection.h"
#include "media/audio/media_audio_track.h"
#include "platform/platform_info.h"
#include "calls/calls_panel.h"
#include "data/data_user.h"
#include "data/data_session.h"
@ -561,11 +562,7 @@ void Call::createAndStartController(const MTPDphoneCall &call) {
tgvoip::VoIPController::Config config;
config.dataSaving = tgvoip::DATA_SAVING_NEVER;
#ifdef Q_OS_MAC
config.enableAEC = (QSysInfo::macVersion() < QSysInfo::MV_10_7);
#else // Q_OS_MAC
config.enableAEC = true;
#endif // Q_OS_MAC
config.enableAEC = !Platform::IsMac10_7OrGreater();
config.enableNS = true;
config.enableAGC = true;
config.enableVolumeControl = true;

View File

@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_instance.h"
#include "lang/lang_cloud_manager.h"
#include "core/application.h"
#include "platform/platform_specific.h"
#include "platform/platform_info.h"
#include "ui/emoji_config.h"
#include "auth_session.h"
#include "apiwrap.h"

View File

@ -461,7 +461,7 @@ void LastCrashedWindow::onSendReport() {
}
QString apiid = getReportField(qstr("apiid"), qstr("ApiId:")), version = getReportField(qstr("version"), qstr("Version:"));
_checkReply = _sendManager.get(QNetworkRequest(qsl("https://tdesktop.com/crash.php?act=query_report&apiid=%1&version=%2&dmp=%3&platform=%4").arg(apiid).arg(version).arg(minidumpFileName().isEmpty() ? 0 : 1).arg(cPlatformString())));
_checkReply = _sendManager.get(QNetworkRequest(qsl("https://tdesktop.com/crash.php?act=query_report&apiid=%1&version=%2&dmp=%3&platform=%4").arg(apiid).arg(version).arg(minidumpFileName().isEmpty() ? 0 : 1).arg(CrashReports::PlatformString())));
connect(_checkReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onSendingError(QNetworkReply::NetworkError)));
connect(_checkReply, SIGNAL(finished()), this, SLOT(onCheckingFinished()));

View File

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/crash_reports.h"
#include "platform/platform_specific.h"
#include "platform/platform_info.h"
#include "core/launcher.h"
#include <signal.h>
@ -320,13 +321,32 @@ bool DumpCallback(const google_breakpad::MinidumpDescriptor &md, void *context,
} // namespace
QString PlatformString() {
if (Platform::IsWindowsStoreBuild()) {
return qsl("WinStore");
} else if (Platform::IsWindows()) {
return qsl("Windows");
} else if (Platform::IsMacStoreBuild()) {
return qsl("MacAppStore");
} else if (Platform::IsMacOldBuild()) {
return qsl("MacOSold");
} else if (Platform::IsMac()) {
return qsl("MacOS");
} else if (Platform::IsLinux32Bit()) {
return qsl("Linux32Bit");
} else if (Platform::IsLinux64Bit()) {
return qsl("Linux64bit");
}
Unexpected("Platform in CrashReports::PlatformString.");
}
void StartCatching(not_null<Core::Launcher*> launcher) {
#ifndef TDESKTOP_DISABLE_CRASH_REPORTS
ProcessAnnotations["Binary"] = cExeName().toUtf8().constData();
ProcessAnnotations["ApiId"] = QString::number(ApiId).toUtf8().constData();
ProcessAnnotations["Version"] = (cAlphaVersion() ? qsl("%1 alpha").arg(cAlphaVersion()) : (AppBetaVersion ? qsl("%1 beta") : qsl("%1")).arg(AppVersion)).toUtf8().constData();
ProcessAnnotations["Launched"] = QDateTime::currentDateTime().toString("dd.MM.yyyy hh:mm:ss").toUtf8().constData();
ProcessAnnotations["Platform"] = cPlatformString().toUtf8().constData();
ProcessAnnotations["Platform"] = PlatformString().toUtf8().constData();
ProcessAnnotations["UserTag"] = QString::number(launcher->installationTag(), 16).toUtf8().constData();
QString dumpspath = cWorkingDir() + qsl("tdata/dumps");

View File

@ -13,6 +13,8 @@ class Launcher;
namespace CrashReports {
QString PlatformString();
#ifndef TDESKTOP_DISABLE_CRASH_REPORTS
struct dump {

View File

@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "platform/platform_launcher.h"
#include "platform/platform_specific.h"
#include "platform/platform_info.h"
#include "core/crash_reports.h"
#include "core/main_queue_processor.h"
#include "core/update_checker.h"
@ -334,44 +335,6 @@ bool Launcher::customWorkingDir() const {
}
void Launcher::prepareSettings() {
#ifdef Q_OS_MAC
#ifndef OS_MAC_OLD
if (QSysInfo::macVersion() >= QSysInfo::MV_10_11) {
gIsElCapitan = true;
}
#else // OS_MAC_OLD
if (QSysInfo::macVersion() < QSysInfo::MV_10_7) {
gIsSnowLeopard = true;
}
#endif // OS_MAC_OLD
#endif // Q_OS_MAC
switch (cPlatform()) {
case dbipWindows:
#ifndef OS_WIN_STORE
gPlatformString = qsl("Windows");
#else // OS_WIN_STORE
gPlatformString = qsl("WinStore");
#endif // OS_WIN_STORE
break;
case dbipMac:
#ifndef OS_MAC_STORE
gPlatformString = qsl("MacOS");
#else // OS_MAC_STORE
gPlatformString = qsl("MacAppStore");
#endif // OS_MAC_STORE
break;
case dbipMacOld:
gPlatformString = qsl("MacOSold");
break;
case dbipLinux64:
gPlatformString = qsl("Linux64bit");
break;
case dbipLinux32:
gPlatformString = qsl("Linux32bit");
break;
}
auto path = Platform::CurrentExecutablePath(_argc, _argv);
LOG(("Executable path before check: %1").arg(path));
if (!path.isEmpty()) {

View File

@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "core/sandbox.h"
#include "platform/platform_specific.h"
#include "platform/platform_info.h"
#include "mainwidget.h"
#include "mainwindow.h"
#include "storage/localstorage.h"
@ -178,7 +178,7 @@ void Sandbox::setupScreenScale() {
const auto ratio = devicePixelRatio();
if (ratio > 1.) {
if ((cPlatform() != dbipMac && cPlatform() != dbipMacOld) || (ratio != 2.)) {
if (!Platform::IsMac() || (ratio != 2.)) {
LOG(("Found non-trivial Device Pixel Ratio: %1").arg(ratio));
LOG(("Environmental variables: QT_DEVICE_PIXEL_RATIO='%1'").arg(QString::fromLatin1(qgetenv("QT_DEVICE_PIXEL_RATIO"))));
LOG(("Environmental variables: QT_SCALE_FACTOR='%1'").arg(QString::fromLatin1(qgetenv("QT_SCALE_FACTOR"))));

View File

@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwidget.h"
#include "core/application.h"
#include "media/player/media_player_instance.h"
#include "platform/platform_specific.h"
#include "platform/platform_info.h"
#include "base/parse_helper.h"
namespace Shortcuts {
@ -299,7 +299,7 @@ void Manager::fillDefaults() {
set(qsl("alt+down"), Command::ChatNext);
set(qsl("ctrl+pgup"), Command::ChatPrevious);
set(qsl("alt+up"), Command::ChatPrevious);
if (cPlatform() == dbipMac || cPlatform() == dbipMacOld) {
if (Platform::IsMac()) {
set(qsl("meta+tab"), Command::ChatNext);
set(qsl("meta+shift+tab"), Command::ChatPrevious);
set(qsl("meta+backtab"), Command::ChatPrevious);

View File

@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "core/update_checker.h"
#include "platform/platform_specific.h"
#include "platform/platform_info.h"
#include "base/timer.h"
#include "base/bytes.h"
#include "storage/localstorage.h"
@ -495,14 +495,19 @@ bool ParseCommonMap(
}
const auto platforms = document.object();
const auto platform = [&] {
switch (cPlatform()) {
case dbipWindows: return "win";
case dbipMac: return "mac";
case dbipMacOld: return "mac32";
case dbipLinux64: return "linux";
case dbipLinux32: return "linux32";
if (Platform::IsWindows()) {
return "win";
} else if (Platform::IsMacOldBuild()) {
return "mac32";
} else if (Platform::IsMac()) {
return "mac";
} else if (Platform::IsLinux32Bit()) {
return "linux32";
} else if (Platform::IsLinux64Bit()) {
return "linux";
} else {
Unexpected("Platform in ParseCommonMap.");
}
Unexpected("Platform in ParseCommonMap.");
}();
const auto it = platforms.constFind(platform);
if (it == platforms.constEnd()) {

View File

@ -341,14 +341,6 @@ QNetworkProxy ToNetworkProxy(const ProxyData &proxy);
static const int MatrixRowShift = 40000;
enum DBIPlatform {
dbipWindows = 0,
dbipMac = 1,
dbipLinux64 = 2,
dbipLinux32 = 3,
dbipMacOld = 4,
};
enum DBIPeerReportSpamStatus {
dbiprsNoButton = 0, // hidden, but not in the cloud settings yet
dbiprsUnknown = 1, // contacts not loaded yet

View File

@ -16,7 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h"
#include "storage/localstorage.h"
#include "core/file_utilities.h"
#include "platform/platform_specific.h"
#include "platform/platform_info.h"
#include "auth_session.h"
#include "data/data_session.h"
#include "styles/style_export.h"
@ -107,7 +107,7 @@ bool IsDefaultPath(const QString &path) {
const auto result = value.endsWith('/')
? value.mid(0, value.size() - 1)
: value;
return (cPlatform() == dbipWindows) ? result.toLower() : result;
return Platform::IsWindows() ? result.toLower() : result;
};
return (check(path) == check(File::DefaultDownloadPath()));
}
@ -380,7 +380,7 @@ void PanelController::saveSettings() const {
const auto result = value.endsWith('/')
? value.mid(0, value.size() - 1)
: value;
return (cPlatform() == dbipWindows) ? result.toLower() : result;
return Platform::IsWindows() ? result.toLower() : result;
};
auto settings = *_settings;
if (check(settings.path) == check(File::DefaultDownloadPath())) {

View File

@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "media/clip/media_clip_reader.h"
#include "window/window_controller.h"
#include "history/history_item_components.h"
#include "platform/platform_info.h"
#include "data/data_peer.h"
#include "data/data_user.h"
#include "observer_peer.h"
@ -436,7 +437,7 @@ struct Data {
Notify::ScreenCorner NotificationsCorner = Notify::ScreenCorner::BottomRight;
bool NotificationsDemoIsShown = false;
bool TryIPv6 = (cPlatform() == dbipWindows) ? false : true;
bool TryIPv6 = !Platform::IsWindows();
std::vector<ProxyData> ProxiesList;
ProxyData SelectedProxy;
ProxyData::Settings ProxySettings = ProxyData::Settings::System;

View File

@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/view/history_view_cursor_state.h"
#include "chat_helpers/message_field.h"
#include "boxes/sticker_set_box.h"
#include "platform/platform_info.h"
#include "mainwindow.h"
#include "mainwidget.h"
#include "core/application.h"
@ -1023,7 +1024,7 @@ void InnerWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
}
}
if (!document->filepath(DocumentData::FilePathResolve::Checked).isEmpty()) {
_menu->addAction(lang((cPlatform() == dbipMac || cPlatform() == dbipMacOld) ? lng_context_show_in_finder : lng_context_show_in_folder), [=] {
_menu->addAction(lang(Platform::IsMac() ? lng_context_show_in_finder : lng_context_show_in_folder), [=] {
showContextInFolder(document);
});
}

View File

@ -40,6 +40,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "auth_session.h"
#include "core/application.h"
#include "apiwrap.h"
#include "platform/platform_info.h"
#include "lang/lang_keys.h"
#include "data/data_session.h"
#include "data/data_media_types.h"
@ -1558,7 +1559,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
});
}
if (!document->filepath(DocumentData::FilePathResolve::Checked).isEmpty()) {
_menu->addAction(lang((cPlatform() == dbipMac || cPlatform() == dbipMacOld) ? lng_context_show_in_finder : lng_context_show_in_folder), [=] {
_menu->addAction(lang(Platform::IsMac() ? lng_context_show_in_finder : lng_context_show_in_folder), [=] {
showContextInFolder(document);
});
}

View File

@ -28,6 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_groups.h"
#include "data/data_channel.h"
#include "core/file_utilities.h"
#include "platform/platform_info.h"
#include "window/window_peer_menu.h"
#include "lang/lang_keys.h"
#include "core/application.h"
@ -181,7 +182,7 @@ void AddDocumentActions(
if (!document->filepath(
DocumentData::FilePathResolve::Checked).isEmpty()) {
menu->addAction(
lang((cPlatform() == dbipMac || cPlatform() == dbipMacOld)
lang(Platform::IsMac()
? lng_context_show_in_finder
: lng_context_show_in_folder),
[=] { ShowInFolder(document); });

View File

@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "window/main_window.h"
#include "styles/style_overview.h"
#include "styles/style_info.h"
#include "platform/platform_info.h"
#include "media/player/media_player_instance.h"
#include "boxes/peer_list_controllers.h"
#include "boxes/confirm_box.h"
@ -1267,7 +1268,7 @@ void ListWidget::showContextMenu(
File::ShowInFolder(filepath);
});
_contextMenu->addAction(
lang((cPlatform() == dbipMac || cPlatform() == dbipMacOld)
lang(Platform::IsMac()
? lng_context_show_in_finder
: lng_context_show_in_folder),
std::move(handler));

View File

@ -16,7 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/click_handler_types.h"
#include "boxes/confirm_box.h"
#include "base/qthelp_url.h"
#include "platform/platform_specific.h"
#include "platform/platform_info.h"
#include "core/application.h"
namespace Intro {
@ -35,7 +35,7 @@ I'm trying to use my mobile phone number: ") + phone + qsl("\n\
But Telegram says it's banned. Please help.\n\
\n\
App version: ") + version + qsl("\n\
OS version: ") + cPlatformString() + qsl("\n\
OS version: ") + Platform::SystemVersionPretty() + qsl("\n\
Locale: ") + Platform::SystemLanguage();
const auto url = "mailto:?to="

View File

@ -29,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "window/window_slide_animation.h"
#include "window/window_connecting_widget.h"
#include "window/window_lock_widgets.h"
#include "platform/platform_info.h"
#include "data/data_user.h"
#include "window/themes/window_theme.h"
#include "lang/lang_cloud_manager.h"

View File

@ -10,7 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/application.h"
#include "storage/serialize_common.h"
#include "storage/localstorage.h"
#include "platform/platform_specific.h"
#include "platform/platform_info.h"
#include "boxes/confirm_box.h"
#include "lang/lang_file_parser.h"
#include "base/qthelp_regex.h"

View File

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_translator.h"
#include "lang/lang_keys.h"
#include "platform/platform_info.h"
namespace Lang {
@ -23,8 +24,8 @@ QString Translator::translate(const char *context, const char *sourceText, const
return QString();
}
if (qstr("QWidgetTextControl") == context || qstr("QLineEdit") == context) {
if (qstr("&Undo") == sourceText) return lang((cPlatform() == dbipWindows) ? lng_wnd_menu_undo : ((cPlatform() == dbipMac || cPlatform() == dbipMacOld) ? lng_mac_menu_undo : lng_linux_menu_undo));
if (qstr("&Redo") == sourceText) return lang((cPlatform() == dbipWindows) ? lng_wnd_menu_redo : ((cPlatform() == dbipMac || cPlatform() == dbipMacOld) ? lng_mac_menu_redo : lng_linux_menu_redo));
if (qstr("&Undo") == sourceText) return lang(Platform::IsWindows() ? lng_wnd_menu_undo : (Platform::IsMac() ? lng_mac_menu_undo : lng_linux_menu_undo));
if (qstr("&Redo") == sourceText) return lang(Platform::IsWindows() ? lng_wnd_menu_redo : (Platform::IsMac() ? lng_mac_menu_redo : lng_linux_menu_redo));
if (qstr("Cu&t") == sourceText) return lang(lng_mac_menu_cut);
if (qstr("&Copy") == sourceText) return lang(lng_mac_menu_copy);
if (qstr("&Paste") == sourceText) return lang(lng_mac_menu_paste);

View File

@ -35,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "apiwrap.h"
#include "settings/settings_intro.h"
#include "platform/platform_notifications_manager.h"
#include "platform/platform_info.h"
#include "window/layer_widget.h"
#include "window/notifications_manager.h"
#include "window/themes/window_theme.h"
@ -124,12 +125,11 @@ void MainWindow::firstShow() {
trayIconMenu = new QMenu(this);
#endif // else for Q_OS_WIN
auto isLinux = (cPlatform() == dbipLinux32 || cPlatform() == dbipLinux64);
auto notificationActionText = lang(Global::DesktopNotify()
? lng_disable_notifications_from_tray
: lng_enable_notifications_from_tray);
if (isLinux) {
if (Platform::IsLinux()) {
trayIconMenu->addAction(lang(lng_open_from_tray), this, SLOT(showFromTray()));
trayIconMenu->addAction(lang(lng_minimize_to_tray), this, SLOT(minimizeToTray()));
trayIconMenu->addAction(notificationActionText, this, SLOT(toggleDisplayNotifyFromTray()));
@ -541,12 +541,11 @@ bool MainWindow::eventFilter(QObject *object, QEvent *e) {
}
void MainWindow::updateTrayMenu(bool force) {
if (!trayIconMenu || (cPlatform() == dbipWindows && !force)) return;
if (!trayIconMenu || (Platform::IsWindows() && !force)) return;
auto iconMenu = trayIconMenu;
auto actions = iconMenu->actions();
auto isLinux = (cPlatform() == dbipLinux32 || cPlatform() == dbipLinux64);
if (isLinux) {
if (Platform::IsLinux()) {
auto minimizeAction = actions.at(1);
minimizeAction->setDisabled(!isVisible());
} else {
@ -560,11 +559,11 @@ void MainWindow::updateTrayMenu(bool force) {
// On macOS just remove trayIcon menu if the window is not active.
// So we will activate the window on click instead of showing the menu.
if (!active && (cPlatform() == dbipMac || cPlatform() == dbipMacOld)) {
if (!active && Platform::IsMac()) {
iconMenu = nullptr;
}
}
auto notificationAction = actions.at(isLinux ? 2 : 1);
auto notificationAction = actions.at(Platform::IsLinux() ? 2 : 1);
auto notificationActionText = lang(Global::DesktopNotify()
? lng_disable_notifications_from_tray
: lng_enable_notifications_from_tray);
@ -678,8 +677,7 @@ void MainWindow::showFromTray(QSystemTrayIcon::ActivationReason reason) {
void MainWindow::handleTrayIconActication(
QSystemTrayIcon::ActivationReason reason) {
updateIsActive(0);
if ((cPlatform() == dbipMac || cPlatform() == dbipMacOld)
&& isActive()) {
if (Platform::IsMac() && isActive()) {
return;
}
if (reason == QSystemTrayIcon::Context) {

View File

@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/application.h"
#include "core/file_utilities.h"
#include "core/mime_type.h"
#include "platform/platform_info.h"
#include "ui/widgets/popup_menu.h"
#include "ui/widgets/buttons.h"
#include "ui/image/image.h"
@ -289,11 +290,11 @@ OverlayWidget::OverlayWidget()
hide();
createWinId();
if (cPlatform() == dbipLinux32 || cPlatform() == dbipLinux64) {
if (Platform::IsLinux()) {
windowHandle()->setTransientParent(App::wnd()->windowHandle());
setWindowModality(Qt::WindowModal);
}
if (cPlatform() != dbipMac && cPlatform() != dbipMacOld) {
if (!Platform::IsMac()) {
setWindowState(Qt::WindowFullScreen);
}
@ -646,7 +647,7 @@ void OverlayWidget::updateActions() {
_actions.push_back({ lang(lng_context_to_msg), SLOT(onToMessage()) });
}
if (_doc && !_doc->filepath(DocumentData::FilePathResolve::Checked).isEmpty()) {
_actions.push_back({ lang((cPlatform() == dbipMac || cPlatform() == dbipMacOld) ? lng_context_show_in_finder : lng_context_show_in_folder), SLOT(onShowInFolder()) });
_actions.push_back({ lang(Platform::IsMac() ? lng_context_show_in_finder : lng_context_show_in_folder), SLOT(onShowInFolder()) });
}
if ((_doc && documentContentShown()) || (_photo && _photo->loaded())) {
_actions.push_back({ lang(lng_mediaview_copy), SLOT(onCopy()) });

View File

@ -9,7 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "passport/passport_panel_controller.h"
#include "lang/lang_keys.h"
#include "platform/platform_specific.h"
#include "platform/platform_info.h"
#include "ui/widgets/input_fields.h"
#include "ui/widgets/labels.h"
#include "ui/widgets/buttons.h"

View File

@ -0,0 +1,35 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "platform/linux/info_linux.h"
namespace Platform {
QString DeviceModelPretty() {
#ifdef Q_OS_LINUX64
return "PC 64bit";
#else // Q_OS_LINUX64
return "PC 32bit";
#endif // Q_OS_LINUX64
}
QString SystemVersionPretty() {
const auto result = getenv("XDG_CURRENT_DESKTOP");
const auto value = result ? QString::fromLatin1(result) : QString();
const auto list = value.split(':', QString::SkipEmptyParts);
return list.isEmpty() ? "Linux" : "Linux " + list[0];
}
QString SystemCountry() {
return QString();
}
QString SystemLanguage() {
return QString();
}
} // namespace Platform

View File

@ -0,0 +1,53 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
namespace Platform {
inline constexpr bool IsLinux() {
return true;
}
inline constexpr bool IsLinux32Bit() {
#ifdef Q_OS_LINUX32
return true;
#else // Q_OS_LINUX32
return false;
#endif // Q_OS_LINUX32
}
inline constexpr bool IsLinux64Bit() {
#ifdef Q_OS_LINUX64
return true;
#else // Q_OS_LINUX64
return false;
#endif // Q_OS_LINUX64
}
inline constexpr bool IsWindows() { return false; }
inline constexpr bool IsWindowsStoreBuild() { return false; }
inline bool IsWindowsXPOrGreater() { return false; }
inline bool IsWindowsVistaOrGreater() { return false; }
inline bool IsWindows7OrGreater() { return false; }
inline bool IsWindows8OrGreater() { return false; }
inline bool IsWindows8Point1OrGreater() { return false; }
inline bool IsWindows10OrGreater() { return false; }
inline constexpr bool IsMac() { return false; }
inline constexpr bool IsMacOldBuild() { return false; }
inline constexpr bool IsMacStoreBuild() { return false; }
inline bool IsMac10_6OrGreater() { return false; }
inline bool IsMac10_7OrGreater() { return false; }
inline bool IsMac10_8OrGreater() { return false; }
inline bool IsMac10_9OrGreater() { return false; }
inline bool IsMac10_10OrGreater() { return false; }
inline bool IsMac10_11OrGreater() { return false; }
inline bool IsMac10_12OrGreater() { return false; }
inline bool IsMac10_13OrGreater() { return false; }
inline bool IsMac10_14OrGreater() { return false; }
} // namespace Platform

View File

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "platform/linux/launcher_linux.h"
#include "platform/platform_info.h"
#include "core/crash_reports.h"
#include "core/update_checker.h"
@ -39,25 +40,10 @@ private:
};
QString DeviceModel() {
#ifdef Q_OS_LINUX64
return "PC 64bit";
#else // Q_OS_LINUX64
return "PC 32bit";
#endif // Q_OS_LINUX64
}
QString SystemVersion() {
const auto result = getenv("XDG_CURRENT_DESKTOP");
const auto value = result ? QString::fromLatin1(result) : QString();
const auto list = value.split(':', QString::SkipEmptyParts);
return list.isEmpty() ? "Linux" : "Linux " + list[0];
}
} // namespace
Launcher::Launcher(int argc, char *argv[])
: Core::Launcher(argc, argv, DeviceModel(), SystemVersion()) {
: Core::Launcher(argc, argv, DeviceModelPretty(), SystemVersionPretty()) {
}
bool Launcher::launchUpdater(UpdaterLaunch action) {

View File

@ -283,14 +283,6 @@ bool TranslucentWindowsSupported(QPoint globalPosition) {
return false;
}
QString SystemCountry() {
return QString();
}
QString SystemLanguage() {
return QString();
}
void RegisterCustomScheme() {
#ifndef TDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME
auto home = getHomeDir();

View File

@ -0,0 +1,9 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "platform/mac/info_mac.h"

View File

@ -0,0 +1,44 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
namespace Platform {
inline constexpr bool IsMac() {
return true;
}
inline constexpr bool IsMacOldBuild() {
#ifdef OS_MAC_OLD
return true;
#else // OS_MAC_OLD
return false;
#endif // OS_MAC_OLD
}
inline constexpr bool IsMacStoreBuild() {
#ifdef OS_MAC_STORE
return true;
#else // OS_MAC_STORE
return false;
#endif // OS_MAC_STORE
}
inline constexpr bool IsWindows() { return false; }
inline constexpr bool IsWindowsStoreBuild() { return false; }
inline bool IsWindowsXPOrGreater() { return false; }
inline bool IsWindowsVistaOrGreater() { return false; }
inline bool IsWindows7OrGreater() { return false; }
inline bool IsWindows8OrGreater() { return false; }
inline bool IsWindows8Point1OrGreater() { return false; }
inline bool IsWindows10OrGreater() { return false; }
inline constexpr bool IsLinux() { return false; }
inline constexpr bool IsLinux32Bit() { return false; }
inline constexpr bool IsLinux64Bit() { return false; }
} // namespace Platform

View File

@ -0,0 +1,153 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "platform/mac/info_mac.h"
#include "platform/mac/mac_utilities.h"
#include <sys/sysctl.h>
#include <Cocoa/Cocoa.h>
namespace Platform {
namespace {
QString FromIdentifier(const QString &model) {
if (model.isEmpty() || model.toLower().indexOf("mac") < 0) {
return QString();
}
QStringList words;
QString word;
for (const QChar ch : model) {
if (!ch.isLetter()) {
continue;
}
if (ch.isUpper()) {
if (!word.isEmpty()) {
words.push_back(word);
word = QString();
}
}
word.append(ch);
}
if (!word.isEmpty()) {
words.push_back(word);
}
QString result;
for (const QString word : words) {
if (!result.isEmpty()
&& word != "Mac"
&& word != "Book") {
result.append(' ');
}
result.append(word);
}
return result;
}
int MinorVersion() {
static const int version = QSysInfo::macVersion();
constexpr int kShift = 2;
if (version == QSysInfo::MV_Unknown
#ifndef OS_MAC_OLD
|| version == QSysInfo::MV_None
#endif // OS_MAC_OLD
|| version < kShift + 6) {
return 0;
}
return version - kShift;
}
template <int Minor>
bool IsMacThatOrGreater() {
static const auto result = (MinorVersion() >= Minor);
return result;
}
} // namespace
QString DeviceModelPretty() {
size_t length = 0;
sysctlbyname("hw.model", nullptr, &length, nullptr, 0);
if (length > 0) {
QByteArray bytes(length, Qt::Uninitialized);
sysctlbyname("hw.model", bytes.data(), &length, nullptr, 0);
const QString parsed = FromIdentifier(QString::fromUtf8(bytes));
if (!parsed.isEmpty()) {
return parsed;
}
}
return "Mac";
}
QString SystemVersionPretty() {
const auto version = MinorVersion();
if (!version) {
return "OS X";
} else if (version < 12) {
return QString("OS X 10.%1").arg(version);
}
return QString("macOS 10.%1").arg(version);
}
QString SystemCountry() {
NSLocale *currentLocale = [NSLocale currentLocale]; // get the current locale.
NSString *countryCode = [currentLocale objectForKey:NSLocaleCountryCode];
return countryCode ? NS2QString(countryCode) : QString();
}
QString SystemLanguage() {
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();
}
bool IsMac10_6OrGreater() {
return IsMacThatOrGreater<6>();
}
bool IsMac10_7OrGreater() {
return IsMacThatOrGreater<7>();
}
bool IsMac10_8OrGreater() {
return IsMacThatOrGreater<8>();
}
bool IsMac10_9OrGreater() {
return IsMacThatOrGreater<9>();
}
bool IsMac10_10OrGreater() {
return IsMacThatOrGreater<10>();
}
bool IsMac10_11OrGreater() {
return IsMacThatOrGreater<11>();
}
bool IsMac10_12OrGreater() {
return IsMacThatOrGreater<12>();
}
bool IsMac10_13OrGreater() {
return IsMacThatOrGreater<13>();
}
bool IsMac10_14OrGreater() {
return IsMacThatOrGreater<14>();
}
} // namespace Platform

View File

@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/crash_reports.h"
#include "core/update_checker.h"
#include "platform/mac/mac_utilities.h"
#include "platform/platform_info.h"
#include "platform/platform_specific.h"
#include <Cocoa/Cocoa.h>
@ -17,74 +18,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <sys/sysctl.h>
namespace Platform {
namespace {
QString FromIdentifier(const QString &model) {
if (model.isEmpty() || model.toLower().indexOf("mac") < 0) {
return QString();
}
QStringList words;
QString word;
for (const QChar ch : model) {
if (!ch.isLetter()) {
continue;
}
if (ch.isUpper()) {
if (!word.isEmpty()) {
words.push_back(word);
word = QString();
}
}
word.append(ch);
}
if (!word.isEmpty()) {
words.push_back(word);
}
QString result;
for (const QString word : words) {
if (!result.isEmpty()
&& word != "Mac"
&& word != "Book") {
result.append(' ');
}
result.append(word);
}
return result;
}
QString DeviceModel() {
size_t length = 0;
sysctlbyname("hw.model", nullptr, &length, nullptr, 0);
if (length > 0) {
QByteArray bytes(length, Qt::Uninitialized);
sysctlbyname("hw.model", bytes.data(), &length, nullptr, 0);
const QString parsed = FromIdentifier(QString::fromUtf8(bytes));
if (!parsed.isEmpty()) {
return parsed;
}
}
return "Mac";
}
QString SystemVersion() {
const int version = QSysInfo::macVersion();
constexpr int kShift = 2;
if (version == QSysInfo::MV_Unknown
#ifndef OS_MAC_OLD
|| version == QSysInfo::MV_None
#endif // OS_MAC_OLD
|| version < kShift + 6) {
return "OS X";
} else if (version < kShift + 12) {
return QString("OS X 10.%1").arg(version - kShift);
}
return QString("macOS 10.%1").arg(version - kShift);
}
} // namespace
Launcher::Launcher(int argc, char *argv[])
: Core::Launcher(argc, argv, DeviceModel(), SystemVersion()) {
: Core::Launcher(argc, argv, DeviceModelPretty(), SystemVersionPretty()) {
}
void Launcher::initHook() {

View File

@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "window/notifications_manager_default.h"
#include "window/themes/window_theme.h"
#include "platform/platform_notifications_manager.h"
#include "platform/platform_info.h"
#include "boxes/peer_list_controllers.h"
#include "boxes/about_box.h"
#include "lang/lang_keys.h"
@ -400,14 +401,7 @@ MainWindow::MainWindow()
}
void MainWindow::initTouchBar() {
const int version = QSysInfo::macVersion();
constexpr int kShift = 2;
if (version == QSysInfo::MV_Unknown
#ifndef OS_MAC_OLD
|| version == QSysInfo::MV_None
#endif // OS_MAC_OLD
// Allow touch bar only starting with 10.13.
|| version < kShift + 13) {
if (!IsMac10_13OrGreater()) {
return;
}

View File

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "platform/mac/notifications_manager_mac.h"
#include "platform/platform_specific.h"
#include "platform/platform_info.h"
#include "platform/mac/mac_utilities.h"
#include "history/history.h"
#include "mainwindow.h"
@ -141,7 +142,7 @@ bool SkipToast() {
}
bool Supported() {
return (cPlatform() != dbipMacOld);
return Platform::IsMac10_8OrGreater();
}
std::unique_ptr<Window::Notifications::Manager> Create(Window::Notifications::System *system) {

View File

@ -153,27 +153,6 @@ void StartTranslucentPaint(QPainter &p, QPaintEvent *e) {
#endif // OS_MAC_OLD
}
QString SystemCountry() {
NSLocale *currentLocale = [NSLocale currentLocale]; // get the current locale.
NSString *countryCode = [currentLocale objectForKey:NSLocaleCountryCode];
return countryCode ? NS2QString(countryCode) : QString();
}
QString SystemLanguage() {
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();
}
QString CurrentExecutablePath(int argc, char *argv[]) {
return NS2QString([[NSBundle mainBundle] bundlePath]);
}

View File

@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "media/player/media_player_instance.h"
#include "platform/mac/mac_touchbar.h"
#include "platform/mac/mac_utilities.h"
#include "platform/platform_info.h"
#include "lang/lang_keys.h"
#include "base/timer.h"
#include "styles/style_window.h"
@ -125,15 +126,11 @@ ApplicationDelegate *_sharedDelegate = nil;
});
#ifndef OS_MAC_STORE
if ([SPMediaKeyTap usesGlobalMediaKeyTap]) {
#ifndef OS_MAC_OLD
if (QSysInfo::macVersion() < Q_MV_OSX(10, 14)) {
#else // OS_MAC_OLD
if (true) {
#endif // OS_MAC_OLD
if (!Platform::IsMac10_14OrGreater()) {
_keyTap = [[SPMediaKeyTap alloc] initWithDelegate:self];
} else {
// In macOS Mojave it requires accessibility features.
LOG(("Media key monitoring disabled in Mojave."));
LOG(("Media key monitoring disabled starting with Mojave."));
}
} else {
LOG(("Media key monitoring disabled"));

View File

@ -0,0 +1,51 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
namespace Platform {
[[nodiscard]] QString DeviceModelPretty();
[[nodiscard]] QString SystemVersionPretty();
[[nodiscard]] QString SystemCountry();
[[nodiscard]] QString SystemLanguage();
[[nodiscard]] constexpr bool IsWindows();
[[nodiscard]] constexpr bool IsWindowsStoreBuild();
[[nodiscard]] bool IsWindowsXPOrGreater();
[[nodiscard]] bool IsWindowsVistaOrGreater();
[[nodiscard]] bool IsWindows7OrGreater();
[[nodiscard]] bool IsWindows8OrGreater();
[[nodiscard]] bool IsWindows8Point1OrGreater();
[[nodiscard]] bool IsWindows10OrGreater();
[[nodiscard]] constexpr bool IsMac();
[[nodiscard]] constexpr bool IsMacOldBuild();
[[nodiscard]] constexpr bool IsMacStoreBuild();
[[nodiscard]] bool IsMac10_6OrGreater();
[[nodiscard]] bool IsMac10_7OrGreater();
[[nodiscard]] bool IsMac10_8OrGreater();
[[nodiscard]] bool IsMac10_9OrGreater();
[[nodiscard]] bool IsMac10_10OrGreater();
[[nodiscard]] bool IsMac10_11OrGreater();
[[nodiscard]] bool IsMac10_12OrGreater();
[[nodiscard]] bool IsMac10_13OrGreater();
[[nodiscard]] bool IsMac10_14OrGreater();
[[nodiscard]] constexpr bool IsLinux();
[[nodiscard]] constexpr bool IsLinux32Bit();
[[nodiscard]] constexpr bool IsLinux64Bit();
} // namespace Platform
#ifdef Q_OS_MAC
#include "platform/mac/info_mac.h"
#elif defined Q_OS_LINUX // Q_OS_MAC
#include "platform/linux/info_linux.h"
#elif defined Q_OS_WIN // Q_OS_MAC || Q_OS_LINUX
#include "platform/win/info_win.h"
#endif // Q_OS_MAC || Q_OS_LINUX || Q_OS_WIN

View File

@ -40,9 +40,6 @@ void RequestPermission(PermissionType type, Fn<void(PermissionStatus)> resultCal
void OpenSystemSettingsForPermission(PermissionType type);
bool OpenSystemSettings(SystemSettingsType type);
[[nodiscard]] QString SystemLanguage();
[[nodiscard]] QString SystemCountry();
[[nodiscard]] std::optional<crl::time> LastUserInputTime();
[[nodiscard]] inline bool LastUserInputTimeSupported() {
return LastUserInputTime().has_value();

View File

@ -0,0 +1,244 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "platform/win/info_win.h"
#include "platform/platform_info.h"
#include "platform/win/wrapper_windows_h.h"
#include <VersionHelpers.h>
namespace Platform {
namespace {
QString GetLangCodeById(unsigned int lngId) {
const auto primary = (lngId & 0xFFU);
switch (primary) {
case 0x36: return qsl("af");
case 0x1C: return qsl("sq");
case 0x5E: return qsl("am");
case 0x01: return qsl("ar");
case 0x2B: return qsl("hy");
case 0x4D: return qsl("as");
case 0x2C: return qsl("az");
case 0x45: return qsl("bn");
case 0x6D: return qsl("ba");
case 0x2D: return qsl("eu");
case 0x23: return qsl("be");
case 0x1A:
if (lngId == LANG_CROATIAN) {
return qsl("hr");
} else if (lngId == LANG_BOSNIAN_NEUTRAL || lngId == LANG_BOSNIAN) {
return qsl("bs");
}
return qsl("sr");
break;
case 0x7E: return qsl("br");
case 0x02: return qsl("bg");
case 0x92: return qsl("ku");
case 0x03: return qsl("ca");
case 0x04: return qsl("zh");
case 0x83: return qsl("co");
case 0x05: return qsl("cs");
case 0x06: return qsl("da");
case 0x65: return qsl("dv");
case 0x13: return qsl("nl");
case 0x09: return qsl("en");
case 0x25: return qsl("et");
case 0x38: return qsl("fo");
case 0x0B: return qsl("fi");
case 0x0c: return qsl("fr");
case 0x62: return qsl("fy");
case 0x56: return qsl("gl");
case 0x37: return qsl("ka");
case 0x07: return qsl("de");
case 0x08: return qsl("el");
case 0x6F: return qsl("kl");
case 0x47: return qsl("gu");
case 0x68: return qsl("ha");
case 0x0D: return qsl("he");
case 0x39: return qsl("hi");
case 0x0E: return qsl("hu");
case 0x0F: return qsl("is");
case 0x70: return qsl("ig");
case 0x21: return qsl("id");
case 0x5D: return qsl("iu");
case 0x3C: return qsl("ga");
case 0x34: return qsl("xh");
case 0x35: return qsl("zu");
case 0x10: return qsl("it");
case 0x11: return qsl("ja");
case 0x4B: return qsl("kn");
case 0x3F: return qsl("kk");
case 0x53: return qsl("kh");
case 0x87: return qsl("rw");
case 0x12: return qsl("ko");
case 0x40: return qsl("ky");
case 0x54: return qsl("lo");
case 0x26: return qsl("lv");
case 0x27: return qsl("lt");
case 0x6E: return qsl("lb");
case 0x2F: return qsl("mk");
case 0x3E: return qsl("ms");
case 0x4C: return qsl("ml");
case 0x3A: return qsl("mt");
case 0x81: return qsl("mi");
case 0x4E: return qsl("mr");
case 0x50: return qsl("mn");
case 0x61: return qsl("ne");
case 0x14: return qsl("no");
case 0x82: return qsl("oc");
case 0x48: return qsl("or");
case 0x63: return qsl("ps");
case 0x29: return qsl("fa");
case 0x15: return qsl("pl");
case 0x16: return qsl("pt");
case 0x67: return qsl("ff");
case 0x46: return qsl("pa");
case 0x18: return qsl("ro");
case 0x17: return qsl("rm");
case 0x19: return qsl("ru");
case 0x3B: return qsl("se");
case 0x4F: return qsl("sa");
case 0x32: return qsl("tn");
case 0x59: return qsl("sd");
case 0x5B: return qsl("si");
case 0x1B: return qsl("sk");
case 0x24: return qsl("sl");
case 0x0A: return qsl("es");
case 0x41: return qsl("sw");
case 0x1D: return qsl("sv");
case 0x28: return qsl("tg");
case 0x49: return qsl("ta");
case 0x44: return qsl("tt");
case 0x4A: return qsl("te");
case 0x1E: return qsl("th");
case 0x51: return qsl("bo");
case 0x73: return qsl("ti");
case 0x1F: return qsl("tr");
case 0x42: return qsl("tk");
case 0x22: return qsl("uk");
case 0x20: return qsl("ur");
case 0x80: return qsl("ug");
case 0x43: return qsl("uz");
case 0x2A: return qsl("vi");
case 0x52: return qsl("cy");
case 0x88: return qsl("wo");
case 0x78: return qsl("ii");
case 0x6A: return qsl("yo");
}
return QString();
}
} // namespace
QString DeviceModelPretty() {
return "PC";
}
QString SystemVersionPretty() {
if (IsWindows10OrGreater()) {
return "Windows 10";
} else if (IsWindows8Point1OrGreater()) {
return "Windows 8.1";
} else if (IsWindows8OrGreater()) {
return "Windows 8";
} else if (IsWindows7OrGreater()) {
return "Windows 7";
} else if (IsWindowsVistaOrGreater()) {
return "Windows Vista";
} else if (IsWindowsXPOrGreater()) {
return "Windows XP";
} else {
return QSysInfo::prettyProductName();
}
}
QString SystemCountry() {
int chCount = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, 0, 0);
if (chCount && chCount < 128) {
WCHAR wstrCountry[128];
int len = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, wstrCountry, chCount);
if (len) {
return QString::fromStdWString(std::wstring(wstrCountry));
}
}
return QString();
}
QString SystemLanguage() {
constexpr auto kMaxLanguageLength = 128;
auto uiLanguageId = GetUserDefaultUILanguage();
auto uiLanguageLength = GetLocaleInfo(uiLanguageId, LOCALE_SNAME, nullptr, 0);
if (uiLanguageLength > 0 && uiLanguageLength < kMaxLanguageLength) {
WCHAR uiLanguageWideString[kMaxLanguageLength] = { 0 };
uiLanguageLength = GetLocaleInfo(uiLanguageId, LOCALE_SNAME, uiLanguageWideString, uiLanguageLength);
if (uiLanguageLength <= 0) {
return QString();
}
return QString::fromWCharArray(uiLanguageWideString);
}
auto uiLanguageCodeLength = GetLocaleInfo(uiLanguageId, LOCALE_ILANGUAGE, nullptr, 0);
if (uiLanguageCodeLength > 0 && uiLanguageCodeLength < kMaxLanguageLength) {
WCHAR uiLanguageCodeWideString[kMaxLanguageLength] = { 0 };
uiLanguageCodeLength = GetLocaleInfo(uiLanguageId, LOCALE_ILANGUAGE, uiLanguageCodeWideString, uiLanguageCodeLength);
if (uiLanguageCodeLength <= 0) {
return QString();
}
auto languageCode = 0U;
for (auto i = 0; i != uiLanguageCodeLength; ++i) {
auto ch = uiLanguageCodeWideString[i];
if (!ch) {
break;
}
languageCode *= 0x10U;
if (ch >= WCHAR('0') && ch <= WCHAR('9')) {
languageCode += static_cast<unsigned>(int(ch) - int(WCHAR('0')));
} else if (ch >= WCHAR('A') && ch <= WCHAR('F')) {
languageCode += static_cast<unsigned>(0x0A + int(ch) - int(WCHAR('A')));
} else {
return QString();
}
}
return GetLangCodeById(languageCode);
}
return QString();
}
bool IsWindowsXPOrGreater() {
static const auto result = ::IsWindowsXPOrGreater();
return result;
}
bool IsWindowsVistaOrGreater() {
static const auto result = ::IsWindowsVistaOrGreater();
return result;
}
bool IsWindows7OrGreater() {
static const auto result = ::IsWindows7OrGreater();
return result;
}
bool IsWindows8OrGreater() {
static const auto result = ::IsWindows8OrGreater();
return result;
}
bool IsWindows8Point1OrGreater() {
static const auto result = ::IsWindows8Point1OrGreater();
return result;
}
bool IsWindows10OrGreater() {
static const auto result = ::IsWindows10OrGreater();
return result;
}
} // namespace Platform

View File

@ -0,0 +1,40 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
namespace Platform {
inline constexpr bool IsWindows() {
return true;
}
inline constexpr bool IsWindowsStoreBuild() {
#ifdef OS_WIN_STORE
return true;
#else // OS_WIN_STORE
return false;
#endif // OS_WIN_STORE
}
inline constexpr bool IsMac() { return false; }
inline constexpr bool IsMacOldBuild() { return false; }
inline constexpr bool IsMacStoreBuild() { return false; }
inline bool IsMac10_6OrGreater() { return false; }
inline bool IsMac10_7OrGreater() { return false; }
inline bool IsMac10_8OrGreater() { return false; }
inline bool IsMac10_9OrGreater() { return false; }
inline bool IsMac10_10OrGreater() { return false; }
inline bool IsMac10_11OrGreater() { return false; }
inline bool IsMac10_12OrGreater() { return false; }
inline bool IsMac10_13OrGreater() { return false; }
inline bool IsMac10_14OrGreater() { return false; }
inline constexpr bool IsLinux() { return false; }
inline constexpr bool IsLinux32Bit() { return false; }
inline constexpr bool IsLinux64Bit() { return false; }
} // namespace Platform

View File

@ -9,41 +9,16 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/crash_reports.h"
#include "core/update_checker.h"
#include "platform/platform_specific.h"
#include "platform/platform_info.h"
#include "platform/win/wrapper_windows_h.h"
#include <shellapi.h>
#include <VersionHelpers.h>
namespace Platform {
namespace {
QString DeviceModel() {
return "PC";
}
QString SystemVersion() {
if (IsWindows10OrGreater()) {
return "Windows 10";
} else if (IsWindows8Point1OrGreater()) {
return "Windows 8.1";
} else if (IsWindows8OrGreater()) {
return "Windows 8";
} else if (IsWindows7OrGreater()) {
return "Windows 7";
} else if (IsWindowsVistaOrGreater()) {
return "Windows Vista";
} else if (IsWindowsXPOrGreater()) {
return "Windows XP";
} else {
return QSysInfo::prettyProductName();
}
}
} // namespace
Launcher::Launcher(int argc, char *argv[])
: Core::Launcher(argc, argv, DeviceModel(), SystemVersion()) {
: Core::Launcher(argc, argv, DeviceModelPretty(), SystemVersionPretty()) {
}
std::optional<QStringList> Launcher::readArgumentsHook(

View File

@ -289,18 +289,6 @@ void finish() {
EventFilter::destroy();
}
QString SystemCountry() {
int chCount = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, 0, 0);
if (chCount && chCount < 128) {
WCHAR wstrCountry[128];
int len = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, wstrCountry, chCount);
if (len) {
return QString::fromStdWString(std::wstring(wstrCountry));
}
}
return QString();
}
bool IsApplicationActive() {
return QApplication::activeWindow() != nullptr;
}
@ -335,170 +323,6 @@ std::optional<crl::time> LastUserInputTime() {
: std::nullopt;
}
namespace {
QString GetLangCodeById(unsigned lngId) {
auto primary = (lngId & 0xFFU);
switch (primary) {
case 0x36: return qsl("af");
case 0x1C: return qsl("sq");
case 0x5E: return qsl("am");
case 0x01: return qsl("ar");
case 0x2B: return qsl("hy");
case 0x4D: return qsl("as");
case 0x2C: return qsl("az");
case 0x45: return qsl("bn");
case 0x6D: return qsl("ba");
case 0x2D: return qsl("eu");
case 0x23: return qsl("be");
case 0x1A:
if (lngId == LANG_CROATIAN) {
return qsl("hr");
} else if (lngId == LANG_BOSNIAN_NEUTRAL || lngId == LANG_BOSNIAN) {
return qsl("bs");
}
return qsl("sr");
break;
case 0x7E: return qsl("br");
case 0x02: return qsl("bg");
case 0x92: return qsl("ku");
case 0x03: return qsl("ca");
case 0x04: return qsl("zh");
case 0x83: return qsl("co");
case 0x05: return qsl("cs");
case 0x06: return qsl("da");
case 0x65: return qsl("dv");
case 0x13: return qsl("nl");
case 0x09: return qsl("en");
case 0x25: return qsl("et");
case 0x38: return qsl("fo");
case 0x0B: return qsl("fi");
case 0x0c: return qsl("fr");
case 0x62: return qsl("fy");
case 0x56: return qsl("gl");
case 0x37: return qsl("ka");
case 0x07: return qsl("de");
case 0x08: return qsl("el");
case 0x6F: return qsl("kl");
case 0x47: return qsl("gu");
case 0x68: return qsl("ha");
case 0x0D: return qsl("he");
case 0x39: return qsl("hi");
case 0x0E: return qsl("hu");
case 0x0F: return qsl("is");
case 0x70: return qsl("ig");
case 0x21: return qsl("id");
case 0x5D: return qsl("iu");
case 0x3C: return qsl("ga");
case 0x34: return qsl("xh");
case 0x35: return qsl("zu");
case 0x10: return qsl("it");
case 0x11: return qsl("ja");
case 0x4B: return qsl("kn");
case 0x3F: return qsl("kk");
case 0x53: return qsl("kh");
case 0x87: return qsl("rw");
case 0x12: return qsl("ko");
case 0x40: return qsl("ky");
case 0x54: return qsl("lo");
case 0x26: return qsl("lv");
case 0x27: return qsl("lt");
case 0x6E: return qsl("lb");
case 0x2F: return qsl("mk");
case 0x3E: return qsl("ms");
case 0x4C: return qsl("ml");
case 0x3A: return qsl("mt");
case 0x81: return qsl("mi");
case 0x4E: return qsl("mr");
case 0x50: return qsl("mn");
case 0x61: return qsl("ne");
case 0x14: return qsl("no");
case 0x82: return qsl("oc");
case 0x48: return qsl("or");
case 0x63: return qsl("ps");
case 0x29: return qsl("fa");
case 0x15: return qsl("pl");
case 0x16: return qsl("pt");
case 0x67: return qsl("ff");
case 0x46: return qsl("pa");
case 0x18: return qsl("ro");
case 0x17: return qsl("rm");
case 0x19: return qsl("ru");
case 0x3B: return qsl("se");
case 0x4F: return qsl("sa");
case 0x32: return qsl("tn");
case 0x59: return qsl("sd");
case 0x5B: return qsl("si");
case 0x1B: return qsl("sk");
case 0x24: return qsl("sl");
case 0x0A: return qsl("es");
case 0x41: return qsl("sw");
case 0x1D: return qsl("sv");
case 0x28: return qsl("tg");
case 0x49: return qsl("ta");
case 0x44: return qsl("tt");
case 0x4A: return qsl("te");
case 0x1E: return qsl("th");
case 0x51: return qsl("bo");
case 0x73: return qsl("ti");
case 0x1F: return qsl("tr");
case 0x42: return qsl("tk");
case 0x22: return qsl("uk");
case 0x20: return qsl("ur");
case 0x80: return qsl("ug");
case 0x43: return qsl("uz");
case 0x2A: return qsl("vi");
case 0x52: return qsl("cy");
case 0x88: return qsl("wo");
case 0x78: return qsl("ii");
case 0x6A: return qsl("yo");
}
return QString();
}
} // namespace
QString SystemLanguage() {
constexpr auto kMaxLanguageLength = 128;
auto uiLanguageId = GetUserDefaultUILanguage();
auto uiLanguageLength = GetLocaleInfo(uiLanguageId, LOCALE_SNAME, nullptr, 0);
if (uiLanguageLength > 0 && uiLanguageLength < kMaxLanguageLength) {
WCHAR uiLanguageWideString[kMaxLanguageLength] = { 0 };
uiLanguageLength = GetLocaleInfo(uiLanguageId, LOCALE_SNAME, uiLanguageWideString, uiLanguageLength);
if (uiLanguageLength <= 0) {
return QString();
}
return QString::fromWCharArray(uiLanguageWideString);
}
auto uiLanguageCodeLength = GetLocaleInfo(uiLanguageId, LOCALE_ILANGUAGE, nullptr, 0);
if (uiLanguageCodeLength > 0 && uiLanguageCodeLength < kMaxLanguageLength) {
WCHAR uiLanguageCodeWideString[kMaxLanguageLength] = { 0 };
uiLanguageCodeLength = GetLocaleInfo(uiLanguageId, LOCALE_ILANGUAGE, uiLanguageCodeWideString, uiLanguageCodeLength);
if (uiLanguageCodeLength <= 0) {
return QString();
}
auto languageCode = 0U;
for (auto i = 0; i != uiLanguageCodeLength; ++i) {
auto ch = uiLanguageCodeWideString[i];
if (!ch) {
break;
}
languageCode *= 0x10U;
if (ch >= WCHAR('0') && ch <= WCHAR('9')) {
languageCode += static_cast<unsigned>(int(ch) - int(WCHAR('0')));
} else if (ch >= WCHAR('A') && ch <= WCHAR('F')) {
languageCode += static_cast<unsigned>(0x0A + int(ch) - int(WCHAR('A')));
} else {
return QString();
}
}
return GetLangCodeById(languageCode);
}
return QString();
}
} // namespace Platform
namespace {

View File

@ -67,23 +67,6 @@ crl::time gPasscodeLastTry = 0;
float64 gRetinaFactor = 1.;
int32 gIntRetinaFactor = 1;
#ifdef Q_OS_WIN
DBIPlatform gPlatform = dbipWindows;
#elif defined OS_MAC_OLD
DBIPlatform gPlatform = dbipMacOld;
#elif defined Q_OS_MAC
DBIPlatform gPlatform = dbipMac;
#elif defined Q_OS_LINUX64
DBIPlatform gPlatform = dbipLinux64;
#elif defined Q_OS_LINUX32
DBIPlatform gPlatform = dbipLinux32;
#else
#error Unknown platform
#endif
QString gPlatformString;
bool gIsElCapitan = false;
bool gIsSnowLeopard = false;
int gOtherOnline = 0;
ReportSpamStatuses gReportSpamStatuses;

View File

@ -157,11 +157,6 @@ DeclareSetting(QString, StartUrl);
DeclareSetting(float64, RetinaFactor);
DeclareSetting(int32, IntRetinaFactor);
DeclareReadSetting(DBIPlatform, Platform);
DeclareReadSetting(QString, PlatformString);
DeclareReadSetting(bool, IsElCapitan);
DeclareReadSetting(bool, IsSnowLeopard);
DeclareSetting(int, OtherOnline);
typedef QMap<uint64, DBIPeerReportSpamStatus> ReportSpamStatuses;

View File

@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "info/profile/info_profile_button.h"
#include "info/profile/info_profile_values.h"
#include "platform/platform_specific.h"
#include "platform/platform_info.h"
#include "lang/lang_keys.h"
#include "core/update_checker.h"
#include "core/application.h"
@ -239,7 +240,7 @@ void SetupUpdate(not_null<Ui::VerticalLayout*> container) {
}
bool HasTray() {
return cSupportTray() || (cPlatform() == dbipWindows);
return cSupportTray() || Platform::IsWindows();
}
void SetupTrayContent(not_null<Ui::VerticalLayout*> container) {
@ -277,7 +278,7 @@ void SetupTrayContent(not_null<Ui::VerticalLayout*> container) {
return (workMode == dbiwmWindowOnly)
|| (workMode == dbiwmWindowAndTray);
};
const auto taskbar = (cPlatform() == dbipWindows)
const auto taskbar = Platform::IsWindows()
? addCheckbox(
lng_settings_workmode_window,
taskbarEnabled())
@ -322,7 +323,7 @@ void SetupTrayContent(not_null<Ui::VerticalLayout*> container) {
}
#ifndef OS_WIN_STORE
if (cPlatform() == dbipWindows) {
if (Platform::IsWindows()) {
const auto minimizedToggled = [] {
return cStartMinimized() && !Global::LocalPasscode();
};

View File

@ -32,6 +32,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/file_utilities.h"
#include "data/data_session.h"
#include "chat_helpers/emoji_sets_manager.h"
#include "platform/platform_info.h"
#include "support/support_common.h"
#include "support/support_templates.h"
#include "auth_session.h"
@ -527,7 +528,7 @@ void SetupMessages(not_null<Ui::VerticalLayout*> container) {
add(SendByType::Enter, lng_settings_send_enter);
add(
SendByType::CtrlEnter,
((cPlatform() == dbipMac || cPlatform() == dbipMacOld)
(Platform::IsMac()
? lng_settings_send_cmdenter
: lng_settings_send_ctrlenter));

View File

@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/localstorage.h"
#include "window/notifications_manager.h"
#include "platform/platform_notifications_manager.h"
#include "platform/platform_info.h"
#include "mainwindow.h"
#include "core/application.h"
#include "auth_session.h"
@ -599,10 +600,9 @@ void SetupNotificationsContent(not_null<Ui::VerticalLayout*> container) {
const auto nativeKey = [&] {
if (!Platform::Notifications::Supported()) {
return LangKey();
} else if (cPlatform() == dbipWindows) {
} else if (Platform::IsWindows()) {
return lng_settings_use_windows;
} else if (cPlatform() == dbipLinux32
|| cPlatform() == dbipLinux64) {
} else if (Platform::IsLinux()) {
return lng_settings_use_native_notifications;
}
return LangKey();
@ -619,7 +619,7 @@ void SetupNotificationsContent(not_null<Ui::VerticalLayout*> container) {
return addCheckbox(nativeKey, Global::NativeNotifications());
}();
const auto advancedSlide = (cPlatform() != dbipMac)
const auto advancedSlide = !Platform::IsMac10_8OrGreater()
? container->add(
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
container,

View File

@ -14,7 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text/text_block.h"
#include "ui/emoji_config.h"
#include "lang/lang_keys.h"
#include "platform/platform_specific.h"
#include "platform/platform_info.h"
#include "boxes/confirm_box.h"
#include "mainwindow.h"
@ -27,25 +27,24 @@ inline int32 countBlockHeight(const ITextBlock *b, const style::TextStyle *st) {
} // namespace
bool chIsBad(QChar ch) {
#ifdef OS_MAC_OLD
if (cIsSnowLeopard() && (ch == 8207 || ch == 8206 || ch == 8288)) {
return true;
}
#endif // OS_MAC_OLD
return (ch == 0)
|| (ch >= 8232 && ch < 8237)
|| (ch >= 65024 && ch < 65040 && ch != 65039)
|| (ch >= 127 && ch < 160 && ch != 156)
|| (Platform::IsMac()
&& !Platform::IsMac10_7OrGreater()
&& (ch == 8207 || ch == 8206 || ch == 8288))
// qt harfbuzz crash see https://github.com/telegramdesktop/tdesktop/issues/4551
|| (cPlatform() == dbipMac && ch == 6158)
|| (Platform::IsMac() && ch == 6158)
// tmp hack see https://bugreports.qt.io/browse/QTBUG-48910
|| (cPlatform() == dbipMac
&& ch >= 0x0B00
|| (Platform::IsMac10_11OrGreater()
&& !Platform::IsMac10_12OrGreater()
&& ch >= 0x0B00
&& ch <= 0x0B7F
&& chIsDiac(ch)
&& cIsElCapitan());
&& chIsDiac(ch));
}
QString textcmdSkipBlock(ushort w, ushort h) {
@ -439,7 +438,7 @@ public:
bool skip = false, isNewLine = multiline && chIsNewline(ch), isSpace = chIsSpace(ch), isDiac = chIsDiac(ch), isTilde = checkTilde && (ch == '~');
if (chIsBad(ch) || ch.isLowSurrogate()) {
skip = true;
} else if (ch == 0xFE0F && (cPlatform() == dbipMac || cPlatform() == dbipMacOld)) {
} else if (ch == 0xFE0F && Platform::IsMac()) {
// Some sequences like 0x0E53 0xFE0F crash OS X harfbuzz text processing :(
skip = true;
} else if (isDiac) {

View File

@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwindow.h"
#include "core/application.h"
#include "platform/platform_info.h"
namespace Fonts {
namespace {
@ -134,7 +135,7 @@ void CreateWidgetStateRecursive(not_null<QWidget*> target) {
if (!target->isWindow()) {
CreateWidgetStateRecursive(target->parentWidget());
WidgetCreator::Create(target);
} else if (!cIsSnowLeopard()) {
} else if (!Platform::IsMac() || Platform::IsMac10_7OrGreater()) {
WidgetCreator::Create(target);
}
}

View File

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/continuous_sliders.h"
#include "base/timer.h"
#include "platform/platform_info.h"
namespace Ui {
namespace {
@ -113,7 +114,7 @@ void ContinuousSlider::wheelEvent(QWheelEvent *e) {
constexpr auto coef = 1. / (step * 10.);
auto deltaX = e->angleDelta().x(), deltaY = e->angleDelta().y();
if (cPlatform() == dbipMac || cPlatform() == dbipMacOld) {
if (Platform::IsMac()) {
deltaY *= -1;
} else {
deltaX *= -1;

View File

@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "emoji_suggestions_data.h"
#include "chat_helpers/emoji_suggestions_helper.h"
#include "chat_helpers/message_field.h" // ConvertTextTagsToEntities
#include "platform/platform_info.h"
#include "window/themes/window_theme.h"
#include "lang/lang_keys.h"
#include "data/data_user.h"
@ -2580,7 +2581,7 @@ bool InputField::ShouldSubmit(
void InputField::keyPressEventInner(QKeyEvent *e) {
bool shift = e->modifiers().testFlag(Qt::ShiftModifier), alt = e->modifiers().testFlag(Qt::AltModifier);
bool macmeta = (cPlatform() == dbipMac || cPlatform() == dbipMacOld) && e->modifiers().testFlag(Qt::ControlModifier) && !e->modifiers().testFlag(Qt::MetaModifier) && !e->modifiers().testFlag(Qt::AltModifier);
bool macmeta = Platform::IsMac() && e->modifiers().testFlag(Qt::ControlModifier) && !e->modifiers().testFlag(Qt::MetaModifier) && !e->modifiers().testFlag(Qt::AltModifier);
bool ctrl = e->modifiers().testFlag(Qt::ControlModifier) || e->modifiers().testFlag(Qt::MetaModifier);
bool enterSubmit = (_mode != Mode::MultiLine)
|| ShouldSubmit(_submitSettings, e->modifiers());

View File

@ -9,20 +9,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/shadow.h"
#include "ui/image/image_prepare.h"
#include "platform/platform_info.h"
#include "platform/platform_specific.h"
#include "mainwindow.h"
#include "core/application.h"
#include "lang/lang_keys.h"
namespace Ui {
namespace {
bool InactiveMacApplication() {
return (cPlatform() == dbipMac || cPlatform() == dbipMacOld)
&& !Platform::IsApplicationActive();
}
} // namespace
PopupMenu::PopupMenu(QWidget *parent, const style::PopupMenu &st)
: RpWidget(parent)
@ -430,7 +423,7 @@ void PopupMenu::popup(const QPoint &p) {
}
void PopupMenu::showMenu(const QPoint &p, PopupMenu *parent, TriggeredSource source) {
if (!parent && InactiveMacApplication()) {
if (!parent && Platform::IsMac() && !Platform::IsApplicationActive()) {
_hiding = false;
_a_opacity.stop();
_a_show.stop();

View File

@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/localstorage.h"
#include "platform/platform_window_title.h"
#include "platform/platform_info.h"
#include "history/history.h"
#include "window/themes/window_theme.h"
#include "window/window_controller.h"
@ -26,10 +27,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_boxes.h"
namespace Window {
namespace {
constexpr auto kInactivePressTimeout = crl::time(200);
constexpr auto kSaveWindowPositionTimeout = crl::time(1000);
} // namespace
QImage LoadLogo() {
return QImage(qsl(":/gui/art/logo_256.png"));
}
@ -96,7 +100,7 @@ QIcon CreateOfficialIcon() {
QIcon CreateIcon() {
auto result = CreateOfficialIcon();
if (cPlatform() == dbipLinux32 || cPlatform() == dbipLinux64) {
if (Platform::IsLinux()) {
return QIcon::fromTheme("telegram", result);
}
return result;
@ -229,7 +233,7 @@ bool MainWindow::hideNoQuit() {
Ui::showChatsList();
return true;
}
} else if (cPlatform() == dbipMac || cPlatform() == dbipMacOld) {
} else if (Platform::IsMac()) {
closeWithoutDestroy();
updateIsActive(Global::OfflineBlurTimeout());
updateGlobalMenu();
@ -335,9 +339,14 @@ HitTestResult MainWindow::hitTest(const QPoint &p) const {
return Window::HitTestResult::None;
}
int MainWindow::computeMinHeight() const {
const auto title = _title ? _title->height() : 0;
return title + st::windowMinHeight;
}
void MainWindow::initSize() {
setMinimumWidth(st::windowMinWidth);
setMinimumHeight((_title ? _title->height() : 0) + st::windowMinHeight);
setMinimumHeight(computeMinHeight());
auto position = cWindowPos();
DEBUG_LOG(("Window Pos: Initializing first %1, %2, %3, %4 (maximized %5)").arg(position.x).arg(position.y).arg(position.w).arg(position.h).arg(Logs::b(position.maximized)));

View File

@ -158,6 +158,8 @@ private:
void showTermsDecline();
void showTermsDelete();
int computeMinHeight() const;
base::Timer _positionUpdatedTimer;
bool _positionInited = false;

View File

@ -564,6 +564,8 @@
<(src_loc)/platform/linux/linux_libs.h
<(src_loc)/platform/linux/file_utilities_linux.cpp
<(src_loc)/platform/linux/file_utilities_linux.h
<(src_loc)/platform/linux/info_linux.cpp
<(src_loc)/platform/linux/info_linux.h
<(src_loc)/platform/linux/launcher_linux.cpp
<(src_loc)/platform/linux/launcher_linux.h
<(src_loc)/platform/linux/main_window_linux.cpp
@ -574,6 +576,8 @@
<(src_loc)/platform/linux/specific_linux.h
<(src_loc)/platform/mac/file_utilities_mac.mm
<(src_loc)/platform/mac/file_utilities_mac.h
<(src_loc)/platform/mac/info_mac.mm
<(src_loc)/platform/mac/info_mac.h
<(src_loc)/platform/mac/launcher_mac.mm
<(src_loc)/platform/mac/launcher_mac.h
<(src_loc)/platform/mac/mac_iconv_helper.c
@ -595,6 +599,8 @@
<(src_loc)/platform/win/audio_win.h
<(src_loc)/platform/win/file_utilities_win.cpp
<(src_loc)/platform/win/file_utilities_win.h
<(src_loc)/platform/win/info_win.cpp
<(src_loc)/platform/win/info_win.h
<(src_loc)/platform/win/launcher_win.cpp
<(src_loc)/platform/win/launcher_win.h
<(src_loc)/platform/win/main_window_win.cpp
@ -615,6 +621,7 @@
<(src_loc)/platform/win/wrapper_wrl_implements_h.h
<(src_loc)/platform/platform_audio.h
<(src_loc)/platform/platform_file_utilities.h
<(src_loc)/platform/platform_info.h
<(src_loc)/platform/platform_launcher.h
<(src_loc)/platform/platform_main_window.h
<(src_loc)/platform/platform_notifications_manager.h