| 201 | namespace FileDialog { |
| 202 | |
| 203 | void GetOpenPath( |
| 204 | QPointer<QWidget> parent, |
| 205 | const QString &caption, |
| 206 | const QString &filter, |
| 207 | Fn<void(OpenResult &&result)> callback, |
| 208 | Fn<void()> failed) { |
| 209 | InvokeQueued(QCoreApplication::instance(), [=] { |
| 210 | auto files = QStringList(); |
| 211 | auto remoteContent = QByteArray(); |
| 212 | Ui::PreventDelayedActivation(); |
| 213 | const auto success = Platform::FileDialog::Get( |
| 214 | parent, |
| 215 | files, |
| 216 | remoteContent, |
| 217 | caption, |
| 218 | filter, |
| 219 | FileDialog::internal::Type::ReadFile); |
| 220 | if (success |
| 221 | && ((!files.isEmpty() && !files[0].isEmpty()) |
| 222 | || !remoteContent.isEmpty())) { |
| 223 | if (callback) { |
| 224 | auto result = OpenResult(); |
| 225 | if (!files.isEmpty() && !files[0].isEmpty()) { |
| 226 | result.paths.push_back(files[0]); |
| 227 | } |
| 228 | result.remoteContent = remoteContent; |
| 229 | callback(std::move(result)); |
| 230 | } |
| 231 | } else if (failed) { |
| 232 | failed(); |
| 233 | } |
| 234 | }); |
| 235 | } |
| 236 | |
| 237 | void GetOpenPaths( |
| 238 | QPointer<QWidget> parent, |
no test coverage detected