Use placeholder text for new map/layout names

This commit is contained in:
GriffinR 2025-01-22 13:24:09 -05:00
parent 90c904ecb9
commit f4c0cb2d2d
7 changed files with 15 additions and 28 deletions

View File

@ -68,6 +68,9 @@
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The constant that will be used to refer to this layout. It cannot be the same as any other existing layout.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="placeholderText">
<string>LAYOUT_MY_NEW_LAYOUT</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
@ -92,6 +95,9 @@
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The name of the new layout. The name cannot be the same as any other existing layout.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="placeholderText">
<string>MyNewLayout</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>

View File

@ -185,6 +185,9 @@
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The name of the new map. The name cannot be the same as any other existing map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="placeholderText">
<string>MyNewMap</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>

View File

@ -133,8 +133,6 @@ public:
NewMapSettings newMapSettings;
Layout::Settings newLayoutSettings;
QString getNewMapName() const;
QString getNewLayoutName() const;
void initNewMapSettings();
void initNewLayoutSettings();

View File

@ -32,6 +32,7 @@ void Layout::copyFrom(const Layout *other) {
this->border = other->border;
}
// When we create a layout automatically for a new map we add this suffix to differentiate the layout name from the map name.
QString Layout::defaultSuffix() {
return "_Layout";
}

View File

@ -1995,28 +1995,8 @@ QString Project::toUniqueIdentifier(const QString &identifier) const {
return uniqueIdentifier;
}
QString Project::getNewMapName() const {
// Ensure default name/ID doesn't already exist.
int suffix = 1;
QString newMapName;
do {
newMapName = QString("NewMap%1").arg(suffix++);
} while (!isIdentifierUnique(newMapName) || !isIdentifierUnique(Map::mapConstantFromName(newMapName)));
return newMapName;
}
QString Project::getNewLayoutName() const {
// Ensure default name/ID doesn't already exist.
int suffix = 1;
QString newLayoutName;
do {
newLayoutName = QString("NewLayout%1").arg(suffix++);
} while (!isIdentifierUnique(newLayoutName) || !isIdentifierUnique(Layout::layoutConstantFromName(newLayoutName)));
return newLayoutName;
}
void Project::initNewMapSettings() {
this->newMapSettings.name = getNewMapName();
this->newMapSettings.name = QString();
this->newMapSettings.group = this->groupNames.at(0);
this->newMapSettings.canFlyTo = false;
@ -2044,7 +2024,7 @@ void Project::initNewMapSettings() {
}
void Project::initNewLayoutSettings() {
this->newLayoutSettings.name = getNewLayoutName();
this->newLayoutSettings.name = QString();
this->newLayoutSettings.id = Layout::layoutConstantFromName(this->newLayoutSettings.name);
this->newLayoutSettings.width = getDefaultMapDimension();
this->newLayoutSettings.height = getDefaultMapDimension();

View File

@ -28,7 +28,7 @@ NewLayoutDialog::NewLayoutDialog(Project *project, const Layout *layoutToCopy, Q
if (this->layoutToCopy && !this->layoutToCopy->name.isEmpty()) {
settings->name = project->toUniqueIdentifier(this->layoutToCopy->name);
} else {
settings->name = project->getNewLayoutName();
settings->name = QString();
}
// Generate a unique Layout constant
settings->id = project->toUniqueIdentifier(Layout::layoutConstantFromName(settings->name));

View File

@ -35,9 +35,8 @@ NewMapDialog::NewMapDialog(Project *project, const Map *mapToCopy, QWidget *pare
settings->name = project->toUniqueIdentifier(this->mapToCopy->name());
} else {
// Not duplicating a map, get a generic new map name.
// The rest of the settings are preserved in the project between sessions.
settings->name = project->getNewMapName();
// Clear the previously-used map name. The rest of the settings are preserved between sessions.
settings->name = QString();
}
// Generate a unique Layout constant
settings->layout.id = project->toUniqueIdentifier(Layout::layoutConstantFromName(settings->name));