mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
videoplayer cheat code -> experimental setting
This commit is contained in:
parent
01d6cacee5
commit
1f1cd35d57
10 changed files with 19 additions and 22 deletions
|
@ -32,6 +32,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "platform/platform_specific.h"
|
#include "platform/platform_specific.h"
|
||||||
#include "platform/platform_file_utilities.h"
|
#include "platform/platform_file_utilities.h"
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
|
#include "base/options.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/history_item.h"
|
#include "history/history_item.h"
|
||||||
#include "history/view/media/history_view_gif.h"
|
#include "history/view/media/history_view_gif.h"
|
||||||
|
@ -1312,10 +1313,12 @@ bool DocumentData::useStreamingLoader() const {
|
||||||
bool DocumentData::canBeStreamed(HistoryItem *item) const {
|
bool DocumentData::canBeStreamed(HistoryItem *item) const {
|
||||||
// Streaming couldn't be used with external player
|
// Streaming couldn't be used with external player
|
||||||
// Maybe someone brave will implement this once upon a time...
|
// Maybe someone brave will implement this once upon a time...
|
||||||
|
static const auto &ExternalVideoPlayer = base::options::lookup<bool>(
|
||||||
|
Data::kOptionExternalVideoPlayer);
|
||||||
return hasRemoteLocation()
|
return hasRemoteLocation()
|
||||||
&& supportsStreaming()
|
&& supportsStreaming()
|
||||||
&& (!isVideoFile()
|
&& (!isVideoFile()
|
||||||
|| !cUseExternalVideoPlayer()
|
|| !ExternalVideoPlayer.value()
|
||||||
|| (item && !item->allowsForward()));
|
|| (item && !item->allowsForward()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "data/data_document_resolver.h"
|
#include "data/data_document_resolver.h"
|
||||||
|
|
||||||
|
#include "base/options.h"
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
#include "ui/boxes/confirm_box.h"
|
#include "ui/boxes/confirm_box.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
|
@ -36,6 +37,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
base::options::toggle OptionExternalVideoPlayer({
|
||||||
|
.id = kOptionExternalVideoPlayer,
|
||||||
|
.name = "External video player",
|
||||||
|
});
|
||||||
|
|
||||||
void ConfirmDontWarnBox(
|
void ConfirmDontWarnBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
rpl::producer<TextWithEntities> &&text,
|
rpl::producer<TextWithEntities> &&text,
|
||||||
|
@ -117,6 +123,8 @@ void LaunchWithWarning(
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
const char kOptionExternalVideoPlayer[] = "external-video-player";
|
||||||
|
|
||||||
QString FileExtension(const QString &filepath) {
|
QString FileExtension(const QString &filepath) {
|
||||||
const auto reversed = ranges::views::reverse(filepath);
|
const auto reversed = ranges::views::reverse(filepath);
|
||||||
const auto last = ranges::find_first_of(reversed, ".\\/");
|
const auto last = ranges::find_first_of(reversed, ".\\/");
|
||||||
|
@ -241,7 +249,7 @@ void ResolveDocument(
|
||||||
const auto msgId = item ? item->fullId() : FullMsgId();
|
const auto msgId = item ? item->fullId() : FullMsgId();
|
||||||
|
|
||||||
const auto showDocument = [&] {
|
const auto showDocument = [&] {
|
||||||
if (cUseExternalVideoPlayer()
|
if (OptionExternalVideoPlayer.value()
|
||||||
&& document->isVideoFile()
|
&& document->isVideoFile()
|
||||||
&& !document->filepath().isEmpty()) {
|
&& !document->filepath().isEmpty()) {
|
||||||
File::Launch(document->location(false).fname);
|
File::Launch(document->location(false).fname);
|
||||||
|
|
|
@ -20,6 +20,8 @@ namespace Data {
|
||||||
|
|
||||||
class DocumentMedia;
|
class DocumentMedia;
|
||||||
|
|
||||||
|
extern const char kOptionExternalVideoPlayer[];
|
||||||
|
|
||||||
[[nodiscard]] QString FileExtension(const QString &filepath);
|
[[nodiscard]] QString FileExtension(const QString &filepath);
|
||||||
// [[nodiscard]] bool IsValidMediaFile(const QString &filepath);
|
// [[nodiscard]] bool IsValidMediaFile(const QString &filepath);
|
||||||
[[nodiscard]] bool IsExecutableName(const QString &filepath);
|
[[nodiscard]] bool IsExecutableName(const QString &filepath);
|
||||||
|
|
|
@ -29,7 +29,6 @@ bool gStartMinimized = false;
|
||||||
bool gStartInTray = false;
|
bool gStartInTray = false;
|
||||||
bool gAutoStart = false;
|
bool gAutoStart = false;
|
||||||
bool gSendToMenu = false;
|
bool gSendToMenu = false;
|
||||||
bool gUseExternalVideoPlayer = false;
|
|
||||||
bool gAutoUpdate = true;
|
bool gAutoUpdate = true;
|
||||||
LaunchMode gLaunchMode = LaunchModeNormal;
|
LaunchMode gLaunchMode = LaunchModeNormal;
|
||||||
bool gSeenTrayTooltip = false;
|
bool gSeenTrayTooltip = false;
|
||||||
|
|
|
@ -38,7 +38,6 @@ DeclareSetting(bool, AutoStart);
|
||||||
DeclareSetting(bool, StartMinimized);
|
DeclareSetting(bool, StartMinimized);
|
||||||
DeclareSetting(bool, StartInTray);
|
DeclareSetting(bool, StartInTray);
|
||||||
DeclareSetting(bool, SendToMenu);
|
DeclareSetting(bool, SendToMenu);
|
||||||
DeclareSetting(bool, UseExternalVideoPlayer);
|
|
||||||
enum LaunchMode {
|
enum LaunchMode {
|
||||||
LaunchModeNormal = 0,
|
LaunchModeNormal = 0,
|
||||||
LaunchModeAutoStart,
|
LaunchModeAutoStart,
|
||||||
|
|
|
@ -116,19 +116,6 @@ auto GenerateCodes() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
codes.emplace(u"videoplayer"_q, [](SessionController *window) {
|
|
||||||
if (!window) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto text = cUseExternalVideoPlayer()
|
|
||||||
? u"Use internal video player?"_q
|
|
||||||
: u"Use external video player?"_q;
|
|
||||||
Ui::show(Ui::MakeConfirmBox({ text, [=] {
|
|
||||||
cSetUseExternalVideoPlayer(!cUseExternalVideoPlayer());
|
|
||||||
window->session().saveSettingsDelayed();
|
|
||||||
Ui::hideLayer();
|
|
||||||
} }));
|
|
||||||
});
|
|
||||||
codes.emplace(u"endpoints"_q, [](SessionController *window) {
|
codes.emplace(u"endpoints"_q, [](SessionController *window) {
|
||||||
if (!Core::App().domain().started()) {
|
if (!Core::App().domain().started()) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -28,6 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "window/notifications_manager.h"
|
#include "window/notifications_manager.h"
|
||||||
#include "settings/settings_common.h"
|
#include "settings/settings_common.h"
|
||||||
#include "storage/localimageloader.h"
|
#include "storage/localimageloader.h"
|
||||||
|
#include "data/data_document_resolver.h"
|
||||||
#include "styles/style_settings.h"
|
#include "styles/style_settings.h"
|
||||||
#include "styles/style_layers.h"
|
#include "styles/style_layers.h"
|
||||||
|
|
||||||
|
@ -148,6 +149,7 @@ void SetupExperimental(
|
||||||
addToggle(kOptionAutoScrollInactiveChat);
|
addToggle(kOptionAutoScrollInactiveChat);
|
||||||
addToggle(Window::Notifications::kOptionGNotification);
|
addToggle(Window::Notifications::kOptionGNotification);
|
||||||
addToggle(Core::kOptionFreeType);
|
addToggle(Core::kOptionFreeType);
|
||||||
|
addToggle(Data::kOptionExternalVideoPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -192,12 +192,10 @@ bool ReadSetting(
|
||||||
cSetSendToMenu(v == 1);
|
cSetSendToMenu(v == 1);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dbiUseExternalVideoPlayer: {
|
case dbiUseExternalVideoPlayerOld: {
|
||||||
qint32 v;
|
qint32 v;
|
||||||
stream >> v;
|
stream >> v;
|
||||||
if (!CheckStreamStatus(stream)) return false;
|
if (!CheckStreamStatus(stream)) return false;
|
||||||
|
|
||||||
cSetUseExternalVideoPlayer(v == 1);
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dbiCacheSettingsOld: {
|
case dbiCacheSettingsOld: {
|
||||||
|
|
|
@ -140,7 +140,7 @@ enum {
|
||||||
dbiNotificationsCornerOld = 0x46,
|
dbiNotificationsCornerOld = 0x46,
|
||||||
dbiThemeKeyOld = 0x47,
|
dbiThemeKeyOld = 0x47,
|
||||||
dbiDialogsWidthRatioOld = 0x48,
|
dbiDialogsWidthRatioOld = 0x48,
|
||||||
dbiUseExternalVideoPlayer = 0x49,
|
dbiUseExternalVideoPlayerOld = 0x49,
|
||||||
dbiDcOptionsOld = 0x4a,
|
dbiDcOptionsOld = 0x4a,
|
||||||
dbiMtpAuthorization = 0x4b,
|
dbiMtpAuthorization = 0x4b,
|
||||||
dbiLastSeenWarningSeenOld = 0x4c,
|
dbiLastSeenWarningSeenOld = 0x4c,
|
||||||
|
|
|
@ -860,7 +860,6 @@ void Account::writeSessionSettings(Main::SessionSettings *stored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
EncryptedDescriptor data(size);
|
EncryptedDescriptor data(size);
|
||||||
data.stream << quint32(dbiUseExternalVideoPlayer) << qint32(cUseExternalVideoPlayer());
|
|
||||||
data.stream << quint32(dbiCacheSettings) << qint64(_cacheTotalSizeLimit) << qint32(_cacheTotalTimeLimit) << qint64(_cacheBigFileTotalSizeLimit) << qint32(_cacheBigFileTotalTimeLimit);
|
data.stream << quint32(dbiCacheSettings) << qint64(_cacheTotalSizeLimit) << qint32(_cacheTotalTimeLimit) << qint64(_cacheBigFileTotalSizeLimit) << qint32(_cacheBigFileTotalTimeLimit);
|
||||||
if (!userData.isEmpty()) {
|
if (!userData.isEmpty()) {
|
||||||
data.stream << quint32(dbiSessionSettings) << userData;
|
data.stream << quint32(dbiSessionSettings) << userData;
|
||||||
|
|
Loading…
Add table
Reference in a new issue