summaryrefslogtreecommitdiff
path: root/src/plugins/projectexplorer/jsonwizard/jsonfilepage.cpp
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2021-09-27 09:58:54 +0200
committerhjk <hjk@qt.io>2021-09-27 11:16:20 +0000
commit95907b0f7dc9b3dd69c70e4c0ccba3b33203b0c7 (patch)
treec85719de7e50d380111e511456dfcb026d6d8c92 /src/plugins/projectexplorer/jsonwizard/jsonfilepage.cpp
parentfdb5c7a8a36d37ad0fa30da999366d9ed0f3e5fc (diff)
downloadqt-creator-95907b0f7dc9b3dd69c70e4c0ccba3b33203b0c7.tar.gz
Utils: Allow full file paths with directory parts
... when creating a new empty file. This simplifies file creation with file paths cut&paste from external applications as it removes the need to split it into a directory part and the file name. Change-Id: I3f81db89d5ae7db4117c29a4f947cdf92dc4d50c Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'src/plugins/projectexplorer/jsonwizard/jsonfilepage.cpp')
-rw-r--r--src/plugins/projectexplorer/jsonwizard/jsonfilepage.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/plugins/projectexplorer/jsonwizard/jsonfilepage.cpp b/src/plugins/projectexplorer/jsonwizard/jsonfilepage.cpp
index 19615f929a..0b4c93649e 100644
--- a/src/plugins/projectexplorer/jsonwizard/jsonfilepage.cpp
+++ b/src/plugins/projectexplorer/jsonwizard/jsonfilepage.cpp
@@ -27,13 +27,17 @@
#include "jsonwizard.h"
-#include <QFileInfo>
-#include <QVariant>
+#include <utils/filepath.h>
+
+using namespace Utils;
namespace ProjectExplorer {
-JsonFilePage::JsonFilePage(QWidget *parent) : Utils::FileWizardPage(parent)
-{ }
+JsonFilePage::JsonFilePage(QWidget *parent)
+ : FileWizardPage(parent)
+{
+ setAllowDirectoriesInFileSelector(true);
+}
void JsonFilePage::initializePage()
{
@@ -53,16 +57,13 @@ bool JsonFilePage::validatePage()
if (path().isEmpty() || fileName().isEmpty())
return false;
- QFileInfo d(path());
- if (!d.isDir())
+ const FilePath dir = FilePath::fromString(path());
+ if (!dir.isDir())
return false;
- QString target = d.absoluteFilePath();
- if (!target.endsWith(QLatin1Char('/')))
- target += QLatin1Char('/');
- target += fileName();
+ const FilePath target = dir.resolvePath(fileName());
- wizard()->setProperty("TargetPath", target);
+ wizard()->setProperty("TargetPath", target.toString());
return true;
}