summaryrefslogtreecommitdiffstats
path: root/kdejava/koala/test
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit90825e2392b2d70e43c7a25b8a3752299a933894 (patch)
treee33aa27f02b74604afbfd0ea4f1cfca8833d882a /kdejava/koala/test
downloadtdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.tar.gz
tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.zip
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/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdejava/koala/test')
-rw-r--r--kdejava/koala/test/dcop/JavaDCOPObject.java45
-rw-r--r--kdejava/koala/test/dcop/README28
-rw-r--r--kdejava/koala/test/dcop/Test.java30
-rw-r--r--kdejava/koala/test/kbase/KBase.java596
-rw-r--r--kdejava/koala/test/kbase/KBaseDoc.java198
-rw-r--r--kdejava/koala/test/kbase/KBaseView.java36
-rw-r--r--kdejava/koala/test/kbase/kbase.desktop11
-rw-r--r--kdejava/koala/test/kbase/kbaseui.rc8
-rw-r--r--kdejava/koala/test/kblend/KBlendTest.java130
-rw-r--r--kdejava/koala/test/kblend/testimage.pngbin0 -> 35951 bytes
-rw-r--r--kdejava/koala/test/kcharselect/KCharSelectTest.java31
-rw-r--r--kdejava/koala/test/kcombobox/KComboBoxTest.java122
-rw-r--r--kdejava/koala/test/kdatepicker/KDatePickTest.java26
-rw-r--r--kdejava/koala/test/kfontdialog/KFontDialogTest.java164
-rw-r--r--kdejava/koala/test/khelpers/KHelpers.java103
-rw-r--r--kdejava/koala/test/khelpers/Main.java52
-rw-r--r--kdejava/koala/test/kioslave/KioslaveTest.java589
-rw-r--r--kdejava/koala/test/kmenu/KdeMenuSample.java142
-rw-r--r--kdejava/koala/test/kprogress/KProgressTest.java88
-rw-r--r--kdejava/koala/test/ksystemtray/Test.java28
-rw-r--r--kdejava/koala/test/simplebrowser/KSimpleBrowser.java65
-rw-r--r--kdejava/koala/test/simplebrowser/Main.java40
22 files changed, 2532 insertions, 0 deletions
diff --git a/kdejava/koala/test/dcop/JavaDCOPObject.java b/kdejava/koala/test/dcop/JavaDCOPObject.java
new file mode 100644
index 00000000..8b97efaa
--- /dev/null
+++ b/kdejava/koala/test/dcop/JavaDCOPObject.java
@@ -0,0 +1,45 @@
+import org.kde.koala.*;
+import org.kde.qt.*;
+import java.util.*;
+import java.io.*;
+
+public class JavaDCOPObject extends DCOPObject{
+ public JavaDCOPObject(){
+ super("JavaDCOPObject");
+ }
+ public ArrayList functions(){
+ ArrayList operations = new ArrayList();
+ operations.add("QString myOperation()");
+ return operations;
+ }
+ public ArrayList interfaces(){
+ ArrayList list = new ArrayList();
+ list.add("JavaDCOPObject");
+ return list;
+ }
+ public DCOPAnswer javaProcess( String fun, byte[] data){
+ DCOPAnswer answer = new DCOPAnswer();
+ try{
+ if("myOperation()".equals(fun)){
+ answer.setReplyType("QString");
+ answer.setSucces(true);
+
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ DataOutputStream os = new DataOutputStream(stream);
+ Marchaller.write_QString(os, this.myOperation());
+ answer.setReplyData(stream.toByteArray());
+ return answer;
+ } else{
+ return answer;
+ }
+ }catch(IOException ioe){
+ ioe.printStackTrace();
+ return answer;
+ }
+ }
+
+ public String myOperation(){
+ return "test from Java";
+ }
+
+}
diff --git a/kdejava/koala/test/dcop/README b/kdejava/koala/test/dcop/README
new file mode 100644
index 00000000..3143c6ea
--- /dev/null
+++ b/kdejava/koala/test/dcop/README
@@ -0,0 +1,28 @@
+This directory contains a test for using a DCOPObject written Java.
+
+The java DCOP object is in JavaDCOPObject.java
+The test app is in Test.java
+
+
+To test it, you should do the following:
+
+set your CLASSPATH (qtjava.jar & koala.jar)
+set your LD_LIBRARY_PATH (${KDEDIR}/lib
+
+compile it (javac *.java)
+$javac *.java
+
+run it
+$java Test
+
+open kdcop and look voor a program called "JavaTest"
+open it and the JavaDCOPObjet appears. The JavaDCOPObject contains one
+operation called myOperation. If you select it and run it, you should see 'test from Java'
+
+You can quit the java program by calling quit() on the application dcop object! (or just hit ctrl-c)
+
+
+Note that the JavaDCOPObject implements javaProcess(), interfaces() and functions().
+These should be generated, but for the timebeing this is done manually.
+
+
diff --git a/kdejava/koala/test/dcop/Test.java b/kdejava/koala/test/dcop/Test.java
new file mode 100644
index 00000000..1117bf87
--- /dev/null
+++ b/kdejava/koala/test/dcop/Test.java
@@ -0,0 +1,30 @@
+import org.kde.qt.*;
+import org.kde.koala.*;
+
+public class Test{
+ static String description = "DCOP test application for Java";
+
+
+ /**
+ * test the DCOP stuff.
+ *
+ * This test doesn't simply construct a DCOPClient, because
+ * dcop needs the eventloop (app.exec())
+ */
+ public static void main(String[] argv){
+ KAboutData aboutData = new KAboutData( "test", "Test",
+ "0.1", description, KAboutData.License_GPL,
+ "(C) 2002 Gert-Jan van der Heiden");
+ KCmdLineArgs.init( argv, aboutData );
+
+ KApplication app = new KApplication();
+ app.dcopClient().registerAs("JavaTest", false);
+ JavaDCOPObject object = new JavaDCOPObject();
+ app.exec();
+ }
+
+ static{
+ qtjava.initialize();
+ kdejava.initialize();
+ }
+}
diff --git a/kdejava/koala/test/kbase/KBase.java b/kdejava/koala/test/kbase/KBase.java
new file mode 100644
index 00000000..abbf784c
--- /dev/null
+++ b/kdejava/koala/test/kbase/KBase.java
@@ -0,0 +1,596 @@
+import java.util.*;
+
+import org.kde.qt.*;
+import org.kde.koala.*;
+
+/**
+ * The base class for JavaApiTest application windows. It sets up the main
+ * window and reads the config file as well as providing a menubar, toolbar
+ * and statusbar. An instance of KBaseView creates your center view, which is connected
+ * to the window's Doc object.
+ * KBase reimplements the methods that KMainWindow provides for main window handling and supports
+ * full session management as well as using KActions.
+ * @see KMainWindow
+ * @see KApplication
+ * @see KConfig
+ *
+ * @author Source Framework Automatically Generated by KDevelop, (c) The KDevelop Team.
+ * @version KDevelop version 1.2 code generation
+ */
+public class KBase extends KMainWindow
+{
+ public static final int ID_STATUS_MSG = 1;
+
+ /** the configuration object of the application */
+ private KConfig config;
+ /** view is the main widget which represents your working area. The View
+ * class should handle all events of the view widget. It is kept empty so
+ * you can create your view according to your application's needs by
+ * changing the view class.
+ */
+ private KBaseView view;
+ /** doc represents your actual document and is created only once. It keeps
+ * information such as filename and does the serialization of your files.
+ */
+ private KBaseDoc doc;
+
+ // KAction references to enable/disable actions
+ private KAction fileNewWindow;
+ private KAction fileNew;
+ private KAction fileOpen;
+ private KRecentFilesAction fileOpenRecent;
+ private KAction fileSave;
+ private KAction fileSaveAs;
+ private KAction fileClose;
+ private KAction filePrint;
+ private KAction fileQuit;
+ private KAction editCut;
+ private KAction editCopy;
+ private KAction editPaste;
+ private KToggleAction viewToolBar;
+ private KToggleAction viewStatusBar;
+
+ /** construtor of KBase, calls all init functions to create the application.
+ */
+public KBase(QWidget parent, String name)
+{
+ super(parent, name, 0);
+ KApplication kapp = KApplication.kApplication();
+ config=kapp.config();
+
+ ///////////////////////////////////////////////////////////////////
+ // call inits to invoke all other construction parts
+ initStatusBar();
+ initActions();
+ initDocument();
+ initView();
+
+ readOptions();
+
+ ///////////////////////////////////////////////////////////////////
+ // disable actions at startup
+ fileSave.setEnabled(false);
+ fileSaveAs.setEnabled(false);
+ filePrint.setEnabled(false);
+ editCut.setEnabled(false);
+ editCopy.setEnabled(false);
+ }
+
+public KBase()
+{
+ this(null, null);
+}
+
+ /** initializes the KActions of the application */
+protected void initActions()
+{
+ fileNewWindow = new KAction(tr("New &Window"), "", new KShortcut(), this, SLOT("slotFileNewWindow()"), actionCollection(),"file_new_window");
+ fileNew = KStdAction.openNew(this, SLOT("slotFileNew()"), actionCollection());
+ fileOpen = KStdAction.open(this, SLOT("slotFileOpen()"), actionCollection());
+ fileOpenRecent = (KRecentFilesAction) KStdAction.openRecent(this, SLOT("slotFileOpenRecent(KURL)"), actionCollection());
+ fileSave = KStdAction.save(this, SLOT("slotFileSave()"), actionCollection());
+ fileSaveAs = KStdAction.saveAs(this, SLOT("slotFileSaveAs()"), actionCollection());
+ // this one crashes for me...
+// fileClose = KStdAction.close(this, SLOT(slotFileClose()), actionCollection());
+ filePrint = KStdAction.print(this, SLOT("slotFilePrint()"), actionCollection());
+ fileQuit = KStdAction.quit(this, SLOT("slotFileQuit()"), actionCollection());
+ editCut = KStdAction.cut(this, SLOT("slotEditCut()"), actionCollection());
+ editCopy = KStdAction.copy(this, SLOT("slotEditCopy()"), actionCollection());
+ editPaste = KStdAction.paste(this, SLOT("slotEditPaste()"), actionCollection());
+ createStandardStatusBarAction();
+// viewToolBar = KStdAction.showToolbar(this, SLOT("slotViewToolBar()"), actionCollection());
+ viewStatusBar = KStdAction.showStatusbar(this, SLOT("slotViewStatusBar()"), actionCollection());
+
+ fileNewWindow.setToolTip(tr("Opens a new application window"));
+ fileNew.setToolTip(tr("Creates a new document"));
+ fileOpen.setToolTip(tr("Opens an existing document"));
+ fileOpenRecent.setToolTip(tr("Opens a recently used file"));
+ fileSave.setToolTip(tr("Saves the actual document"));
+ fileSaveAs.setToolTip(tr("Saves the actual document as..."));
+// fileClose.setToolTip(tr("Closes the actual document"));
+ filePrint .setToolTip(tr("Prints out the actual document"));
+ fileQuit.setToolTip(tr("Quits the application"));
+ editCut.setToolTip(tr("Cuts the selected section and puts it to the clipboard"));
+ editCopy.setToolTip(tr("Copies the selected section to the clipboard"));
+ editPaste.setToolTip(tr("Pastes the clipboard contents to actual position"));
+// viewToolBar.setToolTip(tr("Enables/disables the toolbar"));
+ viewStatusBar.setToolTip(tr("Enables/disables the statusbar"));
+
+ // use the absolute path to your kbaseui.rc file for testing purpose in createGUI();
+ createGUI();
+
+}
+
+
+
+ /** sets up the kstatusBar for the main window by initialzing a statuslabel.
+ */
+protected void initStatusBar()
+{
+ ///////////////////////////////////////////////////////////////////
+ // STATUSBAR
+ // TODO: add your own items you need for displaying current application status.
+ kstatusBar().insertItem(tr("Ready."), ID_STATUS_MSG);
+}
+
+ /** initializes the document object of the main window that is connected to the view in initView().
+ * @see initView();
+ */
+public void initDocument()
+{
+ doc = new KBaseDoc(this, null);
+ doc.newDocument();
+}
+
+ /** creates the centerwidget of the KTMainWindow instance and sets it as the view
+ */
+protected void initView()
+{
+ ////////////////////////////////////////////////////////////////////
+ // create the main widget here that is managed by KTMainWindow's view-region and
+ // connect the widget to your document to display document contents.
+
+ view = new KBaseView(this, null);
+ doc.addView(view);
+ setCentralWidget(view);
+ setCaption(doc.URL().fileName(),false);
+
+}
+
+ /** opens a file specified by commandline option
+ */
+public void openDocumentFile(KURL url)
+{
+ slotStatusMsg(tr("Opening file..."));
+
+// doc.openDocument( url);
+ fileOpenRecent.addURL( url );
+ slotStatusMsg(tr("Ready."));
+}
+
+public void openDocumentFile()
+{
+ openDocumentFile(new KURL(""));
+ return;
+}
+
+
+ /** returns a pointer to the current document connected to the KTMainWindow instance and is used by
+ * the View class to access the document object's methods
+ */
+public KBaseDoc getDocument()
+{
+ return doc;
+}
+
+ /** save general Options like all bar positions and status as well as the geometry and the recent file list to the configuration
+ * file
+ */
+protected void saveOptions()
+{
+ config.setGroup("General Options");
+ config.writeEntry("Geometry", size());
+// config.writeEntry("Show Toolbar", viewToolBar.isChecked());
+ config.writeEntry("Show Statusbar",viewStatusBar.isChecked());
+// config.writeEntry("ToolBarPos", (int) toolBar("mainToolBar").barPos());
+ fileOpenRecent.saveEntries(config,"Recent Files");
+}
+
+
+ /** read general Options again and initialize all variables like the recent file list
+ */
+protected void readOptions()
+{
+
+ config.setGroup("General Options");
+
+ // bar status settings
+// boolean bViewToolbar = config.readBoolEntry("Show Toolbar", true);
+// viewToolBar.setChecked(bViewToolbar);
+// slotViewToolBar();
+
+ boolean bViewStatusbar = config.readBoolEntry("Show Statusbar", true);
+ viewStatusBar.setChecked(bViewStatusbar);
+ slotViewStatusBar();
+
+
+ // bar position settings
+// int toolBarPos;
+ //Pos=(int) config.readNumEntry("ToolBarPos", KToolBar.Top);
+// toolBar("mainToolBar").setBarPos(toolBarPos);
+
+ // initialize the recent file list
+ fileOpenRecent.loadEntries(config,"Recent Files");
+
+ QSize size=config.readSizeEntry("Geometry", null);
+ if(!size.isEmpty())
+ {
+ resize(size);
+ }
+}
+
+ /** saves the window properties for each open window during session end to the session config file, including saving the currently
+ * opened file by a temporary filename provided by KApplication.
+ * @see KTMainWindow#saveProperties
+ */
+protected void saveProperties(KConfig _cfg)
+{
+ if(doc.URL().fileName()!=tr("Untitled") && !doc.isModified())
+ {
+ // saving to tempfile not necessary
+
+ }
+ else
+ {
+ KURL url=doc.URL();
+ _cfg.writeEntry("filename", url.url());
+ _cfg.writeEntry("modified", doc.isModified());
+ String tempname = KApplication.kApplication().tempSaveName(url.url());
+ String tempurl= KURL.encode_string(tempname, 0);
+ KURL _url = new KURL(tempurl);
+ doc.saveDocument(_url);
+ }
+}
+
+
+ /** reads the session config file and restores the application's state including the last opened files and documents by reading the
+ * temporary files saved by saveProperties()
+ * @see KTMainWindow#readProperties
+ */
+protected void readProperties(KConfig _cfg)
+{
+ String filename = _cfg.readEntry("filename", "");
+ KURL url = new KURL(filename);
+ boolean modified = _cfg.readBoolEntry("modified", false);
+ if(modified)
+ {
+ boolean canRecover = false;
+ String tempname = KApplication.kApplication().checkRecoverFile(filename, canRecover);
+ KURL _url = new KURL(tempname);
+
+ if(canRecover)
+ {
+ doc.openDocument(_url);
+ doc.setModified();
+ setCaption(_url.fileName(),true);
+ QFile.remove(tempname);
+ }
+ }
+ else
+ {
+ if(filename.length() > 0)
+ {
+ doc.openDocument(url);
+ setCaption(url.fileName(),false);
+ }
+ }
+}
+
+ /** queryClose is called by KTMainWindow on each closeEvent of a window. Against the
+ * default implementation (only returns true), this calles saveModified() on the document object to ask if the document shall
+ * be saved if Modified; on cancel the closeEvent is rejected.
+ * @see KTMainWindow#queryClose
+ * @see KTMainWindow#closeEvent
+ */
+protected boolean queryClose()
+{
+ return doc.saveModified();
+}
+
+ /** queryExit is called by KTMainWindow when the last window of the application is going to be closed during the closeEvent().
+ * Against the default implementation that just returns true, this calls saveOptions() to save the settings of the last window's
+ * properties.
+ * @see KTMainWindow#queryExit
+ * @see KTMainWindow#closeEvent
+ */
+protected boolean queryExit()
+{
+ saveOptions();
+ return true;
+}
+
+/////////////////////////////////////////////////////////////////////
+// SLOT IMPLEMENTATION
+/////////////////////////////////////////////////////////////////////
+
+ /** open a new application window by creating a new instance of KBase */
+public void slotFileNewWindow()
+{
+ slotStatusMsg(tr("Opening a new application window..."));
+
+ KBase new_window= new KBase();
+ new_window.show();
+
+ slotStatusMsg(tr("Ready."));
+}
+
+ /** clears the document in the actual view to reuse it as the new document */
+public void slotFileNew()
+{
+ slotStatusMsg(tr("Creating new document..."));
+
+ if(!doc.saveModified())
+ {
+ // here saving wasn't successful
+
+ }
+ else
+ {
+ doc.newDocument();
+ setCaption(doc.URL().fileName(), false);
+ }
+
+ slotStatusMsg(tr("Ready."));
+}
+
+ /** open a file and load it into the document*/
+public void slotFileOpen()
+{
+System.out.println("ENTER slotFileOpen()");
+ slotStatusMsg(tr("Opening file..."));
+
+ if(!doc.saveModified())
+ {
+ // here saving wasn't successful
+
+ }
+ else
+ {
+ KURL url=KFileDialog.getOpenURL("",
+ tr("*|All files"), this, tr("Open File..."));
+ if(!url.isEmpty())
+ {
+ doc.openDocument(url);
+ setCaption(url.fileName(), false);
+ fileOpenRecent.addURL( url );
+ }
+ }
+ slotStatusMsg(tr("Ready."));
+}
+
+ /** opens a file from the recent files menu */
+public void slotFileOpenRecent(KURL url)
+{
+ slotStatusMsg(tr("Opening file..."));
+
+ if(!doc.saveModified())
+ {
+ // here saving wasn't successful
+ }
+ else
+ {
+ doc.openDocument(url);
+ setCaption(url.fileName(), false);
+ }
+
+ slotStatusMsg(tr("Ready."));
+}
+
+ /** save a document */
+public void slotFileSave()
+{
+ slotStatusMsg(tr("Saving file..."));
+
+ doc.saveDocument(doc.URL());
+
+ slotStatusMsg(tr("Ready."));
+}
+
+ /** save a document by a new filename*/
+public void slotFileSaveAs()
+{
+ slotStatusMsg(tr("Saving file with a new filename..."));
+
+ KURL url=KFileDialog.getSaveURL(QDir.currentDirPath(),
+ tr("*|All files"), this, tr("Save as..."));
+ if(!url.isEmpty())
+ {
+ doc.saveDocument(url);
+ fileOpenRecent.addURL(url);
+ setCaption(url.fileName(),doc.isModified());
+ }
+
+ slotStatusMsg(tr("Ready."));
+}
+
+ /** asks for saving if the file is modified, then closes the actual file and window*/
+public void slotFileClose()
+{
+ slotStatusMsg(tr("Closing file..."));
+
+ close();
+
+ slotStatusMsg(tr("Ready."));
+}
+
+ /** print the actual file */
+public void slotFilePrint()
+{
+ slotStatusMsg(tr("Printing..."));
+
+ QPrinter printer = new QPrinter();
+ if (printer.setup(this))
+ {
+ view.print(printer);
+ }
+
+ slotStatusMsg(tr("Ready."));
+}
+
+ /** closes all open windows by calling close() on each memberList item until the list is empty, then quits the application.
+ * If queryClose() returns false because the user canceled the saveModified() dialog, the closing breaks.
+ */
+public void slotFileQuit()
+{
+ slotStatusMsg(tr("Exiting..."));
+ saveOptions();
+ // close the first window, the list makes the next one the first again.
+ // This ensures that queryClose() is called on each window to ask for closing
+ KMainWindow w;
+ Iterator it = memberList().iterator();
+ while(it.hasNext())
+ {
+ w=(KMainWindow)it.next();
+ // only close the window if the closeEvent is accepted. If the user presses Cancel on the saveModified() dialog,
+ // the window and the application stay open.
+ if(!w.close())
+ break;
+ }
+
+ slotStatusMsg(tr("Ready."));
+}
+
+ /** put the marked text/object into the clipboard and remove
+ * it from the document
+ */
+public void slotEditCut()
+{
+ slotStatusMsg(tr("Cutting selection..."));
+
+ slotStatusMsg(tr("Ready."));
+}
+
+ /** put the marked text/object into the clipboard
+ */
+public void slotEditCopy()
+{
+ slotStatusMsg(tr("Copying selection to clipboard..."));
+
+ slotStatusMsg(tr("Ready."));
+}
+
+ /** paste the clipboard into the document
+ */
+public void slotEditPaste()
+{
+ slotStatusMsg(tr("Inserting clipboard contents..."));
+
+ slotStatusMsg(tr("Ready."));
+}
+
+ /** toggles the toolbar
+ */
+public void slotViewToolBar()
+{
+ slotStatusMsg(tr("Toggling toolbar..."));
+ ///////////////////////////////////////////////////////////////////
+ // turn Toolbar on or off
+// if(!viewToolBar.isChecked())
+// {
+// toolBar("mainToolBar").hide();
+// }
+// else
+// {
+// toolBar("mainToolBar").show();
+// }
+
+ slotStatusMsg(tr("Ready."));
+}
+
+ /** toggles the statusbar
+ */
+public void slotViewStatusBar()
+{
+ slotStatusMsg(tr("Toggle the statusbar..."));
+ ///////////////////////////////////////////////////////////////////
+ //turn Statusbar on or off
+ if(!viewStatusBar.isChecked())
+ {
+ kstatusBar().hide();
+ }
+ else
+ {
+ kstatusBar().show();
+ }
+
+ slotStatusMsg(tr("Ready."));
+}
+
+
+ /** changes the statusbar contents for the standard label permanently, used to indicate current actions.
+ * @param text the text that is displayed in the statusbar
+ */
+public void slotStatusMsg(String text)
+{
+ ///////////////////////////////////////////////////////////////////
+ // change status message permanently
+ kstatusBar().clear();
+ kstatusBar().changeItem(text, ID_STATUS_MSG);
+}
+
+static String description =
+ "JavaApiTest";
+// INSERT A DESCRIPTION FOR YOUR APPLICATION HERE
+
+
+static String[][] options =
+{
+ { "+[File]", "file to open", null }
+ // INSERT YOUR COMMANDLINE OPTIONS HERE
+};
+
+static String VERSION = "0.1";
+
+public static void main(String[] cmdLineArgs)
+{
+
+ KAboutData aboutData = new KAboutData( "kbase", "JavaApiTest",
+ VERSION, description, KAboutData.License_GPL,
+ "(c) 2001, Richard Dale");
+ aboutData.addAuthor("Richard Dale",null, "Lost_Highway@tipitina.demon.co.uk");
+ KCmdLineArgs.init( cmdLineArgs, aboutData );
+ KCmdLineArgs.addCmdLineOptions( options ); // Add our own options.
+
+ KApplication app = new KApplication();
+
+ if (app.isRestored())
+ {
+ RESTORE("KBase");
+ }
+ else
+ {
+ KBase kbase = new KBase();
+ kbase.show();
+ KCmdLineArgs args = KCmdLineArgs.parsedArgs();
+
+ if (args.count() > 0)
+ {
+ kbase.openDocumentFile(new KURL(args.arg(0)));
+ }
+ else
+ {
+ kbase.openDocumentFile();
+ }
+ args.clear();
+ }
+
+ app.exec();
+ return;
+}
+
+ static {
+ qtjava.initialize();
+ kdejava.initialize();
+ }
+
+}
diff --git a/kdejava/koala/test/kbase/KBaseDoc.java b/kdejava/koala/test/kbase/KBaseDoc.java
new file mode 100644
index 00000000..0ee4f8f3
--- /dev/null
+++ b/kdejava/koala/test/kbase/KBaseDoc.java
@@ -0,0 +1,198 @@
+import java.util.*;
+
+import org.kde.qt.*;
+import org.kde.koala.*;
+
+/** KBaseDoc provides a document object for a document-view model.
+ *
+ * The KBaseDoc class provides a document object that can be used in conjunction with the classes JavaApiTestApp and KBaseView
+ * to create a document-view model for standard KDE applications based on KApplication and KMainWindow. Thereby, the document object
+ * is created by the JavaApiTestApp instance and contains the document structure with the according methods for manipulation of the document
+ * data by KBaseView objects. Also, KBaseDoc contains the methods for serialization of the document data from and to files.
+ *
+ * @author Source Framework Automatically Generated by KDevelop, (c) The KDevelop Team.
+ * @version KDevelop version 1.2 code generation
+ */
+public class KBaseDoc extends QObject {
+
+ /** the list of the views currently connected to the document */
+ public ArrayList pViewList;
+
+ /** the modified flag of the current document */
+ private boolean modified;
+ private KURL doc_url;
+
+ /** Constructor for the fileclass of the application */
+public KBaseDoc(QWidget parent, String name)
+{
+ super(parent, name);
+ setURL(new KURL());
+
+ if(pViewList == null)
+ {
+ pViewList = new ArrayList();
+ }
+
+// pViewList.setAutoDelete(true);
+}
+
+ /** adds a view to the document which represents the document contents. Usually this is your main view. */
+public void addView(KBaseView view)
+{
+ pViewList.add(view);
+}
+
+ /** removes a view from the list of currently connected views */
+public void removeView(KBaseView view)
+{
+ pViewList.remove(view);
+}
+
+ /** sets the modified flag for the document after a modifying action on the view connected to the document.*/
+public void setModified(boolean _m){ modified=_m; }
+public void setModified(){ modified=true; }
+
+ /** returns if the document is modified or not. Use this to determine if your document needs saving by the user on closing.*/
+public boolean isModified(){ return modified; }
+
+ /** sets the URL of the document */
+public void setURL(KURL url)
+{
+ doc_url=url;
+}
+
+ /** returns the KURL of the document */
+public KURL URL()
+{
+ return doc_url;
+}
+
+ /** calls repaint() on all views connected to the document object and is called by the view by which the document has been changed.
+ * As this view normally repaints itself, it is excluded from the paintEvent.
+ */
+public void slotUpdateAllViews(KBaseView sender)
+{
+ KBaseView w;
+ if(pViewList != null)
+ {
+ Iterator it = pViewList.iterator();
+ while(it.hasNext())
+ {
+ w=(KBaseView)it.next();
+ if(w!=sender)
+ w.repaint();
+ }
+ }
+
+}
+
+ /** "save modified" - asks the user for saving if the document is modified */
+public boolean saveModified()
+{
+ boolean completed=true;
+
+ if(modified)
+ {
+ KBase win=(KBase ) parent();
+ int want_save = KMessageBox.warningYesNoCancel(win, tr("Warning"),
+ tr("The current file has been modified.\n"
+ + "Do you want to save it?"));
+ switch(want_save)
+ {
+ case 1:
+ if (doc_url.fileName() == tr("Untitled"))
+ {
+ win.slotFileSaveAs();
+ }
+ else
+ {
+ saveDocument(URL());
+ };
+
+ deleteContents();
+ completed=true;
+ break;
+
+ case 2:
+ setModified(false);
+ deleteContents();
+ completed=true;
+ break;
+
+ case 3:
+ completed=false;
+ break;
+
+ default:
+ completed=false;
+ break;
+ }
+ }
+
+ return completed;
+}
+
+ /** closes the acutal document */
+public void closeDocument()
+{
+ deleteContents();
+}
+
+ /** initializes the document generally */
+public boolean newDocument()
+{
+ /////////////////////////////////////////////////
+ // TODO: Add your document initialization code here
+ /////////////////////////////////////////////////
+ modified=false;
+ doc_url.setFileName(tr("Untitled"));
+
+ return true;
+}
+
+ /** loads the document by filename and format and emits the updateViews() signal */
+public boolean openDocument(KURL url, String format)
+{
+ StringBuffer tmpfile = new StringBuffer("");
+ NetAccess.download( url, tmpfile, null );
+ /////////////////////////////////////////////////
+ // TODO: Add your document opening code here
+ /////////////////////////////////////////////////
+
+ NetAccess.removeTempFile( tmpfile.toString() );
+
+ modified=false;
+ return true;
+}
+
+public boolean openDocument(KURL url)
+{
+ return openDocument(url, null);
+}
+
+ /** saves the document under filename and format.*/
+public boolean saveDocument(KURL url, String format)
+{
+ /////////////////////////////////////////////////
+ // TODO: Add your document saving code here
+ /////////////////////////////////////////////////
+
+ modified=false;
+ return true;
+}
+
+public boolean saveDocument(KURL url)
+{
+ return saveDocument(url, null);
+}
+
+ /** deletes the document's contents */
+public void deleteContents()
+{
+ /////////////////////////////////////////////////
+ // TODO: Add implementation to delete the document contents
+ /////////////////////////////////////////////////
+
+}
+
+}
diff --git a/kdejava/koala/test/kbase/KBaseView.java b/kdejava/koala/test/kbase/KBaseView.java
new file mode 100644
index 00000000..2b745b11
--- /dev/null
+++ b/kdejava/koala/test/kbase/KBaseView.java
@@ -0,0 +1,36 @@
+import org.kde.qt.*;
+
+/** The KBaseView class provides the view widget for the KBase instance.
+ * The View instance inherits QWidget as a base class and represents the view object of a KTMainWindow. As KBaseView is part of the
+ * docuement-view model, it needs a reference to the document object connected with it by the KBase class to manipulate and display
+ * the document structure provided by the KBaseDoc class.
+ *
+ * @author Source Framework Automatically Generated by KDevelop, (c) The KDevelop Team.
+ * @version KDevelop version 0.4 code generation
+ */
+public class KBaseView extends QWidget {
+
+public KBaseView(QWidget parent, String name)
+{
+ super(parent, name);
+ setBackgroundMode(PaletteBase);
+}
+
+public KBaseDoc getDocument()
+{
+ KBase theApp=(KBase) parentWidget();
+
+ return theApp.getDocument();
+}
+
+public void print(QPrinter pPrinter)
+{
+ QPainter printpainter = new QPainter();
+ printpainter.begin(pPrinter);
+
+ // TODO: add your printing code here
+
+ printpainter.end();
+}
+
+}
diff --git a/kdejava/koala/test/kbase/kbase.desktop b/kdejava/koala/test/kbase/kbase.desktop
new file mode 100644
index 00000000..635ae553
--- /dev/null
+++ b/kdejava/koala/test/kbase/kbase.desktop
@@ -0,0 +1,11 @@
+# KDE Config File
+[Desktop Entry]
+Type=Application
+Exec=java -cp ".:/home/duke/src/qt-2.2.1java/javalib:.." KBase KBase -caption "%c" %i %m
+Icon=kbase.xpm
+DocPath=kbase/index.html
+Comment=
+Comment[de]=
+Terminal=false
+Name=KBase
+Name[de]=KBase
diff --git a/kdejava/koala/test/kbase/kbaseui.rc b/kdejava/koala/test/kbase/kbaseui.rc
new file mode 100644
index 00000000..03958feb
--- /dev/null
+++ b/kdejava/koala/test/kbase/kbaseui.rc
@@ -0,0 +1,8 @@
+<!DOCTYPE kpartgui>
+<kpartgui name="kbase" version="0.1">
+<MenuBar>
+ <Menu name="file"><text>&amp;File</text>
+ <Action name="file_new_window"/>
+ </Menu>
+</MenuBar>
+</kpartgui>
diff --git a/kdejava/koala/test/kblend/KBlendTest.java b/kdejava/koala/test/kblend/KBlendTest.java
new file mode 100644
index 00000000..6e4e4109
--- /dev/null
+++ b/kdejava/koala/test/kblend/KBlendTest.java
@@ -0,0 +1,130 @@
+import org.kde.qt.*;
+import org.kde.koala.*;
+
+//
+// Simple little hack to show off blending effects.
+//
+// (C) KDE Artistic Cristian Tibirna <tibirna@kde.org>
+//
+
+/**
+ * Class to test KImageEffect blending effects.
+ *
+ * This is a translation to java from kblendtest.cpp in the tests library
+ * of kdeui source.
+ *
+ * @see KApplication
+ * @see KImageEffect
+ *
+ * @author Cristian Tibirna <tibirna@kde.org>, java translation Kenneth J. Pouncey, kjpou@hotmail.com
+ * @version 0.1
+ */
+
+public class KBlendTest {
+
+ public static void main(String[] args) {
+ KCmdLineArgs.init(args, "kblendtest", "KBlendTest", "It blends!", "0.1");
+ KApplication app = new KApplication();
+ KBlendWidget w = new KBlendWidget(null,"KBlendTest");
+ w.setCaption(app.name());
+ app.setMainWidget(w);
+ w.show();
+ app.exec();
+ return;
+ }
+
+
+ public static class KBlendWidget extends QWidget {
+
+ QImage image;
+ QColor bgnd;
+
+ String testImage = "testimage.png";
+
+ public KBlendWidget (QWidget parent, String name) {
+
+ // change the colors to see the effects.
+// bgnd = new QColor(QColor.qRgb(255, 255, 255));
+ bgnd = Qt.blue();
+// bgnd = Qt.red();
+
+ image = new QImage(testImage);
+
+ resize(image.width()*2+60, image.height()*3+80);
+ setBackgroundColor(bgnd);
+ }
+
+ protected void paintEvent(QPaintEvent pe ) {
+
+ long it, ft;
+ String say = "";
+
+ image = new QImage(testImage);
+
+ QPainter p = new QPainter(this);
+
+ p.setPen(Qt.black());
+
+ // you see here use of anti_dir param (blend from down to up, here)
+ it = System.currentTimeMillis();
+ KImageEffect.blend(image, 0.2f, bgnd, KImageEffect.VerticalGradient,true);
+ ft = System.currentTimeMillis();
+ say = (ft - it) + " ms, Vertical";
+ p.drawImage(20, 20, image);
+ p.drawText(5 , 15, say);
+
+ image = new QImage(testImage);
+
+ // here a negative initial intensity is used (1/2 of image is unaffected)
+ it = System.currentTimeMillis();
+ KImageEffect.blend(image, -0.5f, bgnd, KImageEffect.HorizontalGradient);
+ ft = System.currentTimeMillis();
+ say = (ft - it) + " ms, Horizontal";
+ p.drawImage(40+image.width(), 20, image);
+ p.drawText(15+image.width() , 15, say);
+
+ image = new QImage(testImage);
+
+ it = System.currentTimeMillis();
+ KImageEffect.blend(image, 0.0f, bgnd, KImageEffect.DiagonalGradient,true);
+ ft = System.currentTimeMillis();
+ say = (ft - it) + " ms, Diagonal";
+ p.drawImage(20, 40+image.height(), image);
+ p.drawText(5 , 35+image.height(), say);
+
+ image = new QImage(testImage);
+
+ it = System.currentTimeMillis();
+ KImageEffect.blend(image, 0.1f, bgnd, KImageEffect.CrossDiagonalGradient);
+ ft = System.currentTimeMillis();
+ say = (ft - it) + " ms, CrossDiagonal";
+ p.drawImage(40+image.width(), 40+image.height(), image);
+ p.drawText(25+image.width() , 35 + image.height(), say);
+
+ image = new QImage(testImage);
+
+ it = System.currentTimeMillis();
+ KImageEffect.blend(image, -0.6f, bgnd, KImageEffect.RectangleGradient);
+ ft = System.currentTimeMillis();
+ say = (ft - it) + " ms, Rectangle";
+ p.drawImage(20, 60+2*image.height(), image);
+ p.drawText(5 , 55+2*image.height(), say);
+
+ image = new QImage(testImage);
+
+ it = System.currentTimeMillis();
+ KImageEffect.blend(image, 0.2f, bgnd, KImageEffect.EllipticGradient);
+ ft = System.currentTimeMillis();
+ say = (ft - it) + " ms, Elliptic";
+ p.drawImage(40+image.width(), 60+2*image.height(), image);
+ p.drawText(25+image.width(), 55+2*image.height(), say);
+ p.end();
+ }
+ }
+
+ static {
+ qtjava.initialize();
+ kdejava.initialize();
+ }
+
+}
diff --git a/kdejava/koala/test/kblend/testimage.png b/kdejava/koala/test/kblend/testimage.png
new file mode 100644
index 00000000..2f591d8e
--- /dev/null
+++ b/kdejava/koala/test/kblend/testimage.png
Binary files differ
diff --git a/kdejava/koala/test/kcharselect/KCharSelectTest.java b/kdejava/koala/test/kcharselect/KCharSelectTest.java
new file mode 100644
index 00000000..c994fb78
--- /dev/null
+++ b/kdejava/koala/test/kcharselect/KCharSelectTest.java
@@ -0,0 +1,31 @@
+import org.kde.qt.*;
+import org.kde.koala.*;
+
+/**
+ *
+ * Taken from test program of the kdeui tests
+ **/
+public class KCharSelectTest {
+
+
+ public static void main (String[] args) {
+
+ KCmdLineArgs.init(args, "kcharselecttest", "KCharSelectTest",
+ "A KCharSelect test app", "0.1");
+ KApplication app = new KApplication();
+ KCharSelect selector = new KCharSelect(null,"char selector");
+ selector.resize( selector.sizeHint() );
+ app.setMainWidget(selector);
+ selector.show();
+ selector.setCaption( "KCharSelect Test");
+ app.exec();
+ return;
+
+ }
+
+ static {
+ qtjava.initialize();
+ kdejava.initialize();
+ }
+
+}
diff --git a/kdejava/koala/test/kcombobox/KComboBoxTest.java b/kdejava/koala/test/kcombobox/KComboBoxTest.java
new file mode 100644
index 00000000..b2dd9a2f
--- /dev/null
+++ b/kdejava/koala/test/kcombobox/KComboBoxTest.java
@@ -0,0 +1,122 @@
+import java.util.*;
+
+ import org.kde.qt.*;
+ import org.kde.koala.*;
+
+ /**
+ * Class to text KComboBox widgets.
+ *
+ * This is a translation to java from kcomboboxtest.cpp in the tests library
+ * of kdeui source.
+ *
+ * Combo boxes tested
+ * - Editable ComboBox
+ * - Select Only ComboBox
+ * @see KComboBox
+ * @see KApplication
+ * @see KConfig
+ *
+ * @author original author unknown, java translation Kenneth J. Pouncey,
+ kjpou@hotmail.com
+ * @version 0.1
+ */
+ public class KComboBoxTest {
+
+ static String description = "Java KComboBox test program.";
+ static String[][] options = { };
+ static String VERSION = "0.1";
+
+ public static void main(String[] cmdLineArgs) {
+
+ KAboutData aboutData = new KAboutData( "kcomboboxtest", "KComboBoxTest",
+ VERSION, description, KAboutData.License_GPL,
+ "(c) 2002, Kenneth J. Pouncey");
+ aboutData.addAuthor("Kenneth J. Pouncey",null, "kjpou@hotmail.com");
+ KCmdLineArgs.init( cmdLineArgs, aboutData );
+ KCmdLineArgs.addCmdLineOptions( options ); // Add our own options.
+
+ KApplication app = new KApplication();
+
+ // parse the args
+ KCmdLineArgs args = KCmdLineArgs.parsedArgs();
+
+ // Make a central widget to contain the other widgets
+ QWidget w = new QWidget();
+ // Insert the widget container (parent widget) into
+ // a layout manager (VERTICAL).
+ QVBoxLayout vbox = new QVBoxLayout( w, KDialog.marginHint(),
+ KDialog.spacingHint() );
+ // Resize the widget
+ w.resize( 500, 100 );
+
+ String[] list = {"Stone" , "Tree" , "Pebbles" , "Ocean" , "Sand" , "Chips"
+ , "Computer" , "Mankind"};
+
+ // Create and modify read-write widget
+ KComboBox rwc = new KComboBox( true, w, "rwcombobox" );
+ QLabel lblrw = new QLabel( rwc, "&Editable ComboBox", w, "rwcombolabel",0
+ );
+ rwc.setDuplicatesEnabled( true );
+ rwc.completionObject().setItems( list );
+ rwc.setInsertionPolicy( QComboBox.NoInsertion );
+ rwc.insertStringList( list );
+ rwc.setEditText( "KDE Java Bindings" );
+
+ // Create a read-write combobox and reproduce konqueror's code
+ KComboBox konqc = new KComboBox( true, w, "konqc" );
+ konqc.setMaxCount( 10 );
+ KSimpleConfig historyConfig = new KSimpleConfig("konq_history");
+ historyConfig.setGroup( "Location Bar" );
+ KCompletion s_pCompletion = new KCompletion();
+ s_pCompletion.setOrder( KCompletion.Weighted );
+
+ String[] rle = null;
+ // historyConfig.readListEntry( "ComboContents" ,rle);
+ s_pCompletion.setItems( rle );
+ s_pCompletion.setCompletionMode( KGlobalSettings.completionMode() );
+ konqc.setCompletionObject( s_pCompletion );
+
+ QLabel lblkonq = new QLabel( konqc, "&Konqueror's ComboBox", w );
+ // konqc.insertItem( KIconLoader.SmallIcon("www"),
+ // "http://www.kde.org" );
+ konqc.insertItem( app.iconLoader().loadIcon("www",0 ),
+ "http://www.kde.org" );
+ konqc.setCurrentItem( konqc.count()-1 );
+
+ // Create a read-only widget
+ KComboBox soc = new KComboBox( w, "socombobox" );
+ QLabel lblso = new QLabel( soc, "&Select-Only ComboBox", w, "socombolabel",0 );
+ soc.setCompletionMode( KGlobalSettings.CompletionAuto );
+ soc.completionObject().setItems( list );
+ soc.insertStringList( list );
+
+ // Create an exit button
+ QPushButton push = new QPushButton( "E&xit", w );
+
+ QObject.connect( push, Qt.SIGNAL("clicked()"), app, Qt.SLOT("closeAllWindows()" ) );
+
+ // Insert the widgets into the layout manager.
+ vbox.addWidget( lblrw );
+ vbox.addWidget( rwc );
+ vbox.addWidget( lblso );
+ vbox.addWidget( soc );
+ vbox.addWidget( lblkonq );
+ vbox.addWidget( konqc );
+ vbox.addWidget( push );
+
+ app.setMainWidget(w);
+ rwc.setFocus();
+ w.show();
+
+ app.exec();
+ return;
+ }
+
+ static {
+ qtjava.initialize();
+ kdejava.initialize();
+ }
+
+ }
+
+
diff --git a/kdejava/koala/test/kdatepicker/KDatePickTest.java b/kdejava/koala/test/kdatepicker/KDatePickTest.java
new file mode 100644
index 00000000..bf214ca9
--- /dev/null
+++ b/kdejava/koala/test/kdatepicker/KDatePickTest.java
@@ -0,0 +1,26 @@
+import org.kde.qt.*;
+import org.kde.koala.*;
+
+public class KDatePickTest {
+
+
+ public static void main (String[] args) {
+
+ KLocale.setMainCatalogue("kdelibs");
+ KCmdLineArgs.init(args, "kdatepickertest", "KDatePickTest",
+ "A KDatePicker test..", "0.1");
+ KApplication app = new KApplication();
+ KDatePicker picker = new KDatePicker();
+ app.setMainWidget(picker);
+ picker.show();
+ app.exec();
+ return;
+
+ }
+
+ static {
+ qtjava.initialize();
+ kdejava.initialize();
+ }
+
+}
diff --git a/kdejava/koala/test/kfontdialog/KFontDialogTest.java b/kdejava/koala/test/kfontdialog/KFontDialogTest.java
new file mode 100644
index 00000000..a210d90e
--- /dev/null
+++ b/kdejava/koala/test/kfontdialog/KFontDialogTest.java
@@ -0,0 +1,164 @@
+import java.util.*;
+
+import org.kde.qt.*;
+import org.kde.koala.*;
+/*
+ $Id$
+
+ Requires the Qt widget libraries, available at no cost at
+ http://www.troll.no
+
+ Copyright (C) 1996 Bernd Johannes Wuebben
+ wuebben@math.cornell.edu
+
+ 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.
+
+*/
+
+/**
+ * Class to test KFontDialog widgets.
+ *
+ * This is a translation to java from kfontdialogtest.cpp in the tests library
+ * of kdeui source.
+ *
+ * @see KFontDialog
+ * @see KApplication
+ * @see KConfig
+ *
+ * @author Bernd Johannes Wuebben, java translation Kenneth J. Pouncey, kjpou@hotmail.com
+ * @version 0.1
+ */
+public class KFontDialogTest {
+
+ static String description = "Java KFontDialog test program.";
+ static String[][] options = { };
+ static String VERSION = "0.1";
+
+ public static void main(String[] cmdLineArgs) {
+
+ KAboutData aboutData = new KAboutData( "kfontdialogtest", "KFontDialogTest",
+ VERSION, description, KAboutData.License_GPL,
+ "(c) 2002, Kenneth J. Pouncey");
+ aboutData.addAuthor("Kenneth J. Pouncey",null, "kjpou@hotmail.com");
+ KCmdLineArgs.init( cmdLineArgs, aboutData );
+ KCmdLineArgs.addCmdLineOptions( options ); // Add our own options.
+
+ KApplication app = new KApplication();
+
+ // parse the args
+ KCmdLineArgs args = KCmdLineArgs.parsedArgs();
+
+ KConfig aConfig = new KConfig();
+ aConfig.setGroup( "KFontDialog-test" );
+
+ // parameters are Font name, Font Point Size, Font Style, Font Italic
+ app.setFont(new QFont("Helvetica",12,QFont.Normal,false));
+// app.setFont(new QFont("Times",18,QFont.Bold,true));
+
+ QFont font = aConfig.readFontEntry( "Chosen" );
+
+ int nRet = KFontDialog.getFont(font);
+
+ // return values from KFontDialog
+ // nRet = 1 for OK Button
+ // nRet = 0 for Cancel button
+
+ if (nRet == 1) { // print out font values
+ System.out.println("Ok Button pressed from KFontDialog ");
+ System.out.println(" Font name selected: " + font.family());
+ System.out.println(" Font Point Size selected: " + font.pointSize());
+ System.out.println(" Font Bold?: " + font.bold());
+ System.out.println(" Font Italic?: " + font.italic());
+ System.out.println(" Font Underline?: " + font.underline());
+// System.out.println(" Font Character Set: " + getCharacterSet(font.charSet()));
+ System.out.println(" Font raw name selected: " + font.rawName());
+ }
+
+ int[] flags = { 0 };
+
+ //Static method for KFontDialog needs to be generated
+ nRet = KFontDialog.getFontDiff(font, flags);
+ if (nRet == 1) {
+ System.out.println("Ok Button pressed from KFontDialog diff dialog ");
+ System.out.println(" Font diff flags: " + flags[0]);
+ System.out.println(" Font name selected: " + font.family());
+ System.out.println(" Font Point Size selected: " + font.pointSize());
+ System.out.println(" Font Bold?: " + font.bold());
+ System.out.println(" Font Italic?: " + font.italic());
+ System.out.println(" Font Underline?: " + font.underline());
+ System.out.println(" Font raw name selected: " + font.rawName());
+ }
+
+ // This should save off the font chose in the configuration so it can
+ // be read next time.
+ aConfig.writeEntry( "Chosen", font,true,false,false );
+
+ aConfig.sync();
+
+ app.exec();
+ return;
+ }
+
+ /**
+ * Returns the string representation of the character set.
+ * Others should be added here.
+ */
+/* private static String getCharacterSet (int cs) {
+
+ switch (cs) {
+
+ case QFont.ISO_8859_1 :
+ return "ISO_8859_1";
+ case QFont.ISO_8859_2 :
+ return "ISO_8859_2";
+ case QFont.ISO_8859_3 :
+ return "ISO_8859_3";
+ case QFont.ISO_8859_4 :
+ return "ISO_8859_4";
+ case QFont.ISO_8859_5 :
+ return "ISO_8859_5";
+ case QFont.ISO_8859_6 :
+ return "ISO_8859_6";
+ case QFont.ISO_8859_7 :
+ return "ISO_8859_7";
+ case QFont.ISO_8859_8 :
+ return "ISO_8859_8";
+ case QFont.ISO_8859_9 :
+ return "ISO_8859_9";
+ case QFont.ISO_8859_10 :
+ return "ISO_8859_10";
+ case QFont.ISO_8859_11 :
+ return "ISO_8859_11";
+ case QFont.ISO_8859_12 :
+ return "ISO_8859_12";
+ case QFont.ISO_8859_13 :
+ return "ISO_8859_13";
+ case QFont.ISO_8859_14 :
+ return "ISO_8859_14";
+ case QFont.ISO_8859_15 :
+ return "ISO_8859_15";
+
+ // more should be added
+ default :
+ return " other ";
+
+ }
+ } */
+ static {
+ qtjava.initialize();
+ kdejava.initialize();
+ }
+
+}
diff --git a/kdejava/koala/test/khelpers/KHelpers.java b/kdejava/koala/test/khelpers/KHelpers.java
new file mode 100644
index 00000000..3ab345c0
--- /dev/null
+++ b/kdejava/koala/test/khelpers/KHelpers.java
@@ -0,0 +1,103 @@
+import org.kde.qt.*;
+import org.kde.koala.*;
+
+/**
+ * Class KHelpers is the main application window.
+ *
+ * Taken from KDE 2.0 Development book
+ *
+ * ToolTips, What's This?, and More
+ *
+ *
+ *
+ * @see KMainWindow
+ * @see KApplication
+ *
+ * @author java translation Kenneth J. Pouncey, kjpou@hotmail.com
+ * @version 0.1
+ */
+
+public class KHelpers extends KMainWindow {
+
+ // File menu item id's
+ protected int idfilenew;
+ protected int idfileopen;
+ protected int idfilesave;
+ protected int idfilequit;
+
+ // reference to the application
+ KApplication kapp;
+
+ // time to display the message in the status bar
+ int HelpMessageTime = 200;
+
+ public KHelpers () {
+
+ // get a reference to the application
+ kapp = KApplication.kApplication();
+
+ QPopupMenu file = new QPopupMenu(this);
+
+ idfilenew = file.insertItem("&New");
+ idfileopen = file.insertItem("&Open...");
+ idfilesave = file.insertItem("&Save");
+ idfilequit = file.insertItem("&Quit", kapp, SLOT("closeAllWindows()"));
+
+ connect ( file, SIGNAL( "highlighted(int)"), this, SLOT( "slotMenuEntryHelp (int)"));
+
+ menuBar().insertItem("&File",file);
+
+ QPopupMenu help = helpMenu("KHelpers\n" +
+ "Copyright (C) 2000 By Joe Developer\n\n" +
+ "KHelpers demonstates a few of the ways " +
+ "that your application can provide help to a user");
+
+ help.insertSeparator();
+ help.insertItem("Help on a special topic", this, SLOT("slotSpecialHelp()"));
+
+ menuBar().insertItem("&Help",help);
+
+ // Create the statusbar
+ statusBar();
+
+ QLabel clientarea = new QLabel(this);
+ clientarea.setBackgroundColor(Qt.white());
+
+ QToolTip.add(clientarea, "Functionless client area");
+ QWhatsThis.add(clientarea,"This client area doesn't do anything.");
+
+ setCentralWidget(clientarea);
+
+ clientarea.setFocus();
+ }
+
+ public void slotMenuEntryHelp (int id) {
+
+ if (id == idfilenew) {
+ statusBar().message("Create a new document.",HelpMessageTime);
+ }
+ else if (id == idfileopen) {
+
+ statusBar().message("Open a file.",HelpMessageTime);
+
+ }
+ else if (id == idfilesave) {
+
+ statusBar().message("Save the current document.",HelpMessageTime);
+
+ }
+ else if (id == idfilequit) {
+
+ statusBar().message("Quit the application.",HelpMessageTime);
+
+ }
+ }
+
+ public void slotSpecialHelp() {
+
+ String helpfilename = kapp.name();
+ helpfilename += "/specialhelp.html";
+ kapp.invokeHelp(helpfilename,"");
+ }
+
+}
diff --git a/kdejava/koala/test/khelpers/Main.java b/kdejava/koala/test/khelpers/Main.java
new file mode 100644
index 00000000..57f4fb7f
--- /dev/null
+++ b/kdejava/koala/test/khelpers/Main.java
@@ -0,0 +1,52 @@
+import org.kde.qt.*;
+import org.kde.koala.*;
+
+/**
+ * Main class.
+ *
+ * Taken from KDE 2.0 Development book
+ *
+ * Helping the User Use Your Application
+ *
+ * ToolTips, What's This?, and More
+ *
+ * @see KApplication
+ * @see KCmdLineArgs
+ *
+ * @author java translation Kenneth J. Pouncey, kjpou@hotmail.com
+ * @version 0.1
+ */
+
+public class Main {
+
+ static String description = "KDE 2 Development example";
+
+
+ static String[][] options = { };
+
+
+static String VERSION = "0.1";
+
+ public static void main(String[] cmdLineArgs) {
+
+ KAboutData aboutData = new KAboutData( "KHelpers", "KHelpers",
+ VERSION, description, KAboutData.License_GPL,
+ "KDE 2 Development");
+ KCmdLineArgs.init( cmdLineArgs, aboutData );
+ KCmdLineArgs.addCmdLineOptions( options ); // Add our own options.
+
+ KApplication app = new KApplication();
+ KHelpers khelpers = new KHelpers();
+
+ khelpers.show();
+
+ app.exec();
+ return;
+ }
+
+ static {
+ qtjava.initialize();
+ kdejava.initialize();
+ }
+
+}
diff --git a/kdejava/koala/test/kioslave/KioslaveTest.java b/kdejava/koala/test/kioslave/KioslaveTest.java
new file mode 100644
index 00000000..384c8b2f
--- /dev/null
+++ b/kdejava/koala/test/kioslave/KioslaveTest.java
@@ -0,0 +1,589 @@
+ /*
+ This file is or will be part of KDE desktop environment
+
+ Copyright 1999 Matt Koss <koss@miesto.sk>
+
+ It is licensed under GPL version 2.
+
+ If it is part of KDE libraries than this file is licensed under
+ LGPL version 2.
+ */
+
+import org.kde.qt.*;
+import org.kde.koala.*;
+import java.io.ByteArrayOutputStream;
+
+class KioslaveTest extends KMainWindow {
+
+ static final int List = 0;
+ static final int ListRecursive = 1;
+ static final int Stat = 2;
+ static final int Get = 3;
+ static final int Put = 4;
+ static final int Copy = 5;
+ static final int Move = 6;
+ static final int Delete = 7;
+ static final int Shred = 8;
+ static final int Mkdir = 9;
+ static final int Mimetype = 10;
+
+ static final int ProgressNone = 0;
+ static final int ProgressDefault = 1;
+ static final int ProgressStatus = 2;
+
+ // info stuff
+ QLabel lb_from;
+ QLineEdit le_source;
+
+ QLabel lb_to;
+ QLineEdit le_dest;
+
+ // operation stuff
+ QButtonGroup opButtons;
+
+ QRadioButton rbList;
+ QRadioButton rbListRecursive;
+ QRadioButton rbStat;
+ QRadioButton rbGet;
+ QRadioButton rbPut;
+ QRadioButton rbCopy;
+ QRadioButton rbMove;
+ QRadioButton rbDelete;
+ QRadioButton rbShred;
+ QRadioButton rbMkdir;
+ QRadioButton rbMimetype;
+
+ // progress stuff
+ QButtonGroup progressButtons;
+
+ QRadioButton rbProgressNone;
+ QRadioButton rbProgressDefault;
+ QRadioButton rbProgressStatus;
+
+ QPushButton pbStart;
+ QPushButton pbStop;
+
+ QPushButton close;
+
+
+private Job job;
+private QWidget main_widget;
+
+private StatusbarProgress statusProgress;
+
+private int selectedOperation;
+private int progressMode;
+private int putBuffer;
+private Slave slave;
+
+ /*
+ This file is or will be part of KDE desktop environment
+
+ Copyright 1999 Matt Koss <koss@miesto.sk>
+
+ It is licensed under GPL version 2.
+
+ If it is part of KDE libraries than this file is licensed under
+ LGPL version 2.
+ */
+
+
+
+
+
+KioslaveTest( String src, String dest, int op, int pr )
+{
+ super(null, "");
+ job = null;
+
+ main_widget = new QWidget( this, "");
+ QBoxLayout topLayout = new QVBoxLayout( main_widget, 10, 5 );
+
+ QGridLayout grid = new QGridLayout( 2, 2, 10 );
+ topLayout.addLayout( grid );
+
+ grid.setRowStretch(0,1);
+ grid.setRowStretch(1,1);
+
+ grid.setColStretch(0,1);
+ grid.setColStretch(1,100);
+
+ lb_from = new QLabel( "From :", main_widget );
+ grid.addWidget( lb_from, 0, 0 );
+
+ le_source = new QLineEdit( main_widget );
+ grid.addWidget( le_source, 0, 1 );
+ le_source.setText( src );
+
+ lb_to = new QLabel( "To :", main_widget );
+ grid.addWidget( lb_to, 1, 0 );
+
+ le_dest = new QLineEdit( main_widget );
+ grid.addWidget( le_dest, 1, 1 );
+ le_dest.setText( dest );
+
+ // Operation groupbox & buttons
+ opButtons = new QButtonGroup( "Operation", main_widget );
+ topLayout.addWidget( opButtons, 10 );
+ connect( opButtons, SIGNAL("clicked(int)"), SLOT("changeOperation(int)") );
+
+ QBoxLayout hbLayout = new QHBoxLayout( opButtons, 15 );
+
+ rbList = new QRadioButton( "List", opButtons );
+ opButtons.insert( rbList, List );
+ hbLayout.addWidget( rbList, 5 );
+
+ rbListRecursive = new QRadioButton( "ListRecursive", opButtons );
+ opButtons.insert( rbListRecursive, ListRecursive );
+ hbLayout.addWidget( rbListRecursive, 5 );
+
+ rbStat = new QRadioButton( "Stat", opButtons );
+ opButtons.insert( rbStat, Stat );
+ hbLayout.addWidget( rbStat, 5 );
+
+ rbGet = new QRadioButton( "Get", opButtons );
+ opButtons.insert( rbGet, Get );
+ hbLayout.addWidget( rbGet, 5 );
+
+ rbPut = new QRadioButton( "Put", opButtons );
+ opButtons.insert( rbPut, Put );
+ hbLayout.addWidget( rbPut, 5 );
+
+ rbCopy = new QRadioButton( "Copy", opButtons );
+ opButtons.insert( rbCopy, Copy );
+ hbLayout.addWidget( rbCopy, 5 );
+
+ rbMove = new QRadioButton( "Move", opButtons );
+ opButtons.insert( rbMove, Move );
+ hbLayout.addWidget( rbMove, 5 );
+
+ rbDelete = new QRadioButton( "Delete", opButtons );
+ opButtons.insert( rbDelete, Delete );
+ hbLayout.addWidget( rbDelete, 5 );
+
+ rbShred = new QRadioButton( "Shred", opButtons );
+ opButtons.insert( rbShred, Shred );
+ hbLayout.addWidget( rbShred, 5 );
+
+ rbMkdir = new QRadioButton( "Mkdir", opButtons );
+ opButtons.insert( rbMkdir, Mkdir );
+ hbLayout.addWidget( rbMkdir, 5 );
+
+ rbMimetype = new QRadioButton( "Mimetype", opButtons );
+ opButtons.insert( rbMimetype, Mimetype );
+ hbLayout.addWidget( rbMimetype, 5 );
+
+ opButtons.setButton( op );
+ changeOperation( op );
+
+ // Progress groupbox & buttons
+ progressButtons = new QButtonGroup( "Progress dialog mode", main_widget );
+ topLayout.addWidget( progressButtons, 10 );
+ connect( progressButtons, SIGNAL("clicked(int)"), SLOT("changeProgressMode(int)") );
+
+ hbLayout = new QHBoxLayout( progressButtons, 15 );
+
+ rbProgressNone = new QRadioButton( "None", progressButtons );
+ progressButtons.insert( rbProgressNone, ProgressNone );
+ hbLayout.addWidget( rbProgressNone, 5 );
+
+ rbProgressDefault = new QRadioButton( "Default", progressButtons );
+ progressButtons.insert( rbProgressDefault, ProgressDefault );
+ hbLayout.addWidget( rbProgressDefault, 5 );
+
+ rbProgressStatus = new QRadioButton( "Status", progressButtons );
+ progressButtons.insert( rbProgressStatus, ProgressStatus );
+ hbLayout.addWidget( rbProgressStatus, 5 );
+
+ progressButtons.setButton( pr );
+ changeProgressMode( pr );
+
+ // statusbar progress widget
+ statusProgress = new StatusbarProgress( statusBar() );
+ statusBar().addWidget( statusProgress, 0, true );
+
+ // run & stop butons
+ hbLayout = new QHBoxLayout( topLayout, 15 );
+
+ pbStart = new QPushButton( "&Start", main_widget );
+ pbStart.setFixedSize( pbStart.sizeHint() );
+ connect( pbStart, SIGNAL("clicked()"), SLOT("startJob()") );
+ hbLayout.addWidget( pbStart, 5 );
+
+ pbStop = new QPushButton( "Sto&p", main_widget );
+ pbStop.setFixedSize( pbStop.sizeHint() );
+ pbStop.setEnabled( false );
+ connect( pbStop, SIGNAL("clicked()"), SLOT("stopJob()") );
+ hbLayout.addWidget( pbStop, 5 );
+
+ // close button
+ close = new QPushButton( "&Close", main_widget );
+ close.setFixedSize( close.sizeHint() );
+ connect(close, SIGNAL("clicked()"), this, SLOT("slotQuit()"));
+
+ topLayout.addWidget( close, 5 );
+
+ main_widget.setMinimumSize( main_widget.sizeHint() );
+ setCentralWidget( main_widget );
+
+ slave = null;
+// slave = Scheduler.getConnectedSlave(new KURL("ftp://ftp.kde.org"));
+ Scheduler.connect(SIGNAL("slaveConnected(Slave)"),
+ this, SLOT("slotSlaveConnected()"));
+ Scheduler.connect(SIGNAL("slaveError(Slave,int,String)"),
+ this, SLOT("slotSlaveError()"));
+}
+
+
+protected void closeEvent( QCloseEvent e ){
+ slotQuit();
+}
+
+
+void slotQuit(){
+ if ( job != null ) {
+ job.kill( true ); // kill the job quietly
+ }
+ if (slave != null )
+ Scheduler.disconnectSlave(slave);
+ KApplication.kApplication().quit();
+}
+
+
+void changeOperation( int id ) {
+ // only two urls for copy and move
+ boolean enab = rbCopy.isChecked() || rbMove.isChecked();
+
+ le_dest.setEnabled( enab );
+
+ selectedOperation = id;
+}
+
+
+void changeProgressMode( int id ) {
+ progressMode = id;
+
+ if ( progressMode == ProgressStatus ) {
+ statusBar().show();
+ } else {
+ statusBar().hide();
+ }
+}
+
+
+void startJob() {
+ String sCurrent = QDir.currentDirPath()+"/";
+ KURL.encode_string(sCurrent);
+ String sSrc = le_source.text();
+ KURL src = new KURL( new KURL(sCurrent), sSrc );
+
+ if ( !src.isValid() ) {
+ QMessageBox.critical(this, "Kioslave Error Message", "Source URL is malformed" );
+ return;
+ }
+
+ String sDest = le_dest.text();
+ KURL dest = new KURL( new KURL(sCurrent), sDest );
+
+ if ( !dest.isValid() &&
+ ( selectedOperation == Copy || selectedOperation == Move ) ) {
+ QMessageBox.critical(this, "Kioslave Error Message",
+ "Destination URL is malformed" );
+ return;
+ }
+
+ pbStart.setEnabled( false );
+
+ boolean observe = true;
+ if (progressMode != ProgressDefault) {
+ observe = false;
+ }
+
+ SimpleJob myJob = null;
+
+ switch ( selectedOperation ) {
+ case List:
+ myJob = KIO.listDir( src );
+// connect(myJob, SIGNAL(" entries( Job, const KIO.UDSEntryList&)"),
+// SLOT(" slotEntries( KIO.Job, const KIO.UDSEntryList&)"));
+ break;
+
+ case ListRecursive:
+ myJob = KIO.listRecursive( src );
+// connect(myJob, SIGNAL(" entries( KIO.Job, const KIO.UDSEntryList&)"),
+ // SLOT(" slotEntries( KIO.Job, const KIO.UDSEntryList&)"));
+ break;
+
+ case Stat:
+ myJob = KIO.stat( src );
+ break;
+
+ case Get:
+ myJob = KIO.get( src, true );
+ connect(myJob, SIGNAL("data( Job, byte[])"),
+ SLOT("slotData( Job, byte[])"));
+ break;
+
+ case Put:
+ putBuffer = 0;
+ myJob = KIO.put( src, -1, true, false);
+ connect(myJob, SIGNAL("dataReq( Job, ByteArrayOutputStream)"),
+ SLOT("slotDataReq( Job, ByteArrayOutputStream)"));
+ break;
+
+ case Copy:
+ job = KIO.copy( src, dest, observe );
+ break;
+
+ case Move:
+ job = KIO.move( src, dest, observe );
+ break;
+
+ case Delete:
+ job = KIO.del( src, false, observe );
+ break;
+
+ case Shred:
+ job = KIO.del(src, true, observe);
+ break;
+
+ case Mkdir:
+ myJob = KIO.mkdir( src );
+ break;
+
+ case Mimetype:
+ myJob = KIO.mimetype( src );
+ break;
+ }
+ if (myJob != null)
+ {
+ if (slave != null)
+ Scheduler.assignJobToSlave(slave, myJob);
+ job = myJob;
+ }
+
+ connect( job, SIGNAL(" result( Job )"),
+ SLOT(" slotResult( Job )") );
+
+ connect( job, SIGNAL(" canceled( Job )"),
+ SLOT(" slotResult( Job )") );
+
+ if (progressMode == ProgressStatus) {
+ statusProgress.setJob( job );
+ }
+
+ pbStop.setEnabled( true );
+}
+
+
+void slotResult(Job _job )
+{
+ if ( _job.error() != 0 )
+ {
+ _job.showErrorDialog();
+ }
+ else if ( selectedOperation == Stat )
+ {
+// UDSEntry entry = ((KIO.StatJob)_job).statResult();
+// printUDSEntry( entry );
+ }
+ else if ( selectedOperation == Mimetype )
+ {
+ System.out.println("mimetype is " + ((MimetypeJob)_job).mimetype());
+ }
+
+ if (job == _job)
+ job = null;
+ pbStart.setEnabled( true );
+ pbStop.setEnabled( false );
+}
+
+void slotSlaveConnected()
+{
+ System.out.println("Slave connected.");
+}
+
+void slotSlaveError()
+{
+ System.out.println("Error connected.");
+ slave = null;
+}
+
+/*
+void UDSEntry & entry )
+{
+ KIO.UDSEntry.ConstIterator it = entry.begin();
+ for( ; it != entry.end(); it++ ) {
+ switch ((it).m_uds) {
+ case KIO.UDS_FILE_TYPE:
+ kdDebug() << "File Type : " << (mode_t)((it).m_long) << endl;
+ if ( S_ISDIR( (mode_t)((it).m_long) ) )
+ {
+ kdDebug() << "is a dir" << endl;
+ }
+ break;
+ case KIO.UDS_ACCESS:
+ kdDebug() << "Access permissions : " << (mode_t)((it).m_long) << endl;
+ break;
+ case KIO.UDS_USER:
+ kdDebug() << "User : " << ((it).m_str.ascii() ) << endl;
+ break;
+ case KIO.UDS_GROUP:
+ kdDebug() << "Group : " << ((it).m_str.ascii() ) << endl;
+ break;
+ case KIO.UDS_NAME:
+ kdDebug() << "Name : " << ((it).m_str.ascii() ) << endl;
+ //m_strText = decodeFileName( (it).m_str );
+ break;
+ case KIO.UDS_URL:
+ kdDebug() << "URL : " << ((it).m_str.ascii() ) << endl;
+ break;
+ case KIO.UDS_MIME_TYPE:
+ kdDebug() << "MimeType : " << ((it).m_str.ascii() ) << endl;
+ break;
+ case KIO.UDS_LINK_DEST:
+ kdDebug() << "LinkDest : " << ((it).m_str.ascii() ) << endl;
+ break;
+ }
+ }
+}
+
+void UDSEntryList& list) {
+
+ UDSEntryListConstIterator it=list.begin();
+ for (; it != list.end(); ++it) {
+ UDSEntry.ConstIterator it2 = (it).begin();
+ for( ; it2 != (it).end(); it2++ ) {
+ if ((it2).m_uds == UDS_NAME)
+ kdDebug() << "" << ( it2 ).m_str << endl;
+ }
+ }
+}
+*/
+
+void slotData(Job job, byte[] data)
+{
+ if (data.length == 0)
+ {
+ System.out.println("Data: <End>");
+ }
+ else
+ {
+ String myString = new String(data);
+ System.out.println("Data: \"" + myString + "\"");
+ }
+}
+
+void slotDataReq(Job job, ByteArrayOutputStream data)
+{
+ String[] fileDataArray =
+ {
+ "Hello world\n",
+ "This is a test file\n",
+ "You can safely delete it.\n",
+ null
+ };
+ String fileData = fileDataArray[putBuffer++];
+
+ if (fileData == null)
+ {
+ System.out.println("DataReq: <End>");
+ return;
+ }
+
+ try {
+ data.write(fileData.getBytes());
+ } catch (java.io.IOException e) {
+ ;
+ }
+
+ System.out.println("DataReq: \"" + fileData + "\"");
+}
+
+void stopJob() {
+ System.out.println("KioslaveTest.stopJob()");
+ job.kill();
+ job = null;
+
+ pbStop.setEnabled( false );
+ pbStart.setEnabled( true );
+}
+
+static String version = "v0.0.0 0000"; // :-)
+static String description = "Test for kioslaves";
+static String[][] options =
+{
+ { "s", null, null },
+ { "src <src>", "Source URL", "" },
+ { "d", null, null },
+ { "dest <dest>", "Destination URL", "" },
+ { "o", null, null },
+ { "operation <operation>", "Operation (list,listrecursive,stat,get,copy,move,del,shred,mkdir)", "copy" },
+ { "p", null, null },
+ { "progress <progress>", "Progress Type (none,default,status)", "default" }
+};
+
+public static void main(String[] argv) {
+ KCmdLineArgs.init( argv, "kioslavetest", "KIOSlaveTest", description, version );
+ KCmdLineArgs.addCmdLineOptions( options );
+ KApplication app = new KApplication();
+
+ KCmdLineArgs args = KCmdLineArgs.parsedArgs();
+
+ String src = args.getOption("src");
+ String dest = args.getOption("dest");
+
+ int op = 0;
+ int pr = 0;
+
+ String tmps;
+
+ tmps = args.getOption("operation");
+ if ( tmps.equals("list")) {
+ op = KioslaveTest.List;
+ } else if ( tmps.equals("listrecursive")) {
+ op = KioslaveTest.ListRecursive;
+ } else if ( tmps.equals("stat")) {
+ op = KioslaveTest.Stat;
+ } else if ( tmps.equals("get")) {
+ op = KioslaveTest.Get;
+ } else if ( tmps.equals("copy")) {
+ op = KioslaveTest.Copy;
+ } else if ( tmps.equals("move")) {
+ op = KioslaveTest.Move;
+ } else if ( tmps.equals("del")) {
+ op = KioslaveTest.Delete;
+ } else if ( tmps.equals("shred")) {
+ op = KioslaveTest.Shred;
+ } else if ( tmps.equals("mkdir")) {
+ op = KioslaveTest.Mkdir;
+ } else KCmdLineArgs.usage("unknown operation");
+
+ tmps = args.getOption("progress");
+ if ( tmps.equals("none")) {
+ pr = KioslaveTest.ProgressNone;
+ } else if ( tmps.equals("default")) {
+ pr = KioslaveTest.ProgressDefault;
+ } else if ( tmps.equals("status")) {
+ pr = KioslaveTest.ProgressStatus;
+ } else KCmdLineArgs.usage("unknown progress mode");
+
+ args.clear(); // Free up memory
+
+ KioslaveTest test = new KioslaveTest( src, dest, op, pr );
+ test.show();
+ // Bug in KTMW / Qt / layouts ?
+ test.resize( test.sizeHint() );
+
+ app.setMainWidget(test);
+ app.exec();
+ return;
+}
+
+ static {
+ qtjava.initialize();
+ kdejava.initialize();
+ }
+}
+
+
diff --git a/kdejava/koala/test/kmenu/KdeMenuSample.java b/kdejava/koala/test/kmenu/KdeMenuSample.java
new file mode 100644
index 00000000..b7832118
--- /dev/null
+++ b/kdejava/koala/test/kmenu/KdeMenuSample.java
@@ -0,0 +1,142 @@
+/*
+ * KdeMenuSample.java
+ *
+ * Created on 8. Marz 2002, 20:31
+ */
+
+//package com.werpu.sample3;
+
+//import com.werpu.common.*;
+import org.kde.koala.kdejava;
+import org.kde.qt.qtjava;
+
+import org.kde.koala.KMainWindow;
+import org.kde.koala.KCmdLineArgs;
+import org.kde.qt.QPopupMenu;
+import org.kde.qt.QTextView;
+import org.kde.koala.KMenuBar;
+import org.kde.koala.KApplication;
+import org.kde.koala.KURL;
+import org.kde.koala.KFileDialog;
+import org.kde.koala.KMessageBox;
+import org.kde.qt.QColor;
+import org.kde.qt.QButton;
+import org.kde.koala.KPushButton;
+
+
+
+/**
+ * @author Werner Punz werpu@gmx.at
+ * To Java translated KDE Menu Example from
+ * The kde.org KDE Tutorial from Antonio Larrosa Jimenez
+ * http://person.wanadoo.es/antlarr/tutorial
+ */
+public class KdeMenuSample extends KMainWindow {
+
+ static {
+ qtjava.initialize();
+ kdejava.initialize();
+ }
+
+ KApplication kApp = null;
+
+ /** Creates a new instance of KdeMenuSample */
+ public KdeMenuSample(KApplication kApp) {
+ super(null,"Menu Sample",1);
+ this.kApp = kApp;
+ setCaption("KDE3 Tutorial");
+ createMenu();
+ QTextView centralWidget = createTextView();
+
+ this.setCentralWidget(centralWidget);
+ }
+
+
+ /**
+ * creates the file menu
+ */
+ private QPopupMenu createFileMenu() {
+ QPopupMenu fileMenu = new QPopupMenu(this);
+ fileMenu.insertItem("&Open",this,this.SLOT("fileOpen()"));
+ fileMenu.insertItem("&Save",this,this.SLOT("fileSave()"));
+ fileMenu.insertItem("&Quit",kApp,kApp.SLOT("quit()"));
+ return fileMenu;
+ }
+
+ /**
+ * creates the about menu
+ */
+ private QPopupMenu createAboutMenu() {
+ StringBuffer aboutText = new StringBuffer();
+
+ aboutText.append("Menu Example: \n ");
+ aboutText.append("Originally written by Antonio Larrosa Jimenez larossa@kde.org \n");
+ aboutText.append("Translated to Java by Werner Punz werpu@gmx.at \n");
+ aboutText.append("Simple KDE Tutorial\n");
+ aboutText.append("This tutorial comes with ABSOLUTELY NO WARRANTY\n");
+ aboutText.append("This is free software, and you are welcome to redistribute it\n");
+ aboutText.append("under certain conditions\n");
+
+ QPopupMenu aboutMenu = helpMenu(aboutText.toString(),true);
+
+ return aboutMenu;
+ }
+
+ /**
+ * creates the menu
+ */
+ private void createMenu() {
+ KMenuBar mainMenu = kmenuBar();
+ mainMenu.insertItem("&File",createFileMenu());
+ mainMenu.insertSeparator();
+ mainMenu.insertItem("&About",createAboutMenu());
+ }
+
+ /**
+ * creates the textview of the window
+ */
+ private QTextView createTextView() {
+ StringBuffer textBuf = new StringBuffer();
+ textBuf.append("<H2>Hello World !</H2><BR>This is a simple");
+ textBuf.append(" window with <I><font size=5><B>R<font color=red");
+ textBuf.append(" size=5>ich </font><font color=blue size=5>Text");
+ textBuf.append("</font></B></I> capabilities<BR>Try to resize");
+ textBuf.append(" this window, all this is automatic !</H2>");
+
+ QTextView mainTextView = new QTextView(this,"");
+ mainTextView.setText(textBuf.toString());
+
+
+ return mainTextView;
+ }
+
+ //--------------------------------------------------------------
+ //Slots
+ //--------------------------------------------------------------
+ public void fileOpen() {
+ //System.out.println("File Open");
+ KURL filename = KFileDialog.getOpenURL("", "*", this,"Open File" );
+ String msg = "Now this app should open the url " + filename.url();
+ KMessageBox.information(this , msg, "Information" , "fileOpenInformationDialog" );
+ }
+
+ public void fileSave() {
+ KURL filename = KFileDialog.getSaveURL( "" , "*", this, "Save File" );
+ }
+
+ //----------------------------------------------------------------
+ // main method
+ //----------------------------------------------------------------
+ public static void main(String [] argv) {
+ KCmdLineArgs.init(argv, "menuapp", "MenuApp",
+ "A simple menu example", "0.1");
+ KApplication menuApp = new KApplication();
+ KdeMenuSample mainWnd = new KdeMenuSample(menuApp);
+
+ mainWnd.resize(100,300);
+ menuApp.setMainWidget(mainWnd);
+
+ mainWnd.show();
+ menuApp.exec();
+ }
+}
diff --git a/kdejava/koala/test/kprogress/KProgressTest.java b/kdejava/koala/test/kprogress/KProgressTest.java
new file mode 100644
index 00000000..456fbc14
--- /dev/null
+++ b/kdejava/koala/test/kprogress/KProgressTest.java
@@ -0,0 +1,88 @@
+import org.kde.qt.*;
+import org.kde.koala.*;
+
+/**
+ * Class to test KProgress widget.
+ *
+ * This is a translation to java from kprogresstest.cpp in the tests library
+ * of kdeui source.
+ *
+ * @see KProgress
+ * @see KApplication
+ *
+ * @author orignal unknown, java translation Kenneth J. Pouncey, kjpou@hotmail.com
+ * @version 0.1
+ */
+
+public class KProgressTest {
+
+ static String description = "Java KProgress test program";
+ static String[][] options = { };
+ static String VERSION = "0.1";
+
+ public static void main(String[] cmdLineArgs) {
+
+ KAboutData aboutData = new KAboutData( "kprogresstest", "KProgressTest",
+ VERSION, description, KAboutData.License_GPL,
+ "(c) 2002, Kenneth J. Pouncey");
+ aboutData.addAuthor("Kenneth J. Pouncey",null, "kjpou@hotmail.com");
+ KCmdLineArgs.init( cmdLineArgs, aboutData );
+ KCmdLineArgs.addCmdLineOptions( options ); // Add our own options.
+
+ KApplication app = new KApplication();
+
+ // parse the args
+ KCmdLineArgs args = KCmdLineArgs.parsedArgs();
+
+ MyWidget mine = new MyWidget();
+
+ mine.setCaption(description);
+
+ app.setMainWidget(mine);
+ mine.show();
+
+ app.exec();
+
+ return;
+ }
+
+ private static class MyWidget extends QWidget {
+
+ private KProgress Progress;
+ static int fwd = 0;
+ static int back = 1;
+ static int direction = fwd;
+
+ public MyWidget () {
+ super();
+ setFixedSize(440, 80);
+ Progress = new KProgress(this);
+ Progress.resize(400, 40);
+ Progress.move(20, 20);
+ startTimer(50);
+ }
+
+ public void timerEvent(QTimerEvent timer) {
+
+ if (direction == fwd) {
+ if (Progress.progress() == Progress.totalSteps())
+ direction = back;
+ else
+ Progress.advance(1);
+ }
+ else {
+ if (Progress.progress() == 0) { /*Progress.minValue()*/
+ direction = fwd;
+ }
+ else
+ Progress.advance(-1);
+ }
+ }
+ }
+
+ static {
+ qtjava.initialize();
+ kdejava.initialize();
+ }
+
+}
diff --git a/kdejava/koala/test/ksystemtray/Test.java b/kdejava/koala/test/ksystemtray/Test.java
new file mode 100644
index 00000000..f5f8f90c
--- /dev/null
+++ b/kdejava/koala/test/ksystemtray/Test.java
@@ -0,0 +1,28 @@
+import org.kde.koala.*;
+import org.kde.qt.*;
+
+public class Test {
+ static String description = "Systemtray test application for Java";
+ static String[][] options = {{ "+[File]", "image file to open", null }};
+// static String[][] options = new String[0][0];//{{ null, null, null }};
+
+ public static void main(String[] argv){
+ KAboutData aboutData = new KAboutData( "test", "Test",
+ "0.1", description, KAboutData.License_GPL,
+ "(C) 2002 Gert-Jan van der Heiden");
+ KCmdLineArgs.init( argv, aboutData );
+ KCmdLineArgs.addCmdLineOptions(options);
+ System.out.println("1");
+ KApplication app = new KApplication();
+ System.out.println("2");
+ KSystemTray systemTrayIcon = new KSystemTray(null, "test");
+ System.out.println("3");
+ systemTrayIcon.show();
+ app.exec();
+ System.exit(0);
+ }
+ static {
+ qtjava.initialize();
+ kdejava.initialize();
+ }
+}
diff --git a/kdejava/koala/test/simplebrowser/KSimpleBrowser.java b/kdejava/koala/test/simplebrowser/KSimpleBrowser.java
new file mode 100644
index 00000000..714ed72a
--- /dev/null
+++ b/kdejava/koala/test/simplebrowser/KSimpleBrowser.java
@@ -0,0 +1,65 @@
+import org.kde.qt.*;
+import org.kde.koala.*;
+
+/**
+ * Class KSimpleBrowser is the main application window.
+ *
+ * Taken from KDE 2.0 Development book
+ *
+ * Rendering HTML Files
+ *
+ * A Simple Web Browser - A feature-limited Web Browser.
+ *
+ * @see KMainWindow
+ * @see KApplication
+ * @see KHTMLPart
+ *
+ * @author java translation Kenneth J. Pouncey, kjpou@hotmail.com
+ * @version 0.1
+ */
+
+public class KSimpleBrowser extends KMainWindow {
+
+
+ static final int URLLined = 1;
+
+ KHTMLPart khtmlpart;
+
+ public KSimpleBrowser (String name) {
+
+ super(null,name,0);
+
+ toolBar().insertLined( "", URLLined, SIGNAL("returnPressed()"),
+ this, SLOT ("slotNewURL()"));
+
+
+ toolBar().setItemAutoSized(URLLined);
+
+ khtmlpart = new KHTMLPart(this);
+ khtmlpart.begin();
+
+ khtmlpart.write("<HTML><BODY><H1>KSimpleBrowser</H1>" +
+ "<P>To load a web page, type its URL in the line " +
+ "edit box and press enter,</P>" +
+ "</BODY></HTML>");
+
+ khtmlpart.end();
+
+ setCaption("KDE 2 Development book example - KSimpleBrowser");
+
+ setCentralWidget(khtmlpart.view());
+
+ }
+
+ public void slotNewURL () {
+
+ khtmlpart.openURL(new KURL(this.toolBar().getLinedText(URLLined))) ;
+ }
+
+
+ static {
+ qtjava.initialize();
+ kdejava.initialize();
+ }
+
+}
diff --git a/kdejava/koala/test/simplebrowser/Main.java b/kdejava/koala/test/simplebrowser/Main.java
new file mode 100644
index 00000000..d5a64ab3
--- /dev/null
+++ b/kdejava/koala/test/simplebrowser/Main.java
@@ -0,0 +1,40 @@
+import org.kde.qt.*;
+import org.kde.koala.*;
+
+/**
+ * Main class.
+ *
+ * Taken from KDE 2.0 Development book
+ *
+ * Rendering HTML Files
+ *
+ * A Simple Web Browser
+ *
+ *
+ * @see KApplication
+ *
+ * @author java translation Kenneth J. Pouncey, kjpou@hotmail.com
+ * @version 0.1
+ */
+
+public class Main {
+
+ public static void main(String[] cmdLineArgs) {
+
+ KCmdLineArgs.init(cmdLineArgs, "ksimplebrowser", "KSimpleBrowser",
+ "A KDE 3 Development Example - KSimpleBrowser", "0.1");
+ KApplication app = new KApplication();
+ KSimpleBrowser kbrowser = new KSimpleBrowser("KSimpleBrowser");
+
+ kbrowser.show();
+
+ app.exec();
+ return;
+ }
+
+ static {
+ qtjava.initialize();
+ kdejava.initialize();
+ }
+
+}