10#include <config-libkleo.h>
12#include "filenamerequester.h"
14#include <KLocalizedString>
19#include <QFileSystemModel>
27class Q_DECL_HIDDEN FileNameRequester::FileNameRequesterPrivate
29 friend class ::Kleo::FileNameRequester;
30 FileNameRequester *
const q;
33 explicit FileNameRequesterPrivate(FileNameRequester *qq);
34 ~FileNameRequesterPrivate();
37 void slotButtonClicked();
55FileNameRequester::FileNameRequesterPrivate::FileNameRequesterPrivate(FileNameRequester *qq)
60 , completer(&dirmodel)
81 button.setToolTip(
i18nc(
"@info:tooltip",
"Open file dialog"));
82 button.setAccessibleName(
i18n(
"Open file dialog"));
84 lineedit.setCompleter(&completer);
86 lineedit.setClearButtonEnabled(
true);
87 hlay.setContentsMargins(0, 0, 0, 0);
88 hlay.addWidget(&lineedit);
89 hlay.addWidget(&button);
90 q->setFocusPolicy(lineedit.focusPolicy());
91 q->setFocusProxy(&lineedit);
99FileNameRequester::FileNameRequesterPrivate::~FileNameRequesterPrivate()
103FileNameRequester::FileNameRequester(
QWidget *p)
105 , d(new FileNameRequesterPrivate(this))
111 , d(new FileNameRequesterPrivate(this))
113#ifndef QT_NO_DIRMODEL
114 d->dirmodel.setFilter(f);
120FileNameRequester::~FileNameRequester() =
default;
122void FileNameRequester::setFileName(
const QString &file)
124 d->lineedit.setText(file);
127QString FileNameRequester::fileName()
const
129 return d->lineedit.text();
132void FileNameRequester::setExistingOnly(
bool on)
134 d->existingOnly = on;
137bool FileNameRequester::existingOnly()
const
139 return d->existingOnly;
144#ifndef QT_NO_DIRMODEL
145 d->dirmodel.setFilter(f);
153#ifndef QT_NO_DIRMODEL
154 return d->dirmodel.filter();
160void FileNameRequester::setNameFilter(
const QString &nameFilter)
162 d->nameFilter = nameFilter;
165QString FileNameRequester::nameFilter()
const
167 return d->nameFilter;
170void FileNameRequester::setAccessibleNameOfLineEdit(
const QString &name)
172 d->lineedit.setAccessibleName(name);
175void FileNameRequester::FileNameRequesterPrivate::slotButtonClicked()
177 const QString fileName = q->requestFileName();
179 q->setFileName(fileName);
183bool FileNameRequester::event(
QEvent *e)
186 d->lineedit.setToolTip(
toolTip());
191QString FileNameRequester::requestFileName()
193#ifndef QT_NO_FILEDIALOG
197 }
else if (d->existingOnly) {
207void FileNameRequester::setButtonHint(
const QString &text)
209 d->button.setToolTip(text);
210 d->button.setAccessibleName(text);
213#include "moc_filenamerequester.cpp"
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
QString getExistingDirectory(QWidget *parent, const QString &caption, const QString &dir, Options options)
QString getOpenFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, Options options)
QString getSaveFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, Options options)
QIcon fromTheme(const QString &name)
void textChanged(const QString &text)
bool isEmpty() const const
QFuture< void > filter(QThreadPool *pool, Sequence &sequence, KeepFunctor &&filterFunction)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)