Implement close to taskbar option
This commit is contained in:
parent
ce256161f1
commit
e92ae40ecb
|
@ -357,6 +357,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_settings_update_fail" = "Update check failed :(";
|
"lng_settings_update_fail" = "Update check failed :(";
|
||||||
"lng_settings_workmode_tray" = "Show tray icon";
|
"lng_settings_workmode_tray" = "Show tray icon";
|
||||||
"lng_settings_workmode_window" = "Show taskbar icon";
|
"lng_settings_workmode_window" = "Show taskbar icon";
|
||||||
|
"lng_settings_close_to_taskbar" = "Close to taskbar";
|
||||||
"lng_settings_native_frame" = "Use system window frame";
|
"lng_settings_native_frame" = "Use system window frame";
|
||||||
"lng_settings_auto_start" = "Launch Telegram when system starts";
|
"lng_settings_auto_start" = "Launch Telegram when system starts";
|
||||||
"lng_settings_start_min" = "Launch minimized";
|
"lng_settings_start_min" = "Launch minimized";
|
||||||
|
|
|
@ -220,7 +220,8 @@ QByteArray Settings::serialize() const {
|
||||||
<< qint32(_disableOpenGL ? 1 : 0)
|
<< qint32(_disableOpenGL ? 1 : 0)
|
||||||
<< _photoEditorBrush
|
<< _photoEditorBrush
|
||||||
<< qint32(_groupCallNoiseSuppression ? 1 : 0)
|
<< qint32(_groupCallNoiseSuppression ? 1 : 0)
|
||||||
<< qint32(_voicePlaybackSpeed * 100);
|
<< qint32(_voicePlaybackSpeed * 100)
|
||||||
|
<< qint32(_closeToTaskbar.current() ? 1 : 0);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -303,6 +304,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
||||||
QByteArray proxy;
|
QByteArray proxy;
|
||||||
qint32 hiddenGroupCallTooltips = qint32(_hiddenGroupCallTooltips.value());
|
qint32 hiddenGroupCallTooltips = qint32(_hiddenGroupCallTooltips.value());
|
||||||
QByteArray photoEditorBrush = _photoEditorBrush;
|
QByteArray photoEditorBrush = _photoEditorBrush;
|
||||||
|
qint32 closeToTaskbar = _closeToTaskbar.current() ? 1 : 0;
|
||||||
|
|
||||||
stream >> themesAccentColors;
|
stream >> themesAccentColors;
|
||||||
if (!stream.atEnd()) {
|
if (!stream.atEnd()) {
|
||||||
|
@ -460,6 +462,9 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
||||||
if (!stream.atEnd()) {
|
if (!stream.atEnd()) {
|
||||||
stream >> voicePlaybackSpeed;
|
stream >> voicePlaybackSpeed;
|
||||||
}
|
}
|
||||||
|
if (!stream.atEnd()) {
|
||||||
|
stream >> closeToTaskbar;
|
||||||
|
}
|
||||||
if (stream.status() != QDataStream::Ok) {
|
if (stream.status() != QDataStream::Ok) {
|
||||||
LOG(("App Error: "
|
LOG(("App Error: "
|
||||||
"Bad data for Core::Settings::constructFromSerialized()"));
|
"Bad data for Core::Settings::constructFromSerialized()"));
|
||||||
|
@ -600,6 +605,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
||||||
: Tooltip(0));
|
: Tooltip(0));
|
||||||
}();
|
}();
|
||||||
_photoEditorBrush = photoEditorBrush;
|
_photoEditorBrush = photoEditorBrush;
|
||||||
|
_closeToTaskbar = (closeToTaskbar == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Settings::getSoundPath(const QString &key) const {
|
QString Settings::getSoundPath(const QString &key) const {
|
||||||
|
|
|
@ -601,6 +601,19 @@ public:
|
||||||
_hiddenGroupCallTooltips |= value;
|
_hiddenGroupCallTooltips |= value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setCloseToTaskbar(bool value) {
|
||||||
|
_closeToTaskbar = 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]] static bool ThirdColumnByDefault();
|
[[nodiscard]] static bool ThirdColumnByDefault();
|
||||||
[[nodiscard]] static float64 DefaultDialogsWidthRatio();
|
[[nodiscard]] static float64 DefaultDialogsWidthRatio();
|
||||||
[[nodiscard]] static qint32 SerializePlaybackSpeed(float64 speed) {
|
[[nodiscard]] static qint32 SerializePlaybackSpeed(float64 speed) {
|
||||||
|
@ -700,6 +713,7 @@ private:
|
||||||
bool _disableOpenGL = false;
|
bool _disableOpenGL = false;
|
||||||
rpl::variable<WorkMode> _workMode = WorkMode::WindowAndTray;
|
rpl::variable<WorkMode> _workMode = WorkMode::WindowAndTray;
|
||||||
base::flags<Calls::Group::StickedTooltip> _hiddenGroupCallTooltips;
|
base::flags<Calls::Group::StickedTooltip> _hiddenGroupCallTooltips;
|
||||||
|
rpl::variable<bool> _closeToTaskbar = false;
|
||||||
|
|
||||||
bool _tabbedReplacedWithInfo = false; // per-window
|
bool _tabbedReplacedWithInfo = false; // per-window
|
||||||
rpl::event_stream<bool> _tabbedReplacedWithInfoValue; // per-window
|
rpl::event_stream<bool> _tabbedReplacedWithInfoValue; // per-window
|
||||||
|
|
|
@ -464,6 +464,7 @@ void Launcher::processArguments() {
|
||||||
{ "-noupdate" , KeyFormat::NoValues },
|
{ "-noupdate" , KeyFormat::NoValues },
|
||||||
{ "-tosettings" , KeyFormat::NoValues },
|
{ "-tosettings" , KeyFormat::NoValues },
|
||||||
{ "-startintray" , KeyFormat::NoValues },
|
{ "-startintray" , KeyFormat::NoValues },
|
||||||
|
{ "-quit" , KeyFormat::NoValues },
|
||||||
{ "-sendpath" , KeyFormat::AllLeftValues },
|
{ "-sendpath" , KeyFormat::AllLeftValues },
|
||||||
{ "-workdir" , KeyFormat::OneValue },
|
{ "-workdir" , KeyFormat::OneValue },
|
||||||
{ "--" , KeyFormat::OneValue },
|
{ "--" , KeyFormat::OneValue },
|
||||||
|
@ -504,6 +505,7 @@ void Launcher::processArguments() {
|
||||||
gNoStartUpdate = parseResult.contains("-noupdate");
|
gNoStartUpdate = parseResult.contains("-noupdate");
|
||||||
gStartToSettings = parseResult.contains("-tosettings");
|
gStartToSettings = parseResult.contains("-tosettings");
|
||||||
gStartInTray = parseResult.contains("-startintray");
|
gStartInTray = parseResult.contains("-startintray");
|
||||||
|
gQuit = parseResult.contains("-quit");
|
||||||
gSendPaths = parseResult.value("-sendpath", {});
|
gSendPaths = parseResult.value("-sendpath", {});
|
||||||
gWorkingDir = parseResult.value("-workdir", {}).join(QString());
|
gWorkingDir = parseResult.value("-workdir", {}).join(QString());
|
||||||
if (!gWorkingDir.isEmpty()) {
|
if (!gWorkingDir.isEmpty()) {
|
||||||
|
|
|
@ -237,6 +237,8 @@ void Sandbox::socketConnected() {
|
||||||
}
|
}
|
||||||
if (!cStartUrl().isEmpty()) {
|
if (!cStartUrl().isEmpty()) {
|
||||||
commands += qsl("OPEN:") + _escapeTo7bit(cStartUrl()) + ';';
|
commands += qsl("OPEN:") + _escapeTo7bit(cStartUrl()) + ';';
|
||||||
|
} else if (cQuit()) {
|
||||||
|
commands += qsl("CMD:quit;");
|
||||||
} else {
|
} else {
|
||||||
commands += qsl("CMD:show;");
|
commands += qsl("CMD:show;");
|
||||||
}
|
}
|
||||||
|
@ -305,6 +307,10 @@ void Sandbox::socketError(QLocalSocket::LocalSocketError e) {
|
||||||
return App::quit();
|
return App::quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cQuit()) {
|
||||||
|
return App::quit();
|
||||||
|
}
|
||||||
|
|
||||||
singleInstanceChecked();
|
singleInstanceChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -605,6 +611,8 @@ void Sandbox::execExternal(const QString &cmd) {
|
||||||
} else if (PreLaunchWindow::instance()) {
|
} else if (PreLaunchWindow::instance()) {
|
||||||
PreLaunchWindow::instance()->activate();
|
PreLaunchWindow::instance()->activate();
|
||||||
}
|
}
|
||||||
|
} else if (cmd == "quit") {
|
||||||
|
App::quit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -315,12 +315,18 @@ bool GenerateDesktopFile(
|
||||||
|
|
||||||
fileText = fileText.replace(
|
fileText = fileText.replace(
|
||||||
QRegularExpression(
|
QRegularExpression(
|
||||||
qsl("^Exec=.*$"),
|
qsl("^Exec=telegram-desktop(.*)$"),
|
||||||
QRegularExpression::MultilineOption),
|
QRegularExpression::MultilineOption),
|
||||||
qsl("Exec=%1 -workdir %2").arg(
|
qsl("Exec=%1 -workdir %2\\1").arg(
|
||||||
EscapeShellInLauncher(cExeDir() + cExeName()),
|
EscapeShellInLauncher(cExeDir() + cExeName()),
|
||||||
EscapeShellInLauncher(cWorkingDir()))
|
EscapeShellInLauncher(cWorkingDir())));
|
||||||
+ (args.isEmpty() ? QString() : ' ' + args));
|
|
||||||
|
fileText = fileText.replace(
|
||||||
|
QRegularExpression(
|
||||||
|
qsl("^Exec=(.*) -- %u$"),
|
||||||
|
QRegularExpression::MultilineOption),
|
||||||
|
qsl("Exec=\\1%1").arg(
|
||||||
|
args.isEmpty() ? QString() : ' ' + args));
|
||||||
|
|
||||||
target.write(fileText.toUtf8());
|
target.write(fileText.toUtf8());
|
||||||
target.close();
|
target.close();
|
||||||
|
|
|
@ -35,6 +35,7 @@ bool gAutoUpdate = true;
|
||||||
LaunchMode gLaunchMode = LaunchModeNormal;
|
LaunchMode gLaunchMode = LaunchModeNormal;
|
||||||
bool gSeenTrayTooltip = false;
|
bool gSeenTrayTooltip = false;
|
||||||
bool gRestartingUpdate = false, gRestarting = false, gRestartingToSettings = false, gWriteProtected = false;
|
bool gRestartingUpdate = false, gRestarting = false, gRestartingToSettings = false, gWriteProtected = false;
|
||||||
|
bool gQuit = false;
|
||||||
int32 gLastUpdateCheck = 0;
|
int32 gLastUpdateCheck = 0;
|
||||||
bool gNoStartUpdate = false;
|
bool gNoStartUpdate = false;
|
||||||
bool gStartToSettings = false;
|
bool gStartToSettings = false;
|
||||||
|
|
|
@ -77,6 +77,7 @@ DeclareSetting(bool, NoStartUpdate);
|
||||||
DeclareSetting(bool, StartToSettings);
|
DeclareSetting(bool, StartToSettings);
|
||||||
DeclareSetting(bool, DebugMode);
|
DeclareSetting(bool, DebugMode);
|
||||||
DeclareReadSetting(bool, ManyInstance);
|
DeclareReadSetting(bool, ManyInstance);
|
||||||
|
DeclareSetting(bool, Quit);
|
||||||
|
|
||||||
DeclareSetting(QByteArray, LocalSalt);
|
DeclareSetting(QByteArray, LocalSalt);
|
||||||
DeclareSetting(int, ScreenScale);
|
DeclareSetting(int, ScreenScale);
|
||||||
|
|
|
@ -346,6 +346,7 @@ void SetupSystemIntegrationContent(
|
||||||
checkbox(std::move(label), checked),
|
checkbox(std::move(label), checked),
|
||||||
st::settingsCheckboxPadding));
|
st::settingsCheckboxPadding));
|
||||||
};
|
};
|
||||||
|
|
||||||
if (Platform::TrayIconSupported()) {
|
if (Platform::TrayIconSupported()) {
|
||||||
const auto trayEnabled = [] {
|
const auto trayEnabled = [] {
|
||||||
const auto workMode = Core::App().settings().workMode();
|
const auto workMode = Core::App().settings().workMode();
|
||||||
|
@ -406,6 +407,29 @@ void SetupSystemIntegrationContent(
|
||||||
}, taskbar->lifetime());
|
}, taskbar->lifetime());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Platform::IsMac()) {
|
||||||
|
const auto closeToTaskbar = addSlidingCheckbox(
|
||||||
|
tr::lng_settings_close_to_taskbar(),
|
||||||
|
Core::App().settings().closeToTaskbar());
|
||||||
|
|
||||||
|
const auto closeToTaskbarShown = std::make_shared<rpl::variable<bool>>(false);
|
||||||
|
Core::App().settings().workModeValue(
|
||||||
|
) | rpl::start_with_next([=](WorkMode workMode) {
|
||||||
|
*closeToTaskbarShown = (workMode == WorkMode::WindowOnly)
|
||||||
|
|| !Platform::TrayIconSupported();
|
||||||
|
}, closeToTaskbar->lifetime());
|
||||||
|
|
||||||
|
closeToTaskbar->toggleOn(closeToTaskbarShown->value());
|
||||||
|
closeToTaskbar->entity()->checkedChanges(
|
||||||
|
) | rpl::filter([=](bool checked) {
|
||||||
|
return (checked != Core::App().settings().closeToTaskbar());
|
||||||
|
}) | rpl::start_with_next([=](bool checked) {
|
||||||
|
Core::App().settings().setCloseToTaskbar(checked);
|
||||||
|
Local::writeSettings();
|
||||||
|
}, closeToTaskbar->lifetime());
|
||||||
|
}
|
||||||
|
|
||||||
if (Ui::Platform::NativeWindowFrameSupported()) {
|
if (Ui::Platform::NativeWindowFrameSupported()) {
|
||||||
const auto nativeFrame = addCheckbox(
|
const auto nativeFrame = addCheckbox(
|
||||||
tr::lng_settings_native_frame(),
|
tr::lng_settings_native_frame(),
|
||||||
|
@ -419,6 +443,7 @@ void SetupSystemIntegrationContent(
|
||||||
Core::App().saveSettingsDelayed();
|
Core::App().saveSettingsDelayed();
|
||||||
}, nativeFrame->lifetime());
|
}, nativeFrame->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Platform::AutostartSupported() && controller) {
|
if (Platform::AutostartSupported() && controller) {
|
||||||
const auto minimizedToggled = [=] {
|
const auto minimizedToggled = [=] {
|
||||||
return cStartMinimized()
|
return cStartMinimized()
|
||||||
|
|
|
@ -213,8 +213,13 @@ bool MainWindow::hideNoQuit() {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (Platform::IsMac()) {
|
}
|
||||||
closeWithoutDestroy();
|
if (Platform::IsMac() || Core::App().settings().closeToTaskbar()) {
|
||||||
|
if (Platform::IsMac()) {
|
||||||
|
closeWithoutDestroy();
|
||||||
|
} else {
|
||||||
|
setWindowState(window()->windowState() | Qt::WindowMinimized);
|
||||||
|
}
|
||||||
controller().updateIsActiveBlur();
|
controller().updateIsActiveBlur();
|
||||||
updateGlobalMenu();
|
updateGlobalMenu();
|
||||||
if (const auto controller = sessionController()) {
|
if (const auto controller = sessionController()) {
|
||||||
|
|
|
@ -11,4 +11,10 @@ Type=Application
|
||||||
Categories=Chat;Network;InstantMessaging;Qt;
|
Categories=Chat;Network;InstantMessaging;Qt;
|
||||||
MimeType=x-scheme-handler/tg;
|
MimeType=x-scheme-handler/tg;
|
||||||
Keywords=tg;chat;im;messaging;messenger;sms;tdesktop;
|
Keywords=tg;chat;im;messaging;messenger;sms;tdesktop;
|
||||||
|
Actions=Quit;
|
||||||
X-GNOME-UsesNotifications=true
|
X-GNOME-UsesNotifications=true
|
||||||
|
|
||||||
|
[Desktop Action Quit]
|
||||||
|
Exec=telegram-desktop -quit
|
||||||
|
Name=Quit Telegram
|
||||||
|
Icon=application-exit
|
||||||
|
|
Loading…
Reference in New Issue