524 menu->addSeparator(); |
521 menu->addSeparator(); |
525 menu->addAction(nightModeAction); |
522 menu->addAction(nightModeAction); |
526 menu->addAction(osmAction); |
523 menu->addAction(osmAction); |
527 #endif |
524 #endif |
528 |
525 |
529 QTimer::singleShot(0, this, SLOT(delayedInit())); |
526 QNetworkConfigurationManager manager; |
|
527 if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { |
|
528 // Get saved network configuration |
|
529 QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); |
|
530 settings.beginGroup(QLatin1String("QtNetwork")); |
|
531 const QString id = |
|
532 settings.value(QLatin1String("DefaultNetworkConfiguration")).toString(); |
|
533 settings.endGroup(); |
|
534 |
|
535 // If the saved network configuration is not currently discovered use the system |
|
536 // default |
|
537 QNetworkConfiguration config = manager.configurationFromIdentifier(id); |
|
538 if ((config.state() & QNetworkConfiguration::Discovered) != |
|
539 QNetworkConfiguration::Discovered) { |
|
540 config = manager.defaultConfiguration(); |
|
541 } |
|
542 |
|
543 networkSession = new QNetworkSession(config, this); |
|
544 connect(networkSession, SIGNAL(opened()), this, SLOT(sessionOpened())); |
|
545 |
|
546 networkSession->open(); |
|
547 } else { |
|
548 networkSession = 0; |
|
549 } |
530 } |
550 } |
531 |
551 |
532 private slots: |
552 private slots: |
533 |
553 |
534 void delayedInit() { |
554 void sessionOpened() { |
535 #if defined(Q_OS_SYMBIAN) |
555 // Save the used configuration |
536 qt_SetDefaultIap(); |
556 QNetworkConfiguration config = networkSession->configuration(); |
537 #endif |
557 QString id; |
|
558 if (config.type() == QNetworkConfiguration::UserChoice) { |
|
559 id = networkSession->sessionProperty( |
|
560 QLatin1String("UserChoiceConfiguration")).toString(); |
|
561 } else { |
|
562 id = config.identifier(); |
|
563 } |
|
564 |
|
565 QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); |
|
566 settings.beginGroup(QLatin1String("QtNetwork")); |
|
567 settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id); |
|
568 settings.endGroup(); |
538 } |
569 } |
539 |
570 |
540 void chooseOslo() { |
571 void chooseOslo() { |
541 map->setCenter(59.9138204, 10.7387413); |
572 map->setCenter(59.9138204, 10.7387413); |
542 } |
573 } |