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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
/***************************************************************************
* Copyright (C) 2005 Nicolas Hadacek <hadacek@kde.org> *
* Copyright (C) 2003-2004 Alain Gibaud <alain.gibaud@free.fr> *
* *
* 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 "global_config.h"
#include <kapplication.h>
#include <kconfig.h>
#include <klocale.h>
#include "progs/list/prog_list.h"
#include "tools/list/tool_list.h"
const BaseGlobalConfig::Data BaseGlobalConfig::DATA[Nb_Types] = {
{ "auto_rebuild_modified", I18N_NOOP("Automatically rebuild project before programming if it is modified."), QVariant(true, 0) },
{ "program_after_build", I18N_NOOP("Program device after successful build."), QVariant(false, 0) },
{ "user_id_set_to_checksum", I18N_NOOP("Set User Ids to unprotected checksum (if User Ids are empty)."), QVariant(false, 0) },
{ "show_tab_close_buttons", I18N_NOOP("Show close buttons on tabs (need restart to take effect)."), QVariant(true, 0) }
};
PURL::Url GlobalConfig::openedProject()
{
GenericConfig config(QString::null);
return PURL::Url::fromPathOrUrl(config.readEntry("project", QString::null));
}
void GlobalConfig::writeOpenedProject(const PURL::Url &p)
{
GenericConfig config(QString::null);
config.writeEntry("project", p.filepath());
}
PURL::UrlList GlobalConfig::openedFiles()
{
GenericConfig config(QString::null);
PURL::UrlList files;
uint i = 0;
for (;;) {
QString file = config.readEntry(QString("file%1").arg(i), QString::null);
if ( file.isEmpty() ) break;
files += PURL::Url::fromPathOrUrl(file);
i++;
}
return files;
}
void GlobalConfig::writeOpenedFiles(const PURL::UrlList &files)
{
GenericConfig config(QString::null);
for (uint i=0; i<=files.count(); i++) {
QString s = (i==files.count() ? QString::null : files[i].filepath());
config.writeEntry(QString("file%1").arg(i), s);
}
}
void GlobalConfig::writeProgrammerGroup(const Programmer::Group &group)
{
GenericConfig config(QString::null);
config.writeEntry("programmer", group.name());
}
const Programmer::Group &GlobalConfig::programmerGroup()
{
GenericConfig config(QString::null);
QString s = config.readEntry("programmer");
const Programmer::Group *group = Programmer::lister().group(s);
if ( group==0 ) return *Programmer::lister().begin().data();
return *group;
}
void GlobalConfig::writeDebugLevel(Log::DebugLevel level)
{
GenericConfig config(QString::null);
config.writeEnumEntry<Log::DebugLevel>("log_debug_level", level);
}
Log::DebugLevel GlobalConfig::debugLevel()
{
GenericConfig config(QString::null);
return config.readEnumEntry<Log::DebugLevel>("log_debug_level", Log::DebugLevel::Normal);
}
void GlobalConfig::writeLogOutputType(Log::OutputType type)
{
GenericConfig config(QString::null);
config.writeEntry("log_output_type", type);
}
Log::OutputType GlobalConfig::logOutputType()
{
GenericConfig config(QString::null);
uint output = config.readUIntEntry("log_output_type", Log::GuiOnly);
if ( output>=Log::Nb_OutputTypes ) return Log::GuiOnly;
return Log::OutputType(output);
}
void GlobalConfig::writeShowLineNumbers(bool show)
{
GenericConfig config(QString::null);
config.writeEntry("show_line_numbers", show);
}
bool GlobalConfig::showLineNumbers()
{
GenericConfig config(QString::null);
return config.readBoolEntry("show_line_numbers", false);
}
|