From bcb704366cb5e333a626c18c308c7e0448a8e69f Mon Sep 17 00:00:00 2001
From: toma
Date: Wed, 25 Nov 2009 17:56:58 +0000
Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
---
kdict/AUTHORS | 25 +
kdict/ChangeLog | 79 ++
kdict/LICENSE | 125 +++
kdict/Makefile.am | 33 +
kdict/README | 47 +
kdict/TODO | 2 +
kdict/actions.cpp | 335 +++++++
kdict/actions.h | 111 +++
kdict/applet/Makefile.am | 19 +
kdict/applet/kdictapplet.cpp | 405 ++++++++
kdict/applet/kdictapplet.desktop | 147 +++
kdict/applet/kdictapplet.h | 101 ++
kdict/application.cpp | 71 ++
kdict/application.h | 39 +
kdict/dcopinterface.h | 54 ++
kdict/dict.cpp | 1632 ++++++++++++++++++++++++++++++++
kdict/dict.h | 204 ++++
kdict/hi128-app-kdict.png | Bin 0 -> 14431 bytes
kdict/hi16-app-kdict.png | Bin 0 -> 779 bytes
kdict/hi32-app-kdict.png | Bin 0 -> 2101 bytes
kdict/hi48-app-kdict.png | Bin 0 -> 3891 bytes
kdict/hi64-app-kdict.png | Bin 0 -> 5901 bytes
kdict/hisc-app-kdict.svgz | Bin 0 -> 5220 bytes
kdict/kdict.desktop | 153 +++
kdict/kdictui.rc | 59 ++
kdict/main.cpp | 56 ++
kdict/matchview.cpp | 473 +++++++++
kdict/matchview.h | 105 ++
kdict/options.cpp | 947 ++++++++++++++++++
kdict/options.h | 229 +++++
kdict/pics/Makefile.am | 2 +
kdict/pics/cr16-action-define_clip.png | Bin 0 -> 917 bytes
kdict/pics/cr16-action-query_erase.png | Bin 0 -> 396 bytes
kdict/pics/cr22-action-define_clip.png | Bin 0 -> 1228 bytes
kdict/pics/cr32-action-define_clip.png | Bin 0 -> 2109 bytes
kdict/queryview.cpp | 618 ++++++++++++
kdict/queryview.h | 178 ++++
kdict/sets.cpp | 326 +++++++
kdict/sets.h | 68 ++
kdict/toplevel.cpp | 778 +++++++++++++++
kdict/toplevel.h | 149 +++
41 files changed, 7570 insertions(+)
create mode 100644 kdict/AUTHORS
create mode 100644 kdict/ChangeLog
create mode 100644 kdict/LICENSE
create mode 100644 kdict/Makefile.am
create mode 100644 kdict/README
create mode 100644 kdict/TODO
create mode 100644 kdict/actions.cpp
create mode 100644 kdict/actions.h
create mode 100644 kdict/applet/Makefile.am
create mode 100644 kdict/applet/kdictapplet.cpp
create mode 100644 kdict/applet/kdictapplet.desktop
create mode 100644 kdict/applet/kdictapplet.h
create mode 100644 kdict/application.cpp
create mode 100644 kdict/application.h
create mode 100644 kdict/dcopinterface.h
create mode 100644 kdict/dict.cpp
create mode 100644 kdict/dict.h
create mode 100644 kdict/hi128-app-kdict.png
create mode 100644 kdict/hi16-app-kdict.png
create mode 100644 kdict/hi32-app-kdict.png
create mode 100644 kdict/hi48-app-kdict.png
create mode 100644 kdict/hi64-app-kdict.png
create mode 100644 kdict/hisc-app-kdict.svgz
create mode 100644 kdict/kdict.desktop
create mode 100644 kdict/kdictui.rc
create mode 100644 kdict/main.cpp
create mode 100644 kdict/matchview.cpp
create mode 100644 kdict/matchview.h
create mode 100644 kdict/options.cpp
create mode 100644 kdict/options.h
create mode 100644 kdict/pics/Makefile.am
create mode 100644 kdict/pics/cr16-action-define_clip.png
create mode 100644 kdict/pics/cr16-action-query_erase.png
create mode 100644 kdict/pics/cr22-action-define_clip.png
create mode 100644 kdict/pics/cr32-action-define_clip.png
create mode 100644 kdict/queryview.cpp
create mode 100644 kdict/queryview.h
create mode 100644 kdict/sets.cpp
create mode 100644 kdict/sets.h
create mode 100644 kdict/toplevel.cpp
create mode 100644 kdict/toplevel.h
(limited to 'kdict')
diff --git a/kdict/AUTHORS b/kdict/AUTHORS
new file mode 100644
index 00000000..b81599fe
--- /dev/null
+++ b/kdict/AUTHORS
@@ -0,0 +1,25 @@
+Developers:
+Christian Gebauer
+Matthias Hoelzer-Kluepfel
+
+Documentation:
+Christian Gebauer
+
+Translators:
+Wolfram Diestel
+Otto Bruggeman
+Mattias Newzella
+Andris Maziks
+Jaime Robles
+Pedro Morais
+Andrey S. Cherepanov
+Claudiu Costin
+Erik Kjær Pedersen
+Stanislav Visnovsky
+Andy Rysin
+Dimitris Kamenopoulos
+Meni Livne
+Matthias Kiefer
+Sinohara
+Tamas Szanto
+Grkem etin
\ No newline at end of file
diff --git a/kdict/ChangeLog b/kdict/ChangeLog
new file mode 100644
index 00000000..d9513c75
--- /dev/null
+++ b/kdict/ChangeLog
@@ -0,0 +1,79 @@
+0.5.3
+ + recognize http and ftp urls in cross references
+ + convert characters that are incompatible with html
+ like <,>,& into &, etc.
+
+0.5.2
+ + Kdict is now part of the offical kdenetwork package
+ + support for IPv6 and socks-proxies
+ + up-to-date docbook-handbook
+ + code cleanup
+
+0.5
+ + dcop interface
+ + panel applet
+ + bugfixes: session management, small problems
+ with the toolbar editor
+
+0.4.1
+ + fixed CSS-issues with KDE 2.0.x
+ + fixed saving of results as html file
+
+0.4
+ + ported to KDE2
+ + full unicode support
+ + improved portability, should work in non-linux environments now
+ + the german gui-translation is missing in this release,
+ I will add it later on
+ + documentation is not yet converted to docbook
+
+0.3.1
+ + essential bugfix for older, libc5-based linux systems
+ (Thanks to Osvaldo Fornaro for testing)
+ + mini-howto for installing a local DICT-server
+
+0.3
+ + integrated implementation of the DICT-protocol,
+ dict(1) is no longer needed.
+ + match mode: At first all matches for a query are
+ displayed in a separate list, the user can then
+ choose the most interesting definitions.
+ + database sets: The user can create individual
+ compilations of the available databases and use
+ them in the same way as a single database.
+ + nicer/more configurable html-layout
+ + find dialog for locating text in the definitions
+ + the user can paste text into Kdict with the middle
+ mouse button. Kdict starts a new query with the pasted text
+ (analogue to Netscape).
+ + command to show detailed database information is
+ implemented ("show info")
+ + speed improvements:
+ * faster html-generation
+ * results are stored in a local cache, so they
+ are displayed instantly when the users wants to
+ browse back.
+ * Kdict holds the connection to the server
+ for a configurable amount of time.
+ + various gui improvements:
+ * improved statusbar
+ * unified preferences dialog
+ * all toolbars are now removable and remember
+ their position.
+ * new toolbar icons
+ + ...
+
+0.2
+ fixed some bugs (and introduced new ones ;-)
+ added various features:
+ + saving/printing of the queryresult
+ + query history
+ + improved html output
+ + improved command line interface
+ + html help
+ + Preferences dialogbox for fonts, colors, etc.
+ + Synonyms get displayed and handled like hyperlinks
+ + Automatically lookup of a word in the X clipboard
+ + ...
+
+0.1 Initial release
diff --git a/kdict/LICENSE b/kdict/LICENSE
new file mode 100644
index 00000000..4def90fc
--- /dev/null
+++ b/kdict/LICENSE
@@ -0,0 +1,125 @@
+kdict - The KDE Dictionary Client
+
+Copyright (C) 2000-2001 Christian Gebauer
+copyright (C) 1998 by Matthias Hoelzer
+
+
+ Preamble
+
+ The intent of this document is to state the conditions under which a
+ Package may be copied, such that the Copyright Holder maintains some
+ semblance of artistic control over the development of the package,
+ while giving the users of the package the right to use and
+ distribute the Package in a more-or-less customary fashion, plus the
+ right to make reasonable modifications.
+
+ Definitions:
+
+ * "Package" refers to the collection of files distributed by the
+ Copyright Holder, and derivatives of that collection of files
+ created through textual modification.
+
+ * "Standard Version" refers to such a Package if it has not been
+ modified, or has been modified in accordance with the wishes of
+ the Copyright Holder.
+
+ * "Copyright Holder" is whoever is named in the copyright or
+ copyrights for the package.
+
+ * "You" is you, if you're thinking about copying or distributing
+ this Package.
+
+ * "Reasonable copying fee" is whatever you can justify on the
+ basis of media cost, duplication charges, time of people
+ involved, and so on. (You will not be required to justify it to
+ the Copyright Holder, but only to the computing community at
+ large as a market that must bear the fee.)
+
+ * "Freely Available" means that no fee is charged for the item
+ itself, though there may be fees involved in handling the item.
+ It also means that recipients of the item may redistribute it
+ under the same conditions they received it.
+
+ 1. You may make and give away verbatim copies of the source form of
+ the Standard Version of this Package without restriction, provided
+ that you duplicate all of the original copyright notices and
+ associated disclaimers.
+
+ 2. You may apply bug fixes, portability fixes and other
+ modifications derived from the Public Domain or from the Copyright
+ Holder. A Package modified in such a way shall still be considered
+ the Standard Version.
+
+ 3. You may otherwise modify your copy of this Package in any way,
+ provided that you insert a prominent notice in each changed file
+ stating how and when you changed that file, and provided that you do
+ at least ONE of the following:
+
+ a) place your modifications in the Public Domain or
+ otherwise make them Freely Available, such as by posting
+ said modifications to Usenet or an equivalent medium, or
+ placing the modifications on a major archive site such as
+ ftp.uu.net, or by allowing the Copyright Holder to include
+ your modifications in the Standard Version of the Package.
+
+ b) use the modified Package only within your corporation
+ or organization.
+
+ c) rename any non-standard executables so the names do not
+ conflict with standard executables, which must also be
+ provided, and provide a separate manual page for each
+ non-standard executable that clearly documents how it
+ differs from the Standard Version.
+
+ d) make other distribution arrangements with the Copyright
+ Holder.
+
+ 4. You may distribute the programs of this Package in object code or
+ executable form, provided that you do at least ONE of the following:
+
+ a) distribute a Standard Version of the executables and
+ library files, together with instructions (in the manual
+ page or equivalent) on where to get the Standard Version.
+
+ b) accompany the distribution with the machine-readable
+ source of the Package with your modifications.
+
+ c) accompany any non-standard executables with their
+ corresponding Standard Version executables, giving the
+ non-standard executables non-standard names, and clearly
+ documenting the differences in manual pages (or
+ equivalent), together with instructions on where to get
+ the Standard Version.
+
+ d) make other distribution arrangements with the Copyright
+ Holder.
+
+ 5. You may charge a reasonable copying fee for any distribution of
+ this Package. You may charge any fee you choose for support of this
+ Package. You may not charge a fee for this Package itself. However,
+ you may distribute this Package in aggregate with other (possibly
+ commercial) programs as part of a larger (possibly commercial)
+ software distribution provided that you do not advertise this
+ Package as a product of your own.
+
+ 6. The scripts and library files supplied as input to or produced as
+ output from the programs of this Package do not automatically fall
+ under the copyright of this Package, but belong to whomever
+ generated them, and may be sold commercially, and may be aggregated
+ with this Package.
+
+ 7. C or perl subroutines supplied by you and linked into this
+ Package shall not be considered part of this Package.
+
+ 8. The name of the Copyright Holder may not be used to endorse or
+ promote products derived from this software without specific prior
+ written permission.
+
+ 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+
+ The End
+
+
+
diff --git a/kdict/Makefile.am b/kdict/Makefile.am
new file mode 100644
index 00000000..5cb60755
--- /dev/null
+++ b/kdict/Makefile.am
@@ -0,0 +1,33 @@
+## Makefile.am for kdict
+
+KDE_CXXFLAGS = $(USE_THREADS)
+
+SUBDIRS = applet pics
+
+bin_PROGRAMS =
+lib_LTLIBRARIES =
+kdeinit_LTLIBRARIES = kdict.la
+
+# set the include path for X, qt and KDE
+AM_CPPFLAGS = $(all_includes)
+
+kdict_la_LDFLAGS = $(KDE_RPATH) $(all_libraries) -module $(KDE_PLUGIN)
+kdict_la_LIBADD = $(LIB_KFILE) $(LIB_KHTML) $(LIBPTHREAD) $(LIBRESOLV)
+kdict_la_SOURCES = dcopinterface.skel main.cpp actions.cpp dict.cpp options.cpp \
+ queryview.cpp toplevel.cpp sets.cpp matchview.cpp application.cpp
+
+# these are the headers for your project
+noinst_HEADERS = actions.h dict.h options.h queryview.h toplevel.h sets.h matchview.h application.h
+
+METASOURCES = AUTO
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp *.h -o $(podir)/kdict.pot
+
+KDE_ICON = AUTO
+
+# this is where the kdelnk file will go
+xdg_apps_DATA = kdict.desktop
+
+rcdir = $(kde_datadir)/kdict
+rc_DATA = kdictui.rc
diff --git a/kdict/README b/kdict/README
new file mode 100644
index 00000000..894983ab
--- /dev/null
+++ b/kdict/README
@@ -0,0 +1,47 @@
+Kdict - The KDE Dictionary Client
+Copyright (C) 2000-2001 Christian Gebauer
+copyright (c) 1998 by Matthias Hoelzer
+
+maintained by Christian Gebauer
+
+Homepage: http://www.rhrk.uni-kl.de/~gebauerc/kdict/
+
+See LICENSE for the license of this programm.
+
+**************************************************************************
+
+Kdict is a graphical client for the DICT Protocol.
+It enables you to search through dictionary-like databases
+for a word or phrase, then displays suitable definitions.
+
+Kdict trys to ease basic as well as advanced queries. A separate list
+offers a convenient way to deal with the enormous number of matching
+words that a advanced query can return.
+
+The remainder of Kdict's user interface resembles a web browser:
+For instance, you can jump to the definition of a synonym by
+simply clicking on the highlighted word. The back/forward functionality
+is also implemented, enabling you to quickly go back to the result of
+previous queries.
+
+Kdict is able to process the content of the X clipboard, so it's easy
+to combine Kdict with your web browser or text editor.
+
+Kdict is now a real client, no additional software is needed.
+
+If your machine is behind a firewall, has no permanent internet
+connection or the server of dict.org is too slow for you, you can
+set up your own local server, all you need is available at
+http://www.dict.org.
+The advantages of a local server are optimal performance and
+the ability to install additional databases of your choice.
+The handbook contains a small tutorial for installation
+and links to databases.
+
+**************************************************************************
+
+For installing Kdict you need:
+
+- KDE 3.x
+- POSIX Threads
+
diff --git a/kdict/TODO b/kdict/TODO
new file mode 100644
index 00000000..5a1d2446
--- /dev/null
+++ b/kdict/TODO
@@ -0,0 +1,2 @@
+* offline-support:
+ accessing local database-files without running a dictd-server
\ No newline at end of file
diff --git a/kdict/actions.cpp b/kdict/actions.cpp
new file mode 100644
index 00000000..5ca1aade
--- /dev/null
+++ b/kdict/actions.cpp
@@ -0,0 +1,335 @@
+/* -------------------------------------------------------------
+
+ actions.cpp (part of The KDE Dictionary Client)
+
+ Copyright (C) 2000-2001 Christian Gebauer
+
+ This file is distributed under the Artistic License.
+ See LICENSE for details.
+
+ -------------------------------------------------------------
+
+ DictComboAction, special KAction subclasses used
+ DictLabelAction, in the toolbar
+ DictButtonAction
+
+ ------------------------------------------------------------- */
+
+#include "actions.h"
+
+#include
+#include
+
+#include
+#include
+
+
+DictComboAction::DictComboAction( const QString &text, QObject *parent, const char *name,
+ bool editable, bool autoSized )
+ : KAction( text, 0, parent, name ), m_editable(editable), m_autoSized(autoSized), m_compMode(KGlobalSettings::completionMode())
+{
+}
+
+
+DictComboAction::~DictComboAction()
+{
+}
+
+
+int DictComboAction::plug( QWidget *widget, int index )
+{
+ if ( widget->inherits( "KToolBar" ) )
+ {
+ KToolBar* bar = static_cast( widget );
+ int id_ = KAction::getToolButtonID();
+
+ m_combo = new KComboBox(m_editable,bar);
+ m_combo->setCompletionMode(m_compMode);
+
+ bar->insertWidget( id_, m_combo->sizeHint().width(), m_combo, index );
+ bar->setItemAutoSized(id_,m_autoSized);
+
+ if ( m_combo ) {
+ connect(bar->getCombo(id_), SIGNAL(activated(const QString&)), SLOT(slotComboActivated(const QString&)));
+ connect(bar->getCombo(id_), SIGNAL(activated(int)), SLOT(slotComboActivated(int)));
+
+ if (m_editable)
+ m_combo->setInsertionPolicy( QComboBox::NoInsertion );
+ }
+
+ addContainer( bar, id_ );
+ connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) );
+ return containerCount() - 1;
+ }
+
+ return -1;
+}
+
+
+void DictComboAction::unplug( QWidget *widget )
+{
+ if ( widget->inherits( "KToolBar" ) )
+ {
+ KToolBar *bar = (KToolBar *)widget;
+
+ int idx = findContainer( bar );
+
+ if ( idx != -1 )
+ {
+ bar->removeItem( itemId( idx ) );
+ removeContainer( idx );
+ }
+
+ return;
+ }
+}
+
+
+QWidget* DictComboAction::widget()
+{
+ return m_combo;
+}
+
+
+void DictComboAction::setFocus()
+{
+ if (m_combo)
+ m_combo->setFocus();
+}
+
+
+QString DictComboAction::currentText() const
+{
+ if (m_combo)
+ return m_combo->currentText();
+ else
+ return QString::null;
+}
+
+void DictComboAction::selectAll()
+{
+ if (m_combo)
+ {
+ m_combo->lineEdit()->selectAll();
+ m_combo->lineEdit()->setFocus();
+ }
+}
+
+
+void DictComboAction::setEditText(const QString &s)
+{
+ if (m_combo && m_editable)
+ m_combo->setEditText(s);
+}
+
+
+void DictComboAction::setCurrentItem(int index)
+{
+ if (m_combo)
+ m_combo->setCurrentItem(index);
+}
+
+
+void DictComboAction::clearEdit()
+{
+ if (m_combo && m_editable)
+ m_combo->clearEdit();
+}
+
+
+void DictComboAction::clear()
+{
+ if (m_combo) {
+ m_combo->clear();
+ if (m_editable && m_combo->completionObject())
+ m_combo->completionObject()->clear();
+ }
+}
+
+
+void DictComboAction::setList(QStringList items)
+{
+ if (m_combo) {
+ m_combo->clear();
+ m_combo->insertStringList(items);
+ if (m_editable && m_combo->completionObject())
+ m_combo->completionObject()->setItems(items);
+ if (!m_autoSized)
+ m_combo->setFixedWidth(m_combo->sizeHint().width());
+ }
+}
+
+
+KGlobalSettings::Completion DictComboAction::completionMode()
+{
+ if (m_combo)
+ return m_combo->completionMode();
+ else
+ return m_compMode;
+ }
+
+
+void DictComboAction::setCompletionMode(KGlobalSettings::Completion mode)
+{
+ if (m_combo)
+ m_combo->setCompletionMode(mode);
+ else
+ m_compMode = mode;
+}
+
+
+void DictComboAction::slotComboActivated(int i)
+{
+ emit(activated(i));
+}
+
+
+void DictComboAction::slotComboActivated(const QString &s)
+{
+ emit(activated(s));
+}
+
+
+//*********************************************************************************
+
+
+DictLabelAction::DictLabelAction( const QString &text, QObject *parent, const char *name )
+ : KAction( text, 0, parent, name )
+{
+}
+
+
+DictLabelAction::~DictLabelAction()
+{
+}
+
+
+int DictLabelAction::plug( QWidget *widget, int index )
+{
+ if ( widget->inherits( "KToolBar" ) )
+ {
+ KToolBar *tb = (KToolBar *)widget;
+
+ int id = KAction::getToolButtonID();
+
+ QLabel *label = new QLabel( text(), widget, "kde toolbar widget" );
+ label->setMinimumWidth(label->sizeHint().width());
+ label->setBackgroundMode( Qt::PaletteButton );
+ label->setAlignment(AlignCenter | AlignVCenter);
+ label->adjustSize();
+
+ tb->insertWidget( id, label->width(), label, index );
+
+ addContainer( tb, id );
+
+ connect( tb, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) );
+
+ m_label = label;
+
+ return containerCount() - 1;
+ }
+
+ return -1;
+}
+
+
+void DictLabelAction::unplug( QWidget *widget )
+{
+ if ( widget->inherits( "KToolBar" ) )
+ {
+ KToolBar *bar = (KToolBar *)widget;
+
+ int idx = findContainer( bar );
+
+ if ( idx != -1 )
+ {
+ bar->removeItem( itemId( idx ) );
+ removeContainer( idx );
+ }
+
+ return;
+ }
+}
+
+
+void DictLabelAction::setBuddy(QWidget *buddy)
+{
+ if (m_label && buddy)
+ m_label->setBuddy(buddy);
+}
+
+
+//*********************************************************************************
+
+
+DictButtonAction::DictButtonAction( const QString& text, QObject* receiver,
+ const char* slot, QObject* parent, const char* name )
+ : KAction( text, 0, receiver, slot, parent, name )
+{
+}
+
+
+DictButtonAction::~DictButtonAction()
+{
+}
+
+
+int DictButtonAction::plug( QWidget *widget, int index )
+{
+ if ( widget->inherits( "KToolBar" ) )
+ {
+ KToolBar *tb = (KToolBar *)widget;
+
+ int id = KAction::getToolButtonID();
+
+ QPushButton *button = new QPushButton( text(), widget );
+ button->adjustSize();
+ connect(button,SIGNAL(clicked()),this,SLOT(activate()));
+ tb->insertWidget( id, button->width(), button, index );
+
+ addContainer( tb, id );
+
+ connect( tb, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) );
+
+ m_button = button;
+
+ return containerCount() - 1;
+ }
+
+ return -1;
+}
+
+
+void DictButtonAction::unplug( QWidget *widget )
+{
+ if ( widget->inherits( "KToolBar" ) )
+ {
+ KToolBar *bar = (KToolBar *)widget;
+
+ int idx = findContainer( bar );
+
+ if ( idx != -1 )
+ {
+ bar->removeItem( itemId( idx ) );
+ removeContainer( idx );
+ }
+ }
+}
+
+
+int DictButtonAction::widthHint()
+{
+ if (m_button)
+ return m_button->sizeHint().width();
+ else
+ return 0;
+}
+
+
+void DictButtonAction::setWidth(int width)
+{
+ if (m_button)
+ m_button->setFixedWidth(width);
+}
+
+#include "actions.moc"
diff --git a/kdict/actions.h b/kdict/actions.h
new file mode 100644
index 00000000..568a9f7c
--- /dev/null
+++ b/kdict/actions.h
@@ -0,0 +1,111 @@
+/* -------------------------------------------------------------
+
+ actions.h (part of The KDE Dictionary Client)
+
+ Copyright (C) 2000-2001 Christian Gebauer
+
+ This file is distributed under the Artistic License.
+ See LICENSE for details.
+
+ -------------------------------------------------------------
+
+ DictComboAction, special KAction subclasses used
+ DictLabelAction, in the toolbar
+ DictButtonAction
+
+ ------------------------------------------------------------- */
+
+#ifndef _ACTIONS_H_
+#define _ACTIONS_H_
+
+#include
+#include
+#include
+#include
+
+class KComboBox;
+class QLabel;
+class QPushButton;
+
+
+class DictComboAction : public KAction
+{
+ Q_OBJECT
+
+ public:
+ DictComboAction( const QString& text, QObject* parent,
+ const char* name, bool editable, bool autoSized );
+ ~DictComboAction();
+
+ virtual int plug( QWidget *w, int index = -1 );
+ virtual void unplug( QWidget *w );
+
+ QWidget* widget();
+ void setFocus();
+
+ QString currentText() const;
+ void selectAll();
+ void setEditText(const QString &s);
+ void setCurrentItem(int index);
+ void clearEdit();
+
+ void clear();
+ void setList(QStringList items);
+
+ KGlobalSettings::Completion completionMode();
+ void setCompletionMode(KGlobalSettings::Completion mode);
+
+ signals:
+ void activated(int);
+ void activated(const QString&);
+
+ private slots:
+ void slotComboActivated(int);
+ void slotComboActivated(const QString&);
+
+ private:
+ QGuardedPtr m_combo;
+ bool m_editable, m_autoSized;
+ KGlobalSettings::Completion m_compMode;
+};
+
+
+class DictLabelAction : public KAction
+{
+ Q_OBJECT
+
+ public:
+ DictLabelAction( const QString &text, QObject *parent = 0, const char *name = 0 );
+ ~DictLabelAction();
+
+ virtual int plug( QWidget *widget, int index = -1 );
+ virtual void unplug( QWidget *widget );
+
+ void setBuddy(QWidget *buddy);
+
+ private:
+ QGuardedPtr m_label;
+
+};
+
+
+class DictButtonAction : public KAction
+{
+ Q_OBJECT
+
+ public:
+ DictButtonAction( const QString& text, QObject* receiver,
+ const char* slot, QObject* parent, const char* name );
+ ~DictButtonAction();
+
+ virtual int plug( QWidget *w, int index = -1 );
+ virtual void unplug( QWidget *w );
+
+ int widthHint();
+ void setWidth(int width);
+
+ private:
+ QGuardedPtr m_button;
+};
+
+#endif
diff --git a/kdict/applet/Makefile.am b/kdict/applet/Makefile.am
new file mode 100644
index 00000000..db1f4bc2
--- /dev/null
+++ b/kdict/applet/Makefile.am
@@ -0,0 +1,19 @@
+INCLUDES = $(all_includes)
+
+kde_module_LTLIBRARIES = kdict_panelapplet.la
+
+kdict_panelapplet_la_SOURCES = kdictapplet.cpp
+
+METASOURCES = AUTO
+noinst_HEADERS = kdictapplet.h
+
+lnkdir = $(kde_datadir)/kicker/applets
+lnk_DATA = kdictapplet.desktop
+
+EXTRA_DIST = $(lnk_DATA)
+
+kdict_panelapplet_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -module
+kdict_panelapplet_la_LIBADD = $(LIB_KSYCOCA) $(LIB_KDEUI)
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp *.h -o $(podir)/kdictapplet.pot
diff --git a/kdict/applet/kdictapplet.cpp b/kdict/applet/kdictapplet.cpp
new file mode 100644
index 00000000..ad907864
--- /dev/null
+++ b/kdict/applet/kdictapplet.cpp
@@ -0,0 +1,405 @@
+/* -------------------------------------------------------------
+
+ kdictapplet.h (part of The KDE Dictionary Client)
+
+ Copyright (C) 2001 Christian Gebauer
+
+ The applet is loosely based on the "Run" applet included in KDE.
+ Copyright (c) 2000 Matthias Elter (Artistic License)
+
+ This file is distributed under the Artistic License.
+ See LICENSE for details.
+
+ -------------------------------------------------------------
+
+ PopupBox helper class
+ DictApplet a small kicker-applet
+
+ ------------------------------------------------------------- */
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "kdictapplet.h"
+
+//********* PopupBox ********************************************
+
+PopupBox::PopupBox()
+ : QHBox(0, 0, WStyle_Customize | WType_Popup ), popupEnabled(true)
+{
+}
+
+
+PopupBox::~PopupBox()
+{}
+
+
+bool PopupBox::showBox()
+{
+ if (!popupEnabled) // prevents that the popup is shown again immediatly
+ return false;
+ else {
+ show();
+ return true;
+ }
+}
+
+
+void PopupBox::hideEvent(QHideEvent *)
+{
+ emit(hidden());
+ popupEnabled = false;
+ QTimer::singleShot(100, this, SLOT(enablePopup()));
+}
+
+
+void PopupBox::enablePopup()
+{
+ popupEnabled = true;
+}
+
+
+//********* DictApplet ********************************************
+
+extern "C"
+{
+ KDE_EXPORT KPanelApplet* init(QWidget *parent, const QString& configFile)
+ {
+ KGlobal::locale()->insertCatalogue("kdictapplet");
+ return new DictApplet(configFile, KPanelApplet::Stretch, 0, parent, "kdictapplet");
+ }
+}
+
+
+DictApplet::DictApplet(const QString& configFile, Type type, int actions, QWidget *parent, const char *name)
+ : KPanelApplet(configFile, type, actions, parent, name), waiting(0)
+{
+ // first the widgets for a horizontal panel
+ baseWidget = new QWidget(this);
+ QGridLayout *baseLay = new QGridLayout(baseWidget,2,6,0,1);
+
+ textLabel = new QLabel(i18n("Dictionary:"), baseWidget);
+ textLabel->setBackgroundOrigin(AncestorOrigin);
+ QFont f(textLabel->font());
+ f.setPixelSize(12);
+ textLabel->setFont(f);
+ baseLay->addWidget(textLabel,0,1);
+ QToolTip::add(textLabel,i18n("Look up a word or phrase with Kdict"));
+
+ iconLabel = new QLabel(baseWidget);
+ iconLabel->setBackgroundOrigin(AncestorOrigin);
+ QPixmap pm = KGlobal::iconLoader()->loadIcon("kdict", KIcon::Panel, KIcon::SizeSmall, KIcon::DefaultState, 0L, true);
+ iconLabel->setPixmap(pm);
+ baseLay->addWidget(iconLabel,1,0);
+ iconLabel->setAlignment(Qt::AlignCenter | Qt::AlignVCenter);
+ iconLabel->setFixedWidth(pm.width()+4);
+ QToolTip::add(iconLabel,i18n("Look up a word or phrase with Kdict"));
+
+ f.setPixelSize(10);
+ clipboardBtn = new QPushButton(i18n("C"),baseWidget);
+ clipboardBtn->setBackgroundOrigin(AncestorOrigin);
+ clipboardBtn->setFont(f);
+ clipboardBtn->setFixedSize(16,16);
+ connect(clipboardBtn, SIGNAL(clicked()), SLOT(queryClipboard()));
+ baseLay->addWidget(clipboardBtn,0,3);
+ QToolTip::add(clipboardBtn,i18n("Define selected text"));
+
+ defineBtn = new QPushButton(i18n("D"),baseWidget);
+ defineBtn->setBackgroundOrigin(AncestorOrigin);
+ defineBtn->setFont(f);
+ defineBtn->setFixedSize(16,16);
+ defineBtn->setEnabled(false);
+ connect(defineBtn, SIGNAL(clicked()), SLOT(startDefine()));
+ baseLay->addWidget(defineBtn,0,4);
+ QToolTip::add(defineBtn,i18n("Define word/phrase"));
+
+ matchBtn = new QPushButton(i18n("M"),baseWidget);
+ matchBtn->setBackgroundOrigin(AncestorOrigin);
+ matchBtn->setFont(f);
+ matchBtn->setFixedSize(16,16);
+ matchBtn->setEnabled(false);
+ connect(matchBtn, SIGNAL(clicked()), SLOT(startMatch()));
+ baseLay->addWidget(matchBtn,0,5);
+ QToolTip::add(matchBtn,i18n("Find matching definitions"));
+
+ completionObject = new KCompletion();
+
+ internalCombo = new KHistoryCombo(baseWidget);
+ internalCombo->setBackgroundOrigin(AncestorOrigin);
+ internalCombo->setCompletionObject(completionObject);
+ internalCombo->setFocus();
+ internalCombo->clearEdit();
+ internalCombo->lineEdit()->installEventFilter( this );
+ connect(internalCombo, SIGNAL(returnPressed(const QString&)), SLOT(startQuery(const QString&)));
+ connect(internalCombo, SIGNAL(textChanged(const QString&)), SLOT(comboTextChanged(const QString&)));
+ QToolTip::add(internalCombo,i18n("Look up a word or phrase with Kdict"));
+
+ baseLay->addMultiCellWidget(internalCombo,1,1,1,5);
+
+ baseLay->setColStretch(2,1);
+
+ // widgets for a vertical panel
+ verticalBtn = new QPushButton(this);
+ connect(verticalBtn, SIGNAL(pressed()), SLOT(showExternalCombo()));
+ QToolTip::add(verticalBtn,i18n("Look up a word or phrase with Kdict"));
+
+ popupBox = new PopupBox();
+ popupBox->setFixedSize(160, 22);
+ connect(popupBox, SIGNAL(hidden()), SLOT(externalComboHidden()));
+ externalCombo = new KHistoryCombo(popupBox);
+ externalCombo->setCompletionObject(completionObject);
+ connect(externalCombo, SIGNAL(returnPressed(const QString&)), SLOT(startQuery(const QString&)));
+ externalCombo->setFixedSize(160, externalCombo->sizeHint().height());
+
+ connect(internalCombo, SIGNAL(completionModeChanged(KGlobalSettings::Completion)),
+ this, SLOT(updateCompletionMode(KGlobalSettings::Completion)));
+ connect(externalCombo, SIGNAL(completionModeChanged(KGlobalSettings::Completion)),
+ this, SLOT(updateCompletionMode(KGlobalSettings::Completion)));
+
+ // restore history and completion list
+ KConfig *c = config();
+ c->setGroup("General");
+
+ QStringList list = c->readListEntry("Completion list");
+ completionObject->setItems(list);
+ int mode = c->readNumEntry("Completion mode",
+ KGlobalSettings::completionMode());
+ internalCombo->setCompletionMode((KGlobalSettings::Completion)mode);
+ externalCombo->setCompletionMode((KGlobalSettings::Completion)mode);
+
+ list = c->readListEntry("History list");
+ internalCombo->setHistoryItems(list);
+ externalCombo->setHistoryItems(list);
+}
+
+
+DictApplet::~DictApplet()
+{
+ // save history and completion list
+ KConfig *c = config();
+ c->setGroup("General");
+
+ QStringList list = completionObject->items();
+ c->writeEntry("Completion list", list);
+ c->writeEntry("Completion mode", (int) internalCombo->completionMode());
+
+ list = internalCombo->historyItems();
+ c->writeEntry("History list", list);
+ c->sync();
+
+ delete completionObject;
+}
+
+
+int DictApplet::widthForHeight(int height) const
+{
+ if (height >= 38)
+ return textLabel->sizeHint().width()+55;
+ else
+ return textLabel->sizeHint().width()+25;
+}
+
+
+int DictApplet::heightForWidth(int width) const
+{
+ return width;
+}
+
+
+void DictApplet::resizeEvent(QResizeEvent*)
+{
+ if (orientation() == Horizontal) {
+ verticalBtn->hide();
+ baseWidget->show();
+ baseWidget->setFixedSize(width(),height());
+
+ if (height() < internalCombo->sizeHint().height())
+ internalCombo->setFixedHeight(height());
+ else
+ internalCombo->setFixedHeight(internalCombo->sizeHint().height());
+
+ if (height() >= 38) {
+ textLabel->show();
+ clipboardBtn->show();
+ defineBtn->show();
+ matchBtn->show();
+ iconLabel->hide();
+ internalCombo->setFixedWidth(width());
+ } else {
+ textLabel->hide();
+ clipboardBtn->hide();
+ defineBtn->hide();
+ matchBtn->hide();
+ iconLabel->show();
+ internalCombo->setFixedWidth(width()-iconLabel->width()-1);
+ }
+
+ baseWidget->updateGeometry();
+ } else { // orientation() == Vertical
+ verticalBtn->show();
+ baseWidget->hide();
+ verticalBtn->setFixedSize(width(),width());
+
+ KIcon::StdSizes sz = width() < 32 ? KIcon::SizeSmall : (width() < 48 ? KIcon::SizeMedium : KIcon::SizeLarge);
+ QPixmap pm = KGlobal::iconLoader()->loadIcon("kdict", KIcon::Panel, sz, KIcon::DefaultState, 0L, true);
+ verticalBtn->setPixmap(pm);
+ }
+}
+
+
+bool DictApplet::eventFilter( QObject *o, QEvent * e)
+{
+ if (e->type() == QEvent::MouseButtonRelease)
+ emit requestFocus();
+
+ return KPanelApplet::eventFilter(o, e);
+}
+
+
+void DictApplet::sendCommand(const QCString &fun, const QString &data)
+{
+ if (waiting > 0) {
+ waiting = 1;
+ delayedFunc = fun.copy();
+ delayedData = data;
+ return;
+ }
+
+ DCOPClient *client = kapp->dcopClient();
+ if (!client->isApplicationRegistered("kdict")) {
+ KApplication::startServiceByDesktopName("kdict");
+ waiting = 1;
+ delayedFunc = fun.copy();
+ delayedData = data;
+ QTimer::singleShot(100, this, SLOT(sendDelayedCommand()));
+ return;
+ } else {
+ QCStringList list = client->remoteObjects("kdict");
+ if (list.findIndex("KDictIface")==-1) {
+ waiting = 1;
+ delayedFunc = fun.copy();
+ delayedData = data;
+ QTimer::singleShot(100, this, SLOT(sendDelayedCommand()));
+ return;
+ }
+ }
+
+ client->send("kdict","default",fun,data);
+}
+
+
+void DictApplet::sendDelayedCommand()
+{
+ if (waiting > 100) { // timeout after ten seconds
+ waiting = 0;
+ return;
+ }
+
+ DCOPClient *client = kapp->dcopClient();
+ if (!client->isApplicationRegistered("kdict")) {
+ waiting++;
+ QTimer::singleShot(100, this, SLOT(sendDelayedCommand()));
+ return;
+ } else {
+ QCStringList list = client->remoteObjects("kdict");
+ if (list.findIndex("KDictIface")==-1) {
+ waiting++;
+ QTimer::singleShot(100, this, SLOT(sendDelayedCommand()));
+ return;
+ }
+ }
+
+ client->send("kdict","default",delayedFunc,delayedData);
+ waiting = 0;
+}
+
+
+void DictApplet::startQuery(const QString &s)
+{
+ QString query = s.stripWhiteSpace();
+ if (query.isEmpty())
+ return;
+
+ internalCombo->addToHistory(query);
+ externalCombo->addToHistory(query);
+ internalCombo->clearEdit();
+ externalCombo->clearEdit();
+
+ sendCommand("definePhrase(QString)",query);
+
+ if (orientation() == Vertical)
+ popupBox->hide();
+}
+
+
+void DictApplet::comboTextChanged(const QString &s)
+{
+ defineBtn->setEnabled(!s.isEmpty());
+ matchBtn->setEnabled(!s.isEmpty());
+}
+
+
+void DictApplet::queryClipboard()
+{
+ sendCommand("defineClipboardContent()",QString::null);
+}
+
+
+void DictApplet::startDefine()
+{
+ startQuery(internalCombo->currentText());
+}
+
+
+void DictApplet::startMatch()
+{
+ QString query = internalCombo->currentText().stripWhiteSpace();
+ internalCombo->addToHistory(query);
+ externalCombo->addToHistory(query);
+ internalCombo->clearEdit();
+ externalCombo->clearEdit();
+
+ sendCommand("matchPhrase(QString)",query);
+}
+
+
+void DictApplet::showExternalCombo()
+{
+ QPoint p;
+ if (position() == pLeft)
+ p = mapToGlobal(QPoint(-popupBox->width()-1, 0));
+ else
+ p = mapToGlobal(QPoint(width()+1, 0));
+ popupBox->move(p);
+ if (popupBox->showBox())
+ externalCombo->setFocus();
+ else
+ verticalBtn->setDown(false);
+}
+
+
+void DictApplet::externalComboHidden()
+{
+ verticalBtn->setDown(false);
+}
+
+void DictApplet::updateCompletionMode(KGlobalSettings::Completion mode)
+{
+ internalCombo->setCompletionMode(mode);
+ externalCombo->setCompletionMode(mode);
+}
+
+//--------------------------------
+
+#include "kdictapplet.moc"
diff --git a/kdict/applet/kdictapplet.desktop b/kdict/applet/kdictapplet.desktop
new file mode 100644
index 00000000..23d26f3f
--- /dev/null
+++ b/kdict/applet/kdictapplet.desktop
@@ -0,0 +1,147 @@
+[Desktop Entry]
+Comment=Lookup phrases in a dictionary
+Comment[af]=Opkyk frases in 'n woordeboek
+Comment[ar]=ابحث عن الكلمات في القاموس
+Comment[az]=Lüğətdən kəlimələrə baxın
+Comment[be]=Пошук выразаў у слоўніку
+Comment[bg]=Търсене на фрази в речника
+Comment[bn]=একটি অভিধানে শব্দসমষ্টির খোঁজ করো
+Comment[bs]=Potražite fraze u rječniku
+Comment[ca]=Cerca expressions en un diccionari
+Comment[cs]=Vyhledávač pojmů ve slovníku
+Comment[cy]=Edrych am ddywediadau mewn geiriadur
+Comment[da]=Slå sætninger op i en ordbog
+Comment[de]=Ausdrücke in einem Lexikon nachschlagen
+Comment[el]=Αναζήτηση φράσεων σε λεξικό
+Comment[eo]=Serĉi kapvortojn en vortaroj
+Comment[es]=Busca expresiones en un diccionario
+Comment[et]=Fraaside otsimine sõnaraamatust
+Comment[eu]=Bilatu esaldiak hiztegi batean
+Comment[fa]=مراجعه به واژهنامه برای عبارتها
+Comment[fi]=Hae lauseita sanakirjasta
+Comment[fr]=Recherche de phrases dans un dictionnaire
+Comment[ga]=Cuardaigh frásaí i bhfoclóir
+Comment[gl]=Buscar expresións no diccionario
+Comment[he]=חיפוש ביטויים במילון
+Comment[hi]=शब्दकोश में वाक्यांशों को देखे
+Comment[hr]=Potraži fraze u rječniku
+Comment[hu]=Szótárkezelő alkalmazás
+Comment[is]=Fletta upp í orðabók
+Comment[it]=Cerca frasi in un dizionario
+Comment[ja]=辞書で語句を検索
+Comment[ka]=ფრაზების ლექსიკონში ძებნა
+Comment[kk]=Сөздікте іздеу
+Comment[km]=រកមើលប្រយោគនៅក្នុងវចនានុក្រមមួយ
+Comment[ko]=사전에서 글귀를 찾아줍니다
+Comment[lt]=Ieškoti frazių žodyne
+Comment[lv]=Skatīt frāzes vārdnīcā
+Comment[mk]=Барајте за изрази во речник
+Comment[mn]=Толь бичигээс үг харах
+Comment[ms]=Mencari frasa di dalam kamus
+Comment[mt]=Fittex frażijiet fid-dizzjunarju
+Comment[nb]=Finn fraser i en ordbok
+Comment[nds]=Begrepen in en Wöörbook nakieken
+Comment[ne]=शब्दकोशमा वाक्यांश खोजी गर्नुहोस्
+Comment[nl]=Zoek bepaalde uitdrukkingen op in een woordenboek
+Comment[nn]=Slå opp ord i ei ordboka
+Comment[nso]=Nyaka mantsu ka gare ga pukuntsu
+Comment[pl]=Szukanie zwrotów w słowniku
+Comment[pt]=Procura por frases num dicionário
+Comment[pt_BR]=Busca frases em um dicionário
+Comment[ro]=Caută fraze într-un dicţionar
+Comment[ru]=Поиск слов в словаре
+Comment[se]=Oza sániid sátnegirjjis
+Comment[sk]=Hľadanie fráz v slovníku
+Comment[sl]=Iskanje Izrazov v slovarju
+Comment[sr]=Потражите фразе у речнику
+Comment[sr@Latn]=Potražite fraze u rečniku
+Comment[sv]=Leta upp fraser i en ordlista
+Comment[ta]=ஒரு அகராதியிலுள்ள தேடற்சொற்தொடர்கள்
+Comment[tg]=Ҷустуҷӯи ибораҳо дар луғат
+Comment[th]=ค้นหาวลีในพจนานุกรม
+Comment[tr]=Sözlükten kelimelere bakın
+Comment[uk]=Пошук фраз у словнику
+Comment[ven]=Todani fhungo kha bugu talutshedza maipfi
+Comment[wa]=Cweri des fråzes dins on diccionaire
+Comment[xh]=Jonga amabinzana kwincwadi enekcazelo zamagama
+Comment[zh_CN]=在字典中查找短语
+Comment[zh_HK]=在字典中尋找片語
+Comment[zh_TW]=在字典中尋找片語
+Comment[zu]=Bheka amagama kwisichazamagama
+Icon=
+Name=Dictionary
+Name[af]=Woordeboek
+Name[ar]=القاموس
+Name[az]=Lüğət
+Name[be]=Слоўнік
+Name[bg]=Речник
+Name[bn]=অভিধান
+Name[br]=Geriadur
+Name[bs]=Rječnik
+Name[ca]=Diccionari
+Name[cs]=Slovník
+Name[cy]=Geiriadur
+Name[da]=Ordbog
+Name[de]=Lexikon
+Name[el]=Λεξικό
+Name[eo]=Vortaro
+Name[es]=Diccionario
+Name[et]=Sõnaraamat
+Name[eu]=Hiztegia
+Name[fa]=واژهنامه
+Name[fi]=Sanakirja
+Name[fr]=Dictionnaire
+Name[ga]=Foclóir
+Name[gl]=Diccionario
+Name[he]=מילון
+Name[hi]=शब्दकोश
+Name[hr]=Rječnik
+Name[hu]=Szótár
+Name[is]=Orðabók
+Name[it]=Dizionario
+Name[ja]=辞書
+Name[ka]=ლექსიკონი
+Name[kk]=Сөздік
+Name[km]=វចនានុក្រម
+Name[ko]=사전
+Name[lt]=Žodynas
+Name[lv]=Vārdnīca
+Name[mk]=Речник
+Name[mn]=Толь бичиг
+Name[ms]=Kamus
+Name[mt]=Dizzjunarju
+Name[nb]=Ordbok
+Name[nds]=Wöörbook
+Name[ne]=शब्दकोश
+Name[nl]=Woordenboek
+Name[nn]=Ordbok
+Name[nso]=Pukuntsu
+Name[pa]=ਸ਼ਬਦ-ਕੋਸ਼
+Name[pl]=Słownik
+Name[pt]=Dicionário
+Name[pt_BR]=Dicionário
+Name[ro]=Dicţionar
+Name[ru]=Словарь
+Name[se]=Sátnegirji
+Name[sk]=Slovník
+Name[sl]=Slovar
+Name[sr]=Речник
+Name[sr@Latn]=Rečnik
+Name[sv]=Ordlista
+Name[ta]=அகராதி
+Name[tg]=Луғат
+Name[th]=พจนานุกรม
+Name[tr]=Sözlük
+Name[uk]=Словник
+Name[uz]=Lugʻat
+Name[uz@cyrillic]=Луғат
+Name[ven]=Bugu yau talutshedza maipfi
+Name[wa]=Motî
+Name[xh]=Incwadi eneenkcazelo zamagama
+Name[zh_CN]=字典
+Name[zh_HK]=字典
+Name[zh_TW]=字典
+Name[zu]=Isichazamagama
+Icon=kdict
+X-KDE-Library=kdict_panelapplet
+X-KDE-UniqueApplet=true
diff --git a/kdict/applet/kdictapplet.h b/kdict/applet/kdictapplet.h
new file mode 100644
index 00000000..a9738148
--- /dev/null
+++ b/kdict/applet/kdictapplet.h
@@ -0,0 +1,101 @@
+/* -------------------------------------------------------------
+
+ kdictapplet.h (part of The KDE Dictionary Client)
+
+ Copyright (C) 2001 Christian Gebauer
+
+ The applet is loosely based on the "Run" applet included in KDE.
+ Copyright (c) 2000 Matthias Elter (Artistic License)
+
+ This file is distributed under the Artistic License.
+ See LICENSE for details.
+
+ -------------------------------------------------------------
+
+ PopupBox helper class
+ DictApplet a small kicker-applet
+
+ ------------------------------------------------------------- */
+
+#ifndef _DICTAPPLET_H_
+#define _DICTAPPLET_H_
+
+#include
+#include
+
+class QLabel;
+class QPushButton;
+class KHistoryCombo;
+
+
+//********* PopupBox ********************************************
+
+class PopupBox : public QHBox
+{
+ Q_OBJECT
+
+public:
+ PopupBox();
+ ~PopupBox();
+
+ bool showBox();
+
+signals:
+ void hidden();
+
+public slots:
+ void enablePopup();
+
+protected:
+ void hideEvent(QHideEvent *);
+
+private:
+ bool popupEnabled;
+
+};
+
+//********* DictApplet ********************************************
+
+class DictApplet : public KPanelApplet
+{
+ Q_OBJECT
+
+public:
+ DictApplet(const QString& configFile, Type t = Stretch, int actions = 0, QWidget *parent = 0, const char *name = 0);
+ virtual ~DictApplet();
+
+ int widthForHeight(int height) const;
+ int heightForWidth(int width) const;
+
+protected:
+ void resizeEvent(QResizeEvent*);
+ bool eventFilter( QObject *, QEvent * );
+
+ void sendCommand(const QCString &fun, const QString &data);
+
+protected slots:
+ void sendDelayedCommand();
+ void startQuery(const QString&);
+ void comboTextChanged(const QString&);
+ void queryClipboard();
+ void startDefine();
+ void startMatch();
+ void showExternalCombo();
+ void externalComboHidden();
+ void updateCompletionMode(KGlobalSettings::Completion mode);
+
+private:
+ KHistoryCombo *internalCombo, *externalCombo;
+ KCompletion *completionObject;
+ QLabel *textLabel, *iconLabel;
+ QPushButton *verticalBtn, *clipboardBtn, *defineBtn, *matchBtn;
+ QWidget *baseWidget;
+ PopupBox *popupBox;
+
+ int waiting;
+ QCString delayedFunc;
+ QString delayedData;
+
+};
+
+#endif
diff --git a/kdict/application.cpp b/kdict/application.cpp
new file mode 100644
index 00000000..28e3a398
--- /dev/null
+++ b/kdict/application.cpp
@@ -0,0 +1,71 @@
+/* -------------------------------------------------------------
+
+ application.cpp (part of The KDE Dictionary Client)
+
+ Copyright (C) 2000-2001 Christian Gebauer
+
+ This file is distributed under the Artistic License.
+ See LICENSE for details.
+
+ ------------------------------------------------------------- */
+
+#include
+#include
+#include
+
+#include "application.h"
+#include "toplevel.h"
+
+
+Application::Application()
+ : KUniqueApplication()
+{
+ m_mainWindow = new TopLevel( 0, "mainWindow" );
+}
+
+
+Application::~Application()
+{
+ delete m_mainWindow;
+}
+
+
+int Application::newInstance()
+{
+ kdDebug(5004) << "Application::newInstance()" << endl;
+ KUniqueApplication::newInstance();
+
+ // process parameters...
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+
+ m_mainWindow->show();
+
+ if (args->isSet("clipboard"))
+ {
+ m_mainWindow->defineClipboard();
+ }
+ else
+ {
+ if (args->count()>0)
+ {
+ QString phrase;
+ for (int i=0;icount();i++)
+ {
+ phrase += QString::fromLocal8Bit(args->arg(i));
+ if (i+1 < args->count())
+ phrase += " ";
+ }
+ m_mainWindow->define(phrase);
+ }
+ else
+ {
+ m_mainWindow->normalStartup();
+ }
+ }
+
+ return 0;
+}
+
+//--------------------------------
+
+#include "application.moc"
diff --git a/kdict/application.h b/kdict/application.h
new file mode 100644
index 00000000..eddb7f44
--- /dev/null
+++ b/kdict/application.h
@@ -0,0 +1,39 @@
+/* -------------------------------------------------------------
+
+ application.h (part of The KDE Dictionary Client)
+
+ Copyright (C) 2000-2001 Christian Gebauer
+
+ This file is distributed under the Artistic License.
+ See LICENSE for details.
+
+ ------------------------------------------------------------- */
+
+#ifndef APPLICATION_H
+#define APPLICATION_H
+
+#include
+#include
+
+#define KDICT_VERSION "0.6"
+
+class TopLevel;
+
+class Application : public KUniqueApplication
+{
+ Q_OBJECT
+
+ public:
+ Application();
+ ~Application();
+
+ /** Create new instance of Kdict. Make the existing
+ main window active if Kdict is already running */
+ int newInstance();
+
+ private:
+ QGuardedPtr m_mainWindow;
+
+};
+
+#endif
diff --git a/kdict/dcopinterface.h b/kdict/dcopinterface.h
new file mode 100644
index 00000000..f088a842
--- /dev/null
+++ b/kdict/dcopinterface.h
@@ -0,0 +1,54 @@
+/* -------------------------------------------------------------
+
+ dcopinterface.h (part of The KDE Dictionary Client)
+ Copyright (C) 2000-2001 Christian Gebauer
+
+ This file is distributed under the Artistic License.
+ See LICENSE for details.
+
+ -------------------------------------------------------------
+
+ KDictDCOPInterface abstract base class that defines the
+ DCOP interface of Kdict
+
+ ------------------------------------------------------------- */
+
+#ifndef _DCOPINTERFACE_H
+#define _DCOPINTERFACE_H
+
+#include
+#include
+
+class KDictIface : virtual public DCOPObject
+{
+ K_DCOP
+
+k_dcop:
+
+ /** Quit Kdict **/
+ virtual void quit() = 0;
+ virtual void makeActiveWindow() = 0;
+
+ /** define/match a word/phrase **/
+ virtual void definePhrase(QString phrase) = 0;
+ virtual void matchPhrase(QString phrase) = 0;
+ virtual void defineClipboardContent() = 0;
+ virtual void matchClipboardContent() = 0;
+
+ /** get info **/
+ virtual QStringList getDatabases() = 0;
+ virtual QString currentDatabase() = 0;
+ virtual QStringList getStrategies() = 0;
+ virtual QString currentStrategy() = 0;
+
+ /** set current database/strategy (returns true on success) **/
+ virtual bool setDatabase(QString db) = 0;
+ virtual bool setStrategy(QString strategy) = 0;
+
+ /** navigate in history **/
+ virtual bool historyGoBack() = 0;
+ virtual bool historyGoForward() = 0;
+
+};
+
+#endif
diff --git a/kdict/dict.cpp b/kdict/dict.cpp
new file mode 100644
index 00000000..b36f1ac1
--- /dev/null
+++ b/kdict/dict.cpp
@@ -0,0 +1,1632 @@
+/* -------------------------------------------------------------
+
+ dict.cpp (part of The KDE Dictionary Client)
+
+ Copyright (C) 2000-2001 Christian Gebauer
+ (C) by Matthias Hlzer 1998
+
+ This file is distributed under the Artistic License.
+ See LICENSE for details.
+
+ -------------------------------------------------------------
+
+ JobData used for data transfer between Client and Interface
+ DictAsyncClient all network related stuff happens here in asynchrous thread
+ DictInterface interface for DictAsyncClient, job management
+
+ ------------------------------------------------------------- */
+
+#include
+
+#include "application.h"
+#include "options.h"
+#include "dict.h"
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+//********* JobData ******************************************
+
+
+JobData::JobData(QueryType Ntype,bool NnewServer,QString const& Nserver,int Nport,
+ int NidleHold, int Ntimeout, int NpipeSize, QString const& Nencoding, bool NAuthEnabled,
+ QString const& Nuser, QString const& Nsecret, unsigned int NheadLayout)
+ : type(Ntype), error(ErrNoErr), canceled(false), numFetched(0), newServer(NnewServer),server(Nserver), port(Nport),
+ timeout(Ntimeout), pipeSize(NpipeSize), idleHold(NidleHold), encoding(Nencoding), authEnabled(NAuthEnabled),
+ user(Nuser), secret(Nsecret), headLayout(NheadLayout)
+{}
+
+
+//********* DictAsyncClient *************************************
+
+DictAsyncClient::DictAsyncClient(int NfdPipeIn, int NfdPipeOut)
+: job(0L), inputSize(10000), fdPipeIn(NfdPipeIn),
+ fdPipeOut(NfdPipeOut), tcpSocket(-1), idleHold(0)
+{
+ input = new char[inputSize];
+}
+
+
+DictAsyncClient::~DictAsyncClient()
+{
+ if (-1!=tcpSocket)
+ doQuit();
+ delete [] input;
+}
+
+
+void* DictAsyncClient::startThread(void* pseudoThis)
+{
+ DictAsyncClient* newthis = (DictAsyncClient*) (pseudoThis);
+
+ if (0!=pthread_setcanceltype(PTHREAD_CANCEL_ENABLE,NULL))
+ qWarning("pthread_setcanceltype failed!");
+ if (0!= pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS,NULL))
+ qWarning("pthread_setcanceltype failed!");
+
+ signal(SIGPIPE,SIG_IGN); // ignore sigpipe
+
+ newthis->waitForWork();
+ return NULL;
+}
+
+
+void DictAsyncClient::insertJob(JobData *newJob)
+{
+ if (!job) // don't overwrite existing job pointer
+ job = newJob;
+}
+
+
+void DictAsyncClient::removeJob()
+{
+ job = 0L;
+}
+
+
+void DictAsyncClient::waitForWork()
+{
+ fd_set fdsR,fdsE;
+ timeval tv;
+ int selectRet;
+ char buf;
+
+ while (true) {
+ if (tcpSocket != -1) { // we are connected, hold the connection for xx secs
+ FD_ZERO(&fdsR);
+ FD_SET(fdPipeIn, &fdsR);
+ FD_SET(tcpSocket, &fdsR);
+ FD_ZERO(&fdsE);
+ FD_SET(tcpSocket, &fdsE);
+ tv.tv_sec = idleHold;
+ tv.tv_usec = 0;
+ selectRet = KSocks::self()->select(FD_SETSIZE, &fdsR, NULL, &fdsE, &tv);
+ if (selectRet == 0) {
+ doQuit(); // nothing happend...
+ } else {
+ if (((selectRet > 0)&&(!FD_ISSET(fdPipeIn,&fdsR)))||(selectRet == -1))
+ closeSocket();
+ }
+ }
+
+ do {
+ FD_ZERO(&fdsR);
+ FD_SET(fdPipeIn, &fdsR);
+ } while (select(FD_SETSIZE, &fdsR, NULL, NULL, NULL)<0); // don't get tricked by signals
+
+ clearPipe();
+
+ if (job) {
+ if ((tcpSocket!=-1)&&(job->newServer))
+ doQuit();
+
+ codec = QTextCodec::codecForName(job->encoding.latin1());
+ input[0] = 0; //terminate string
+ thisLine = input;
+ nextLine = input;
+ inputEnd = input;
+ timeout = job->timeout;
+ idleHold = job->idleHold;
+
+ if (tcpSocket==-1)
+ openConnection();
+
+ if (tcpSocket!=-1) { // connection is ready
+ switch (job->type) {
+ case JobData::TDefine :
+ define();
+ break;
+ case JobData::TGetDefinitions :
+ getDefinitions();
+ break;
+ case JobData::TMatch :
+ match();
+ break;
+ case JobData::TShowDatabases :
+ showDatabases();
+ break;
+ case JobData::TShowDbInfo :
+ showDbInfo();
+ break;
+ case JobData::TShowStrategies :
+ showStrategies();
+ break;
+ case JobData::TShowInfo :
+ showInfo();
+ break;
+ case JobData::TUpdate :
+ update();
+ }
+ }
+ clearPipe();
+ }
+ if (write(fdPipeOut,&buf,1) == -1) // emit stopped signal
+ ::perror( "waitForJobs()" );
+ }
+}
+
+
+void DictAsyncClient::define()
+{
+ QString command;
+
+ job->defines.clear();
+ QStringList::iterator it;
+ for (it = job->databases.begin(); it != job->databases.end(); ++it) {
+ command = "define ";
+ command += *it;
+ command += " \"";
+ command += job->query;
+ command += "\"\r\n";
+ job->defines.append(command);
+ }
+
+ if (!getDefinitions())
+ return;
+
+ if (job->numFetched == 0) {
+ job->strategy = ".";
+ if (!match())
+ return;
+ job->result = QString::null;
+ if (job->numFetched == 0) {
+ resultAppend("\n\n");
+ resultAppend(i18n("No definitions found for \'%1'.").arg(job->query));
+ resultAppend("
\n
\n\n");
+ resultAppend(i18n("No definitions found for \'%1\'. Perhaps you mean:").arg(job->query));
+ resultAppend("
\n\n");
+
+ QString lastDb;
+ QStringList::iterator it;
+ for (it = job->matches.begin(); it != job->matches.end(); ++it) {
+ int pos = (*it).find(' ');
+ if (pos != -1) {
+ if (lastDb != (*it).left(pos)) {
+ if (lastDb.length() > 0)
+ resultAppend("\n");
+ lastDb = (*it).left(pos);
+ resultAppend("");
+ resultAppend(lastDb);
+ resultAppend(": | ");
+ }
+ if ((*it).length() > (unsigned int)pos+2) {
+ resultAppend("");
+ resultAppend((*it).mid(pos+2, (*it).length()-pos-3));
+ resultAppend(" ");
+ }
+ }
+ }
+ resultAppend("\n |
\n