Move Platform::FileDialog::Gtk::Supported to private namespace

This commit is contained in:
Ilya Fedin 2021-03-09 13:00:13 +04:00 committed by John Preston
parent 2c6a9614b2
commit 5d1601d9c9
6 changed files with 41 additions and 48 deletions

View file

@ -104,8 +104,7 @@ bool Get(
} }
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION #endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
if (const auto integration = GtkIntegration::Instance()) { if (const auto integration = GtkIntegration::Instance()) {
if (integration->fileDialogSupported() if (integration->useFileDialog(type)) {
&& integration->useFileDialog(type)) {
return integration->getFileDialog( return integration->getFileDialog(
parent, parent,
files, files,

View file

@ -69,6 +69,42 @@ QStringList cleanFilterList(const QString &filter) {
return f.split(QLatin1Char(' '), base::QStringSkipEmptyParts); return f.split(QLatin1Char(' '), base::QStringSkipEmptyParts);
} }
bool Supported() {
return internal::GdkHelperLoaded()
&& (gtk_widget_hide_on_delete != nullptr)
&& (gtk_clipboard_store != nullptr)
&& (gtk_clipboard_get != nullptr)
&& (gtk_widget_destroy != nullptr)
&& (gtk_dialog_get_type != nullptr)
&& (gtk_dialog_run != nullptr)
&& (gtk_widget_realize != nullptr)
&& (gdk_window_set_modal_hint != nullptr)
&& (gtk_widget_show != nullptr)
&& (gdk_window_focus != nullptr)
&& (gtk_widget_hide != nullptr)
&& (gtk_widget_hide_on_delete != nullptr)
&& (gtk_file_chooser_dialog_new != nullptr)
&& (gtk_file_chooser_get_type != nullptr)
&& (gtk_file_chooser_set_current_folder != nullptr)
&& (gtk_file_chooser_get_current_folder != nullptr)
&& (gtk_file_chooser_set_current_name != nullptr)
&& (gtk_file_chooser_select_filename != nullptr)
&& (gtk_file_chooser_get_filenames != nullptr)
&& (gtk_file_chooser_set_filter != nullptr)
&& (gtk_file_chooser_get_filter != nullptr)
&& (gtk_window_get_type != nullptr)
&& (gtk_window_set_title != nullptr)
&& (gtk_file_chooser_set_local_only != nullptr)
&& (gtk_file_chooser_set_action != nullptr)
&& (gtk_file_chooser_set_select_multiple != nullptr)
&& (gtk_file_chooser_set_do_overwrite_confirmation != nullptr)
&& (gtk_file_chooser_remove_filter != nullptr)
&& (gtk_file_filter_set_name != nullptr)
&& (gtk_file_filter_add_pattern != nullptr)
&& (gtk_file_chooser_add_filter != nullptr)
&& (gtk_file_filter_new != nullptr);
}
bool PreviewSupported() { bool PreviewSupported() {
return (gdk_pixbuf_new_from_file_at_size != nullptr); return (gdk_pixbuf_new_from_file_at_size != nullptr);
} }
@ -602,43 +638,11 @@ void GtkFileDialog::setNameFilters(const QStringList &filters) {
} // namespace } // namespace
bool Supported() {
return internal::GdkHelperLoaded()
&& (gtk_widget_hide_on_delete != nullptr)
&& (gtk_clipboard_store != nullptr)
&& (gtk_clipboard_get != nullptr)
&& (gtk_widget_destroy != nullptr)
&& (gtk_dialog_get_type != nullptr)
&& (gtk_dialog_run != nullptr)
&& (gtk_widget_realize != nullptr)
&& (gdk_window_set_modal_hint != nullptr)
&& (gtk_widget_show != nullptr)
&& (gdk_window_focus != nullptr)
&& (gtk_widget_hide != nullptr)
&& (gtk_widget_hide_on_delete != nullptr)
&& (gtk_file_chooser_dialog_new != nullptr)
&& (gtk_file_chooser_get_type != nullptr)
&& (gtk_file_chooser_set_current_folder != nullptr)
&& (gtk_file_chooser_get_current_folder != nullptr)
&& (gtk_file_chooser_set_current_name != nullptr)
&& (gtk_file_chooser_select_filename != nullptr)
&& (gtk_file_chooser_get_filenames != nullptr)
&& (gtk_file_chooser_set_filter != nullptr)
&& (gtk_file_chooser_get_filter != nullptr)
&& (gtk_window_get_type != nullptr)
&& (gtk_window_set_title != nullptr)
&& (gtk_file_chooser_set_local_only != nullptr)
&& (gtk_file_chooser_set_action != nullptr)
&& (gtk_file_chooser_set_select_multiple != nullptr)
&& (gtk_file_chooser_set_do_overwrite_confirmation != nullptr)
&& (gtk_file_chooser_remove_filter != nullptr)
&& (gtk_file_filter_set_name != nullptr)
&& (gtk_file_filter_add_pattern != nullptr)
&& (gtk_file_chooser_add_filter != nullptr)
&& (gtk_file_filter_new != nullptr);
}
bool Use(Type type) { bool Use(Type type) {
if (!Supported()) {
return false;
}
return qEnvironmentVariableIsSet("TDESKTOP_USE_GTK_FILE_DIALOG") return qEnvironmentVariableIsSet("TDESKTOP_USE_GTK_FILE_DIALOG")
|| DesktopEnvironment::IsGtkBased(); || DesktopEnvironment::IsGtkBased();
} }

View file

@ -15,7 +15,6 @@ namespace Gtk {
using Type = ::FileDialog::internal::Type; using Type = ::FileDialog::internal::Type;
bool Supported();
bool Use(Type type = Type::ReadFile); bool Use(Type type = Type::ReadFile);
bool Get( bool Get(
QPointer<QWidget> parent, QPointer<QWidget> parent,

View file

@ -158,10 +158,6 @@ std::optional<int> GtkIntegration::scaleFactor() const {
return gdk_monitor_get_scale_factor(monitor); return gdk_monitor_get_scale_factor(monitor);
} }
bool GtkIntegration::fileDialogSupported() const {
return FileDialog::Gtk::Supported();
}
bool GtkIntegration::useFileDialog(FileDialogType type) const { bool GtkIntegration::useFileDialog(FileDialogType type) const {
return FileDialog::Gtk::Use(type); return FileDialog::Gtk::Use(type);
} }

View file

@ -21,7 +21,6 @@ public:
[[nodiscard]] std::optional<int> scaleFactor() const; [[nodiscard]] std::optional<int> scaleFactor() const;
using FileDialogType = ::FileDialog::internal::Type; using FileDialogType = ::FileDialog::internal::Type;
[[nodiscard]] bool fileDialogSupported() const;
[[nodiscard]] bool useFileDialog( [[nodiscard]] bool useFileDialog(
FileDialogType type = FileDialogType::ReadFile) const; FileDialogType type = FileDialogType::ReadFile) const;
[[nodiscard]] bool getFileDialog( [[nodiscard]] bool getFileDialog(

View file

@ -24,10 +24,6 @@ std::optional<int> GtkIntegration::scaleFactor() const {
return std::nullopt; return std::nullopt;
} }
bool GtkIntegration::fileDialogSupported() const {
return false;
}
bool GtkIntegration::useFileDialog(FileDialogType type) const { bool GtkIntegration::useFileDialog(FileDialogType type) const {
return false; return false;
} }