From b26b40f7e1f67dd3de1c81bd022aa202b5b5cad5 Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Fri, 14 Feb 2020 05:27:06 +0100 Subject: Doc: remove link to Qt Quarterly in example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Qt Quarterly 31 was the last edition of Qt Quarterly to be published exclusively as a PDF. We cannot fix the typo in the PDF. As the content is >10 years old an in an unmaintained archive section, remove the reference to it from this example. Fixes: QTBUG-81972 Change-Id: I41a82487ff89dbe8ea5701c02c51e7f7c79bf73d Reviewed-by: Leena Miettinen Reviewed-by: Topi Reiniƶ --- examples/widgets/doc/src/syntaxhighlighter.qdoc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'examples') diff --git a/examples/widgets/doc/src/syntaxhighlighter.qdoc b/examples/widgets/doc/src/syntaxhighlighter.qdoc index 8583d86114..618b387ed5 100644 --- a/examples/widgets/doc/src/syntaxhighlighter.qdoc +++ b/examples/widgets/doc/src/syntaxhighlighter.qdoc @@ -246,11 +246,7 @@ \section1 Other Code Editor Features - It is possible to implement parenthesis matching with - QSyntaxHighlighter. The "Matching Parentheses with - QSyntaxHighlighter" article in Qt Quarterly 31 - (\l{http://doc.qt.io/archives/qq/}) implements this. We also have - the \l{Code Editor Example}, which shows how to implement line + The \l{Code Editor Example} shows how to implement line numbers and how to highlight the current line. */ -- cgit v1.2.3 From 882f340f62b8dc34633f5f296be12243b6e8999d Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 14 Feb 2020 17:11:13 +0100 Subject: Deprecate QTabletEvent::device() in favor of deviceType() The idea is to reserve device() to return a pointer to a QInputDevice in the future, which is in sync with QQuickPointerEvent::device() and with QTouchEvent::device(). Change-Id: Ifda6e8aea72d5121955b31bdcbd91bf1bfa4cec4 Reviewed-by: Allan Sandfeld Jensen --- examples/widgets/widgets/tablet/tabletcanvas.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'examples') diff --git a/examples/widgets/widgets/tablet/tabletcanvas.cpp b/examples/widgets/widgets/tablet/tabletcanvas.cpp index 59ca608cef..90a5017500 100644 --- a/examples/widgets/widgets/tablet/tabletcanvas.cpp +++ b/examples/widgets/widgets/tablet/tabletcanvas.cpp @@ -106,7 +106,7 @@ void TabletCanvas::tabletEvent(QTabletEvent *event) break; case QEvent::TabletMove: #ifndef Q_OS_IOS - if (event->device() == QTabletEvent::RotationStylus) + if (event->deviceType() == QTabletEvent::RotationStylus) updateCursor(event); #endif if (m_deviceDown) { @@ -161,7 +161,7 @@ void TabletCanvas::paintPixmap(QPainter &painter, QTabletEvent *event) static qreal maxPenRadius = pressureToWidth(1.0); painter.setRenderHint(QPainter::Antialiasing); - switch (event->device()) { + switch (event->deviceType()) { //! [6] case QTabletEvent::Airbrush: { @@ -251,7 +251,7 @@ void TabletCanvas::updateBrush(const QTabletEvent *event) m_color.setAlphaF(event->pressure()); break; case TangentialPressureValuator: - if (event->device() == QTabletEvent::Airbrush) + if (event->deviceType() == QTabletEvent::Airbrush) m_color.setAlphaF(qMax(0.01, (event->tangentialPressure() + 1.0) / 2.0)); else m_color.setAlpha(255); @@ -312,7 +312,7 @@ void TabletCanvas::updateCursor(const QTabletEvent *event) if (event->pointerType() == QTabletEvent::Eraser) { cursor = QCursor(QPixmap(":/images/cursor-eraser.png"), 3, 28); } else { - switch (event->device()) { + switch (event->deviceType()) { case QTabletEvent::Stylus: cursor = QCursor(QPixmap(":/images/cursor-pencil.png"), 0, 0); break; -- cgit v1.2.3 From 57a6c60fb94f6b619a4655f53c2fed8a1564131a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 14 Feb 2020 16:28:42 +0100 Subject: Remove usage of bearer management from lightmaps example Because bearer management is going away Change-Id: I82f2e67a052fdcdf0dde337f9f69b414681511c4 Reviewed-by: Timur Pocheptsov Reviewed-by: Paul Wicking --- examples/embedded/lightmaps/mapzoom.cpp | 43 --------------------------------- examples/embedded/lightmaps/mapzoom.h | 3 --- 2 files changed, 46 deletions(-) (limited to 'examples') diff --git a/examples/embedded/lightmaps/mapzoom.cpp b/examples/embedded/lightmaps/mapzoom.cpp index d82b9ad473..781d4f27e3 100644 --- a/examples/embedded/lightmaps/mapzoom.cpp +++ b/examples/embedded/lightmaps/mapzoom.cpp @@ -81,52 +81,9 @@ MapZoom::MapZoom() menu->addAction(nightModeAction); menu->addAction(osmAction); - QNetworkConfigurationManager manager; - if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { - // Get saved network configuration - QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); - settings.beginGroup(QLatin1String("QtNetwork")); - const QString id = - settings.value(QLatin1String("DefaultNetworkConfiguration")).toString(); - settings.endGroup(); - - // If the saved network configuration is not currently discovered use the system - // default - QNetworkConfiguration config = manager.configurationFromIdentifier(id); - if ((config.state() & QNetworkConfiguration::Discovered) != - QNetworkConfiguration::Discovered) { - config = manager.defaultConfiguration(); - } - - networkSession = new QNetworkSession(config, this); - connect(networkSession, SIGNAL(opened()), this, SLOT(sessionOpened())); - - networkSession->open(); - } else { - networkSession = 0; - } - setWindowTitle(tr("Light Maps")); } -void MapZoom::sessionOpened() -{ - // Save the used configuration - QNetworkConfiguration config = networkSession->configuration(); - QString id; - if (config.type() == QNetworkConfiguration::UserChoice) { - id = networkSession->sessionProperty( - QLatin1String("UserChoiceConfiguration")).toString(); - } else { - id = config.identifier(); - } - - QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); - settings.beginGroup(QLatin1String("QtNetwork")); - settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id); - settings.endGroup(); -} - void MapZoom::chooseOslo() { map->setCenter(59.9138204, 10.7387413); diff --git a/examples/embedded/lightmaps/mapzoom.h b/examples/embedded/lightmaps/mapzoom.h index 30f2e63138..3844eca718 100644 --- a/examples/embedded/lightmaps/mapzoom.h +++ b/examples/embedded/lightmaps/mapzoom.h @@ -53,7 +53,6 @@ #include -class QNetworkSession; class LightMaps; class MapZoom : public QMainWindow @@ -64,7 +63,6 @@ public: MapZoom(); private slots: - void sessionOpened(); void chooseOslo(); void chooseBerlin(); void chooseJakarta(); @@ -72,7 +70,6 @@ private slots: private: LightMaps *map; - QNetworkSession *networkSession; }; #endif \ No newline at end of file -- cgit v1.2.3 From 22c585f0f9d694bd5c1d8f8afb23b4a66681acd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 14 Feb 2020 16:31:02 +0100 Subject: Remove the bearermonitor example Because bearer management is going away Change-Id: I64311895c347b3e63df75d10db1673bcfe54f52d Reviewed-by: Timur Pocheptsov Reviewed-by: Paul Wicking --- examples/network/bearermonitor/bearermonitor.cpp | 421 --------------------- examples/network/bearermonitor/bearermonitor.h | 95 ----- examples/network/bearermonitor/bearermonitor.pro | 22 -- .../network/bearermonitor/bearermonitor_240_320.ui | 420 -------------------- .../network/bearermonitor/bearermonitor_640_480.ui | 386 ------------------- examples/network/bearermonitor/main.cpp | 69 ---- examples/network/bearermonitor/sessionwidget.cpp | 203 ---------- examples/network/bearermonitor/sessionwidget.h | 88 ----- examples/network/bearermonitor/sessionwidget.ui | 307 --------------- examples/network/network.pro | 1 - 10 files changed, 2012 deletions(-) delete mode 100644 examples/network/bearermonitor/bearermonitor.cpp delete mode 100644 examples/network/bearermonitor/bearermonitor.h delete mode 100644 examples/network/bearermonitor/bearermonitor.pro delete mode 100644 examples/network/bearermonitor/bearermonitor_240_320.ui delete mode 100644 examples/network/bearermonitor/bearermonitor_640_480.ui delete mode 100644 examples/network/bearermonitor/main.cpp delete mode 100644 examples/network/bearermonitor/sessionwidget.cpp delete mode 100644 examples/network/bearermonitor/sessionwidget.h delete mode 100644 examples/network/bearermonitor/sessionwidget.ui (limited to 'examples') diff --git a/examples/network/bearermonitor/bearermonitor.cpp b/examples/network/bearermonitor/bearermonitor.cpp deleted file mode 100644 index 322224a902..0000000000 --- a/examples/network/bearermonitor/bearermonitor.cpp +++ /dev/null @@ -1,421 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "bearermonitor.h" -#include "sessionwidget.h" - -#include - -#ifdef Q_OS_WIN -#include -#undef interface - -#ifndef NS_NLA -#define NS_NLA 15 -#endif -#endif - -BearerMonitor::BearerMonitor(QWidget *parent) -: QWidget(parent) -{ - setupUi(this); - delete tabWidget->currentWidget(); - sessionGroup->hide(); - updateConfigurations(); - onlineStateChanged(!manager.allConfigurations(QNetworkConfiguration::Active).isEmpty()); - QNetworkConfiguration defaultConfiguration = manager.defaultConfiguration(); - for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) { - QTreeWidgetItem *item = treeWidget->topLevelItem(i); - - if (item->data(0, Qt::UserRole).toString() == defaultConfiguration.identifier()) { - treeWidget->setCurrentItem(item); - showConfigurationFor(item); - break; - } - } - connect(&manager, &QNetworkConfigurationManager::onlineStateChanged, - this, &BearerMonitor::onlineStateChanged); - connect(&manager, &QNetworkConfigurationManager::configurationAdded, - this, [this](const QNetworkConfiguration &config) { configurationAdded(config); }); - connect(&manager, &QNetworkConfigurationManager::configurationRemoved, - this, &BearerMonitor::configurationRemoved); - connect(&manager, &QNetworkConfigurationManager::configurationChanged, - this, &BearerMonitor::configurationChanged); - connect(&manager, &QNetworkConfigurationManager::updateCompleted, - this, &BearerMonitor::updateConfigurations); - -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) - connect(registerButton, &QPushButton::clicked, - this, &BearerMonitor::registerNetwork); - connect(unregisterButton, &QPushButton::clicked, - this, &BearerMonitor::unregisterNetwork); -#else // Q_OS_WIN && !Q_OS_WINRT - nlaGroup->hide(); -#endif - - connect(treeWidget, &QTreeWidget::itemActivated, - this, &BearerMonitor::createSessionFor); - connect(treeWidget, &QTreeWidget::currentItemChanged, - this, &BearerMonitor::showConfigurationFor); - - connect(newSessionButton, &QPushButton::clicked, - this, &BearerMonitor::createNewSession); - connect(deleteSessionButton, &QPushButton::clicked, - this, &BearerMonitor::deleteSession); - connect(scanButton, &QPushButton::clicked, - this, &BearerMonitor::performScan); - - // Just in case update all configurations so that all - // configurations are up to date. - manager.updateConfigurations(); -} - -BearerMonitor::~BearerMonitor() -{ -} - -static void updateItem(QTreeWidgetItem *item, const QNetworkConfiguration &config) -{ - item->setText(0, config.name()); - item->setData(0, Qt::UserRole, config.identifier()); - - QFont font = item->font(1); - font.setBold(config.state().testFlag(QNetworkConfiguration::Active)); - item->setFont(0, font); -} - -void BearerMonitor::configurationAdded(const QNetworkConfiguration &config, QTreeWidgetItem *parent) -{ - if (!config.isValid()) - return; - - QTreeWidgetItem *item = new QTreeWidgetItem; - updateItem(item, config); - - if (parent) - parent->addChild(item); - else - treeWidget->addTopLevelItem(item); - - if (config.type() == QNetworkConfiguration::ServiceNetwork) { - const QList children = config.children(); - for (const QNetworkConfiguration &child : children) - configurationAdded(child, item); - } -} - -void BearerMonitor::configurationRemoved(const QNetworkConfiguration &config) -{ - for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) { - QTreeWidgetItem *item = treeWidget->topLevelItem(i); - - if (item->data(0, Qt::UserRole).toString() == config.identifier()) { - delete item; - break; - } - } -} - -void BearerMonitor::configurationChanged(const QNetworkConfiguration &config) -{ - for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) { - QTreeWidgetItem *item = treeWidget->topLevelItem(i); - - if (item->data(0, Qt::UserRole).toString() == config.identifier()) { - updateItem(item, config); - - if (config.type() == QNetworkConfiguration::ServiceNetwork) - updateSnapConfiguration(item, config); - - if (item == treeWidget->currentItem()) - showConfigurationFor(item); - - break; - } - } -} - -void BearerMonitor::updateSnapConfiguration(QTreeWidgetItem *parent, const QNetworkConfiguration &snap) -{ - QMap itemMap; - const QList children = parent->takeChildren(); - for (QTreeWidgetItem *item : children) - itemMap.insert(item->data(0, Qt::UserRole).toString(), item); - - QList allConfigurations = snap.children(); - - while (!allConfigurations.isEmpty()) { - QNetworkConfiguration config = allConfigurations.takeFirst(); - - QTreeWidgetItem *item = itemMap.take(config.identifier()); - if (item) { - updateItem(item, config); - - parent->addChild(item); - - if (config.type() == QNetworkConfiguration::ServiceNetwork) - updateSnapConfiguration(item, config); - } else { - configurationAdded(config, parent); - } - } - - qDeleteAll(itemMap); -} - -void BearerMonitor::updateConfigurations() -{ - progressBar->hide(); - scanButton->show(); - - // Just in case update online state, on Symbian platform - // WLAN scan needs to be triggered initially to have their true state. - onlineStateChanged(manager.isOnline()); - - QList items = treeWidget->findItems(QLatin1String("*"), Qt::MatchWildcard); - QMap itemMap; - while (!items.isEmpty()) { - QTreeWidgetItem *item = items.takeFirst(); - itemMap.insert(item->data(0, Qt::UserRole).toString(), item); - } - - QNetworkConfiguration defaultConfiguration = manager.defaultConfiguration(); - QTreeWidgetItem *defaultItem = itemMap.take(defaultConfiguration.identifier()); - - if (defaultItem) { - updateItem(defaultItem, defaultConfiguration); - - if (defaultConfiguration.type() == QNetworkConfiguration::ServiceNetwork) - updateSnapConfiguration(defaultItem, defaultConfiguration); - } else { - configurationAdded(defaultConfiguration); - } - - QList allConfigurations = manager.allConfigurations(); - - while (!allConfigurations.isEmpty()) { - QNetworkConfiguration config = allConfigurations.takeFirst(); - - if (config.identifier() == defaultConfiguration.identifier()) - continue; - - QTreeWidgetItem *item = itemMap.take(config.identifier()); - if (item) { - updateItem(item, config); - - if (config.type() == QNetworkConfiguration::ServiceNetwork) - updateSnapConfiguration(item, config); - } else { - configurationAdded(config); - } - } - - qDeleteAll(itemMap); -} - -void BearerMonitor::onlineStateChanged(bool isOnline) -{ - if (isOnline) - onlineState->setText(tr("Online")); - else - onlineState->setText(tr("Offline")); -} - -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) -void BearerMonitor::registerNetwork() -{ - QTreeWidgetItem *item = treeWidget->currentItem(); - if (!item) return; - - QNetworkConfiguration configuration = - manager.configurationFromIdentifier(item->data(0, Qt::UserRole).toString()); - - const QString name = configuration.name(); - - qDebug() << "Registering" << name << "with system"; - - WSAQUERYSET networkInfo; - memset(&networkInfo, 0, sizeof(networkInfo)); - networkInfo.dwSize = sizeof(networkInfo); - networkInfo.lpszServiceInstanceName = (LPWSTR)name.utf16(); - networkInfo.dwNameSpace = NS_NLA; - - if (WSASetService(&networkInfo, RNRSERVICE_REGISTER, 0) == SOCKET_ERROR) - qDebug() << "WSASetService(RNRSERVICE_REGISTER) returned" << WSAGetLastError(); -} - -void BearerMonitor::unregisterNetwork() -{ - QTreeWidgetItem *item = treeWidget->currentItem(); - if (!item) return; - - QNetworkConfiguration configuration = - manager.configurationFromIdentifier(item->data(0, Qt::UserRole).toString()); - - const QString name = configuration.name(); - - qDebug() << "Unregistering" << name << "with system"; - - WSAQUERYSET networkInfo; - memset(&networkInfo, 0, sizeof(networkInfo)); - networkInfo.dwSize = sizeof(networkInfo); - networkInfo.lpszServiceInstanceName = (LPWSTR)name.utf16(); - networkInfo.dwNameSpace = NS_NLA; - - if (WSASetService(&networkInfo, RNRSERVICE_DELETE, 0) == SOCKET_ERROR) - qDebug() << "WSASetService(RNRSERVICE_DELETE) returned" << WSAGetLastError(); -} -#endif // Q_OS_WIN && !Q_OS_WINRT - -void BearerMonitor::showConfigurationFor(QTreeWidgetItem *item) -{ - QString identifier; - - if (item) - identifier = item->data(0, Qt::UserRole).toString(); - - QNetworkConfiguration conf = manager.configurationFromIdentifier(identifier); - - switch (conf.state()) { - case QNetworkConfiguration::Active: - configurationState->setText(tr("Active")); - break; - case QNetworkConfiguration::Discovered: - configurationState->setText(tr("Discovered")); - break; - case QNetworkConfiguration::Defined: - configurationState->setText(tr("Defined")); - break; - case QNetworkConfiguration::Undefined: - configurationState->setText(tr("Undefined")); - break; - } - - switch (conf.type()) { - case QNetworkConfiguration::InternetAccessPoint: - configurationType->setText(tr("Internet Access Point")); - break; - case QNetworkConfiguration::ServiceNetwork: - configurationType->setText(tr("Service Network")); - break; - case QNetworkConfiguration::UserChoice: - configurationType->setText(tr("User Choice")); - break; - case QNetworkConfiguration::Invalid: - configurationType->setText(tr("Invalid")); - break; - } - - switch (conf.purpose()) { - case QNetworkConfiguration::UnknownPurpose: - configurationPurpose->setText(tr("Unknown")); - break; - case QNetworkConfiguration::PublicPurpose: - configurationPurpose->setText(tr("Public")); - break; - case QNetworkConfiguration::PrivatePurpose: - configurationPurpose->setText(tr("Private")); - break; - case QNetworkConfiguration::ServiceSpecificPurpose: - configurationPurpose->setText(tr("Service Specific")); - break; - } - - configurationIdentifier->setText(conf.identifier()); - - configurationRoaming->setText(conf.isRoamingAvailable() ? tr("Available") : tr("Not available")); - - configurationChildren->setText(QString::number(conf.children().count())); - - configurationName->setText(conf.name()); -} - -void BearerMonitor::createSessionFor(QTreeWidgetItem *item) -{ - const QString identifier = item->data(0, Qt::UserRole).toString(); - - QNetworkConfiguration conf = manager.configurationFromIdentifier(identifier); - - SessionWidget *session = new SessionWidget(conf); - - tabWidget->addTab(session, conf.name()); - - sessionGroup->show(); - - sessionWidgets.append(session); -} - -void BearerMonitor::createNewSession() -{ - QTreeWidgetItem *item = treeWidget->currentItem(); - if (!item) return; - - createSessionFor(item); -} - -void BearerMonitor::deleteSession() -{ - SessionWidget *session = qobject_cast(tabWidget->currentWidget()); - if (session) { - sessionWidgets.removeAll(session); - - delete session; - - if (tabWidget->count() == 0) - sessionGroup->hide(); - } -} - -void BearerMonitor::performScan() -{ - scanButton->hide(); - progressBar->show(); - manager.updateConfigurations(); -} diff --git a/examples/network/bearermonitor/bearermonitor.h b/examples/network/bearermonitor/bearermonitor.h deleted file mode 100644 index 79b8d876ec..0000000000 --- a/examples/network/bearermonitor/bearermonitor.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef BEARERMONITOR_H -#define BEARERMONITOR_H - -#include -#include "ui_bearermonitor_640_480.h" - -QT_USE_NAMESPACE - -class SessionWidget; - -class BearerMonitor : public QWidget, public Ui_BearerMonitor -{ - Q_OBJECT - -public: - BearerMonitor(QWidget *parent = nullptr); - ~BearerMonitor(); - -private slots: - void configurationAdded(const QNetworkConfiguration &config, QTreeWidgetItem *parent = nullptr); - void configurationRemoved(const QNetworkConfiguration &config); - void configurationChanged(const QNetworkConfiguration &config); - void updateSnapConfiguration(QTreeWidgetItem *parent, const QNetworkConfiguration &snap); - void updateConfigurations(); - - void onlineStateChanged(bool isOnline); - -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) - void registerNetwork(); - void unregisterNetwork(); -#endif // Q_OS_WIN && !Q_OS_WINRT - - void showConfigurationFor(QTreeWidgetItem *item); - - void createSessionFor(QTreeWidgetItem *item); - void createNewSession(); - void deleteSession(); - void performScan(); - -private: - QNetworkConfigurationManager manager; - QVector sessionWidgets; -}; - -#endif //BEARERMONITOR_H diff --git a/examples/network/bearermonitor/bearermonitor.pro b/examples/network/bearermonitor/bearermonitor.pro deleted file mode 100644 index 16ac41298a..0000000000 --- a/examples/network/bearermonitor/bearermonitor.pro +++ /dev/null @@ -1,22 +0,0 @@ -TARGET = bearermonitor -QT = core gui network widgets -requires(qtConfig(treeview)) - -HEADERS = sessionwidget.h \ - bearermonitor.h - -SOURCES = main.cpp \ - bearermonitor.cpp \ - sessionwidget.cpp - -FORMS = bearermonitor_240_320.ui \ - bearermonitor_640_480.ui \ - sessionwidget.ui - -win32: QMAKE_USE += ws2_32 - -CONFIG += console - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/network/bearermonitor -INSTALLS += target diff --git a/examples/network/bearermonitor/bearermonitor_240_320.ui b/examples/network/bearermonitor/bearermonitor_240_320.ui deleted file mode 100644 index 93cfc5e0e3..0000000000 --- a/examples/network/bearermonitor/bearermonitor_240_320.ui +++ /dev/null @@ -1,420 +0,0 @@ - - - BearerMonitor - - - - 0 - 0 - 240 - 320 - - - - BearerMonitor - - - - - - QFrame::NoFrame - - - QFrame::Plain - - - true - - - - - 0 - -274 - 206 - 576 - - - - - - - System State - - - true - - - - 0 - - - 0 - - - 0 - - - - - - - Online State: - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - - Configurations - - - true - - - - 0 - - - 0 - - - 0 - - - - - - - - - Name: - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - State: - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - Type: - - - - - - - - 0 - 0 - - - - Invalid - - - - - - - - - - - Purpose: - - - - - - - - 0 - 0 - - - - Unknown - - - - - - - - - - - Identifier: - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - Roaming: - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - Children: - - - - - - - - 0 - 0 - - - - - - - - - - - - - Network Location Awareness - - - - - - Register - - - - - - - Unregister - - - - - - - - - - New Session - - - - - - - Delete Session - - - - - - - Scan - - - - - - - 0 - - - -1 - - - false - - - false - - - %p% - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - 0 - 0 - - - - Qt::ScrollBarAlwaysOff - - - false - - - - 1 - - - - - - - - - - - - - Sessions - - - true - - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - 0 - - - - Session 1 - - - - - - - - - - - - - - - - diff --git a/examples/network/bearermonitor/bearermonitor_640_480.ui b/examples/network/bearermonitor/bearermonitor_640_480.ui deleted file mode 100644 index 52866bc9cd..0000000000 --- a/examples/network/bearermonitor/bearermonitor_640_480.ui +++ /dev/null @@ -1,386 +0,0 @@ - - - BearerMonitor - - - - 0 - 0 - 640 - 515 - - - - BearerMonitor - - - - - - System State - - - true - - - - 0 - - - 0 - - - 0 - - - - - - - Online State: - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - - Configurations - - - true - - - - 0 - - - 0 - - - 0 - - - - - false - - - - 1 - - - - - - - - - - - - Name: - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - State: - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - Type: - - - - - - - - 0 - 0 - - - - Invalid - - - - - - - - - - - Purpose: - - - - - - - - 0 - 0 - - - - Unknown - - - - - - - - - - - Identifier: - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - Roaming: - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - Children: - - - - - - - - 0 - 0 - - - - - - - - - - - - - Network Location Awareness - - - - - - Register - - - - - - - Unregister - - - - - - - - - - New Session - - - - - - - Delete Session - - - - - - - Scan - - - - - - - 0 - - - -1 - - - false - - - false - - - %p% - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - Sessions - - - true - - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - 0 - - - - Session 1 - - - - - - - - - - - - diff --git a/examples/network/bearermonitor/main.cpp b/examples/network/bearermonitor/main.cpp deleted file mode 100644 index 3c2525012d..0000000000 --- a/examples/network/bearermonitor/main.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include "bearermonitor.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - QMainWindow mainWindow; - - BearerMonitor monitor; - - mainWindow.setCentralWidget(&monitor); - mainWindow.show(); - - return app.exec(); -} - diff --git a/examples/network/bearermonitor/sessionwidget.cpp b/examples/network/bearermonitor/sessionwidget.cpp deleted file mode 100644 index 0fd5d4f67f..0000000000 --- a/examples/network/bearermonitor/sessionwidget.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "sessionwidget.h" -#include - -SessionWidget::SessionWidget(const QNetworkConfiguration &config, QWidget *parent) -: QWidget(parent) -{ - setupUi(this); - -#ifdef QT_NO_NETWORKINTERFACE - interfaceName->setVisible(false); - interfaceNameLabel->setVisible(false); - interfaceGuid->setVisible(false); - interfaceGuidLabel->setVisible(false); -#endif - - session = new QNetworkSession(config, this); - - connect(session, &QNetworkSession::stateChanged, - this, &SessionWidget::updateSession); - connect(session, QOverload::of(&QNetworkSession::error), - this, &SessionWidget::updateSessionError); - - updateSession(); - - sessionId->setText(QString("0x%1").arg(qulonglong(session), 8, 16, QChar('0'))); - - configuration->setText(session->configuration().name()); - - connect(openSessionButton, &QPushButton::clicked, - this, &SessionWidget::openSession); - connect(openSyncSessionButton, &QPushButton::clicked, - this, &SessionWidget::openSyncSession); - connect(closeSessionButton, &QPushButton::clicked, - this, &SessionWidget::closeSession); - connect(stopSessionButton, &QPushButton::clicked, - this, &SessionWidget::stopSession); -} - -SessionWidget::~SessionWidget() -{ - delete session; -} - -void SessionWidget::timerEvent(QTimerEvent *e) -{ - if (e->timerId() == statsTimer) { - rxData->setText(QString::number(session->bytesReceived())); - txData->setText(QString::number(session->bytesWritten())); - activeTime->setText(QString::number(session->activeTime())); - } -} - -void SessionWidget::updateSession() -{ - updateSessionState(session->state()); - - if (session->state() == QNetworkSession::Connected) - statsTimer = startTimer(1000); - else if (statsTimer != -1) - killTimer(statsTimer); - - if (session->configuration().type() == QNetworkConfiguration::InternetAccessPoint) - bearer->setText(session->configuration().bearerTypeName()); - else { - QNetworkConfigurationManager mgr; - QNetworkConfiguration c = mgr.configurationFromIdentifier(session->sessionProperty("ActiveConfiguration").toString()); - bearer->setText(c.bearerTypeName()); - } - -#ifndef QT_NO_NETWORKINTERFACE - interfaceName->setText(session->interface().humanReadableName()); - interfaceGuid->setText(session->interface().name()); -#endif -} - -void SessionWidget::openSession() -{ - clearError(); - session->open(); - updateSession(); -} - -void SessionWidget::openSyncSession() -{ - clearError(); - session->open(); - session->waitForOpened(); - updateSession(); -} - -void SessionWidget::closeSession() -{ - clearError(); - session->close(); - updateSession(); -} - -void SessionWidget::stopSession() -{ - clearError(); - session->stop(); - updateSession(); -} - -void SessionWidget::updateSessionState(QNetworkSession::State state) -{ - QString s = tr("%1 (%2)"); - - switch (state) { - case QNetworkSession::Invalid: - s = s.arg(tr("Invalid")); - break; - case QNetworkSession::NotAvailable: - s = s.arg(tr("Not Available")); - break; - case QNetworkSession::Connecting: - s = s.arg(tr("Connecting")); - break; - case QNetworkSession::Connected: - s = s.arg(tr("Connected")); - break; - case QNetworkSession::Closing: - s = s.arg(tr("Closing")); - break; - case QNetworkSession::Disconnected: - s = s.arg(tr("Disconnected")); - break; - case QNetworkSession::Roaming: - s = s.arg(tr("Roaming")); - break; - default: - s = s.arg(tr("Unknown")); - } - - if (session->isOpen()) - s = s.arg(tr("Open")); - else - s = s.arg(tr("Closed")); - - sessionState->setText(s); -} - -void SessionWidget::updateSessionError(QNetworkSession::SessionError error) -{ - lastError->setText(QString::number(error)); - errorString->setText(session->errorString()); -} - -void SessionWidget::clearError() -{ - lastError->clear(); - errorString->clear(); -} diff --git a/examples/network/bearermonitor/sessionwidget.h b/examples/network/bearermonitor/sessionwidget.h deleted file mode 100644 index 6b2da2c1c1..0000000000 --- a/examples/network/bearermonitor/sessionwidget.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SESSIONWIDGET_H -#define SESSIONWIDGET_H - -#include - -#include "ui_sessionwidget.h" - -QT_USE_NAMESPACE - -class SessionWidget : public QWidget, public Ui_SessionWidget -{ - Q_OBJECT - -public: - explicit SessionWidget(const QNetworkConfiguration &config, QWidget *parent = nullptr); - ~SessionWidget(); - - void timerEvent(QTimerEvent *e) override; - -private: - void updateSessionState(QNetworkSession::State state); - void clearError(); - -private Q_SLOTS: - void openSession(); - void openSyncSession(); - void closeSession(); - void stopSession(); - void updateSession(); - void updateSessionError(QNetworkSession::SessionError error); - -private: - QNetworkSession *session = nullptr; - int statsTimer = -1; -}; - -#endif - diff --git a/examples/network/bearermonitor/sessionwidget.ui b/examples/network/bearermonitor/sessionwidget.ui deleted file mode 100644 index 4199109ce3..0000000000 --- a/examples/network/bearermonitor/sessionwidget.ui +++ /dev/null @@ -1,307 +0,0 @@ - - - SessionWidget - - - - 0 - 0 - 340 - 276 - - - - Session Details - - - - - - - - - - Session ID: - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - - 0 - 0 - - - - Session State: - - - - - - - - 0 - 0 - - - - Invalid - - - - - - - - - - - Configuration: - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - Bearer: - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - Interface Name: - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - Interface GUID: - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - Last Error: - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - Error String: - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - 0 - - - Qt::AlignCenter - - - - - - - 0 - - - Qt::AlignCenter - - - - - - - - - - - Active Time: - - - - - - - - 0 - 0 - - - - 0 seconds - - - - - - - - - - - Open - - - - - - - Blocking Open - - - - - - - - - - - Close - - - - - - - Stop - - - - - - - - - - - - diff --git a/examples/network/network.pro b/examples/network/network.pro index af3c0df43e..7b6271e954 100644 --- a/examples/network/network.pro +++ b/examples/network/network.pro @@ -23,7 +23,6 @@ qtHaveModule(widgets) { qtConfig(processenvironment): SUBDIRS += network-chat SUBDIRS += \ - bearermonitor \ fortuneclient \ fortuneserver -- cgit v1.2.3 From 3742c67041b47adefa0d293e45d543f31ab15da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 14 Feb 2020 16:35:01 +0100 Subject: Remove bearer management from remaining network examples Because bearer management is going away Change-Id: I60439c1714e0350b0f2bbef6afc8d2015886135f Reviewed-by: Timur Pocheptsov Reviewed-by: Paul Wicking --- examples/network/fortuneclient/client.cpp | 48 +------------------------------ examples/network/fortuneclient/client.h | 4 --- examples/network/fortuneserver/server.cpp | 41 ++------------------------ examples/network/fortuneserver/server.h | 5 ++-- examples/network/network-chat/main.cpp | 39 ------------------------- examples/network/network.pro | 11 +++---- 6 files changed, 9 insertions(+), 139 deletions(-) (limited to 'examples') diff --git a/examples/network/fortuneclient/client.cpp b/examples/network/fortuneclient/client.cpp index 4d3a318a7b..0ccbf51df8 100644 --- a/examples/network/fortuneclient/client.cpp +++ b/examples/network/fortuneclient/client.cpp @@ -150,29 +150,6 @@ Client::Client(QWidget *parent) setWindowTitle(QGuiApplication::applicationDisplayName()); portLineEdit->setFocus(); - - QNetworkConfigurationManager manager; - if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { - // Get saved network configuration - QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); - settings.beginGroup(QLatin1String("QtNetwork")); - const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString(); - settings.endGroup(); - - // If the saved network configuration is not currently discovered use the system default - QNetworkConfiguration config = manager.configurationFromIdentifier(id); - if ((config.state() & QNetworkConfiguration::Discovered) != - QNetworkConfiguration::Discovered) { - config = manager.defaultConfiguration(); - } - - networkSession = new QNetworkSession(config, this); - connect(networkSession, &QNetworkSession::opened, this, &Client::sessionOpened); - - getFortuneButton->setEnabled(false); - statusLabel->setText(tr("Opening network session.")); - networkSession->open(); - } //! [5] } //! [5] @@ -241,30 +218,7 @@ void Client::displayError(QAbstractSocket::SocketError socketError) void Client::enableGetFortuneButton() { - getFortuneButton->setEnabled((!networkSession || networkSession->isOpen()) && - !hostCombo->currentText().isEmpty() && + getFortuneButton->setEnabled(!hostCombo->currentText().isEmpty() && !portLineEdit->text().isEmpty()); } - -void Client::sessionOpened() -{ - // Save the used configuration - QNetworkConfiguration config = networkSession->configuration(); - QString id; - if (config.type() == QNetworkConfiguration::UserChoice) - id = networkSession->sessionProperty(QLatin1String("UserChoiceConfiguration")).toString(); - else - id = config.identifier(); - - QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); - settings.beginGroup(QLatin1String("QtNetwork")); - settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id); - settings.endGroup(); - - statusLabel->setText(tr("This examples requires that you run the " - "Fortune Server example as well.")); - - enableGetFortuneButton(); -} - diff --git a/examples/network/fortuneclient/client.h b/examples/network/fortuneclient/client.h index ac335acb83..80177bacbf 100644 --- a/examples/network/fortuneclient/client.h +++ b/examples/network/fortuneclient/client.h @@ -61,7 +61,6 @@ class QLabel; class QLineEdit; class QPushButton; class QTcpSocket; -class QNetworkSession; QT_END_NAMESPACE //! [0] @@ -77,7 +76,6 @@ private slots: void readFortune(); void displayError(QAbstractSocket::SocketError socketError); void enableGetFortuneButton(); - void sessionOpened(); private: QComboBox *hostCombo = nullptr; @@ -88,8 +86,6 @@ private: QTcpSocket *tcpSocket = nullptr; QDataStream in; QString currentFortune; - - QNetworkSession *networkSession = nullptr; }; //! [0] diff --git a/examples/network/fortuneserver/server.cpp b/examples/network/fortuneserver/server.cpp index 7db81fe07a..c91b6a5c0c 100644 --- a/examples/network/fortuneserver/server.cpp +++ b/examples/network/fortuneserver/server.cpp @@ -61,29 +61,7 @@ Server::Server(QWidget *parent) setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); statusLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); - QNetworkConfigurationManager manager; - if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { - // Get saved network configuration - QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); - settings.beginGroup(QLatin1String("QtNetwork")); - const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString(); - settings.endGroup(); - - // If the saved network configuration is not currently discovered use the system default - QNetworkConfiguration config = manager.configurationFromIdentifier(id); - if ((config.state() & QNetworkConfiguration::Discovered) != - QNetworkConfiguration::Discovered) { - config = manager.defaultConfiguration(); - } - - networkSession = new QNetworkSession(config, this); - connect(networkSession, &QNetworkSession::opened, this, &Server::sessionOpened); - - statusLabel->setText(tr("Opening network session.")); - networkSession->open(); - } else { - sessionOpened(); - } + initServer(); //! [2] fortunes << tr("You've been leading a dog's life. Stay off the furniture.") @@ -128,23 +106,8 @@ Server::Server(QWidget *parent) setWindowTitle(QGuiApplication::applicationDisplayName()); } -void Server::sessionOpened() +void Server::initServer() { - // Save the used configuration - if (networkSession) { - QNetworkConfiguration config = networkSession->configuration(); - QString id; - if (config.type() == QNetworkConfiguration::UserChoice) - id = networkSession->sessionProperty(QLatin1String("UserChoiceConfiguration")).toString(); - else - id = config.identifier(); - - QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); - settings.beginGroup(QLatin1String("QtNetwork")); - settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id); - settings.endGroup(); - } - //! [0] //! [1] tcpServer = new QTcpServer(this); if (!tcpServer->listen()) { diff --git a/examples/network/fortuneserver/server.h b/examples/network/fortuneserver/server.h index c5bfa7d928..96d7145148 100644 --- a/examples/network/fortuneserver/server.h +++ b/examples/network/fortuneserver/server.h @@ -58,7 +58,6 @@ QT_BEGIN_NAMESPACE class QLabel; class QTcpServer; -class QNetworkSession; QT_END_NAMESPACE //! [0] @@ -70,14 +69,14 @@ public: explicit Server(QWidget *parent = nullptr); private slots: - void sessionOpened(); void sendFortune(); private: + void initServer(); + QLabel *statusLabel = nullptr; QTcpServer *tcpServer = nullptr; QVector fortunes; - QNetworkSession *networkSession = nullptr; }; //! [0] diff --git a/examples/network/network-chat/main.cpp b/examples/network/network-chat/main.cpp index f88e29977b..029c18f0ff 100644 --- a/examples/network/network-chat/main.cpp +++ b/examples/network/network-chat/main.cpp @@ -53,50 +53,11 @@ #include "chatdialog.h" #include -#include -#include int main(int argc, char *argv[]) { QApplication app(argc, argv); - QNetworkConfigurationManager manager; - if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { - // Get saved network configuration - QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); - settings.beginGroup(QLatin1String("QtNetwork")); - const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString(); - settings.endGroup(); - - // If the saved network configuration is not currently discovered use the system default - QNetworkConfiguration config = manager.configurationFromIdentifier(id); - if ((config.state() & QNetworkConfiguration::Discovered) != - QNetworkConfiguration::Discovered) { - config = manager.defaultConfiguration(); - } - - QNetworkSession *networkSession = new QNetworkSession(config, &app); - networkSession->open(); - networkSession->waitForOpened(); - - if (networkSession->isOpen()) { - // Save the used configuration - QNetworkConfiguration config = networkSession->configuration(); - QString id; - if (config.type() == QNetworkConfiguration::UserChoice) { - id = networkSession->sessionProperty( - QLatin1String("UserChoiceConfiguration")).toString(); - } else { - id = config.identifier(); - } - - QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); - settings.beginGroup(QLatin1String("QtNetwork")); - settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id); - settings.endGroup(); - } - } - ChatDialog dialog; dialog.show(); return app.exec(); diff --git a/examples/network/network.pro b/examples/network/network.pro index 7b6271e954..3f851d7c71 100644 --- a/examples/network/network.pro +++ b/examples/network/network.pro @@ -19,14 +19,11 @@ qtHaveModule(widgets) { multicastreceiver \ multicastsender - qtConfig(bearermanagement) { - qtConfig(processenvironment): SUBDIRS += network-chat + qtConfig(processenvironment): SUBDIRS += network-chat - SUBDIRS += \ - fortuneclient \ - fortuneserver - - } + SUBDIRS += \ + fortuneclient \ + fortuneserver qtConfig(ssl): SUBDIRS += securesocketclient qtConfig(dtls): SUBDIRS += secureudpserver secureudpclient -- cgit v1.2.3