summaryrefslogtreecommitdiffstats
path: root/src/libgui/global_config.cpp
blob: 085f79997086531252775d3b4a42d35c1b26bee3 (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
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 <tdeconfig.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."), TQVariant(true, 0) },
  { "program_after_build", I18N_NOOP("Program device after successful build."), TQVariant(false, 0) },
  { "user_id_set_to_checksum", I18N_NOOP("Set User Ids to unprotected checksum (if User Ids are empty)."), TQVariant(false, 0) },
  { "show_tab_close_buttons", I18N_NOOP("Show close buttons on tabs (need restart to take effect)."), TQVariant(true, 0) }
};

PURL::Url GlobalConfig::openedProject()
{
  GenericConfig config(TQString::null);
  return PURL::Url::fromPathOrUrl(config.readEntry("project", TQString::null));
}
void GlobalConfig::writeOpenedProject(const PURL::Url &p)
{
  GenericConfig config(TQString::null);
  config.writeEntry("project", p.filepath());
}

PURL::UrlList GlobalConfig::openedFiles()
{
  GenericConfig config(TQString::null);
  PURL::UrlList files;
  uint i = 0;
  for (;;) {
    TQString file = config.readEntry(TQString("file%1").arg(i), TQString::null);
    if ( file.isEmpty() ) break;
    files += PURL::Url::fromPathOrUrl(file);
    i++;
  }
  return files;
}
void GlobalConfig::writeOpenedFiles(const PURL::UrlList &files)
{
  GenericConfig config(TQString::null);
  for (uint i=0; i<=files.count(); i++) {
    TQString s = (i==files.count() ? TQString::null : files[i].filepath());
    config.writeEntry(TQString("file%1").arg(i), s);
  }
}

void GlobalConfig::writeProgrammerGroup(const Programmer::Group &group)
{
  GenericConfig config(TQString::null);
  config.writeEntry("programmer", group.name());
}
const Programmer::Group &GlobalConfig::programmerGroup()
{
  GenericConfig config(TQString::null);
  TQString 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(TQString::null);
  config.writeEnumEntry<Log::DebugLevel>("log_debug_level", level);
}
Log::DebugLevel GlobalConfig::debugLevel()
{
  GenericConfig config(TQString::null);
  return config.readEnumEntry<Log::DebugLevel>("log_debug_level", Log::DebugLevel::Normal);
}

void GlobalConfig::writeLogOutputType(Log::OutputType type)
{
  GenericConfig config(TQString::null);
  config.writeEntry("log_output_type", type);
}
Log::OutputType GlobalConfig::logOutputType()
{
  GenericConfig config(TQString::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(TQString::null);
  config.writeEntry("show_line_numbers", show);
}
bool GlobalConfig::showLineNumbers()
{
  GenericConfig config(TQString::null);
  return config.readBoolEntry("show_line_numbers", false);
}