Changeset View
Changeset View
Standalone View
Standalone View
src/filechooser.cpp
Show First 20 Lines • Show All 127 Lines • ▼ Show 20 Line(s) | 127 | { | |||
---|---|---|---|---|---|
128 | Q_UNUSED(app_id); | 128 | Q_UNUSED(app_id); | ||
129 | 129 | | |||
130 | qCDebug(XdgDesktopPortalKdeFileChooser) << "OpenFile called with parameters:"; | 130 | qCDebug(XdgDesktopPortalKdeFileChooser) << "OpenFile called with parameters:"; | ||
131 | qCDebug(XdgDesktopPortalKdeFileChooser) << " handle: " << handle.path(); | 131 | qCDebug(XdgDesktopPortalKdeFileChooser) << " handle: " << handle.path(); | ||
132 | qCDebug(XdgDesktopPortalKdeFileChooser) << " parent_window: " << parent_window; | 132 | qCDebug(XdgDesktopPortalKdeFileChooser) << " parent_window: " << parent_window; | ||
133 | qCDebug(XdgDesktopPortalKdeFileChooser) << " title: " << title; | 133 | qCDebug(XdgDesktopPortalKdeFileChooser) << " title: " << title; | ||
134 | qCDebug(XdgDesktopPortalKdeFileChooser) << " options: " << options; | 134 | qCDebug(XdgDesktopPortalKdeFileChooser) << " options: " << options; | ||
135 | 135 | | |||
136 | bool directory = false; | ||||
136 | bool modalDialog = true; | 137 | bool modalDialog = true; | ||
137 | bool multipleFiles = false; | 138 | bool multipleFiles = false; | ||
138 | QString acceptLabel; | 139 | QString acceptLabel; | ||
139 | QStringList nameFilters; | 140 | QStringList nameFilters; | ||
140 | QStringList mimeTypeFilters; | 141 | QStringList mimeTypeFilters; | ||
141 | 142 | | |||
142 | /* TODO | 143 | /* TODO | ||
143 | * choices a(ssa(ss)s) | 144 | * choices a(ssa(ss)s) | ||
Show All 14 Lines | |||||
158 | if (options.contains(QStringLiteral("modal"))) { | 159 | if (options.contains(QStringLiteral("modal"))) { | ||
159 | modalDialog = options.value(QStringLiteral("modal")).toBool(); | 160 | modalDialog = options.value(QStringLiteral("modal")).toBool(); | ||
160 | } | 161 | } | ||
161 | 162 | | |||
162 | if (options.contains(QStringLiteral("multiple"))) { | 163 | if (options.contains(QStringLiteral("multiple"))) { | ||
163 | multipleFiles = options.value(QStringLiteral("multiple")).toBool(); | 164 | multipleFiles = options.value(QStringLiteral("multiple")).toBool(); | ||
164 | } | 165 | } | ||
165 | 166 | | |||
167 | if (options.contains(QStringLiteral("directory"))) { | ||||
broulik: This check isn't needed, but is probably consistent with the rest and should be cleaned up… | |||||
168 | directory = options.value(QStringLiteral("directory")).toBool(); | ||||
169 | } | ||||
170 | | ||||
166 | if (options.contains(QStringLiteral("filters"))) { | 171 | if (options.contains(QStringLiteral("filters"))) { | ||
167 | FilterListList filterListList = qdbus_cast<FilterListList>(options.value(QStringLiteral("filters"))); | 172 | FilterListList filterListList = qdbus_cast<FilterListList>(options.value(QStringLiteral("filters"))); | ||
168 | for (const FilterList &filterList : filterListList) { | 173 | for (const FilterList &filterList : filterListList) { | ||
169 | QStringList filterStrings; | 174 | QStringList filterStrings; | ||
170 | for (const Filter &filterStruct : filterList.filters) { | 175 | for (const Filter &filterStruct : filterList.filters) { | ||
171 | if (filterStruct.type == 0) { | 176 | if (filterStruct.type == 0) { | ||
172 | filterStrings << filterStruct.filterString; | 177 | filterStrings << filterStruct.filterString; | ||
173 | } else { | 178 | } else { | ||
174 | mimeTypeFilters << filterStruct.filterString; | 179 | mimeTypeFilters << filterStruct.filterString; | ||
175 | } | 180 | } | ||
176 | } | 181 | } | ||
177 | 182 | | |||
178 | if (!filterStrings.isEmpty()) { | 183 | if (!filterStrings.isEmpty()) { | ||
179 | nameFilters << QStringLiteral("%1|%2").arg(filterStrings.join(QLatin1Char(' '))).arg(filterList.userVisibleName); | 184 | nameFilters << QStringLiteral("%1|%2").arg(filterStrings.join(QLatin1Char(' '))).arg(filterList.userVisibleName); | ||
180 | } | 185 | } | ||
181 | } | 186 | } | ||
182 | } | 187 | } | ||
183 | 188 | | |||
184 | QScopedPointer<FileDialog, QScopedPointerDeleteLater> fileDialog(new FileDialog()); | 189 | QScopedPointer<FileDialog, QScopedPointerDeleteLater> fileDialog(new FileDialog()); | ||
185 | Utils::setParentWindow(fileDialog.data(), parent_window); | 190 | Utils::setParentWindow(fileDialog.data(), parent_window); | ||
186 | fileDialog->setWindowTitle(title); | 191 | fileDialog->setWindowTitle(title); | ||
187 | fileDialog->setModal(modalDialog); | 192 | fileDialog->setModal(modalDialog); | ||
188 | fileDialog->m_fileWidget->setMode(multipleFiles ? KFile::Mode::Files | KFile::Mode::ExistingOnly : KFile::Mode::File | KFile::Mode::ExistingOnly); | 193 | KFile::Mode mode = directory ? KFile::Mode::Directory : multipleFiles ? KFile::Mode::Files : KFile::Mode::File; | ||
194 | fileDialog->m_fileWidget->setMode(mode | KFile::Mode::ExistingOnly); | ||||
189 | fileDialog->m_fileWidget->okButton()->setText(!acceptLabel.isEmpty() ? acceptLabel : i18n("Open")); | 195 | fileDialog->m_fileWidget->okButton()->setText(!acceptLabel.isEmpty() ? acceptLabel : i18n("Open")); | ||
190 | 196 | | |||
191 | if (!nameFilters.isEmpty()) { | 197 | if (!nameFilters.isEmpty()) { | ||
192 | fileDialog->m_fileWidget->setFilter(nameFilters.join(QLatin1Char('\n'))); | 198 | fileDialog->m_fileWidget->setFilter(nameFilters.join(QLatin1Char('\n'))); | ||
193 | } | 199 | } | ||
194 | 200 | | |||
195 | if (!mimeTypeFilters.isEmpty()) { | 201 | if (!mimeTypeFilters.isEmpty()) { | ||
196 | fileDialog->m_fileWidget->setMimeFilter(mimeTypeFilters); | 202 | fileDialog->m_fileWidget->setMimeFilter(mimeTypeFilters); | ||
▲ Show 20 Lines • Show All 128 Lines • Show Last 20 Lines |
This check isn't needed, but is probably consistent with the rest and should be cleaned up separately afterwards