SVN_SILENT made messages (.desktop file)
[kdeaccessibility.git] / kmouth / phrasebook / phrasebookdialog.h
blobbbe789266ec3a49cb4179343bcf09b2922c1ce60
1 /***************************************************************************
2 phrasebookdialog.h - description
3 -------------------
4 begin : Don Sep 19 2002
5 copyright : (C) 2002 by Gunnar Schmi Dt
6 email : kmouth@schmi-dt.de
7 ***************************************************************************/
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
18 #ifndef PHRASEBOOKDIALOG_H
19 #define PHRASEBOOKDIALOG_H
21 #include <q3button.h>
22 #include <QRadioButton>
23 #include <q3buttongroup.h>
24 #include <QLabel>
25 #include <q3listview.h>
26 //Added by qt3to4:
27 #include <QList>
28 #include <QGridLayout>
29 #include <QDropEvent>
30 #include <kxmlguiwindow.h>
31 #include <klineedit.h>
32 #include <kkeysequencewidget.h>
33 #include <kurl.h>
34 #include "phrasebook.h"
35 #include "ui_buttonboxui.h"
36 #include <kicon.h>
37 class Q3ListViewItem;
38 class PhraseTreeItem;
39 class PhraseTree;
40 class QString;
41 class K3ListView;
42 class KToolBarPopupAction;
43 class KActionMenu;
45 struct StandardBook {
46 QString name;
47 QString path;
48 QString filename;
50 typedef QList<StandardBook> StandardBookList;
52 /**The class PhraseTreeItem is an ListViewItem for either a phrase or a phrase book.
53 *@author Gunnar Schmi Dt
56 class CheckBookItem : public Q3CheckListItem {
57 public:
58 CheckBookItem (Q3ListViewItem *parent, Q3ListViewItem *last,
59 const QString &text, const QString &name, const QString &filename);
60 CheckBookItem (Q3ListView *parent, Q3ListViewItem *last,
61 const QString &text, const QString &name, const QString &filename);
62 ~CheckBookItem();
64 protected:
65 virtual void activate ();
66 virtual void stateChange (bool);
67 virtual void propagateStateChange ();
68 virtual void childChange (int numberDiff, int selDiff);
70 private:
71 int numberOfBooks;
72 int selectedBooks;
75 /**
76 * This class represents a widget for configuring the initial phrasebook.
77 * @author Gunnar Schmi Dt
80 class InitialPhraseBookWidget : public QWidget {
81 Q_OBJECT
82 public:
83 InitialPhraseBookWidget(QWidget *parent, const char *name);
84 ~InitialPhraseBookWidget();
86 void createBook();
88 private:
89 /** initializes the list of standard phrase books */
90 void initStandardPhraseBooks ();
92 K3ListView *books;
95 /**
96 * The class StandardPhraseBookInsertAction implements an Action for
97 * inserting a standard phrase book.
98 * @author Gunnar Schmi Dt
100 class StandardPhraseBookInsertAction : public KAction {
101 Q_OBJECT
102 public:
103 StandardPhraseBookInsertAction (const KUrl &url, const QString& name, const QObject* receiver, const char* slot, KActionCollection* parent)
104 : KAction (KIcon("phrasebook"), name, parent) {
105 this->url = url;
106 connect (this, SIGNAL(slotActivated (const KUrl &)), receiver, slot);
107 parent->addAction(name, this);
109 ~StandardPhraseBookInsertAction () {
112 public slots:
113 void slotActivated () {
114 trigger();
115 emit slotActivated (url);
118 signals:
119 void slotActivated (const KUrl &url);
121 private:
122 KUrl url;
126 * This class represents a widget holding the buttons of the phrase book
127 * edit window.
128 * @author Gunnar Schmi Dt
130 class ButtonBoxWidget : public QWidget, public Ui::ButtonBoxUI {
131 public:
132 ButtonBoxWidget (QWidget *parent = 0, const char *name = 0);
133 ~ButtonBoxWidget ();
135 KKeySequenceWidget *keyButton;
136 Q3ButtonGroup *group;
138 protected:
139 QGridLayout *keyButtonPlaceLayout;
143 * The class PhraseBookDialog implements a dialog for editing phrase books.
144 * @author Gunnar Schmi Dt
147 class PhraseBookDialog : public KXmlGuiWindow {
148 friend class InitialPhraseBookWidget;
149 Q_OBJECT
150 private:
151 /** Constructor. It is private because this class implements the singleton
152 * pattern. For creating the instance of the dialog, use the get() method.
154 PhraseBookDialog ();
156 static QString displayPath (QString path);
158 public:
159 /** Returns a pointer to the instance of this dialog. As a part off the
160 * singleton pattern it will make sure that there is at most one instance
161 * of the dialog at a given time.
163 static PhraseBookDialog *get();
165 /** Destructor. */
166 ~PhraseBookDialog();
168 bool queryClose ();
170 public slots:
171 void slotTextChanged (const QString &s);
172 void slotNoKey();
173 void slotCustomKey();
174 void capturedShortcut (const KShortcut& cut);
176 void selectionChanged ();
177 void contextMenuRequested(Q3ListViewItem *, const QPoint &pos, int);
179 void slotRemove ();
180 void slotCut ();
181 void slotCopy ();
182 void slotPaste ();
184 void slotAddPhrasebook ();
185 void slotAddPhrase ();
187 void slotSave ();
188 void slotImportPhrasebook ();
189 void slotImportPhrasebook (const KUrl &url);
190 void slotExportPhrasebook ();
191 void slotPrint ();
193 void slotDropped (QDropEvent *e, Q3ListViewItem *parent, Q3ListViewItem *after);
194 void slotMoved (Q3ListViewItem *item, Q3ListViewItem *, Q3ListViewItem *);
196 signals:
197 void phrasebookConfirmed (PhraseBook &book);
199 private:
200 static StandardBookList standardPhraseBooks ();
202 void initGUI();
203 /** initializes the KActions of the window */
204 void initActions();
205 /** initializes the list of standard phrase books */
206 void initStandardPhraseBooks ();
208 Q3ListViewItem *addBook (Q3ListViewItem *parent, Q3ListViewItem *after, PhraseBook *book);
209 Q3ListViewItem *addBook (Q3ListViewItem *item, PhraseBook *book);
211 void setShortcut (const KShortcut &cut);
213 void _warning (const QKeySequence &cut, const QString &sAction, const QString &sTitle);
215 bool isGlobalKeyPresent (const KShortcut& cut, bool warnUser);
216 bool isPhraseKeyPresent (const KShortcut& cut, bool warnUser);
217 bool isKeyPresent (const KShortcut& cut, bool warnUser);
219 PhraseBook book;
220 bool phrasebookChanged;
222 PhraseTree *treeView;
223 ButtonBoxWidget *buttonBox;
225 QAction* fileNewPhrase;
226 QAction* fileNewBook;
227 QAction* fileSave;
228 QAction* fileImport;
229 KToolBarPopupAction* toolbarImport;
230 KActionMenu* fileImportStandardBook;
231 QAction* fileExport;
232 QAction* filePrint;
233 QAction* fileClose;
234 QAction* editCut;
235 QAction* editCopy;
236 QAction* editPaste;
237 QAction* editDelete;
240 #endif