예제 #1
0
파일: core.cpp 프로젝트: Zereal/leechcraft
	void Core::handleAddToFavorites (QString title, QString url)
	{
		Util::DefaultHookProxy_ptr proxy = Util::DefaultHookProxy_ptr (new Util::DefaultHookProxy ());
		emit hookAddToFavoritesRequested (proxy, title, url);
		if (proxy->IsCancelled ())
			return;
		
		proxy->FillValue ("title", title);
		proxy->FillValue ("url", url);

		std::auto_ptr<AddToFavoritesDialog> dia (new AddToFavoritesDialog (title,
					url,
					qApp->activeWindow ()));

		bool result = false;
		do
		{
			if (dia->exec () == QDialog::Rejected)
				return;

			result = FavoritesModel_->addItem (dia->GetTitle (),
					url, dia->GetTags ());
		}
		while (!result);
	}
예제 #2
0
	void CustomWebPage::javaScriptConsoleMessage (const QString& thmsg, int line,
			const QString& thsid)
	{
		Util::DefaultHookProxy_ptr proxy (new Util::DefaultHookProxy);
		QString msg = thmsg;
		QString sid = thsid;
		emit hookJavaScriptConsoleMessage (proxy,
				this, msg, line, sid);
		if (proxy->IsCancelled ())
			return;

		proxy->FillValue ("message", msg);
		proxy->FillValue ("line", line);
		proxy->FillValue ("sourceID", sid);

		QWebPage::javaScriptConsoleMessage (msg, line, sid);
	}
예제 #3
0
	bool CustomWebPage::javaScriptPrompt (QWebFrame *frame, const QString& thpr,
			const QString& thdef, QString *result)
	{
		Util::DefaultHookProxy_ptr proxy (new Util::DefaultHookProxy);
		QString pr = thpr;
		QString def = thdef;
		emit hookJavaScriptPrompt (proxy,
				this, frame, pr, def, *result);
		proxy->FillValue ("result", *result);
		if (proxy->IsCancelled ())
			return proxy->GetReturnValue ().toBool ();

		proxy->FillValue ("message", pr);
		proxy->FillValue ("default", def);

		return QWebPage::javaScriptPrompt (frame, pr, def, result);
	}
예제 #4
0
void Core::handleAddToFavorites (QString title, QString url)
{
    Util::DefaultHookProxy_ptr proxy = Util::DefaultHookProxy_ptr (new Util::DefaultHookProxy ());
    emit hookAddToFavoritesRequested (proxy, title, url);
    if (proxy->IsCancelled ())
        return;

    proxy->FillValue ("title", title);
    proxy->FillValue ("url", url);

    bool oneClick = XmlSettingsManager::Instance ()->property ("BookmarkInOneClick").toBool ();

    const auto& index = FavoritesModel_->addItem (title, url, QStringList ());

    if (!oneClick)
        FavoritesModel_->EditBookmark (index);

    emit bookmarkAdded (url);
}
예제 #5
0
	QObject* CustomWebPage::createPlugin (const QString& thclsid, const QUrl& thurl,
			const QStringList& thnames, const QStringList& thvalues)
	{
		Util::DefaultHookProxy_ptr proxy (new Util::DefaultHookProxy);
		QString clsid = thclsid;
		QUrl url = thurl;
		QStringList names = thnames;
		QStringList values = thvalues;
		emit hookCreatePlugin (proxy, this,
				clsid, url, names, values);
		if (proxy->IsCancelled ())
			return proxy->GetReturnValue ().value<QObject*> ();

		proxy->FillValue ("clsid", clsid);
		proxy->FillValue ("url", url);
		proxy->FillValue ("names", names);
		proxy->FillValue ("values", values);

		return QWebPage::createPlugin (clsid, url, names, values);
	}
예제 #6
0
	QString CustomWebPage::chooseFile (QWebFrame *frame, const QString& thsuggested)
	{
		Util::DefaultHookProxy_ptr proxy (new Util::DefaultHookProxy);
		QString suggested = thsuggested;
		emit hookChooseFile (proxy, this, frame, suggested);
		if (proxy->IsCancelled ())
			return proxy->GetReturnValue ().toString ();

		proxy->FillValue ("suggested", suggested);

		return QWebPage::chooseFile (frame, suggested);
	}
예제 #7
0
	bool CustomWebPage::javaScriptConfirm (QWebFrame *frame, const QString& thmsg)
	{
		Util::DefaultHookProxy_ptr proxy (new Util::DefaultHookProxy);
		QString msg = thmsg;
		emit hookJavaScriptConfirm (proxy,
				this, frame, msg);
		if (proxy->IsCancelled ())
			return proxy->GetReturnValue ().toBool ();

		proxy->FillValue ("message", msg);

		return QWebPage::javaScriptConfirm (frame, msg);
	}
예제 #8
0
	void CustomWebPage::javaScriptAlert (QWebFrame *frame, const QString& thmsg)
	{
		Util::DefaultHookProxy_ptr proxy (new Util::DefaultHookProxy);
		QString msg = thmsg;
		emit hookJavaScriptAlert (proxy,
				this, frame, msg);
		if (proxy->IsCancelled ())
			return;

		proxy->FillValue ("message", msg);

		QWebPage::javaScriptAlert (frame, msg);
	}
예제 #9
0
	bool CustomWebPage::acceptNavigationRequest (QWebFrame *frame,
			const QNetworkRequest& other, QWebPage::NavigationType type)
	{
		Util::DefaultHookProxy_ptr proxy (new Util::DefaultHookProxy);
		QNetworkRequest request = other;
		emit hookAcceptNavigationRequest (proxy, this, frame, request, type);
		if (proxy->IsCancelled ())
			return proxy->GetReturnValue ().toBool ();

		proxy->FillValue ("request", request);

		QString scheme = request.url ().scheme ();
		if (scheme == "mailto" ||
				scheme == "ftp")
		{
			const auto& e = Util::MakeEntity (request.url (),
					QString (),
					FromUserInitiated);
			auto em = Core::Instance ().GetProxy ()->GetEntityManager ();
			if (em->CouldHandle (e))
				em->HandleEntity (e);
			else
				QDesktopServices::openUrl (request.url ());
			return false;
		}

		if (frame)
			HandleForms (frame, request, type);

		if (type == NavigationTypeLinkClicked &&
				(MouseButtons_ == Qt::MidButton ||
					Modifiers_ & Qt::ControlModifier))
		{
			bool invert = Modifiers_ & Qt::ShiftModifier;

			CustomWebView *view = Core::Instance ().MakeWebView (invert);
			view->Load (request);

			MouseButtons_ = Qt::NoButton;
			Modifiers_ = Qt::NoModifier;
			return false;
		}

		if (frame == mainFrame ())
			LoadingURL_ = request.url ();

		return QWebPage::acceptNavigationRequest (frame, request, type);
	}
예제 #10
0
	void CustomWebPage::handleDownloadRequested (const QNetworkRequest& other)
	{
		QNetworkRequest request = other;
		Util::DefaultHookProxy_ptr proxy (new Util::DefaultHookProxy);
		emit hookDownloadRequested (proxy, this, request);
		if (proxy->IsCancelled ())
			return;

		proxy->FillValue ("request", request);

		Entity e = Util::MakeEntity (request.url (),
				QString (),
				FromUserInitiated);
		e.Additional_ ["AllowedSemantics"] = QStringList ("fetch") << "save";
		e.Additional_ ["IgnorePlugins"] = "org.LeechCraft.Poshuku";
		emit gotEntity (e);
	}