diff options
author | Vincent Untz <vuntz@gnome.org> | 2012-03-02 15:36:01 +0100 |
---|---|---|
committer | Vincent Untz <vuntz@gnome.org> | 2012-03-02 15:36:01 +0100 |
commit | 94db110fab0dcea1f8f87efce6ce1be15a67dfc7 (patch) | |
tree | 5e04297a2a3a811f9097de50160c4533887a141e /xembed/tests/qt-client.cpp | |
parent | a988ef565a037a39aecca754a2f9d2f43e5c5131 (diff) | |
parent | 23d7d60971b8428429f120cbf77f3fcf70304b67 (diff) | |
download | xdg-specs-94db110fab0dcea1f8f87efce6ce1be15a67dfc7.tar.xz |
xembed: Merge import from CVS
Diffstat (limited to 'xembed/tests/qt-client.cpp')
-rw-r--r-- | xembed/tests/qt-client.cpp | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/xembed/tests/qt-client.cpp b/xembed/tests/qt-client.cpp new file mode 100644 index 0000000..ef40739 --- /dev/null +++ b/xembed/tests/qt-client.cpp @@ -0,0 +1,127 @@ +#include <kapp.h> +#include <qhbox.h> +#include <qlabel.h> +#include <qlineedit.h> +#include <qlayout.h> +#include <qpushbutton.h> +#include <qtimer.h> + +#include <qxembed.h> + +#include "qt-client.h" +#include "qt-common.h" + +XEmbedQtButtonBox::XEmbedQtButtonBox (QWidget *parent, XEmbedQtClient *client) + : QWidget (parent) +{ + QHBoxLayout *layout = new QHBoxLayout (this); + layout->setAutoAdd (TRUE); + + QPushButton *button; + + button = new QPushButton( "&Add", this ); + QObject::connect (button, SIGNAL(clicked()), client, SLOT(addButtons())); + + button = new QPushButton( "&Remove", this ); + QObject::connect (button, SIGNAL(clicked()), this, SLOT(close())); +} + + +XEmbedQtClient::XEmbedQtClient () +{ + setFrameStyle (QFrame::Box | QFrame::Sunken); + + QVBoxLayout *vlayout = new QVBoxLayout (this); + + vlayout->setAutoAdd (TRUE); + vlayout->setMargin (5); + + hbox_ = new QHBox (this); + + new QLabel ("Qt", hbox_); + + new QLineEdit (hbox_); + + QPushButton *button; + + button = new QPushButton( "&Close", hbox_ ); + QObject::connect (button, SIGNAL(clicked()), this, SLOT(close())); + + button = new QPushButton( "&Blink", hbox_ ); + QObject::connect (button, SIGNAL(clicked()), this, SLOT(blink())); + + button = new QPushButton( "Add >K+", hbox_ ); + QObject::connect (button, SIGNAL(clicked()), this, SLOT(addGtkChild())); + + button = new QPushButton( "Add &Qt", hbox_ ); + QObject::connect (button, SIGNAL(clicked()), this, SLOT(addQtChild())); + + addButtons(); +} + +void +XEmbedQtClient::blink() +{ + hide (); + + QTimer *timer = new QTimer ( this ); + QObject::connect (timer, SIGNAL(timeout()), this, SLOT(show())); + timer->start (1000, TRUE); +} + +void +XEmbedQtClient::addGtkChild() +{ + new XEmbedQtChildSite (this, FALSE, FALSE); +} + +void +XEmbedQtClient::addQtChild() +{ + new XEmbedQtChildSite (this, FALSE, TRUE); +} + +void +XEmbedQtClient::addButtons () +{ + XEmbedQtButtonBox *box = new XEmbedQtButtonBox (hbox_, this); + box->show(); +} + +int main( int argc, char **argv ) +{ + KApplication a( argc, argv, "qt-client" ); + WId embedder_xid, client_xid; + XEmbedQtClient *client; + + if (argc != 1 && argc != 2) + { + fprintf (stderr, "Usage: qt-client [WINDOW_ID]\n"); + exit (1); + } + + QXEmbed::initialize (); + + if (argc == 2) + { + embedder_xid = strtol (argv[1], NULL, 0); + if (embedder_xid == 0) + { + fprintf (stderr, "Invalid window id '%s'\n", argv[1]); + exit (1); + } + + client = new XEmbedQtClient (); + QXEmbed::embedClientIntoWindow (client, embedder_xid); + } + else + { + client = new XEmbedQtClient (); + printf ("%d\n", client->winId()); + fflush (stdout); + } + + a.setMainWidget( client ); + + return a.exec(); +} |