本文整理汇总了C++中QNetworkAccessManager::setParent方法的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkAccessManager::setParent方法的具体用法?C++ QNetworkAccessManager::setParent怎么用?C++ QNetworkAccessManager::setParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QNetworkAccessManager
的用法示例。
在下文中一共展示了QNetworkAccessManager::setParent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleUri
bool HermelinWebPage::handleUri(const QString& originmsg)
{
QString msg = originmsg;
if (msg.startsWith("hermelin:")) {
msg = msg.mid(6);
QString type = msg.section("/", 0, 0);
QString method = msg.section("/", 1, 1);
if (type == "system") {
if (method == "notify") {
QString notify_type = QUrl::fromPercentEncoding(msg.section("/", 2, 2).toUtf8());
QString title = QUrl::fromPercentEncoding(msg.section("/", 3, 3).toUtf8());
QString summary = QUrl::fromPercentEncoding(msg.section("/", 4, 4).toUtf8());
QString image = QUrl::fromPercentEncoding(msg.section("/", 5, 5).toUtf8());
m_mainWindow->notification(notify_type, title, summary, image);
} else if (method == "unread_alert") {
QString number = QUrl::fromPercentEncoding(msg.section("/", 2, 2).toUtf8());
m_mainWindow->unreadAlert(number);
} else if (method == "load_settings") {
QString settingString = QUrl::fromPercentEncoding(msg.section("/", 2, -1).toUtf8());
currentFrame()->evaluateJavaScript("hermelin_qt = " + settingString + ";");
QString proxyType = currentFrame()->evaluateJavaScript("hermelin_qt.proxy_type").toString();
QNetworkProxy proxy;
QNetworkAccessManager* nm = NULL;
#ifdef HAVE_KDE
if (proxyType == "none") {
nm = new QNetworkAccessManager(this);
}
#else
if (proxyType == "system")
{
nm = new QNetworkAccessManager(this);
QList<QNetworkProxy> proxies = QNetworkProxyFactory::systemProxyForQuery();
proxy = proxies[0];
}
#endif
if (proxyType == "http" || proxyType == "socks") {
nm = new QNetworkAccessManager(this);
bool proxyAuth = currentFrame()->evaluateJavaScript("hermelin_qt.proxy_auth").toBool();
int proxyPort = currentFrame()->evaluateJavaScript("hermelin_qt.proxy_port").toInt();
QString proxyHost = currentFrame()->evaluateJavaScript("hermelin_qt.proxy_host").toString();
QString proxyAuthName = currentFrame()->evaluateJavaScript("hermelin_qt.proxy_auth_name").toString();
QString proxyAuthPassword = currentFrame()->evaluateJavaScript("hermelin_qt.proxy_auth_password").toString();
proxy = QNetworkProxy(proxyType == "socks" ? QNetworkProxy::Socks5Proxy : QNetworkProxy::HttpProxy,
proxyHost,
proxyPort);
if (proxyAuth) {
proxy.setUser(proxyAuthName);
proxy.setPassword(proxyAuthPassword);
}
}
if (proxy.type() != QNetworkProxy::NoProxy) {
QNetworkProxy::setApplicationProxy(proxy);
}
if (nm != NULL) {
QNetworkAccessManager* oldnm = networkAccessManager();
oldnm->setParent(NULL);
oldnm->deleteLater();
nm->setProxy(QNetworkProxy::DefaultProxy);
setNetworkAccessManager(nm);
}
} else if (method == "sign_in") {
m_mainWindow->setSignIn(true);
} else if (method == "sign_out") {
m_mainWindow->setSignIn(false);
}
} else if (type == "action") {
if (method == "search") {
} else if (method == "choose_file") {
QFileDialog dialog;
dialog.setAcceptMode(QFileDialog::AcceptOpen);
dialog.setFileMode(QFileDialog::ExistingFile);
dialog.setNameFilter(tr("Images (*.png *.bmp *.jpg *.gif)"));
int result = dialog.exec();
if (result) {
QStringList fileNames = dialog.selectedFiles();
if (fileNames.size() > 0) {
QString callback = msg.section("/", 2, 2);
currentFrame()->evaluateJavaScript(QString("%1(\"%2\")").arg(callback, QUrl::fromLocalFile(fileNames[0]).toString().replace("file://", "")));
}
}
} else if (method == "save_avatar") {
} else if (method == "log") {
qDebug() << msg;
} else if (method == "paste_clipboard_text") {
triggerAction(QWebPage::Paste);
} else if (method == "set_clipboard_text") {
QClipboard *clipboard = QApplication::clipboard();
if (clipboard)
clipboard->setText(msg.section("/", 2, -1));
}
} else if (type == "request") {
QString json = QUrl::fromPercentEncoding(msg.section("/", 1, -1).toUtf8());
currentFrame()->evaluateJavaScript(QString("hermelin_qt_request_json = %1 ;").arg(json));
QString request_uuid = currentFrame()->evaluateJavaScript(QString("hermelin_qt_request_json.uuid")).toString();
QString request_method = currentFrame()->evaluateJavaScript(QString("hermelin_qt_request_json.method")).toString();
//.........这里部分代码省略.........