Commit 6fa0121b authored by Jekyll Wu's avatar Jekyll Wu

When saving profile, always use its untranslated name as filename

An internal property is introduced to record the untranslated name.
When saving profile into disk, always refer to that untranslated name
to get the filename.

This extra consideration is intended to deal with the situation when the
profile's contents are i18nized. The typical example is the "Shell" profile
shipped by default.

BUG: 250506
FIXED-IN: 4.9.0
parent eec927bd
......@@ -55,6 +55,7 @@ const Profile::PropertyInfo Profile::DefaultPropertyNames[] = {
// General
{ Path , "Path" , 0 , QVariant::String }
, { Name , "Name" , GENERAL_GROUP , QVariant::String }
, { UntranslatedName, "UntranslatedName" , 0 , QVariant::String }
, { Icon , "Icon" , GENERAL_GROUP , QVariant::String }
, { Command , "Command" , 0 , QVariant::String }
, { Arguments , "Arguments" , 0 , QVariant::StringList }
......@@ -137,6 +138,7 @@ FallbackProfile::FallbackProfile()
{
// Fallback settings
setProperty(Name, i18n("Shell"));
setProperty(UntranslatedName, "Shell");
// magic path for the fallback profile which is not a valid
// non-directory file name
setProperty(Path, "FALLBACK/");
......
......@@ -79,6 +79,10 @@ public:
Path,
/** (QString) The descriptive name of this profile. */
Name,
/** (QString) The untranslted name of this profile.
* Warning: this is an internal property. Do not touch it.
*/
UntranslatedName,
/** (QString) The name of the icon associated with this profile.
* This is used in menus and tabs to represent the profile.
*/
......@@ -324,6 +328,11 @@ public:
return property<QString>(Profile::Name);
}
/** Convenience method for property<QString>(Profile::UntranslatedName) */
QString untranslatedName() const {
return property<QString>(Profile::UntranslatedName);
}
/** Convenience method for property<QString>(Profile::Directory) */
QString defaultWorkingDirectory() const {
return property<QString>(Profile::Directory);
......
......@@ -86,6 +86,8 @@ bool KDE4ProfileReader::readProfile(const QString& path , Profile::Ptr profile ,
profile->setProperty(Profile::Arguments, shellCommand.arguments());
}
profile->setProperty(Profile::UntranslatedName, general.readEntryUntranslated("Name"));
// Read remaining properties
readProperties(config, profile, Profile::DefaultPropertyNames);
......
......@@ -45,7 +45,7 @@ QString KDE4ProfileWriter::getPath(const Profile::Ptr profile)
static const QString localDataLocation = KGlobal::dirs()->saveLocation("data", "konsole/");
static const QString systemDataLocation = KStandardDirs::installPath("data") + "konsole/";
const QString candidateLocalPath = localDataLocation + profile->name() + ".profile";
const QString candidateLocalPath = localDataLocation + profile->untranslatedName() + ".profile";
QString newPath;
// when the path property is not set, it means the profile has just
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment