|
From: Ben G. <goo...@fa...> - 2005-09-05 01:55:33
|
Hi Jeroen,
OK. I followed your instructions and have made some progress. The new
functions are declared in the proper header files and I made the
KAction. Also, I made a public member function called sendInput in
kilekonsolewidget.cpp / .h based on a similar function in Kate.
Here is my function:
void Kile::slotPipeToConsole ()
{
Kile::activateView *v = m_viewManager->activateView();
if (!v)
return;
if (v->getDoc()->hasSelection ())
KileWidget::Konsole->sendInput (v->getDoc()->selection());
else
KileWidget::Konsole->sendInput (v->getDoc()->text());
}
And, I get these compiler errors:
kile.cpp: In member function 'void Kile::slotPipeToConsole()':
kile.cpp:722: error: 'v' was not declared in this scope
kile.cpp:722: error: no matching function for call to
'KileView::Manager::activateView()'
kileviewmanager.h:92: note: candidates are: void
KileView::Manager::activateView(QWidget*, bool)
kile.cpp:728: error: expected unqualified-id before '->' token
kile.cpp:730: error: expected unqualified-id before '->' token
Clearly, the activateView function takes two arguments (making it
different from the activeView function in Kate that governs
slotPipeToConsole). And I am looking at the implementation of
void Kile::activateView(QWidget* w, bool updateStruct /* = true */ )
//Needs to be QWidget because of QTabWidget::currentChanged
but don't quite understand what I should pass as a pointer to the object
of class QWidget. I think if I could figure that out, the other errors
would go away.
Thanks,
Ben
Jeroen Wijnhout wrote:
> 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
>
>
|