summaryrefslogtreecommitdiffstats
path: root/conduits/notepadconduit/notepad-factory.cpp
blob: 2f81414edab1f66981cef90ff7b35ebada8b14af (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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/* KPilot
**
** Copyright (C) 2004 by Adriaan de Groot, Joern Ahrens
**
** This file defines the factory for the notepad-conduit plugin.
*/

/*
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
** the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
** along with this program in a file called COPYING; if not, write to
** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
** MA 02110-1301, USA.
*/

/*
** Bug reports and questions can be sent to [email protected]
*/

#include "options.h"

#include <tdeconfig.h>
#include <kinstance.h>
#include <tdeaboutdata.h>
#include <kurlrequester.h>
#include <tdemessagebox.h>
#include <tqlineedit.h>

#include "pluginfactory.h"

#include "notepad-conduit.h"     // Conduit action
#include "notepad-setup.h"
#include "notepadconduit.h"     // Settings class

//----------------------------------------------------------------------------
// Conduit Configuration
//----------------------------------------------------------------------------
class NotepadConduitConfig : public ConduitConfigBase
{
public:
	NotepadConduitConfig(TQWidget *parent=0L, const char *n=0L);
	virtual void commit();
	virtual void load();
	static ConduitConfigBase *create(TQWidget *p, const char *n)
	{
		return new NotepadConduitConfig(p, n);
	};

protected:
	NotepadWidget *fConfigWidget;
} ;

static TDEAboutData *createAbout()
{
	FUNCTIONSETUP;

	TDEAboutData *fAbout = new TDEAboutData("NotepadConduit",
		I18N_NOOP("Saves notepads to png files"),
		KPILOT_VERSION,
		I18N_NOOP("Configures the Notepad Conduit for KPilot"),
		TDEAboutData::License_LGPL,
		"(C) 2004, Joern Ahrens");
	fAbout->addAuthor("Joern Ahrens",
		I18N_NOOP("Primary Author"),
		"[email protected]",
		"http://www.jokele.de/");
	fAbout->addCredit("Adriaan de Groot");
	fAbout->addCredit("Angus Ainslies",
		I18N_NOOP("Notepad conduit is based on Angus' read-notepad, part of pilot-link" ));
	return fAbout;
}


NotepadConduitConfig::NotepadConduitConfig(TQWidget *p, const char *n) :
	ConduitConfigBase(p, n),
	fConfigWidget(new NotepadWidget(p))
{
	FUNCTIONSETUP;

	fConduitName = i18n("Notepad");
	ConduitConfigBase::addAboutPage(fConfigWidget->tabWidget, createAbout());
	fWidget=fConfigWidget;
	TQObject::connect(fConfigWidget->fOutputDirectory, TQT_SIGNAL(textChanged(const TQString&)),
		this, TQT_SLOT(modified()));
	fConfigWidget->fOutputDirectory->setMode(KFile::Directory |
											KFile::LocalOnly);
}

/* virtual */ void NotepadConduitConfig::commit()
{
	FUNCTIONSETUP;

	NotepadConduitSettings::setOutputDirectory(fConfigWidget->fOutputDirectory->url());
	NotepadConduitSettings::self()->writeConfig();
}

/* virtual */ void NotepadConduitConfig::load()
{
	FUNCTIONSETUP;

	NotepadConduitSettings::self()->readConfig();
	fConfigWidget->fOutputDirectory->setURL(NotepadConduitSettings::outputDirectory());
	fModified=false;
}

extern "C"
{

void *init_conduit_notepad()
{
	return new ConduitFactory<NotepadConduitConfig,NotepadConduit>(0,"abbrowserconduit");
}

}