|
From: Jeroen W. <Jer...@kd...> - 2005-09-04 09:42:51
|
Ben Goodrich wrote:
>Hi,
>
Hi!
>I am attempting to add the "Pipe to Console" functionality to kile 1.8.1 -- the
>same as for kate --and would appreciate tremendously some guidance. It seems as
>if this should not be too difficult. I know some C++ but have never hacked a KDE
>application before, so I do not quite grasp how all the parts work together yet.
>Here are the files that I think are relevant in kile and kate and with which I
>am familiar:
>
>
>
>It seems as if I need to add a code chunk like this into kileui.rc
>
> <Menu name="tools"><text>&Tools</text>
> <Action name="tools_pipe_to_terminal"/>
> </Menu>
>
>
>
This is only step one. You also have to create a KAction instance. The
above lines only tell Kile, where this action should
be placed in the GUI. See kile.cpp:setupActions for tons of examples.
>And then I see two parts of katemainwindow.cpp (which use functionality from
>kateconsole)
>
> // pipe to terminal action
> if (kapp->authorize("shell_access"))
> new KAction(i18n("&Pipe to Console"), "pipe", 0, this,
>SLOT(slotPipeToConsole()), actionCollection(), "tools_pipe_to_terminal");
>
>
You would put these lines in kile.cpp:setupActions.
>[snip]
>void KateMainWindow::slotPipeToConsole ()
>{
> if (!console)
> return;
>
> Kate::View *v = m_viewManager->activeView();
>
> if (!v)
> return;
>
> if (v->getDoc()->hasSelection ())
> console->sendInput (v->getDoc()->selection());
> else
> console->sendInput (v->getDoc()->text());
>}
>
>
>
You could place the slot in kile.cpp if you choose to. Don't forget to
add the slot declaration to kile.h.
>Where would I put similar code into kile? Also, do I need to do anything special
>to get the Pipe to Console to show up in Configure Toolbars and Configure
>Shortcuts in kile?
>
>
Since you would have created a KAction, it will automatically appear in
those dialogs.
best,
Jeroen
|