KHTMLImage::KHTMLImage(QWidget *parentWidget, const char *widgetName, QObject *parent, const char *name, KHTMLPart::GUIProfile prof) : KParts::ReadOnlyPart(parent, name), m_image(0) { KHTMLPart *parentPart = ::qt_cast< KHTMLPart * >(parent); setInstance(KHTMLImageFactory::instance(), prof == KHTMLPart::BrowserViewGUI && !parentPart); QVBox *box = new QVBox(parentWidget, widgetName); m_khtml = new KHTMLPart(box, widgetName, this, "htmlimagepart", prof); m_khtml->setAutoloadImages(true); m_khtml->widget()->installEventFilter(this); connect(m_khtml->view(), SIGNAL(finishedLayout()), this, SLOT(restoreScrollPosition())); setWidget(box); // VBox can't take focus, so pass it on to sub-widget box->setFocusProxy(m_khtml->widget()); m_ext = new KHTMLImageBrowserExtension(this, "be"); // Remove unnecessary actions. KAction *encodingAction = actionCollection()->action("setEncoding"); if(encodingAction) { encodingAction->unplugAll(); delete encodingAction; } KAction *viewSourceAction = actionCollection()->action("viewDocumentSource"); if(viewSourceAction) { viewSourceAction->unplugAll(); delete viewSourceAction; } KAction *selectAllAction = actionCollection()->action("selectAll"); if(selectAllAction) { selectAllAction->unplugAll(); delete selectAllAction; } // forward important signals from the khtml part // forward opening requests to parent frame (if existing) KHTMLPart *p = ::qt_cast< KHTMLPart * >(parent); KParts::BrowserExtension *be = p ? p->browserExtension() : m_ext; connect(m_khtml->browserExtension(), SIGNAL(openURLRequestDelayed(const KURL &, const KParts::URLArgs &)), be, SIGNAL(openURLRequestDelayed(const KURL &, const KParts::URLArgs &))); connect(m_khtml->browserExtension(), SIGNAL(popupMenu(KXMLGUIClient *, const QPoint &, const KURL &, const KParts::URLArgs &, KParts::BrowserExtension::PopupFlags, mode_t)), m_ext, SIGNAL(popupMenu(KXMLGUIClient *, const QPoint &, const KURL &, const KParts::URLArgs &, KParts::BrowserExtension::PopupFlags, mode_t))); connect(m_khtml->browserExtension(), SIGNAL(enableAction(const char *, bool)), m_ext, SIGNAL(enableAction(const char *, bool))); m_ext->setURLDropHandlingEnabled(true); }
KHTMLImage::KHTMLImage( QWidget *parentWidget, const char *widgetName, QObject *parent, const char *name ) : KParts::ReadOnlyPart( parent, name ) { setInstance( KHTMLImageFactory::instance() ); QVBox *box = new QVBox( parentWidget, widgetName ); m_khtml = new KHTMLPart( box, widgetName, this, "htmlimagepart" ); m_khtml->setAutoloadImages( true ); setWidget( box ); // VBox can't take focus, so pass it on to sub-widget box->setFocusProxy( m_khtml->widget() ); m_ext = new KHTMLImageBrowserExtension( this, "be" ); // Remove unnecessary actions. KAction *encodingAction = actionCollection()->action( "setEncoding" ); if ( encodingAction ) { encodingAction->unplugAll(); delete encodingAction; } KAction *viewSourceAction= actionCollection()->action( "viewDocumentSource" ); if ( viewSourceAction ) { viewSourceAction->unplugAll(); delete viewSourceAction; } KAction *selectAllAction= actionCollection()->action( "selectAll" ); if ( selectAllAction ) { selectAllAction->unplugAll(); delete selectAllAction; } connect( m_khtml->browserExtension(), SIGNAL( popupMenu( KXMLGUIClient *, const QPoint &, const KURL &, const QString &, mode_t ) ), m_ext, SIGNAL( popupMenu( KXMLGUIClient *, const QPoint &, const KURL &, const QString &, mode_t ) ) ); connect( m_khtml->browserExtension(), SIGNAL( enableAction( const char *, bool ) ), m_ext, SIGNAL( enableAction( const char *, bool ) ) ); m_ext->setURLDropHandlingEnabled( true ); }