2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-06 09:35:12 +00:00

Add option to choose file dialog

This commit is contained in:
Ilya Fedin
2021-03-31 12:34:17 +04:00
parent a618181120
commit ecb10dca8a
14 changed files with 101 additions and 6 deletions

View File

@@ -642,17 +642,18 @@ rpl::producer<> XDPFileDialog::rejected() {
} // namespace
bool Use(Type type) {
static const auto ShouldUse = [&] {
const auto envVar = qEnvironmentVariableIsSet("TDESKTOP_USE_PORTAL");
const auto shouldUse = [&] {
const auto setting = cFileDialogType() <= ImplementationType::XDP;
const auto forceSetting = cFileDialogType() == ImplementationType::XDP;
const auto confined = InFlatpak() || InSnap();
const auto notGtkBased = !DesktopEnvironment::IsGtkBased();
return confined || notGtkBased || envVar;
return setting && (confined || notGtkBased || forceSetting);
}();
static const auto Version = FileChooserPortalVersion();
return ShouldUse
return shouldUse
&& Version.has_value()
&& (type != Type::ReadFolder || *Version >= 3);
}