Compare commits

..

2 Commits

Author SHA1 Message Date
John Preston
a7958f5235 Save custom app icon color with digest to settings. 2022-02-08 16:29:10 +03:00
John Preston
2ae5fc0fac Proof-of-concept macOS app icon change. 2022-02-08 15:21:06 +03:00
13 changed files with 181 additions and 45 deletions

View File

@@ -10,7 +10,7 @@
<Identity Name="TelegramMessengerLLP.TelegramDesktop"
ProcessorArchitecture="ARCHITECTURE"
Publisher="CN=536BC709-8EE1-4478-AF22-F0F0F26FF64A"
Version="3.5.2.0" />
Version="3.5.1.0" />
<Properties>
<DisplayName>Telegram Desktop</DisplayName>
<PublisherDisplayName>Telegram Messenger LLP</PublisherDisplayName>

View File

@@ -44,8 +44,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico"
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,5,2,0
PRODUCTVERSION 3,5,2,0
FILEVERSION 3,5,1,0
PRODUCTVERSION 3,5,1,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -62,10 +62,10 @@ BEGIN
BEGIN
VALUE "CompanyName", "Telegram FZ-LLC"
VALUE "FileDescription", "Telegram Desktop"
VALUE "FileVersion", "3.5.2.0"
VALUE "FileVersion", "3.5.1.0"
VALUE "LegalCopyright", "Copyright (C) 2014-2022"
VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "3.5.2.0"
VALUE "ProductVersion", "3.5.1.0"
END
END
BLOCK "VarFileInfo"

View File

@@ -35,8 +35,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,5,2,0
PRODUCTVERSION 3,5,2,0
FILEVERSION 3,5,1,0
PRODUCTVERSION 3,5,1,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -53,10 +53,10 @@ BEGIN
BEGIN
VALUE "CompanyName", "Telegram FZ-LLC"
VALUE "FileDescription", "Telegram Desktop Updater"
VALUE "FileVersion", "3.5.2.0"
VALUE "FileVersion", "3.5.1.0"
VALUE "LegalCopyright", "Copyright (C) 2014-2022"
VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "3.5.2.0"
VALUE "ProductVersion", "3.5.1.0"
END
END
BLOCK "VarFileInfo"

View File

@@ -66,6 +66,21 @@ constexpr auto kRecentEmojiLimit = 42;
return result;
}
[[nodiscard]] quint32 SerializeColor(QColor color) {
return (quint32(std::clamp(color.alpha(), 0, 255)) << 24)
| (quint32(std::clamp(color.red(), 0, 255)) << 16)
| (quint32(std::clamp(color.green(), 0, 255)) << 8)
| quint32(std::clamp(color.blue(), 0, 255));
}
[[nodiscard]] QColor DeserializeColor(quint32 value) {
return QColor(
(value >> 16) & 0xFF,
(value >> 8) & 0xFF,
value & 0xFF,
(value >> 24) & 0xFF);
}
} // namespace
Settings::Settings()
@@ -236,6 +251,10 @@ QByteArray Settings::serialize() const {
for (const auto &id : _accountsOrder) {
stream << quint64(id);
}
stream
<< SerializeColor(_customAppIcon.color)
<< quint64(_customAppIcon.digest);
}
return result;
}
@@ -325,6 +344,8 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
qint32 macWarnBeforeQuit = _macWarnBeforeQuit ? 1 : 0;
qint32 accountsOrderCount = 0;
std::vector<uint64> accountsOrder;
quint32 customAppIconColor = SerializeColor(_customAppIcon.color);
quint64 customAppIconDigest = _customAppIcon.digest;
stream >> themesAccentColors;
if (!stream.atEnd()) {
@@ -506,6 +527,11 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
}
}
}
if (!stream.atEnd()) {
stream
>> customAppIconColor
>> customAppIconDigest;
}
if (stream.status() != QDataStream::Ok) {
LOG(("App Error: "
"Bad data for Core::Settings::constructFromSerialized()"));
@@ -662,6 +688,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
case Media::Player::OrderMode::Shuffle: _playerOrderMode = uncheckedPlayerOrderMode; break;
}
_macWarnBeforeQuit = macWarnBeforeQuit ? 1 : 0;
_customAppIcon = { DeserializeColor(customAppIconColor), customAppIconDigest };
}
QString Settings::getSoundPath(const QString &key) const {

View File

@@ -51,6 +51,11 @@ struct WindowPosition {
int h = 0;
};
struct CustomAppIcon {
QColor color;
uint64 digest = 0;
};
class Settings final {
public:
enum class ScreenCorner {
@@ -669,6 +674,12 @@ public:
[[nodiscard]] bool macWarnBeforeQuit() const {
return _macWarnBeforeQuit;
}
void setCustomAppIcon(CustomAppIcon icon) {
_customAppIcon = icon;
}
[[nodiscard]] CustomAppIcon customAppIcon() const {
return _customAppIcon;
}
[[nodiscard]] static bool ThirdColumnByDefault();
[[nodiscard]] static float64 DefaultDialogsWidthRatio();
@@ -775,6 +786,7 @@ private:
rpl::variable<Media::Player::OrderMode> _playerOrderMode;
bool _macWarnBeforeQuit = true;
std::vector<uint64> _accountsOrder;
CustomAppIcon _customAppIcon;
bool _tabbedReplacedWithInfo = false; // per-window
rpl::event_stream<bool> _tabbedReplacedWithInfoValue; // per-window

View File

@@ -22,7 +22,7 @@ constexpr auto AppId = "{53F49750-6209-4FBF-9CA8-7A333C87D1ED}"_cs;
constexpr auto AppNameOld = "Telegram Win (Unofficial)"_cs;
constexpr auto AppName = "Telegram Desktop"_cs;
constexpr auto AppFile = "Telegram"_cs;
constexpr auto AppVersion = 3005002;
constexpr auto AppVersionStr = "3.5.2";
constexpr auto AppVersion = 3005001;
constexpr auto AppVersionStr = "3.5.1";
constexpr auto AppBetaVersion = false;
constexpr auto AppAlphaVersion = TDESKTOP_ALPHA_VERSION;

View File

@@ -3399,6 +3399,9 @@ void HistoryWidget::checkSupportPreload(bool force) {
const auto maxId = 0;
const auto minId = 0;
const auto historyHash = uint64(0);
const auto tmp = history->peer->name.toStdString();
const auto tmp2 = _history->peer->name.toStdString();
LOG(("PRELOADING FROM: %1 FOR: %2").arg(_history->peer->name).arg(history->peer->name));
const auto type = Data::Histories::RequestType::History;
auto &histories = history->owner().histories();
_supportPreloadRequest = histories.sendRequest(history, type, [=](Fn<void()> finish) {
@@ -3414,6 +3417,7 @@ void HistoryWidget::checkSupportPreload(bool force) {
)).done([=](const MTPmessages_Messages &result) {
if (const auto around = history->loadAroundId()) {
if (around != offsetId) {
LOG(("RE-PRELOADING FOR: %1").arg(history->peer->name));
_supportPreloadRequest = 0;
_supportPreloadHistory = nullptr;
crl::on_main(this, [=] { checkSupportPreload(); });
@@ -3422,6 +3426,7 @@ void HistoryWidget::checkSupportPreload(bool force) {
history->clear(History::ClearType::Unload);
history->getReadyFor(ShowAtUnreadMsgId);
} else if (offsetId) {
LOG(("RE-PRELOADING FOR: %1").arg(history->peer->name));
_supportPreloadRequest = 0;
_supportPreloadHistory = nullptr;
crl::on_main(this, [=] { checkSupportPreload(); });
@@ -3430,6 +3435,9 @@ void HistoryWidget::checkSupportPreload(bool force) {
history->clear(History::ClearType::Unload);
history->getReadyFor(ShowAtTheEndMsgId);
}
LOG(("PRELOADED FOR: %1").arg(history->peer->name));
auto count = 0;
const QVector<MTPMessage> emptyList, *histList = &emptyList;
result.match([](const MTPDmessages_messagesNotModified&) {
}, [&](const auto &data) {
history->owner().processUsers(data.vusers());

View File

@@ -50,6 +50,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/platform/base_platform_info.h"
#include "platform/platform_specific.h"
#include "base/call_delayed.h"
#include "base/custom_app_icon.h"
#include "support/support_common.h"
#include "support/support_templates.h"
#include "main/main_session.h"
@@ -75,6 +76,11 @@ public:
explicit ColorsPalette(not_null<Ui::VerticalLayout*> container);
void show(Type type);
void show(
std::vector<QColor> &&colors,
int selected,
int customLightnessMin,
int customLightnessMax);
rpl::producer<QColor> selected() const;
@@ -102,11 +108,9 @@ private:
};
void show(
not_null<const Scheme*> scheme,
std::vector<QColor> &&colors,
int selected);
void selectCustom(not_null<const Scheme*> scheme);
void selectCustom(
int customLightnessMin,
int customLightnessMax);
void updateInnerGeometry();
not_null<Ui::SlideWrap<>*> _outer;
@@ -267,20 +271,22 @@ void ColorsPalette::show(Type type) {
0,
int(list.size()) - 1);
_outer->show(anim::type::instant);
show(&*scheme, std::move(list), selected);
const auto inner = _outer->entity();
inner->resize(_outer->width(), inner->height());
updateInnerGeometry();
const auto colorizer = Window::Theme::ColorizerFrom(
*scheme,
scheme->accentColor);
show(
std::move(list),
selected,
colorizer.lightnessMin,
colorizer.lightnessMax);
}
void ColorsPalette::show(
not_null<const Scheme*> scheme,
std::vector<QColor> &&colors,
int selected) {
Expects(selected >= 0 && selected < colors.size());
int selected,
int customLightnessMin,
int customLightnessMax) {
_outer->show(anim::type::instant);
while (_buttons.size() > colors.size()) {
_buttons.pop_back();
@@ -321,25 +327,27 @@ void ColorsPalette::show(
std::move(
clicks
) | rpl::start_with_next([=] {
selectCustom(scheme);
selectCustom(customLightnessMin, customLightnessMax);
}, inner->lifetime());
}
inner->resize(_outer->width(), inner->height());
updateInnerGeometry();
}
void ColorsPalette::selectCustom(not_null<const Scheme*> scheme) {
void ColorsPalette::selectCustom(
int customLightnessMin,
int customLightnessMax) {
const auto selected = ranges::find(_buttons, true, &Button::selected);
Assert(selected != end(_buttons));
const auto colorizer = Window::Theme::ColorizerFrom(
*scheme,
scheme->accentColor);
auto box = Box<EditColorBox>(
tr::lng_settings_theme_accent_title(tr::now),
EditColorBox::Mode::HSL,
(*selected)->color());
box->setLightnessLimits(
colorizer.lightnessMin,
colorizer.lightnessMax);
customLightnessMin,
customLightnessMax);
box->setSaveCallback(crl::guard(_outer, [=](QColor result) {
_selected.fire_copy(result);
}));
@@ -1013,6 +1021,88 @@ void SetupChatBackground(
}, adaptive->lifetime());
}
#if defined Q_OS_MAC && !defined OS_MAC_STORE
void SetupAppIcon(
not_null<Window::Controller*> window,
not_null<Ui::VerticalLayout*> container) {
AddSkip(container, st::settingsPrivacySkip);
container->add(
object_ptr<Ui::FlatLabel>(
container,
rpl::single(u"App Icon"_q),
st::settingsSubsectionTitle),
(st::settingsSubsectionTitlePadding
- QMargins(0, 0, 0, st::settingsSubsectionTitlePadding.bottom())));
const auto palette = Ui::CreateChild<ColorsPalette>(
container.get(),
container.get());
const auto original = QColor(29, 148, 208);
const auto refresh = [=](uint64 currentDigest) {
auto list = Window::Theme::DefaultAccentColors(
Window::Theme::EmbeddedType::Night);
list[0] = original;
const auto current = Core::App().settings().customAppIcon();
const auto selected = !currentDigest
? 0
: (currentDigest != current.digest)
? -1
: std::min(
int(ranges::find(list, current.color) - begin(list)),
int(size(list)) - 1);
if (selected == size(list) - 1) {
list[selected] = current.color;
}
palette->show(std::move(list), selected, 0, 255);
};
refresh(base::CurrentCustomAppIconDigest().value_or(0));
const auto logo = QImage(":/gui/art/logo_256.png").convertToFormat(
QImage::Format_ARGB32);
palette->selected(
) | rpl::start_with_next([=](QColor color) {
if (color == original) {
const auto success = base::ClearCustomAppIcon();
if (success) {
Core::App().settings().setCustomAppIcon({});
Core::App().saveSettingsDelayed();
refresh(0);
}
Ui::Toast::Show(success
? "Icon cleared. Restarting the Dock."
: "Icon clear failed. See log.txt for details.");
} else {
auto colorizer = style::colorizer{
.hueThreshold = 64,
};
original.getHsv(
&colorizer.was.hue,
&colorizer.was.saturation,
&colorizer.was.value);
color.getHsv(
&colorizer.now.hue,
&colorizer.now.saturation,
&colorizer.now.value);
auto image = logo;
style::colorize(image, colorizer);
const auto digest = base::SetCustomAppIcon(std::move(image));
if (digest) {
Core::App().settings().setCustomAppIcon({ color, *digest });
Core::App().saveSettingsDelayed();
refresh(*digest);
}
Ui::Toast::Show(digest
? "Icon updated. Restarting the Dock."
: "Icon update failed. See log.txt for details.");
}
}, container->lifetime());
AddSkip(container);
AddDivider(container);
}
#endif // Q_OS_MAC && !OS_MAC_STORE
void SetupDefaultThemes(
not_null<Window::Controller*> window,
not_null<Ui::VerticalLayout*> container) {
@@ -1483,6 +1573,10 @@ Chat::Chat(QWidget *parent, not_null<Window::SessionController*> controller)
void Chat::setupContent(not_null<Window::SessionController*> controller) {
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
#if defined Q_OS_MAC && !defined OS_MAC_STORE
SetupAppIcon(&controller->window(), content);
#endif // Q_OS_MAC && !OS_MAC_STORE
SetupThemeOptions(controller, content);
SetupAutoNightMode(controller, content);
SetupCloudThemes(controller, content);

View File

@@ -4,6 +4,6 @@ pushd `dirname $0` > /dev/null
FullScriptPath=`pwd`
popd > /dev/null
python3 $FullScriptPath/set_version.py $1
python $FullScriptPath/set_version.py $1
exit

View File

@@ -1,7 +1,7 @@
AppVersion 3005002
AppVersion 3005001
AppVersionStrMajor 3.5
AppVersionStrSmall 3.5.2
AppVersionStr 3.5.2
AppVersionStrSmall 3.5.1
AppVersionStr 3.5.1
BetaChannel 0
AlphaVersion 0
AppVersionOriginal 3.5.2
AppVersionOriginal 3.5.1

View File

@@ -1,8 +1,3 @@
3.5.2 (06.02.22)
- Fix a freeze in audio playback on Linux.
- Fix a crash in screen sharing initialization on Linux.
3.5.1 (04.02.22)
- Keep the screen on while watching a video or participating in a video chat.

2
cmake

Submodule cmake updated: 3604a7f023...6d81711cf8