mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-08 08:04:08 +02:00
Move Platform::FileDialog::Gtk::Supported to private namespace
This commit is contained in:
parent
2c6a9614b2
commit
5d1601d9c9
6 changed files with 41 additions and 48 deletions
|
@ -104,8 +104,7 @@ bool Get(
|
|||
}
|
||||
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||
if (const auto integration = GtkIntegration::Instance()) {
|
||||
if (integration->fileDialogSupported()
|
||||
&& integration->useFileDialog(type)) {
|
||||
if (integration->useFileDialog(type)) {
|
||||
return integration->getFileDialog(
|
||||
parent,
|
||||
files,
|
||||
|
|
|
@ -69,6 +69,42 @@ QStringList cleanFilterList(const QString &filter) {
|
|||
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() {
|
||||
return (gdk_pixbuf_new_from_file_at_size != nullptr);
|
||||
}
|
||||
|
@ -602,43 +638,11 @@ void GtkFileDialog::setNameFilters(const QStringList &filters) {
|
|||
|
||||
} // 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) {
|
||||
if (!Supported()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return qEnvironmentVariableIsSet("TDESKTOP_USE_GTK_FILE_DIALOG")
|
||||
|| DesktopEnvironment::IsGtkBased();
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ namespace Gtk {
|
|||
|
||||
using Type = ::FileDialog::internal::Type;
|
||||
|
||||
bool Supported();
|
||||
bool Use(Type type = Type::ReadFile);
|
||||
bool Get(
|
||||
QPointer<QWidget> parent,
|
||||
|
|
|
@ -158,10 +158,6 @@ std::optional<int> GtkIntegration::scaleFactor() const {
|
|||
return gdk_monitor_get_scale_factor(monitor);
|
||||
}
|
||||
|
||||
bool GtkIntegration::fileDialogSupported() const {
|
||||
return FileDialog::Gtk::Supported();
|
||||
}
|
||||
|
||||
bool GtkIntegration::useFileDialog(FileDialogType type) const {
|
||||
return FileDialog::Gtk::Use(type);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ public:
|
|||
[[nodiscard]] std::optional<int> scaleFactor() const;
|
||||
|
||||
using FileDialogType = ::FileDialog::internal::Type;
|
||||
[[nodiscard]] bool fileDialogSupported() const;
|
||||
[[nodiscard]] bool useFileDialog(
|
||||
FileDialogType type = FileDialogType::ReadFile) const;
|
||||
[[nodiscard]] bool getFileDialog(
|
||||
|
|
|
@ -24,10 +24,6 @@ std::optional<int> GtkIntegration::scaleFactor() const {
|
|||
return std::nullopt;
|
||||
}
|
||||
|
||||
bool GtkIntegration::fileDialogSupported() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GtkIntegration::useFileDialog(FileDialogType type) const {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue