summaryrefslogtreecommitdiffstats
path: root/lib/util/settings.cpp
blob: f78951457387c6c34a27b314bfb4420ecae6f56f (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                                    *
 *   jens.dagerbo@swipnet.se                                               *
 *                                                                         *
 *   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( TDEConfig & config )
{
	config.setGroup("TerminalEmulator");
	bool useKDESetting = config.readBoolEntry( "UseKDESetting", true );
	TQString terminal;

	if ( useKDESetting )
	{
		TDEConfigGroup confGroup( TDEGlobal::config(), TQString::fromLatin1("General") );
		terminal = confGroup.readEntry("TerminalApplication", TQString::fromLatin1("konsole"));
	}
	else
	{
		terminal = config.readEntry( "TerminalApplication", TQString::fromLatin1("konsole"));
	}
	return terminal;
}

TQString Settings::profileByAttributes(const TQString &language, const TQStringList &keywords)
{
    TDEConfig config(locate("data", "tdevelop/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.contains(*it))
        {
            idx = profileKeywords.findIndex(*it);
            break;
        }
    }

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