You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tdebindings/xparts/xpart_notepad/shell_xparthost.cpp

81 lines
2.0 KiB

#include "xparthost_kpart.h"
#include "shell_xparthost.h"
#include <dcopclient.h>
#include <dcopobject.h>
#include <kapplication.h>
#include <kstdaction.h>
#include <kaction.h>
#include <kmainwindow.h>
#include <kprocess.h>
#include <kparts/mainwindow.h>
#include <kdebug.h>
ShellWindow::ShellWindow()
: KParts::MainWindow()
{
m_host = new XPartHost_KPart( this, 0, this, "parthost" );
setCentralWidget( m_host->widget() );
connect(m_host, TQT_SIGNAL( actionsInitialized() ), this, TQT_SLOT( mergeGUI() ) );
// Launch our XPart child.
m_partProcess = new KProcess;
*m_partProcess << "./xp_notepad"
<< kapp->dcopClient()->appId() << m_host->objId();
m_partProcess->start();
// Init our Gui
(void) new KAction( "Hop", 0, this, TQT_SLOT(hop()), actionCollection(), "hop" );
KStdAction::quit( this, TQT_SLOT( close() ), actionCollection() );
KSelectAction *s = new KSelectAction( "http://www.kde.org" , 0,
actionCollection(), "location" );
connect( s, TQT_SIGNAL(activated( const TTQString& ) ), this, TQT_SLOT( slotOpenUrl( const TTQString & ) ) );
s->setEditable(true);
kdDebug() << "KShell window created" << endl;
}
ShellWindow::~ShellWindow()
{
delete m_partProcess;
}
void ShellWindow::hop()
{
kdDebug() << "hop called!" << endl;
}
void ShellWindow::slotOpenUrl( const TTQString &url )
{
kdDebug() << "this=" << this;
kdDebug() << "url=" << url << endl;
m_host->openURL(url.latin1());
}
void ShellWindow::mergeGUI()
{
qDebug("initGUI");
setXMLFile("shell_xparthost.rc");
createGUI( m_host );
m_host->widget()->setFocus();
kdDebug() << "focus set to embedded widget" << endl;
}
int main( int argc, char **argv )
{
KApplication app( argc, argv, "xparthost_shell" );
app.dcopClient()->registerAs("xparthost_shell");
ShellWindow *w = new ShellWindow;
w->resize(500, 500);
w->show();
return app.exec();
}
#include "shell_xparthost.moc"