summaryrefslogtreecommitdiffstats
path: root/src/libgui/global_config.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libgui/global_config.cpp')
-rw-r--r--src/libgui/global_config.cpp106
1 files changed, 106 insertions, 0 deletions
diff --git a/src/libgui/global_config.cpp b/src/libgui/global_config.cpp
new file mode 100644
index 0000000..8424450
--- /dev/null
+++ b/src/libgui/global_config.cpp
@@ -0,0 +1,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);
+}