diff options
| author | manuel <manuel@mausz.at> | 2020-10-19 00:52:24 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2020-10-19 00:52:24 +0200 |
| commit | be933ef2241d79558f91796cc5b3a161f72ebf9c (patch) | |
| tree | fe3ab2f130e20c99001f2d7a81d610c78c96a3f4 /xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/FileBrowser.h | |
| parent | 5f8335c1e49ce108ef3481863833c98efa00411b (diff) | |
| download | kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.gz kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.bz2 kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.zip | |
sync with upstream
Diffstat (limited to 'xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/FileBrowser.h')
| -rw-r--r-- | xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/FileBrowser.h | 302 |
1 files changed, 302 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/FileBrowser.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/FileBrowser.h new file mode 100644 index 0000000..244c76c --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/FileBrowser.h | |||
| @@ -0,0 +1,302 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../../AddonBase.h" | ||
| 12 | #include "../../c-api/gui/dialogs/filebrowser.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace gui | ||
| 19 | { | ||
| 20 | namespace dialogs | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_gui_dialogs_FileBrowser Dialog File Browser | ||
| 25 | /// @ingroup cpp_kodi_gui_dialogs | ||
| 26 | /// @brief @cpp_namespace{ kodi::gui::dialogs::FileBrowser } | ||
| 27 | /// **File browser dialog**\n | ||
| 28 | /// The functions listed below of the class "FileBrowser" offer the possibility | ||
| 29 | /// to select to a file by the user of the add-on. | ||
| 30 | /// | ||
| 31 | /// It allows all the options that are possible in Kodi itself and offers all | ||
| 32 | /// support file types. | ||
| 33 | /// | ||
| 34 | /// It has the header @ref FileBrowser.h "#include <kodi/gui/dialogs/FileBrowser.h>" | ||
| 35 | /// be included to enjoy it. | ||
| 36 | /// | ||
| 37 | namespace FileBrowser | ||
| 38 | { | ||
| 39 | //============================================================================== | ||
| 40 | /// @ingroup cpp_kodi_gui_dialogs_FileBrowser | ||
| 41 | /// @brief Directory selection dialog. | ||
| 42 | /// | ||
| 43 | /// @param[in] shares With Shares becomes the available start folders be set | ||
| 44 | /// @param[in] heading Dialog header name | ||
| 45 | /// @param[in,out] path As in the path to start and return value about | ||
| 46 | /// selected directory | ||
| 47 | /// @param[in] writeOnly [opt] If set only writeable folders are shown | ||
| 48 | /// @return False if selection becomes canceled | ||
| 49 | /// | ||
| 50 | /// **Example:** | ||
| 51 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 52 | /// #include <kodi/gui/dialogs/FileBrowser.h> | ||
| 53 | /// | ||
| 54 | /// // Example show directory selection dialog with on 'share' (first value) | ||
| 55 | /// // defined directory types. | ||
| 56 | /// // | ||
| 57 | /// // If this becomes leaved empty and 'directory' is empty goes it to the | ||
| 58 | /// // base path of the hard disk. | ||
| 59 | /// // | ||
| 60 | /// // Also can be with path written to 'directory' before the dialog forced | ||
| 61 | /// // to a start place. | ||
| 62 | /// std::string directory; | ||
| 63 | /// bool ret = kodi::gui::dialogs::FileBrowser::ShowAndGetDirectory("local|network|removable", | ||
| 64 | /// "Test directory selection", | ||
| 65 | /// directory, | ||
| 66 | /// false); | ||
| 67 | /// fprintf(stderr, "Selected directory is : %s and was %s\n", directory.c_str(), ret ? "OK" : "Canceled"); | ||
| 68 | /// ~~~~~~~~~~~~~ | ||
| 69 | /// | ||
| 70 | inline bool ATTRIBUTE_HIDDEN ShowAndGetDirectory(const std::string& shares, | ||
| 71 | const std::string& heading, | ||
| 72 | std::string& path, | ||
| 73 | bool writeOnly = false) | ||
| 74 | { | ||
| 75 | using namespace ::kodi::addon; | ||
| 76 | char* retString = nullptr; | ||
| 77 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_directory( | ||
| 78 | CAddonBase::m_interface->toKodi->kodiBase, shares.c_str(), heading.c_str(), path.c_str(), | ||
| 79 | &retString, writeOnly); | ||
| 80 | if (retString != nullptr) | ||
| 81 | { | ||
| 82 | if (std::strlen(retString)) | ||
| 83 | path = retString; | ||
| 84 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 85 | retString); | ||
| 86 | } | ||
| 87 | return ret; | ||
| 88 | } | ||
| 89 | //------------------------------------------------------------------------------ | ||
| 90 | |||
| 91 | //============================================================================== | ||
| 92 | /// @ingroup cpp_kodi_gui_dialogs_FileBrowser | ||
| 93 | /// @brief File selection dialog. | ||
| 94 | /// | ||
| 95 | /// @param[in] shares With Shares becomes the available start folders be set. | ||
| 96 | /// @param[in] mask The mask to filter visible files, e.g. ".m3u|.pls|.b4s|.wpl" | ||
| 97 | /// @param[in] heading Dialog header name | ||
| 98 | /// @param[in,out] path As in the path to start and Return value about selected | ||
| 99 | /// file | ||
| 100 | /// @param[in] useThumbs [opt] If set show thumbs if possible on dialog | ||
| 101 | /// @param[in] useFileDirectories [opt] If set also packages (e.g. *.zip) are | ||
| 102 | /// handled as directories. | ||
| 103 | /// @return False if selection becomes canceled | ||
| 104 | /// | ||
| 105 | inline bool ATTRIBUTE_HIDDEN ShowAndGetFile(const std::string& shares, | ||
| 106 | const std::string& mask, | ||
| 107 | const std::string& heading, | ||
| 108 | std::string& path, | ||
| 109 | bool useThumbs = false, | ||
| 110 | bool useFileDirectories = false) | ||
| 111 | { | ||
| 112 | using namespace ::kodi::addon; | ||
| 113 | char* retString = nullptr; | ||
| 114 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file( | ||
| 115 | CAddonBase::m_interface->toKodi->kodiBase, shares.c_str(), mask.c_str(), heading.c_str(), | ||
| 116 | path.c_str(), &retString, useThumbs, useFileDirectories); | ||
| 117 | if (retString != nullptr) | ||
| 118 | { | ||
| 119 | if (std::strlen(retString)) | ||
| 120 | path = retString; | ||
| 121 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 122 | retString); | ||
| 123 | } | ||
| 124 | return ret; | ||
| 125 | } | ||
| 126 | //------------------------------------------------------------------------------ | ||
| 127 | |||
| 128 | //============================================================================== | ||
| 129 | /// @ingroup cpp_kodi_gui_dialogs_FileBrowser | ||
| 130 | /// @brief File selection from a directory. | ||
| 131 | /// | ||
| 132 | /// @param[in] directory The directory name where the dialog start, possible are | ||
| 133 | /// normal names and kodi's special names | ||
| 134 | /// @param[in] mask The mask to filter visible files, e.g. ".m3u|.pls|.b4s|.wpl" | ||
| 135 | /// @param[in] heading Dialog header name | ||
| 136 | /// @param[in,out] path As in the path to start and Return value about selected | ||
| 137 | /// file | ||
| 138 | /// @param[in] useThumbs [opt] If set show thumbs if possible on dialog | ||
| 139 | /// @param[in] useFileDirectories [opt] If set also packages (e.g. *.zip) are | ||
| 140 | /// handled as directories | ||
| 141 | /// @param[in] singleList [opt] | ||
| 142 | /// @return False if selection becomes canceled | ||
| 143 | /// | ||
| 144 | inline bool ATTRIBUTE_HIDDEN ShowAndGetFileFromDir(const std::string& directory, | ||
| 145 | const std::string& mask, | ||
| 146 | const std::string& heading, | ||
| 147 | std::string& path, | ||
| 148 | bool useThumbs = false, | ||
| 149 | bool useFileDirectories = false, | ||
| 150 | bool singleList = false) | ||
| 151 | { | ||
| 152 | using namespace ::kodi::addon; | ||
| 153 | char* retString = nullptr; | ||
| 154 | bool ret = | ||
| 155 | CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file_from_dir( | ||
| 156 | CAddonBase::m_interface->toKodi->kodiBase, directory.c_str(), mask.c_str(), | ||
| 157 | heading.c_str(), path.c_str(), &retString, useThumbs, useFileDirectories, singleList); | ||
| 158 | if (retString != nullptr) | ||
| 159 | { | ||
| 160 | if (std::strlen(retString)) | ||
| 161 | path = retString; | ||
| 162 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 163 | retString); | ||
| 164 | } | ||
| 165 | return ret; | ||
| 166 | } | ||
| 167 | //------------------------------------------------------------------------------ | ||
| 168 | |||
| 169 | //============================================================================== | ||
| 170 | /// @ingroup cpp_kodi_gui_dialogs_FileBrowser | ||
| 171 | /// @brief File selection dialog to get several in to a list. | ||
| 172 | /// | ||
| 173 | /// @param[in] shares With Shares becomes the available start folders be set. | ||
| 174 | /// @param[in] mask The mask to filter visible files, e.g. ".m3u|.pls|.b4s|.wpl" | ||
| 175 | /// @param[in] heading Dialog header name | ||
| 176 | /// @param[out] fileList Return value about selected files | ||
| 177 | /// @param[in] useThumbs [opt] If set show thumbs if possible on dialog. | ||
| 178 | /// @param[in] useFileDirectories [opt] If set also packages (e.g. *.zip) are | ||
| 179 | /// handled as directories. | ||
| 180 | /// @return False if selection becomes canceled. | ||
| 181 | /// | ||
| 182 | inline bool ATTRIBUTE_HIDDEN ShowAndGetFileList(const std::string& shares, | ||
| 183 | const std::string& mask, | ||
| 184 | const std::string& heading, | ||
| 185 | std::vector<std::string>& fileList, | ||
| 186 | bool useThumbs = false, | ||
| 187 | bool useFileDirectories = false) | ||
| 188 | { | ||
| 189 | using namespace ::kodi::addon; | ||
| 190 | char** list = nullptr; | ||
| 191 | unsigned int listSize = 0; | ||
| 192 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file_list( | ||
| 193 | CAddonBase::m_interface->toKodi->kodiBase, shares.c_str(), mask.c_str(), heading.c_str(), | ||
| 194 | &list, &listSize, useThumbs, useFileDirectories); | ||
| 195 | if (ret) | ||
| 196 | { | ||
| 197 | for (unsigned int i = 0; i < listSize; ++i) | ||
| 198 | fileList.emplace_back(list[i]); | ||
| 199 | CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list( | ||
| 200 | CAddonBase::m_interface->toKodi->kodiBase, &list, listSize); | ||
| 201 | } | ||
| 202 | return ret; | ||
| 203 | } | ||
| 204 | //------------------------------------------------------------------------------ | ||
| 205 | |||
| 206 | //============================================================================== | ||
| 207 | /// @ingroup cpp_kodi_gui_dialogs_FileBrowser | ||
| 208 | /// @brief Source selection dialog. | ||
| 209 | /// | ||
| 210 | /// @param[in,out] path As in the path to start and Return value about selected | ||
| 211 | /// source | ||
| 212 | /// @param[in] allowNetworkShares Allow also access to network | ||
| 213 | /// @param[in] additionalShare [opt] With additionalShare becomes the available | ||
| 214 | /// start folders be set. | ||
| 215 | /// @param[in] type [opt] | ||
| 216 | /// @return False if selection becomes canceled | ||
| 217 | /// | ||
| 218 | inline bool ATTRIBUTE_HIDDEN ShowAndGetSource(std::string& path, | ||
| 219 | bool allowNetworkShares, | ||
| 220 | const std::string& additionalShare = "", | ||
| 221 | const std::string& type = "") | ||
| 222 | { | ||
| 223 | using namespace ::kodi::addon; | ||
| 224 | char* retString = nullptr; | ||
| 225 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_source( | ||
| 226 | CAddonBase::m_interface->toKodi->kodiBase, path.c_str(), &retString, allowNetworkShares, | ||
| 227 | additionalShare.c_str(), type.c_str()); | ||
| 228 | if (retString != nullptr) | ||
| 229 | { | ||
| 230 | if (std::strlen(retString)) | ||
| 231 | path = retString; | ||
| 232 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 233 | retString); | ||
| 234 | } | ||
| 235 | return ret; | ||
| 236 | } | ||
| 237 | //------------------------------------------------------------------------------ | ||
| 238 | |||
| 239 | //============================================================================== | ||
| 240 | /// @ingroup cpp_kodi_gui_dialogs_FileBrowser | ||
| 241 | /// @brief Image selection dialog. | ||
| 242 | /// | ||
| 243 | /// @param[in] shares With Shares becomes the available start folders be set | ||
| 244 | /// @param[in] heading Dialog header name | ||
| 245 | /// @param[out] path Return value about selected image | ||
| 246 | /// @return False if selection becomes canceled | ||
| 247 | /// | ||
| 248 | inline bool ATTRIBUTE_HIDDEN ShowAndGetImage(const std::string& shares, | ||
| 249 | const std::string& heading, | ||
| 250 | std::string& path) | ||
| 251 | { | ||
| 252 | using namespace ::kodi::addon; | ||
| 253 | char* retString = nullptr; | ||
| 254 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_image( | ||
| 255 | CAddonBase::m_interface->toKodi->kodiBase, shares.c_str(), heading.c_str(), path.c_str(), | ||
| 256 | &retString); | ||
| 257 | if (retString != nullptr) | ||
| 258 | { | ||
| 259 | if (std::strlen(retString)) | ||
| 260 | path = retString; | ||
| 261 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 262 | retString); | ||
| 263 | } | ||
| 264 | return ret; | ||
| 265 | } | ||
| 266 | //------------------------------------------------------------------------------ | ||
| 267 | |||
| 268 | //============================================================================== | ||
| 269 | /// @ingroup cpp_kodi_gui_dialogs_FileBrowser | ||
| 270 | /// @brief Image selection dialog to get several in to a list. | ||
| 271 | /// | ||
| 272 | /// @param[in] shares With Shares becomes the available start folders be set | ||
| 273 | /// @param[in] heading Dialog header name | ||
| 274 | /// @param[out] file_list Return value about selected images | ||
| 275 | /// @return False if selection becomes canceled | ||
| 276 | /// | ||
| 277 | inline bool ATTRIBUTE_HIDDEN ShowAndGetImageList(const std::string& shares, | ||
| 278 | const std::string& heading, | ||
| 279 | std::vector<std::string>& file_list) | ||
| 280 | { | ||
| 281 | using namespace ::kodi::addon; | ||
| 282 | char** list = nullptr; | ||
| 283 | unsigned int listSize = 0; | ||
| 284 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_image_list( | ||
| 285 | CAddonBase::m_interface->toKodi->kodiBase, shares.c_str(), heading.c_str(), &list, &listSize); | ||
| 286 | if (ret) | ||
| 287 | { | ||
| 288 | for (unsigned int i = 0; i < listSize; ++i) | ||
| 289 | file_list.emplace_back(list[i]); | ||
| 290 | CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list( | ||
| 291 | CAddonBase::m_interface->toKodi->kodiBase, &list, listSize); | ||
| 292 | } | ||
| 293 | return ret; | ||
| 294 | } | ||
| 295 | //------------------------------------------------------------------------------ | ||
| 296 | }; // namespace FileBrowser | ||
| 297 | |||
| 298 | } /* namespace dialogs */ | ||
| 299 | } /* namespace gui */ | ||
| 300 | } /* namespace kodi */ | ||
| 301 | |||
| 302 | #endif /* __cplusplus */ | ||
