2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Update icon on macOS, allow changing back.

This commit is contained in:
John Preston
2023-02-28 20:49:45 +04:00
parent c575e61853
commit aa9e56c633
35 changed files with 157 additions and 8 deletions

View File

@@ -1653,16 +1653,27 @@ void Application::quitDelayed() {
}
}
void Application::refreshApplicationIcon() {
const auto session = (domain().started() && domain().active().sessionExists())
? &domain().active().session()
: nullptr;
refreshApplicationIcon(session);
}
void Application::refreshApplicationIcon(Main::Session *session) {
const auto support = session && session->supportMode();
Shortcuts::ToggleSupportShortcuts(support);
Platform::SetApplicationIcon(Window::CreateIcon(
session,
Platform::IsMac()));
}
void Application::startShortcuts() {
Shortcuts::Start();
_domain->activeSessionChanges(
) | rpl::start_with_next([=](Main::Session *session) {
const auto support = session && session->supportMode();
Shortcuts::ToggleSupportShortcuts(support);
Platform::SetApplicationIcon(Window::CreateIcon(
session,
Platform::IsMac()));
refreshApplicationIcon(session);
}, _lifetime);
Shortcuts::Requests(

View File

@@ -304,6 +304,7 @@ public:
// Sandbox interface.
void postponeCall(FnMut<void()> &&callable);
void refreshGlobalProxy();
void refreshApplicationIcon();
void quitPreventFinished();
@@ -349,6 +350,7 @@ private:
void enumerateWindows(
Fn<void(not_null<Window::Controller*>)> callback) const;
void processCreatedWindow(not_null<Window::Controller*> window);
void refreshApplicationIcon(Main::Session *session);
friend void QuitAttempt();
void quitDelayed();

View File

@@ -198,7 +198,8 @@ QByteArray Settings::serialize() const {
+ sizeof(quint64)
+ sizeof(qint32) * 3
+ Serialize::bytearraySize(mediaViewPosition)
+ sizeof(qint32);
+ sizeof(qint32)
+ sizeof(quint64);
auto result = QByteArray();
result.reserve(size);
@@ -331,7 +332,8 @@ QByteArray Settings::serialize() const {
<< qint32(_windowTitleContent.current().hideAccountName ? 1 : 0)
<< qint32(_windowTitleContent.current().hideTotalUnread ? 1 : 0)
<< mediaViewPosition
<< qint32(_ignoreBatterySaving.current() ? 1 : 0);
<< qint32(_ignoreBatterySaving.current() ? 1 : 0)
<< quint64(_macRoundIconDigest.value_or(0));
}
return result;
}
@@ -436,6 +438,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
qint32 hideTotalUnread = _windowTitleContent.current().hideTotalUnread ? 1 : 0;
QByteArray mediaViewPosition;
qint32 ignoreBatterySaving = _ignoreBatterySaving.current() ? 1 : 0;
quint64 macRoundIconDigest = _macRoundIconDigest.value_or(0);
stream >> themesAccentColors;
if (!stream.atEnd()) {
@@ -667,6 +670,9 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
if (!stream.atEnd()) {
stream >> ignoreBatterySaving;
}
if (!stream.atEnd()) {
stream >> macRoundIconDigest;
}
if (stream.status() != QDataStream::Ok) {
LOG(("App Error: "
"Bad data for Core::Settings::constructFromSerialized()"));
@@ -864,6 +870,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
}
}
_ignoreBatterySaving = (ignoreBatterySaving == 1);
_macRoundIconDigest = macRoundIconDigest ? macRoundIconDigest : std::optional<uint64>();
}
QString Settings::getSoundPath(const QString &key) const {

View File

@@ -786,6 +786,12 @@ public:
void setIgnoreBatterySavingValue(bool value) {
_ignoreBatterySaving = value;
}
void setMacRoundIconDigest(std::optional<uint64> value) {
_macRoundIconDigest = value;
}
[[nodiscard]] std::optional<uint64> macRoundIconDigest() const {
return _macRoundIconDigest;
}
[[nodiscard]] static bool ThirdColumnByDefault();
[[nodiscard]] static float64 DefaultDialogsWidthRatio();
@@ -910,6 +916,7 @@ private:
bool _rememberedDeleteMessageOnlyForYou = false;
WindowPosition _mediaViewPosition = { .maximized = 2 };
rpl::variable<bool> _ignoreBatterySaving = false;
std::optional<uint64> _macRoundIconDigest;
bool _tabbedReplacedWithInfo = false; // per-window
rpl::event_stream<bool> _tabbedReplacedWithInfoValue; // per-window