From b0e41abf5a4a2b6abfe074e6d796edce38ec2acb Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Wed, 1 Dec 2021 17:35:21 +0300 Subject: [PATCH] Allow to set placeholder for FileSystemPathEdit --- src/gui/fspathedit.cpp | 12 ++++++++++++ src/gui/fspathedit.h | 3 +++ src/gui/fspathedit_p.cpp | 20 ++++++++++++++++++++ src/gui/fspathedit_p.h | 6 ++++++ 4 files changed, 41 insertions(+) diff --git a/src/gui/fspathedit.cpp b/src/gui/fspathedit.cpp index be8e15c16..9d36cb84c 100644 --- a/src/gui/fspathedit.cpp +++ b/src/gui/fspathedit.cpp @@ -247,6 +247,18 @@ void FileSystemPathEdit::setFileNameFilter(const QString &val) #endif } +QString FileSystemPathEdit::placeholder() const +{ + Q_D(const FileSystemPathEdit); + return d->m_editor->placeholder(); +} + +void FileSystemPathEdit::setPlaceholder(const QString &val) +{ + Q_D(FileSystemPathEdit); + d->m_editor->setPlaceholder(val); +} + bool FileSystemPathEdit::briefBrowseButtonCaption() const { Q_D(const FileSystemPathEdit); diff --git a/src/gui/fspathedit.h b/src/gui/fspathedit.h index d9f9d5e63..f6ba65cb7 100644 --- a/src/gui/fspathedit.h +++ b/src/gui/fspathedit.h @@ -71,6 +71,9 @@ public: QString fileNameFilter() const; void setFileNameFilter(const QString &val); + QString placeholder() const; + void setPlaceholder(const QString &val); + /// The browse button caption is "..." if true, and "Browse" otherwise bool briefBrowseButtonCaption() const; void setBriefBrowseButtonCaption(bool brief); diff --git a/src/gui/fspathedit_p.cpp b/src/gui/fspathedit_p.cpp index f2c8c294a..5565d1cc2 100644 --- a/src/gui/fspathedit_p.cpp +++ b/src/gui/fspathedit_p.cpp @@ -240,6 +240,16 @@ void Private::FileLineEdit::setValidator(QValidator *validator) QLineEdit::setValidator(validator); } +QString Private::FileLineEdit::placeholder() const +{ + return placeholderText(); +} + +void Private::FileLineEdit::setPlaceholder(const QString &val) +{ + setPlaceholderText(val); +} + QWidget *Private::FileLineEdit::widget() { return this; @@ -346,6 +356,16 @@ void Private::FileComboEdit::setValidator(QValidator *validator) lineEdit()->setValidator(validator); } +QString Private::FileComboEdit::placeholder() const +{ + return lineEdit()->placeholderText(); +} + +void Private::FileComboEdit::setPlaceholder(const QString &val) +{ + lineEdit()->setPlaceholderText(val); +} + void Private::FileComboEdit::setFilenameFilters(const QStringList &filters) { static_cast(lineEdit())->setFilenameFilters(filters); diff --git a/src/gui/fspathedit_p.h b/src/gui/fspathedit_p.h index 8f443b4d2..15b1305dd 100644 --- a/src/gui/fspathedit_p.h +++ b/src/gui/fspathedit_p.h @@ -105,6 +105,8 @@ namespace Private virtual void setFilenameFilters(const QStringList &filters) = 0; virtual void setBrowseAction(QAction *action) = 0; virtual void setValidator(QValidator *validator) = 0; + virtual QString placeholder() const = 0; + virtual void setPlaceholder(const QString &val) = 0; virtual QWidget *widget() = 0; }; @@ -121,6 +123,8 @@ namespace Private void setFilenameFilters(const QStringList &filters) override; void setBrowseAction(QAction *action) override; void setValidator(QValidator *validator) override; + QString placeholder() const override; + void setPlaceholder(const QString &val) override; QWidget *widget() override; protected: @@ -149,6 +153,8 @@ namespace Private void setFilenameFilters(const QStringList &filters) override; void setBrowseAction(QAction *action) override; void setValidator(QValidator *validator) override; + QString placeholder() const override; + void setPlaceholder(const QString &val) override; QWidget *widget() override; protected: