mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Add option to use old tray icon.
New monochrome icon is default for the new installations. Fixes #26983, fixes #26988, fixes #26989, fixes #26991, fixes #27005.
This commit is contained in:
parent
f306b11676
commit
a57eecd420
9 changed files with 83 additions and 19 deletions
|
@ -546,6 +546,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_settings_workmode_tray" = "Show tray icon";
|
||||
"lng_settings_workmode_window" = "Show taskbar icon";
|
||||
"lng_settings_close_to_taskbar" = "Close to taskbar";
|
||||
"lng_settings_monochrome_icon" = "Use monochrome icon";
|
||||
"lng_settings_window_system" = "Window title";
|
||||
"lng_settings_title_chat_name" = "Show chat name";
|
||||
"lng_settings_title_account_name" = "Show active account";
|
||||
|
|
|
@ -344,6 +344,8 @@ QByteArray Settings::serialize() const {
|
|||
for (const auto &id : _recentEmojiSkip) {
|
||||
stream << id;
|
||||
}
|
||||
stream
|
||||
<< qint32(_trayIconMonochrome.current() ? 1 : 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -451,6 +453,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
|||
quint64 macRoundIconDigest = _macRoundIconDigest.value_or(0);
|
||||
qint32 storiesClickTooltipHidden = _storiesClickTooltipHidden.current() ? 1 : 0;
|
||||
base::flat_set<QString> recentEmojiSkip;
|
||||
qint32 trayIconMonochrome = (_trayIconMonochrome.current() ? 1 : 0);
|
||||
|
||||
stream >> themesAccentColors;
|
||||
if (!stream.atEnd()) {
|
||||
|
@ -701,6 +704,12 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!stream.atEnd()) {
|
||||
stream >> trayIconMonochrome;
|
||||
} else {
|
||||
// Let existing clients use the old value.
|
||||
trayIconMonochrome = 0;
|
||||
}
|
||||
if (stream.status() != QDataStream::Ok) {
|
||||
LOG(("App Error: "
|
||||
"Bad data for Core::Settings::constructFromSerialized()"));
|
||||
|
@ -894,6 +903,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
|||
_macRoundIconDigest = macRoundIconDigest ? macRoundIconDigest : std::optional<uint64>();
|
||||
_storiesClickTooltipHidden = (storiesClickTooltipHidden == 1);
|
||||
_recentEmojiSkip = std::move(recentEmojiSkip);
|
||||
_trayIconMonochrome = (trayIconMonochrome == 1);
|
||||
}
|
||||
|
||||
QString Settings::getSoundPath(const QString &key) const {
|
||||
|
|
|
@ -702,6 +702,15 @@ public:
|
|||
[[nodiscard]] rpl::producer<bool> closeToTaskbarChanges() const {
|
||||
return _closeToTaskbar.changes();
|
||||
}
|
||||
void setTrayIconMonochrome(bool value) {
|
||||
_trayIconMonochrome = value;
|
||||
}
|
||||
[[nodiscard]] bool trayIconMonochrome() const {
|
||||
return _trayIconMonochrome.current();
|
||||
}
|
||||
[[nodiscard]] rpl::producer<bool> trayIconMonochromeChanges() const {
|
||||
return _trayIconMonochrome.changes();
|
||||
}
|
||||
|
||||
void setCustomDeviceModel(const QString &model) {
|
||||
_customDeviceModel = model;
|
||||
|
@ -918,6 +927,7 @@ private:
|
|||
rpl::variable<WorkMode> _workMode = WorkMode::WindowAndTray;
|
||||
base::flags<Calls::Group::StickedTooltip> _hiddenGroupCallTooltips;
|
||||
rpl::variable<bool> _closeToTaskbar = false;
|
||||
rpl::variable<bool> _trayIconMonochrome = true;
|
||||
rpl::variable<QString> _customDeviceModel;
|
||||
rpl::variable<Media::RepeatMode> _playerRepeatMode;
|
||||
rpl::variable<Media::OrderMode> _playerOrderMode;
|
||||
|
|
|
@ -67,4 +67,8 @@ private:
|
|||
|
||||
};
|
||||
|
||||
inline bool HasMonochromeSetting() {
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace Platform
|
||||
|
|
|
@ -55,4 +55,8 @@ private:
|
|||
|
||||
};
|
||||
|
||||
inline bool HasMonochromeSetting() {
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace Platform
|
||||
|
|
|
@ -11,6 +11,8 @@ namespace Platform {
|
|||
|
||||
class Tray;
|
||||
|
||||
[[nodiscard]] bool HasMonochromeSetting();
|
||||
|
||||
} // namespace Platform
|
||||
|
||||
// Platform dependent implementations.
|
||||
|
|
|
@ -221,18 +221,19 @@ void Tray::updateIcon() {
|
|||
: !controller->sessionController()
|
||||
? nullptr
|
||||
: &controller->sessionController()->session();
|
||||
const auto monochrome = Core::App().settings().trayIconMonochrome();
|
||||
const auto supportMode = session && session->supportMode();
|
||||
const auto iconSizeWidth = GetSystemMetrics(SM_CXSMICON);
|
||||
|
||||
auto iconSmallPixmap16 = Tray::IconWithCounter(
|
||||
CounterLayerArgs(16, counter, muted),
|
||||
true,
|
||||
true,
|
||||
monochrome,
|
||||
supportMode);
|
||||
auto iconSmallPixmap32 = Tray::IconWithCounter(
|
||||
CounterLayerArgs(32, counter, muted),
|
||||
true,
|
||||
true,
|
||||
monochrome,
|
||||
supportMode);
|
||||
auto iconSmall = QIcon();
|
||||
iconSmall.addPixmap(iconSmallPixmap16);
|
||||
|
@ -339,8 +340,15 @@ QPixmap Tray::IconWithCounter(
|
|||
bool smallIcon,
|
||||
bool monochrome,
|
||||
bool supportMode) {
|
||||
return Ui::PixmapFromImage(
|
||||
ImageIconWithCounter(std::move(args), supportMode, smallIcon, monochrome));
|
||||
return Ui::PixmapFromImage(ImageIconWithCounter(
|
||||
std::move(args),
|
||||
supportMode,
|
||||
smallIcon,
|
||||
monochrome));
|
||||
}
|
||||
|
||||
bool HasMonochromeSetting() {
|
||||
return IsDarkTaskbar().has_value();
|
||||
}
|
||||
|
||||
} // namespace Platform
|
||||
|
|
|
@ -453,18 +453,35 @@ void SetupSystemIntegrationContent(
|
|||
st::settingsCheckboxPadding));
|
||||
};
|
||||
|
||||
const auto settings = &Core::App().settings();
|
||||
if (Platform::TrayIconSupported()) {
|
||||
const auto trayEnabled = [] {
|
||||
const auto workMode = Core::App().settings().workMode();
|
||||
const auto trayEnabled = [=] {
|
||||
const auto workMode = settings->workMode();
|
||||
return (workMode == WorkMode::TrayOnly)
|
||||
|| (workMode == WorkMode::WindowAndTray);
|
||||
};
|
||||
const auto tray = addCheckbox(
|
||||
tr::lng_settings_workmode_tray(),
|
||||
trayEnabled());
|
||||
const auto monochrome = Platform::HasMonochromeSetting()
|
||||
? addSlidingCheckbox(
|
||||
tr::lng_settings_monochrome_icon(),
|
||||
settings->trayIconMonochrome())
|
||||
: nullptr;
|
||||
if (monochrome) {
|
||||
monochrome->toggle(tray->checked(), anim::type::instant);
|
||||
|
||||
const auto taskbarEnabled = [] {
|
||||
const auto workMode = Core::App().settings().workMode();
|
||||
monochrome->entity()->checkedChanges(
|
||||
) | rpl::filter([=](bool value) {
|
||||
return (value != settings->trayIconMonochrome());
|
||||
}) | rpl::start_with_next([=](bool value) {
|
||||
settings->setTrayIconMonochrome(value);
|
||||
Core::App().saveSettingsDelayed();
|
||||
}, monochrome->lifetime());
|
||||
}
|
||||
|
||||
const auto taskbarEnabled = [=] {
|
||||
const auto workMode = settings->workMode();
|
||||
return (workMode == WorkMode::WindowOnly)
|
||||
|| (workMode == WorkMode::WindowAndTray);
|
||||
};
|
||||
|
@ -482,10 +499,10 @@ void SetupSystemIntegrationContent(
|
|||
: WorkMode::WindowOnly;
|
||||
if ((newMode == WorkMode::WindowAndTray
|
||||
|| newMode == WorkMode::TrayOnly)
|
||||
&& Core::App().settings().workMode() != newMode) {
|
||||
&& settings->workMode() != newMode) {
|
||||
cSetSeenTrayTooltip(false);
|
||||
}
|
||||
Core::App().settings().setWorkMode(newMode);
|
||||
settings->setWorkMode(newMode);
|
||||
Core::App().saveSettingsDelayed();
|
||||
};
|
||||
|
||||
|
@ -498,6 +515,9 @@ void SetupSystemIntegrationContent(
|
|||
} else {
|
||||
updateWorkmode();
|
||||
}
|
||||
if (monochrome) {
|
||||
monochrome->toggle(checked, anim::type::normal);
|
||||
}
|
||||
}, tray->lifetime());
|
||||
|
||||
if (taskbar) {
|
||||
|
@ -519,19 +539,19 @@ void SetupSystemIntegrationContent(
|
|||
tr::lng_settings_mac_warn_before_quit(
|
||||
lt_text,
|
||||
rpl::single(Platform::ConfirmQuit::QuitKeysString())),
|
||||
Core::App().settings().macWarnBeforeQuit());
|
||||
settings->macWarnBeforeQuit());
|
||||
warnBeforeQuit->checkedChanges(
|
||||
) | rpl::filter([=](bool checked) {
|
||||
return (checked != Core::App().settings().macWarnBeforeQuit());
|
||||
return (checked != settings->macWarnBeforeQuit());
|
||||
}) | rpl::start_with_next([=](bool checked) {
|
||||
Core::App().settings().setMacWarnBeforeQuit(checked);
|
||||
settings->setMacWarnBeforeQuit(checked);
|
||||
Core::App().saveSettingsDelayed();
|
||||
}, warnBeforeQuit->lifetime());
|
||||
|
||||
#ifndef OS_MAC_STORE
|
||||
const auto enabled = [] {
|
||||
const auto digest = base::Platform::CurrentCustomAppIconDigest();
|
||||
return digest && (Core::App().settings().macRoundIconDigest() == digest);
|
||||
return digest && (settings->macRoundIconDigest() == digest);
|
||||
};
|
||||
const auto roundIcon = addCheckbox(
|
||||
tr::lng_settings_mac_round_icon(),
|
||||
|
@ -548,7 +568,7 @@ void SetupSystemIntegrationContent(
|
|||
}
|
||||
Window::OverrideApplicationIcon(checked ? IconMacRound() : QImage());
|
||||
Core::App().refreshApplicationIcon();
|
||||
Core::App().settings().setMacRoundIconDigest(digest);
|
||||
settings->setMacRoundIconDigest(digest);
|
||||
Core::App().saveSettings();
|
||||
}, roundIcon->lifetime());
|
||||
#endif // OS_MAC_STORE
|
||||
|
@ -557,10 +577,10 @@ void SetupSystemIntegrationContent(
|
|||
if (!Platform::RunInBackground()) {
|
||||
const auto closeToTaskbar = addSlidingCheckbox(
|
||||
tr::lng_settings_close_to_taskbar(),
|
||||
Core::App().settings().closeToTaskbar());
|
||||
settings->closeToTaskbar());
|
||||
|
||||
const auto closeToTaskbarShown = std::make_shared<rpl::variable<bool>>(false);
|
||||
Core::App().settings().workModeValue(
|
||||
settings->workModeValue(
|
||||
) | rpl::start_with_next([=](WorkMode workMode) {
|
||||
*closeToTaskbarShown = !Core::App().tray().has();
|
||||
}, closeToTaskbar->lifetime());
|
||||
|
@ -568,9 +588,9 @@ void SetupSystemIntegrationContent(
|
|||
closeToTaskbar->toggleOn(closeToTaskbarShown->value());
|
||||
closeToTaskbar->entity()->checkedChanges(
|
||||
) | rpl::filter([=](bool checked) {
|
||||
return (checked != Core::App().settings().closeToTaskbar());
|
||||
return (checked != settings->closeToTaskbar());
|
||||
}) | rpl::start_with_next([=](bool checked) {
|
||||
Core::App().settings().setCloseToTaskbar(checked);
|
||||
settings->setCloseToTaskbar(checked);
|
||||
Local::writeSettings();
|
||||
}, closeToTaskbar->lifetime());
|
||||
}
|
||||
|
|
|
@ -39,6 +39,11 @@ void Tray::create() {
|
|||
}
|
||||
}, _tray.lifetime());
|
||||
|
||||
Core::App().settings().trayIconMonochromeChanges(
|
||||
) | rpl::start_with_next([=] {
|
||||
updateIconCounters();
|
||||
}, _tray.lifetime());
|
||||
|
||||
Core::App().passcodeLockChanges(
|
||||
) | rpl::start_with_next([=] {
|
||||
rebuildMenu();
|
||||
|
|
Loading…
Add table
Reference in a new issue