KTextAddons

grammalectemanager.cpp
1/*
2 SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "grammalectemanager.h"
8#include <KConfigGroup>
9#include <KSharedConfig>
10#include <QStandardPaths>
11namespace
12{
13static const char myConfigGroupName[] = "Grammalecte";
14}
15using namespace TextGrammarCheck;
16GrammalecteManager::GrammalecteManager(QObject *parent)
17 : QObject(parent)
18{
19 loadSettings();
20}
21
22GrammalecteManager::~GrammalecteManager() = default;
23
24GrammalecteManager *GrammalecteManager::self()
25{
26 static GrammalecteManager s_self;
27 return &s_self;
28}
29
30void GrammalecteManager::saveSettings()
31{
33 grp.writeEntry(QStringLiteral("pythonpath"), mPythonPath);
34 grp.writeEntry(QStringLiteral("grammalectepath"), mGrammalectePath);
35 grp.writeEntry(QStringLiteral("options"), mOptions);
36}
37
38QStringList GrammalecteManager::options() const
39{
40 return mOptions;
41}
42
43void GrammalecteManager::setOptions(const QStringList &saveOptions)
44{
45 mOptions = saveOptions;
46}
47
48void GrammalecteManager::loadSettings()
49{
51 mPythonPath = grp.readEntry(QStringLiteral("pythonpath"));
52 if (mPythonPath.isEmpty()) {
53 mPythonPath = QStandardPaths::findExecutable(QStringLiteral("python3"));
54 }
55 mGrammalectePath = grp.readEntry(QStringLiteral("grammalectepath"));
56 mOptions = grp.readEntry(QStringLiteral("options"), QStringList());
57}
58
59QString GrammalecteManager::pythonPath() const
60{
61 return mPythonPath;
62}
63
64QString GrammalecteManager::grammalectePath() const
65{
66 return mGrammalectePath;
67}
68
69void GrammalecteManager::setPythonPath(const QString &pythonPath)
70{
71 mPythonPath = pythonPath;
72}
73
74void GrammalecteManager::setGrammalectePath(const QString &grammalectePath)
75{
76 mGrammalectePath = grammalectePath;
77}
78
79#include "moc_grammalectemanager.cpp"
static KSharedConfig::Ptr openConfig(const QString &fileName=QString(), OpenFlags mode=FullConfig, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation)
QString findExecutable(const QString &executableName, const QStringList &paths)
bool isEmpty() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:19:49 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.