Esempio n. 1
0
KDE_NO_EXPORT void KlashBrowserExtension::requestOpenUrl (const KUrl & url, const QString & /*target*/, const QString & /*service*/) {
    KParts::OpenUrlArguments args;
    //FIXME what replaces those?
    //args.frameName = target;
    //args.serviceType = service;
    emit openUrlRequest (url, args);
}
bool KHTMLSideBar::urlSelected( const QString &url, int button,
                                int state, const QString &_target,
                                const KParts::OpenUrlArguments& args,
                                const KParts::BrowserArguments& browserArgs )
{
    if (button == Qt::LeftButton ) {
        if (_target.toLower() == "_self") {
            openUrl(url);
        } else if (_target.toLower() == "_blank") {
            emit openUrlNewWindow(completeURL(url).url(), args);
        } else { // isEmpty goes here too
            emit openUrlRequest(completeURL(url).url(), args);
        }
        return true;
    }
    if (button == Qt::MidButton) {
        emit openUrlNewWindow(completeURL(url).url(),
                              args);
        return true;
    }
    // A refresh
    if (button == 0 && _target.toLower() == "_self") {
        openUrl(completeURL(url));
        return true;
    }
    return KHTMLPart::urlSelected(url, button, state, _target, args, browserArgs);
}
Esempio n. 3
0
WelcomePageView::WelcomePageView(QWidget* const parent)
    : KHTMLPart(parent)
{
    widget()->setFocusPolicy(Qt::WheelFocus);
    // Let's better be paranoid and disable plugins (it defaults to enabled):
    setPluginsEnabled(false);
    setJScriptEnabled(false); // just make this explicit.
    setJavaEnabled(false);    // just make this explicit.
    setMetaRefreshEnabled(false);
    setURLCursor(Qt::PointingHandCursor);
    view()->adjustSize();

    // Disable some KHTMLPart actions as they break predefined digiKam actions.
    // We can re-assign the disabled actions later if we ever need to.
    disablePredefinedActions();

    // ------------------------------------------------------------

    connect(browserExtension(), SIGNAL(openUrlRequest(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)),
            this, SLOT(slotUrlOpen(KUrl)));

    connect(ThemeManager::instance(), SIGNAL(signalThemeChanged()),
            this, SLOT(slotThemeChanged()));

    QTimer::singleShot(0, this, SLOT(slotThemeChanged()));
}
Esempio n. 4
0
TestKHTML::TestKHTML()
    : KXmlGuiWindow()
{
#ifndef __KDE_HAVE_GCC_VISIBILITY
    m_factory = new KHTMLGlobal();
#endif

    m_movie = new QMovie(":/pics/progress.gif");
    m_indicator = new QLabel;
    m_indicator->setFixedSize(QSize(24, 24));
    m_indicator->setMovie(m_movie);

    m_part = new KHTMLPart( this, this, KHTMLPart::BrowserViewGUI );
    connect( m_part->browserExtension(), SIGNAL(openUrlRequest(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)),
             this, SLOT(openUrl(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)));

    m_combo = new KComboBox;
    m_combo->setEditable(true);
    connect(m_combo, SIGNAL(returnPressed(QString)), this, SLOT(openUrl(QString)));

    m_goButton = new QToolButton;
    m_goButton->setText("Go");
    connect(m_goButton, SIGNAL(clicked()), this, SLOT(openUrl()));

    m_reloadButton = new QToolButton;
    m_reloadButton->setIcon(KIcon("view-refresh"));
    connect(m_reloadButton, SIGNAL(clicked()), this, SLOT(reload()));

    QHBoxLayout *topLayout = new QHBoxLayout;
    topLayout->addWidget(m_reloadButton);
    topLayout->addWidget(m_combo);
    topLayout->addWidget(m_goButton);
    topLayout->addWidget(m_indicator);
    m_indicator->show();

    QFrame *mainWidget = new QFrame;
    QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget);
    mainLayout->addLayout(topLayout);
    mainLayout->addWidget(m_part->widget());

    setCentralWidget(mainWidget);
    resize(800, 600);
    setupActions();

    m_part->setJScriptEnabled(true);
    m_part->setJavaEnabled(true);
    m_part->setPluginsEnabled(true);
    m_part->setURLCursor(QCursor(Qt::PointingHandCursor));

    connect(m_part, SIGNAL(setWindowCaption(QString)),
            m_part->widget()->topLevelWidget(), SLOT(setCaption(QString)));

    connect(m_part, SIGNAL(started(KIO::Job*)), this, SLOT(startLoading()));
    connect(m_part, SIGNAL(completed()), this, SLOT(finishedLoading()));
}
KonqSideBarWebModule::KonqSideBarWebModule(const KComponentData &componentData, QWidget *parent, const KConfigGroup& configGroup)
    : KonqSidebarModule(componentData, parent, configGroup)
{
    _htmlPart = new KHTMLSideBar();
    _htmlPart->setAutoDeletePart(false);
    connect(_htmlPart, SIGNAL(reload()), this, SLOT(reload()));
    connect(_htmlPart, SIGNAL(completed()), this, SLOT(pageLoaded()));
    connect(_htmlPart,
            SIGNAL(setWindowCaption(QString)),
            this,
            SLOT(setTitle(QString)));
    connect(_htmlPart,
            SIGNAL(openUrlRequest(QString,KParts::OpenUrlArguments,KParts::BrowserArguments)),
            this,
            SLOT(urlClicked(QString,KParts::OpenUrlArguments,KParts::BrowserArguments)));
    connect(_htmlPart->browserExtension(),
            SIGNAL(openUrlRequest(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)),
            this,
            SLOT(formClicked(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)) );
    connect(_htmlPart,
            SIGNAL(setAutoReload()), this, SLOT(setAutoReload()));
    connect(_htmlPart,
            SIGNAL(openUrlNewWindow(QString,KParts::OpenUrlArguments,KParts::BrowserArguments,KParts::WindowArgs)),
            this,
            SLOT(urlNewWindow(QString,KParts::OpenUrlArguments,KParts::BrowserArguments,KParts::WindowArgs)));
    connect(_htmlPart,
            SIGNAL(submitFormRequest(const char*,QString,QByteArray,QString,QString,QString)),
            this,
            SIGNAL(submitFormRequest(const char*,QString,QByteArray,QString,QString,QString)));

    reloadTimeout = configGroup.readEntry("Reload", 0);
    _url = configGroup.readPathEntry("URL", QString());
    _htmlPart->openUrl(_url );
    // Must load this delayed
    QTimer::singleShot(0, this, SLOT(loadFavicon()));
}
Esempio n. 6
0
//-----------------------------------
HtmlView::HtmlView(KoPart *part, KoDocument *doc, QWidget *parent)
    : ViewBase(part, doc, parent)
{
    m_htmlPart = new KHTMLPart( this );
    m_htmlPart->view()->setFrameStyle( QFrame::StyledPanel );
    m_htmlPart->view()->setFrameShadow( QFrame::Sunken );

    QVBoxLayout * l = new QVBoxLayout( this );
    l->setMargin( 0 );
    l->addWidget( m_htmlPart->view() );
    m_htmlPart->show();

    setupGui();

    KParts::BrowserExtension *ext = m_htmlPart->browserExtension();
    if ( ext ) {
        connect( ext, SIGNAL(openUrlRequest(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)), SLOT(slotOpenUrlRequest(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)) );
    }
}
void KonqSidebarTree::slotExecuted( Q3ListViewItem *item )
{
    kDebug(1201) << item;
    if ( !item )
        return;

    if ( !static_cast<KonqSidebarTreeItem*>(item)->isClickable() )
        return;

    KonqSidebarTreeItem *dItem = static_cast<KonqSidebarTreeItem *>( item );

    KParts::OpenUrlArguments args;
    args.setMimeType(dItem->externalMimeType());
    KParts::BrowserArguments browserArgs;
    browserArgs.trustedSource = true; // is this needed?
    KUrl externalURL = dItem->externalURL();
    if ( !externalURL.isEmpty() )
        openUrlRequest( externalURL, args, browserArgs );
}
void KonqSideBarWebModule::urlClicked(const QString& url, const KParts::OpenUrlArguments& args, const KParts::BrowserArguments& browserArgs)
{
    emit openUrlRequest(KUrl(url), args, browserArgs);
}
Esempio n. 9
0
void HtmlView::slotOpenUrlRequest(const KUrl &url, const KParts::OpenUrlArguments &/*arguments*/, const KParts::BrowserArguments &/*browserArguments*/)
{
    emit openUrlRequest( this, url );
}
Esempio n. 10
0
void Session::setUserTitle( int what, const QString &caption )
{
    //set to true if anything is actually changed (eg. old _nameTitle != new _nameTitle )
	bool modified = false;

    // (btw: what=0 changes _userTitle and icon, what=1 only icon, what=2 only _nameTitle
    if ((what == 0) || (what == 2)) 
    {
       	if ( _userTitle != caption ) {
			_userTitle = caption;
			modified = true;
		}
    }

    if ((what == 0) || (what == 1))
	{
		if ( _iconText != caption ) {
       		_iconText = caption;
			modified = true;
		}
	}

    if (what == 11) 
    {
      QString colorString = caption.section(';',0,0);
      qDebug() << __FILE__ << __LINE__ << ": setting background colour to " << colorString;
      QColor backColor = QColor(colorString);
      if (backColor.isValid()){// change color via \033]11;Color\007
          if (backColor != _modifiedBackground)
          {
              _modifiedBackground = backColor;

              // bail out here until the code to connect the terminal display
              // to the changeBackgroundColor() signal has been written
              // and tested - just so we don't forget to do this.
              Q_ASSERT( 0 );

              emit changeBackgroundColorRequest(backColor);
          }
      }
    }

	if (what == 30) 
    {
		if ( _nameTitle != caption ) {
       		setTitle(Session::NameRole,caption);
			return;
		}
	}

    if (what == 31) 
    {
       QString cwd=caption;
       cwd=cwd.replace( QRegExp("^~"), QDir::homePath() );
       emit openUrlRequest(cwd);
	}

    // change icon via \033]32;Icon\007
    if (what == 32) 
    { 
    	if ( _iconName != caption ) {
	   		_iconName = caption;

			modified = true;
		}
    }

    if (what == 50) 
    {
        emit profileChangeCommandReceived(caption);
        return;
    }

	if ( modified )
    	emit titleChanged();
}
Esempio n. 11
0
int main(int argc, char *argv[])
{
    KCmdLineOptions options;
    options.add("+file", ki18n("URL to open"));

    KCmdLineArgs::init(argc, argv, "testkhtml", 0, ki18n("Testkhtml"),
            "1.0", ki18n("a basic web browser using the KHTML library"));
    KCmdLineArgs::addCmdLineOptions(options);

    KApplication a;
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs( );
    if ( args->count() == 0 ) {
	KCmdLineArgs::usage();
	::exit( 1 );
    }

    new KHTMLGlobal;

    KXmlGuiWindow *toplevel = new KXmlGuiWindow();
    KHTMLPart *doc = new KHTMLPart( toplevel, toplevel, KHTMLPart::BrowserViewGUI );

    Dummy *dummy = new Dummy( doc );
    QObject::connect( doc->browserExtension(), SIGNAL(openUrlRequest(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)),
		      dummy, SLOT(slotOpenURL(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)) );

    QObject::connect( doc, SIGNAL(completed()), dummy, SLOT(handleDone()) );

    if (args->url(0).url().right(4).toLower() == ".xml") {
        KParts::OpenUrlArguments args(doc->arguments());
        args.setMimeType("text/xml");
        doc->setArguments(args);
    }

    doc->openUrl( args->url(0) );

    toplevel->setCentralWidget( doc->widget() );
    toplevel->resize( 800, 600);

    QDomDocument d = doc->domDocument();
    QDomElement viewMenu = d.documentElement().firstChild().childNodes().item( 2 ).toElement();
    QDomElement e = d.createElement( "action" );
    e.setAttribute( "name", "debugRenderTree" );
    viewMenu.appendChild( e );
    e = d.createElement( "action" );
    e.setAttribute( "name", "debugDOMTree" );
    viewMenu.appendChild( e );
    e = d.createElement( "action" );
    e.setAttribute( "name", "debugDoBenchmark" );
    viewMenu.appendChild( e );

    QDomElement toolBar = d.documentElement().firstChild().nextSibling().toElement();
    e = d.createElement( "action" );
    e.setAttribute( "name", "editable" );
    toolBar.insertBefore( e, toolBar.firstChild() );
    e = d.createElement( "action" );
    e.setAttribute( "name", "navigable" );
    toolBar.insertBefore( e, toolBar.firstChild() );
    e = d.createElement( "action" );
    e.setAttribute( "name", "reload" );
    toolBar.insertBefore( e, toolBar.firstChild() );
    e = d.createElement( "action" );
    e.setAttribute( "name", "print" );
    toolBar.insertBefore( e, toolBar.firstChild() );

    KAction *action = new KAction(KIcon("view-refresh"),  "Reload", doc );
    doc->actionCollection()->addAction( "reload", action );
    QObject::connect(action, SIGNAL(triggered(bool)), dummy, SLOT(reload()));
    action->setShortcut(Qt::Key_F5);

    KAction *bench = new KAction( KIcon(), "Benchmark...", doc );
    doc->actionCollection()->addAction( "debugDoBenchmark", bench );
    QObject::connect(bench, SIGNAL(triggered(bool)), dummy, SLOT(doBenchmark()));

    KAction *kprint = new KAction(KIcon("document-print"),  "Print", doc );
    doc->actionCollection()->addAction( "print", kprint );
    QObject::connect(kprint, SIGNAL(triggered(bool)), doc->browserExtension(), SLOT(print()));
    kprint->setEnabled(true);
    KToggleAction *ta = new KToggleAction( KIcon("edit-rename"), "Navigable", doc );
    doc->actionCollection()->addAction( "navigable", ta );
    ta->setShortcuts( KShortcut() );
    ta->setChecked(doc->isCaretMode());
    QWidget::connect(ta, SIGNAL(toggled(bool)), dummy, SLOT(toggleNavigable(bool)));
    ta = new KToggleAction( KIcon("document-properties"), "Editable", doc );
    doc->actionCollection()->addAction( "editable", ta );
    ta->setShortcuts( KShortcut() );
    ta->setChecked(doc->isEditable());
    QWidget::connect(ta, SIGNAL(toggled(bool)), dummy, SLOT(toggleEditable(bool)));
    toplevel->guiFactory()->addClient( doc );

    doc->setJScriptEnabled(true);
    doc->setJavaEnabled(true);
    doc->setPluginsEnabled( true );
    doc->setURLCursor(QCursor(Qt::PointingHandCursor));
    a.setTopWidget(doc->widget());
    QWidget::connect(doc, SIGNAL(setWindowCaption(QString)),
		     doc->widget()->topLevelWidget(), SLOT(setCaption(QString)));
    doc->widget()->show();
    toplevel->show();
    doc->view()->viewport()->show();
    doc->view()->widget()->show();


    int ret = a.exec();
    return ret;
}
QObject* WebPluginFactory::create (const QString& _mimeType, const QUrl& url, const QStringList& argumentNames, const QStringList& argumentValues) const
{
    //kDebug() << _mimeType << url << argumentNames;
    QString mimeType (_mimeType.trimmed());
    if (mimeType.isEmpty()) {
        extractGuessedMimeType (url, &mimeType);
    }

    const bool noPluginHandling = WebKitSettings::self()->isInternalPluginHandlingDisabled();

    if (!noPluginHandling && WebKitSettings::self()->isLoadPluginsOnDemandEnabled()) {
        const uint id = pluginId(url, argumentNames, argumentValues);
        if (!mPluginsLoadedOnDemand.contains(id)) {
            FakePluginWidget* widget = new FakePluginWidget(id, url, mimeType);
            connect(widget, SIGNAL(pluginLoaded(uint)), this, SLOT(loadedPlugin(uint)));
            return widget;
        }
    }

    Q_ASSERT(mPart); // should never happen!!
    KParts::ReadOnlyPart* part = 0;
    QWebView* view = (mPart ? mPart->view() : 0);

    if (noPluginHandling || !excludedMimeType(mimeType)) {
        QWebFrame* frame = (view ? view->page()->currentFrame() : 0);
        if (frame) {
            part = createPartInstanceFrom(mimeType, argumentNames, argumentValues, view, frame);
        }
    }

    kDebug() << "Asked for" << mimeType << "plugin, got" << part;

    if (part) {
        connect (part->browserExtension(), SIGNAL (openUrlNotify()),
                 mPart->browserExtension(), SIGNAL (openUrlNotify()));

        connect (part->browserExtension(), SIGNAL (openUrlRequest (KUrl, KParts::OpenUrlArguments, KParts::BrowserArguments)),
                 mPart->browserExtension(), SIGNAL (openUrlRequest (KUrl, KParts::OpenUrlArguments, KParts::BrowserArguments)));

        // Check if this part is scriptable
        KParts::ScriptableExtension* scriptExt = KParts::ScriptableExtension::childObject(part);
        if (!scriptExt) {
            // Try to fall back to LiveConnectExtension compat
            KParts::LiveConnectExtension* lc = KParts::LiveConnectExtension::childObject(part);
            if (lc) {
                scriptExt = KParts::ScriptableExtension::adapterFromLiveConnect(part, lc);
            }
        }

        if (scriptExt) {
            scriptExt->setHost(KParts::ScriptableExtension::childObject(mPart));
        }

        QMap<QString, QString> metaData = part->arguments().metaData();
        QString urlStr = url.toString (QUrl::RemovePath | QUrl::RemoveQuery | QUrl::RemoveFragment);
        metaData.insert ("PropagateHttpHeader", "true");
        metaData.insert ("referrer", urlStr);
        metaData.insert ("cross-domain", urlStr);
        metaData.insert ("main_frame_request", "TRUE");
        metaData.insert ("ssl_activate_warnings", "TRUE");

        KWebPage *page = (view ? qobject_cast<KWebPage*>(view->page()) : 0);

        if (page) {
            const QString scheme = page->currentFrame()->url().scheme();
            if (page && (QString::compare (scheme, QL1S ("https"), Qt::CaseInsensitive) == 0 ||
                         QString::compare (scheme, QL1S ("webdavs"), Qt::CaseInsensitive) == 0))
                metaData.insert ("ssl_was_in_use", "TRUE");
            else
                metaData.insert ("ssl_was_in_use", "FALSE");
        }

        KParts::OpenUrlArguments openUrlArgs = part->arguments();
        openUrlArgs.metaData() = metaData;
        openUrlArgs.setMimeType(mimeType);
        part->setArguments(openUrlArgs);
        QMetaObject::invokeMethod(part, "openUrl", Qt::QueuedConnection, Q_ARG(KUrl, KUrl(url)));
        return part->widget();
    }

    return 0;
}
Esempio n. 13
0
void BookmarksWindow::on_openButton_clicked()
{
	if(bookmarksTreeWidget->currentItem() != NULL)
		emit openUrlRequest(bookmarksTreeWidget->currentItem()->text(1));
}
Esempio n. 14
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    if (a.arguments().count() <= 1) {
        qWarning() << "Argument expected: url to open";
        return 1;
    }

    new KHTMLGlobal;

    KXmlGuiWindow *toplevel = new KXmlGuiWindow();
    KHTMLPart *doc = new KHTMLPart(toplevel, toplevel, KHTMLPart::BrowserViewGUI);

    Dummy *dummy = new Dummy(doc);
    QObject::connect(doc->browserExtension(), SIGNAL(openUrlRequest(QUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)),
                     dummy, SLOT(slotOpenURL(QUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)));

    QObject::connect(doc, SIGNAL(completed()), dummy, SLOT(handleDone()));

    QUrl url = QUrl::fromUserInput(a.arguments().at(1)); // TODO support for relative paths
    if (url.path().right(4).toLower() == ".xml") {
        KParts::OpenUrlArguments args(doc->arguments());
        args.setMimeType("text/xml");
        doc->setArguments(args);
    }

    doc->openUrl(url);

    toplevel->setCentralWidget(doc->widget());
    toplevel->resize(800, 600);

    QDomDocument d = doc->domDocument();
    QDomElement viewMenu = d.documentElement().firstChild().childNodes().item(2).toElement();
    QDomElement e = d.createElement("action");
    e.setAttribute("name", "debugRenderTree");
    viewMenu.appendChild(e);
    e = d.createElement("action");
    e.setAttribute("name", "debugDOMTree");
    viewMenu.appendChild(e);
    e = d.createElement("action");
    e.setAttribute("name", "debugDoBenchmark");
    viewMenu.appendChild(e);

    QDomElement toolBar = d.documentElement().firstChild().nextSibling().toElement();
    e = d.createElement("action");
    e.setAttribute("name", "editable");
    toolBar.insertBefore(e, toolBar.firstChild());
    e = d.createElement("action");
    e.setAttribute("name", "navigable");
    toolBar.insertBefore(e, toolBar.firstChild());
    e = d.createElement("action");
    e.setAttribute("name", "reload");
    toolBar.insertBefore(e, toolBar.firstChild());
    e = d.createElement("action");
    e.setAttribute("name", "print");
    toolBar.insertBefore(e, toolBar.firstChild());

    QAction *action = new QAction(QIcon::fromTheme("view-refresh"),  "Reload", doc);
    doc->actionCollection()->addAction("reload", action);
    QObject::connect(action, SIGNAL(triggered(bool)), dummy, SLOT(reload()));
    doc->actionCollection()->setDefaultShortcut(action, Qt::Key_F5);

    QAction *bench = new QAction(QIcon(), "Benchmark...", doc);
    doc->actionCollection()->addAction("debugDoBenchmark", bench);
    QObject::connect(bench, SIGNAL(triggered(bool)), dummy, SLOT(doBenchmark()));

    QAction *kprint = new QAction(QIcon::fromTheme("document-print"),  "Print", doc);
    doc->actionCollection()->addAction("print", kprint);
    QObject::connect(kprint, SIGNAL(triggered(bool)), doc->browserExtension(), SLOT(print()));
    kprint->setEnabled(true);
    KToggleAction *ta = new KToggleAction(QIcon::fromTheme("edit-rename"), "Navigable", doc);
    doc->actionCollection()->addAction("navigable", ta);
    ta->setShortcuts(QList<QKeySequence>());
    ta->setChecked(doc->isCaretMode());
    QWidget::connect(ta, SIGNAL(toggled(bool)), dummy, SLOT(toggleNavigable(bool)));
    ta = new KToggleAction(QIcon::fromTheme("document-properties"), "Editable", doc);
    doc->actionCollection()->addAction("editable", ta);
    ta->setShortcuts(QList<QKeySequence>());
    ta->setChecked(doc->isEditable());
    QWidget::connect(ta, SIGNAL(toggled(bool)), dummy, SLOT(toggleEditable(bool)));
    toplevel->guiFactory()->addClient(doc);

    doc->setJScriptEnabled(true);
    doc->setJavaEnabled(true);
    doc->setPluginsEnabled(true);
    doc->setURLCursor(QCursor(Qt::PointingHandCursor));
    a.setActiveWindow(doc->widget());
    QWidget::connect(doc, SIGNAL(setWindowCaption(QString)),
                     doc->widget()->topLevelWidget(), SLOT(setCaption(QString)));
    doc->widget()->show();
    toplevel->show();
    doc->view()->viewport()->show();
    doc->view()->widget()->show();

    int ret = a.exec();
    return ret;
}