Skip to content
Snippets Groups Projects
Commit b97aec31 authored by dt's avatar dt
Browse files

Path Chooser: Add a basedirectory

Reviewed-By: Friedemann Kleint
parent 02a4fc72
No related branches found
No related tags found
No related merge requests found
...@@ -89,6 +89,7 @@ struct PathChooserPrivate ...@@ -89,6 +89,7 @@ struct PathChooserPrivate
QString m_dialogTitleOverride; QString m_dialogTitleOverride;
QString m_dialogFilter; QString m_dialogFilter;
QString m_initialBrowsePathOverride; QString m_initialBrowsePathOverride;
QString m_baseDirectory;
}; };
PathChooserPrivate::PathChooserPrivate(PathChooser *chooser) : PathChooserPrivate::PathChooserPrivate(PathChooser *chooser) :
...@@ -142,9 +143,23 @@ QAbstractButton *PathChooser::buttonAtIndex(int index) const ...@@ -142,9 +143,23 @@ QAbstractButton *PathChooser::buttonAtIndex(int index) const
return findChildren<QAbstractButton*>().at(index); return findChildren<QAbstractButton*>().at(index);
} }
QString PathChooser::baseDirectory() const
{
return m_d->m_baseDirectory;
}
void PathChooser::setBaseDirectory(const QString &directory)
{
m_d->m_baseDirectory = directory;
}
QString PathChooser::path() const QString PathChooser::path() const
{ {
return m_d->m_lineEdit->text(); const QString path = m_d->m_lineEdit->text();
if (!m_d->m_baseDirectory.isEmpty() && QFileInfo(path).isRelative())
return QFileInfo(m_d->m_baseDirectory + QLatin1Char('/') + path).absoluteFilePath();
else
return QFileInfo(path).absoluteFilePath();
} }
void PathChooser::setPath(const QString &path) void PathChooser::setPath(const QString &path)
......
...@@ -56,6 +56,7 @@ class QTCREATOR_UTILS_EXPORT PathChooser : public QWidget ...@@ -56,6 +56,7 @@ class QTCREATOR_UTILS_EXPORT PathChooser : public QWidget
Q_PROPERTY(QString path READ path WRITE setPath DESIGNABLE true) Q_PROPERTY(QString path READ path WRITE setPath DESIGNABLE true)
Q_PROPERTY(QString promptDialogTitle READ promptDialogTitle WRITE setPromptDialogTitle DESIGNABLE true) Q_PROPERTY(QString promptDialogTitle READ promptDialogTitle WRITE setPromptDialogTitle DESIGNABLE true)
Q_PROPERTY(Kind expectedKind READ expectedKind WRITE setExpectedKind DESIGNABLE true) Q_PROPERTY(Kind expectedKind READ expectedKind WRITE setExpectedKind DESIGNABLE true)
Q_PROPERTY(QString baseDirectory READ baseDirectory WRITE setBaseDirectory DESIGNABLE true)
public: public:
static const char * const browseButtonLabel; static const char * const browseButtonLabel;
...@@ -87,6 +88,9 @@ public: ...@@ -87,6 +88,9 @@ public:
QString path() const; QString path() const;
QString baseDirectory() const;
void setBaseDirectory(const QString &directory);
/** Returns the suggested label title when used in a form layout. */ /** Returns the suggested label title when used in a form layout. */
static QString label(); static QString label();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment