[Kde-java] Some questions - long - KScribble in java

KJ P kde-java@kde.org
Tue, 12 Feb 2002 09:21:45 +0000


Hello Richard

Thanks for the reply and the help.  I posted a longer response last night 
but it is being held because it is over the limit.  I will try to remember 
what I wrote as it was very late.

The other e-mail has all the source attached so if they will allow it you 
will receive the source as well.  If not I will attach it later as I do not 
have the source here at this time.

> > I can not find BarIcon.  Is it missing or have I missed something.
>I've had a look - and it is missing because it's a function call rather 
>than a
>static method of KIconLoader. So that needs to be fixed up by hand - in 
>java
>the functions at the end of kiconloader.h would appear as KIconLoader 
>static
>methods.
Instead of KStdAction I decided to go with the BarIcon so that the programs 
are the same for comparison purposes.  This works well but I added 2 methods 
to KScribble.java.

One called BarIcon() and another called BarIcon2.
The BarIcon will return a Pixmap by using the KIconLoader method.  This is 
used in the toolbar().

The BarIcon2 will return a QIconSet by creating a QIconSet and calling 
BarIcon() to load the icons into a set.  This is used in the menubar() 
because I could not get Pixmap version to work properly.  It does work for 
the IconSets.  For the pixmap version the Graphic part was showing up but 
the text part was not.

I can change this to use the KStdAction if you want but for comparison 
reasons I left it using the BarIcon.  If you decide to not implement the 
BarIcon let me know.

> > 2) Does the i18n not exist for java?  KBase.java uses tr() so instead I
> > wrote an i18n method which calls tr() that way I did not have to change 
>all
> > the i18n code.  Is the tr() method going to be used instead of the i18n?
>Yes, it should be there. I'll add your version if you post it on this list 
>or
>send it to me.

Sorry for not expaining this correctly.  I added a method to KScribble.java 
like the following:

private String i18n (String lit) {
   return tr(lit);

}

I do not have cvs setup for KDE.  I am using the sources from the KDE WebCVS 
when I want to look at the sources.  I hope to remedy this soon so I can 
hopefully help you on this instead of just feeding problems to you.

>This compiles, but it crashes:
>
>private static final int ID_HELP_WHATS_THIS = 1;
>	...
>
>	QToolButton btnwhat = QWhatsThis.whatsThisButton(toolBar());
>	QToolTip.add(btnwhat, "What's this...?");
>	toolBar().insertWidget(ID_HELP_WHATS_THIS, btnwhat.sizeHint().width(),
>btnwhat);
>
>I'm investigating what's wrong.
I had not problem with this at all.  It worked beautifully.  Actually it is 
close to what I had but I was missing something.  I should have looked 
closer but was tired.

> > I tried the buffer.load( filename, format, conv) method.
> >
The same problem with the buffer.save method.

What I mentioned in the other e-mail about KMainWindow and KTMainWindow 
please ignore for now.  If the other e-mail goes through.  Still off topic I 
know but KTMainWindow doc says it is deprecated but the tutorials for the 
xmlgui still use it.  What is the way to go?

The following are from memory so please excuse me if they are not exactly 
correct.


void  viewportDragEnterEvent ( QDragEnterEvent e) {
  e.accept(QImageDrag.canDecode(e));
  action = DRAG;
}

QImageDrag.canDecode(e) crashes with a recursive error 2.  I tried multiple 
ways of doing this but could not get it work.  The canDecode is a static 
method but I tried with instantiating objects as well.  I could not get the 
kscribble.cpp to work either.  It was not crashing but it would hang.

void  viewportDragMoveEvent ( QDragMoveEvent e) {
  QImage img = new QImage();
  if ( QImageDrag.decode(e, img) ){

QImageDrag.decode(e,img) crashes with a recursive error 2 as well.  I got 
here because I commented out the   e.accept(QImageDrag.canDecode(e)); in the 
previous just to see what would happen.  I tried multiple was of this as 
well.

Still it was late so could be my fault.

There is also a reference to the following:
QScrollView::viewportPaintEvent(e);

I did not implement this as I am not sure what it does exactly.  I did read 
the docs but could not figure out if it was needed or not.  If it is it is a 
static method and does not exist in the java bindings as such.  I will take 
a closer look at this later unless you have the time to explain it here.  
Maybe it is a method call that I did not see last night?

I will send the sources later today.  They are still rough and not really 
ready but at least you will see what I am talking about.

Thanks again


Kenneth

>From: Richard Dale <Richard_Dale@tipitina.demon.co.uk>
>Reply-To: kde-java@kde.org
>To: kde-java@kde.org
>Subject: Re: [Kde-java] Some questions - long - KScribble in java
>Date: Mon, 11 Feb 2002 16:54:52 +0000
>
>On Monday 11 February 2002 9:48 am, KJ P wrote:
>
> > 1)  KScribble uses the following
> >
> > pFileMenu->insertItem(BarIcon("filenew"), i18n("&New"), ID_FILE_NEW);
> > pFileMenu->insertItem(BarIcon("fileopen"), i18n("&Open..."), 
>ID_FILE_OPEN);
> >
> > I can not find BarIcon.  Is it missing or have I missed something.
>I've had a look - and it is missing because it's a function call rather 
>than a
>static method of KIconLoader. So that needs to be fixed up by hand - in 
>java
>the functions at the end of kiconloader.h would appear as KIconLoader 
>static
>methods.
>
> > Also, when looking at KBase.java example it uses KStdAction.  Which is 
>used
> > as a standard both or should KStdAction be used?  I guess this is off 
>topic
> > for this list but hope to get an answer here.
>
>From KStdAction.java:
>
>  In general, using standard actions should be a drop in replacement
>  for regular actions.  For example, if you previously had:
>
>  <PRE>
>  KAction newAct = new KAction(i18n("&New"), QIconSet(BarIcon("filenew")),
>                                KStdAccel.key(KStdAccel.New), this,
>                                SLOT("fileNew()"), actionCollection());
>  </PRE>
>
>  You could drop that and replace it with:
>
>  <PRE>
>  KAction newAct = KStdAction.openNew(this, SLOT("fileNew()"),
>                                        actionCollection());
>  </PRE>
>
>So maybe BarIcon() isn't needed so much anymore.
>
> > 2) Does the i18n not exist for java?  KBase.java uses tr() so instead I
> > wrote an i18n method which calls tr() that way I did not have to change 
>all
> > the i18n code.  Is the tr() method going to be used instead of the i18n?
>Yes, it should be there. I'll add your version if you post it on this list 
>or
>send it to me.
>
> > 3) Could someone give me an example of using the QWhatsThis.  In
> > kscribble.cpp it is as follows:
> >
> > QToolButton *btnwhat = QWhatsThis::whatsThisButton(toolBar());
> > QToolTip::add(btnwhat, i18n("What's this...?"));
> > toolBar()->insertWidget(ID_HELP_WHATS_THIS, btnwhat->sizeHint().width(),
> > btnwhat);
> >
> > I have tried all sorts of things to get this working but to no avail.
>This compiles, but it crashes:
>
>private static final int ID_HELP_WHATS_THIS = 1;
>	...
>
>	QToolButton btnwhat = QWhatsThis.whatsThisButton(toolBar());
>	QToolTip.add(btnwhat, "What's this...?");
>	toolBar().insertWidget(ID_HELP_WHATS_THIS, btnwhat.sizeHint().width(),
>btnwhat);
>
>I'm investigating what's wrong.
>
>Here is some QWhatsThis() code which works:
>
>     button =
>             new QPushButton("Top Level\nWidget",this);
>     QWhatsThis.add(button,
>         "Button\n\n"
>         + "This button is used as the top\n"
>         + "level widget for this example. It\n"
>         + "is very safe to click the button\n"
>         + "because it doesn't do anything.\n");
>     setCentralWidget(button);
>
> > 4) While reading options and using the readListEntry for recentFiles I 
>get
> > a error linkage not satisfied error.  I have tried both versions of the
> > method call for java.
> >   // initialize the recent file list
> >   config->readListEntry("Recent Files",recentFiles);
> >
> >   My code (example):
> >
> >   ArrayList recentFiles = new ArrayList();
> >   config.readListEntry("Recent Files",recentFiles);
> >
> > Sorry I can not give the exact error message as I am writing from memory
> > and do not have the code here.  I can of course provide this if needed
> > later.
>That method needs fixing up by hand. At the moment it is passing the value 
>of
>'recentFiles' to config.readListEntry(), but isn't converting the returned
>value of the list back to java.
>
>On the other hand:
>
>ArrayList recentFiles = config.readListEntry("Recent Files");
>
>A function returning a C++ list would be easier to convert than a void
>procedure.
>
> > 5) When trying to load an image from open file list in kscribbledoc.cpp
> >
> >   /////////////////////////////////////////////////
> >   // TODO: Add your document opening code here
> > 	if(!buffer.load( filename, format ))
> > 		return false;
> > 	size=buffer.size(); /////////////////////////////////////////////////
> >
> > I tried the buffer.load( filename, format, conv) method.
> >
> >    format is difined as a char in the C++ library version but in the 
>java
> > binding it is a String.  I could not for the life of me get this to 
>work.
> > I finally used !buffer.load( filename ) and it worked perfectly.
> >
> > My question is is this an error or have I done something wrong?  
>Probably I
> > did something wrong but just had to ask.
>It looks like a bug - I'll look into it.
>
> > Sorry for so many newbie quesions.  I have others but I like to dig.
>No problem, keep coming up with more feedback like this..
>
> > The KScribble in java works great so far.  There is no difference in 
>look
> > and feel nor speed so far.  This is great.
>Just slower start up time is the main difference.
>
> > I will post the code for your examples as soon as I get it cleaned up.  
>I
> > have stuff commented out all over the place and the toolbar does not 
>work
> > yet I think because of the BarIcon that I mentioned before.
>It would be good to add a java KScribble to the kdebindings examples. It's 
>an
>excellent test program - I can just keep fixing the problems you describe
>until we get it fully working.
>
> > I did all of this yesterday (Sunday) while learning the Qt and KDE stuff 
>at
> > the same time.  I think this is a testimonial to the java bindings.
>Yes, that's encouraging for me too..
>
>-- Richard
>_______________________________________________
>Kde-java mailing list
>Kde-java@mail.kde.org
>http://mail.kde.org/mailman/listinfo/kde-java




_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx