Esempio n. 1
0
	void Core::saveSingleSession ()
	{
		BrowserWidget *source = qobject_cast<BrowserWidget*> (sender ());
		if (!source)
		{
			qWarning () << Q_FUNC_INFO
				<< "sender is not a BrowserWidget*"
				<< sender ();
			return;
		}

		QSettings settings (QCoreApplication::organizationName (),
				QCoreApplication::applicationName () + "_Poshuku");
		settings.beginWriteArray ("Saved session");
		for (int i = 0, size = Widgets_.size (); i < size; ++i)
			if (Widgets_.at (i) == source)
			{
				settings.setArrayIndex (i);
				settings.setValue ("Title", source->GetView ()->title ());
				settings.setValue ("URL", source->GetView ()->url ().toString ());
				settings.setValue ("Settings",
						QVariant::fromValue<BrowserWidgetSettings> (source->GetWidgetSettings ()));
				break;
			}

		// It looks like QSettings determines array size by last used index
		// no matter what was passed to QSettings::beginWriteArray (). Forcing correct size
		settings.setArrayIndex (Widgets_.size () - 1);
		settings.endArray ();
		settings.sync ();
	}
Esempio n. 2
0
	void Core::handleUnclose ()
	{
		QAction *action = qobject_cast<QAction*> (sender ());
		UncloseData ud = action->data ().value<UncloseData> ();
		BrowserWidget *bw = NewURL (ud.URL_);

		QDataStream str (ud.History_);
		str >> *bw->GetView ()->page ()->history ();

		bw->SetOnLoadScrollPoint (ud.SPoint_);

		Unclosers_.removeAll (action);

		action->deleteLater ();
	}
Esempio n. 3
0
	QWebPage* CustomWebPage::createWindow (QWebPage::WebWindowType type)
	{
		Util::DefaultHookProxy_ptr proxy (new Util::DefaultHookProxy);
		emit hookCreateWindow (proxy, this, type);
		if (proxy->IsCancelled ())
			return qobject_cast<QWebPage*> (proxy->GetReturnValue ().value<QObject*> ());

		switch (type)
		{
		case QWebPage::WebBrowserWindow:
			return Core::Instance ().NewURL (QUrl ())->GetView ()->page ();
		case QWebPage::WebModalDialog:
			{
				BrowserWidget *widget = new BrowserWidget (view ());
				widget->InitShortcuts ();
				widget->setWindowFlags (Qt::Dialog);
				widget->setAttribute (Qt::WA_DeleteOnClose);
				widget->setWindowModality (Qt::ApplicationModal);
				connect (widget,
						SIGNAL (gotEntity (const LeechCraft::Entity&)),
						&Core::Instance (),
						SIGNAL (gotEntity (const LeechCraft::Entity&)));
				connect (widget,
						SIGNAL (titleChanged (const QString&)),
						widget,
						SLOT (setWindowTitle (const QString&)));
				widget->show ();
				return widget->GetView ()->page ();
			}
		default:
			qWarning () << Q_FUNC_INFO
					<< "unknown type"
					<< type;
			return 0;
		}
	}