Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions docs/sphinx/reference-libobs-util-dstr.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,28 @@ General String Helper Functions

----------------------

.. function:: int astrnatcmp(const char *str1, const char *str2, os_locale_t locale)

Natural comparison function for strings.

In natural comparison numbers are compared by their value instead of the alphabetical order.
For example "z2" < "z11" while in alphabetical comparison it would be "z11" < "z2".

Otherwise the function uses locale aware string comparison function strcoll_l() / _strcoll_l().

----------------------

.. function:: int wstrnatcmp(const wchar_t *str1, const wchar_t *str2, os_locale_t locale)

Natural comparison function for wide strings.

In natural comparison numbers are compared by their value instead of the alphabetical order.
For example "z2" < "z11" while in alphabetical comparison it would be "z11" < "z2".

Otherwise the function uses locale aware wide string comparison function wcscoll_l() / _wcscoll_l().

----------------------

.. function:: char *astrstri(const char *str, const char *find)

Case insensitive version of strstr.
Expand Down
70 changes: 70 additions & 0 deletions docs/sphinx/reference-libobs-util-platform.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,60 @@ Number/String Conversion Functions
---------------------


Locale Awareness Functions
----------------------------------

.. type:: os_locale_t

Platform specific locale. Either _locale_t for Windows or locale_t for posix.

.. type:: int (*os_locale_aware_cmp)(const void *a, const void *b, os_locale_t locale)

Locale aware comparison function.

---------------------

.. function:: int os_strcoll_l(const char *a, const char *b, os_locale_t locale)

Performs locale aware comparison with strcoll_l() or _strcoll_l() depending on platform.

---------------------

.. function:: int os_wcscoll_l(const wchar_t *a, const wchar_t *b, os_locale_t locale)

Performs locale aware comparison with wcscoll_l() or _wcscoll_l() depending on platform.

---------------------

.. function:: os_locale_t os_get_locale(const char *locale)

Returns platform specific locale type. Must be freed with os_free_locale().

:param locale: Locale to be created. (ie. "en_US.UTF-8")
If NULL or empty, system default with UTF-8 encoding (for char apis) is returned.

---------------------

.. function:: void os_free_locale(os_locale_t locale)

Frees locale acquired with os_get_locale().

---------------------

.. function:: void os_locale_aware_sort(void *base, size_t elements, size_t element_size, os_locale_aware_cmp cmp, os_locale_t locale)

Performs locale aware sort with parameters similiar to qsort().

:param cmp: Comparison callback to use. Takes os_locale_t as the 3rd parameter.
This can be for example os_wcscoll_l or wstrnatcoll if the sort list is whcar_t* directly.

:param locale: Locale acquired from os_get_locale().
If NULL, system default with UTF-8 encoding is used.
If the comparison is for wide chars, then platform specific encoding is used.

---------------------


Dynamic Link Library Functions
------------------------------

Expand Down Expand Up @@ -285,6 +339,22 @@ Other Path/File Functions

---------------------

.. type:: bool (*dir_filter_func)(struct os_dirent *)

Filter function when iterating files in directory. Should return false to remove entries and true to keep them.

---------------------

.. function:: void os_sortdir_natural(os_dir_t *dir, struct darray *sorted, dir_filter_func filter_func)

Returns files in directory sorted by a natural (number aware) and locale aware sort.

:param sorted: Pointer to darray of struct os_dirent to append files to.

:param filter_func: Filter function for directory files.

---------------------

.. struct:: os_globent

A glob entry.
Expand Down
9 changes: 6 additions & 3 deletions frontend/widgets/OBSBasic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ class OBSBasic : public OBSMainWindow {
DropType_Html,
DropType_Url,
};
static const std::map<DropType, const char *> DropTypes;
struct DropItem;

enum ContextBarSize { ContextBarSize_Minimized, ContextBarSize_Reduced, ContextBarSize_Normal };

Expand Down Expand Up @@ -471,9 +473,10 @@ private slots:
* -------------------------------------
*/
private:
void AddDropSource(const char *file, DropType image);
void AddDropURL(QUrl url, QString &name, obs_data_t *settings, const obs_video_info &ovi);
void ConfirmDropUrl(const QString &url);
QString GetUrlDisplayName(QUrl url);
void AddDropSource(const DropItem &dropItem);
void AddDropURL(QUrl url, obs_data_t *settings, const obs_video_info &ovi);
bool ConfirmDropUrl(const QString &url);
void dragEnterEvent(QDragEnterEvent *event) override;
void dragLeaveEvent(QDragLeaveEvent *event) override;
void dragMoveEvent(QDragMoveEvent *event) override;
Expand Down
Loading