.. index:: pair: class; EE::System::FileAssociation .. _doxid-class_e_e_1_1_system_1_1_file_association: class EE::System::FileAssociation ================================= .. toctree:: :hidden: Overview ~~~~~~~~ Registers a desktop application as a handler for filename extensions. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include class FileAssociation { public: // construction :target:`FileAssociation`(:ref:`FileAssociationApplication` application); // methods std::vector :ref:`getRegisteredExtensions`(const std::vector& supportedExtensions) const; bool :ref:`setRegisteredExtensions`(const std::vector& registeredExtensions, const std::vector& supportedExtensions); bool :ref:`setRegisteredExtensions`(const std::vector& registeredExtensions, const std::vector& supportedExtensions, bool desktopEntryInstalled); bool :target:`isDesktopEntryInstalled`() const; bool :target:`setDesktopEntryInstalled`(bool installed); const std::string& :target:`getLastError`() const; static bool :target:`isSupported`(); static bool :ref:`supportsDesktopEntries`(); static std::string :ref:`normalizeExtension`(std::string_view extension); }; .. _details-class_e_e_1_1_system_1_1_file_association: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Registers a desktop application as a handler for filename extensions. Registrations are per-user. On Windows this adds the application to the Open With list, since current Windows versions do not allow applications to silently change the user's default app. XDG desktops use a generated desktop entry and the shared MIME database. macOS uses Launch Services and therefore treats a selected extension as a request to make the application its editor. Methods ------- .. index:: pair: function; getRegisteredExtensions .. _doxid-class_e_e_1_1_system_1_1_file_association_1ad8e9e4df55c00903140b567c4c0d0e81: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::vector getRegisteredExtensions(const std::vector& supportedExtensions) const Returns the extensions from ``supportedExtensions`` currently registered for this app. .. index:: pair: function; setRegisteredExtensions .. _doxid-class_e_e_1_1_system_1_1_file_association_1af42b4d24cba3ed1afce1d891aebbf99c: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool setRegisteredExtensions(const std::vector& registeredExtensions, const std::vector& supportedExtensions) Makes ``registeredExtensions`` the registered subset of ``supportedExtensions``. .. index:: pair: function; setRegisteredExtensions .. _doxid-class_e_e_1_1_system_1_1_file_association_1acfc16f6bfe6e0be13d38ef1451e5c360: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool setRegisteredExtensions(const std::vector& registeredExtensions, const std::vector& supportedExtensions, bool desktopEntryInstalled) Makes ``registeredExtensions`` the registered subset of ``supportedExtensions`` and updates the desktop-entry visibility in the same operation. ``desktopEntryInstalled`` is ignored on platforms that do not support desktop entries. .. index:: pair: function; supportsDesktopEntries .. _doxid-class_e_e_1_1_system_1_1_file_association_1a75199465a89db20b97f68be8e6994f5f: .. ref-code-block:: cpp :class: doxyrest-title-code-block static bool supportsDesktopEntries() XDG platforms can additionally expose the generated desktop entry in application menus. .. index:: pair: function; normalizeExtension .. _doxid-class_e_e_1_1_system_1_1_file_association_1ad1d9ac64f54b3ba3edf84528c7ed67c7: .. ref-code-block:: cpp :class: doxyrest-title-code-block static std::string normalizeExtension(std::string_view extension) Returns a lower-case extension without a leading dot, or an empty string if invalid.