1
/* This file is part of the KDE libraries
2
* Copyright (C) 2005 Joseph Wenninger <jowenn@kde.org>
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 as published by the Free Software Foundation; either
7
* version 2 of the License, or (at your option) any later version.
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Library General Public License for more details.
14
* You should have received a copy of the GNU Library General Public License
15
* along with this library; see the file COPYING.LIB. If not, write to
16
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
* Boston, MA 02110-1301, USA.
19
#ifndef _EDITOR_CHOOSER_H_
20
#define _EDITOR_CHOOSER_H_
22
#include <ktexteditor/ktexteditor_export.h>
23
#include <ktexteditor/document.h>
24
#include <ktexteditor/editor.h>
26
#include <QtGui/QWidget>
35
* \brief Editor Component Chooser.
38
* - \ref chooser_intro
40
* - \ref chooser_editor
42
* \section chooser_intro Introduction
44
* The EditorChooser is responsible for two different tasks: It provides
45
* - a GUI, with which the user can choose the preferred editor part
46
* - a static accessor, with which the current selected editor part can be
49
* \section chooser_gui The GUI Editor Chooser
50
* The EditorChooser is a simple widget with a group box containing an
51
* information label and a combo box which lists all available KTextEditor
52
* implementations. To give the user the possibility to choose a text editor
53
* implementation, create an instance of this class and put it into the GUI:
55
* KTextEditor::EditorChooser* ec = new KTextEditor::EditorChooser(parent);
56
* // read the settings from the application's KConfig object
57
* ec->readAppSetting();
58
* // optionally connect the signal changed()
59
* // plug the widget into a layout
60
* layout->addWidget(ec);
62
* Later, for example when the user clicks the Apply-button:
64
* // save the user's choice
65
* ec->writeAppSetting();
67
* After this, the static accessor editor() will return the new editor part
68
* object. Now, either the application has to be restarted, or you need code
69
* that closes all current documents so that you can safely switch and use the
70
* new editor part. Restarting is probably much easier.
72
* \note If you do not put the EditorChooser into the GUI, the default editor
73
* component will be used. The default editor is configurable in KDE's
75
* "KDE Components > Component Chooser > Embedded Text Editor".
77
* \section chooser_editor Accessing the Editor Part
78
* The call of editor() will return the currently used editor part, either the
79
* KDE default or the one configured with the EditorChooser's GUI
80
* (see \ref chooser_gui). Example:
82
* KTextEditor::Editor* editor = KTextEditor::EditorChooser::editor();
85
* \see KTextEditor::Editor
86
* \author Joseph Wenninger \<jowenn@kde.org\>
88
class KTEXTEDITOR_EXPORT EditorChooser: public QWidget
90
friend class PrivateEditorChooser;
98
* Create an editor chooser widget.
99
* \param parent the parent widget
101
EditorChooser(QWidget *parent=0);
105
virtual ~EditorChooser();
107
/* void writeSysDefault();*/
110
* Read the configuration from the application's config file. The group
111
* is handeled internally (it is called "KTEXTEDITOR:", but it is possible
112
* to add a string to extend the group name with \p postfix.
113
* \param postfix config group postfix string
114
* \see writeAppSetting()
116
void readAppSetting(const QString& postfix=QString());
118
* Write the configuration to the application's config file.
119
* \param postfix config group postfix string
120
* \see readAppSetting()
122
void writeAppSetting(const QString& postfix=QString());
125
* Static accessor to get the Editor instance of the currently used
126
* KTextEditor component.
128
* That Editor instance can be qobject-cast to specific extensions.
129
* If the result of the cast is not NULL, that extension is supported:
131
* \param postfix config group postfix string
132
* \param fallBackToKatePart if \e true, the returned Editor component
133
* will be a katepart if no other implementation can be found
134
* \return Editor controller or NULL, if no editor component could be
137
static KTextEditor::Editor *editor (const QString& postfix=QString(), bool fallBackToKatePart = true);
141
* This signal is emitted whenever the selected item in the combo box
146
class PrivateEditorChooser *d;
150
class EditorChooserBackEnd: public ComponentChooserPlugin {
154
EditorChooserBackEnd(QObject *parent=0, const char *name=0);
155
virtual ~EditorChooserBackEnd();
157
virtual QWidget *widget(QWidget *);
158
virtual const QStringList &choices();
159
virtual void saveSettings();
161
void readAppSetting(KConfig *cfg,const QString& postfix);
162
void writeAppSetting(KConfig *cfg,const QString& postfix);
165
virtual void madeChoice(int pos,const QString &choice);
173
// kate: space-indent on; indent-width 2; replace-tabs on;