summaryrefslogtreecommitdiff
path: root/src/createinstancedialogpages.cpp
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2020-07-30 04:36:12 -0400
committerisanae <14251494+isanae@users.noreply.github.com>2020-11-03 11:39:07 -0500
commitea4485857c09fd3ab6879966e7377d3c56951a85 (patch)
tree425ac56298842500653bfb35595a67527baec380 /src/createinstancedialogpages.cpp
parent6f21f3a19fbd82bc43c97dcab877959220ce2f22 (diff)
filter, explore buttons, instance rename
Diffstat (limited to 'src/createinstancedialogpages.cpp')
-rw-r--r--src/createinstancedialogpages.cpp62
1 files changed, 8 insertions, 54 deletions
diff --git a/src/createinstancedialogpages.cpp b/src/createinstancedialogpages.cpp
index 127243c6..8d304635 100644
--- a/src/createinstancedialogpages.cpp
+++ b/src/createinstancedialogpages.cpp
@@ -21,50 +21,6 @@ QString makeDefaultPath(const std::wstring& dir)
QString::fromStdWString(dir)));
}
-QString sanitizeFileName(const QString& name)
-{
- QString new_name = name;
-
- // Restrict the allowed characters
- new_name = new_name.remove(QRegExp("[^A-Za-z0-9 _=+;!@#$%^'\\-\\.\\[\\]\\{\\}\\(\\)]"));
-
- // Don't end in spaces and periods
- new_name = new_name.remove(QRegExp("\\.*$"));
- new_name = new_name.remove(QRegExp(" *$"));
-
- // Recurse until stuff stops changing
- if (new_name != name) {
- return sanitizeFileName(new_name);
- }
-
- return new_name;
-}
-
-// same thing as above, but allows path separators and colons
-//
-QString sanitizePath(const QString& path)
-{
- QString new_name = path;
-
- // Restrict the allowed characters
- new_name = new_name.remove(QRegExp("[^\\\\\\/A-Za-z0-9 _=+;!@#$%^:'\\-\\.\\[\\]\\{\\}\\(\\)]"));
-
- // Don't end in spaces and periods
- new_name = new_name.remove(QRegExp("\\.*$"));
- new_name = new_name.remove(QRegExp(" *$"));
-
- // Recurse until stuff stops changing
- if (new_name != path) {
- return sanitizeFileName(new_name);
- }
-
- return new_name;
-}
-
-void setPossiblePlaceholder(
- QLabel* label, const QString& s, const QString& arg)
-{
-}
PlaceholderLabel::PlaceholderLabel(QLabel* label)
@@ -762,7 +718,7 @@ QString NamePage::selectedInstanceName() const
}
const auto text = ui->instanceName->text().trimmed();
- return sanitizeFileName(text);
+ return InstanceManager::instance().sanitizeInstanceName(text);
}
void NamePage::onChanged()
@@ -790,12 +746,10 @@ bool NamePage::checkName(QString parentDir, QString name)
if (name.isEmpty()) {
empty = true;
} else {
- const QString sanitized = sanitizeFileName(name);
-
- if (name != sanitized) {
- invalid = true;
- } else {
+ if (InstanceManager::instance().validInstanceName(name)) {
exists = QDir(parentDir).exists(name);
+ } else {
+ invalid = true;
}
}
@@ -963,11 +917,9 @@ bool PathsPage::checkPath(
if (path.isEmpty()) {
empty = true;
} else {
- const QString sanitized = sanitizePath(path);
+ const QDir d(path);
- if (path != sanitized) {
- invalid = true;
- } else {
+ if (InstanceManager::instance().validInstanceName(d.dirName())) {
if (m_dlg.instanceType() == CreateInstanceDialog::Portable) {
// the default data path for a portable instance is the application
// directory, so it's not an error if it exists
@@ -977,6 +929,8 @@ bool PathsPage::checkPath(
} else {
exists = QDir(path).exists();
}
+ } else {
+ invalid = true;
}
}