-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathzealsearch_config.cpp
93 lines (81 loc) · 3.03 KB
/
zealsearch_config.cpp
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
/*
* <one line to give the program's name and a brief idea of what it does.>
* Copyright (C) 2015 Mykola G <g@whatwhatweb.com>
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#include "zealsearch_config.h"
#include "zealsearchplugin.h"
#include <QtGui/QBoxLayout>
#include <QtGui/QLineEdit>
#include <QtGui/QTextEdit>
#include <QMessageBox>
#include <QLabel>
#include <KPluginFactory>
#include <KPluginLoader>
#include <KConfigGroup>
ZealSearch_config::ZealSearch_config(QWidget *parent, const QVariantList &args)
: KCModule(ZealSearchPluginFactory::componentData(), parent, args)
{
QVBoxLayout *layout = new QVBoxLayout(this);
zealCmd = new QLineEdit(this);
zealCmd->setPlaceholderText("Zeal launch command");
zealCmd->setToolTip("Zeal launch command. %1 is replaced by text selected in editor.");
layout->addWidget(zealCmd);
docSets = new QTextEdit(this);
docSets->setToolTip("Enter new line separated docset limitations for file extensions. More explanation here: http://zealdocs.org/usage.html");
layout->addWidget(docSets);
setLayout(layout);
load();
connect(zealCmd, SIGNAL(textChanged(QString)), this, SLOT(slotChanged()));
connect(docSets, SIGNAL(textChanged()), this, SLOT(slotChanged()));
}
ZealSearch_config::~ZealSearch_config(){}
void ZealSearch_config::save()
{
if(ZealSearchPlugin::self()){
ZealSearchPlugin::self()->setZealCmd(zealCmd->text());
ZealSearchPlugin::self()->setDocSetsStr(docSets->toPlainText());
ZealSearchPlugin::self()->writeConfig();
}else{
KConfigGroup cg(KGlobal::config(), "ZealSearch Plugin");
cg.writeEntry("zeal_command", zealCmd->text());
}
emit changed(false);
}
void ZealSearch_config::load()
{
if(ZealSearchPlugin::self()){
ZealSearchPlugin::self()->readConfig();
zealCmd->setText(ZealSearchPlugin::self()->getZealCmd());
docSets->setPlainText(ZealSearchPlugin::self()->getDocSetsStr());
}else{
KConfigGroup cg(KGlobal::config(), "ZealSearch Plugin");
zealCmd->setText(cg.readEntry("zeal_command", "/usr/bin/zeal --query \"%1\""));
}
emit changed(false);
}
void ZealSearch_config::defaults()
{
zealCmd->setText("/usr/bin/zeal --query \"%1\"");
docSets->setPlainText("php:html,joomla,php,wordpress\nhtml:html\ncss:css,less\njs:javascript,jquery\n");
emit changed(true);
}
void ZealSearch_config::slotChanged()
{
emit changed(true);
}
#include "zealsearch_config.moc"