forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -95,6 +95,11 @@ void FileWizardPage::setFileName(const QString &name)
|
|||||||
d->m_ui.nameLineEdit->setText(name);
|
d->m_ui.nameLineEdit->setText(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FileWizardPage::setAllowDirectoriesInFileSelector(bool allow)
|
||||||
|
{
|
||||||
|
d->m_ui.nameLineEdit->setAllowDirectories(allow);
|
||||||
|
}
|
||||||
|
|
||||||
bool FileWizardPage::isComplete() const
|
bool FileWizardPage::isComplete() const
|
||||||
{
|
{
|
||||||
return d->m_complete;
|
return d->m_complete;
|
||||||
|
@@ -54,6 +54,7 @@ public:
|
|||||||
|
|
||||||
bool forceFirstCapitalLetterForFileName() const;
|
bool forceFirstCapitalLetterForFileName() const;
|
||||||
void setForceFirstCapitalLetterForFileName(bool b);
|
void setForceFirstCapitalLetterForFileName(bool b);
|
||||||
|
void setAllowDirectoriesInFileSelector(bool allow);
|
||||||
|
|
||||||
// Validate a base name entry field (potentially containing extension)
|
// Validate a base name entry field (potentially containing extension)
|
||||||
static bool validateBaseName(const QString &name, QString *errorMessage = nullptr);
|
static bool validateBaseName(const QString &name, QString *errorMessage = nullptr);
|
||||||
|
@@ -27,13 +27,17 @@
|
|||||||
|
|
||||||
#include "jsonwizard.h"
|
#include "jsonwizard.h"
|
||||||
|
|
||||||
#include <QFileInfo>
|
#include <utils/filepath.h>
|
||||||
#include <QVariant>
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
JsonFilePage::JsonFilePage(QWidget *parent) : Utils::FileWizardPage(parent)
|
JsonFilePage::JsonFilePage(QWidget *parent)
|
||||||
{ }
|
: FileWizardPage(parent)
|
||||||
|
{
|
||||||
|
setAllowDirectoriesInFileSelector(true);
|
||||||
|
}
|
||||||
|
|
||||||
void JsonFilePage::initializePage()
|
void JsonFilePage::initializePage()
|
||||||
{
|
{
|
||||||
@@ -53,16 +57,13 @@ bool JsonFilePage::validatePage()
|
|||||||
if (path().isEmpty() || fileName().isEmpty())
|
if (path().isEmpty() || fileName().isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QFileInfo d(path());
|
const FilePath dir = FilePath::fromString(path());
|
||||||
if (!d.isDir())
|
if (!dir.isDir())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QString target = d.absoluteFilePath();
|
const FilePath target = dir.resolvePath(fileName());
|
||||||
if (!target.endsWith(QLatin1Char('/')))
|
|
||||||
target += QLatin1Char('/');
|
|
||||||
target += fileName();
|
|
||||||
|
|
||||||
wizard()->setProperty("TargetPath", target);
|
wizard()->setProperty("TargetPath", target.toString());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user