mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Use KSandbox to check flatpak/snap environment
This commit is contained in:
parent
89879e355d
commit
5132fd5010
5 changed files with 16 additions and 31 deletions
|
@ -31,6 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include <QtCore/QJsonDocument>
|
||||
#include <QtCore/QJsonObject>
|
||||
#include <KSandbox>
|
||||
|
||||
extern "C" {
|
||||
#include <openssl/rsa.h>
|
||||
|
@ -1634,16 +1635,14 @@ void UpdateApplication() {
|
|||
return "https://www.microsoft.com/en-us/store/p/telegram-desktop/9nztwsqntd0s";
|
||||
#elif defined OS_MAC_STORE // OS_WIN_STORE
|
||||
return "https://itunes.apple.com/ae/app/telegram-desktop/id946399090";
|
||||
#elif defined Q_OS_UNIX && !defined Q_OS_MAC // OS_WIN_STORE || OS_MAC_STORE
|
||||
if (Platform::InFlatpak()) {
|
||||
#else // OS_WIN_STORE || OS_MAC_STORE
|
||||
if (KSandbox::isFlatpak()) {
|
||||
return "https://flathub.org/apps/details/org.telegram.desktop";
|
||||
} else if (Platform::InSnap()) {
|
||||
} else if (KSandbox::isSnap()) {
|
||||
return "https://snapcraft.io/telegram-desktop";
|
||||
}
|
||||
return "https://desktop.telegram.org";
|
||||
#else // OS_WIN_STORE || OS_MAC_STORE || (defined Q_OS_UNIX && !defined Q_OS_MAC)
|
||||
return "https://desktop.telegram.org";
|
||||
#endif // OS_WIN_STORE || OS_MAC_STORE || (defined Q_OS_UNIX && !defined Q_OS_MAC)
|
||||
#endif // OS_WIN_STORE || OS_MAC_STORE
|
||||
}();
|
||||
UrlClickHandler::Open(url);
|
||||
} else {
|
||||
|
|
|
@ -15,13 +15,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "mtproto/mtproto_response.h"
|
||||
#include "mtproto/mtproto_dc_options.h"
|
||||
#include "mtproto/connection_abstract.h"
|
||||
#include "platform/platform_specific.h"
|
||||
#include "base/random.h"
|
||||
#include "base/qthelp_url.h"
|
||||
#include "base/openssl_help.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "base/platform/base_platform_info.h"
|
||||
|
||||
#include <KSandbox>
|
||||
#include <zlib.h>
|
||||
|
||||
namespace MTP {
|
||||
|
@ -86,15 +86,13 @@ using namespace details;
|
|||
return u" Mac App Store"_q;
|
||||
#elif defined OS_WIN_STORE // OS_MAC_STORE
|
||||
return u" Microsoft Store"_q;
|
||||
#elif defined Q_OS_UNIX && !defined Q_OS_MAC // OS_MAC_STORE || OS_WIN_STORE
|
||||
return Platform::InFlatpak()
|
||||
#else // OS_MAC_STORE || OS_WIN_STORE
|
||||
return KSandbox::isFlatpak()
|
||||
? u" Flatpak"_q
|
||||
: Platform::InSnap()
|
||||
: KSandbox::isSnap()
|
||||
? u" Snap"_q
|
||||
: QString();
|
||||
#else // OS_MAC_STORE || OS_WIN_STORE || (defined Q_OS_UNIX && !defined Q_OS_MAC)
|
||||
return QString();
|
||||
#endif // OS_MAC_STORE || OS_WIN_STORE || (defined Q_OS_UNIX && !defined Q_OS_MAC)
|
||||
#endif // OS_MAC_STORE || OS_WIN_STORE
|
||||
})();
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include <QtCore/QStandardPaths>
|
||||
#include <QtCore/QProcess>
|
||||
#include <KShell>
|
||||
#include <KSandbox>
|
||||
|
||||
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||
#include <glibmm.h>
|
||||
|
@ -264,22 +265,12 @@ void SetApplicationIcon(const QIcon &icon) {
|
|||
QApplication::setWindowIcon(icon);
|
||||
}
|
||||
|
||||
bool InFlatpak() {
|
||||
static const auto Result = QFileInfo::exists(qsl("/.flatpak-info"));
|
||||
return Result;
|
||||
}
|
||||
|
||||
bool InSnap() {
|
||||
static const auto Result = qEnvironmentVariableIsSet("SNAP");
|
||||
return Result;
|
||||
}
|
||||
|
||||
QString AppRuntimeDirectory() {
|
||||
static const auto Result = [&] {
|
||||
auto runtimeDir = QStandardPaths::writableLocation(
|
||||
QStandardPaths::RuntimeLocation);
|
||||
|
||||
if (InFlatpak()) {
|
||||
if (KSandbox::isFlatpak()) {
|
||||
runtimeDir += qsl("/app/") + FlatpakID();
|
||||
}
|
||||
|
||||
|
@ -311,7 +302,7 @@ QString SingleInstanceLocalServerName(const QString &hash) {
|
|||
}
|
||||
|
||||
QString GetIconName() {
|
||||
static const auto Result = InFlatpak()
|
||||
static const auto Result = KSandbox::isFlatpak()
|
||||
? FlatpakID()
|
||||
: kIconName.utf16();
|
||||
return Result;
|
||||
|
@ -363,7 +354,7 @@ bool AutostartSupported() {
|
|||
// in folders with names started with a dot
|
||||
// and doesn't provide any api to add an app to autostart
|
||||
// thus, autostart isn't supported in snap
|
||||
return !InSnap();
|
||||
return !KSandbox::isSnap();
|
||||
}
|
||||
|
||||
void AutostartToggle(bool enabled, Fn<void(bool)> done) {
|
||||
|
@ -374,7 +365,7 @@ void AutostartToggle(bool enabled, Fn<void(bool)> done) {
|
|||
});
|
||||
|
||||
const auto silent = !done;
|
||||
if (InFlatpak()) {
|
||||
if (KSandbox::isFlatpak()) {
|
||||
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||
PortalAutostart(enabled, silent);
|
||||
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||
|
|
|
@ -15,9 +15,6 @@ class LocationPoint;
|
|||
|
||||
namespace Platform {
|
||||
|
||||
bool InFlatpak();
|
||||
bool InSnap();
|
||||
|
||||
QString AppRuntimeDirectory();
|
||||
QString GetIconName();
|
||||
|
||||
|
|
2
cmake
2
cmake
|
@ -1 +1 @@
|
|||
Subproject commit c79563ea343075d97d30fe3a6598775538676515
|
||||
Subproject commit 152fc28f343aff610f5f9dbdff243bbdbda85bf0
|
Loading…
Add table
Reference in a new issue