• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

Konsole

  • kde-4.14
  • applications
  • konsole
  • src
ProfileReader.cpp
Go to the documentation of this file.
1 /*
2  This source file is part of Konsole, a terminal emulator.
3 
4  Copyright 2006-2008 by Robert Knight <robertknight@gmail.com>
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  02110-1301 USA.
20 */
21 
22 // Own
23 #include "ProfileReader.h"
24 
25 // Qt
26 #include <QtCore/QFile>
27 
28 // KDE
29 #include <KConfig>
30 #include <KConfigGroup>
31 #include <KGlobal>
32 #include <KStandardDirs>
33 
34 // Konsole
35 #include "ShellCommand.h"
36 
37 using namespace Konsole;
38 
39 // FIXME: A dup line from Profile.cpp - redo these
40 static const char GENERAL_GROUP[] = "General";
41 
42 QStringList KDE4ProfileReader::findProfiles()
43 {
44  return KGlobal::dirs()->findAllResources("data", "konsole/*.profile",
45  KStandardDirs::NoDuplicates);
46 }
47 void KDE4ProfileReader::readProperties(const KConfig& config, Profile::Ptr profile,
48  const Profile::PropertyInfo* properties)
49 {
50  const char* groupName = 0;
51  KConfigGroup group;
52 
53  while (properties->name != 0) {
54  if (properties->group != 0) {
55  if (groupName == 0 || qstrcmp(groupName, properties->group) != 0) {
56  group = config.group(properties->group);
57  groupName = properties->group;
58  }
59 
60  QString name(properties->name);
61 
62  if (group.hasKey(name))
63  profile->setProperty(properties->property,
64  group.readEntry(name, QVariant(properties->type)));
65  }
66 
67  properties++;
68  }
69 }
70 
71 bool KDE4ProfileReader::readProfile(const QString& path , Profile::Ptr profile , QString& parentProfile)
72 {
73  if (!QFile::exists(path))
74  return false;
75 
76  KConfig config(path, KConfig::NoGlobals);
77 
78  KConfigGroup general = config.group(GENERAL_GROUP);
79  if (general.hasKey("Parent"))
80  parentProfile = general.readEntry("Parent");
81 
82  if (general.hasKey("Command")) {
83  ShellCommand shellCommand(general.readEntry("Command"));
84 
85  profile->setProperty(Profile::Command, shellCommand.command());
86  profile->setProperty(Profile::Arguments, shellCommand.arguments());
87  }
88 
89  profile->setProperty(Profile::UntranslatedName, general.readEntryUntranslated("Name"));
90 
91  // Read remaining properties
92  readProperties(config, profile, Profile::DefaultPropertyNames);
93 
94  return true;
95 }
96 
Konsole::KDE4ProfileReader::findProfiles
virtual QStringList findProfiles()
Returns a list of paths to profiles which this reader can read.
Definition: ProfileReader.cpp:42
ProfileReader.h
QFile::exists
bool exists() const
ShellCommand.h
Konsole::Profile::Command
(QString) The command to execute ( excluding arguments ) when creating a new terminal session using t...
Definition: Profile.h:93
Konsole::Profile::UntranslatedName
(QString) The untranslated name of this profile.
Definition: Profile.h:85
Konsole::ShellCommand
A class to parse and extract information about shell commands.
Definition: ShellCommand.h:52
Konsole::Profile::Arguments
(QStringList) The arguments which are passed to the program specified by the Command property when cr...
Definition: Profile.h:98
QString
QStringList
Konsole::Profile::Ptr
KSharedPtr< Profile > Ptr
Definition: Profile.h:67
GENERAL_GROUP
static const char GENERAL_GROUP[]
Definition: ProfileReader.cpp:40
Konsole::KDE4ProfileReader::readProfile
virtual bool readProfile(const QString &path, Profile::Ptr profile, QString &parentProfile)
Attempts to read a profile from path and save the property values described into profile.
Definition: ProfileReader.cpp:71
QVariant
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:27 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Konsole

Skip menu "Konsole"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal