• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KHTML

  • sources
  • kde-4.12
  • kdelibs
  • khtml
  • java
kjavaappletwidget.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE project
2  *
3  * Copyright (C) 2000 Richard Moore <rich@kde.org>
4  * 2000 Wynn Wilkes <wynnw@caldera.com>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #include "kjavaappletwidget.h"
23 #include "kjavaappletserver.h"
24 
25 #include <kwindowsystem.h>
26 #include <kdebug.h>
27 #include <klocale.h>
28 
29 #include <QtGui/QLabel>
30 
31 #ifndef Q_WS_X11
32 #define QXEmbed QWidget
33 #endif
34 
35 // For future expansion
36 class KJavaAppletWidgetPrivate
37 {
38 friend class KJavaAppletWidget;
39 private:
40  QLabel* tmplabel;
41 };
42 
43 int KJavaAppletWidget::appletCount = 0;
44 
45 KJavaAppletWidget::KJavaAppletWidget( QWidget* parent )
46  : QX11EmbedContainer ( parent ),
47  d(new KJavaAppletWidgetPrivate)
48 {
49  //setProtocol(QXEmbed::XPLAIN);
50 
51  m_applet = new KJavaApplet( this );
52 
53  d->tmplabel = new QLabel( this );
54  d->tmplabel->setText( KJavaAppletServer::getAppletLabel() );
55  d->tmplabel->setAlignment( Qt::AlignCenter );
56  d->tmplabel->setWordWrap( true );
57  d->tmplabel->setFrameStyle( QFrame::StyledPanel | QFrame::Sunken );
58  d->tmplabel->show();
59 
60  m_swallowTitle.sprintf( "KJAS Applet - Ticket number %u", appletCount++ );
61  m_applet->setWindowName( m_swallowTitle );
62 }
63 
64 KJavaAppletWidget::~KJavaAppletWidget()
65 {
66  delete m_applet;
67  delete d;
68 }
69 
70 void KJavaAppletWidget::showApplet()
71 {
72 #ifdef Q_WS_X11
73  connect( KWindowSystem::self(), SIGNAL(windowAdded(WId)),
74  this, SLOT(setWindow(WId)) );
75 
76  //Now we send applet info to the applet server
77  if ( !m_applet->isCreated() )
78  m_applet->create();
79 #endif
80 }
81 
82 void KJavaAppletWidget::setWindow( WId w )
83 {
84 #ifdef Q_WS_X11
85  //make sure that this window has the right name, if so, embed it...
86  KWindowInfo w_info = KWindowSystem::windowInfo( w, NET::WMVisibleName | NET::WMName );
87  if ( m_swallowTitle == w_info.name() ||
88  m_swallowTitle == w_info.visibleName() )
89  {
90  KWindowSystem::setState(w, NET::Hidden | NET::SkipTaskbar | NET::SkipPager);
91  kDebug(6100) << "swallowing our window: " << m_swallowTitle
92  << ", window id = " << w << endl;
93  delete d->tmplabel;
94  d->tmplabel = 0;
95 
96  // disconnect from KWM events
97  disconnect( KWindowSystem::self(), SIGNAL(windowAdded(WId)),
98  this, SLOT(setWindow(WId)) );
99 
100  embedClient( w );
101  setFocus();
102  }
103 #else
104  //TODO
105 #endif
106 }
107 
108 QSize KJavaAppletWidget::sizeHint() const
109 {
110  kDebug(6100) << "KJavaAppletWidget::sizeHint()";
111  QSize rval = QX11EmbedContainer::sizeHint();
112 
113  if( rval.width() == 0 || rval.height() == 0 )
114  {
115  if( width() != 0 && height() != 0 )
116  {
117  rval = QSize( width(), height() );
118  }
119  }
120 
121  kDebug(6100) << "returning: (" << rval.width() << ", " << rval.height() << ")";
122 
123  return rval;
124 }
125 
126 void KJavaAppletWidget::resize( int w, int h )
127 {
128  if( d->tmplabel )
129  {
130  d->tmplabel->resize( w, h );
131  m_applet->setSize( QSize( w, h ) );
132  }
133 
134  QX11EmbedContainer::resize( w, h );
135 }
136 
137 void KJavaAppletWidget::showEvent (QShowEvent * e) {
138  QX11EmbedContainer::showEvent(e);
139  if (!applet()->isCreated() && !applet()->appletClass().isEmpty()) {
140  // delayed showApplet
141  if (applet()->size().width() <= 0)
142  applet()->setSize (sizeHint());
143  showApplet();
144  }
145 }
146 
147 #include "kjavaappletwidget.moc"
KJavaAppletWidget::setWindow
void setWindow(WId w)
This slot is called by KWin when new windows are added.
Definition: kjavaappletwidget.cpp:82
KJavaApplet::setWindowName
void setWindowName(const QString &title)
Set the window title for swallowing.
Definition: kjavaapplet.cpp:165
kjavaappletserver.h
kdebug.h
KJavaAppletWidget::sizeHint
QSize sizeHint() const
Definition: kjavaappletwidget.cpp:108
KWindowInfo::visibleName
QString visibleName() const
KJavaAppletWidget::resize
void resize(int, int)
Definition: kjavaappletwidget.cpp:126
d
#define d
Definition: khtmlfind.cpp:42
KJavaAppletServer::getAppletLabel
static QString getAppletLabel()
This allows the KJavaAppletWidget to display some feedback in a QLabel while the applet is being load...
Definition: kjavaappletserver.cpp:165
KWindowSystem::windowInfo
static KWindowInfo windowInfo(WId win, unsigned long properties, unsigned long properties2=0)
QWidget
KWindowInfo
KJavaApplet::isCreated
bool isCreated()
Returns status of applet- whether it's been created or not.
Definition: kjavaapplet.cpp:72
KJavaAppletWidget
Definition: kjavaappletwidget.h:82
kDebug
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
klocale.h
KJavaAppletWidget::~KJavaAppletWidget
~KJavaAppletWidget()
Definition: kjavaappletwidget.cpp:64
KJavaApplet
Definition: kjavaapplet.h:50
KJavaApplet::create
void create()
Send message to AppletServer to create this applet's frame to be swallowed and download the applet cl...
Definition: kjavaapplet.cpp:180
KJavaAppletWidget::KJavaAppletWidget
KJavaAppletWidget(QWidget *parent=0)
Definition: kjavaappletwidget.cpp:45
KJavaApplet::setSize
void setSize(QSize size)
Set the size of the applet.
Definition: kjavaapplet.cpp:128
KJavaAppletWidget::appletCount
static int appletCount
Definition: kjavaappletwidget.h:115
KWindowSystem::setState
static void setState(WId win, unsigned long state)
kjavaappletwidget.h
KWindowSystem::self
static KWindowSystem * self()
KJavaAppletWidget::showApplet
void showApplet()
Tells the AppletServer to create, initialize, and show the Applet.
Definition: kjavaappletwidget.cpp:70
KJavaAppletWidget::showEvent
void showEvent(QShowEvent *)
Definition: kjavaappletwidget.cpp:137
KJavaAppletWidget::applet
KJavaApplet * applet()
Returns a pointer to the KJavaApplet.
Definition: kjavaappletwidget.h:95
QLabel
kwindowsystem.h
KWindowInfo::name
QString name() const
QSize
QX11EmbedContainer
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:51:22 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal