Commit a4c6ca23 authored by Robert Knight's avatar Robert Knight
Browse files

Record profile parent when saving to disk and reload them as needed when loading a profile.

svn path=/trunk/KDE/kdebase/apps/konsole/; revision=678033
parent fe2be784
......@@ -333,7 +333,7 @@ QStringList KDE4ProfileReader::findProfiles()
return KGlobal::dirs()->findAllResources("data","konsole/*.profile",
KStandardDirs::NoDuplicates);
}
bool KDE4ProfileReader::readProfile(const QString& path , Profile* profile)
bool KDE4ProfileReader::readProfile(const QString& path , Profile* profile , QString& parentProfile)
{
qDebug() << "KDE 4 Profile Reader:" << path;
......@@ -342,6 +342,9 @@ bool KDE4ProfileReader::readProfile(const QString& path , Profile* profile)
// general
KConfigGroup general = config.group("General");
if ( general.hasKey("Parent") )
parentProfile = general.readEntry("Parent");
if ( general.hasKey("Name") )
profile->setProperty(Profile::Name,general.readEntry("Name"));
else
......@@ -422,11 +425,14 @@ QStringList KDE3ProfileReader::findProfiles()
return KGlobal::dirs()->findAllResources("data", "konsole/*.desktop",
KStandardDirs::NoDuplicates);
}
bool KDE3ProfileReader::readProfile(const QString& path , Profile* profile)
bool KDE3ProfileReader::readProfile(const QString& path , Profile* profile , QString& parentProfile)
{
if (!QFile::exists(path))
return false;
// KDE 3 profiles do not have parents
parentProfile = QString();
KDesktopFile* desktopFile = new KDesktopFile(path);
KConfigGroup* config = new KConfigGroup( desktopFile->desktopGroup() );
......
......@@ -390,22 +390,27 @@ public:
* save the property values described into @p profile.
*
* Returns true if the profile was successfully read or false otherwise.
*
* @param path Path to the profile to read
* @param profile TODO: Document me
* @param parentProfile Receives the name of the parent profile specified in
* @p path. TODO: Document me
*/
virtual bool readProfile(const QString& path , Profile* profile) = 0;
virtual bool readProfile(const QString& path , Profile* profile , QString& parentProfile) = 0;
};
/** Reads a KDE 3 profile .desktop file. */
class KDE3ProfileReader : public ProfileReader
{
public:
virtual QStringList findProfiles();
virtual bool readProfile(const QString& path , Profile* profile);
virtual bool readProfile(const QString& path , Profile* profile, QString& parentProfile);
};
/** Reads a KDE 4 .profile file. */
class KDE4ProfileReader : public ProfileReader
{
public:
virtual QStringList findProfiles();
virtual bool readProfile(const QString& path , Profile* profile);
virtual bool readProfile(const QString& path , Profile* profile, QString& parentProfile);
private:
template <typename T>
void readStandardElement(const KConfigGroup& group ,
......
......@@ -135,7 +135,16 @@ QString SessionManager::loadProfile(const QString& shortPath)
Profile* newProfile = new Profile(defaultProfile());
newProfile->setProperty(Profile::Path,path);
bool result = reader->readProfile(path,newProfile);
QString parentProfile;
bool result = reader->readProfile(path,newProfile,parentProfile);
if ( !parentProfile.isEmpty() )
{
qDebug() << "Loading parent profile" << parentProfile;
QString parentKey = loadProfile(parentProfile);
newProfile->setParent(profile(parentKey));
}
delete reader;
......
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