1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
#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 TQString& ) ), this, TQT_SLOT( slotOpenUrl( const TQString & ) ) );
s->setEditable(true);
kdDebug() << "KShell window created" << endl;
}
ShellWindow::~ShellWindow()
{
delete m_partProcess;
}
void ShellWindow::hop()
{
kdDebug() << "hop called!" << endl;
}
void ShellWindow::slotOpenUrl( const TQString &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"
|