diff --git a/src/plugins/qmldesigner/components/propertyeditor/filewidget.cpp b/src/plugins/qmldesigner/components/propertyeditor/filewidget.cpp index 1b26f8c9364238212212502e182e6086c4fbca7c..28dc745ab923606b5169c461bc6e2f77a6225e6f 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/filewidget.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/filewidget.cpp @@ -40,7 +40,7 @@ QT_BEGIN_NAMESPACE FileWidget::FileWidget(QWidget *parent) : QWidget(parent), m_filter("(*.*)"), m_showComboBox(false), m_lock(false) { - m_pushButton = new QPushButton(this); + m_pushButton = new QToolButton(this); m_pushButton->setFixedWidth(32); m_lineEdit = new QLineEdit(this); m_comboBox = new QComboBox(this); @@ -126,16 +126,20 @@ void FileWidget::setupComboBox() m_lock = true; m_comboBox->clear(); - if (m_itemNode.isValid()) { - QDir dir = QFileInfo(m_itemNode.modelNode().model()->fileUrl().toLocalFile()).absoluteDir(); - QStringList filterList = m_filter.split(' '); - QDirIterator it(dir.absolutePath(), filterList, QDir::Files, QDirIterator::Subdirectories); - while (it.hasNext()) { - QString absolutePath = it.next(); - m_comboBox->addItem(dir.relativeFilePath(absolutePath)); - } - } + QDir dir; + + if (m_itemNode.isValid()) + dir = QFileInfo(m_itemNode.modelNode().model()->fileUrl().toLocalFile()).absoluteDir(); + else if (m_path.isValid()) + dir = QFileInfo(m_path.toLocalFile()).absoluteDir(); + QStringList filterList = m_filter.split(' '); + + QDirIterator it(dir.absolutePath(), filterList, QDir::Files, QDirIterator::Subdirectories); + while (it.hasNext()) { + QString absolutePath = it.next(); + m_comboBox->addItem(dir.relativeFilePath(absolutePath)); + } m_comboBox->setEditText(m_fileName.toString()); m_lock = false; diff --git a/src/plugins/qmldesigner/components/propertyeditor/filewidget.h b/src/plugins/qmldesigner/components/propertyeditor/filewidget.h index c3d93e90ceadc8d10e642c1355cfb55968431160..f0c25a1b25e6a7be7fbbd39b0ed44994b264d62d 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/filewidget.h +++ b/src/plugins/qmldesigner/components/propertyeditor/filewidget.h @@ -33,7 +33,7 @@ #include <QtGui/QWidget> #include <QLabel> -#include <QPushButton> +#include <QToolButton> #include <QLineEdit> #include <QComboBox> #include <QUrl> @@ -49,7 +49,8 @@ class FileWidget : public QWidget Q_PROPERTY(QString fileName READ fileName WRITE setFileNameStr NOTIFY fileNameChanged) Q_PROPERTY(QString filter READ filter WRITE setFilter) Q_PROPERTY(bool showComboBox READ showComboBox WRITE setShowComboBox) - Q_PROPERTY(QVariant itemNode READ itemNode WRITE setItemNode NOTIFY itemNodeChanged) + Q_PROPERTY(QVariant itemNode READ itemNode WRITE setItemNode NOTIFY itemNodeChanged) + Q_PROPERTY(QUrl path READ path WRITE setPath) public: @@ -67,6 +68,10 @@ public: } + void setPath(const QUrl &url) { m_path = url; setupComboBox(); } + + QUrl path() const { return m_path; } + QString text() const { return QString(); @@ -104,10 +109,11 @@ private: void setupComboBox(); - QPushButton *m_pushButton; + QToolButton *m_pushButton; QLineEdit *m_lineEdit; QComboBox *m_comboBox; QUrl m_fileName; + QUrl m_path; QmlDesigner::QmlItemNode m_itemNode; QString m_filter; bool m_showComboBox;