├── .cmake.conf ├── .gitignore ├── CMakeLists.txt ├── LICENSES ├── BSD-3-Clause.txt ├── GFDL-1.3-no-invariants-only.txt ├── GPL-2.0-only.txt ├── GPL-3.0-only.txt ├── LGPL-3.0-only.txt ├── LicenseRef-Qt-Commercial.txt └── Qt-GPL-exception-1.0.txt ├── coin └── module_config.yaml ├── conanfile.py ├── dependencies.yaml ├── examples ├── CMakeLists.txt └── deviceutilities │ ├── CMakeLists.txt │ └── settingsuiapp │ ├── AutoScroller.qml │ ├── CMakeLists.txt │ ├── DeviceUtilities │ ├── QtButtonImageProvider │ │ ├── CMakeLists.txt │ │ ├── QtButton.qml │ │ ├── plugin.cpp │ │ ├── plugin_p.h │ │ ├── qtbuttonimageprovider.cpp │ │ └── qtbuttonimageprovider.h │ └── SettingsUI │ │ ├── CMakeLists.txt │ │ ├── Globals.qml │ │ ├── Network │ │ ├── AddressListEntry.qml │ │ ├── CMakeLists.txt │ │ ├── ComboBoxEntry.qml │ │ ├── CustomSwitch.qml │ │ ├── CustomTableView.qml │ │ ├── EditWiredSettings.qml │ │ ├── IpAddressTextField.qml │ │ ├── NetworkListView.qml │ │ ├── NetworkSettings.qml │ │ ├── PassphraseEnter.qml │ │ ├── WifiSelectorDelegate.qml │ │ ├── WifiSettings.qml │ │ ├── WifiSignalMonitor.qml │ │ ├── WiredSettings.qml │ │ └── icons │ │ │ ├── Alert_yellow_1x.png │ │ │ ├── WifiAnim_black_2x.png │ │ │ ├── Wifi_lightgray_2x.png │ │ │ ├── generate_icons.sh │ │ │ ├── ref │ │ │ └── extra │ │ │ │ └── Alert.png │ │ │ └── scripts │ │ │ ├── cimage.sh │ │ │ ├── cimages.sh │ │ │ ├── rimage.sh │ │ │ └── rimages.sh │ │ ├── SettingsUI.qml │ │ └── icons │ │ ├── back.svg │ │ └── network.svg │ ├── HandwritingModeButton.qml │ ├── applicationsettings.cpp │ ├── applicationsettings.h │ ├── images │ ├── FloatingButton_Active.png │ ├── FloatingButton_Available.png │ └── FloatingButton_Unavailable.png │ ├── main.cpp │ └── main.qml ├── src ├── CMakeLists.txt ├── doc │ ├── CMakeLists.txt │ ├── QtDeviceUtilitiesDoc │ ├── online │ │ ├── qtdeviceutilities.qdocconf │ │ └── style │ │ │ └── qt5-sidebar.html │ ├── qtdeviceutilities-project.qdocconf │ ├── qtdeviceutilities.qdocconf │ └── src │ │ ├── external-resources.qdoc │ │ ├── qtdeviceutilities-examples.qdoc │ │ ├── qtdeviceutilities-index.qdoc │ │ ├── qtdeviceutilities-module-cpp.qdoc │ │ ├── qtdeviceutilities-module-qml.qdoc │ │ └── wifiexample.qdoc ├── networksettings │ ├── CMakeLists.txt │ ├── connman │ │ ├── connman_manager.xml │ │ ├── connman_service.xml │ │ ├── connman_technology.xml │ │ ├── connmancommon.cpp │ │ ├── connmancommon.h │ │ ├── qnetworksettingsinterface_p.cpp │ │ ├── qnetworksettingsinterface_p.h │ │ ├── qnetworksettingsmanager_p.cpp │ │ ├── qnetworksettingsmanager_p.h │ │ ├── qnetworksettingsservice_p.cpp │ │ ├── qnetworksettingsservice_p.h │ │ ├── qnetworksettingsuseragent_p.cpp │ │ └── qnetworksettingsuseragent_p.h │ ├── qnetworksettings.cpp │ ├── qnetworksettings.h │ ├── qnetworksettings.qdoc │ ├── qnetworksettingsaddressmodel.cpp │ ├── qnetworksettingsaddressmodel.h │ ├── qnetworksettingsglobal.h │ ├── qnetworksettingsinterface.cpp │ ├── qnetworksettingsinterface.h │ ├── qnetworksettingsinterfacemodel.cpp │ ├── qnetworksettingsinterfacemodel.h │ ├── qnetworksettingsmanager.cpp │ ├── qnetworksettingsmanager.h │ ├── qnetworksettingsservice.cpp │ ├── qnetworksettingsservice.h │ ├── qnetworksettingsservicemodel.cpp │ ├── qnetworksettingsservicemodel.h │ ├── qnetworksettingsuseragent.cpp │ └── qnetworksettingsuseragent.h └── networksettingsqml │ ├── CMakeLists.txt │ ├── qnetworksettingsforeign.cpp │ └── qnetworksettingsforeign.h ├── sync.profile └── tests └── CMakeLists.txt /.cmake.conf: -------------------------------------------------------------------------------- 1 | set(QT_REPO_MODULE_VERSION "6.10.0") 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.moc 2 | *.obj 3 | *.pro.user* 4 | *.qmlproject.user* 5 | Makefile* 6 | .qmake.cache 7 | 8 | # Vim temporary files 9 | .*.swp 10 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15.0) 2 | 3 | include(.cmake.conf) 4 | project(QtDeviceUtilities 5 | VERSION "${QT_REPO_MODULE_VERSION}" 6 | DESCRIPTION "Qt Device Utilities Libraries" 7 | HOMEPAGE_URL "https://qt.io/" 8 | LANGUAGES CXX C 9 | ) 10 | 11 | find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS BuildInternals Core) 12 | find_package(Qt6 ${PROJECT_VERSION} QUIET CONFIG OPTIONAL_COMPONENTS Gui Network Quick Qml QuickControls2 DBus) 13 | 14 | macro(assertTargets) 15 | foreach(qtTarget IN ITEMS ${ARGN}) 16 | if(NOT TARGET Qt::${qtTarget}) 17 | message(NOTICE "Skipping the build as the condition \"TARGET Qt::${qtTarget}\" is not met.") 18 | return() 19 | endif() 20 | endforeach() 21 | endmacro() 22 | 23 | assertTargets(Quick DBus) 24 | 25 | if(NOT LINUX) 26 | message(NOTICE "Skipping the build as the condition \"LINUX\" is not met.") 27 | return() 28 | endif() 29 | if(WASM) 30 | message(NOTICE "Skipping the build as the condition \"NOT WASM\" is not met.") 31 | return() 32 | endif() 33 | 34 | qt_build_repo() 35 | -------------------------------------------------------------------------------- /LICENSES/BSD-3-Clause.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) . 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 2. 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. 7 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 8 | 9 | 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 HOLDER 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. 10 | -------------------------------------------------------------------------------- /LICENSES/LGPL-3.0-only.txt: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /LICENSES/LicenseRef-Qt-Commercial.txt: -------------------------------------------------------------------------------- 1 | Licensees holding valid commercial Qt licenses may use this software in 2 | accordance with the the terms contained in a written agreement between 3 | you and The Qt Company. Alternatively, the terms and conditions that were 4 | accepted by the licensee when buying and/or downloading the 5 | software do apply. 6 | 7 | For the latest licensing terms and conditions, see https://www.qt.io/terms-conditions. 8 | For further information use the contact form at https://www.qt.io/contact-us. 9 | -------------------------------------------------------------------------------- /LICENSES/Qt-GPL-exception-1.0.txt: -------------------------------------------------------------------------------- 1 | The Qt Company GPL Exception 1.0 2 | 3 | Exception 1: 4 | 5 | As a special exception you may create a larger work which contains the 6 | output of this application and distribute that work under terms of your 7 | choice, so long as the work is not otherwise derived from or based on 8 | this application and so long as the work does not in itself generate 9 | output that contains the output from this application in its original 10 | or modified form. 11 | 12 | Exception 2: 13 | 14 | As a special exception, you have permission to combine this application 15 | with Plugins licensed under the terms of your choice, to produce an 16 | executable, and to copy and distribute the resulting executable under 17 | the terms of your choice. However, the executable must be accompanied 18 | by a prominent notice offering all users of the executable the entire 19 | source code to this application, excluding the source code of the 20 | independent modules, but including any changes you have made to this 21 | application, under the terms of this license. 22 | 23 | -------------------------------------------------------------------------------- /coin/module_config.yaml: -------------------------------------------------------------------------------- 1 | version: 2 2 | tags: ["documentation"] 3 | accept_configuration: 4 | condition: or 5 | conditions: 6 | - condition: property 7 | property: features 8 | contains_value: LicenseCheck 9 | - condition: and 10 | conditions: 11 | - condition: property 12 | property: target.os 13 | equals_value: "Linux" 14 | - condition: property 15 | property: configureArgs 16 | not_contains_value: "-DFEATURE_gui=OFF" 17 | 18 | instructions: 19 | Build: 20 | - type: EnvironmentVariable 21 | variableName: BUILD_DOCUMENTATION 22 | variableValue: "1" 23 | - !include "{{qt/qtbase}}/coin_module_build_template_v2.yaml" 24 | 25 | Test: 26 | - !include "{{qt/qtbase}}/coin_module_test_template_v3.yaml" 27 | -------------------------------------------------------------------------------- /conanfile.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2021 The Qt Company Ltd. 2 | # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 3 | 4 | from conans import ConanFile, tools, CMake 5 | import os 6 | from pathlib import Path 7 | 8 | 9 | class QtConanError(Exception): 10 | pass 11 | 12 | 13 | class QtDeviceUtilities(ConanFile): 14 | name = "qtdeviceutilities" 15 | version = "6.4.0" 16 | license = "GPL-3.0, Commercial Qt License Agreement" 17 | author = "The Qt Company " 18 | url = "https://code.qt.io/cgit/qt/qtdeviceutilities.git/" 19 | description = "Qt Device Utilities provides functionality that is useful for controlling settings in embedded applications." 20 | topics = ("qt", "qt6", "deviceutilities", "device creation", "network") 21 | settings = "os", "compiler", "build_type", "arch" 22 | options = {"shared": [True, False, "default"], 23 | "qt6": "ANY"} # this is needed to model unique package_id for the Add-on build per used Qt6 version 24 | default_options = {"shared": "default", # default: Use the value of the Qt build 25 | "qt6": None} 26 | exports_sources = "*", "!conan*.*" 27 | # use commit ID as the RREV (recipe revision) if this is exported from .git repository 28 | revision_mode = "scm" if Path(Path(__file__).parent.resolve() / ".git").exists() else "hash" 29 | 30 | def source(self): 31 | # sources are installed next to recipe, no need to clone etc. sources here 32 | pass 33 | 34 | def _get_cmake_prefix_path(self): 35 | # 'QTDIR' provided as env variable in profile file which is part of the Qt essential binary 36 | # package(s). Installed under .conan/profiles 37 | cmake_prefix_path = os.environ.get("QTDIR") 38 | if not cmake_prefix_path: 39 | raise QtConanError("'QTDIR' not defined! The 'QTDIR' needs to point to Qt installation directory.") 40 | print(f"CMAKE_PREFIX_PATH for '{self.name}/{self.version}' build is: {cmake_prefix_path}") 41 | return cmake_prefix_path 42 | 43 | def _read_env(self, key): 44 | value = os.environ.get(key) 45 | if not value: 46 | raise QtConanError(f"{self.settings.os} build specified but '{key}' was not defined?") 47 | return value 48 | 49 | def _get_qtcmake(self): 50 | qt_install_path = self._get_cmake_prefix_path() 51 | ext = ".bat" if tools.os_info.is_windows else "" 52 | qtcmake = os.path.abspath(os.path.join(qt_install_path, "bin", "qt-cmake" + ext)) 53 | if not os.path.exists(qtcmake): 54 | raise QtConanError(f"Unable to locate {qtcmake} from 'QTDIR': {qt_install_path}") 55 | return qtcmake 56 | 57 | def _get_cmake_tool(self): 58 | cmake = CMake(self, cmake_program=self._get_qtcmake()) 59 | cmake.verbose = True 60 | 61 | # Qt modules need to be 'installed'. 62 | # We need to direct the 'make install' to some directory under Conan cache, 63 | # place it under the current build directory which is also under the Conan cache. 64 | # Note, the actual 'make install' is called in "package()". 65 | install_dir = os.path.join(os.getcwd(), "_install_tmp") 66 | cmake.definitions["CMAKE_INSTALL_PREFIX"] = install_dir 67 | 68 | # Use the value of the Qt build 69 | if self.options.shared.value == "default": 70 | del cmake.definitions["BUILD_SHARED_LIBS"] 71 | 72 | cmake_toolchain_file = os.environ.get("CMAKE_TOOLCHAIN_FILE") 73 | if cmake_toolchain_file: 74 | cmake.definitions["CMAKE_TOOLCHAIN_FILE"] = cmake_toolchain_file 75 | 76 | if self.settings.os == "Android": 77 | cmake.definitions["ANDROID_SDK_ROOT"] = self._read_env('ANDROID_SDK_ROOT') 78 | cmake.definitions["ANDROID_NDK_ROOT"] = self._read_env('ANDROID_NDK_ROOT') 79 | 80 | if self.settings.os == "iOS": 81 | # Instead of Conan's auto-added 'Darwin', explicitly pass 'iOS'. 82 | cmake.definitions["CMAKE_SYSTEM_NAME"] = "iOS" 83 | 84 | # Remove the explicit sysroot, let CMake detect the sysroots, to ensure 85 | # that multi-arch builds work. 86 | del cmake.definitions["CMAKE_OSX_SYSROOT"] 87 | 88 | # Remove the conan provided architecture, instead rely on the architectures set 89 | # by the Qt toolchain file, which with official Qt packages most likely means 90 | # multi-arch iOS. 91 | del cmake.definitions["CMAKE_OSX_ARCHITECTURES"] 92 | 93 | return cmake 94 | 95 | def build(self): 96 | cmake = self._get_cmake_tool() 97 | self.run('%s "%s" %s' % (self._get_qtcmake(), self.source_folder, cmake.command_line)) 98 | self.run('cmake --build . %s' % cmake.build_config) 99 | 100 | def package(self): 101 | install_dir = os.path.join(os.getcwd(), "_install_tmp") # see 'CMAKE_INSTALL_PREFIX' above 102 | self.run('cmake --build . --target install') 103 | self.copy("*", src=install_dir, dst=".") 104 | 105 | def package_info(self): 106 | self.cpp_info.libs = ["Qt6NetworkSettings"] # used for the actual library filename, Ordered list with the library names 107 | 108 | def deploy(self): 109 | self.copy("*") # copy from current package 110 | self.copy_deps("*") # copy from dependencies 111 | 112 | -------------------------------------------------------------------------------- /dependencies.yaml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | ../../qt/qtdeclarative: 3 | ref: fa4568622cc19e5a876238d6cfca2e95936f8bdd 4 | required: true 5 | ../qttools: 6 | ref: 9b0e5531293d70e2bc19393174118e0950eb16f6 7 | required: false 8 | -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | qt_examples_build_begin(EXTERNAL_BUILD) 2 | 3 | add_subdirectory(deviceutilities) 4 | 5 | qt_examples_build_end() 6 | -------------------------------------------------------------------------------- /examples/deviceutilities/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(TARGET Qt::Quick) 2 | qt_internal_add_example(settingsuiapp) 3 | endif() 4 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/AutoScroller.qml: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | import QtQuick 4 | import QtQuick.VirtualKeyboard 5 | 6 | Item { 7 | 8 | property var innerFlickable 9 | property var outerFlickable 10 | property var inputItem: InputContext.inputItem 11 | 12 | onInputItemChanged: { 13 | innerFlickable = null 14 | outerFlickable = null 15 | if (inputItem !== null) { 16 | var parent_ = inputItem.parent 17 | while (parent_) { 18 | if (parent_.maximumFlickVelocity) { 19 | if (innerFlickable) { 20 | outerFlickable = parent_ 21 | break 22 | } else { 23 | innerFlickable = parent_ 24 | } 25 | } 26 | parent_ = parent_.parent 27 | } 28 | delayedLoading.triggered() 29 | } 30 | } 31 | 32 | function ensureVisible(flickable) { 33 | if (Qt.inputMethod.visible && inputItem && flickable && flickable.visible && flickable.interactive) { 34 | 35 | var verticallyFlickable = (flickable.flickableDirection === Flickable.HorizontalAndVerticalFlick || flickable.flickableDirection === Flickable.VerticalFlick 36 | || (flickable.flickableDirection === Flickable.AutoFlickDirection && flickable.contentHeight > flickable.height)) 37 | var horizontallyFlickable = (flickable.flickableDirection === Flickable.HorizontalAndVerticalFlick || flickable.flickableDirection === Flickable.HorizontalFlick 38 | || (flickable.flickableDirection === Flickable.AutoFlickDirection && flickable.contentWidth > flickable.width)) 39 | 40 | if ((!verticallyFlickable && !horizontallyFlickable) || !inputItem.hasOwnProperty("cursorRectangle")) 41 | return 42 | 43 | var cursorRectangle = flickable.contentItem.mapFromItem(inputItem, inputItem.cursorRectangle.x, inputItem.cursorRectangle.y) 44 | 45 | var oldContentY = flickable.contentY 46 | if (verticallyFlickable) { 47 | var scrollMarginVertical = (flickable && flickable.scrollMarginVertical) ? flickable.scrollMarginVertical : 10 48 | if (flickable.contentY >= cursorRectangle.y - scrollMarginVertical) 49 | flickable.contentY = Math.max(0, cursorRectangle.y - scrollMarginVertical) 50 | else if (flickable.contentY + flickable.height <= cursorRectangle.y + inputItem.cursorRectangle.height + scrollMarginVertical) 51 | flickable.contentY = Math.min(flickable.contentHeight - flickable.height, cursorRectangle.y + inputItem.cursorRectangle.height - flickable.height + scrollMarginVertical) 52 | } 53 | if (horizontallyFlickable) { 54 | var scrollMarginHorizontal = (flickable && flickable.scrollMarginHorizontal) ? flickable.scrollMarginHorizontal : 10 55 | if (flickable.contentX >= cursorRectangle.x - scrollMarginHorizontal) 56 | flickable.contentX = Math.max(0, cursorRectangle.x - scrollMarginHorizontal) 57 | else if (flickable.contentX + flickable.width <= cursorRectangle.x + inputItem.cursorRectangle.width + scrollMarginHorizontal) 58 | flickable.contentX = Math.min(flickable.contentWidth - flickable.width, cursorRectangle.x + inputItem.cursorRectangle.width - flickable.width + scrollMarginHorizontal) 59 | } 60 | } 61 | } 62 | Timer { 63 | id: delayedLoading 64 | interval: 10 65 | onTriggered: { 66 | ensureVisible(innerFlickable) 67 | ensureVisible(outerFlickable) 68 | } 69 | } 70 | Connections { 71 | ignoreUnknownSignals: true 72 | target: inputItem && !Qt.inputMethod.animating ? Qt.inputMethod : null 73 | function onKeyboardRectangleChanged() { delayedLoading.triggered() } 74 | } 75 | Connections { 76 | ignoreUnknownSignals: true 77 | target: inputItem && inputItem.activeFocus ? inputItem : null 78 | function onCursorRectangleChanged() { delayedLoading.triggered() } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | project(settingsapp VERSION 1.0 LANGUAGES CXX) 4 | 5 | if(NOT DEFINED INSTALL_EXAMPLESDIR) 6 | set(INSTALL_EXAMPLESDIR "${CMAKE_INSTALL_PREFIX}/share/examples") 7 | endif() 8 | set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/deviceutilities/settingsapp") 9 | 10 | set(CMAKE_AUTOMOC ON) 11 | set(CMAKE_CXX_STANDARD 17) 12 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 13 | 14 | find_package(Qt6 COMPONENTS Core Qml Quick) 15 | 16 | add_subdirectory(DeviceUtilities/SettingsUI) 17 | add_subdirectory(DeviceUtilities/QtButtonImageProvider) 18 | 19 | set(qml_files 20 | "main.qml" 21 | "AutoScroller.qml" 22 | "HandwritingModeButton.qml" 23 | ) 24 | 25 | set(images 26 | "images/FloatingButton_Active.png" 27 | "images/FloatingButton_Available.png" 28 | "images/FloatingButton_Unavailable.png" 29 | ) 30 | 31 | qt_add_executable(settingsapp 32 | main.cpp 33 | ) 34 | 35 | qt_add_qml_module(settingsapp 36 | URI DeviceUtilities 37 | VERSION 1.0 38 | QML_FILES 39 | ${qml_files} 40 | SOURCES 41 | applicationsettings.cpp 42 | applicationsettings.h 43 | RESOURCES 44 | ${images} 45 | ) 46 | 47 | target_link_libraries(settingsapp PRIVATE 48 | Qt::Core 49 | Qt::Gui 50 | ) 51 | 52 | install(TARGETS settingsapp 53 | RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" 54 | BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" 55 | LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" 56 | ) 57 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/QtButtonImageProvider/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # There are a number of options to qt_add_qml_module that start with capital NO. 2 | # The most prominent NO option is probably NO_GENERATE_PLUGIN_SOURCE. 3 | # Unfortunately image providers still need to be configured per QML engine. 4 | # Therefore, if you bundle an image provider in your QML module, you need to implement 5 | # the QQmlEngineExtensionPlugin::initializeEngine() method. 6 | # This, in turn, makes it necessary to write your own plugin. 7 | # In this example the plugin is in the QtButtonImageProvider class. 8 | 9 | qt_add_qml_module(qtbuttonimageproviderplugin 10 | URI "DeviceUtilities.QtButtonImageProvider" 11 | VERSION 1.0 12 | PLUGIN_TARGET qtbuttonimageproviderplugin 13 | NO_PLUGIN_OPTIONAL 14 | NO_GENERATE_PLUGIN_SOURCE 15 | CLASS_NAME QtButtonImageProviderPlugin 16 | SOURCES 17 | plugin.cpp plugin_p.h 18 | qtbuttonimageprovider.cpp qtbuttonimageprovider.h 19 | QML_FILES 20 | "QtButton.qml" 21 | ) 22 | 23 | target_link_libraries(qtbuttonimageproviderplugin PRIVATE 24 | Qt::Quick 25 | ) 26 | 27 | install(TARGETS qtbuttonimageproviderplugin 28 | DESTINATION "${INSTALL_EXAMPLEDIR}/DeviceUtilities/QtButtonImageProvider" 29 | ) 30 | install(FILES $/qmldir 31 | DESTINATION "${INSTALL_EXAMPLEDIR}/DeviceUtilities/QtButtonImageProvider" 32 | ) 33 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/QtButtonImageProvider/QtButton.qml: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | import QtQuick 4 | import DeviceUtilities.SettingsUI 5 | 6 | Image { 7 | id: root 8 | source: "image://QtButton/" + cutSize + "/" + fillColor + "/" + borderColor 9 | sourceSize: Qt.size(width, height) 10 | property string state: "enabled" 11 | property int cutSize: 10 12 | property color fillColor: Globals.buttonGreenColor 13 | property color borderColor: mouseArea.pressed ? Globals.buttonActiveColor : Globals.buttonGreenColor 14 | property alias text: buttonText.text 15 | property alias fontFamily: buttonText.font.family 16 | signal clicked() 17 | 18 | width: buttonText.contentWidth + cutSize * 4 19 | 20 | MouseArea { 21 | id: mouseArea 22 | anchors.fill: parent 23 | onClicked: root.clicked() 24 | } 25 | Text { 26 | id: buttonText 27 | anchors.fill: parent 28 | verticalAlignment: Text.AlignVCenter 29 | horizontalAlignment: Text.AlignHCenter 30 | font.pixelSize: parent.height * 0.65 31 | //font.family: Globals.appFont 32 | color: "white" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/QtButtonImageProvider/plugin.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #include "plugin_p.h" 4 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/QtButtonImageProvider/plugin_p.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #ifndef QTBUTTONIMAGEPROVIDERQMLPLUGIN_H 4 | #define QTBUTTONIMAGEPROVIDERQMLPLUGIN_H 5 | 6 | #include "qtbuttonimageprovider.h" 7 | #include 8 | 9 | // 10 | // W A R N I N G 11 | // ------------- 12 | // 13 | // This file is not part of the Qt API. It exists for the convenience 14 | // of other Qt classes. This header file may change from version to 15 | // version without notice, or even be removed. 16 | // 17 | // We mean it. 18 | // 19 | 20 | QT_BEGIN_NAMESPACE 21 | 22 | class QtButtonImageProviderQmlPlugin : public QQmlEngineExtensionPlugin 23 | { 24 | Q_OBJECT 25 | Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) 26 | 27 | public: 28 | void initializeEngine(QQmlEngine *engine, const char *uri) final 29 | { 30 | Q_UNUSED(uri); 31 | engine->addImageProvider("QtButton", new QtButtonImageProvider); 32 | } 33 | }; 34 | 35 | QT_END_NAMESPACE 36 | #endif //QTBUTTONIMAGEPROVIDERQMLPLUGIN_H 37 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/QtButtonImageProvider/qtbuttonimageprovider.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #include 4 | #include 5 | #include 6 | 7 | #include "qtbuttonimageprovider.h" 8 | 9 | QtButtonImageProvider::QtButtonImageProvider() 10 | : QQuickImageProvider(QQuickImageProvider::Pixmap) 11 | { 12 | } 13 | 14 | QPixmap QtButtonImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) 15 | { 16 | bool ok = false; 17 | 18 | QStringList params = id.split("/"); 19 | 20 | int cutSize = params.at(0).toInt(&ok); 21 | 22 | if (!ok) 23 | cutSize = 10; 24 | 25 | QColor fillColor; 26 | QColor borderColor; 27 | 28 | if (params.length() > 1) { 29 | fillColor = QColor(params.at(1)); 30 | } 31 | 32 | if (params.length() > 2) 33 | borderColor = QColor(params.at(2)); 34 | 35 | if (!fillColor.isValid()) 36 | fillColor = "#00eb00"; 37 | 38 | if (!borderColor.isValid()) 39 | borderColor ="white"; 40 | 41 | int width = 100; 42 | int height = 50; 43 | 44 | if (size) 45 | *size = QSize(requestedSize.width(), requestedSize.height()); 46 | 47 | QPixmap pixmap(requestedSize.width() > 0 ? requestedSize.width() : width, 48 | requestedSize.height() > 0 ? requestedSize.height() : height); 49 | pixmap.fill(Qt::transparent); 50 | 51 | QPainter painter(&pixmap); 52 | const qreal borderPenWidth = 2; 53 | QPen borderPen(QBrush(borderColor), borderPenWidth); 54 | borderPen.setJoinStyle(Qt::MiterJoin); 55 | painter.setRenderHint(QPainter::Antialiasing, true); 56 | painter.setPen(borderPen); 57 | painter.setBrush(fillColor); 58 | 59 | QPainterPath path; 60 | qreal top = borderPenWidth - 1; 61 | qreal left = borderPenWidth - 1; 62 | qreal bottom = pixmap.height() - borderPenWidth; 63 | qreal right = pixmap.width() - borderPenWidth; 64 | path.moveTo(left + cutSize, top); 65 | path.lineTo(right, top); 66 | path.lineTo(right, bottom - cutSize); 67 | path.lineTo(right - cutSize, bottom); 68 | path.lineTo(left, bottom); 69 | path.lineTo(left, top + cutSize); 70 | path.lineTo(left + cutSize, top); 71 | painter.drawPath(path); 72 | 73 | return pixmap; 74 | } 75 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/QtButtonImageProvider/qtbuttonimageprovider.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #ifndef QTBUTTONIMAGEPROVIDER_H 4 | #define QTBUTTONIMAGEPROVIDER_H 5 | 6 | #include 7 | #include 8 | 9 | class QtButtonImageProvider : public QQuickImageProvider 10 | { 11 | public: 12 | QtButtonImageProvider(); 13 | 14 | QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) override; 15 | 16 | void setCutSize(int size) { m_cutSize = size; } 17 | private: 18 | int m_cutSize; 19 | }; 20 | 21 | #endif // QTBUTTONIMAGEPROVIDER_H 22 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(qml_files 2 | "Globals.qml" 3 | "SettingsUI.qml" 4 | ) 5 | 6 | # Resources: 7 | set(images 8 | "icons/back.svg" 9 | "icons/network.svg" 10 | ) 11 | 12 | set_source_files_properties(Globals.qml 13 | PROPERTIES 14 | QT_QML_SINGLETON_TYPE true 15 | ) 16 | 17 | find_package(Qt6 COMPONENTS NetworkSettings QuickControls2) 18 | 19 | add_subdirectory(Network) 20 | 21 | qt_add_qml_module(settingsui 22 | URI "DeviceUtilities.SettingsUI" 23 | VERSION 1.0 24 | QML_FILES 25 | ${qml_files} 26 | RESOURCES 27 | ${images} 28 | ) 29 | 30 | target_link_libraries(settingsui PRIVATE 31 | Qt::NetworkSettings 32 | Qt::QuickControls2 33 | ) 34 | 35 | set_target_properties(settingsuiplugin PROPERTIES 36 | INSTALL_RPATH $ORIGIN/../..:$ORIGIN/../../${CMAKE_INSTALL_LIBDIR} 37 | ) 38 | 39 | install(TARGETS settingsui 40 | RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" 41 | BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" 42 | LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" 43 | ) 44 | 45 | install(TARGETS settingsuiplugin 46 | LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}/DeviceUtilities/SettingsUI" 47 | ) 48 | install(FILES $/qmldir 49 | DESTINATION "${INSTALL_EXAMPLEDIR}/DeviceUtilities/SettingsUI" 50 | ) 51 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Globals.qml: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | pragma Singleton 4 | import QtQuick 5 | import QtDeviceUtilities.NetworkSettings 6 | 7 | QtObject { 8 | id: globals 9 | readonly property string appFont: "TitilliumWeb" 10 | readonly property color backgroundColor: "#09102b" 11 | readonly property color borderColor: "#9d9faa" 12 | readonly property color buttonGreenColor: "#41cd52" 13 | readonly property color buttonGrayColor: "#9d9faa" 14 | readonly property color buttonActiveColor: "#216729" 15 | readonly property color scrollBarColor: "#41cd52" 16 | 17 | readonly property real spacing: 0.5 18 | readonly property real titleFontSize: 0.04 19 | readonly property real subTitleFontSize: 0.035 20 | readonly property real valueFontSize: 0.025 21 | readonly property real fieldHeight: 0.07 22 | readonly property real fieldTextHeight: 0.05 23 | readonly property real buttonHeight: 0.05 24 | 25 | function margin(width) { 26 | return (width / 3 * 2) * 0.05; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/AddressListEntry.qml: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | import QtQuick 4 | import QtQuick.Layouts 5 | import QtQuick.Controls 6 | 7 | RowLayout { 8 | id: root 9 | spacing: 10 10 | property alias model: repeater.model 11 | property bool modified: false 12 | property alias title: label.text 13 | 14 | Label { 15 | id: label 16 | Layout.preferredWidth: content.titleWidth 17 | horizontalAlignment: Text.AlignRight 18 | Layout.alignment: Qt.AlignTop 19 | Layout.topMargin: 10 20 | } 21 | ColumnLayout { 22 | spacing: 10 23 | Layout.fillWidth: true 24 | 25 | Repeater { 26 | id: repeater 27 | visible: count > 0 28 | RowLayout { 29 | spacing: 10 30 | TextField { 31 | text: edit 32 | Layout.fillWidth: true 33 | onEditingFinished: { 34 | root.modified = true; 35 | edit = text; 36 | } 37 | } 38 | Button { 39 | Layout.preferredWidth: height 40 | text: "-" 41 | visible: repeater.count > 0 42 | onClicked: { 43 | root.modified = true; 44 | root.model.remove(index); 45 | } 46 | } 47 | Button { 48 | Layout.preferredWidth: height 49 | visible: index === repeater.count - 1 50 | text: "+" 51 | onClicked: root.model.append("") 52 | 53 | Layout.alignment: Qt.AlignRight 54 | } 55 | } 56 | } 57 | RowLayout { 58 | visible: repeater.count === 0 59 | spacing: 10 60 | TextField { 61 | id: nameServerEntryItem 62 | Layout.fillWidth: true 63 | text: "" 64 | onAccepted: root.model.append(text) 65 | } 66 | Button { 67 | Layout.preferredWidth: height 68 | text: "+" 69 | onClicked: nameServerEntryItem.accepted() 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(qml_files 2 | "CustomSwitch.qml" 3 | "CustomTableView.qml" 4 | "AddressListEntry.qml" 5 | "ComboBoxEntry.qml" 6 | "EditWiredSettings.qml" 7 | "IpAddressTextField.qml" 8 | "NetworkListView.qml" 9 | "NetworkSettings.qml" 10 | "PassphraseEnter.qml" 11 | "WifiSelectorDelegate.qml" 12 | "WifiSettings.qml" 13 | "WifiSignalMonitor.qml" 14 | "WiredSettings.qml" 15 | ) 16 | 17 | # Resources: 18 | set(images 19 | "icons/Alert_yellow_1x.png" 20 | "icons/WifiAnim_black_2x.png" 21 | "icons/Wifi_lightgray_2x.png" 22 | ) 23 | 24 | find_package(Qt6 COMPONENTS NetworkSettings QuickControls2) 25 | 26 | qt_add_qml_module(settingsuinetwork 27 | URI "DeviceUtilities.SettingsUI.Network" 28 | VERSION 1.0 29 | QML_FILES 30 | ${qml_files} 31 | RESOURCES 32 | ${images} 33 | ) 34 | 35 | target_link_libraries(settingsuinetwork PRIVATE 36 | Qt::NetworkSettings 37 | Qt::QuickControls2 38 | ) 39 | 40 | set_target_properties(settingsuinetworkplugin PROPERTIES 41 | INSTALL_RPATH $ORIGIN/../../..:$ORIGIN/../../../${CMAKE_INSTALL_LIBDIR} 42 | ) 43 | 44 | install(TARGETS settingsuinetwork 45 | RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" 46 | BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" 47 | LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" 48 | ) 49 | 50 | install(TARGETS settingsuinetworkplugin 51 | DESTINATION "${INSTALL_EXAMPLEDIR}/DeviceUtilities/SettingsUI/Network" 52 | ) 53 | install(FILES $/qmldir 54 | DESTINATION "${INSTALL_EXAMPLEDIR}/DeviceUtilities/SettingsUI/Network" 55 | ) 56 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/ComboBoxEntry.qml: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | import QtQuick 4 | import QtQuick.Layouts 5 | import QtQuick.Controls 6 | 7 | RowLayout { 8 | id: root 9 | spacing: 10 10 | width: parent.width 11 | 12 | property alias title: label.text 13 | property alias currentIndex: cb.currentIndex 14 | property alias delegate: cb.delegate 15 | property alias textRole: cb.textRole 16 | property alias model: cb.model 17 | property alias count: cb.count 18 | property int titleWidth: -1 19 | signal activated(int index) 20 | signal highlighted(int index) 21 | 22 | Label { 23 | id: label 24 | Layout.preferredWidth: root.titleWidth 25 | horizontalAlignment: Text.AlignRight 26 | Layout.alignment: Qt.AlignVCenter 27 | } 28 | ComboBox { 29 | id: cb 30 | textRole: "text" 31 | Layout.fillWidth: true 32 | onActivated: root.activated(currentIndex) 33 | onHighlightedIndexChanged: root.highlighted(currentIndex) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/CustomSwitch.qml: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | import QtQuick 4 | import QtQuick.Controls 5 | import DeviceUtilities.SettingsUI 6 | import DeviceUtilities.QtButtonImageProvider 7 | 8 | Switch { 9 | id: control 10 | 11 | property alias indicatorWidth: indicatorImg.width 12 | property alias indicatorHeight: indicatorImg.height 13 | 14 | indicator: Image { 15 | id: indicatorImg 16 | width: 200 17 | height: 75 18 | sourceSize: Qt.size(width, height) 19 | anchors.horizontalCenter: control.horizontalCenter 20 | y: parent.height / 2 - height / 2 21 | source: "image://QtButton/10/#848895/transparent" 22 | Text { 23 | id: offText 24 | anchors.left: parent.left 25 | anchors.leftMargin: parent.width * 0.075 26 | anchors.verticalCenter: parent.verticalCenter 27 | horizontalAlignment: Text.AlignHCenter 28 | verticalAlignment: Text.AlignVCenter 29 | fontSizeMode: Text.Fit 30 | minimumPixelSize: 1 31 | font.pixelSize: parent.height * 0.55 32 | color: "#3b4155" 33 | text: "OFF" 34 | font.family: Globals.appFont 35 | } 36 | Text { 37 | id: onText 38 | anchors.right: parent.right 39 | anchors.rightMargin: parent.width * 0.1 40 | anchors.verticalCenter: parent.verticalCenter 41 | horizontalAlignment: Text.AlignHCenter 42 | verticalAlignment: Text.AlignVCenter 43 | fontSizeMode: Text.Fit 44 | minimumPixelSize: 1 45 | font.pixelSize: parent.height * 0.55 46 | color: "#3b4155" 47 | text: "ON" 48 | font.family: Globals.appFont 49 | } 50 | 51 | Binding { 52 | target: qtHandle 53 | property: "x" 54 | value: control.checked ? indicatorImg.width - qtHandle.width - indicatorImg.width * 0.025 : indicatorImg.width * 0.025 55 | when: !mousearea.drag.active 56 | } 57 | 58 | QtButton { 59 | id: qtHandle 60 | anchors.verticalCenter: parent.verticalCenter 61 | width: parent.width * 0.475 62 | height: parent.height * 0.9 63 | fillColor: control.checked ? Globals.buttonGreenColor : Globals.buttonGrayColor 64 | text: control.checked ? "ON" : "OFF" 65 | borderColor: "transparent" 66 | Behavior on x { 67 | NumberAnimation { duration: 50 } 68 | } 69 | 70 | MouseArea { 71 | id: mousearea 72 | anchors.fill: parent 73 | drag.target: qtHandle 74 | drag.axis: Drag.XAxis 75 | drag.minimumX: indicatorImg.width * 0.005 76 | drag.maximumX: indicatorImg.width - width - indicatorImg.width * 0.005 77 | 78 | onReleased: { 79 | if (qtHandle.x > indicatorImg.width / 5 ) { 80 | control.checked = true 81 | } else { 82 | control.checked = false 83 | } 84 | } 85 | } 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/CustomTableView.qml: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | import QtQuick 4 | import QtQuick.Layouts 5 | import QtQuick.Controls 6 | import DeviceUtilities.SettingsUI 7 | 8 | ColumnLayout { 9 | id: root 10 | 11 | Layout.fillHeight: true 12 | Layout.fillWidth: true 13 | 14 | property var headerTexts: [] 15 | property var roleNames: [] 16 | property alias model: listView.model 17 | property alias localeIndex: listView.currentIndex 18 | signal clicked(int index) 19 | 20 | Timer { //A workaround to position the listView.. 21 | interval: 250 22 | running: true 23 | onTriggered: listView.positionViewAtIndex(listView.currentIndex, ListView.Beginning) 24 | } 25 | 26 | ListView { 27 | id: listView 28 | Layout.fillHeight: true 29 | Layout.fillWidth: true 30 | clip: true 31 | 32 | onCurrentIndexChanged: { 33 | if (listView.model) { 34 | positionViewAtIndex(listView.currentIndex, ListView.beginning) 35 | } 36 | } 37 | 38 | ScrollBar.vertical: ScrollBar { 39 | contentItem: Rectangle { 40 | implicitWidth: listView.width * 0.0175 41 | implicitHeight: listView.height * 0.5 42 | color: Globals.scrollBarColor 43 | } 44 | } 45 | 46 | delegate: Item { 47 | id: delegateRectangle 48 | width: parent.width 49 | height: listView.height * 0.1 50 | property var delegateData: entry 51 | 52 | Row { 53 | anchors.fill: parent 54 | anchors.leftMargin: 10 55 | spacing: 10 56 | 57 | Repeater { 58 | model: root.roleNames.length 59 | 60 | Text { 61 | width: parent.width / root.roleNames.length 62 | text: delegateData[root.roleNames[index]] 63 | anchors.verticalCenter: parent.verticalCenter 64 | verticalAlignment: Text.AlignVCenter 65 | font.pixelSize: delegateRectangle.height * 0.5 66 | antialiasing: false 67 | smooth: false 68 | renderType: listView.moving ? Text.NativeRendering : Text.QtRendering 69 | color: listView.currentIndex == delegateRectangle.index ? Globals.buttonGreenColor : "white" 70 | font.family: Globals.appFont 71 | } 72 | } 73 | } 74 | MouseArea { 75 | anchors.fill: parent 76 | onClicked: root.clicked(index) 77 | } 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/IpAddressTextField.qml: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | import QtQuick 4 | import QtQuick.Controls 5 | 6 | TextField { 7 | Layout.fillWidth: true 8 | validator: RegExpValidator { regExp: /^(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))$/ } 9 | } 10 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/NetworkListView.qml: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | import QtQuick 4 | import QtDeviceUtilities.NetworkSettings 5 | import DeviceUtilities.SettingsUI 6 | import DeviceUtilities.QtButtonImageProvider 7 | 8 | ListView { 9 | id: list 10 | clip: true 11 | property var connectingService: null 12 | property bool retryConnectAfterIdle: false 13 | 14 | focus: true 15 | boundsBehavior: Flickable.DragOverBounds 16 | model: NetworkSettingsManager.services 17 | 18 | function connectBySsid() { 19 | passphraseEnter.showSsid = true 20 | passphraseEnter.visible = true 21 | } 22 | 23 | delegate: Item { 24 | id: networkDelegate 25 | width: list.width 26 | height: list.height * 0.15 27 | Column { 28 | anchors.left: parent.left 29 | anchors.verticalCenter: parent.verticalCenter 30 | width: parent.width * 0.5 31 | Text { 32 | id: networkName 33 | horizontalAlignment: Text.AlignLeft 34 | verticalAlignment: Text.AlignVCenter 35 | font.pixelSize: Globals.subTitleFontSize 36 | font.family: Globals.appFont 37 | color: connected ? Globals.buttonGreenColor : "white" 38 | text: (type === NetworkSettingsType.Wired) ? name + " (" + entry["id"] + ")" : name 39 | } 40 | Row { 41 | id: ipRow 42 | height: networkDelegate.height * 0.275 * opacity 43 | spacing: networkDelegate.width * 0.0075 44 | Item { 45 | width: Globals.margin(list.width) 46 | height: 1 47 | } 48 | Text { 49 | id: ipAddressLabel 50 | height: parent.height 51 | anchors.verticalCenter: parent.verticalCenter 52 | text: qsTr("IP Address:") 53 | color: connected ? Globals.buttonGreenColor : "white" 54 | font.pixelSize: Globals.valueFontSize 55 | font.family: Globals.appFont 56 | verticalAlignment: Text.AlignVCenter 57 | horizontalAlignment: Text.AlignLeft 58 | } 59 | Text { 60 | id: ipAddress 61 | width: root.width * 0.15 62 | height: parent.height 63 | anchors.verticalCenter: parent.verticalCenter 64 | verticalAlignment: Text.AlignVCenter 65 | horizontalAlignment: Text.AlignLeft 66 | color: connected ? Globals.buttonGreenColor : "white" 67 | text: connected ? NetworkSettingsManager.services.itemFromRow(index).ipv4.address 68 | : (NetworkSettingsManager.services.itemFromRow(index).state === NetworkSettingsState.Idle) ? 69 | qsTr("Not connected") : qsTr("Connecting") 70 | font.pixelSize: Globals.valueFontSize 71 | font.family: Globals.appFont 72 | font.styleName: connected ? "SemiBold" : "Regular" 73 | } 74 | } 75 | } 76 | QtButton { 77 | id: connectButton 78 | fontFamily: Globals.appFont 79 | anchors.right: parent.right 80 | anchors.verticalCenter: parent.verticalCenter 81 | fillColor: connected ? Globals.buttonGrayColor : Globals.buttonGreenColor 82 | borderColor: "transparent" 83 | text: connected ? qsTr("DISCONNECT") : qsTr("CONNECT") 84 | enabled: true 85 | onClicked: { 86 | if (connected) { 87 | NetworkSettingsManager.services.itemFromRow(index).disconnectService(); 88 | } else { 89 | list.connectingService = NetworkSettingsManager.services.itemFromRow(index) 90 | if (list.connectingService) { 91 | passphraseEnter.extraInfo = ""; 92 | list.connectingService.connectService(); 93 | list.connectingService.stateChanged.connect(connectingServiceStateChange); 94 | } 95 | } 96 | } 97 | } 98 | Rectangle { 99 | id: delegateBottom 100 | width: networkDelegate.width 101 | color: Globals.borderColor 102 | height: 2 103 | anchors.bottom: networkDelegate.bottom 104 | anchors.horizontalCenter: networkDelegate.horizontalCenter 105 | } 106 | Behavior on height { NumberAnimation { duration: 200} } 107 | } 108 | 109 | Connections { 110 | target: NetworkSettingsManager.userAgent 111 | function onShowUserCredentialsInput() { 112 | passphraseEnter.visible = true; 113 | } 114 | } 115 | 116 | // Popup for entering passphrase 117 | PassphraseEnter { 118 | id: passphraseEnter 119 | parent: list.parent 120 | visible: false 121 | } 122 | 123 | function connectingServiceStateChange() { 124 | if (connectingService !== null) { 125 | if (connectingService.state === NetworkSettingsState.Failure) { 126 | // If authentication failed, request connection again. That will 127 | // initiate new passphrase request. 128 | retryConnectAfterIdle = true 129 | } else if (connectingService.state === NetworkSettingsState.Ready) { 130 | // If connection succeeded, we no longer have service connecting 131 | connectingService = null; 132 | retryConnectAfterIdle = false; 133 | } else if (connectingService.state === NetworkSettingsState.Idle) { 134 | if (retryConnectAfterIdle) { 135 | passphraseEnter.extraInfo = qsTr("Invalid passphrase"); 136 | connectingService.connectService(); 137 | } 138 | retryConnectAfterIdle = false; 139 | } 140 | } 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/NetworkSettings.qml: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | import QtQuick 4 | import QtDeviceUtilities.NetworkSettings 5 | import DeviceUtilities.QtButtonImageProvider 6 | import DeviceUtilities.SettingsUI 7 | 8 | Item { 9 | id: networkSettingsRoot 10 | anchors.fill: parent 11 | 12 | Connections { 13 | target: NetworkSettingsManager 14 | function onInterfacesChanged() { 15 | if (NetworkSettingsManager.interface(NetworkSettingsType.Wifi, 0) !== null) { 16 | wifiSwitch.visible = true 17 | wifiSwitch.checked = Qt.binding(function() { return NetworkSettingsManager.interface(NetworkSettingsType.Wifi, 0).powered }) 18 | } else { 19 | wifiSwitch.visible = false 20 | } 21 | } 22 | } 23 | 24 | Text { 25 | id: wlanText 26 | visible: wifiSwitch.visible 27 | text: qsTr("WiFi") 28 | font.pixelSize: networkSettingsRoot.height * Globals.subTitleFontSize 29 | font.family: Globals.appFont 30 | font.styleName: "SemiBold" 31 | color: "white" 32 | anchors.top: networkSettingsRoot.top 33 | anchors.left: networkSettingsRoot.left 34 | } 35 | 36 | CustomSwitch { 37 | id: wifiSwitch 38 | anchors.top: wlanText.bottom 39 | anchors.left: wlanText.left 40 | height: networkSettingsRoot.height * Globals.buttonHeight 41 | indicatorWidth: networkSettingsRoot.height * Globals.buttonWidth 42 | indicatorHeight: networkSettingsRoot.height * Globals.buttonHeight 43 | checkable: visible && !wifiSwitchTimer.running 44 | 45 | onCheckedChanged: { 46 | // Power on/off all WiFi interfaces 47 | for (var i = 0; NetworkSettingsManager.interface(NetworkSettingsType.Wifi, i) !== null; i++) { 48 | NetworkSettingsManager.interface(NetworkSettingsType.Wifi, i).powered = checked 49 | wifiSwitchTimer.start() 50 | } 51 | } 52 | 53 | // At least 1s between switching on/off 54 | Timer { 55 | id: wifiSwitchTimer 56 | interval: 1000 57 | running: false 58 | } 59 | } 60 | QtButton { 61 | id: manualConnect 62 | anchors.top: wlanText.bottom 63 | anchors.left: wifiSwitch.right 64 | anchors.right: manualDisconnect.left 65 | anchors.rightMargin: 10 66 | visible: wifiSwitch.visible 67 | enabled: wifiSwitch.checked 68 | fillColor: enabled ? Globals.buttonGreenColor : Globals.buttonGrayColor 69 | borderColor: "transparent" 70 | height: networkSettingsRoot.height * Globals.buttonHeight 71 | text: qsTr("MANUAL CONNECT") 72 | onClicked: { 73 | networkList.connectBySsid() 74 | } 75 | } 76 | 77 | QtButton { 78 | id: manualDisconnect 79 | anchors.top: wlanText.bottom 80 | anchors.right: networkSettingsRoot.right 81 | visible: wifiSwitch.visible 82 | enabled: NetworkSettingsManager.currentWifiConnection 83 | fillColor: enabled ? Globals.buttonGreenColor : Globals.buttonGrayColor 84 | borderColor: "transparent" 85 | height: networkSettingsRoot.height * Globals.buttonHeight 86 | text: qsTr("DISCONNECT") 87 | onClicked: { 88 | if (NetworkSettingsManager.currentWifiConnection) { 89 | NetworkSettingsManager.currentWifiConnection.disconnectService(); 90 | } 91 | } 92 | } 93 | 94 | Text { 95 | id: networkListTextItem 96 | text: qsTr("Available networks:") 97 | font.pixelSize: networkSettingsRoot.height * Globals.subTitleFontSize 98 | font.family: Globals.appFont 99 | font.styleName: "SemiBold" 100 | color: "white" 101 | anchors.top: (wifiSwitch.visible === true) ? wifiSwitch.bottom : networkSettingsRoot.top 102 | anchors.topMargin: 10 103 | } 104 | 105 | NetworkListView { 106 | id: networkList 107 | anchors.top: networkListTextItem.bottom 108 | anchors.left: networkListTextItem.left 109 | width: networkSettingsRoot.width 110 | height: networkSettingsRoot.height 111 | } 112 | } 113 | 114 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/PassphraseEnter.qml: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | import QtQuick 4 | import QtQuick.Controls 5 | import QtDeviceUtilities.NetworkSettings 6 | import DeviceUtilities.SettingsUI 7 | import DeviceUtilities.QtButtonImageProvider 8 | 9 | Rectangle { 10 | id: passphrasePopup 11 | width: parent.width 12 | height: parent.height 13 | color: Globals.backgroundColor 14 | opacity: 0.9 15 | property string extraInfo: "" 16 | property bool showSsid: false 17 | 18 | property int margin: (width / 3 * 2) * 0.05 19 | property int spacing: margin * 0.5 20 | 21 | Rectangle { 22 | id: frame 23 | color: Globals.backgroundColor 24 | border.color: Globals.borderColor 25 | border.width: 3 26 | anchors.centerIn: parent 27 | width: passphraseColumn.width * 1.1 28 | height: passphraseColumn.height * 1.1 29 | 30 | Column { 31 | id: passphraseColumn 32 | anchors.centerIn: parent 33 | spacing: spacing 34 | 35 | Text { 36 | visible: showSsid 37 | font.pixelSize: passphrasePopup.height * Globals.subTitleFontSize 38 | font.family: Globals.appFont 39 | color: "white" 40 | text: qsTr("Enter SSID") 41 | } 42 | 43 | TextField { 44 | id: ssidField 45 | visible: showSsid 46 | width: passphrasePopup.width * 0.4 47 | height: passphrasePopup.height * 0.075 48 | color: "white" 49 | background: Rectangle{ 50 | color: "transparent" 51 | border.color: ssidField.focus ? Globals.buttonGreenColor : Globals.buttonGrayColor 52 | border.width: ssidField.focus ? width * 0.01 : 2 53 | } 54 | } 55 | 56 | Text { 57 | font.pixelSize: passphrasePopup.height * Globals.subTitleFontSize 58 | font.family: Globals.appFont 59 | color: "white" 60 | text: qsTr("Enter Passphrase") 61 | } 62 | 63 | Text { 64 | font.pixelSize: passphrasePopup.height * Globals.valueFontSize 65 | font.family: Globals.appFont 66 | color: "red" 67 | text: extraInfo 68 | visible: (extraInfo !== "") 69 | } 70 | 71 | TextField { 72 | id: passField 73 | width: passphrasePopup.width * 0.4 74 | height: passphrasePopup.height * 0.075 75 | color: "white" 76 | echoMode: TextInput.Password 77 | background: Rectangle{ 78 | color: "transparent" 79 | border.color: passField.focus ? Globals.buttonGreenColor : Globals.buttonGrayColor 80 | border.width: passField.focus ? width * 0.01 : 2 81 | } 82 | } 83 | 84 | Row { 85 | spacing: parent.width * 0.025 86 | QtButton{ 87 | id: setButton 88 | text: qsTr("SET") 89 | onClicked: { 90 | if (showSsid) { 91 | NetworkSettingsManager.connectBySsid(ssidField.text, passField.text) 92 | showSsid = false 93 | } else { 94 | NetworkSettingsManager.userAgent.setPassphrase(passField.text) 95 | } 96 | passphrasePopup.visible = false; 97 | } 98 | } 99 | QtButton { 100 | id: cancelButton 101 | text: qsTr("CANCEL") 102 | borderColor: "transparent" 103 | fillColor: Globals.buttonGrayColor 104 | onClicked: { 105 | if (!showSsid) { 106 | NetworkSettingsManager.userAgent.cancelInput() 107 | } 108 | showSsid = false 109 | passphrasePopup.visible = false; 110 | } 111 | } 112 | } 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/WifiSelectorDelegate.qml: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | import QtQuick 4 | import QtQuick.Layouts 5 | import QtQuick.Controls 6 | 7 | ItemDelegate { 8 | id: root 9 | autoExclusive: true 10 | property bool connect: connected 11 | contentItem: Item { 12 | width: root.width 13 | 14 | Label { 15 | id: text 16 | leftPadding: root.spacing 17 | anchors.left: parent.left 18 | anchors.top:parent.top 19 | anchors.right: signalMonitor.left 20 | anchors.bottom:parent.bottom 21 | elide: Text.ElideRight 22 | horizontalAlignment: Text.AlignLeft 23 | verticalAlignment: Text.AlignVCenter 24 | text: entry["name"] 25 | } 26 | WifiSignalMonitor { 27 | id: signalMonitor 28 | anchors.right: parent.right 29 | height: parent.height 30 | width: height 31 | signalStrength: entry.wirelessConfig["signalStrength"] 32 | connected: connected 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/WifiSettings.qml: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | import QtQuick 4 | import QtQuick.Layouts 5 | import QtQuick.Controls 6 | import QtDeviceUtilities.NetworkSettings 7 | 8 | Item { 9 | id: root 10 | anchors.fill: parent 11 | Component.onCompleted: NetworkSettingsManager.services.type = NetworkSettingsType.Wifi; 12 | property bool connecting: false 13 | property var selectedInterface: undefined 14 | 15 | Flickable { 16 | anchors.fill: parent 17 | contentHeight: content.height 18 | contentWidth: width 19 | 20 | GroupBox { 21 | title: qsTr("Wireless Settings") 22 | width: parent.width 23 | 24 | ColumnLayout { 25 | id: content 26 | spacing: 20 27 | width: parent.width 28 | 29 | RowLayout { 30 | spacing: 10 31 | id: enableSwitch 32 | width: parent.width 33 | 34 | Label { 35 | Layout.preferredWidth: root.width * 0.382 36 | Layout.alignment: Qt.AlignVCenter 37 | horizontalAlignment: Text.AlignRight 38 | text: selectedInterface.powered ? qsTr("Wi-Fi ON") : qsTr("Wi-Fi OFF") 39 | } 40 | Switch { 41 | checked: selectedInterface.powered 42 | onCheckedChanged: { 43 | selectedInterface.powered = checked 44 | root.connecting = false 45 | connectView.visible = false 46 | } 47 | } 48 | } 49 | RowLayout { 50 | spacing: 10 51 | width: parent.width 52 | 53 | visible: selectedInterface.powered && networkSelection.count > 0 54 | Label { 55 | Layout.preferredWidth: root.width * 0.382 56 | text: qsTr("Current network") 57 | horizontalAlignment: Text.AlignRight 58 | Layout.alignment: Qt.AlignVCenter 59 | 60 | } 61 | ComboBoxEntry { 62 | id: networkSelection 63 | model: NetworkSettingsManager.services 64 | 65 | textRole: "name" 66 | Layout.fillWidth: true 67 | onActivated: function(index) { 68 | if (index >= 0) { 69 | connectView.visible = false 70 | 71 | var service = model.itemFromRow(index) 72 | if (service) { 73 | root.connecting = true 74 | service.connectService(); 75 | } 76 | } 77 | } 78 | 79 | onCountChanged: { 80 | if (count === 0) { 81 | root.connecting = false 82 | connectView.visible = false 83 | } 84 | } 85 | 86 | Component.onCompleted: { 87 | networkSelection.currentIndex = model.activeRow() 88 | } 89 | 90 | delegate: WifiSelectorDelegate { 91 | width: networkSelection.width 92 | onConnectChanged: if (connect) networkSelection.currentIndex = index 93 | } 94 | } 95 | } 96 | 97 | Row { 98 | id: infoRow 99 | spacing: 10 100 | width: parent.width 101 | visible: selectedInterface.powered && selectedInterface.state !== NetworkSettingsState.Online 102 | Label { 103 | id: scanningText 104 | text: { 105 | if (networkSelection.count == 0) 106 | return qsTr("Searching for Wi-Fi networks...") 107 | else if (root.connecting) 108 | return qsTr("Connecting to the network...") 109 | else 110 | return "" 111 | } 112 | horizontalAlignment: Text.AlignLeft 113 | } 114 | WifiSignalMonitor { 115 | id: scanningIcon 116 | scanning: true 117 | visible: scanningText.text !== "" 118 | height: scanningText.height 119 | width: height 120 | } 121 | } 122 | 123 | GroupBox { 124 | id: connectView 125 | title: qsTr("Enter a passphrase") 126 | visible: false 127 | Layout.fillWidth: true 128 | ColumnLayout { 129 | width: parent.width 130 | 131 | RowLayout { 132 | id: errorView 133 | visible: text.text !== "" 134 | spacing: 10 135 | property alias text: text.text 136 | 137 | Image { 138 | source: "icons/Alert_yellow_1x.png" 139 | Layout.alignment: Qt.AlignVCenter 140 | } 141 | Text { 142 | id: text 143 | color: "#face20" 144 | text: "" 145 | Layout.alignment: Qt.AlignVCenter 146 | } 147 | } 148 | RowLayout { 149 | spacing: 10 150 | width: parent.width 151 | 152 | Label { 153 | text: qsTr("Passphrase:") 154 | horizontalAlignment: Text.AlignRight 155 | Layout.preferredWidth: root.width * 0.382 156 | Layout.alignment: Qt.AlignVCenter 157 | } 158 | TextField { 159 | id: passphrase 160 | text: "" 161 | echoMode: TextInput.Password 162 | inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase | Qt.ImhPreferLowercase | Qt.ImhSensitiveData 163 | Layout.alignment: Qt.AlignVCenter 164 | Layout.fillWidth: true 165 | } 166 | } 167 | RowLayout { 168 | spacing: 10 169 | 170 | Button { 171 | text: qsTr("Connect") 172 | onClicked: { 173 | connectView.visible = false 174 | NetworkSettingsManager.userAgent.setPassphrase(passphrase.text) 175 | if (networkSelection.currentIndex != -1) { 176 | NetworkSettingsManager.services.itemFromRow(networkSelection.currentIndex).connectService(); 177 | } 178 | } 179 | } 180 | Button { 181 | text: qsTr("Cancel") 182 | onClicked: { 183 | networkSelection.currentIndex = -1 184 | connectView.visible = false 185 | } 186 | } 187 | } 188 | } 189 | } 190 | ColumnLayout { 191 | spacing: parent.spacing 192 | width: parent.width 193 | visible: selectedInterface.state === NetworkSettingsState.Online || 194 | selectedInterface.state === NetworkSettingsState.Ready 195 | Label { 196 | text: qsTr("IP Address: ") + NetworkSettingsManager.services.itemFromRow(networkSelection.currentIndex).ipv4.address 197 | } 198 | Button { 199 | id: disconnect 200 | text: qsTr("Disconnect") 201 | onClicked: { 202 | NetworkSettingsManager.services.itemFromRow(networkSelection.currentIndex).disconnectService(); 203 | networkSelection.currentIndex = -1; 204 | root.connecting = false 205 | } 206 | } 207 | } 208 | } 209 | Connections { 210 | target: NetworkSettingsManager.userAgent 211 | function onShowUserCredentialsInput() { 212 | connectView.visible = true 213 | root.connecting = false 214 | } 215 | function onError() { 216 | errorView.visible = true 217 | connectView.visible = true 218 | root.connecting = false 219 | if (networkSelection.currentIndex != -1) { 220 | NetworkSettingsManager.services.itemFromRow(networkSelection.currentIndex).removeService(); 221 | } 222 | } 223 | } 224 | } 225 | } 226 | } 227 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/WifiSignalMonitor.qml: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | import QtQuick 4 | 5 | Item { 6 | id: root 7 | property bool scanning: false 8 | property int signalStrength: 100 9 | property bool connected: false 10 | 11 | onSignalStrengthChanged: { 12 | sprite.visible = true; 13 | 14 | if (signalStrength < 10) { 15 | sprite.visible = false; 16 | } 17 | else if (signalStrength < 30) { 18 | sprite.currentFrame = 0; 19 | } 20 | else if (signalStrength < 60) { 21 | sprite.currentFrame = 1; 22 | } 23 | else if (signalStrength < 80) { 24 | sprite.currentFrame = 2; 25 | } 26 | else if (signalStrength <= 100) { 27 | sprite.currentFrame = 3; 28 | } 29 | } 30 | 31 | Image { 32 | id: sprite 33 | property int currentFrame: 0 34 | anchors.fill: parent 35 | source: "icons/Wifi_lightgray_2x.png" 36 | clip: true 37 | 38 | Timer { 39 | id: scanningTimer 40 | running: scanning 41 | interval: 250 42 | repeat: true 43 | onTriggered: { 44 | if (sprite.currentFrame < 4) 45 | sprite.currentFrame++ 46 | else 47 | sprite.currentFrame = 0 48 | } 49 | } 50 | 51 | Image { 52 | height: parent.height 53 | width: parent.width * 4 54 | source: "icons/WifiAnim_black_2x.png" 55 | x: -parent.currentFrame * width / 4 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/WiredSettings.qml: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | import QtQuick 4 | import QtQuick.Layouts 5 | import QtQuick.Controls 6 | import QtDeviceUtilities.NetworkSettings 7 | 8 | Item { 9 | id: root 10 | anchors.fill: parent 11 | property bool editMode: false 12 | property var service: null 13 | property string title: qsTr("Network"); 14 | 15 | Component.onCompleted: { 16 | NetworkSettingsManager.services.type = NetworkSettingsType.Wired; 17 | root.service = NetworkSettingsManager.services.itemFromRow(0); 18 | ipv4Method.currentIndex = service.ipv4.method 19 | } 20 | 21 | onServiceChanged: { 22 | NetworkSettingsManager.services.type = NetworkSettingsType.Wired; 23 | if (!root.service) { 24 | root.service = NetworkSettingsManager.services.itemFromRow(0); 25 | } 26 | } 27 | 28 | GroupBox { 29 | title: qsTr("Ethernet Connection") 30 | anchors.fill: parent 31 | 32 | Column { 33 | spacing: 10 34 | width: parent.width 35 | 36 | ComboBoxEntry { 37 | id: ipv4Method 38 | title: qsTr("Connection method:") 39 | model: ListModel { 40 | id: methodsModel 41 | 42 | ListElement { 43 | text: "DHCP" 44 | method: NetworkSettingsIPv4.Dhcp 45 | } 46 | ListElement { 47 | text: "Manual" 48 | method: NetworkSettingsIPv4.Manual 49 | } 50 | ListElement { 51 | text: "Off" 52 | method: NetworkSettingsIPv4.Off 53 | } 54 | } 55 | 56 | Component.onCompleted: currentIndex = service.ipv4.method 57 | onCurrentIndexChanged: { 58 | if (model.get(currentIndex).method !== NetworkSettingsIPv4.Dhcp) { 59 | service.ipv4.method = model.get(currentIndex).method; 60 | editMode = true; 61 | } 62 | else if (service){ 63 | //Enable DHCP 64 | if (service.ipv4.method !== model.get(currentIndex).method) { 65 | service.ipv4.method = model.get(currentIndex).method; 66 | service.setupIpv4Config(); 67 | } 68 | editMode = false; 69 | } 70 | } 71 | } 72 | Item { 73 | width: parent.width 74 | height: gridLayout.implicitHeight 75 | GridLayout { 76 | id: gridLayout 77 | columns: 2 78 | rows: 4 79 | width: parent.width 80 | visible: service.ipv4.method !== NetworkSettingsIPv4.Off 81 | 82 | Label { 83 | text: qsTr("IP Address: ") 84 | width: parent.width * .3 85 | } 86 | IpAddressTextField { 87 | id: ipv4Address 88 | text: service.ipv4.address 89 | enabled: editMode 90 | onAccepted: if (text.length > 0) service.ipv4.address = text 91 | } 92 | Label { 93 | text: qsTr("Mask: ") 94 | } 95 | IpAddressTextField { 96 | id: ipv4Mask 97 | text: service.ipv4.mask 98 | enabled: editMode 99 | onAccepted: if (text.length > 0) service.ipv4.mask = text 100 | } 101 | Label { 102 | text: qsTr("Router: ") 103 | } 104 | IpAddressTextField { 105 | id: ipv4Gateway 106 | text: service.ipv4.gateway 107 | enabled: editMode 108 | onAccepted: if (text.length > 0) service.ipv4.gateway = text 109 | } 110 | Label { 111 | Layout.alignment: Qt.AlignTop 112 | text: qsTr("DNS server: ") 113 | } 114 | Column { 115 | spacing: 10 116 | Layout.fillWidth: true 117 | Layout.alignment: Qt.AlignTop 118 | 119 | Repeater { 120 | model: service.nameservers 121 | 122 | Label { 123 | text: display 124 | } 125 | } 126 | } 127 | } 128 | MouseArea { 129 | anchors.fill: parent 130 | enabled: !editMode 131 | && methodsModel.get(ipv4Method.currentIndex).method === NetworkSettingsIPv4.Manual 132 | onClicked: editMode = true 133 | } 134 | } 135 | Row { 136 | spacing: 10 137 | Button { 138 | text: qsTr("Save") 139 | visible: editMode 140 | 141 | onClicked: { 142 | ipv4Address.accepted(); 143 | ipv4Mask.accepted(); 144 | ipv4Gateway.accepted(); 145 | service.setupIpv4Config(); 146 | editMode = false; 147 | } 148 | } 149 | Button { 150 | text: qsTr("Cancel") 151 | visible: editMode 152 | onClicked: { 153 | editMode = false; 154 | ipv4Method.currentIndex = service.ipv4.method 155 | } 156 | } 157 | } 158 | Button { 159 | text: qsTr("Edit") 160 | visible: !editMode 161 | onClicked: stackView.push(Qt.resolvedUrl("EditWiredSettings.qml"), {service: root.service}); 162 | } 163 | } 164 | } 165 | } 166 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/Alert_yellow_1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qt/qtdeviceutilities/fd1999b36d27dd731deb599892b6797beaf38c2d/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/Alert_yellow_1x.png -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/WifiAnim_black_2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qt/qtdeviceutilities/fd1999b36d27dd731deb599892b6797beaf38c2d/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/WifiAnim_black_2x.png -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/Wifi_lightgray_2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qt/qtdeviceutilities/fd1999b36d27dd731deb599892b6797beaf38c2d/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/Wifi_lightgray_2x.png -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/generate_icons.sh: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2017 The Qt Company Ltd. 2 | # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #!/bin/bash 4 | # 5 | # This script resizes and sets correct brand colors for the icons in ref folder 6 | # 7 | 8 | ./scripts/cimages.sh ./ref/*.png 9 | ./scripts/cimage.sh ./ref/extra/Alert.png red 10 | ./scripts/cimage.sh ./ref/extra/Alert.png yellow 11 | ./scripts/rimages.sh *.png 12 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/ref/extra/Alert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qt/qtdeviceutilities/fd1999b36d27dd731deb599892b6797beaf38c2d/examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/ref/extra/Alert.png -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/scripts/cimage.sh: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2017 The Qt Company Ltd. 2 | # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #!/bin/bash 4 | 5 | fullfile=$1 6 | filename=$(basename "$fullfile") 7 | extension="${filename##*.}" 8 | filename="${filename%.*}" 9 | 10 | color=$2 11 | if [ "$color" = "qt" ]; then 12 | fill='rgb(128,195,66)' 13 | elif [ "$color" = "black" ]; then 14 | fill='rgb(32,40,42)' 15 | elif [ "$color" = "white" ]; then 16 | fill='rgb(255,255,255)' 17 | elif [ "$color" = "lightgray" ]; then 18 | fill='rgb(214,214,214)' 19 | elif [ "$color" = "red" ]; then 20 | fill='rgb(228,30,37)' 21 | elif [ "$color" = "yellow" ]; then 22 | fill='rgb(250,206,32)' 23 | else 24 | fill="black" 25 | fi 26 | 27 | separator="_" 28 | 29 | convert $fullfile -fuzz 100% -fill $fill -opaque black $filename$separator$color.$extension 30 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/scripts/cimages.sh: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2017 The Qt Company Ltd. 2 | # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #!/bin/bash 4 | 5 | for dir in "$@" 6 | do 7 | echo "$dir" 8 | scripts/cimage.sh $dir qt 9 | scripts/cimage.sh $dir black 10 | scripts/cimage.sh $dir white 11 | scripts/cimage.sh $dir lightgray 12 | done 13 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/scripts/rimage.sh: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2017 The Qt Company Ltd. 2 | # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #!/bin/bash 4 | fullfile=$1 5 | filename=$(basename "$fullfile") 6 | extension="${filename##*.}" 7 | filename="${filename%.*}" 8 | 9 | postix="_1x" 10 | convert $fullfile -resize x16 $filename$postix.$extension 11 | postix="_2x" 12 | convert $fullfile -resize x32 $filename$postix.$extension 13 | postix="_3x" 14 | convert $fullfile -resize x48 $filename$postix.$extension 15 | postix="_4x" 16 | convert $fullfile -resize x64 $filename$postix.$extension 17 | postix="_5x" 18 | convert $fullfile -resize x80 $filename$postix.$extension 19 | postix="_6x" 20 | convert $fullfile -resize x96 $filename$postix.$extension 21 | 22 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/Network/icons/scripts/rimages.sh: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2017 The Qt Company Ltd. 2 | # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #!/bin/bash 4 | 5 | for dir in "$@" 6 | do 7 | echo "$dir" 8 | scripts/rimage.sh $dir 9 | done 10 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/SettingsUI.qml: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | import QtQuick 4 | import DeviceUtilities.SettingsUI.Network 5 | 6 | Rectangle { 7 | id: main 8 | anchors.fill: parent 9 | color: Globals.backgroundColor 10 | opacity: 0.97 11 | property int margin: Globals.margin(main.width) 12 | signal closed() 13 | 14 | NetworkSettings { 15 | anchors.margins: margin 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/icons/back.svg: -------------------------------------------------------------------------------- 1 | back_icon -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/DeviceUtilities/SettingsUI/icons/network.svg: -------------------------------------------------------------------------------- 1 | network_icon -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/HandwritingModeButton.qml: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | import QtQuick 4 | 5 | Item { 6 | id: handwritingModeButton 7 | state: "unavailable" 8 | property bool floating 9 | property bool flipable 10 | readonly property real __minWidthHeight: Math.min(width, height) 11 | 12 | signal clicked() 13 | signal doubleClicked() 14 | 15 | Flipable { 16 | id: flipableImage 17 | anchors.fill: parent 18 | 19 | property bool flipped 20 | 21 | front: Image { 22 | sourceSize.width: handwritingModeButton.__minWidthHeight 23 | sourceSize.height: handwritingModeButton.__minWidthHeight 24 | smooth: false 25 | source: "images/FloatingButton_Unavailable.png" 26 | } 27 | 28 | back: Image { 29 | id: buttonImage 30 | sourceSize.width: handwritingModeButton.__minWidthHeight 31 | sourceSize.height: handwritingModeButton.__minWidthHeight 32 | smooth: false 33 | source: "images/FloatingButton_Available.png" 34 | } 35 | 36 | states: State { 37 | PropertyChanges { target: rotation; angle: 180 } 38 | when: flipableImage.flipped 39 | } 40 | 41 | transform: Rotation { 42 | id: rotation 43 | origin.x: flipableImage.width / 2 44 | origin.y: flipableImage.height / 2 45 | axis { x: 0; y: 1; z: 0 } 46 | angle: 0 47 | } 48 | 49 | transitions: Transition { 50 | enabled: handwritingModeButton.flipable 51 | NumberAnimation { target: rotation; property: "angle"; duration: 400 } 52 | } 53 | } 54 | 55 | states: [ 56 | State { 57 | name: "available" 58 | PropertyChanges { target: flipableImage; flipped: true } 59 | }, 60 | State { 61 | name: "active" 62 | PropertyChanges { target: flipableImage; flipped: true } 63 | PropertyChanges { target: buttonImage; source: "images/FloatingButton_Active.png" } 64 | } 65 | ] 66 | 67 | function snapHorizontal() { 68 | if (!floating) 69 | return 70 | if (mouseArea.drag.maximumX > mouseArea.drag.minimumX) { 71 | if (x + 20 >= mouseArea.drag.maximumX) { 72 | anchors.left = undefined 73 | anchors.right = parent.right 74 | } else if (x - 20 <= mouseArea.drag.minimumX) { 75 | anchors.right = undefined 76 | anchors.left = parent.left 77 | } 78 | } 79 | } 80 | 81 | function snapVertical() { 82 | if (!floating) 83 | return 84 | if (mouseArea.drag.maximumY > mouseArea.drag.minimumY) { 85 | if (y + 20 >= mouseArea.drag.maximumY) { 86 | anchors.top = undefined 87 | anchors.bottom = parent.bottom 88 | } else if (y - 20 <= mouseArea.drag.minimumY) { 89 | anchors.bottom = undefined 90 | anchors.top = parent.top 91 | } 92 | } 93 | } 94 | 95 | MouseArea { 96 | id: mouseArea 97 | anchors.fill: parent 98 | drag { 99 | target: handwritingModeButton.floating ? handwritingModeButton : undefined 100 | axis: Drag.XAxis | Drag.YAxis 101 | minimumX: 0 102 | maximumX: handwritingModeButton.parent.width - handwritingModeButton.width 103 | onMaximumXChanged: !mouseArea.drag.active && handwritingModeButton.snapHorizontal() 104 | minimumY: 0 105 | maximumY: handwritingModeButton.parent.height - handwritingModeButton.height 106 | onMaximumYChanged: !mouseArea.drag.active && handwritingModeButton.snapVertical() 107 | } 108 | onPressed: { 109 | if (!handwritingModeButton.floating) 110 | return 111 | handwritingModeButton.anchors.left = undefined 112 | handwritingModeButton.anchors.top = undefined 113 | handwritingModeButton.anchors.right = undefined 114 | handwritingModeButton.anchors.bottom = undefined 115 | } 116 | onReleased: { 117 | handwritingModeButton.snapHorizontal() 118 | handwritingModeButton.snapVertical() 119 | } 120 | onClicked: { 121 | handwritingModeButton.snapHorizontal() 122 | handwritingModeButton.snapVertical() 123 | clickTimer.restart() 124 | } 125 | onDoubleClicked: { 126 | clickTimer.stop() 127 | handwritingModeButton.snapHorizontal() 128 | handwritingModeButton.snapVertical() 129 | handwritingModeButton.doubleClicked() 130 | } 131 | Timer { 132 | id: clickTimer 133 | interval: Qt.styleHints ? Qt.styleHints.mouseDoubleClickInterval / 3 : 0 134 | repeat: false 135 | onTriggered: handwritingModeButton.clicked() 136 | } 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/applicationsettings.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #include "applicationsettings.h" 4 | #include 5 | #include 6 | 7 | ApplicationSettings::ApplicationSettings(QObject *parent) 8 | : QObject(parent) 9 | { 10 | m_screen = qobject_cast(QCoreApplication::instance())->primaryScreen(); 11 | 12 | if (m_screen->orientation() == Qt::PortraitOrientation) { 13 | m_width = m_screen->availableGeometry().height(); 14 | m_height = m_screen->availableGeometry().width(); 15 | } else { 16 | m_width = m_screen->availableGeometry().width(); 17 | m_height = m_screen->availableGeometry().height(); 18 | } 19 | } 20 | 21 | bool ApplicationSettings::isHighDpi() 22 | { 23 | return (m_screen->devicePixelRatio() >= 2.0); 24 | } 25 | 26 | int ApplicationSettings::width() 27 | { 28 | return m_width; 29 | } 30 | 31 | int ApplicationSettings::height() 32 | { 33 | return m_height; 34 | } 35 | 36 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/applicationsettings.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #ifndef APPLICATIONSETTINGS_H 5 | #define APPLICATIONSETTINGS_H 6 | 7 | #include 8 | #include 9 | 10 | QT_FORWARD_DECLARE_CLASS(QScreen) 11 | 12 | class ApplicationSettings : public QObject 13 | { 14 | Q_OBJECT 15 | Q_PROPERTY(int width READ width CONSTANT FINAL) 16 | Q_PROPERTY(int height READ height CONSTANT FINAL) 17 | Q_PROPERTY(bool isHighDpi READ isHighDpi NOTIFY isHighDpiChanged FINAL) 18 | 19 | QML_ELEMENT 20 | QML_SINGLETON 21 | 22 | public: 23 | explicit ApplicationSettings(QObject *parent = nullptr); 24 | 25 | int width(); 26 | int height(); 27 | bool isHighDpi(); 28 | 29 | signals: 30 | void isHighDpiChanged(bool isHighDpi); 31 | 32 | private: 33 | QScreen *m_screen = nullptr; 34 | int m_width = 1280; 35 | int m_height = 720; 36 | }; 37 | 38 | #endif // APPLICATIONSETTINGS_H 39 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/images/FloatingButton_Active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qt/qtdeviceutilities/fd1999b36d27dd731deb599892b6797beaf38c2d/examples/deviceutilities/settingsuiapp/images/FloatingButton_Active.png -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/images/FloatingButton_Available.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qt/qtdeviceutilities/fd1999b36d27dd731deb599892b6797beaf38c2d/examples/deviceutilities/settingsuiapp/images/FloatingButton_Available.png -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/images/FloatingButton_Unavailable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qt/qtdeviceutilities/fd1999b36d27dd731deb599892b6797beaf38c2d/examples/deviceutilities/settingsuiapp/images/FloatingButton_Unavailable.png -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #include 4 | #include 5 | 6 | #include "applicationsettings.h" 7 | 8 | int main(int argc, char *argv[]) 9 | { 10 | qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard")); 11 | 12 | QGuiApplication app(argc, argv); 13 | 14 | QQmlApplicationEngine engine; 15 | engine.load(QUrl(QStringLiteral("qrc:///DeviceUtilities/main.qml"))); 16 | 17 | return app.exec(); 18 | } 19 | -------------------------------------------------------------------------------- /examples/deviceutilities/settingsuiapp/main.qml: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | import QtQuick 4 | import QtQuick.Window 5 | import QtQuick.VirtualKeyboard 6 | import DeviceUtilities 7 | import DeviceUtilities.SettingsUI 8 | 9 | Window { 10 | id: window 11 | visible: true 12 | width: ApplicationSettings.width 13 | height: ApplicationSettings.height 14 | 15 | Item { 16 | id: root 17 | width: window.width 18 | height: window.height 19 | 20 | SettingsUI { 21 | id: settingsUI 22 | anchors.fill: parent 23 | anchors.bottomMargin: parent.height - inputPanel.y 24 | } 25 | 26 | /* Handwriting input panel for full screen handwriting input. 27 | 28 | This component is an optional add-on for the InputPanel component, that 29 | is, its use does not affect the operation of the InputPanel component, 30 | but it also can not be used as a standalone component. 31 | 32 | The handwriting input panel is positioned to cover the entire area of 33 | application. The panel itself is transparent, but once it is active the 34 | user can draw handwriting on it. 35 | */ 36 | 37 | HandwritingInputPanel { 38 | z: 79 39 | id: handwritingInputPanel 40 | anchors.fill: parent 41 | inputPanel: inputPanel 42 | Rectangle { 43 | z: -1 44 | anchors.fill: parent 45 | color: "black" 46 | opacity: 0.10 47 | } 48 | } 49 | 50 | /* Container area for the handwriting mode button. 51 | 52 | Handwriting mode button can be moved freely within the container area. 53 | In this example, a single click changes the handwriting mode and a 54 | double-click changes the availability of the full screen handwriting input. 55 | */ 56 | Item { 57 | z: 89 58 | visible: handwritingInputPanel.enabled && Qt.inputMethod.visible 59 | anchors { left: parent.left; top: parent.top; right: parent.right; bottom: inputPanel.top; } 60 | HandwritingModeButton { 61 | id: handwritingModeButton 62 | anchors.top: parent.top 63 | anchors.right: parent.right 64 | anchors.margins: 10 65 | floating: true 66 | flipable: true 67 | width: 76 68 | height: width 69 | state: handwritingInputPanel.state 70 | onClicked: handwritingInputPanel.active = !handwritingInputPanel.active 71 | onDoubleClicked: handwritingInputPanel.available = !handwritingInputPanel.available 72 | } 73 | } 74 | 75 | /* Keyboard input panel. 76 | The keyboard is anchored to the bottom of the application. 77 | */ 78 | InputPanel { 79 | id: inputPanel 80 | z: 99 81 | y: root.height 82 | anchors.left: root.left 83 | anchors.right: root.right 84 | 85 | states: State { 86 | name: "visible" 87 | /* The visibility of the InputPanel can be bound to the Qt.inputMethod.visible property, 88 | but then the handwriting input panel and the keyboard input panel can be visible 89 | at the same time. Here the visibility is bound to InputPanel.active property instead, 90 | which allows the handwriting panel to control the visibility when necessary. 91 | */ 92 | when: inputPanel.active 93 | PropertyChanges { 94 | target: inputPanel 95 | y: root.height - inputPanel.height 96 | } 97 | } 98 | transitions: Transition { 99 | from: "" 100 | to: "visible" 101 | reversible: true 102 | ParallelAnimation { 103 | NumberAnimation { 104 | properties: "y" 105 | duration: 250 106 | easing.type: Easing.InOutQuad 107 | } 108 | } 109 | } 110 | AutoScroller {} 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(networksettings) 2 | add_subdirectory(doc) 3 | 4 | if(TARGET Qt::Qml) 5 | add_subdirectory(networksettingsqml) 6 | endif() 7 | -------------------------------------------------------------------------------- /src/doc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(DeviceUtilities INTERFACE) 2 | target_link_libraries(DeviceUtilities INTERFACE Qt::Core) 3 | 4 | if(QT_BUILD_ONLINE_DOCS) 5 | set(DOC_CONF "online/qtdeviceutilities.qdocconf") 6 | else() 7 | set(DOC_CONF "qtdeviceutilities.qdocconf") 8 | endif() 9 | 10 | qt_internal_add_docs(DeviceUtilities 11 | ${DOC_CONF} 12 | ) 13 | -------------------------------------------------------------------------------- /src/doc/QtDeviceUtilitiesDoc: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /src/doc/online/qtdeviceutilities.qdocconf: -------------------------------------------------------------------------------- 1 | include($QT_INSTALL_DOCS/global/qt-module-defaults-online.qdocconf) 2 | include(../qtdeviceutilities-project.qdocconf) 3 | 4 | # Sidebar used for online template 5 | HTML.stylesheets += style/qt5-sidebar.html 6 | 7 | # Turn off single-directory output mode 8 | HTML.nosubdirs = "false" 9 | HTML.outputsubdir = qtdeviceutilities 10 | -------------------------------------------------------------------------------- /src/doc/online/style/qt5-sidebar.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |

Qt Device Utilities

4 |
5 | 11 |
12 | -------------------------------------------------------------------------------- /src/doc/qtdeviceutilities-project.qdocconf: -------------------------------------------------------------------------------- 1 | project = QtDeviceUtilities 2 | description = Qt Device Utilities $QT_VERSION 3 | version = $QT_VERSION 4 | projectname = "Qt Device Utilities" 5 | macro.maintitle = "\\title $projectname $QT_VERSION\n\\keyword $projectname" 6 | 7 | includepaths += -I . \ 8 | -I ../networksettings 9 | 10 | # pass a custom module header to Clang 11 | moduleheader = QtDeviceUtilitiesDoc 12 | 13 | sourcedirs += src \ 14 | ../networksettingsqml \ 15 | ../networksettings 16 | 17 | headerdirs += ../networksettings 18 | 19 | exampledirs += ../../examples 20 | 21 | imagedirs += images 22 | 23 | depends = qtcore qtdoc qtgui qtqml qtquick qtquickcontrols qtwidgets 24 | 25 | qhp.projects = QtDeviceUtilities 26 | 27 | qhp.QtDeviceUtilities.file = qtdeviceutilities.qhp 28 | qhp.QtDeviceUtilities.namespace = io.qt.qtdeviceutilities.$QT_VERSION_TAG 29 | qhp.QtDeviceUtilities.virtualFolder = qtdeviceutilities 30 | qhp.QtDeviceUtilities.indexTitle = Qt Device Utilities $QT_VERSION 31 | qhp.QtDeviceUtilities.indexRoot = 32 | 33 | qhp.QtDeviceUtilities.subprojects = classes qmltypes examples 34 | 35 | qhp.QtDeviceUtilities.subprojects.classes.title = C++ Classes 36 | qhp.QtDeviceUtilities.subprojects.classes.indexTitle = Qt Device Utilities C++ Classes 37 | qhp.QtDeviceUtilities.subprojects.classes.selectors = class fake:headerfile 38 | qhp.QtDeviceUtilities.subprojects.classes.sortPages = true 39 | 40 | qhp.QtDeviceUtilities.subprojects.qmltypes.title = QML Types 41 | qhp.QtDeviceUtilities.subprojects.qmltypes.indexTitle = Qt Device Utilities QML Types 42 | qhp.QtDeviceUtilities.subprojects.qmltypes.selectors = qmlclass 43 | qhp.QtDeviceUtilities.subprojects.qmltypes.sortPages = true 44 | 45 | qhp.QtDeviceUtilities.subprojects.examples.title = Examples 46 | qhp.QtDeviceUtilities.subprojects.examples.indexTitle = Qt Device Utilities Examples 47 | qhp.QtDeviceUtilities.subprojects.examples.selectors = doc:example 48 | qhp.QtDeviceUtilities.subprojects.examples.sortPages = true 49 | 50 | macro.B2Q = "Boot to Qt" 51 | macro.SDK = "Qt for Device Creation" 52 | macro.QAS = "Qt Automotive Suite" 53 | macro.B2QA = "\\e {Boot to Qt for embedded Android}" 54 | macro.B2QL = "\\e {Boot to Qt for embedded Linux}" 55 | macro.QtDU = "Qt Device Utilities" 56 | 57 | # Qt Device Utilities as the landing page 58 | navigation.landingpage = "Qt Device Utilities" 59 | navigation.qmltypespage = "Qt Device Utilities QML Types" 60 | navigation.cppclassespage = "Qt Device Utilities C++ Classes" 61 | 62 | Cpp.ignoredirectives += Q_DECLARE_LOGGING_CATEGORY 63 | Cpp.ignoretokens += Q_DEL_EXPORT 64 | -------------------------------------------------------------------------------- /src/doc/qtdeviceutilities.qdocconf: -------------------------------------------------------------------------------- 1 | include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) 2 | include(qtdeviceutilities-project.qdocconf) 3 | 4 | # Turn off single-directory output mode 5 | HTML.nosubdirs = "false" 6 | HTML.outputsubdir = qtdeviceutilities 7 | -------------------------------------------------------------------------------- /src/doc/src/external-resources.qdoc: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only 3 | 4 | /*! 5 | \externalpage http://code.qt.io/cgit/qt/qtdeviceutilities.git/ 6 | \title Device Utilities Git Repository 7 | */ 8 | 9 | /*! 10 | \externalpage https://code.qt.io/cgit/qt/qtdeviceutilities.git/tree/examples/deviceutilities/settingsuiapp/ 11 | 12 | \title Settings UI 13 | */ 14 | -------------------------------------------------------------------------------- /src/doc/src/qtdeviceutilities-examples.qdoc: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only 3 | 4 | /*! 5 | 6 | \group qtdeviceutilities-examples 7 | \title Qt Device Utilities Examples 8 | \brief Examples on using Qt Device Utilities. 9 | \ingroup-all-examples 10 | 11 | \l{Qt Device Utilities WiFi Tutorial} demonstrates how you can use 12 | the \l{QtDeviceUtilities.NetworkSettings}{NetworkSettings} module for 13 | connecting to WiFi. 14 | 15 | The source code of Qt Device Utilities is availabe via a public Git repository. 16 | For more information, see \l{Device Utilities Git Repository}. 17 | 18 | You find the Qt Device Utilities module sources under 19 | \l{http://code.qt.io/cgit/qt/qtdeviceutilities.git/tree/src}. Especially, 20 | the sources of \l{Settings UI} provide examples of how to use Qt Device Utilities. 21 | */ 22 | -------------------------------------------------------------------------------- /src/doc/src/qtdeviceutilities-index.qdoc: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only 3 | 4 | /*! 5 | \page qtdeviceutilities-index.html 6 | \maintitle 7 | \brief Provides functionality for controlling settings in embedded applications. 8 | 9 | \QtDU provides functionality that is useful for controlling settings in embedded 10 | applications. \QtDU provides the following C++ modules: 11 | 12 | \annotatedlist qtdevice-utilities-cpp-modules 13 | 14 | \QtDU provides the following QML modules: 15 | 16 | \annotatedlist qtdevice-utilities-qml-modules 17 | 18 | \section1 Getting Started 19 | 20 | To include the definitions of the module's class, use the following 21 | directive: 22 | 23 | \badcode 24 | #include 25 | \endcode 26 | 27 | \section2 Building with CMake 28 | 29 | If you're using CMake to build your application, add the following lines to your CMakeLists.txt file: 30 | 31 | \badcode 32 | find_package(Qt6 COMPONENTS NetworkSettings REQUIRED) 33 | target_link_libraries(mytarget Qt6::NetworkSettings) 34 | \endcode 35 | 36 | To import the QML types into your application, use the following import 37 | statements in your .qml file: 38 | 39 | \code 40 | import QtDeviceUtilities.NetworkSettings 41 | \endcode 42 | 43 | \section1 Examples 44 | 45 | \list 46 | \li \l {Qt Device Utilities Examples} 47 | \endlist 48 | 49 | \section1 Reference 50 | 51 | \list 52 | \li \l {Qt Device Utilities C++ Classes} 53 | \li \l {Qt Device Utilities QML Types} 54 | \endlist 55 | */ 56 | 57 | -------------------------------------------------------------------------------- /src/doc/src/qtdeviceutilities-module-cpp.qdoc: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only 3 | 4 | /*! 5 | \page qtdeviceutilities-cpp-classes.html 6 | \title Qt Device Utilities C++ Classes 7 | \brief Provides classes that are useful for embedded applications. 8 | \ingroup modules 9 | 10 | \QtDU modules provide classes that are useful for embedded applications. 11 | 12 | \section1 Classes 13 | 14 | \section2 Qt Network Settings Module 15 | \generatelist {classesbymodule QtNetworkSettings} 16 | */ 17 | 18 | -------------------------------------------------------------------------------- /src/doc/src/qtdeviceutilities-module-qml.qdoc: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only 3 | /*! 4 | \page qtdeviceutilities-qml-types.html 5 | \title Qt Device Utilities QML Types 6 | \brief Provides additional modules that are useful for embedded 7 | applications. 8 | 9 | The QML types in the \QtDU modules can be imported into your application using the 10 | following import statements in your .qml file: 11 | 12 | \badcode 13 | import QtDeviceUtilities.NetworkSettings 14 | \endcode 15 | 16 | \section1 QML Types 17 | 18 | \section2 Qt Network Settings Module 19 | \generatelist qmltypesbymodule QtDeviceUtilities.NetworkSettings 20 | */ 21 | 22 | -------------------------------------------------------------------------------- /src/doc/src/wifiexample.qdoc: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only 3 | /*! 4 | \page qtdeviceutilities-wifitutorial.html 5 | \title Qt Device Utilities WiFi Tutorial 6 | \previouspage Qt Device Utilities Examples 7 | 8 | \section1 Importing NetworkSettings 9 | 10 | Import the NetworkSettings module as follows: 11 | \badcode 12 | import QtDeviceUtilities.NetworkSettings 13 | \endcode 14 | 15 | \section1 Filtering WiFi Networks 16 | 17 | In order to connect to WiFi instead of wired networks, set 18 | NetworkSettingsManager in a WiFi filtering mode: 19 | 20 | \badcode 21 | Component.onCompleted: NetworkSettingsManager.services.type = NetworkSettingsType.Wifi; 22 | \endcode 23 | 24 | After you have set the filter, \l{NetworkSettingsManager::services}{NetworkSettingsManager.services} contains 25 | the NetworkService objects services representing WiFi networks. 26 | 27 | \section1 Connecting to WiFi 28 | 29 | In order to connect to Wifi, invoke the 30 | \l{NetworkService::connectService()}{connectService} method on NetworkService. 31 | 32 | If no passphrase is needed, \l{NetworkService::connectService()}{connectService} 33 | connects to a WiFi network and changes the connected property of the selected service. 34 | 35 | If a passphrase is needed, NetworkSettingsManager.userAgent 36 | emits the \l{NetworkSettingsManager::userAgent.showUserCredentialsInput}{showUserCredentialsInput} signal. 37 | Before a WiFi network is connected, you must provide the passphrase via 38 | \l{NetworkSettingsManager::userAgent.setPassphrase}{NetworkSettingsManager.userAgent.setPassPhrase}. 39 | 40 | To implement the passphrase handling, you must set a signal handler as follows: 41 | \badcode 42 | Connections { 43 | target: NetworkSettingsManager.userAgent 44 | onShowUserCredentialsInput : { 45 | // obtain the passphrase and set it 46 | } 47 | onError: { 48 | // handle errors 49 | } 50 | } 51 | \endcode 52 | 53 | \section1 Implementing User Interface 54 | 55 | When you are implementing a user interface for handling WiFi connections, 56 | remember that \l{NetworkSettingsManager::services}{NetworkSettingsManager.services} 57 | is designed to be used as a model. The \l{Settings UI} implementation 58 | uses it directly to display a list of available WiFi networks. 59 | 60 | Handling WiFi connections and passphrases for list selections 61 | should be straightforward as described in \l{Filtering WiFi Networks} and 62 | \l{Connecting to WiFi}. 63 | */ 64 | -------------------------------------------------------------------------------- /src/networksettings/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Generated from networksettings.pro. 2 | 3 | ##################################################################### 4 | ## NetworkSettings Module: 5 | ##################################################################### 6 | 7 | qt_internal_add_module(NetworkSettings 8 | SOURCES 9 | connman/connmancommon.cpp connman/connmancommon.h 10 | connman/qnetworksettingsinterface_p.cpp connman/qnetworksettingsinterface_p.h 11 | connman/qnetworksettingsmanager_p.cpp connman/qnetworksettingsmanager_p.h 12 | connman/qnetworksettingsservice_p.cpp connman/qnetworksettingsservice_p.h 13 | connman/qnetworksettingsuseragent_p.cpp connman/qnetworksettingsuseragent_p.h 14 | qnetworksettings.cpp qnetworksettings.h 15 | qnetworksettingsaddressmodel.cpp qnetworksettingsaddressmodel.h 16 | qnetworksettingsinterface.cpp qnetworksettingsinterface.h 17 | qnetworksettingsinterfacemodel.cpp qnetworksettingsinterfacemodel.h 18 | qnetworksettingsmanager.cpp qnetworksettingsmanager.h 19 | qnetworksettingsservice.cpp qnetworksettingsservice.h 20 | qnetworksettingsservicemodel.cpp qnetworksettingsservicemodel.h 21 | qnetworksettingsuseragent.cpp qnetworksettingsuseragent.h 22 | qnetworksettingsglobal.h 23 | DBUS_INTERFACE_SOURCES 24 | connman/connman_manager.xml 25 | connman/connman_service.xml 26 | connman/connman_technology.xml 27 | DBUS_INTERFACE_FLAGS # special case 28 | -iconnmancommon.h # special case 29 | INCLUDE_DIRECTORIES 30 | connman 31 | PUBLIC_LIBRARIES 32 | Qt::Core 33 | Qt::DBus 34 | Qt::Network 35 | ) 36 | 37 | file(MAKE_DIRECTORY header_connman) 38 | -------------------------------------------------------------------------------- /src/networksettings/connman/connman_manager.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /src/networksettings/connman/connman_service.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/networksettings/connman/connman_technology.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/networksettings/connman/connmancommon.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #include "connmancommon.h" 4 | 5 | #include 6 | 7 | QT_BEGIN_NAMESPACE 8 | 9 | //Conversion operations for datatypes 10 | const QDBusArgument &operator>>(const QDBusArgument &argument, ConnmanMapStruct &obj) 11 | { 12 | argument.beginStructure(); 13 | argument >> obj.objectPath >> obj.propertyMap; 14 | argument.endStructure(); 15 | return argument; 16 | } 17 | 18 | QDBusArgument &operator<<(QDBusArgument &argument, const ConnmanMapStruct &obj) 19 | { 20 | argument.beginStructure(); 21 | argument << obj.objectPath << obj.propertyMap; 22 | argument.endStructure(); 23 | return argument; 24 | } 25 | 26 | const QString &operator>>(const QString &argument, QNetworkSettingsType &obj) 27 | { 28 | if (argument == Q_AttributeEthernet) { 29 | obj.setType(QNetworkSettingsType::Wired); 30 | } 31 | else if (argument == Q_AttributeWifi) { 32 | obj.setType(QNetworkSettingsType::Wifi); 33 | } 34 | else if (argument == Q_AttributeBluetooth) { 35 | obj.setType(QNetworkSettingsType::Bluetooth); 36 | } 37 | else { 38 | obj.setType(QNetworkSettingsType::Unknown); 39 | } 40 | 41 | return argument; 42 | } 43 | 44 | const QString &operator>>(const QString &argument, QNetworkSettingsState &obj) 45 | { 46 | if (argument == Q_AttributeIdle) { 47 | obj.setState(QNetworkSettingsState::Idle); 48 | } 49 | else if (argument == Q_AttributeFailure) { 50 | obj.setState(QNetworkSettingsState::Failure); 51 | } 52 | else if (argument == Q_AttributeAssociation) { 53 | obj.setState(QNetworkSettingsState::Association); 54 | } 55 | else if (argument == Q_AttributeConfiguration) { 56 | obj.setState(QNetworkSettingsState::Configuration); 57 | } 58 | else if (argument == Q_AttributeReady) { 59 | obj.setState(QNetworkSettingsState::Ready); 60 | } 61 | else if (argument == Q_AttributeDisconnect) { 62 | obj.setState(QNetworkSettingsState::Disconnect); 63 | } 64 | else if (argument == Q_AttributeOneline) { 65 | obj.setState(QNetworkSettingsState::Online); 66 | } 67 | else { 68 | obj.setState(QNetworkSettingsState::Undefined); 69 | } 70 | return argument; 71 | } 72 | 73 | QT_END_NAMESPACE 74 | -------------------------------------------------------------------------------- /src/networksettings/connman/connmancommon.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #ifndef CONNMANCOMMON_H 4 | #define CONNMANCOMMON_H 5 | 6 | #include 7 | #include 8 | 9 | #define Q_PropertyAgentPath QStringLiteral("/ConnmanAgent") 10 | #define Q_PropertyState QStringLiteral("State") 11 | #define Q_PropertyName QStringLiteral("Name") 12 | #define Q_PropertyType QStringLiteral("Type") 13 | #define Q_PropertyConnected QStringLiteral("Connected") 14 | #define Q_PropertyPowered QStringLiteral("Powered") 15 | #define Q_PropertyAutoConnect QStringLiteral("AutoConnect") 16 | 17 | #define Q_AttributeWifi QStringLiteral("wifi") 18 | #define Q_AttributeEthernet QStringLiteral("ethernet") 19 | #define Q_AttributeBluetooth QStringLiteral("bluetooth") 20 | #define Q_AttributeIdle QStringLiteral("idle") 21 | #define Q_AttributeFailure QStringLiteral("failure") 22 | #define Q_AttributeAssociation QStringLiteral("association") 23 | #define Q_AttributeConfiguration QStringLiteral("configuration") 24 | #define Q_AttributeReady QStringLiteral("ready") 25 | #define Q_AttributeDisconnect QStringLiteral("disconnect") 26 | #define Q_AttributeOneline QStringLiteral("online") 27 | 28 | QT_BEGIN_NAMESPACE 29 | 30 | class QNetworkSettingsType; 31 | class QNetworkSettingsState; 32 | 33 | struct ConnmanMapStruct { 34 | QDBusObjectPath objectPath; 35 | QVariantMap propertyMap; 36 | }; 37 | 38 | QDBusArgument &operator<<(QDBusArgument &argument, const ConnmanMapStruct &obj); 39 | const QDBusArgument &operator>>(const QDBusArgument &argument, ConnmanMapStruct &obj); 40 | 41 | const QString &operator>>(const QString &argument, QNetworkSettingsType &obj); 42 | const QString &operator>>(const QString &argument, QNetworkSettingsState &obj); 43 | 44 | typedef QList ConnmanMapStructList; 45 | 46 | QT_END_NAMESPACE 47 | 48 | Q_DECLARE_METATYPE( ConnmanMapStruct ) 49 | Q_DECLARE_METATYPE( ConnmanMapStructList ) 50 | 51 | #endif // CONNMANCOMMON_H 52 | -------------------------------------------------------------------------------- /src/networksettings/connman/qnetworksettingsinterface_p.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #include "qnetworksettingsinterface_p.h" 4 | #include "connman_technology_interface.h" 5 | #include "connmancommon.h" 6 | 7 | QT_BEGIN_NAMESPACE 8 | 9 | QNetworkSettingsInterfacePrivate::QNetworkSettingsInterfacePrivate(QNetworkSettingsInterface* parent) 10 | : QObject(parent) 11 | , m_technology(nullptr) 12 | ,q_ptr(parent) 13 | { 14 | } 15 | 16 | void QNetworkSettingsInterfacePrivate::initialize(const QString& path, const QVariantMap& properties) 17 | { 18 | m_technology = new NetConnmanTechnologyInterface(QStringLiteral("net.connman"), path, 19 | QDBusConnection::systemBus(), this); 20 | connect(m_technology, SIGNAL(PropertyChanged(QString,QDBusVariant)), 21 | this, SLOT(updateProperty(QString,QDBusVariant))); 22 | 23 | updateProperty(Q_PropertyName, properties[Q_PropertyName]); 24 | updateProperty(Q_PropertyType, properties[Q_PropertyType]); 25 | updateProperty(Q_PropertyConnected, properties[Q_PropertyConnected]); 26 | updateProperty(Q_PropertyPowered, properties[Q_PropertyPowered]); 27 | } 28 | 29 | void QNetworkSettingsInterfacePrivate::updateProperty(const QString &name, const QDBusVariant &value) 30 | { 31 | updateProperty(name, value.variant()); 32 | } 33 | 34 | void QNetworkSettingsInterfacePrivate::updateProperty(const QString &name, const QVariant &value) 35 | { 36 | Q_Q(QNetworkSettingsInterface); 37 | if (name == Q_PropertyName) { 38 | m_name = qdbus_cast(value); 39 | } 40 | else if (name == Q_PropertyType) { 41 | qdbus_cast(value) >> m_type; 42 | emit q->typeChanged(); 43 | } 44 | else if (name == Q_PropertyConnected) { 45 | bool connected = qdbus_cast(value); 46 | if (connected) 47 | m_state.setState(QNetworkSettingsState::Online); 48 | else 49 | m_state.setState(QNetworkSettingsState::Disconnect); 50 | emit q->stateChanged(); 51 | } 52 | else if (name == Q_PropertyPowered) { 53 | m_powered = qdbus_cast(value); 54 | emit q->poweredChanged(); 55 | } 56 | } 57 | 58 | void QNetworkSettingsInterfacePrivate::setState(QNetworkSettingsState::State aState) 59 | { 60 | Q_Q(QNetworkSettingsInterface); 61 | m_state.setState(aState); 62 | emit q->stateChanged(); 63 | } 64 | 65 | void QNetworkSettingsInterfacePrivate::setPowered(const bool aPowered) 66 | { 67 | m_technology->SetProperty(Q_PropertyPowered, QDBusVariant(QVariant(aPowered))); 68 | } 69 | 70 | void QNetworkSettingsInterfacePrivate::scan() 71 | { 72 | if (m_powered) 73 | m_technology->Scan(); 74 | else 75 | qDebug() << "Tried to scan while not powered"; 76 | } 77 | 78 | QString QNetworkSettingsInterfacePrivate::path() const 79 | { 80 | return m_technology->path(); 81 | } 82 | 83 | QT_END_NAMESPACE 84 | -------------------------------------------------------------------------------- /src/networksettings/connman/qnetworksettingsinterface_p.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #ifndef QNETWORKSETTINGSINTERFACEPRIVATE_H 4 | #define QNETWORKSETTINGSINTERFACEPRIVATE_H 5 | 6 | // 7 | // W A R N I N G 8 | // ------------- 9 | // 10 | // This file is not part of the Qt API. It exists for the convenience 11 | // of other Qt classes. This header file may change from version to 12 | // version without notice, or even be removed. 13 | // 14 | // We mean it. 15 | // 16 | 17 | #include 18 | #include 19 | #include "qnetworksettings.h" 20 | #include "qnetworksettingsinterface.h" 21 | 22 | // Automatically generated class in global namespace 23 | class NetConnmanTechnologyInterface; 24 | 25 | QT_BEGIN_NAMESPACE 26 | 27 | class QNetworkSettingsInterfacePrivate : public QObject 28 | { 29 | Q_OBJECT 30 | Q_DECLARE_PUBLIC(QNetworkSettingsInterface) 31 | public: 32 | explicit QNetworkSettingsInterfacePrivate(QNetworkSettingsInterface* parent); 33 | void initialize(const QString& path, const QVariantMap& properties); 34 | void setPowered(const bool power); 35 | void setState(QNetworkSettingsState::State aState); 36 | void scan(); 37 | QString name() const {return m_name;} 38 | QNetworkSettingsType::Type type() const {return m_type.type();} 39 | QNetworkSettingsState::State state() const {return m_state.state();} 40 | bool powered() const {return m_powered;} 41 | QString path() const; 42 | 43 | public slots: 44 | void updateProperty(const QString &name, const QDBusVariant &value); 45 | protected: 46 | void updateProperty(const QString &name, const QVariant &value); 47 | 48 | protected: 49 | NetConnmanTechnologyInterface *m_technology; 50 | QString m_name; 51 | QNetworkSettingsType m_type; 52 | QNetworkSettingsState m_state; 53 | bool m_powered; 54 | QNetworkSettingsInterface *q_ptr; 55 | }; 56 | 57 | 58 | class ConnmanSettingsInterface : public QNetworkSettingsInterface 59 | { 60 | Q_OBJECT 61 | public: 62 | ConnmanSettingsInterface(const QString& path, const QVariantMap& properties, QObject *parent = nullptr) 63 | :QNetworkSettingsInterface(parent) 64 | { 65 | if (d_ptr) 66 | d_ptr->initialize(path, properties); 67 | } 68 | 69 | void setState(QNetworkSettingsState::State aState) { 70 | Q_D(QNetworkSettingsInterface); 71 | d->setState(aState); 72 | } 73 | 74 | virtual ~ConnmanSettingsInterface() {} 75 | 76 | QString path() const { 77 | if (d_ptr) 78 | return d_ptr->path(); 79 | return QString(); 80 | } 81 | }; 82 | 83 | QT_END_NAMESPACE 84 | 85 | #endif // QNETWORKSETTINGSINTERFACEPRIVATE_H 86 | -------------------------------------------------------------------------------- /src/networksettings/connman/qnetworksettingsmanager_p.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #ifndef QNETWORKSETTINGSMANAGERPRIVATE_H 4 | #define QNETWORKSETTINGSMANAGERPRIVATE_H 5 | 6 | // 7 | // W A R N I N G 8 | // ------------- 9 | // 10 | // This file is not part of the Qt API. It exists for the convenience 11 | // of other Qt classes. This header file may change from version to 12 | // version without notice, or even be removed. 13 | // 14 | // We mean it. 15 | // 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include "connmancommon.h" 22 | #include "qnetworksettingsmanager.h" 23 | #include "qnetworksettingsinterfacemodel.h" 24 | #include "connman_manager_interface.h" 25 | 26 | QT_BEGIN_NAMESPACE 27 | 28 | class QDBusObjectPath; 29 | class QDBusPendingCallWatcher; 30 | class QNetworkSettingsService; 31 | class QNetworkSettingsServiceModel; 32 | class QNetworkSettingsServiceFilter; 33 | 34 | class QNetworkSettingsManagerPrivate : public QObject 35 | { 36 | Q_OBJECT 37 | Q_DECLARE_PUBLIC(QNetworkSettingsManager) 38 | public: 39 | explicit QNetworkSettingsManagerPrivate(QNetworkSettingsManager *parent); 40 | QNetworkSettingsManager *q_ptr; 41 | void setUserAgent(QNetworkSettingsUserAgent *agent); 42 | QNetworkSettingsUserAgent *userAgent() const {return m_agent;} 43 | QNetworkSettingsInterfaceModel* interfaceModel() {return &m_interfaceModel;} 44 | QNetworkSettingsServiceModel* serviceModel() const {return m_serviceModel;} 45 | QNetworkSettingsServiceFilter* serviceFilter() const {return m_serviceFilter;} 46 | void connectBySsid(const QString &name); 47 | void clearConnectionState(); 48 | void tryNextConnection(); 49 | void setCurrentWifiConnection(QNetworkSettingsService *connection); 50 | QNetworkSettingsService* currentWifiConnection() const; 51 | void setCurrentWiredConnection(QNetworkSettingsService *connection); 52 | QNetworkSettingsService* currentWiredConnection() const; 53 | 54 | public slots: 55 | void getServicesFinished(QDBusPendingCallWatcher *watcher); 56 | void getTechnologiesFinished(QDBusPendingCallWatcher *watcher); 57 | void requestInput(const QString& service, const QString& type); 58 | void onServicesChanged(ConnmanMapStructList changed, const QList &removed); 59 | void serviceReady(); 60 | void onConnmanServiceRegistered(const QString &serviceName); 61 | void onTechnologyAdded(const QDBusObjectPath &technology, const QVariantMap &properties); 62 | void onTechnologyRemoved(const QDBusObjectPath &technology); 63 | 64 | private: 65 | bool initialize(); 66 | void handleNewService(const QString &servicePath); 67 | 68 | protected: 69 | QNetworkSettingsInterfaceModel m_interfaceModel; 70 | QNetworkSettingsServiceModel *m_serviceModel; 71 | QMap m_unknownServices; 72 | QMap m_unnamedServices; 73 | QMap m_unnamedServicesForSsidConnection; 74 | QNetworkSettingsServiceFilter *m_serviceFilter; 75 | private: 76 | NetConnmanManagerInterface *m_manager; 77 | QNetworkSettingsUserAgent *m_agent; 78 | QDBusServiceWatcher *m_serviceWatcher; 79 | QString m_currentSsid; 80 | QPointer m_currentWifiConnection; 81 | QPointer m_currentWiredConnection; 82 | bool m_initialized; 83 | }; 84 | 85 | QT_END_NAMESPACE 86 | 87 | #endif // QNETWORKSETTINGSMANAGERPRIVATE_H 88 | -------------------------------------------------------------------------------- /src/networksettings/connman/qnetworksettingsservice_p.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #ifndef QNETWORKSETTINGSSERVICEPRIVATE_H 4 | #define QNETWORKSETTINGSSERVICEPRIVATE_H 5 | 6 | // 7 | // W A R N I N G 8 | // ------------- 9 | // 10 | // This file is not part of the Qt API. It exists for the convenience 11 | // of other Qt classes. This header file may change from version to 12 | // version without notice, or even be removed. 13 | // 14 | // We mean it. 15 | // 16 | 17 | #include "qnetworksettingsservice.h" 18 | #include "qnetworksettings.h" 19 | 20 | // Automatically generated class in global namespace 21 | class NetConnmanServiceInterface; 22 | 23 | QT_BEGIN_NAMESPACE 24 | 25 | class QDBusVariant; 26 | class QDBusPendingCallWatcher; 27 | class QNetworkSettingsServicePrivate : public QObject 28 | { 29 | Q_OBJECT 30 | Q_DECLARE_PUBLIC(QNetworkSettingsService) 31 | public: 32 | QNetworkSettingsServicePrivate(const QString& aPath, QNetworkSettingsService *parent = nullptr); 33 | 34 | QNetworkSettingsService *q_ptr; 35 | private slots: 36 | void propertiesUpdated(QDBusPendingCallWatcher *call); 37 | void updateProperty(const QString &name, const QDBusVariant &value); 38 | 39 | private: 40 | void setupConfiguration(const QVariantMap &properties); 41 | void updateProperty(const QString& key, const QVariant& value); 42 | 43 | protected: 44 | void setAutoConnect(bool autoconnect); 45 | bool autoConnect() const; 46 | void setupIpv4Config(); 47 | void setupIpv6Config(); 48 | void setupNameserversConfig(); 49 | void setupDomainsConfig(); 50 | void setupQNetworkSettingsProxy(); 51 | void connectService(); 52 | void disconnectService(); 53 | void removeService(); 54 | void setPlaceholderState(bool placeholderState); 55 | bool placeholderState() const; 56 | 57 | QString m_id; 58 | QString m_name; 59 | QNetworkSettingsState m_state; 60 | QNetworkSettingsIPv4 m_ipv4config; 61 | QNetworkSettingsIPv6 m_ipv6config; 62 | QNetworkSettingsAddressModel m_domainsConfig; 63 | QNetworkSettingsAddressModel m_nameserverConfig; 64 | QNetworkSettingsProxy m_proxyConfig; 65 | QNetworkSettingsWireless m_wifiConfig; 66 | QNetworkSettingsType m_type; 67 | NetConnmanServiceInterface *m_service; 68 | bool m_placeholderState = false; 69 | bool m_autoConnect = false; 70 | }; 71 | 72 | QT_END_NAMESPACE 73 | 74 | #endif // QNETWORKSETTINGSSERVICEPRIVATE_H 75 | -------------------------------------------------------------------------------- /src/networksettings/connman/qnetworksettingsuseragent_p.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #include 4 | 5 | #include "qnetworksettingsuseragent.h" 6 | #include "qnetworksettingsuseragent_p.h" 7 | #include "connmancommon.h" 8 | 9 | QT_BEGIN_NAMESPACE 10 | 11 | const QString PropertyPassphrase(QStringLiteral("Passphrase")); 12 | 13 | QNetworkSettingsUserAgentPrivate::QNetworkSettingsUserAgentPrivate(QNetworkSettingsUserAgent *parent) 14 | :QDBusAbstractAdaptor(parent) 15 | ,q_ptr(parent) 16 | ,m_pendingReply(false) 17 | { 18 | 19 | setAutoRelaySignals(true); 20 | QMetaObject::invokeMethod(this, "registerAgent", Qt::QueuedConnection); 21 | } 22 | 23 | void QNetworkSettingsUserAgentPrivate::cancel() 24 | { 25 | // handle method call net.connman.Agent.Cancel 26 | if (!m_pendingReply) 27 | return; 28 | 29 | m_pendingReply = false; 30 | QDBusMessage errorMessage = m_pendingMessage.createErrorReply( 31 | QStringLiteral("net.connman.Agent.Error.Canceled"), 32 | QStringLiteral("")); 33 | QDBusConnection::systemBus().send(errorMessage); 34 | } 35 | 36 | void QNetworkSettingsUserAgentPrivate::release() 37 | { 38 | // handle method call net.connman.Agent.Release 39 | QMetaObject::invokeMethod(parent(), "Release"); 40 | } 41 | 42 | void QNetworkSettingsUserAgentPrivate::ReportError(const QDBusObjectPath &path, const QString ¶m) 43 | { 44 | Q_Q(QNetworkSettingsUserAgent); 45 | Q_UNUSED(path); 46 | Q_UNUSED(param); 47 | if (!m_ssid.isEmpty()) 48 | q->requestNextConnection(); 49 | else 50 | emit q->error(); 51 | } 52 | 53 | void QNetworkSettingsUserAgentPrivate::registerAgent() 54 | { 55 | Q_Q(QNetworkSettingsUserAgent); 56 | QDBusConnection::systemBus().registerObject(Q_PropertyAgentPath, q); 57 | } 58 | 59 | QVariantMap QNetworkSettingsUserAgentPrivate::RequestInput(const QDBusObjectPath &path, const QVariantMap ¶ms, const QDBusMessage &msg) 60 | { 61 | Q_Q(QNetworkSettingsUserAgent); 62 | Q_UNUSED(path); 63 | QVariant name = params[Q_PropertyName]; 64 | if (!name.isValid()) { 65 | m_ssid.clear(); 66 | } 67 | QVariantMap response; 68 | QVariant passPhrase = params[PropertyPassphrase]; 69 | if (name.isValid() && !m_ssid.isEmpty()) { 70 | response[Q_PropertyName] = m_ssid; 71 | } 72 | if (passPhrase.isValid()) { 73 | if (!m_passphrase.isEmpty()) { 74 | response[PropertyPassphrase] = m_passphrase; 75 | } else { 76 | msg.setDelayedReply(true); 77 | m_pendingMessage = msg; 78 | m_pendingReply = true; 79 | emit q->showUserCredentialsInput(); 80 | return QVariantMap(); 81 | } 82 | } 83 | return response; 84 | } 85 | 86 | void QNetworkSettingsUserAgentPrivate::setPassphrase(const QString& passphrase) 87 | { 88 | m_passphrase = passphrase; 89 | if (m_pendingReply) { 90 | QVariantMap response; 91 | if (!m_ssid.isEmpty()) { 92 | response[Q_PropertyName] = m_ssid; 93 | } 94 | response[PropertyPassphrase] = m_passphrase; 95 | QDBusMessage reply = m_pendingMessage.createReply(); 96 | reply << response; 97 | m_pendingReply = false; 98 | QDBusConnection::systemBus().send(reply); 99 | } 100 | } 101 | 102 | void QNetworkSettingsUserAgentPrivate::setSsidAndPassphrase(const QString &ssid, const QString &passphrase) 103 | { 104 | m_ssid = ssid; 105 | m_passphrase = passphrase; 106 | } 107 | 108 | void QNetworkSettingsUserAgentPrivate::clearConnectionState() 109 | { 110 | m_passphrase.clear(); 111 | m_ssid.clear(); 112 | } 113 | 114 | QT_END_NAMESPACE 115 | -------------------------------------------------------------------------------- /src/networksettings/connman/qnetworksettingsuseragent_p.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #ifndef QNETWORKSETTINGSUSERAGENTPRIVATE_H 4 | #define QNETWORKSETTINGSUSERAGENTPRIVATE_H 5 | 6 | // 7 | // W A R N I N G 8 | // ------------- 9 | // 10 | // This file is not part of the Qt API. It exists for the convenience 11 | // of other Qt classes. This header file may change from version to 12 | // version without notice, or even be removed. 13 | // 14 | // We mean it. 15 | // 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | QT_BEGIN_NAMESPACE 23 | 24 | class QNetworkSettingsUserAgent; 25 | class QNetworkSettingsUserAgentPrivate : public QDBusAbstractAdaptor 26 | { 27 | Q_OBJECT 28 | Q_CLASSINFO("D-Bus Interface", "net.connman.Agent") 29 | Q_DECLARE_PUBLIC(QNetworkSettingsUserAgent) 30 | public: 31 | QNetworkSettingsUserAgentPrivate(QNetworkSettingsUserAgent *parent = nullptr); 32 | void setPassphrase(const QString &passphrase); 33 | QString passphrase() const {return m_passphrase;} 34 | void cancel(); 35 | void release(); 36 | void setSsidAndPassphrase(const QString &ssid, const QString &passphrase); 37 | void clearConnectionState(); 38 | public Q_SLOTS: // Dbus methods 39 | void ReportError(const QDBusObjectPath &path, const QString ¶m); 40 | QVariantMap RequestInput(const QDBusObjectPath &path, const QVariantMap ¶ms, 41 | const QDBusMessage &message); 42 | void registerAgent(); 43 | private: 44 | QNetworkSettingsUserAgent *q_ptr; 45 | QDBusMessage m_pendingMessage; 46 | bool m_pendingReply; 47 | QString m_passphrase; 48 | QString m_ssid; 49 | }; 50 | 51 | QT_END_NAMESPACE 52 | 53 | #endif // QNETWORKSETTINGSUSERAGENTPRIVATE_H 54 | 55 | -------------------------------------------------------------------------------- /src/networksettings/qnetworksettings.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #ifndef QNETWORKSETTINGS_H 4 | #define QNETWORKSETTINGS_H 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | QT_BEGIN_NAMESPACE 13 | 14 | class Q_NETWORKSETTINGS_EXPORT QNetworkSettingsState : public QObject 15 | { 16 | Q_OBJECT 17 | Q_PROPERTY(State state READ state WRITE setState NOTIFY stateChanged) 18 | 19 | public: 20 | enum State { 21 | Idle = 0, 22 | Failure, 23 | Association, 24 | Configuration, 25 | Ready, 26 | Disconnect, 27 | Online, 28 | Undefined 29 | }; 30 | Q_ENUM(State) 31 | 32 | explicit QNetworkSettingsState(State state, QObject *parent = nullptr); 33 | explicit QNetworkSettingsState(QObject *parent = nullptr); 34 | 35 | State state() const; 36 | void setState(const State state); 37 | 38 | Q_SIGNALS: 39 | void stateChanged(); 40 | 41 | private: 42 | State m_state; 43 | }; 44 | 45 | class Q_NETWORKSETTINGS_EXPORT QNetworkSettingsType : public QObject 46 | { 47 | Q_OBJECT 48 | Q_PROPERTY(Type type READ type WRITE setType NOTIFY typeChanged) 49 | 50 | public: 51 | enum Type { 52 | Wired = 0, 53 | Wifi, 54 | Bluetooth, 55 | Unknown 56 | }; 57 | Q_ENUM(Type) 58 | 59 | explicit QNetworkSettingsType(Type type, QObject *parent = nullptr); 60 | explicit QNetworkSettingsType(QObject *parent = nullptr); 61 | 62 | Type type() const; 63 | void setType(const Type type); 64 | 65 | Q_SIGNALS: 66 | void typeChanged(); 67 | 68 | private: 69 | Type m_type; 70 | }; 71 | 72 | class Q_NETWORKSETTINGS_EXPORT QNetworkSettingsIPv4 : public QObject 73 | { 74 | Q_OBJECT 75 | Q_PROPERTY(QString address READ address WRITE setAddress NOTIFY addressChanged) 76 | Q_PROPERTY(QString gateway READ gateway WRITE setGateway NOTIFY gatewayChanged) 77 | Q_PROPERTY(Method method READ method WRITE setMethod NOTIFY methodChanged) 78 | Q_PROPERTY(QString mask READ mask WRITE setMask NOTIFY maskChanged) 79 | 80 | public: 81 | explicit QNetworkSettingsIPv4(QObject *parent = nullptr); 82 | 83 | enum Method { 84 | Dhcp = 0, 85 | Manual, 86 | Off 87 | }; 88 | Q_ENUM(Method) 89 | 90 | QString address() const; 91 | void setAddress(const QString& address); 92 | QString gateway() const; 93 | void setGateway(const QString& gateway); 94 | Method method() const; 95 | void setMethod(const Method method); 96 | QString mask() const; 97 | void setMask(const QString& mask); 98 | 99 | Q_SIGNALS: 100 | void addressChanged(); 101 | void gatewayChanged(); 102 | void methodChanged(); 103 | void maskChanged(); 104 | 105 | private: 106 | QString m_address; 107 | QString m_gateway; 108 | Method m_method; 109 | QString m_mask; 110 | }; 111 | 112 | class Q_NETWORKSETTINGS_EXPORT QNetworkSettingsIPv6 : public QObject 113 | { 114 | Q_OBJECT 115 | Q_PROPERTY(QString address READ address WRITE setAddress NOTIFY addressChanged) 116 | Q_PROPERTY(QString gateway READ gateway WRITE setGateway NOTIFY gatewayChanged) 117 | Q_PROPERTY(Method method READ method WRITE setMethod NOTIFY methodChanged) 118 | Q_PROPERTY(Privacy privacy READ privacy WRITE setPrivacy NOTIFY privacyChanged) 119 | Q_PROPERTY(int prefixLength READ prefixLength WRITE setPrefixLength NOTIFY prefixLengthChanged) 120 | 121 | public: 122 | explicit QNetworkSettingsIPv6(QObject *parent = nullptr); 123 | 124 | enum Method { 125 | Auto = 0, 126 | Manual, 127 | Off 128 | }; 129 | Q_ENUM(Method) 130 | 131 | enum Privacy { 132 | Disabled = 0, 133 | Enabled, 134 | Preferred 135 | }; 136 | Q_ENUM(Privacy) 137 | 138 | QString address() const; 139 | void setAddress(const QString& address); 140 | QString gateway() const; 141 | void setGateway(const QString& gateway); 142 | Method method() const; 143 | void setMethod(const Method method); 144 | Privacy privacy() const; 145 | void setPrivacy(const Privacy privacy); 146 | int prefixLength() const; 147 | void setPrefixLength(const int& prefixLength); 148 | 149 | Q_SIGNALS: 150 | void addressChanged(); 151 | void gatewayChanged(); 152 | void methodChanged(); 153 | void privacyChanged(); 154 | void prefixLengthChanged(); 155 | 156 | private: 157 | QString m_address; 158 | QString m_gateway; 159 | Method m_method; 160 | Privacy m_privacy; 161 | int m_prefixLength; 162 | }; 163 | 164 | class Q_NETWORKSETTINGS_EXPORT QNetworkSettingsProxy : public QObject 165 | { 166 | Q_OBJECT 167 | Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged) 168 | Q_PROPERTY(QAbstractItemModel* servers READ servers NOTIFY serversChanged) 169 | Q_PROPERTY(QAbstractItemModel* excludes READ excludes NOTIFY excludesChanged) 170 | Q_PROPERTY(Method method READ method WRITE setMethod NOTIFY methodChanged) 171 | public: 172 | explicit QNetworkSettingsProxy(QObject *parent = nullptr); 173 | 174 | enum Method { 175 | Direct = 0, 176 | Auto, 177 | Manual 178 | }; 179 | Q_ENUM(Method) 180 | 181 | QUrl url() const; 182 | void setUrl(const QUrl& url); 183 | QAbstractItemModel* servers(); 184 | void setServers(const QStringList& servers); 185 | QStringList servers() const; 186 | QAbstractItemModel* excludes(); 187 | QStringList excludes() const; 188 | void setExcludes(const QStringList& excludes); 189 | Method method() const; 190 | void setMethod(const Method& method); 191 | 192 | Q_SIGNALS: 193 | void urlChanged(); 194 | void serversChanged(); 195 | void excludesChanged(); 196 | void methodChanged(); 197 | private: 198 | QUrl m_url; 199 | QNetworkSettingsAddressModel m_servers; 200 | QNetworkSettingsAddressModel m_excludes; 201 | Method m_method; 202 | }; 203 | 204 | class Q_NETWORKSETTINGS_EXPORT QNetworkSettingsWireless : public QObject 205 | { 206 | Q_OBJECT 207 | Q_PROPERTY(int signalStrength READ signalStrength WRITE setSignalStrength NOTIFY signalStrengthChanged) 208 | Q_PROPERTY(bool hidden READ hidden NOTIFY hiddenChanged) 209 | Q_PROPERTY(bool isOutOfRange READ outOfRange WRITE setOutOfRange NOTIFY outOfRangeChanged) 210 | public: 211 | explicit QNetworkSettingsWireless(QObject* parent = nullptr); 212 | 213 | enum class Security { 214 | None = 0x0000, 215 | WEP = 0x0002, 216 | WPA = 0x0004, 217 | WPA2 = 0x0008 218 | }; 219 | Q_DECLARE_FLAGS(Securities, Security) 220 | 221 | Q_INVOKABLE bool supportsSecurity(Security security); 222 | bool hidden() const; 223 | void setHidden(const bool hidden); 224 | int signalStrength() const; 225 | void setSignalStrength(const int signalStrength); 226 | void setSecurity(const Securities securities); 227 | void setOutOfRange(const bool aOutOfRange); 228 | bool outOfRange() const; 229 | 230 | Q_SIGNALS: 231 | void hiddenChanged(); 232 | void signalStrengthChanged(); 233 | void passwordChanged(); 234 | void outOfRangeChanged(); 235 | private: 236 | Securities m_supportedSecurites; 237 | bool m_hidden; 238 | int m_signalStrength; 239 | bool m_isOutOfRange; 240 | }; 241 | Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkSettingsWireless::Securities) 242 | 243 | QT_END_NAMESPACE 244 | 245 | #endif //QNETWORKSETTINGS_H 246 | -------------------------------------------------------------------------------- /src/networksettings/qnetworksettings.qdoc: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | /*! 4 | \qmltype NetworkSettingsIPv4 5 | \inqmlmodule QtDeviceUtilities.NetworkSettings 6 | \brief Encapsulates IPv4 network configuration. 7 | 8 | The NetworkSettingsIPv4 type cannot be instantiated directly. 9 | 10 | \sa {NetworkService::ipv4}{NetworkService.ipv4} 11 | */ 12 | 13 | /*! 14 | \qmlproperty string NetworkSettingsIPv4::address 15 | \brief Holds the IPv4 address. 16 | */ 17 | 18 | /*! 19 | \qmlproperty string NetworkSettingsIPv4::gateway 20 | \brief Holds the IPv4 gateway address 21 | */ 22 | 23 | /*! 24 | \qmlproperty enumeration NetworkSettingsIPv4::method 25 | \brief Holds the method of IPv4 configuration. 26 | 27 | Possible values: 28 | 29 | \value NetworkSettingsIPv4.Dhcp 30 | Use DHCP protocol for IPv4 configuration 31 | 32 | \value NetworkSettingsIPv4.Manual 33 | Use manual settings 34 | 35 | \value NetworkSettingsIPv4.Off 36 | No configuration done 37 | */ 38 | 39 | /*! 40 | \qmlproperty string NetworkSettingsIPv4::mask 41 | \brief Holds the IPv4 network mask. 42 | */ 43 | 44 | /*! 45 | \qmltype NetworkSettingsIPv6 46 | \inqmlmodule QtDeviceUtilities.NetworkSettings 47 | \brief Encapsulates IPv6 network configuration. 48 | 49 | The NetworkSettingsIPv6 type cannot be instantiated directly. 50 | 51 | \sa {NetworkService::ipv6}{NetworkService.ipv6} 52 | */ 53 | 54 | /*! 55 | \qmlproperty string NetworkSettingsIPv6::address 56 | \brief Holds the IPv6 address. 57 | */ 58 | 59 | /*! 60 | \qmlproperty string NetworkSettingsIPv6::gateway 61 | \brief Holds the IPv6 gateway address. 62 | */ 63 | 64 | /*! 65 | \qmlproperty enumeration NetworkSettingsIPv6::method 66 | \brief Holds the method of IPv6 configuration. 67 | 68 | Possible values: 69 | 70 | \value NetworkSettingsIPv6.Auto 71 | Use automatic configuration 72 | 73 | \value NetworkSettingsIPv6.Manual 74 | Use manual configuration 75 | 76 | \value NetworkSettingsIPv6.Off 77 | No configuration done 78 | */ 79 | 80 | /*! 81 | \qmlproperty enumeration NetworkSettingsIPv6::privacy 82 | \brief Holds the method of applying privacy extensions for IPv6. 83 | 84 | Possible values: 85 | 86 | \value NetworkSettingsIPv6.Disabled 87 | Disable privacy extensions in IPv6 88 | 89 | \value NetworkSettingsIPv6.Enabled 90 | Enable \l {https://tools.ietf.org/html/rfc4941} 91 | {Privacy Extensions for Stateless Address Autoconfiguration in IPv6} 92 | 93 | \value NetworkSettingsIPv6.Preferred 94 | Enable privacy extensions and prefer the use of temporary addresses, even 95 | when a public address is available 96 | */ 97 | 98 | /*! 99 | \qmlproperty int NetworkSettingsIPv6::prefixLength 100 | \brief Holds the IPv6 network prefix length in bits. 101 | */ 102 | 103 | /*! 104 | \qmltype NetworkSettingsProxy 105 | \inqmlmodule QtDeviceUtilities.NetworkSettings 106 | \brief Encapsulates network proxy configuration. 107 | 108 | The NetworkSettingsProxy type cannot be instantiated directly. 109 | 110 | \sa {NetworkService::proxy}{NetworkService.proxy} 111 | */ 112 | 113 | /*! 114 | \qmlproperty url NetworkSettingsProxy::url 115 | \brief Holds the proxy URL. 116 | 117 | For manual proxy configuration, the \e url holds the 118 | proxy server address. For automatic configuration, it holds 119 | the proxy auto-config URL. 120 | 121 | \sa method 122 | */ 123 | 124 | /*! 125 | \qmlproperty enumeration NetworkSettingsProxy::method 126 | \brief Holds the network proxy configuration method. 127 | 128 | Possible values: 129 | 130 | \value NetworkSettingsProxy.Direct 131 | Direct network connection, no proxy in use 132 | 133 | \value NetworkSettingsProxy.Auto 134 | Automatic proxy configuration 135 | 136 | \value NetworkSettingsProxy.Manual 137 | Manual proxy configuration 138 | 139 | \sa url 140 | */ 141 | 142 | /*! 143 | \qmlproperty object NetworkSettingsProxy::excludes 144 | \readonly 145 | \brief The model containing the proxy exclusion list. 146 | 147 | The addresses in the proxy exclusion list are accessed directly, 148 | instead of forwarding the requests to a proxy. 149 | 150 | The \e excludes property can be used as a model for a view 151 | that lists the proxy exclusion addresses. 152 | 153 | \sa excludes.count, excludes.append(), excludes.remove(), excludes.resetChanges() 154 | */ 155 | 156 | /*! 157 | \qmlproperty int NetworkSettingsProxy::excludes.count 158 | \readonly 159 | \brief Holds the number of addresses in the \l excludes model. 160 | */ 161 | 162 | /*! 163 | \qmlmethod void NetworkSettingsProxy::excludes.append(string address) 164 | \brief Adds \a address into the \l excludes model. 165 | */ 166 | 167 | /*! 168 | \qmlmethod void NetworkSettingsProxy::excludes.remove(int index) 169 | \brief Removes the entry at index \a index from the \l excludes model. 170 | */ 171 | 172 | /*! 173 | \qmlmethod void NetworkSettingsProxy::excludes.resetChanges() 174 | \brief Clears unsaved changes from the \l excludes model. 175 | */ 176 | 177 | /*! 178 | \qmlproperty object NetworkSettingsProxy::servers 179 | \readonly 180 | \brief The model containing the proxy servers. 181 | 182 | The \e servers property can be used as a model for a view 183 | that lists the proxy servers. 184 | 185 | \sa servers.count, servers.append(), servers.remove(), servers.resetChanges() 186 | */ 187 | 188 | /*! 189 | \qmlproperty int NetworkSettingsProxy::servers.count 190 | \readonly 191 | \brief Holds the number of addresses in the \l servers model. 192 | */ 193 | 194 | /*! 195 | \qmlmethod void NetworkSettingsProxy::servers.append(string address) 196 | \brief Adds \a address into the \l servers model. 197 | */ 198 | 199 | /*! 200 | \qmlmethod void NetworkSettingsProxy::servers.remove(int index) 201 | \brief Removes the entry at index \a index from the \l servers model. 202 | */ 203 | 204 | /*! 205 | \qmlmethod void NetworkSettingsProxy::servers.resetChanges() 206 | \brief Clears unsaved changes from the \l servers model. 207 | */ 208 | 209 | /*! 210 | \qmltype NetworkSettingsWireless 211 | \inqmlmodule QtDeviceUtilities.NetworkSettings 212 | \brief Encapsulates configuration for a Wifi network service. 213 | 214 | The NetworkSettingsWireless type cannot be instantiated directly. 215 | 216 | \sa {NetworkService::wirelessConfig}{NetworkService.wirelessConfig} 217 | */ 218 | 219 | /*! 220 | \qmlproperty int NetworkSettingsWireless::signalStrength 221 | \brief Holds the Wifi signal strength, in the range of 0 to 100. 222 | */ 223 | 224 | /*! 225 | \qmlproperty bool NetworkSettingsWireless::hidden 226 | \readonly 227 | \brief Holds whether the wireless SSID is hidden. 228 | */ 229 | 230 | /*! 231 | \qmlproperty bool NetworkSettingsWireless::isOutOfRange 232 | \brief Holds whether the Wifi access point is out of range. 233 | */ 234 | 235 | /*! 236 | \qmlmethod bool NetworkSettingsWireless::supportsSecurity(int flags) 237 | \brief Returns whether the Wifi supports the wireless security 238 | protocol(s) specified in \a flags. 239 | 240 | Possible values: 241 | 242 | \value 2 Wired Equivalent Privacy (WEP) 243 | \value 4 Wi-Fi Protected Access (WPA) 244 | \value 8 Wi-Fi Protected Access, version 2 (WPA2) 245 | */ 246 | -------------------------------------------------------------------------------- /src/networksettings/qnetworksettingsaddressmodel.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #include "qnetworksettingsaddressmodel.h" 4 | 5 | QT_BEGIN_NAMESPACE 6 | 7 | /*! 8 | \class QNetworkSettingsAddressModel 9 | \inmodule QtNetworkSettings 10 | 11 | \brief The QNetworkSettingsAddressModel class represents a network 12 | interface address. 13 | 14 | An address model contains a lists of available network interface addresses. 15 | 16 | \sa QNetworkSettingsManager 17 | */ 18 | 19 | /*! 20 | \property QNetworkSettingsAddressModel::count 21 | \brief Holds the number of rows in the model. 22 | */ 23 | 24 | /*! 25 | \fn QNetworkSettingsAddressModel::countChanged() 26 | This signal is emitted when the number of rows in the model changes. 27 | */ 28 | 29 | /*! 30 | Creates an address model with the parent \a parent. 31 | */ 32 | QNetworkSettingsAddressModel::QNetworkSettingsAddressModel(QObject *parent) 33 | :QStringListModel(parent) 34 | { 35 | } 36 | 37 | /*! 38 | Creates an address model with the addresses specified by 39 | \a strings and parent \a parent. 40 | */ 41 | QNetworkSettingsAddressModel::QNetworkSettingsAddressModel(const QStringList &strings, QObject *parent) 42 | :QStringListModel(parent) 43 | { 44 | setStringList(strings); 45 | } 46 | 47 | /*! 48 | Adds the addresses specified by \a addresses to the address model. 49 | */ 50 | void QNetworkSettingsAddressModel::setStringList(const QStringList &addresses) 51 | { 52 | m_addresses = addresses; 53 | QStringListModel::setStringList(m_addresses); 54 | emit countChanged(); 55 | } 56 | 57 | /*! 58 | Adds the address specified by \a address to the address model. 59 | */ 60 | void QNetworkSettingsAddressModel::append(const QString& address) 61 | { 62 | int row = rowCount(); 63 | 64 | bool succeed = insertRows(row, 1); 65 | if (succeed) 66 | succeed = setData(index(row), QVariant::fromValue(address)); 67 | 68 | Q_ASSERT(succeed == true); 69 | 70 | emit countChanged(); 71 | } 72 | 73 | /*! 74 | Removes the address at the position specified by \a index from the address 75 | model. 76 | */ 77 | void QNetworkSettingsAddressModel::remove(int index) 78 | { 79 | removeRows(index, 1); 80 | emit countChanged(); 81 | } 82 | 83 | /*! 84 | Returns the number of rows in the address model. 85 | */ 86 | int QNetworkSettingsAddressModel::count() const 87 | { 88 | return rowCount(); 89 | } 90 | 91 | /*! 92 | Resets the changes made to the addresses in the address model. 93 | */ 94 | void QNetworkSettingsAddressModel::resetChanges() 95 | { 96 | QStringListModel::setStringList(m_addresses); 97 | } 98 | 99 | QT_END_NAMESPACE 100 | -------------------------------------------------------------------------------- /src/networksettings/qnetworksettingsaddressmodel.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #ifndef QNETWORKSETTINGSADDRESSMODEL_H 4 | #define QNETWORKSETTINGSADDRESSMODEL_H 5 | 6 | #include 7 | #include 8 | 9 | QT_BEGIN_NAMESPACE 10 | 11 | class Q_NETWORKSETTINGS_EXPORT QNetworkSettingsAddressModel : public QStringListModel 12 | { 13 | Q_OBJECT 14 | Q_PROPERTY(int count READ count NOTIFY countChanged) 15 | public: 16 | explicit QNetworkSettingsAddressModel(QObject *parent = nullptr); 17 | explicit QNetworkSettingsAddressModel(const QStringList &strings, QObject *parent = nullptr); 18 | Q_INVOKABLE void append(const QString& address); 19 | Q_INVOKABLE void remove(int index); 20 | Q_INVOKABLE void resetChanges(); 21 | void setStringList(const QStringList &addresses); 22 | int count() const; 23 | 24 | Q_SIGNALS: 25 | void countChanged(); 26 | private: 27 | QStringList m_addresses; 28 | }; 29 | 30 | QT_END_NAMESPACE 31 | 32 | #endif // QNETWORKSETTINGSADDRESSMODEL_H 33 | -------------------------------------------------------------------------------- /src/networksettings/qnetworksettingsglobal.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #ifndef QNETWORKSETTINGSGLOBAL_H 4 | #define QNETWORKSETTINGSGLOBAL_H 5 | 6 | #include 7 | 8 | #endif // QNETWORKSETTINGSGLOBAL_H 9 | -------------------------------------------------------------------------------- /src/networksettings/qnetworksettingsinterface.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #include "qnetworksettingsinterface.h" 4 | #include "qnetworksettingsinterface_p.h" 5 | 6 | QT_BEGIN_NAMESPACE 7 | 8 | /*! 9 | \class QNetworkSettingsInterface 10 | \inmodule QtNetworkSettings 11 | \brief Represents a network interface. 12 | 13 | The QNetworkSettingsInterface class represents a network interface attached 14 | to the host. 15 | 16 | Instances of this class cannot be created directly. Instead, they can be 17 | retrieved via QNetworkSettingsManager::interfaces(). 18 | */ 19 | 20 | /*! 21 | \property QNetworkSettingsInterface::state 22 | \readonly 23 | \brief Holds the state of the network interface. 24 | 25 | \sa QNetworkSettingsState::State 26 | */ 27 | 28 | /*! 29 | \property QNetworkSettingsInterface::name 30 | \readonly 31 | \brief Holds the name of the network interface. 32 | */ 33 | 34 | /*! 35 | \property QNetworkSettingsInterface::powered 36 | \brief Holds whether the network interface is powered on of off. 37 | */ 38 | 39 | /*! 40 | \property QNetworkSettingsInterface::type 41 | \readonly 42 | \brief Holds the type of the network interface. 43 | 44 | \sa QNetworkSettingsType::Type 45 | */ 46 | 47 | /*! 48 | \qmltype NetworkInterface 49 | \inqmlmodule QtDeviceUtilities.NetworkSettings 50 | \brief Represents a network interface. 51 | 52 | The NetworkInterface QML type represents a network interface attached 53 | to the host. 54 | 55 | Instances of NetworkInterface cannot be created directly; instead, they can 56 | be retrieved via NetworkSettingsManager. 57 | 58 | \sa {NetworkSettingsManager::interfaces}{NetworkSettingsManager.interfaces} 59 | */ 60 | 61 | 62 | /*! 63 | Creates a new network interface with the parent \a parent. 64 | */ 65 | QNetworkSettingsInterface::QNetworkSettingsInterface(QObject *parent) : 66 | QObject(parent) 67 | ,d_ptr(new QNetworkSettingsInterfacePrivate(this)) 68 | { 69 | 70 | } 71 | 72 | /*! 73 | \qmlproperty string NetworkInterface::name 74 | \readonly 75 | \brief Holds the name of the network interface. 76 | */ 77 | 78 | /*! 79 | Returns the name of the network interface. 80 | */ 81 | QString QNetworkSettingsInterface::name() const 82 | { 83 | Q_D(const QNetworkSettingsInterface); 84 | return d->name(); 85 | } 86 | 87 | /*! 88 | \qmlproperty enumeration NetworkInterface::state 89 | \readonly 90 | \brief Holds the state of the network interface. 91 | 92 | Possible values: 93 | 94 | \value NetworkSettingsState.Idle 95 | Idle 96 | 97 | \value NetworkSettingsState.Failure 98 | Failed to connect 99 | 100 | \value NetworkSettingsState.Association 101 | Authentication in progress 102 | 103 | \value NetworkSettingsState.Configuration 104 | Configuration in progress 105 | 106 | \value NetworkSettingsState.Ready 107 | Connected to a network 108 | 109 | \value NetworkSettingsState.Disconnect 110 | Disconnected from a network 111 | 112 | \value NetworkSettingsState.Online 113 | Online (acquired an IP address) 114 | 115 | \value NetworkSettingsState.Undefined 116 | Undefined state. 117 | */ 118 | 119 | /*! 120 | Returns the state of the network interface. 121 | */ 122 | QNetworkSettingsState::State QNetworkSettingsInterface::state() 123 | { 124 | Q_D(QNetworkSettingsInterface); 125 | return d->state(); 126 | } 127 | 128 | /*! 129 | \qmlproperty enumeration NetworkInterface::type 130 | \readonly 131 | \brief Holds the type of the network interface. 132 | 133 | Possible values: 134 | 135 | \value NetworkSettingsType.Wired Wired network 136 | \value NetworkSettingsType.Wifi Wifi network 137 | \value NetworkSettingsType.Bluetooth Bluetooth network 138 | \value NetworkSettingsType.Unknown Unknown network type 139 | */ 140 | 141 | /*! 142 | Returns the type of the network interface. 143 | */ 144 | QNetworkSettingsType::Type QNetworkSettingsInterface::type() 145 | { 146 | Q_D(QNetworkSettingsInterface); 147 | return d->type(); 148 | } 149 | 150 | /*! 151 | \qmlproperty bool NetworkInterface::powered 152 | \brief Holds whether the network interface is powered on or off. 153 | */ 154 | 155 | /*! 156 | Returns whether the network interface is powered on or off. 157 | */ 158 | bool QNetworkSettingsInterface::powered() const 159 | { 160 | Q_D(const QNetworkSettingsInterface); 161 | return d->powered(); 162 | } 163 | 164 | /*! 165 | Sets the powered state in the network interface to \a powered. 166 | */ 167 | void QNetworkSettingsInterface::setPowered(const bool powered) 168 | { 169 | Q_D(QNetworkSettingsInterface); 170 | d->setPowered(powered); 171 | } 172 | 173 | /*! 174 | \qmlmethod void NetworkInterface::scanServices() 175 | \brief Initiates a scan for network interface services. 176 | */ 177 | 178 | /*! 179 | Initiates a scan for network interface services. 180 | */ 181 | void QNetworkSettingsInterface::scanServices() 182 | { 183 | Q_D(QNetworkSettingsInterface); 184 | d->scan(); 185 | } 186 | 187 | QT_END_NAMESPACE 188 | -------------------------------------------------------------------------------- /src/networksettings/qnetworksettingsinterface.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #ifndef QNETWORKSETTINGSINTERFACE_H 4 | #define QNETWORKSETTINGSINTERFACE_H 5 | 6 | #include 7 | #include 8 | 9 | QT_BEGIN_NAMESPACE 10 | 11 | class QNetworkSettingsInterfacePrivate; 12 | class Q_NETWORKSETTINGS_EXPORT QNetworkSettingsInterface : public QObject 13 | { 14 | Q_OBJECT 15 | Q_PROPERTY(QString name READ name NOTIFY nameChanged) 16 | Q_PROPERTY(QNetworkSettingsState::State state READ state NOTIFY stateChanged) 17 | Q_PROPERTY(QNetworkSettingsType::Type type READ type NOTIFY typeChanged) 18 | Q_PROPERTY(bool powered READ powered WRITE setPowered NOTIFY poweredChanged) 19 | 20 | public: 21 | explicit QNetworkSettingsInterface(QObject* parent = nullptr); 22 | QString name() const; 23 | QNetworkSettingsState::State state(); 24 | QNetworkSettingsType::Type type(); 25 | bool powered() const; 26 | void setPowered(const bool powered); 27 | Q_INVOKABLE void scanServices(); 28 | 29 | Q_SIGNALS: 30 | void nameChanged(); 31 | void stateChanged(); 32 | void typeChanged(); 33 | void poweredChanged(); 34 | 35 | protected: 36 | friend class NetworksInterfaceModel; 37 | QNetworkSettingsInterfacePrivate *d_ptr; 38 | 39 | Q_DISABLE_COPY(QNetworkSettingsInterface) 40 | Q_DECLARE_PRIVATE(QNetworkSettingsInterface) 41 | }; 42 | 43 | QT_END_NAMESPACE 44 | 45 | #endif // QNETWORKSETTINGSINTERFACE_H 46 | -------------------------------------------------------------------------------- /src/networksettings/qnetworksettingsinterfacemodel.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #include "qnetworksettingsinterfacemodel.h" 4 | #include "qnetworksettingsinterface.h" 5 | 6 | QT_BEGIN_NAMESPACE 7 | 8 | /*! 9 | \class QNetworkSettingsInterfaceModel 10 | \inmodule QtNetworkSettings 11 | \brief The QNetworkSettingsInterfaceModel class represents a network 12 | interface model. 13 | 14 | The network interface model contains a list of network interfaces 15 | attached to the host. 16 | */ 17 | 18 | /*! 19 | \enum QNetworkSettingsInterfaceModel::Roles 20 | \brief This enum type holds information about a network interface. 21 | 22 | \value Type 23 | Network interface \l{QNetworkSettingsType::Type}{type}. 24 | \value Status 25 | Network interface \l{QNetworkSettingsState::State}{state}. 26 | \value Name 27 | Network interface name. 28 | \value Powered 29 | Whether the network interface is powered on or off. 30 | */ 31 | 32 | /*! 33 | Creates a new network interface model with the parent \a parent. 34 | */ 35 | QNetworkSettingsInterfaceModel::QNetworkSettingsInterfaceModel(QObject *parent) 36 | : QAbstractListModel(parent) 37 | { 38 | m_roleNames.insert(Qt::UserRole, "entry"); 39 | m_roleNames.insert(Type, "type"); 40 | m_roleNames.insert(Status, "status"); 41 | m_roleNames.insert(Name, "name"); 42 | m_roleNames.insert(Powered, "powered"); 43 | } 44 | 45 | /*! 46 | Returns an array of the names of the roles in the model. 47 | */ 48 | QHash QNetworkSettingsInterfaceModel::roleNames() const 49 | { 50 | return m_roleNames; 51 | } 52 | 53 | /*! 54 | Returns the number of rows in the model with the parent \a parent. 55 | */ 56 | int QNetworkSettingsInterfaceModel::rowCount(const QModelIndex & parent) const 57 | { 58 | Q_UNUSED(parent); 59 | return m_items.count(); 60 | } 61 | 62 | /*! 63 | Returns the data at the index \a index in the model for the type of data 64 | specified by \a role. 65 | */ 66 | QVariant QNetworkSettingsInterfaceModel::data(const QModelIndex & index, int role) const 67 | { 68 | if (!index.isValid()) return QVariant(); 69 | 70 | QNetworkSettingsInterface *item = m_items[index.row()]; 71 | if (role == Qt::UserRole) { 72 | return QVariant::fromValue(static_cast(item)); 73 | } 74 | 75 | switch (role) { 76 | case Type: 77 | return item->type(); 78 | break; 79 | case Name: 80 | return item->name(); 81 | break; 82 | case Status: 83 | return item->state(); 84 | break; 85 | case Powered: 86 | return item->powered(); 87 | break; 88 | default: 89 | return QStringLiteral(""); 90 | } 91 | 92 | } 93 | 94 | /*! 95 | Appends \a item to the model. 96 | */ 97 | void QNetworkSettingsInterfaceModel::append(QNetworkSettingsInterface* item) 98 | { 99 | insert(rowCount(), item); 100 | } 101 | 102 | /*! 103 | Inserts \a item into \a row in the model. 104 | */ 105 | void QNetworkSettingsInterfaceModel::insert(int row, QNetworkSettingsInterface* item) 106 | { 107 | item->setParent(this); 108 | connectStateChanges(item); 109 | 110 | beginInsertRows(QModelIndex(), row, row); 111 | m_items.insert(row, item); 112 | endInsertRows(); 113 | } 114 | 115 | void QNetworkSettingsInterfaceModel::connectStateChanges(QNetworkSettingsInterface* item) 116 | { 117 | connect(item, &QNetworkSettingsInterface::stateChanged, this, &QNetworkSettingsInterfaceModel::connectionStatusChanged); 118 | connect(item, &QNetworkSettingsInterface::poweredChanged, this, &QNetworkSettingsInterfaceModel::poweredChanged); 119 | } 120 | 121 | /*! 122 | Removes the row \a row from the model. 123 | */ 124 | void QNetworkSettingsInterfaceModel::remove(int row) 125 | { 126 | beginRemoveRows(QModelIndex(), row, row); 127 | m_items.takeAt(row)->deleteLater(); 128 | endRemoveRows(); 129 | } 130 | 131 | /*! 132 | Returns whether the interface with the \a name was removed successfully. 133 | */ 134 | bool QNetworkSettingsInterfaceModel::removeInterface(const QString &name) 135 | { 136 | bool ret = false; 137 | for (int i=0; i < m_items.count(); i++) { 138 | if (m_items.at(i)->name() == name) { 139 | remove(i); 140 | ret = true; 141 | break; 142 | } 143 | } 144 | return ret; 145 | } 146 | 147 | /*! 148 | Notifies that the \a row has been updated. 149 | */ 150 | void QNetworkSettingsInterfaceModel::updated(int row) 151 | { 152 | dataChanged(createIndex(row, 0), createIndex(row, 0)); 153 | } 154 | 155 | /*! 156 | Returns the network interface model. 157 | */ 158 | QList QNetworkSettingsInterfaceModel::getModel() 159 | { 160 | return m_items; 161 | } 162 | 163 | void QNetworkSettingsInterfaceModel::connectionStatusChanged() 164 | { 165 | QNetworkSettingsInterface *s = qobject_cast(sender()); 166 | 167 | int row = 0; 168 | for (QNetworkSettingsInterface* item : m_items) { 169 | if (item == s) { 170 | updated(row); 171 | break; 172 | } 173 | row++; 174 | } 175 | 176 | } 177 | 178 | void QNetworkSettingsInterfaceModel::poweredChanged() 179 | { 180 | QNetworkSettingsInterface *s = qobject_cast(sender()); 181 | int row = 0; 182 | for (QNetworkSettingsInterface* item : m_items) { 183 | if (item == s) { 184 | updated(row); 185 | break; 186 | } 187 | row++; 188 | } 189 | } 190 | 191 | 192 | QT_END_NAMESPACE 193 | -------------------------------------------------------------------------------- /src/networksettings/qnetworksettingsinterfacemodel.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #ifndef QNETWORKSETTINGSINTERFACEMODEL_H 4 | #define QNETWORKSETTINGSINTERFACEMODEL_H 5 | 6 | #include 7 | #include 8 | 9 | QT_BEGIN_NAMESPACE 10 | 11 | class QNetworkSettingsInterface; 12 | class Q_NETWORKSETTINGS_EXPORT QNetworkSettingsInterfaceModel : public QAbstractListModel 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit QNetworkSettingsInterfaceModel(QObject *parent = nullptr); 18 | // from QAbstractItemModel 19 | int rowCount(const QModelIndex & parent = QModelIndex()) const override; 20 | QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override; 21 | QHash roleNames() const override; 22 | 23 | void append(QNetworkSettingsInterface* networkInterface); 24 | void insert(int row, QNetworkSettingsInterface* networkInterface); 25 | void remove(int row); 26 | QList getModel(); 27 | 28 | enum Roles { 29 | Type = Qt::UserRole + 1, 30 | Status, 31 | Name, 32 | Powered 33 | }; 34 | 35 | void updated(int row); 36 | bool removeInterface(const QString &name); 37 | private Q_SLOTS: 38 | void connectionStatusChanged(); 39 | void poweredChanged(); 40 | 41 | private: 42 | void connectStateChanges(QNetworkSettingsInterface* item); 43 | 44 | private: 45 | QList m_items; 46 | QHash m_roleNames; 47 | }; 48 | 49 | QT_END_NAMESPACE 50 | 51 | #endif // QNETWORKSETTINGSINTERFACEMODEL_H 52 | -------------------------------------------------------------------------------- /src/networksettings/qnetworksettingsmanager.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #include "qnetworksettings.h" 4 | #include "qnetworksettingsmanager.h" 5 | #include "qnetworksettingsservice.h" 6 | #include "qnetworksettingsservicemodel.h" 7 | #include "qnetworksettingsinterface.h" 8 | #include "qnetworksettingsinterfacemodel.h" 9 | #include "qnetworksettingsmanager_p.h" 10 | #include "qnetworksettingsuseragent.h" 11 | 12 | QT_BEGIN_NAMESPACE 13 | 14 | /*! 15 | \class QNetworkSettingsManager 16 | \inmodule QtNetworkSettings 17 | 18 | \brief The QNetworkSettingsManager class provides an asynchronous API to 19 | network settings. 20 | 21 | The network manager is designed to be used as a model that contains lists 22 | of available network interfaces and services. 23 | 24 | A delegate in a view that uses the interface model can access the 25 | network interface item with the data model role. 26 | 27 | The services list in the model can be controlled with the 28 | \l QNetworkSettingsType::type property, and network service items can be 29 | retrieved with the \l QNetworkSettingsServiceFilter::itemFromRow() method. 30 | 31 | The following code demonstrates how you initialize the network manager: 32 | 33 | \code 34 | manager = new QNetworkSettingsManager(this); 35 | QObject::connect(manager, &QNetworkSettingsManager::interfacesChanged, 36 | this, &MainWindow::interfacesChanged); 37 | 38 | QObject::connect(manager, &QNetworkSettingsManager::servicesChanged, 39 | this, &MainWindow::servicesChanged); 40 | \endcode 41 | 42 | After initializing the network manager, you can iterate WiFi SSIDs as follows: 43 | 44 | \code 45 | void WifiHandler::servicesChanged() 46 | { 47 | QList services = qobject_cast(manager->services()->sourceModel())->getModel(); 48 | 49 | for (const auto &service : services) { 50 | qDebug() << service->name(); 51 | } 52 | } 53 | 54 | 55 | void WifiHandler::interfacesChanged() 56 | { 57 | QList interfaces = manager->interfaces()->getModel(); 58 | for (const auto &interface : interfaces) { 59 | if (interface->type() == QNetworkSettingsType::Type::Wifi) { 60 | if (interface->powered()) { 61 | interface->scanServices(); 62 | } else { 63 | interface->setPowered(true); 64 | } 65 | } 66 | } 67 | } 68 | \endcode 69 | 70 | \sa QNetworkSettingsService 71 | */ 72 | 73 | /*! 74 | \property QNetworkSettingsManager::services 75 | \brief Holds the service model. 76 | 77 | \sa QNetworkSettingsServiceFilter 78 | */ 79 | 80 | /*! 81 | \property QNetworkSettingsManager::interfaces 82 | \brief Holds the interface model. 83 | 84 | \sa QNetworkSettingsInterfaceModel 85 | */ 86 | 87 | /*! 88 | \property QNetworkSettingsManager::userAgent 89 | \brief Holds the user credentials for connecting to a network. 90 | 91 | \sa QNetworkSettingsUserAgent 92 | */ 93 | 94 | /*! 95 | \property QNetworkSettingsManager::currentWifiConnection 96 | \brief Holds the current Wifi connection. 97 | 98 | \sa QNetworkSettingsService 99 | */ 100 | 101 | /*! 102 | \property QNetworkSettingsManager::currentWiredConnection 103 | \brief Holds the current wired connection. 104 | 105 | \sa QNetworkSettingsService 106 | */ 107 | 108 | /*! 109 | \fn QNetworkSettingsManager::servicesChanged() 110 | 111 | This signal is emitted when the network service changes. 112 | */ 113 | 114 | /*! 115 | \fn QNetworkSettingsManager::interfacesChanged() 116 | 117 | This signal is emitted when the network interface changes. 118 | */ 119 | 120 | /*! 121 | \fn QNetworkSettingsManager::currentWifiConnectionChanged() 122 | 123 | This signal is emitted when the current Wifi connection changes. 124 | */ 125 | 126 | /*! 127 | \fn QNetworkSettingsManager::currentWiredConnectionChanged() 128 | 129 | This signal is emitted when the current wired connection changes. 130 | */ 131 | 132 | /*! 133 | Creates a network manager with the parent \a parent. 134 | */ 135 | QNetworkSettingsManager::QNetworkSettingsManager(QObject *parent) : 136 | QObject(parent) 137 | ,d_ptr(new QNetworkSettingsManagerPrivate(this)) 138 | { 139 | } 140 | 141 | /*! 142 | Returns the service model. 143 | 144 | \l QNetworkSettingsType::Type 145 | */ 146 | QNetworkSettingsServiceFilter *QNetworkSettingsManager::services() 147 | { 148 | Q_D(QNetworkSettingsManager); 149 | return d->serviceFilter(); 150 | } 151 | 152 | /*! 153 | Returns the interface model. 154 | */ 155 | QNetworkSettingsInterfaceModel *QNetworkSettingsManager::interfaces() 156 | { 157 | Q_D(QNetworkSettingsManager); 158 | return d->interfaceModel(); 159 | } 160 | 161 | /*! 162 | Returns the service model \a name of the type \a type. 163 | */ 164 | QNetworkSettingsService* QNetworkSettingsManager::service(const QString& name, int type) 165 | { 166 | Q_D(QNetworkSettingsManager); 167 | 168 | for (QNetworkSettingsService* service : d->serviceModel()->getModel()) { 169 | if (service->name() == name && service->type() == type) { 170 | return service; 171 | } 172 | } 173 | return nullptr; 174 | } 175 | 176 | /*! 177 | Creates a connection to the network specified by \a name using the password 178 | \a passphrase. 179 | */ 180 | void QNetworkSettingsManager::connectBySsid(const QString &name, const QString &passphrase) 181 | { 182 | Q_D(QNetworkSettingsManager); 183 | QNetworkSettingsUserAgent* agent = userAgent(); 184 | if (agent) 185 | agent->setSsidAndPassphrase(name, passphrase); 186 | d->connectBySsid(name); 187 | } 188 | 189 | /*! 190 | Clears the connection state. 191 | */ 192 | void QNetworkSettingsManager::clearConnectionState() 193 | { 194 | Q_D(QNetworkSettingsManager); 195 | d->clearConnectionState(); 196 | QNetworkSettingsUserAgent* agent = userAgent(); 197 | if (agent) 198 | agent->clearConnectionState(); 199 | } 200 | 201 | /*! 202 | Attempts to connect using the next network interface in the model. 203 | */ 204 | void QNetworkSettingsManager::tryNextConnection() 205 | { 206 | Q_D(QNetworkSettingsManager); 207 | d->tryNextConnection(); 208 | } 209 | 210 | /*! 211 | Terminates the current connection to the specified \a service. 212 | */ 213 | void QNetworkSettingsManager::clearCurrentConnection(QNetworkSettingsService* service) 214 | { 215 | Q_D(QNetworkSettingsManager); 216 | if (service->type() == QNetworkSettingsType::Wifi) { 217 | QNetworkSettingsService *currentService = d->currentWifiConnection(); 218 | if (service == currentService) { 219 | d->setCurrentWifiConnection(nullptr); 220 | emit currentWifiConnectionChanged(); 221 | } 222 | } else if (service->type() == QNetworkSettingsType::Wired) { 223 | QNetworkSettingsService *currentService = d->currentWiredConnection(); 224 | if (service == currentService) { 225 | d->setCurrentWiredConnection(nullptr); 226 | emit currentWiredConnectionChanged(); 227 | } 228 | } 229 | } 230 | 231 | /*! 232 | Creates a connection to the specified \a service. 233 | */ 234 | void QNetworkSettingsManager::setCurrentConnection(QNetworkSettingsService* service) 235 | { 236 | Q_D(QNetworkSettingsManager); 237 | if (service->type() == QNetworkSettingsType::Wifi) { 238 | QNetworkSettingsService *currentService = d->currentWifiConnection(); 239 | d->setCurrentWifiConnection(service); 240 | if (service != currentService) 241 | emit currentWifiConnectionChanged(); 242 | } else if (service->type() == QNetworkSettingsType::Wired) { 243 | QNetworkSettingsService *currentService = d->currentWiredConnection(); 244 | d->setCurrentWiredConnection(service); 245 | if (service != currentService) 246 | emit currentWiredConnectionChanged(); 247 | } 248 | } 249 | 250 | /*! 251 | Returns the current Wifi connection. 252 | */ 253 | QNetworkSettingsService* QNetworkSettingsManager::currentWifiConnection() 254 | { 255 | Q_D(QNetworkSettingsManager); 256 | return d->currentWifiConnection(); 257 | } 258 | 259 | /*! 260 | Returns the current wired connection. 261 | */ 262 | QNetworkSettingsService* QNetworkSettingsManager::currentWiredConnection() 263 | { 264 | Q_D(QNetworkSettingsManager); 265 | return d->currentWiredConnection(); 266 | } 267 | 268 | /*! 269 | Returns the network interface instance \a instance of the type \a type. 270 | */ 271 | QNetworkSettingsInterface* QNetworkSettingsManager::interface(int type, int instance) 272 | { 273 | Q_D(QNetworkSettingsManager); 274 | int matchingInstance = 0; 275 | 276 | for (QNetworkSettingsInterface* interface : d->m_interfaceModel.getModel()) { 277 | if (interface->type() == type) { 278 | if (matchingInstance == instance) { 279 | return interface; 280 | } 281 | matchingInstance++; 282 | } 283 | } 284 | return nullptr; 285 | } 286 | 287 | /*! 288 | Sets the user credentials for connecting to a network to \a agent. 289 | */ 290 | void QNetworkSettingsManager::setUserAgent(QNetworkSettingsUserAgent *agent) 291 | { 292 | Q_D(QNetworkSettingsManager); 293 | d->setUserAgent(agent); 294 | connect(agent, &QNetworkSettingsUserAgent::requestNextConnection, 295 | this, &QNetworkSettingsManager::tryNextConnection); 296 | } 297 | 298 | /*! 299 | Returns the user credentials for connecting to a network. 300 | */ 301 | QNetworkSettingsUserAgent* QNetworkSettingsManager::userAgent() 302 | { 303 | Q_D(QNetworkSettingsManager); 304 | return d->userAgent(); 305 | } 306 | 307 | QT_END_NAMESPACE 308 | -------------------------------------------------------------------------------- /src/networksettings/qnetworksettingsmanager.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #ifndef QNETWORKSETTINGSMANAGER_H 4 | #define QNETWORKSETTINGSMANAGER_H 5 | 6 | #include 7 | #include 8 | 9 | QT_BEGIN_NAMESPACE 10 | 11 | class QNetworkSettingsService; 12 | class QNetworkSettingsInterface; 13 | class QNetworkSettingsUserAgent; 14 | class QNetworkSettingsServiceFilter; 15 | class QNetworkSettingsInterfaceModel; 16 | class QNetworkSettingsManagerPrivate; 17 | class Q_NETWORKSETTINGS_EXPORT QNetworkSettingsManager : public QObject 18 | { 19 | Q_OBJECT 20 | Q_PROPERTY(QNetworkSettingsServiceFilter* services READ services NOTIFY servicesChanged) 21 | Q_PROPERTY(QNetworkSettingsInterfaceModel* interfaces READ interfaces NOTIFY interfacesChanged) 22 | Q_PROPERTY(QNetworkSettingsUserAgent* userAgent READ userAgent CONSTANT) 23 | Q_PROPERTY(QNetworkSettingsService* currentWifiConnection READ currentWifiConnection NOTIFY currentWifiConnectionChanged) 24 | Q_PROPERTY(QNetworkSettingsService* currentWiredConnection READ currentWiredConnection NOTIFY currentWiredConnectionChanged) 25 | Q_MOC_INCLUDE("qnetworksettingsservicemodel.h") 26 | Q_MOC_INCLUDE("qnetworksettingsuseragent.h") 27 | 28 | public: 29 | explicit QNetworkSettingsManager(QObject* parent = nullptr); 30 | QNetworkSettingsServiceFilter* services(); 31 | QNetworkSettingsInterfaceModel* interfaces(); 32 | void setUserAgent(QNetworkSettingsUserAgent *agent); 33 | QNetworkSettingsUserAgent* userAgent(); 34 | 35 | Q_INVOKABLE QNetworkSettingsService* service(const QString& name, int type); 36 | Q_INVOKABLE void connectBySsid(const QString& name, const QString &passphrase); 37 | void clearConnectionState(); 38 | void tryNextConnection(); 39 | void clearCurrentConnection(QNetworkSettingsService* service); 40 | void setCurrentConnection(QNetworkSettingsService* service); 41 | QNetworkSettingsService* currentWifiConnection(); 42 | QNetworkSettingsService* currentWiredConnection(); 43 | Q_INVOKABLE QNetworkSettingsInterface* interface(int type, int instance); 44 | 45 | Q_SIGNALS: 46 | void servicesChanged(); 47 | void interfacesChanged(); 48 | void currentWifiConnectionChanged(); 49 | void currentWiredConnectionChanged(); 50 | 51 | protected: 52 | QNetworkSettingsManagerPrivate *d_ptr; 53 | 54 | private: 55 | Q_DISABLE_COPY(QNetworkSettingsManager) 56 | Q_DECLARE_PRIVATE(QNetworkSettingsManager) 57 | }; 58 | 59 | QT_END_NAMESPACE 60 | 61 | #endif // QNETWORKSETTINGSMANAGER_H 62 | -------------------------------------------------------------------------------- /src/networksettings/qnetworksettingsservice.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #ifndef QNETWORKSETTINGSSERVICE_H 4 | #define QNETWORKSETTINGSSERVICE_H 5 | 6 | #include 7 | #include 8 | 9 | QT_BEGIN_NAMESPACE 10 | 11 | class QNetworkSettingsServicePrivate; 12 | class Q_NETWORKSETTINGS_EXPORT QNetworkSettingsService : public QObject 13 | { 14 | Q_OBJECT 15 | Q_PROPERTY(QString id READ id CONSTANT) 16 | Q_PROPERTY(QString name READ name NOTIFY nameChanged) 17 | Q_PROPERTY(QNetworkSettingsState::State state READ state NOTIFY stateChanged) 18 | Q_PROPERTY(QNetworkSettingsType::Type type READ type NOTIFY typeChanged) 19 | Q_PROPERTY(QNetworkSettingsIPv4* ipv4 READ ipv4 NOTIFY ipv4Changed) 20 | Q_PROPERTY(QNetworkSettingsIPv6* ipv6 READ ipv6 NOTIFY ipv6Changed) 21 | Q_PROPERTY(QNetworkSettingsProxy* proxy READ proxy NOTIFY proxyChanged) 22 | Q_PROPERTY(QNetworkSettingsWireless* wirelessConfig READ wirelessConfig NOTIFY wirelessChanged) 23 | Q_PROPERTY(QAbstractItemModel* domains READ domains NOTIFY domainsChanged) 24 | Q_PROPERTY(QAbstractItemModel* nameservers READ nameservers NOTIFY nameserversChanged) 25 | Q_PROPERTY(bool autoConnect READ autoConnect WRITE setAutoConnect NOTIFY autoConnectChanged) 26 | public: 27 | explicit QNetworkSettingsService(const QString& aServiceId, QObject* parent = nullptr); 28 | 29 | QString id() const; 30 | QString name() const; 31 | QNetworkSettingsState::State state(); 32 | QNetworkSettingsType::Type type(); 33 | QNetworkSettingsIPv4* ipv4(); 34 | QNetworkSettingsIPv6* ipv6(); 35 | QNetworkSettingsProxy* proxy(); 36 | QAbstractItemModel* domains(); 37 | QAbstractItemModel* nameservers(); 38 | QNetworkSettingsWireless* wirelessConfig(); 39 | void setPlaceholderState(bool placeholderState); 40 | bool placeholderState() const; 41 | 42 | Q_INVOKABLE void setAutoConnect(bool autoconnect); 43 | Q_INVOKABLE bool autoConnect() const; 44 | Q_INVOKABLE void setupIpv4Config(); 45 | Q_INVOKABLE void setupIpv6Config(); 46 | Q_INVOKABLE void setupNameserversConfig(); 47 | Q_INVOKABLE void setupDomainsConfig(); 48 | Q_INVOKABLE void setupNetworkSettingsProxy(); 49 | //Wireless config 50 | Q_INVOKABLE void connectService(); 51 | void doConnectService(); 52 | Q_INVOKABLE void disconnectService(); 53 | Q_INVOKABLE void removeService(); 54 | Q_SIGNALS: 55 | void autoConnectChanged(); 56 | void nameChanged(); 57 | void stateChanged(); 58 | void typeChanged(); 59 | void proxyChanged(); 60 | void ipv4Changed(); 61 | void ipv6Changed(); 62 | void domainsChanged(); 63 | void nameserversChanged(); 64 | void wirelessChanged(); 65 | void connectionStateCleared(); 66 | void serviceConnected(QNetworkSettingsService* service); 67 | void serviceDisconnected(QNetworkSettingsService* service); 68 | protected: 69 | QNetworkSettingsServicePrivate *d_ptr; 70 | 71 | Q_DISABLE_COPY(QNetworkSettingsService) 72 | Q_DECLARE_PRIVATE(QNetworkSettingsService) 73 | }; 74 | 75 | QT_END_NAMESPACE 76 | 77 | #endif // QNETWORKSETTINGSSERVICE_H 78 | -------------------------------------------------------------------------------- /src/networksettings/qnetworksettingsservicemodel.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #ifndef QNETWORKSETTINGSSERVICEMODEL_H 4 | #define QNETWORKSETTINGSSERVICEMODEL_H 5 | 6 | #include 7 | #include 8 | 9 | QT_BEGIN_NAMESPACE 10 | 11 | class QNetworkSettingsService; 12 | class Q_NETWORKSETTINGS_EXPORT QNetworkSettingsServiceModel : public QAbstractListModel 13 | { 14 | Q_OBJECT 15 | public: 16 | explicit QNetworkSettingsServiceModel(QObject *parent = nullptr); 17 | virtual ~QNetworkSettingsServiceModel(); 18 | // from QAbstractItemModel 19 | int rowCount(const QModelIndex & parent = QModelIndex()) const override; 20 | QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override; 21 | QHash roleNames() const override; 22 | 23 | bool replacePlaceholder(QNetworkSettingsService* networkService); 24 | void append(QNetworkSettingsService* networkService); 25 | void insert(int row, QNetworkSettingsService* networkInterface); 26 | void remove(int row); 27 | bool removeService(const QString &id); 28 | void updated(int row); 29 | QNetworkSettingsService* getByName(const QString& name); 30 | QList getModel(); 31 | 32 | enum Roles { 33 | Type = Qt::UserRole + 1, 34 | Name, 35 | SignalStrength, 36 | Connected 37 | }; 38 | 39 | 40 | private Q_SLOTS: 41 | void connectionStatusChanged(); 42 | void signalStrengthChanged(); 43 | 44 | private: 45 | void connectStateChanges(QNetworkSettingsService* item); 46 | 47 | QList m_items; 48 | QHash m_roleNames; 49 | }; 50 | 51 | class Q_NETWORKSETTINGS_EXPORT QNetworkSettingsServiceFilter : public QSortFilterProxyModel 52 | { 53 | Q_OBJECT 54 | Q_PROPERTY(QNetworkSettingsType::Type type READ type WRITE setType NOTIFY typeChanged) 55 | Q_PROPERTY(bool wiredNetworksAvailable MEMBER m_wiredNetworksAvailable WRITE setWiredNetworksAvailable NOTIFY wiredNetworksAvailableChanged) 56 | public: 57 | explicit QNetworkSettingsServiceFilter(QObject* parent = nullptr); 58 | virtual ~QNetworkSettingsServiceFilter(); 59 | bool filterAcceptsRow( int source_row, const QModelIndex& source_parent ) const override; 60 | QNetworkSettingsType::Type type() const; 61 | void setType(QNetworkSettingsType::Type type); 62 | Q_INVOKABLE QVariant itemFromRow(const int row) const; 63 | Q_INVOKABLE int activeRow() const; 64 | void setWiredNetworksAvailable(bool); 65 | Q_SIGNALS: 66 | void typeChanged(); 67 | void wiredNetworksAvailableChanged(); 68 | private: 69 | QNetworkSettingsType::Type m_type; 70 | bool m_wiredNetworksAvailable; 71 | }; 72 | 73 | QT_END_NAMESPACE 74 | 75 | #endif // QNETWORKSETTINGSSERVICEMODEL_H 76 | -------------------------------------------------------------------------------- /src/networksettings/qnetworksettingsuseragent.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #include "qnetworksettingsuseragent.h" 4 | #include "qnetworksettingsuseragent_p.h" 5 | 6 | QT_BEGIN_NAMESPACE 7 | 8 | /*! 9 | \class QNetworkSettingsUserAgent 10 | \inmodule QtNetworkSettings 11 | 12 | \brief The QNetworkSettingsUserAgent represents the user credentials for 13 | connecting to a network. 14 | 15 | The QNetworkSettingsService::connectService() method is used to connect to 16 | a Wifi network. The network name is specified by using a service set 17 | identifier (SSID). If no password is needed, the connection is created 18 | immediately. QNetworkSettingsService::state property can be used to 19 | monitor the state of the connection. 20 | 21 | If a password is needed, the 22 | QNetworkSettingsUserAgent::showUserCredentialsInput() signal is emitted. 23 | To create a connection, the password is set by using the 24 | QNetworkSettingsUserAgent::setPassphrase() method. 25 | 26 | \sa QNetworkSettingsManager 27 | */ 28 | 29 | /*! 30 | \fn QNetworkSettingsUserAgent::showUserCredentialsInput() 31 | 32 | This signal is emitted when user credentials are required for connecting to 33 | a Wifi network. 34 | 35 | \sa QNetworkSettingsService::connectService() 36 | */ 37 | 38 | /*! 39 | \fn QNetworkSettingsUserAgent::error() 40 | 41 | This signal is emitted when the connection failed due to invalid user 42 | credentials. 43 | */ 44 | 45 | /*! 46 | \fn QNetworkSettingsUserAgent::ready(bool cancel) 47 | 48 | This signal is emitted when the user has either submitted the password 49 | for the network, or if \a cancel is \c true, cancelled the password 50 | query. 51 | */ 52 | 53 | /*! 54 | \fn QNetworkSettingsUserAgent::requestNextConnection() 55 | 56 | This signal is emitted when the network manager attempts to connect using 57 | the next network interface in the model. 58 | */ 59 | 60 | /*! 61 | Creates a user agent with the parent \a parent. 62 | */ 63 | QNetworkSettingsUserAgent::QNetworkSettingsUserAgent(QObject *parent) 64 | :QObject(parent) 65 | ,d_ptr(new QNetworkSettingsUserAgentPrivate(this)) 66 | { 67 | } 68 | 69 | /*! 70 | Sets the password for connecting to a Wifi network to \a passphrase. 71 | 72 | This method needs to be called in response to receiving the 73 | \l showUserCredentialsInput() signal. 74 | */ 75 | void QNetworkSettingsUserAgent::setPassphrase(const QString &passphrase) 76 | { 77 | Q_D(QNetworkSettingsUserAgent); 78 | d->setPassphrase(passphrase); 79 | } 80 | 81 | /*! 82 | Cancels the user credentials input request. 83 | */ 84 | void QNetworkSettingsUserAgent::cancelInput() 85 | { 86 | Q_D(QNetworkSettingsUserAgent); 87 | d->cancel(); 88 | } 89 | 90 | /*! 91 | Returns the password of the user agent. 92 | */ 93 | QString QNetworkSettingsUserAgent::passphrase() const 94 | { 95 | Q_D(const QNetworkSettingsUserAgent); 96 | return d->passphrase(); 97 | } 98 | 99 | /*! 100 | Sets the name of the network to \a ssid and the password of the user agent 101 | to \a passphrase. 102 | */ 103 | void QNetworkSettingsUserAgent::setSsidAndPassphrase(const QString &ssid, const QString &passphrase) 104 | { 105 | Q_D(QNetworkSettingsUserAgent); 106 | d->setSsidAndPassphrase(ssid, passphrase); 107 | } 108 | 109 | /*! 110 | Clears the connection state. 111 | */ 112 | void QNetworkSettingsUserAgent::clearConnectionState() 113 | { 114 | Q_D(QNetworkSettingsUserAgent); 115 | d->clearConnectionState(); 116 | } 117 | 118 | QT_END_NAMESPACE 119 | -------------------------------------------------------------------------------- /src/networksettings/qnetworksettingsuseragent.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #ifndef QNETWORKSETTINGSUSERAGENT_H 4 | #define QNETWORKSETTINGSUSERAGENT_H 5 | 6 | #include 7 | #include 8 | 9 | QT_BEGIN_NAMESPACE 10 | 11 | class QNetworkSettingsUserAgentPrivate; 12 | class Q_NETWORKSETTINGS_EXPORT QNetworkSettingsUserAgent : public QObject 13 | { 14 | Q_OBJECT 15 | public: 16 | explicit QNetworkSettingsUserAgent(QObject *parent = nullptr); 17 | Q_INVOKABLE void setPassphrase(const QString &passphrase); 18 | Q_INVOKABLE void cancelInput(); 19 | QString passphrase() const; 20 | void setSsidAndPassphrase(const QString &ssid, const QString &passphrase); 21 | void clearConnectionState(); 22 | 23 | Q_SIGNALS: 24 | void showUserCredentialsInput(); 25 | void error(); 26 | void ready(bool cancel); 27 | void requestNextConnection(); 28 | private: 29 | QNetworkSettingsUserAgentPrivate *d_ptr; 30 | 31 | Q_DISABLE_COPY(QNetworkSettingsUserAgent) 32 | Q_DECLARE_PRIVATE(QNetworkSettingsUserAgent) 33 | }; 34 | 35 | QT_END_NAMESPACE 36 | 37 | #endif // QNETWORKSETTINGSUSERAGENT_H 38 | -------------------------------------------------------------------------------- /src/networksettingsqml/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | qt_internal_add_qml_module(networksettingsqml 2 | URI "QtDeviceUtilities.NetworkSettings" 3 | VERSION "${CMAKE_PROJECT_VERSION}" 4 | PAST_MAJOR_VERSIONS 1 5 | PLUGIN_TARGET networksettingsqml 6 | DEPENDENCIES 7 | QtQml 8 | SOURCES 9 | qnetworksettingsforeign.h qnetworksettingsforeign.cpp 10 | LIBRARIES 11 | Qt::Core 12 | Qt::Qml 13 | Qt::NetworkSettings 14 | ) 15 | -------------------------------------------------------------------------------- /src/networksettingsqml/qnetworksettingsforeign.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #include "qnetworksettingsforeign.h" 4 | 5 | /*! 6 | \qmlmodule QtDeviceUtilities.NetworkSettings 7 | \ingroup qtdevice-utilities-qml-modules 8 | \ingroup qmlmodules 9 | \title Qt Network Settings QML Types 10 | 11 | \brief Provides singleton QML types for controlling network settings. 12 | 13 | Qt Network Settings QML module provides singleton QML types for controlling 14 | network settings in an embedded device. 15 | 16 | To import and use the module's QML types, use the following statement: 17 | 18 | \badcode 19 | import QtDeviceUtilities.NetworkSettings 20 | \endcode 21 | 22 | \l{Qt Device Utilities WiFi Tutorial} demonstrates how you can use 23 | \l{QtDeviceUtilities.NetworkSettings}{NetworkSettings} for connecting to WiFi. 24 | 25 | \note Some functions may not be available on all of the platforms. 26 | 27 | \section1 QML Types 28 | */ 29 | 30 | /*! 31 | \qmltype NetworkSettingsManager 32 | \inqmlmodule QtDeviceUtilities.NetworkSettings 33 | \brief A singleton QML type for managing network settings. 34 | 35 | There is no need to create an instance of this object. To use it, 36 | simply import the \c {QtDeviceUtilities.NetworkSettings} module. 37 | 38 | \l{Qt Device Utilities WiFi Tutorial} demonstrates how you can use 39 | \l{NetworkSettingsManager} for connecting to WiFi. 40 | */ 41 | 42 | /*! 43 | \qmlproperty model NetworkSettingsManager::services 44 | \readonly 45 | 46 | Holds the service model. A delegate in a view that uses 47 | the \e services model can access the NetworkService 48 | item with the \e entry role. 49 | 50 | The services list in the model can be controlled with the 51 | \c type property, and NetworkService items can be retrieved 52 | with the \c {itemFromRow(int index)} method. For example, to 53 | select the first available wired network service: 54 | 55 | \code 56 | property var service: null 57 | ... 58 | NetworkSettingsManager.services.type = NetworkSettingsType.Wired; 59 | service = NetworkSettingsManager.services.itemFromRow(0); 60 | \endcode 61 | 62 | Available service types: 63 | 64 | \value NetworkSettingsType.Wired Wired network 65 | \value NetworkSettingsType.Wifi Wifi network 66 | \value NetworkSettingsType.Bluetooth Bluetooth network 67 | \value NetworkSettingsType.Unknown Unknown network type 68 | 69 | \sa NetworkService 70 | */ 71 | 72 | /*! 73 | \qmlproperty model NetworkSettingsManager::interfaces 74 | \readonly 75 | 76 | Holds the interface model. A delegate in a view that uses 77 | the \e interfaces model can access the NetworkInterface 78 | item with the \e entry role. 79 | 80 | \sa NetworkInterface 81 | */ 82 | 83 | /*! 84 | \qmlmethod NetworkService NetworkSettingsManager::service(string name, int type) 85 | 86 | Returns the service with name \a name and type \a type. 87 | 88 | \sa services 89 | */ 90 | 91 | /*! 92 | \qmlmethod NetworkInterface NetworkSettingsManager::interface(int type, int instance) 93 | 94 | Returns the interface with type \a type and order number of \a instance 95 | 96 | \sa NetworkInterface 97 | */ 98 | 99 | /*! 100 | \qmlmethod NetworkSettingsManager::userAgent.setPassphrase(string passphrase) 101 | 102 | Sets the \a passphrase for connecting to a Wifi network. 103 | 104 | This method needs to be called in response to receiving a showUserCredentialsInput() signal. 105 | 106 | \sa userAgent.showUserCredentialsInput() 107 | */ 108 | 109 | /*! 110 | \qmlsignal NetworkSettingsManager::userAgent.showUserCredentialsInput() 111 | 112 | This signal is emitted when user credentials are required for connecting to a Wifi network. 113 | 114 | \sa userAgent.setPassphrase() 115 | */ 116 | 117 | /*! 118 | \qmlmethod NetworkSettingsManager::userAgent.cancelInput() 119 | 120 | Cancels the user credentials input request. 121 | */ 122 | 123 | /*! 124 | \qmlsignal NetworkSettingsManager::userAgent.error() 125 | 126 | This signal is emitted when the connection failed due to invalid user credentials. 127 | */ 128 | -------------------------------------------------------------------------------- /src/networksettingsqml/qnetworksettingsforeign.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #ifndef NETWORKSETTINGSPLUGIN_PLUGIN_H 4 | #define NETWORKSETTINGSPLUGIN_PLUGIN_H 5 | 6 | #include 7 | #include 8 | 9 | QT_BEGIN_NAMESPACE 10 | 11 | struct NetworkSettingsServiceForeign 12 | { 13 | Q_GADGET 14 | QML_FOREIGN(QNetworkSettingsService) 15 | QML_NAMED_ELEMENT(NetworkService) 16 | QML_UNCREATABLE("Cannot be instantiated directly.") 17 | QML_ADDED_IN_VERSION(1, 0) 18 | }; 19 | 20 | struct NetworkSettingsInterfaceForeign 21 | { 22 | Q_GADGET 23 | QML_FOREIGN(QNetworkSettingsInterface) 24 | QML_NAMED_ELEMENT(NetworkInterface) 25 | QML_UNCREATABLE("Cannot be instantiated directly.") 26 | QML_ADDED_IN_VERSION(1, 0) 27 | }; 28 | 29 | struct NetworkSettingsIPv4Foreign 30 | { 31 | Q_GADGET 32 | QML_FOREIGN(QNetworkSettingsIPv4) 33 | QML_NAMED_ELEMENT(NetworkSettingsIPv4) 34 | QML_UNCREATABLE("Cannot be instantiated directly.") 35 | QML_ADDED_IN_VERSION(1, 0) 36 | }; 37 | 38 | struct NetworkSettingsIPv6Foreign 39 | { 40 | Q_GADGET 41 | QML_FOREIGN(QNetworkSettingsIPv6) 42 | QML_NAMED_ELEMENT(NetworkSettingsIPv6) 43 | QML_UNCREATABLE("Cannot be instantiated directly.") 44 | QML_ADDED_IN_VERSION(1, 0) 45 | }; 46 | 47 | struct NetworkSettingsProxyForeign 48 | { 49 | Q_GADGET 50 | QML_FOREIGN(QNetworkSettingsProxy) 51 | QML_NAMED_ELEMENT(NetworkSettingsProxy) 52 | QML_UNCREATABLE("Cannot be instantiated directly.") 53 | QML_ADDED_IN_VERSION(1, 0) 54 | }; 55 | 56 | struct NetworkSettingsWirelessForeign 57 | { 58 | Q_GADGET 59 | QML_FOREIGN(QNetworkSettingsWireless) 60 | QML_NAMED_ELEMENT(NetworkSettingsWireless) 61 | QML_UNCREATABLE("Cannot be instantiated directly.") 62 | QML_ADDED_IN_VERSION(1, 0) 63 | }; 64 | 65 | struct NetworkSettingsTypeForeign 66 | { 67 | Q_GADGET 68 | QML_FOREIGN(QNetworkSettingsType) 69 | QML_NAMED_ELEMENT(NetworkSettingsType) 70 | QML_UNCREATABLE("Cannot be instantiated directly.") 71 | QML_ADDED_IN_VERSION(1, 0) 72 | }; 73 | 74 | struct NetworkSettingsStateForeign 75 | { 76 | Q_GADGET 77 | QML_FOREIGN(QNetworkSettingsState) 78 | QML_NAMED_ELEMENT(NetworkSettingsState) 79 | QML_UNCREATABLE("Cannot be instantiated directly.") 80 | QML_ADDED_IN_VERSION(1, 0) 81 | }; 82 | 83 | class QNetworkSettingsManagerForeign 84 | { 85 | Q_GADGET 86 | QML_FOREIGN(QNetworkSettingsManager) 87 | QML_NAMED_ELEMENT(NetworkSettingsManager) 88 | QML_SINGLETON 89 | QML_ADDED_IN_VERSION(2, 0) 90 | }; 91 | 92 | QT_END_NAMESPACE 93 | 94 | #endif // NETWORKSETTINGSPLUGIN_PLUGIN_H 95 | 96 | -------------------------------------------------------------------------------- /sync.profile: -------------------------------------------------------------------------------- 1 | %modules = ( # path to module name map 2 | "QtNetworkSettings" => "$basedir/src/networksettings" 3 | ); 4 | %moduleheaders = ( # restrict the module headers to those found in relative path 5 | ); 6 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Generated from tests.pro. 2 | 3 | if(QT_BUILD_STANDALONE_TESTS) 4 | # Add qt_find_package calls for extra dependencies that need to be found when building 5 | # the standalone tests here. 6 | endif() 7 | qt_build_tests() 8 | --------------------------------------------------------------------------------