Hi Dirk,
before I take my very valuable time and answer your
questions I have some for
you...
1) When you were in the editor did you look at the help
menu? There are now
extensive docs.
2) When you were editing did you press the button in the
lower left of the
text editor that says "Functions ..." and look
around the function browser?
3) I really don't have to ask this one... because you would
have had to pay
attention to the others... We were so depressed that we
always had samples
and they never made it into the editor that we have them
included with the
editor now... Did you check the menu under
Tools>Editor>Examples?
On Saturday 29 March 2008 7:05:14 pm almatic wrote:
> Hi,
>
> I'm trying to make use of some of the new features in
kommander 3.5.9, but
> I have some questions.
That's a good start.
>
> 1. What are 'popupmenus' good for ?
Right click all over KDE and you will see.
> The feature sounds nice but I'm unable
> to figure out how to use them. Does anyone have a
sample, or some simple
> sample code ?
Look in the examples under tableselect.kmdr. You have to do
three things after
you put the PopupMenu widget on your form...
1) create the menu items and settings - use the function
browser
2) write whatever actions you want
3) hook up the contextMenuRequested(int,int) signal on the
widget you want to
call it to your popup(int,int) slot on the menu icon. The
easy way is the
second button from the left on the toolbar next to the
pointer icon. Then
drag from you calling widget to your receiving widget and
select the signal
and slot. It saves having to scroll through widgets.
Because the menus can receive index numbers you should set
them and you can
put your script in the menu, or call another widget with
that item. Index
numbers have no bearing on the order in the menu, just the
key to look up the
menu. Since script type widgets can now receive parameters
(and retrun
values) I like to simplify. This is what my menu objects
look like
//get the calling index
m = Self.item(i)
if m == 1 then //menu text here
//handle menu 1
elseif m == 2 then // whatever
//handle 2
else
message_error("unrecognized menu item")
endif
The above is limited to 2 items before it gives me an error
that basically
says "hey dummy, you forgot to give that last menu item
a handler". Generally
I initialize menus in the dialog initilization, or ir I have
a lot of tabs I
initialize each tab individually and call it from the main
dialog
initialization. That way I can sort it out when I get to
500K dialogs.
>
> 2. How can I set a specific tab active from the
tabwidget. Let's say I have
> a combo-box and want to set a specific tab active
depending on which combo
> item is chosen.
Signal and slot from activated() or widgetTextChanged to a
script that calls
TabWidget.setCurrentIndex. In fact if your combo has the
tabs in order you
can use a signal the sends the index, I think
activated(int), and then use
Self.item(0) for the value to send and you do it all with
one line.
>
> 3. How can I make a specific tab invisible/visible
depending on specific
> choices (for example to let users choose between
simple/advanced gui etc.).
I was just wondering that same thing. Turns out it's not so
easy. If you look
at the toolbox you will see what I mean. It gets ugly and
flickers if you try
to set 2-3 pages in the editor, but that is because the
editor is an old
fork. However you can add and remove pages on the fly there
bu adding
widgets. This is the same thing the TabWidget has and for
some inexplicable
reason Michal added long ago the ability to add a widget...
but then he just
copied a panel from another page. It's worthless and you
can't remove it.
Adding a widget means you could add a grid, or a text
editor, but for a group
of widgets your best bet is to make a GroupBox and add it on
initiallzation... There is a very slight flicker, not bad.
This works with
the toolbox, but not the TabWidget. Strangely there is no
tabVisible(bool)
property. Things will be better in KDE4.
One trick is to layout two panels in the same space, side by
side or top and
bottom. Then make one invisible on initialization. Now
toggle visiblity of
both. You can make collapsing docks, popup DatePickers and
more like this.
>
> 4. Is there a way, apart from temp files, to save the
value of variables
> beyond the lifetime of a dialog (options dialog for
example) ?
> Or can I maybe return the values to the main-dialog in
some way ?
Yes, lots of ways. There are the settings functions, but as
they all write
back to the Kommander rc file I strongly advise minimal use.
There are file
functions too and you can access the current directory with
_KDDIR, the
global "pwd" for Kommander. I like this...
===> file with discrete lines
map 0|val1 1|val2 2
I am value 1
and I'm 2
===> on initialization include this
fdata = file_read(_KDDIR+"/session")
array_indexedFromString("line", fdata,
"n")
array_fromString("map", str_replace(line[0],
"|", "n"))
//get value 1
fist = line[map["val1"]]
//make #2 global
_val2 = line[map["val2"]]
debug(first+"n"_val2)
Now here's a really cool trick... in initialization...
createWidget("savestate", "TextEdit",
"Form1")
fdata = file_read(_KDDIR+"/session")
savestate.setText(fdata)
Now you can manipulate variables at any time like so...
//get an indexed array
array_indexedFromString("s", savestate.text,
"n")
array_fromString("map", str_replace(s[0],
"|", "n"))
//a value is now mapped for reading or writing - let's
write
s[map["val2"]] = "I'm tired of being
#2"
//now save it
savestate.setText(array_indexedToString("s",
"n"))
Add a new setting with
s[0] = "|val3t"+array_count(s) //for a zero based
index the count from 1...
savestate.append("nHello from value 3")
in case you didn't know n is new line and t is tab, what
we use in Kommander
to split things... see the docs.
>
> greetings and thank you for your help
> Dirk
After you play with that try the Action Proxy and play with
a MainWindow.
--
Eric Laffoon
Project Lead - kdewebdev module
_______________________________________________
Kommander mailing list
Kommander kdewebdev.org
http://mail.kdewebdev.org/mailman/listinfo/kommander
|