本文整理汇总了C++中QNetworkAccessManager::setNetworkAccessible方法的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkAccessManager::setNetworkAccessible方法的具体用法?C++ QNetworkAccessManager::setNetworkAccessible怎么用?C++ QNetworkAccessManager::setNetworkAccessible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QNetworkAccessManager
的用法示例。
在下文中一共展示了QNetworkAccessManager::setNetworkAccessible方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: icon
LxMainWindow::LxMainWindow( QWidget* prarent /*= 0*/ )
:QWebView(prarent)
{
_initWidget();
this->setRenderHints(QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing);
QObject::connect(this, SIGNAL(linkClicked(const QUrl&)), this, SLOT(linkClickedAction(const QUrl&)));
QNetworkAccessManager* pNetworkAccessManager = this->page()->networkAccessManager();
LxOption* pOption = lxCoreApp->getOption();
if (pOption && pNetworkAccessManager)
{
QString strCookies = pOption->getCookieFilePath();
LxNetWorkCookies* pCookies = new LxNetWorkCookies(strCookies, this);
pNetworkAccessManager->setCookieJar(pCookies);
QNetworkDiskCache *diskCache = new QNetworkDiskCache(this);
QString location = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
//QString location = QDesktopServices::storageLocation(QDesktopServices::CacheLocation);
diskCache->setCacheDirectory(location);
diskCache->setMaximumCacheSize(1024);//byte
pNetworkAccessManager->setCache(diskCache);
pNetworkAccessManager->setNetworkAccessible(QNetworkAccessManager::Accessible);
m_bLoadHrefInCurrent = pOption->getLoadHrefInCurrentMainDialog();
}
QString iconName = pOption->getSystemTrayIconName();
QString iconPath = QCoreApplication::applicationDirPath() + "/" + iconName;
qDebug("show path %s", qPrintable(iconPath));
QIcon icon(iconPath);
this->setWindowIcon(icon);
}
示例2: networkAccessible
void tst_QNetworkAccessManager::networkAccessible()
{
QNetworkAccessManager manager;
qRegisterMetaType<QNetworkAccessManager::NetworkAccessibility>("QNetworkAccessManager::NetworkAccessibility");
QSignalSpy spy(&manager,
SIGNAL(networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility)));
QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::UnknownAccessibility);
manager.setNetworkAccessible(QNetworkAccessManager::NotAccessible);
QCOMPARE(spy.count(), 1);
QCOMPARE(spy.takeFirst().at(0).value<QNetworkAccessManager::NetworkAccessibility>(),
QNetworkAccessManager::NotAccessible);
QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::NotAccessible);
manager.setNetworkAccessible(QNetworkAccessManager::Accessible);
QCOMPARE(spy.count(), 1);
QCOMPARE(spy.takeFirst().at(0).value<QNetworkAccessManager::NetworkAccessibility>(),
QNetworkAccessManager::UnknownAccessibility);
QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::UnknownAccessibility);
QNetworkConfigurationManager configManager;
QNetworkConfiguration defaultConfig = configManager.defaultConfiguration();
if (defaultConfig.isValid()) {
manager.setConfiguration(defaultConfig);
QCOMPARE(spy.count(), 1);
QCOMPARE(spy.takeFirst().at(0).value<QNetworkAccessManager::NetworkAccessibility>(),
QNetworkAccessManager::Accessible);
QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::Accessible);
manager.setNetworkAccessible(QNetworkAccessManager::NotAccessible);
QCOMPARE(spy.count(), 1);
QCOMPARE(QNetworkAccessManager::NetworkAccessibility(spy.takeFirst().at(0).toInt()),
QNetworkAccessManager::NotAccessible);
QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::NotAccessible);
}
}
示例3: newProxy
void
EchoNestPlugin::namChangedSlot( QNetworkAccessManager *nam )
{
qDebug() << Q_FUNC_INFO;
if( !nam )
return;
QNetworkAccessManager* currNam = Echonest::Config::instance()->nam();
TomahawkUtils::NetworkProxyFactory* oldProxyFactory = dynamic_cast< TomahawkUtils::NetworkProxyFactory* >( nam->proxyFactory() );
if ( !oldProxyFactory )
{
qDebug() << "Could not get old proxyFactory!";
return;
}
currNam->setConfiguration( nam->configuration() );
currNam->setNetworkAccessible( nam->networkAccessible() );
TomahawkUtils::NetworkProxyFactory* newProxyFactory = new TomahawkUtils::NetworkProxyFactory();
newProxyFactory->setNoProxyHosts( oldProxyFactory->noProxyHosts() );
QNetworkProxy newProxy( oldProxyFactory->proxy() );
newProxyFactory->setProxy( newProxy );
currNam->setProxyFactory( newProxyFactory );
}
示例4: QNetworkAccessManager
QNetworkAccessManager *create(QObject *parent) override {
QNetworkAccessManager *manager = new QNetworkAccessManager(parent);
manager->setNetworkAccessible(QNetworkAccessManager::NotAccessible);
return manager;
}
示例5: networkAccessible
void tst_QNetworkAccessManager::networkAccessible()
{
#ifndef QT_NO_BEARERMANAGEMENT
QNetworkAccessManager manager;
qRegisterMetaType<QNetworkAccessManager::NetworkAccessibility>("QNetworkAccessManager::NetworkAccessibility");
QSignalSpy spy(&manager,
SIGNAL(networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility)));
// if there is no session, we cannot know in which state we are in
QNetworkAccessManager::NetworkAccessibility initialAccessibility =
manager.networkAccessible();
if (initialAccessibility == QNetworkAccessManager::UnknownAccessibility)
QSKIP("Unknown accessibility", SkipAll);
QCOMPARE(manager.networkAccessible(), initialAccessibility);
manager.setNetworkAccessible(QNetworkAccessManager::NotAccessible);
int expectedCount = (initialAccessibility == QNetworkAccessManager::Accessible) ? 1 : 0;
QCOMPARE(spy.count(), expectedCount);
if (expectedCount > 0)
QCOMPARE(spy.takeFirst().at(0).value<QNetworkAccessManager::NetworkAccessibility>(),
QNetworkAccessManager::NotAccessible);
QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::NotAccessible);
manager.setNetworkAccessible(QNetworkAccessManager::Accessible);
QCOMPARE(spy.count(), expectedCount);
if (expectedCount > 0)
QCOMPARE(spy.takeFirst().at(0).value<QNetworkAccessManager::NetworkAccessibility>(),
initialAccessibility);
QCOMPARE(manager.networkAccessible(), initialAccessibility);
QNetworkConfigurationManager configManager;
QNetworkConfiguration defaultConfig = configManager.defaultConfiguration();
if (defaultConfig.isValid()) {
manager.setConfiguration(defaultConfig);
QCOMPARE(spy.count(), 0);
if (defaultConfig.state().testFlag(QNetworkConfiguration::Active))
QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::Accessible);
else
QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::NotAccessible);
manager.setNetworkAccessible(QNetworkAccessManager::NotAccessible);
if (defaultConfig.state().testFlag(QNetworkConfiguration::Active)) {
QCOMPARE(spy.count(), 1);
QCOMPARE(QNetworkAccessManager::NetworkAccessibility(spy.takeFirst().at(0).toInt()),
QNetworkAccessManager::NotAccessible);
} else {
QCOMPARE(spy.count(), 0);
}
}
QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::NotAccessible);
#endif
}
示例6: dir
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
progression = new QProgressBar(this);
progression->setValue(0);
progression->setRange(0, 100);
ui->setupUi(this);
setFixedSize(1200,200);
setWindowTitle("Updater");
welcome_string=new QLabel("<h2>Welcome on XEML Updater</h2>");
welcome_string->setAlignment(Qt::AlignCenter);
update_string=new QLabel("");
QSplitter * rightSplitter = new QSplitter(Qt::Vertical);
rightSplitter->addWidget(welcome_string);
rightSplitter->addWidget(progression);
rightSplitter->addWidget(update_string);
setCentralWidget(rightSplitter);
this->show();
QNetworkAccessManager manager;
manager.setNetworkAccessible(QNetworkAccessManager::Accessible);
//#if defined(Q_OS_WIN)
//reply = manager.get(QNetworkRequest(QUrl("https://raw.githubusercontent.com/cbib/XEML-Lab/master/bin/Windows_dist/current/XEML-Lab.zip")));
//dep_reply = manager.get(QNetworkRequest(QUrl("https://github.com/cbib/XEML-Lab/tree/master/bin/Windows_dist/current/XEML-Lab.zip")));
#if defined(Q_OS_WIN)
QEventLoop loop;
//reply = manager.get(QNetworkRequest(QUrl("https://raw.githubusercontent.com/cbib/XEML-Lab/master/bin/Windows_dist/current/XEML-Lab.zip")));
reply = manager.get(QNetworkRequest(QUrl("http://github.com/cbib/XEML-Lab/tree/master/bin/Windows_dist/current/XEML-Lab.zip")));
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
connect(reply, SIGNAL(finished()), this, SLOT(enregistrer_for_windows()));
connect(reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(downloadProgress(qint64, qint64)));
//QCoreApplication::processEvents();
//updateSoftware->setEnabled(false);
//QString error= reply->errorString();
//std::cerr << "error" << error.toStdString() << std::endl;
loop.exec();
#elif defined(Q_OS_MACX)
//https://github.com/cbib/XEML-Lab/tree/master/bin/Mac-dist/current/XEML-Lab/Updater/updater.app
//reply = manager.get(QNetworkRequest(QUrl("https://raw.githubusercontent.com/cbib/XEML-Lab/master/bin/Mac-dist/current/XEML-Lab.zip")));
dep_reply = manager.get(QNetworkRequest(QUrl("https://raw.githubusercontent.com/cbib/XEML-Lab/master/bin/Mac-dist/dependencies.txt")));
QEventLoop dep_loop;
QObject::connect(dep_reply, SIGNAL(finished()), &dep_loop, SLOT(quit()));
dep_loop.exec();
QDir dir(QCoreApplication::applicationFilePath());
QDir my_dir=dir;
//std::cerr << my_dir.path().toStdString() << std::endl;
while (! my_dir.path().endsWith("updater.app")){
my_dir.cdUp();
}
my_dir.cdUp();
my_dir.cdUp();
std::cerr << my_dir.path().toStdString() << std::endl;
QString pathTest = my_dir.path()+ "/XemlDesigner.app";
QDir dir_to_remove(pathTest);
dir_to_remove.removeRecursively();
my_dir.mkdir("XemlDesigner.app");
QString dependencies_list = dep_reply->readAll();
QStringList dependencies=dependencies_list.split("\n");
foreach (QString var, dependencies) {
QEventLoop loop;
//std::cerr <<"-------" << var.toStdString() << std::endl;
this->url="https://raw.githubusercontent.com/cbib/XEML-Lab/master/"+var;
//std::cerr << "https://raw.githubusercontent.com/cbib/XEML-Lab/master/"+var.toStdString() << std::endl;
reply = manager.get(QNetworkRequest(QUrl(this->url)));
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
connect(reply, SIGNAL(finished()), this, SLOT(enregistrer_for_mac()));
connect(reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(downloadProgress(qint64, qint64)));
//QCoreApplication::processEvents();
//updateSoftware->setEnabled(false);
//QString error= reply->errorString();
//std::cerr << "error" << error.toStdString() << std::endl;
loop.exec();
}