8#include <QtCore/qloggingcategory.h>
9#include <QtGui/private/qguiapplication_p.h>
10#include <QtGui/qpa/qplatformtheme.h>
11#include <QtQml/qqmlinfo.h>
12#include <QtQml/qqmlfile.h>
13#if QT_CONFIG(accessibility)
14#include <QtQuick/private/qquickaccessibleattached_p.h>
16#include <QtQuick/private/qquickitemview_p_p.h>
17#include <QtQuickTemplates2/private/qquickdialogbuttonbox_p_p.h>
18#include <QtQuickTemplates2/private/qquickpopupitem_p_p.h>
19#include <QtQuickControls2Impl/private/qquickplatformtheme_p.h>
20#include <QtQuickDialogs2Utils/private/qquickfilenamefilter_p.h>
27Q_STATIC_LOGGING_CATEGORY(lcCurrentFolder,
"qt.quick.dialogs.quickfiledialogimpl.currentFolder")
28Q_STATIC_LOGGING_CATEGORY(lcSelectedFile,
"qt.quick.dialogs.quickfiledialogimpl.selectedFile")
29Q_STATIC_LOGGING_CATEGORY(lcUpdateSelectedFile,
"qt.quick.dialogs.quickfiledialogimpl.updateSelectedFile")
30Q_STATIC_LOGGING_CATEGORY(lcOptions,
"qt.quick.dialogs.quickfiledialogimpl.options")
31Q_STATIC_LOGGING_CATEGORY(lcNameFilters,
"qt.quick.dialogs.quickfiledialogimpl.namefilters")
32Q_STATIC_LOGGING_CATEGORY(lcAttachedNameFilters,
"qt.quick.dialogs.quickfiledialogimplattached.namefilters")
33Q_STATIC_LOGGING_CATEGORY(lcAttachedCurrentIndex,
"qt.quick.dialogs.quickfiledialogimplattached.currentIndex")
35QQuickFileDialogImplPrivate::QQuickFileDialogImplPrivate()
39void QQuickFileDialogImplPrivate::setNameFilters(
const QStringList &filters)
41 Q_Q(QQuickFileDialogImpl);
42 if (filters == nameFilters)
45 nameFilters = filters;
46 emit q->nameFiltersChanged();
49void QQuickFileDialogImplPrivate::updateEnabled()
51 Q_Q(QQuickFileDialogImpl);
52 QQuickFileDialogImplAttached *attached = attachedOrWarn();
56 auto openButton = attached->buttonBox()->standardButton(QPlatformDialogHelper::Open);
58 qmlWarning(q).nospace() <<
"Can't update Open button's enabled state because it wasn't found";
62 openButton->setEnabled(!selectedFile.isEmpty() && attached->breadcrumbBar()
63 && !attached->breadcrumbBar()->textField()->isVisible());
67
68
69
70
71
72
73void QQuickFileDialogImplPrivate::updateSelectedFile(
const QString &oldFolderPath)
75 Q_Q(QQuickFileDialogImpl);
76 QQuickFileDialogImplAttached *attached = attachedOrWarn();
77 if (!attached || !attached->fileDialogListView())
80 qCDebug(lcUpdateSelectedFile) <<
"updateSelectedFile called with oldFolderPath" << oldFolderPath;
82 QString newSelectedFilePath;
83 int newSelectedFileIndex = -1;
84 const QString newFolderPath = QQmlFile::urlToLocalFileOrQrc(currentFolder);
85 if (!oldFolderPath.isEmpty() && !newFolderPath.isEmpty()) {
93 const int indexOfFolder = oldFolderPath.indexOf(newFolderPath);
94 if (indexOfFolder != -1) {
99 QStringList relativePaths = oldFolderPath.mid(indexOfFolder + newFolderPath.size()).split(QLatin1Char(
'/'), Qt::SkipEmptyParts);
100 newSelectedFilePath = newFolderPath + QLatin1Char(
'/') + relativePaths.first();
103 const QDir newFolderDir(newFolderPath);
105 if (!newFolderDir.exists()) {
106 qmlWarning(q) <<
"Directory" << newSelectedFilePath <<
"doesn't exist; can't get a file entry list for it";
110 const QFileInfoList filesInNewDir = fileList(newFolderDir);
111 const QFileInfo newSelectedFileInfo(newSelectedFilePath);
112 newSelectedFileIndex = filesInNewDir.indexOf(newSelectedFileInfo);
116 static const bool preselectFirstFile = []() {
117 const QVariant envVar = qEnvironmentVariable(
"QT_QUICK_DIALOGS_PRESELECT_FIRST_FILE");
118 if (envVar.isValid() && envVar.canConvert<
bool>())
119 return envVar.toBool();
120 return QGuiApplicationPrivate::platformTheme()->themeHint(
121 QPlatformTheme::PreselectFirstFileInDirectory).toBool();
124 if (preselectFirstFile && newSelectedFilePath.isEmpty()) {
131 const QDir newFolderDir(newFolderPath);
132 if (newFolderDir.exists()) {
133 if (!cachedFileList.isEmpty()) {
134 newSelectedFilePath = cachedFileList.first().absoluteFilePath();
135 newSelectedFileIndex = 0;
140 const QUrl newSelectedFileUrl = QUrl::fromLocalFile(newSelectedFilePath);
141 qCDebug(lcUpdateSelectedFile).nospace() <<
"updateSelectedFile is setting selectedFile to " << newSelectedFileUrl
142 <<
", newSelectedFileIndex is " << newSelectedFileIndex;
143 q->setSelectedFile(newSelectedFileUrl);
144 updateFileNameTextEdit();
147 if (newSelectedFileIndex != -1)
148 tryUpdateFileDialogListViewCurrentIndex(newSelectedFileIndex);
151void QQuickFileDialogImplPrivate::updateFileNameTextEdit()
153 QQuickFileDialogImplAttached *attached = attachedOrWarn();
154 if (Q_UNLIKELY(!attached))
157 const QFileInfo fileInfo(selectedFile.toLocalFile());
158 if (fileInfo.isFile())
159 attached->fileNameTextField()->setText(fileInfo.fileName());
162QDir::SortFlags QQuickFileDialogImplPrivate::fileListSortFlags()
164 QDir::SortFlags sortFlags = QDir::IgnoreCase;
165 if (QQuickPlatformTheme::getThemeHint(QPlatformTheme::ShowDirectoriesFirst).toBool())
166 sortFlags.setFlag(QDir::DirsFirst);
170QFileInfoList QQuickFileDialogImplPrivate::fileList(
const QDir &dir)
172 return dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot, fileListSortFlags());
175void QQuickFileDialogImplPrivate::setFileDialogListViewCurrentIndex(
int newCurrentIndex)
177 qCDebug(lcSelectedFile) <<
"setting fileDialogListView's currentIndex to" << newCurrentIndex;
182 QQuickFileDialogImplAttached *attached = attachedOrWarn();
183 const QSignalBlocker blocker(attached->fileDialogListView());
184 attached->fileDialogListView()->setCurrentIndex(newCurrentIndex);
185 attached->fileDialogListView()->positionViewAtIndex(newCurrentIndex, QQuickListView::Center);
186 if (QQuickItem *currentItem = attached->fileDialogListView()->currentItem())
187 currentItem->forceActiveFocus();
191
192
193
194
195
196void QQuickFileDialogImplPrivate::tryUpdateFileDialogListViewCurrentIndex(
int newCurrentIndex)
198 qCDebug(lcSelectedFile) <<
"tryUpdateFileDialogListViewCurrentIndex called with newCurrentIndex" << newCurrentIndex;
199 QQuickFileDialogImplAttached *attached = attachedOrWarn();
201 Q_ASSERT(attached->fileDialogListView());
206 if (newCurrentIndex != -1 && newCurrentIndex >= attached->fileDialogListView()->count()) {
207 qCDebug(lcSelectedFile) <<
"- trying to set currentIndex to" << newCurrentIndex
208 <<
"but fileDialogListView only has" << attached->fileDialogListView()->count()
209 <<
"items; setting pendingCurrentIndexToSet to" << newCurrentIndex;
210 pendingCurrentIndexToSet = newCurrentIndex;
211 QObjectPrivate::connect(attached->fileDialogListView(), &QQuickItemView::countChanged,
212 this, &QQuickFileDialogImplPrivate::fileDialogListViewCountChanged, Qt::ConnectionType(Qt::DirectConnection | Qt::UniqueConnection));
216 setFileDialogListViewCurrentIndex(newCurrentIndex);
219void QQuickFileDialogImplPrivate::fileDialogListViewCountChanged()
221 QQuickFileDialogImplAttached *attached = attachedOrWarn();
222 qCDebug(lcSelectedFile) <<
"fileDialogListView count changed to" << attached->fileDialogListView()->count();
224 if (pendingCurrentIndexToSet != -1 && pendingCurrentIndexToSet < attached->fileDialogListView()->count()) {
227 qCDebug(lcSelectedFile) <<
"- ListView has expected count;"
228 <<
"applying pending fileDialogListView currentIndex" << pendingCurrentIndexToSet;
230 QObjectPrivate::disconnect(attached->fileDialogListView(), &QQuickItemView::countChanged,
231 this, &QQuickFileDialogImplPrivate::fileDialogListViewCountChanged);
232 setFileDialogListViewCurrentIndex(pendingCurrentIndexToSet);
233 pendingCurrentIndexToSet = -1;
234 qCDebug(lcSelectedFile) <<
"- reset pendingCurrentIndexToSet to -1";
236 qCDebug(lcSelectedFile) <<
"- ListView doesn't yet have expected count of" << cachedFileList.size();
240void QQuickFileDialogImplPrivate::handleAccept()
245void QQuickFileDialogImplPrivate::handleClick(QQuickAbstractButton *button)
247 Q_Q(QQuickFileDialogImpl);
248 if (buttonRole(button) == QPlatformDialogHelper::AcceptRole && selectedFile.isValid()) {
250 const QFileInfo fileInfo(selectedFile.toLocalFile());
251 if (fileInfo.isDir()) {
253 q->setCurrentFolder(selectedFile);
258 lastButtonClicked = button;
261 const bool dontConfirmOverride = q->options()->testOption(QFileDialogOptions::DontConfirmOverwrite);
262 const bool isSaveMode = q->options()->fileMode() == QFileDialogOptions::AnyFile;
263 if (QQuickFileDialogImplAttached *attached = attachedOrWarn();
264 attached && fileInfo.exists() && isSaveMode && !dontConfirmOverride) {
265 QQuickDialog *confirmationDialog = attached->overwriteConfirmationDialog();
266 confirmationDialog->open();
274void QQuickFileDialogImplPrivate::selectFile()
276 Q_Q(QQuickFileDialogImpl);
277 Q_ASSERT(lastButtonClicked);
278 q->setSelectedFile(selectedFile);
280 QQuickDialogPrivate::handleClick(lastButtonClicked);
281 emit q->fileSelected(selectedFile);
284QQuickFileDialogImpl::QQuickFileDialogImpl(QObject *parent)
285 : QQuickDialog(*(
new QQuickFileDialogImplPrivate), parent)
289QQuickFileDialogImplAttached *QQuickFileDialogImpl::qmlAttachedProperties(QObject *object)
291 return new QQuickFileDialogImplAttached(object);
294QUrl QQuickFileDialogImpl::currentFolder()
const
296 Q_D(
const QQuickFileDialogImpl);
297 return d->currentFolder;
300void QQuickFileDialogImpl::setCurrentFolder(
const QUrl ¤tFolder, SetReason setReason)
302 Q_D(QQuickFileDialogImpl);
303 qCDebug(lcCurrentFolder).nospace() <<
"setCurrentFolder called with " << currentFolder
304 <<
" (old currentFolder is " << d->currentFolder <<
")";
310 if (!currentFolder.isEmpty())
311 d->cachedFileList = d->fileList(QQmlFile::urlToLocalFileOrQrc(currentFolder));
313 d->cachedFileList.clear();
314 qCDebug(lcCurrentFolder) <<
"- cachedFileList size is now " << d->cachedFileList.size();
316 if (currentFolder == d->currentFolder)
319 const QString oldFolderPath = QQmlFile::urlToLocalFileOrQrc(d->currentFolder);
321 d->currentFolder = currentFolder;
324 if (setReason == SetReason::External) {
326 d->updateSelectedFile(oldFolderPath);
328 emit currentFolderChanged(d->currentFolder);
331QUrl QQuickFileDialogImpl::selectedFile()
const
333 Q_D(
const QQuickFileDialogImpl);
334 return d->selectedFile;
338
339
340
341
342
343
344void QQuickFileDialogImpl::setSelectedFile(
const QUrl &selectedFile)
346 qCDebug(lcSelectedFile) <<
"setSelectedFile called with" << selectedFile;
347 Q_D(QQuickFileDialogImpl);
348 if (selectedFile == d->selectedFile)
351 d->selectedFile = selectedFile;
353 emit selectedFileChanged(d->selectedFile);
357
358
359
360
361
362void QQuickFileDialogImpl::setInitialCurrentFolderAndSelectedFile(
const QUrl &file)
364 Q_D(QQuickFileDialogImpl);
365 const QUrl fileDirUrl = QUrl::fromLocalFile(QFileInfo(file.toLocalFile()).dir().absolutePath());
366 const bool currentFolderChanged = d->currentFolder != fileDirUrl;
367 qCDebug(lcSelectedFile) <<
"setting initial currentFolder to" << fileDirUrl <<
"and selectedFile to" << file;
368 setCurrentFolder(fileDirUrl, QQuickFileDialogImpl::SetReason::Internal);
369 setSelectedFile(file);
370 d->updateFileNameTextEdit();
371 d->setCurrentIndexToInitiallySelectedFile =
true;
373 bool isListViewCurrentIndexNegative =
false;
374 if (
const auto *attached = d->attachedOrWarn())
375 isListViewCurrentIndexNegative = attached->fileDialogListView()->currentIndex() < 0;
381 if (!currentFolderChanged || isListViewCurrentIndexNegative) {
382 const QFileInfo newSelectedFileInfo(d->selectedFile.toLocalFile());
383 const int indexOfSelectedFileInFileDialogListView = d->cachedFileList.indexOf(newSelectedFileInfo);
384 d->tryUpdateFileDialogListViewCurrentIndex(indexOfSelectedFileInFileDialogListView);
388QSharedPointer<QFileDialogOptions> QQuickFileDialogImpl::options()
const
390 Q_D(
const QQuickFileDialogImpl);
394void QQuickFileDialogImpl::setOptions(
const QSharedPointer<QFileDialogOptions> &options)
396 qCDebug(lcOptions).nospace() <<
"setOptions called with:"
397 <<
" acceptMode=" << options->acceptMode()
398 <<
" fileMode=" << options->fileMode()
399 <<
" initialDirectory=" << options->initialDirectory()
400 <<
" nameFilters=" << options->nameFilters()
401 <<
" initiallySelectedNameFilter=" << options->initiallySelectedNameFilter();
403 Q_D(QQuickFileDialogImpl);
404 d->options = options;
407 d->selectedNameFilter->setOptions(options);
408 d->setNameFilters(options->nameFilters());
410 if (
auto attached = d->attachedOrWarn()) {
411 const bool isSaveMode = d->options->fileMode() == QFileDialogOptions::AnyFile;
412 attached->fileNameLabel()->setVisible(isSaveMode);
413 attached->fileNameTextField()->setVisible(isSaveMode);
419
420
421
422
423QStringList QQuickFileDialogImpl::nameFilters()
const
425 Q_D(
const QQuickFileDialogImpl);
426 return d->options ? d->options->nameFilters() : QStringList();
429void QQuickFileDialogImpl::resetNameFilters()
431 Q_D(QQuickFileDialogImpl);
432 d->setNameFilters(QStringList());
435QQuickFileNameFilter *QQuickFileDialogImpl::selectedNameFilter()
const
437 Q_D(
const QQuickFileDialogImpl);
438 if (!d->selectedNameFilter) {
439 QQuickFileDialogImpl *that =
const_cast<QQuickFileDialogImpl *>(
this);
440 d->selectedNameFilter =
new QQuickFileNameFilter(that);
442 d->selectedNameFilter->setOptions(d->options);
444 return d->selectedNameFilter;
448
449
450
451
452
453
454void QQuickFileDialogImpl::setAcceptLabel(
const QString &label)
456 Q_D(QQuickFileDialogImpl);
457 d->acceptLabel = label;
458 QQuickFileDialogImplAttached *attached = d->attachedOrWarn();
462 auto acceptButton = attached->buttonBox()->standardButton(QPlatformDialogHelper::Open);
464 qmlWarning(
this).nospace() <<
"Can't set accept label to " << label
465 <<
"; failed to find Open button in DialogButtonBox of " <<
this;
469 auto buttonType = (d->options && d->options->acceptMode() == QFileDialogOptions::AcceptSave)
470 ? QPlatformDialogHelper::Save
471 : QPlatformDialogHelper::Open;
472 acceptButton->setText(!label.isEmpty()
473 ? label : QQuickDialogButtonBoxPrivate::buttonText(buttonType));
476void QQuickFileDialogImpl::setRejectLabel(
const QString &label)
478 Q_D(QQuickFileDialogImpl);
479 d->rejectLabel = label;
480 QQuickFileDialogImplAttached *attached = d->attachedOrWarn();
484 auto rejectButton = attached->buttonBox()->standardButton(QPlatformDialogHelper::Cancel);
486 qmlWarning(
this).nospace() <<
"Can't set reject label to " << label
487 <<
"; failed to find Open button in DialogButtonBox of " <<
this;
491 rejectButton->setText(!label.isEmpty()
492 ? label : QQuickDialogButtonBoxPrivate::buttonText(QPlatformDialogHelper::Cancel));
495void QQuickFileDialogImpl::selectNameFilter(
const QString &filter)
497 qCDebug(lcNameFilters) <<
"selectNameFilter called with" << filter;
498 Q_D(QQuickFileDialogImpl);
499 d->selectedNameFilter->update(filter);
500 emit filterSelected(filter);
503QString QQuickFileDialogImpl::fileName()
const
505 return selectedFile().fileName();
507void QQuickFileDialogImpl::setFileName(
const QString &fileName)
509 const QString previous = selectedFile().fileName();
510 if (previous == fileName)
513 QUrl newSelectedFile;
514 newSelectedFile.setScheme(currentFolder().scheme());
515 newSelectedFile.setPath(currentFolder().path() + u'/' + fileName);
516 setSelectedFile(newSelectedFile);
519QString QQuickFileDialogImpl::currentFolderName()
const
521 return QDir(currentFolder().toLocalFile()).dirName();
524void QQuickFileDialogImpl::componentComplete()
526 Q_D(QQuickFileDialogImpl);
527 QQuickDialog::componentComplete();
533 QQuickFileDialogImplAttached *attached = d->attachedOrWarn();
537 const int buttonCount = attached->buttonBox()->count();
538 if (buttonCount == 0)
541 QQuickAbstractButton *rightMostButton = qobject_cast<QQuickAbstractButton *>(
542 attached->buttonBox()->itemAt(buttonCount - 1));
543 if (!rightMostButton) {
544 qmlWarning(
this) <<
"Can't find right-most button in DialogButtonBox";
548 auto keyNavigationAttached = QQuickKeyNavigationAttached::qmlAttachedProperties(rightMostButton);
549 if (!keyNavigationAttached) {
550 qmlWarning(
this) <<
"Can't create attached KeyNavigation object on" << QDebug::toString(rightMostButton);
554 keyNavigationAttached->setTab(attached->breadcrumbBar()->upButton());
556#if QT_CONFIG(accessibility)
557 auto *label = attached->filterLabel();
558 auto *comboBox = attached->nameFiltersComboBox();
559 if (label && comboBox)
560 if (QQuickAccessibleAttached *accessibleAttached = QQuickControlPrivate::accessibleAttached(label))
561 accessibleAttached->setLabelFor(comboBox);
565void QQuickFileDialogImpl::itemChange(QQuickItem::ItemChange change,
const QQuickItem::ItemChangeData &data)
567 Q_D(QQuickFileDialogImpl);
568 QQuickDialog::itemChange(change, data);
570 if (change != QQuickItem::ItemVisibleHasChanged || !isComponentComplete() || !data.boolValue)
573 QQuickFileDialogImplAttached *attached = d->attachedOrWarn();
577 attached->fileDialogListView()->forceActiveFocus();
581QQuickFileDialogImplAttached *QQuickFileDialogImplPrivate::attachedOrWarn()
583 Q_Q(QQuickFileDialogImpl);
584 QQuickFileDialogImplAttached *attached =
static_cast<QQuickFileDialogImplAttached*>(
585 qmlAttachedPropertiesObject<QQuickFileDialogImpl>(q,
false));
587 qmlWarning(q) <<
"Expected FileDialogImpl attached object to be present on" <<
this;
593 qCDebug(lcAttachedNameFilters) <<
"nameFiltersComboBoxItemActivated called with" << index;
594 auto fileDialogImpl = qobject_cast<QQuickFileDialogImpl*>(parent);
598 fileDialogImpl->selectNameFilter(nameFiltersComboBox->textAt(index));
603 auto fileDialogImpl = qobject_cast<QQuickFileDialogImpl*>(parent);
607 auto fileDialogDelegate = qobject_cast<QQuickFileDialogDelegate*>(fileDialogListView->currentItem());
608 if (!fileDialogDelegate)
611 const QQuickItemViewPrivate::MovementReason moveReason = QQuickItemViewPrivate::get(fileDialogListView)->moveReason;
612 qCDebug(lcAttachedCurrentIndex).nospace() <<
"fileDialogListView currentIndex changed to " << fileDialogListView->currentIndex()
613 <<
" with moveReason " << moveReason
614 <<
"; the file at that index is " << fileDialogDelegate->file();
620 auto fileDialogImplPrivate = QQuickFileDialogImplPrivate::get(fileDialogImpl);
621 if (moveReason != QQuickItemViewPrivate::Other) {
622 fileDialogImpl->setSelectedFile(fileDialogDelegate->file());
623 fileDialogImplPrivate->updateFileNameTextEdit();
624 }
else if (fileDialogImplPrivate->setCurrentIndexToInitiallySelectedFile) {
629 const QFileInfo newSelectedFileInfo(fileDialogImplPrivate->selectedFile.toLocalFile());
630 const int indexOfSelectedFileInFileDialogListView = fileDialogImplPrivate->cachedFileList.indexOf(newSelectedFileInfo);
631 fileDialogImplPrivate->tryUpdateFileDialogListViewCurrentIndex(indexOfSelectedFileInFileDialogListView);
632 fileDialogImplPrivate->setCurrentIndexToInitiallySelectedFile =
false;
640 auto openButton = buttonBox->standardButton(QPlatformDialogHelper::Open);
641 if (!openButton || !fileNameTextField)
643 openButton->setEnabled(!fileNameTextField->text().isEmpty());
648 auto fileDialogImpl = qobject_cast<QQuickFileDialogImpl *>(parent);
652 fileDialogImpl->setFileName(fileNameTextField->text());
655QQuickFileDialogImplAttached::QQuickFileDialogImplAttached(QObject *parent)
656 : QObject(*(
new QQuickFileDialogImplAttachedPrivate), parent)
658 if (!qobject_cast<QQuickFileDialogImpl*>(parent)) {
659 qmlWarning(
this) <<
"FileDialogImpl attached properties should only be "
660 <<
"accessed through the root FileDialogImpl instance";
664QQuickDialogButtonBox *QQuickFileDialogImplAttached::buttonBox()
const
666 Q_D(
const QQuickFileDialogImplAttached);
670void QQuickFileDialogImplAttached::setButtonBox(QQuickDialogButtonBox *buttonBox)
672 Q_D(QQuickFileDialogImplAttached);
673 if (buttonBox == d->buttonBox)
677 QQuickFileDialogImpl *fileDialogImpl = qobject_cast<QQuickFileDialogImpl*>(parent());
678 if (fileDialogImpl) {
679 auto dialogPrivate = QQuickDialogPrivate::get(fileDialogImpl);
680 QObjectPrivate::disconnect(d->buttonBox, &QQuickDialogButtonBox::accepted,
681 dialogPrivate, &QQuickDialogPrivate::handleAccept);
682 QObjectPrivate::disconnect(d->buttonBox, &QQuickDialogButtonBox::rejected,
683 dialogPrivate, &QQuickDialogPrivate::handleReject);
684 QObjectPrivate::disconnect(d->buttonBox, &QQuickDialogButtonBox::clicked,
685 dialogPrivate, &QQuickDialogPrivate::handleClick);
689 d->buttonBox = buttonBox;
692 QQuickFileDialogImpl *fileDialogImpl = qobject_cast<QQuickFileDialogImpl*>(parent());
693 if (fileDialogImpl) {
694 auto dialogPrivate = QQuickDialogPrivate::get(fileDialogImpl);
695 QObjectPrivate::connect(d->buttonBox, &QQuickDialogButtonBox::accepted,
696 dialogPrivate, &QQuickDialogPrivate::handleAccept);
697 QObjectPrivate::connect(d->buttonBox, &QQuickDialogButtonBox::rejected,
698 dialogPrivate, &QQuickDialogPrivate::handleReject);
699 QObjectPrivate::connect(d->buttonBox, &QQuickDialogButtonBox::clicked,
700 dialogPrivate, &QQuickDialogPrivate::handleClick);
704 emit buttonBoxChanged();
707QQuickComboBox *QQuickFileDialogImplAttached::nameFiltersComboBox()
const
709 Q_D(
const QQuickFileDialogImplAttached);
710 return d->nameFiltersComboBox;
713void QQuickFileDialogImplAttached::setNameFiltersComboBox(QQuickComboBox *nameFiltersComboBox)
715 Q_D(QQuickFileDialogImplAttached);
716 if (nameFiltersComboBox == d->nameFiltersComboBox)
719 d->nameFiltersComboBox = nameFiltersComboBox;
721 QObjectPrivate::connect(d->nameFiltersComboBox, &QQuickComboBox::activated,
722 d, &QQuickFileDialogImplAttachedPrivate::nameFiltersComboBoxItemActivated);
724 emit nameFiltersComboBoxChanged();
727QQuickLabel *QQuickFileDialogImplAttached::filterLabel()
const
729 Q_D(
const QQuickFileDialogImplAttached);
730 return d->filterLabel;
733void QQuickFileDialogImplAttached::setFilterLabel(QQuickLabel *label)
735 Q_D(QQuickFileDialogImplAttached);
737 if (d->filterLabel == label)
740 d->filterLabel = label;
742 emit filterLabelChanged();
745QString QQuickFileDialogImplAttached::selectedNameFilter()
const
747 Q_D(
const QQuickFileDialogImplAttached);
748 return d->nameFiltersComboBox ? d->nameFiltersComboBox->currentText() : QString();
751void QQuickFileDialogImplAttached::selectNameFilter(
const QString &filter)
753 Q_D(QQuickFileDialogImplAttached);
754 qCDebug(lcAttachedNameFilters) <<
"selectNameFilter called with" << filter;
755 if (!d->nameFiltersComboBox)
758 const int indexInComboBox = d->nameFiltersComboBox->find(filter);
759 if (indexInComboBox == -1)
762 qCDebug(lcAttachedNameFilters) <<
"setting ComboBox's currentIndex to" << indexInComboBox;
763 d->nameFiltersComboBox->setCurrentIndex(indexInComboBox);
766QQuickListView *QQuickFileDialogImplAttached::fileDialogListView()
const
768 Q_D(
const QQuickFileDialogImplAttached);
769 return d->fileDialogListView;
772void QQuickFileDialogImplAttached::setFileDialogListView(QQuickListView *fileDialogListView)
774 Q_D(QQuickFileDialogImplAttached);
775 if (fileDialogListView == d->fileDialogListView)
778 if (d->fileDialogListView)
779 QObjectPrivate::disconnect(d->fileDialogListView, &QQuickListView::currentIndexChanged,
780 d, &QQuickFileDialogImplAttachedPrivate::fileDialogListViewCurrentIndexChanged);
782 d->fileDialogListView = fileDialogListView;
784 if (d->fileDialogListView)
785 QObjectPrivate::connect(d->fileDialogListView, &QQuickListView::currentIndexChanged,
786 d, &QQuickFileDialogImplAttachedPrivate::fileDialogListViewCurrentIndexChanged);
788 emit fileDialogListViewChanged();
791QQuickFolderBreadcrumbBar *QQuickFileDialogImplAttached::breadcrumbBar()
const
793 Q_D(
const QQuickFileDialogImplAttached);
794 return d->breadcrumbBar;
797void QQuickFileDialogImplAttached::setBreadcrumbBar(QQuickFolderBreadcrumbBar *breadcrumbBar)
799 Q_D(QQuickFileDialogImplAttached);
800 if (breadcrumbBar == d->breadcrumbBar)
803 d->breadcrumbBar = breadcrumbBar;
804 emit breadcrumbBarChanged();
807QQuickLabel *QQuickFileDialogImplAttached::fileNameLabel()
const
809 Q_D(
const QQuickFileDialogImplAttached);
810 return d->fileNameLabel;
813void QQuickFileDialogImplAttached::setFileNameLabel(QQuickLabel *fileNameLabel)
815 Q_D(QQuickFileDialogImplAttached);
816 if (fileNameLabel == d->fileNameLabel)
819 d->fileNameLabel = fileNameLabel;
821 emit fileNameLabelChanged();
824QQuickTextField *QQuickFileDialogImplAttached::fileNameTextField()
const
826 Q_D(
const QQuickFileDialogImplAttached);
827 return d->fileNameTextField;
830void QQuickFileDialogImplAttached::setFileNameTextField(QQuickTextField *fileNameTextField)
832 Q_D(QQuickFileDialogImplAttached);
833 if (fileNameTextField == d->fileNameTextField)
836 if (d->fileNameTextField) {
837 QObjectPrivate::disconnect(d->fileNameTextField, &QQuickTextField::editingFinished,
838 d, &QQuickFileDialogImplAttachedPrivate::fileNameEditingByUserFinished);
839 QObjectPrivate::disconnect(d->fileNameTextField, &QQuickTextField::textEdited,
840 d, &QQuickFileDialogImplAttachedPrivate::fileNameEditedByUser);
843 d->fileNameTextField = fileNameTextField;
845 if (d->fileNameTextField) {
846 QObjectPrivate::connect(d->fileNameTextField, &QQuickTextField::editingFinished,
847 d, &QQuickFileDialogImplAttachedPrivate::fileNameEditingByUserFinished);
848 QObjectPrivate::connect(d->fileNameTextField, &QQuickTextField::textEdited,
849 d, &QQuickFileDialogImplAttachedPrivate::fileNameEditedByUser);
851 emit fileNameTextFieldChanged();
854QQuickDialog *QQuickFileDialogImplAttached::overwriteConfirmationDialog()
const
856 Q_D(
const QQuickFileDialogImplAttached);
857 return d->overwriteConfirmationDialog;
860void QQuickFileDialogImplAttached::setOverwriteConfirmationDialog(QQuickDialog *dialog)
862 Q_D(QQuickFileDialogImplAttached);
863 if (dialog == d->overwriteConfirmationDialog)
866 QQuickFileDialogImpl *fileDialogImpl = qobject_cast<QQuickFileDialogImpl*>(parent());
867 if (d->overwriteConfirmationDialog && fileDialogImpl)
868 QObjectPrivate::disconnect(d->overwriteConfirmationDialog, &QQuickDialog::accepted,
869 QQuickFileDialogImplPrivate::get(fileDialogImpl), &QQuickFileDialogImplPrivate::selectFile);
871 d->overwriteConfirmationDialog = dialog;
873 if (d->overwriteConfirmationDialog && fileDialogImpl)
874 QObjectPrivate::connect(d->overwriteConfirmationDialog, &QQuickDialog::accepted,
875 QQuickFileDialogImplPrivate::get(fileDialogImpl), &QQuickFileDialogImplPrivate::selectFile, Qt::QueuedConnection);
877 emit overwriteConfirmationDialogChanged();
880QQuickSideBar *QQuickFileDialogImplAttached::sideBar()
const
882 Q_D(
const QQuickFileDialogImplAttached);
886void QQuickFileDialogImplAttached::setSideBar(QQuickSideBar *sideBar)
888 Q_D(QQuickFileDialogImplAttached);
889 if (sideBar == d->sideBar)
892 d->sideBar = sideBar;
894 emit sideBarChanged();
899#include "moc_qquickfiledialogimpl_p.cpp"
Combined button and popup list for selecting options.