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