mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-30 22:25:12 +00:00
Merge pull request #156 from ilya-fedin/file-dialog-option
This commit is contained in:
@@ -2754,6 +2754,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
"ktg_settings_system" = "System";
|
"ktg_settings_system" = "System";
|
||||||
"ktg_settings_gtk_integration" = "GTK integration";
|
"ktg_settings_gtk_integration" = "GTK integration";
|
||||||
|
|
||||||
|
"ktg_settings_file_dialog_type" = "File dialog";
|
||||||
|
"ktg_file_dialog_type_default" = "Default";
|
||||||
|
|
||||||
"ktg_settings_other" = "Other";
|
"ktg_settings_other" = "Other";
|
||||||
"ktg_profile_copy_id" = "Copy ID";
|
"ktg_profile_copy_id" = "Copy ID";
|
||||||
"ktg_profile_bot_id" = "Bot ID";
|
"ktg_profile_bot_id" = "Bot ID";
|
||||||
|
@@ -68,6 +68,8 @@
|
|||||||
"ktg_net_speed_boost_big": "Big",
|
"ktg_net_speed_boost_big": "Big",
|
||||||
"ktg_settings_system": "System",
|
"ktg_settings_system": "System",
|
||||||
"ktg_settings_gtk_integration": "GTK integration",
|
"ktg_settings_gtk_integration": "GTK integration",
|
||||||
|
"ktg_settings_file_dialog_type": "File dialog",
|
||||||
|
"ktg_file_dialog_type_default": "Default",
|
||||||
"ktg_settings_other": "Other",
|
"ktg_settings_other": "Other",
|
||||||
"ktg_profile_copy_id": "Copy ID",
|
"ktg_profile_copy_id": "Copy ID",
|
||||||
"ktg_profile_bot_id": "Bot ID",
|
"ktg_profile_bot_id": "Bot ID",
|
||||||
|
@@ -67,6 +67,8 @@
|
|||||||
"ktg_net_speed_boost_big": "Высокое",
|
"ktg_net_speed_boost_big": "Высокое",
|
||||||
"ktg_settings_system": "Система",
|
"ktg_settings_system": "Система",
|
||||||
"ktg_settings_gtk_integration": "GTK-интеграция",
|
"ktg_settings_gtk_integration": "GTK-интеграция",
|
||||||
|
"ktg_settings_file_dialog_type": "Файловый диалог",
|
||||||
|
"ktg_file_dialog_type_default": "По умолчанию",
|
||||||
"ktg_settings_other": "Прочие",
|
"ktg_settings_other": "Прочие",
|
||||||
"ktg_profile_copy_id": "Копировать ID",
|
"ktg_profile_copy_id": "Копировать ID",
|
||||||
"ktg_profile_bot_id": "ID бота",
|
"ktg_profile_bot_id": "ID бота",
|
||||||
|
@@ -23,12 +23,14 @@ RadioBox::RadioBox(
|
|||||||
QWidget*,
|
QWidget*,
|
||||||
const QString &title,
|
const QString &title,
|
||||||
int currentValue,
|
int currentValue,
|
||||||
const QMap<int, QString> &options,
|
int valueCount,
|
||||||
|
Fn<QString(int)> labelGetter,
|
||||||
Fn<void(int)> saveCallback,
|
Fn<void(int)> saveCallback,
|
||||||
bool warnRestart)
|
bool warnRestart)
|
||||||
: _title(title)
|
: _title(title)
|
||||||
, _startValue(currentValue)
|
, _startValue(currentValue)
|
||||||
, _options(options)
|
, _valueCount(valueCount)
|
||||||
|
, _labelGetter(labelGetter)
|
||||||
, _saveCallback(std::move(saveCallback))
|
, _saveCallback(std::move(saveCallback))
|
||||||
, _warnRestart(warnRestart) {
|
, _warnRestart(warnRestart) {
|
||||||
}
|
}
|
||||||
@@ -38,13 +40,15 @@ RadioBox::RadioBox(
|
|||||||
const QString &title,
|
const QString &title,
|
||||||
const QString &description,
|
const QString &description,
|
||||||
int currentValue,
|
int currentValue,
|
||||||
const QMap<int, QString> &options,
|
int valueCount,
|
||||||
|
Fn<QString(int)> labelGetter,
|
||||||
Fn<void(int)> saveCallback,
|
Fn<void(int)> saveCallback,
|
||||||
bool warnRestart)
|
bool warnRestart)
|
||||||
: _title(title)
|
: _title(title)
|
||||||
, _description(description)
|
, _description(description)
|
||||||
, _startValue(currentValue)
|
, _startValue(currentValue)
|
||||||
, _options(options)
|
, _valueCount(valueCount)
|
||||||
|
, _labelGetter(labelGetter)
|
||||||
, _saveCallback(std::move(saveCallback))
|
, _saveCallback(std::move(saveCallback))
|
||||||
, _warnRestart(warnRestart) {
|
, _warnRestart(warnRestart) {
|
||||||
}
|
}
|
||||||
@@ -69,13 +73,13 @@ void RadioBox::prepare() {
|
|||||||
|
|
||||||
_group = std::make_shared<Ui::RadiobuttonGroup>(_startValue);
|
_group = std::make_shared<Ui::RadiobuttonGroup>(_startValue);
|
||||||
|
|
||||||
for (auto i = _options.constBegin(); i != _options.constEnd(); ++i) {
|
for (auto i = 0; i != _valueCount; ++i) {
|
||||||
content->add(
|
content->add(
|
||||||
object_ptr<Ui::Radiobutton>(
|
object_ptr<Ui::Radiobutton>(
|
||||||
this,
|
this,
|
||||||
_group,
|
_group,
|
||||||
i.key(),
|
i,
|
||||||
i.value(),
|
_labelGetter(i),
|
||||||
st::autolockButton),
|
st::autolockButton),
|
||||||
style::margins(
|
style::margins(
|
||||||
st::boxPadding.left(),
|
st::boxPadding.left(),
|
||||||
|
@@ -19,8 +19,8 @@ namespace Kotato {
|
|||||||
|
|
||||||
class RadioBox : public Ui::BoxContent {
|
class RadioBox : public Ui::BoxContent {
|
||||||
public:
|
public:
|
||||||
RadioBox(QWidget* parent, const QString &title, int currentValue, const QMap<int, QString> &options, Fn<void(int)> saveCallback, bool warnRestart = false);
|
RadioBox(QWidget* parent, const QString &title, int currentValue, int valueCount, Fn<QString(int)> labelGetter, Fn<void(int)> saveCallback, bool warnRestart = false);
|
||||||
RadioBox(QWidget* parent, const QString &title, const QString &description, int currentValue, const QMap<int, QString> &options, Fn<void(int)> saveCallback, bool warnRestart = false);
|
RadioBox(QWidget* parent, const QString &title, const QString &description, int currentValue, int valueCount, Fn<QString(int)> labelGetter, Fn<void(int)> saveCallback, bool warnRestart = false);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void prepare() override;
|
void prepare() override;
|
||||||
@@ -31,7 +31,8 @@ private:
|
|||||||
QString _title;
|
QString _title;
|
||||||
QString _description;
|
QString _description;
|
||||||
int _startValue;
|
int _startValue;
|
||||||
QMap<int, QString> _options;
|
int _valueCount;
|
||||||
|
Fn<QString(int)> _labelGetter;
|
||||||
Fn<void(int)> _saveCallback;
|
Fn<void(int)> _saveCallback;
|
||||||
bool _warnRestart = false;
|
bool _warnRestart = false;
|
||||||
std::shared_ptr<Ui::RadiobuttonGroup> _group;
|
std::shared_ptr<Ui::RadiobuttonGroup> _group;
|
||||||
|
@@ -370,6 +370,7 @@ QByteArray GenerateSettingsJson(bool areDefault = false) {
|
|||||||
settings.insert(qsl("userpic_corner_type"), cUserpicCornersType());
|
settings.insert(qsl("userpic_corner_type"), cUserpicCornersType());
|
||||||
settings.insert(qsl("always_show_top_userpic"), cShowTopBarUserpic());
|
settings.insert(qsl("always_show_top_userpic"), cShowTopBarUserpic());
|
||||||
settings.insert(qsl("gtk_integration"), cGtkIntegration());
|
settings.insert(qsl("gtk_integration"), cGtkIntegration());
|
||||||
|
settings.insert(qsl("file_dialog_type"), int(cFileDialogType()));
|
||||||
settings.insert(qsl("disable_tray_counter"), cDisableTrayCounter());
|
settings.insert(qsl("disable_tray_counter"), cDisableTrayCounter());
|
||||||
settings.insert(qsl("use_telegram_panel_icon"), cUseTelegramPanelIcon());
|
settings.insert(qsl("use_telegram_panel_icon"), cUseTelegramPanelIcon());
|
||||||
settings.insert(qsl("custom_app_icon"), cCustomAppIcon());
|
settings.insert(qsl("custom_app_icon"), cCustomAppIcon());
|
||||||
@@ -616,6 +617,14 @@ bool Manager::readCustomFile() {
|
|||||||
cSetGtkIntegration(v);
|
cSetGtkIntegration(v);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ReadIntOption(settings, "file_dialog_type", [&](auto v) {
|
||||||
|
const auto typedValue = Platform::FileDialog::ImplementationType(v);
|
||||||
|
if (typedValue >= Platform::FileDialog::ImplementationType::Default
|
||||||
|
&& typedValue < Platform::FileDialog::ImplementationType::Count) {
|
||||||
|
cSetFileDialogType(typedValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
ReadBoolOption(settings, "disable_tray_counter", [&](auto v) {
|
ReadBoolOption(settings, "disable_tray_counter", [&](auto v) {
|
||||||
cSetDisableTrayCounter(v);
|
cSetDisableTrayCounter(v);
|
||||||
});
|
});
|
||||||
|
@@ -148,6 +148,7 @@ rpl::producer<int> RecentStickersLimitChanges() {
|
|||||||
int gUserpicCornersType = 3;
|
int gUserpicCornersType = 3;
|
||||||
bool gShowTopBarUserpic = false;
|
bool gShowTopBarUserpic = false;
|
||||||
bool gGtkIntegration = false;
|
bool gGtkIntegration = false;
|
||||||
|
Platform::FileDialog::ImplementationType gFileDialogType = Platform::FileDialog::ImplementationType::Default;
|
||||||
bool gDisableTrayCounter = Platform::IsLinux();
|
bool gDisableTrayCounter = Platform::IsLinux();
|
||||||
bool gUseTelegramPanelIcon = false;
|
bool gUseTelegramPanelIcon = false;
|
||||||
int gCustomAppIcon = 0;
|
int gCustomAppIcon = 0;
|
||||||
|
@@ -7,6 +7,8 @@ https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "platform/platform_file_utilities.h"
|
||||||
|
|
||||||
#define DeclareReadSetting(Type, Name) extern Type g##Name; \
|
#define DeclareReadSetting(Type, Name) extern Type g##Name; \
|
||||||
inline const Type &c##Name() { \
|
inline const Type &c##Name() { \
|
||||||
return g##Name; \
|
return g##Name; \
|
||||||
@@ -102,6 +104,7 @@ void SetRecentStickersLimit(int limit);
|
|||||||
DeclareSetting(int, UserpicCornersType);
|
DeclareSetting(int, UserpicCornersType);
|
||||||
DeclareSetting(bool, ShowTopBarUserpic);
|
DeclareSetting(bool, ShowTopBarUserpic);
|
||||||
DeclareSetting(bool, GtkIntegration);
|
DeclareSetting(bool, GtkIntegration);
|
||||||
|
DeclareSetting(Platform::FileDialog::ImplementationType, FileDialogType);
|
||||||
DeclareSetting(bool, DisableTrayCounter);
|
DeclareSetting(bool, DisableTrayCounter);
|
||||||
DeclareSetting(bool, UseTelegramPanelIcon);
|
DeclareSetting(bool, UseTelegramPanelIcon);
|
||||||
DeclareSetting(int, CustomAppIcon);
|
DeclareSetting(int, CustomAppIcon);
|
||||||
|
@@ -41,6 +41,15 @@ namespace Settings {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
QString FileDialogTypeLabel(int value) {
|
||||||
|
const auto typedValue = Platform::FileDialog::ImplementationType(value);
|
||||||
|
switch (typedValue) {
|
||||||
|
case Platform::FileDialog::ImplementationType::Default:
|
||||||
|
return tr::ktg_file_dialog_type_default(tr::now);
|
||||||
|
}
|
||||||
|
return Platform::FileDialog::ImplementationTypeLabel(typedValue);
|
||||||
|
}
|
||||||
|
|
||||||
QString NetBoostLabel(int boost) {
|
QString NetBoostLabel(int boost) {
|
||||||
switch (boost) {
|
switch (boost) {
|
||||||
case 0:
|
case 0:
|
||||||
@@ -250,13 +259,6 @@ void SetupKotatoChats(
|
|||||||
Ui::show(Box<FontsBox>());
|
Ui::show(Box<FontsBox>());
|
||||||
});
|
});
|
||||||
|
|
||||||
const QMap<int, QString> userpicRoundOptions = {
|
|
||||||
{ 0, UserpicRoundingLabel(0) },
|
|
||||||
{ 1, UserpicRoundingLabel(1) },
|
|
||||||
{ 2, UserpicRoundingLabel(2) },
|
|
||||||
{ 3, UserpicRoundingLabel(3) }
|
|
||||||
};
|
|
||||||
|
|
||||||
AddButtonWithLabel(
|
AddButtonWithLabel(
|
||||||
container,
|
container,
|
||||||
tr::ktg_settings_userpic_rounding(),
|
tr::ktg_settings_userpic_rounding(),
|
||||||
@@ -267,7 +269,8 @@ void SetupKotatoChats(
|
|||||||
tr::ktg_settings_userpic_rounding(tr::now),
|
tr::ktg_settings_userpic_rounding(tr::now),
|
||||||
tr::ktg_settings_userpic_rounding_desc(tr::now),
|
tr::ktg_settings_userpic_rounding_desc(tr::now),
|
||||||
cUserpicCornersType(),
|
cUserpicCornersType(),
|
||||||
userpicRoundOptions,
|
4,
|
||||||
|
UserpicRoundingLabel,
|
||||||
[=] (int value) {
|
[=] (int value) {
|
||||||
cSetUserpicCornersType(value);
|
cSetUserpicCornersType(value);
|
||||||
::Kotato::JsonSettings::Write();
|
::Kotato::JsonSettings::Write();
|
||||||
@@ -389,13 +392,6 @@ void SetupKotatoNetwork(not_null<Ui::VerticalLayout*> container) {
|
|||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
AddSubsectionTitle(container, tr::ktg_settings_network());
|
AddSubsectionTitle(container, tr::ktg_settings_network());
|
||||||
|
|
||||||
const QMap<int, QString> netBoostOptions = {
|
|
||||||
{ 0, NetBoostLabel(0) },
|
|
||||||
{ 1, NetBoostLabel(1) },
|
|
||||||
{ 2, NetBoostLabel(2) },
|
|
||||||
{ 3, NetBoostLabel(3) }
|
|
||||||
};
|
|
||||||
|
|
||||||
AddButtonWithLabel(
|
AddButtonWithLabel(
|
||||||
container,
|
container,
|
||||||
tr::ktg_settings_net_speed_boost(),
|
tr::ktg_settings_net_speed_boost(),
|
||||||
@@ -406,7 +402,8 @@ void SetupKotatoNetwork(not_null<Ui::VerticalLayout*> container) {
|
|||||||
tr::ktg_net_speed_boost_title(tr::now),
|
tr::ktg_net_speed_boost_title(tr::now),
|
||||||
tr::ktg_net_speed_boost_desc(tr::now),
|
tr::ktg_net_speed_boost_desc(tr::now),
|
||||||
cNetSpeedBoost(),
|
cNetSpeedBoost(),
|
||||||
netBoostOptions,
|
4,
|
||||||
|
NetBoostLabel,
|
||||||
[=] (int value) {
|
[=] (int value) {
|
||||||
SetNetworkBoost(value);
|
SetNetworkBoost(value);
|
||||||
::Kotato::JsonSettings::Write();
|
::Kotato::JsonSettings::Write();
|
||||||
@@ -438,7 +435,7 @@ void SetupKotatoSystem(
|
|||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
AddSubsectionTitle(container, tr::ktg_settings_system());
|
AddSubsectionTitle(container, tr::ktg_settings_system());
|
||||||
|
|
||||||
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
#ifndef DESKTOP_APP_DISABLE_GTK_INTEGRATION
|
||||||
if (Platform::IsLinux()) {
|
if (Platform::IsLinux()) {
|
||||||
const auto gtkIntegrationToggled = Ui::CreateChild<rpl::event_stream<bool>>(
|
const auto gtkIntegrationToggled = Ui::CreateChild<rpl::event_stream<bool>>(
|
||||||
container.get());
|
container.get());
|
||||||
@@ -467,7 +464,24 @@ void SetupKotatoSystem(
|
|||||||
cancelled));
|
cancelled));
|
||||||
}, container->lifetime());
|
}, container->lifetime());
|
||||||
}
|
}
|
||||||
#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION
|
#endif // !DESKTOP_APP_DISABLE_GTK_INTEGRATION
|
||||||
|
|
||||||
|
AddButtonWithLabel(
|
||||||
|
container,
|
||||||
|
tr::ktg_settings_file_dialog_type(),
|
||||||
|
rpl::single(FileDialogTypeLabel(int(cFileDialogType()))),
|
||||||
|
st::settingsButton
|
||||||
|
)->addClickHandler([=] {
|
||||||
|
Ui::show(Box<::Kotato::RadioBox>(
|
||||||
|
tr::ktg_settings_file_dialog_type(tr::now),
|
||||||
|
int(cFileDialogType()),
|
||||||
|
int(Platform::FileDialog::ImplementationType::Count),
|
||||||
|
FileDialogTypeLabel,
|
||||||
|
[=](int value) {
|
||||||
|
cSetFileDialogType(Platform::FileDialog::ImplementationType(value));
|
||||||
|
::Kotato::JsonSettings::Write();
|
||||||
|
}, false));
|
||||||
|
});
|
||||||
|
|
||||||
if (Platform::IsMac()) {
|
if (Platform::IsMac()) {
|
||||||
const auto useNativeDecorationsToggled = Ui::CreateChild<rpl::event_stream<bool>>(
|
const auto useNativeDecorationsToggled = Ui::CreateChild<rpl::event_stream<bool>>(
|
||||||
@@ -530,15 +544,6 @@ void SetupKotatoSystem(
|
|||||||
}, container->lifetime());
|
}, container->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
const QMap<int, QString> trayIconOptions = {
|
|
||||||
{ 0, TrayIconLabel(0) },
|
|
||||||
{ 1, TrayIconLabel(1) },
|
|
||||||
{ 2, TrayIconLabel(2) },
|
|
||||||
{ 3, TrayIconLabel(3) },
|
|
||||||
{ 4, TrayIconLabel(4) },
|
|
||||||
{ 5, TrayIconLabel(5) },
|
|
||||||
};
|
|
||||||
|
|
||||||
auto trayIconText = rpl::single(
|
auto trayIconText = rpl::single(
|
||||||
rpl::empty_value()
|
rpl::empty_value()
|
||||||
) | rpl::then(
|
) | rpl::then(
|
||||||
@@ -557,7 +562,8 @@ void SetupKotatoSystem(
|
|||||||
tr::ktg_settings_tray_icon(tr::now),
|
tr::ktg_settings_tray_icon(tr::now),
|
||||||
tr::ktg_settings_tray_icon_desc(tr::now),
|
tr::ktg_settings_tray_icon_desc(tr::now),
|
||||||
cCustomAppIcon(),
|
cCustomAppIcon(),
|
||||||
trayIconOptions,
|
6,
|
||||||
|
TrayIconLabel,
|
||||||
[=] (int value) {
|
[=] (int value) {
|
||||||
cSetCustomAppIcon(value);
|
cSetCustomAppIcon(value);
|
||||||
controller->session().data().notifyUnreadBadgeChanged();
|
controller->session().data().notifyUnreadBadgeChanged();
|
||||||
@@ -575,12 +581,6 @@ void SetupKotatoOther(not_null<Ui::VerticalLayout*> container) {
|
|||||||
|
|
||||||
SettingsMenuCSwitch(ktg_settings_show_phone_number, ShowPhoneInDrawer);
|
SettingsMenuCSwitch(ktg_settings_show_phone_number, ShowPhoneInDrawer);
|
||||||
|
|
||||||
const QMap<int, QString> chatIdOptions = {
|
|
||||||
{ 0, ChatIdLabel(0) },
|
|
||||||
{ 1, ChatIdLabel(1) },
|
|
||||||
{ 2, ChatIdLabel(2) },
|
|
||||||
};
|
|
||||||
|
|
||||||
const auto chatIdButton = container->add(
|
const auto chatIdButton = container->add(
|
||||||
object_ptr<Button>(
|
object_ptr<Button>(
|
||||||
container,
|
container,
|
||||||
@@ -603,7 +603,8 @@ void SetupKotatoOther(not_null<Ui::VerticalLayout*> container) {
|
|||||||
tr::ktg_settings_chat_id(tr::now),
|
tr::ktg_settings_chat_id(tr::now),
|
||||||
tr::ktg_settings_chat_id_desc(tr::now),
|
tr::ktg_settings_chat_id_desc(tr::now),
|
||||||
cShowChatId(),
|
cShowChatId(),
|
||||||
chatIdOptions,
|
3,
|
||||||
|
ChatIdLabel,
|
||||||
[=] (int value) {
|
[=] (int value) {
|
||||||
cSetShowChatId(value);
|
cSetShowChatId(value);
|
||||||
::Kotato::JsonSettings::Write();
|
::Kotato::JsonSettings::Write();
|
||||||
|
@@ -159,6 +159,19 @@ bool GetQt(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ImplementationTypeLabel(ImplementationType value) {
|
||||||
|
switch (value) {
|
||||||
|
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||||
|
case ImplementationType::XDP: return qsl("XDG Desktop Portal");
|
||||||
|
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||||
|
#ifndef DESKTOP_APP_DISABLE_GTK_INTEGRATION
|
||||||
|
case ImplementationType::GTK: return qsl("GTK");
|
||||||
|
#endif // !DESKTOP_APP_DISABLE_GTK_INTEGRATION
|
||||||
|
case ImplementationType::Qt: return qsl("Qt");
|
||||||
|
}
|
||||||
|
Unexpected("Value in Platform::FileDialog::ImplementationTypeLabel.");
|
||||||
|
}
|
||||||
|
|
||||||
bool Get(
|
bool Get(
|
||||||
QPointer<QWidget> parent,
|
QPointer<QWidget> parent,
|
||||||
QStringList &files,
|
QStringList &files,
|
||||||
|
@@ -27,6 +27,18 @@ inline void PostprocessDownloaded(const QString &filepath) {
|
|||||||
|
|
||||||
namespace FileDialog {
|
namespace FileDialog {
|
||||||
|
|
||||||
|
enum class ImplementationType {
|
||||||
|
Default,
|
||||||
|
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||||
|
XDP,
|
||||||
|
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||||
|
#ifndef DESKTOP_APP_DISABLE_GTK_INTEGRATION
|
||||||
|
GTK,
|
||||||
|
#endif // !DESKTOP_APP_DISABLE_GTK_INTEGRATION
|
||||||
|
Qt,
|
||||||
|
Count,
|
||||||
|
};
|
||||||
|
|
||||||
inline void InitLastPath() {
|
inline void InitLastPath() {
|
||||||
::FileDialog::internal::InitLastPathDefault();
|
::FileDialog::internal::InitLastPathDefault();
|
||||||
}
|
}
|
||||||
|
@@ -642,11 +642,12 @@ void GtkFileDialog::setNameFilters(const QStringList &filters) {
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
bool Use(Type type) {
|
bool Use(Type type) {
|
||||||
if (!Supported()) {
|
if (!Supported()
|
||||||
|
|| (cFileDialogType() > ImplementationType::GTK)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return qEnvironmentVariableIsSet("TDESKTOP_USE_GTK_FILE_DIALOG")
|
return (cFileDialogType() == ImplementationType::GTK)
|
||||||
|| DesktopEnvironment::IsGtkBased();
|
|| DesktopEnvironment::IsGtkBased();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -642,17 +642,18 @@ rpl::producer<> XDPFileDialog::rejected() {
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
bool Use(Type type) {
|
bool Use(Type type) {
|
||||||
static const auto ShouldUse = [&] {
|
const auto shouldUse = [&] {
|
||||||
const auto envVar = qEnvironmentVariableIsSet("TDESKTOP_USE_PORTAL");
|
const auto setting = cFileDialogType() <= ImplementationType::XDP;
|
||||||
|
const auto forceSetting = cFileDialogType() == ImplementationType::XDP;
|
||||||
const auto confined = InFlatpak() || InSnap();
|
const auto confined = InFlatpak() || InSnap();
|
||||||
const auto notGtkBased = !DesktopEnvironment::IsGtkBased();
|
const auto notGtkBased = !DesktopEnvironment::IsGtkBased();
|
||||||
|
|
||||||
return confined || notGtkBased || envVar;
|
return setting && (confined || notGtkBased || forceSetting);
|
||||||
}();
|
}();
|
||||||
|
|
||||||
static const auto Version = FileChooserPortalVersion();
|
static const auto Version = FileChooserPortalVersion();
|
||||||
|
|
||||||
return ShouldUse
|
return shouldUse
|
||||||
&& Version.has_value()
|
&& Version.has_value()
|
||||||
&& (type != Type::ReadFolder || *Version >= 3);
|
&& (type != Type::ReadFolder || *Version >= 3);
|
||||||
}
|
}
|
||||||
|
@@ -27,6 +27,15 @@ inline void PostprocessDownloaded(const QString &filepath) {
|
|||||||
|
|
||||||
namespace FileDialog {
|
namespace FileDialog {
|
||||||
|
|
||||||
|
enum class ImplementationType {
|
||||||
|
Default,
|
||||||
|
Count,
|
||||||
|
};
|
||||||
|
|
||||||
|
inline QString ImplementationTypeLabel(ImplementationType value) {
|
||||||
|
Unexpected("Value in Platform::FileDialog::TypeLabel.");
|
||||||
|
}
|
||||||
|
|
||||||
inline void InitLastPath() {
|
inline void InitLastPath() {
|
||||||
::FileDialog::internal::InitLastPathDefault();
|
::FileDialog::internal::InitLastPathDefault();
|
||||||
}
|
}
|
||||||
|
@@ -27,6 +27,10 @@ void PostprocessDownloaded(const QString &filepath);
|
|||||||
|
|
||||||
namespace FileDialog {
|
namespace FileDialog {
|
||||||
|
|
||||||
|
enum class ImplementationType;
|
||||||
|
|
||||||
|
QString ImplementationTypeLabel(ImplementationType value);
|
||||||
|
|
||||||
void InitLastPath();
|
void InitLastPath();
|
||||||
|
|
||||||
bool Get(
|
bool Get(
|
||||||
|
@@ -12,6 +12,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
namespace Platform {
|
namespace Platform {
|
||||||
namespace File {
|
namespace File {
|
||||||
|
|
||||||
|
enum class ImplementationType {
|
||||||
|
Default,
|
||||||
|
Count,
|
||||||
|
};
|
||||||
|
|
||||||
|
inline QString ImplementationTypeLabel(ImplementationType value) {
|
||||||
|
Unexpected("Value in Platform::FileDialog::TypeLabel.");
|
||||||
|
}
|
||||||
|
|
||||||
inline QString UrlToLocal(const QUrl &url) {
|
inline QString UrlToLocal(const QUrl &url) {
|
||||||
return ::File::internal::UrlToLocalDefault(url);
|
return ::File::internal::UrlToLocalDefault(url);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user