Changeset View
Changeset View
Standalone View
Standalone View
addons/externaltools/kateexternaltool.cpp
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | This file is part of the Kate text editor of the KDE project. | ||||
3 | | ||||
4 | This library is free software; you can redistribute it and/or | ||||
5 | modify it under the terms of the GNU Library General Public | ||||
6 | License version 2 as published by the Free Software Foundation. | ||||
7 | | ||||
8 | This library is distributed in the hope that it will be useful, | ||||
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
11 | Library General Public License for more details. | ||||
12 | | ||||
13 | You should have received a copy of the GNU Library General Public License | ||||
14 | along with this library; see the file COPYING.LIB. If not, write to | ||||
15 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||||
16 | Boston, MA 02110-1301, USA. | ||||
17 | | ||||
18 | --- | ||||
19 | Copyright (C) 2019 Dominik Haumann <dhaumann@kde.org> | ||||
20 | */ | ||||
21 | #include "kateexternaltool.h" | ||||
22 | | ||||
23 | #include <KConfigGroup> | ||||
24 | #include <QStandardPaths> | ||||
25 | | ||||
26 | bool KateExternalTool::checkExec() | ||||
27 | { | ||||
28 | m_exec = QStandardPaths::findExecutable(executable); | ||||
29 | return !m_exec.isEmpty(); | ||||
30 | } | ||||
31 | | ||||
32 | bool KateExternalTool::valid(const QString& mt) const | ||||
33 | { | ||||
34 | return mimetypes.isEmpty() || mimetypes.contains(mt); | ||||
35 | } | ||||
36 | | ||||
37 | void KateExternalTool::load(const KConfigGroup & cg) | ||||
38 | { | ||||
39 | name = cg.readEntry("name", ""); | ||||
40 | icon = cg.readEntry("icon", ""); | ||||
41 | executable = cg.readEntry("executable", ""); | ||||
42 | arguments = cg.readEntry("arguments", ""); | ||||
43 | input = cg.readEntry("input", ""); | ||||
44 | workingDir = cg.readEntry("workingDir", ""); | ||||
45 | mimetypes = cg.readEntry("mimetypes", QStringList()); | ||||
46 | actionName = cg.readEntry("actionName"); | ||||
47 | cmdname = cg.readEntry("cmdname"); | ||||
48 | saveMode = static_cast<KateExternalTool::SaveMode>(cg.readEntry("save", 0)); | ||||
49 | includeStderr = cg.readEntry("includeStderr", false); | ||||
50 | | ||||
51 | hasexec = checkExec(); | ||||
52 | } | ||||
53 | | ||||
54 | void KateExternalTool::save(KConfigGroup & cg) | ||||
55 | { | ||||
56 | cg.writeEntry("name", name); | ||||
57 | cg.writeEntry("icon", icon); | ||||
58 | cg.writeEntry("executable", executable); | ||||
59 | cg.writeEntry("arguments", arguments); | ||||
60 | cg.writeEntry("input", input); | ||||
61 | cg.writeEntry("workingDir", workingDir); | ||||
62 | cg.writeEntry("mimetypes", mimetypes); | ||||
63 | cg.writeEntry("actionName", actionName); | ||||
64 | cg.writeEntry("cmdname", cmdname); | ||||
65 | cg.writeEntry("save", static_cast<int>(saveMode)); | ||||
66 | cg.writeEntry("includeStderr", includeStderr); | ||||
67 | } | ||||
68 | | ||||
69 | // kate: space-indent on; indent-width 4; replace-tabs on; |