2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Support background-run options on Linux.

This commit is contained in:
John Preston
2025-01-14 20:43:14 +04:00
parent de732ba692
commit 530e2a1feb
6 changed files with 117 additions and 36 deletions

View File

@@ -337,7 +337,7 @@ QByteArray Settings::serialize() const {
<< _photoEditorBrush
<< qint32(_groupCallNoiseSuppression ? 1 : 0)
<< qint32(SerializePlaybackSpeed(_voicePlaybackSpeed))
<< qint32(_closeToTaskbar.current() ? 1 : 0)
<< qint32(_closeBehavior)
<< _customDeviceModel.current()
<< qint32(_playerRepeatMode.current())
<< qint32(_playerOrderMode.current())
@@ -493,7 +493,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
QByteArray proxy;
qint32 hiddenGroupCallTooltips = qint32(_hiddenGroupCallTooltips.value());
QByteArray photoEditorBrush = _photoEditorBrush;
qint32 closeToTaskbar = _closeToTaskbar.current() ? 1 : 0;
qint32 closeBehavior = qint32(_closeBehavior);
QString customDeviceModel = _customDeviceModel.current();
qint32 playerRepeatMode = static_cast<qint32>(_playerRepeatMode.current());
qint32 playerOrderMode = static_cast<qint32>(_playerOrderMode.current());
@@ -689,7 +689,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
stream >> voicePlaybackSpeed;
}
if (!stream.atEnd()) {
stream >> closeToTaskbar;
stream >> closeBehavior;
}
if (!stream.atEnd()) {
stream >> customDeviceModel;
@@ -998,7 +998,12 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
: Tooltip(0));
}();
_photoEditorBrush = photoEditorBrush;
_closeToTaskbar = (closeToTaskbar == 1);
const auto uncheckedCloseBehavior = static_cast<CloseBehavior>(closeBehavior);
switch (uncheckedCloseBehavior) {
case CloseBehavior::CloseToTaskbar:
case CloseBehavior::RunInBackground:
case CloseBehavior::Quit: _closeBehavior = uncheckedCloseBehavior; break;
}
_customDeviceModel = customDeviceModel;
_accountsOrder = accountsOrder;
const auto uncheckedPlayerRepeatMode = static_cast<Media::RepeatMode>(playerRepeatMode);

View File

@@ -109,6 +109,11 @@ public:
TrayOnly = 1,
WindowOnly = 2,
};
enum class CloseBehavior {
Quit = 0,
CloseToTaskbar = 1,
RunInBackground = 2,
};
static constexpr auto kDefaultVolume = 0.9;
@@ -745,17 +750,11 @@ public:
_hiddenGroupCallTooltips |= value;
}
void setCloseToTaskbar(bool value) {
_closeToTaskbar = value;
void setCloseBehavior(CloseBehavior value) {
_closeBehavior = value;
}
[[nodiscard]] bool closeToTaskbar() const {
return _closeToTaskbar.current();
}
[[nodiscard]] rpl::producer<bool> closeToTaskbarValue() const {
return _closeToTaskbar.value();
}
[[nodiscard]] rpl::producer<bool> closeToTaskbarChanges() const {
return _closeToTaskbar.changes();
[[nodiscard]] CloseBehavior closeBehavior() const {
return _closeBehavior;
}
void setTrayIconMonochrome(bool value) {
_trayIconMonochrome = value;
@@ -1042,7 +1041,7 @@ private:
bool _disableOpenGL = false;
rpl::variable<WorkMode> _workMode = WorkMode::WindowAndTray;
base::flags<Calls::Group::StickedTooltip> _hiddenGroupCallTooltips;
rpl::variable<bool> _closeToTaskbar = false;
CloseBehavior _closeBehavior = CloseBehavior::Quit;
rpl::variable<bool> _trayIconMonochrome = true;
rpl::variable<QString> _customDeviceModel;
rpl::variable<Media::RepeatMode> _playerRepeatMode;