summaryrefslogtreecommitdiffstats
path: root/lib/util/settings.cpp
blob: 9855b06bffd8fa39a8629d1c84e8c19225d69d96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/***************************************************************************
 *   Copyright (C) 2005 by Jens Dagerbo                                    *
 *   [email protected]                                               *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include <kconfig.h>
#include <kglobal.h>
#include <kstandarddirs.h>

#include "settings.h"

TQString Settings::terminalEmulatorName( KConfig & config )
{
	config.setGroup("TerminalEmulator");
	bool useKDESetting = config.readBoolEntry( "UseKDESetting", true );
	TQString terminal;

	if ( useKDESetting )
	{
		KConfigGroup confGroup( KGlobal::config(), TQString::tqfromLatin1("General") );
		terminal = confGroup.readEntry("TerminalApplication", TQString::tqfromLatin1("konsole"));
	}
	else
	{
		terminal = config.readEntry( "TerminalApplication", TQString::tqfromLatin1("konsole"));
	}
	return terminal;
}

TQString Settings::profileByAttributes(const TQString &language, const TQStringList &keywords)
{
    KConfig config(locate("data", "kdevelop/profiles/projectprofiles"));
    config.setGroup(language);

    TQStringList profileKeywords = TQStringList::split("/", "Empty");
    if (config.hasKey("Keywords"))
        profileKeywords = config.readListEntry("Keywords");

    int idx = 0;
    for (TQStringList::const_iterator it = profileKeywords.constBegin();
        it != profileKeywords.constEnd(); ++it)
    {
        if (keywords.tqcontains(*it))
        {
            idx = profileKeywords.tqfindIndex(*it);
            break;
        }
    }

    TQStringList profiles;
    if (config.hasKey("Profiles"))
    {
        profiles = config.readListEntry("Profiles");
        return profiles[idx];
    }
    return "KDevelop";
}