From 67630e49d69c03eddbb9c291ebc075b342ebfae5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Fad=C4=B1l=20USTA?= Date: Fri, 20 Mar 2020 01:41:37 +0300 Subject: [PATCH 001/259] Autotest file showing wrong File path It is a small trivial typo about showing same file instead of actual config file. REVIEW: D28151 --- autotests/kconfig_compiler/test_param_minmax.kcfgc | 2 +- autotests/kconfig_compiler/test_properties_minmax.kcfgc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/autotests/kconfig_compiler/test_param_minmax.kcfgc b/autotests/kconfig_compiler/test_param_minmax.kcfgc index 3d9d2768..d2aec87c 100644 --- a/autotests/kconfig_compiler/test_param_minmax.kcfgc +++ b/autotests/kconfig_compiler/test_param_minmax.kcfgc @@ -1,4 +1,4 @@ ClassName=TestParamMinMax -File=test_param_minmax.kcfgc +File=test_param_minmax.kcfg Mutators=true diff --git a/autotests/kconfig_compiler/test_properties_minmax.kcfgc b/autotests/kconfig_compiler/test_properties_minmax.kcfgc index 5cda329b..a7ce429e 100644 --- a/autotests/kconfig_compiler/test_properties_minmax.kcfgc +++ b/autotests/kconfig_compiler/test_properties_minmax.kcfgc @@ -1,5 +1,5 @@ ClassName=TestPropertiesMinMax GenerateProperties=true -File=test_properties_minmax.kcfgc +File=test_properties_minmax.kcfg Mutators=true From 43d4f1276b3afe259907add9b458f15252514fa4 Mon Sep 17 00:00:00 2001 From: Andreas Cord-Landwehr Date: Sun, 22 Mar 2020 12:38:38 +0100 Subject: [PATCH 002/259] KConfig: Convert to SPDX license statements Summary: Convert license headers to SPDX statements and add license files as required by REUSE specification. Reviewers: cgiboudeaux Reviewed By: cgiboudeaux Subscribers: ognarb, cgiboudeaux, kde-frameworks-devel Tags: #frameworks Maniphest Tasks: T11550 Differential Revision: https://phabricator.kde.org/D27601 --- KF5ConfigMacros.cmake | 30 +- LICENSES/BSD-2-Clause.txt | 22 + LICENSES/BSD-3-Clause.txt | 26 + LICENSES/GPL-2.0-or-later.txt | 319 ++++++++++++ LICENSES/LGPL-2.0-only.txt | 446 +++++++++++++++++ LICENSES/LGPL-2.0-or-later.txt | 446 +++++++++++++++++ LICENSES/LGPL-2.1-only.txt | 467 ++++++++++++++++++ LICENSES/LGPL-3.0-only.txt | 163 ++++++ LICENSES/LicenseRef-KDE-Accepted-LGPL.txt | 12 + LICENSES/MIT.txt | 19 + autotests/fallbackconfigresourcestest.cpp | 19 +- autotests/helper.h | 20 +- .../kconfig_compiler/kconfigcompiler_test.cpp | 15 +- .../kconfig_compiler/kconfigcompiler_test.h | 15 +- .../kconfigcompiler_test_signals.cpp | 21 +- autotests/kconfig_compiler/klocalizedstring.h | 21 +- autotests/kconfig_compiler/test10main.cpp | 19 +- autotests/kconfig_compiler/test11_types.h | 19 +- autotests/kconfig_compiler/test11main.cpp | 19 +- autotests/kconfig_compiler/test12main.cpp | 19 +- autotests/kconfig_compiler/test13main.cpp | 19 +- autotests/kconfig_compiler/test1main.cpp | 19 +- autotests/kconfig_compiler/test2main.cpp | 19 +- autotests/kconfig_compiler/test3amain.cpp | 19 +- autotests/kconfig_compiler/test3main.cpp | 19 +- autotests/kconfig_compiler/test4main.cpp | 19 +- autotests/kconfig_compiler/test5main.cpp | 19 +- autotests/kconfig_compiler/test6main.cpp | 19 +- autotests/kconfig_compiler/test7main.cpp | 19 +- autotests/kconfig_compiler/test8main.cpp | 19 +- autotests/kconfig_compiler/test9main.cpp | 20 +- .../kconfig_compiler/test_dpointer_main.cpp | 19 +- .../test_emptyentries_main.cpp | 19 +- .../test_fileextensions_main.cxx | 19 +- .../kconfig_compiler/test_notifiers_main.cpp | 19 +- .../test_qdebugcategorymain.cpp | 19 +- .../kconfig_compiler/test_signal_main.cpp | 19 +- .../test_translation_kde_domain_main.cpp | 19 +- .../test_translation_kde_main.cpp | 19 +- .../test_translation_qt_main.cpp | 19 +- autotests/kconfigguitest.cpp | 21 +- autotests/kconfigguitest.h | 19 +- autotests/kconfigloadertest.cpp | 23 +- autotests/kconfigloadertest.h | 23 +- autotests/kconfignokdehometest.cpp | 19 +- autotests/kconfigskeletontest.cpp | 21 +- autotests/kconfigskeletontest.h | 19 +- autotests/kconfigtest.cpp | 21 +- autotests/kconfigtest.h | 19 +- autotests/kdesktopfiletest.cpp | 20 +- autotests/kdesktopfiletest.h | 20 +- autotests/kentrymaptest.cpp | 21 +- autotests/kentrymaptest.h | 21 +- autotests/ksharedconfig_in_global_object.cpp | 16 +- autotests/ksharedconfigtest.cpp | 17 +- autotests/kstandardshortcuttest.cpp | 21 +- autotests/kstandardshortcuttest.h | 19 +- autotests/test_kconf_update.cpp | 24 +- autotests/test_kconf_update.h | 22 +- autotests/test_kconfigutils.cpp | 24 +- autotests/test_kconfigutils.h | 22 +- cmake/rules_PyKF5.py | 27 +- src/core/bufferfragment_p.h | 21 +- src/core/conversioncheck.h | 19 +- src/core/kauthorized.cpp | 23 +- src/core/kauthorized.h | 21 +- src/core/kconfig.cpp | 25 +- src/core/kconfig.h | 27 +- src/core/kconfig_p.h | 27 +- src/core/kconfigbackend.cpp | 25 +- src/core/kconfigbackend_p.h | 25 +- src/core/kconfigbase.cpp | 25 +- src/core/kconfigbase.h | 27 +- src/core/kconfigbase_p.h | 21 +- src/core/kconfigdata.cpp | 25 +- src/core/kconfigdata.h | 25 +- src/core/kconfiggroup.cpp | 25 +- src/core/kconfiggroup.h | 27 +- src/core/kconfiggroup_p.h | 21 +- src/core/kconfigini.cpp | 25 +- src/core/kconfigini_p.h | 21 +- src/core/kconfigwatcher.cpp | 21 +- src/core/kconfigwatcher.h | 21 +- src/core/kcoreconfigskeleton.cpp | 21 +- src/core/kcoreconfigskeleton.h | 27 +- src/core/kcoreconfigskeleton_p.h | 19 +- src/core/kdesktopfile.cpp | 23 +- src/core/kdesktopfile.h | 22 +- src/core/kemailsettings.cpp | 28 +- src/core/kemailsettings.h | 31 +- src/core/ksharedconfig.cpp | 23 +- src/core/ksharedconfig.h | 21 +- src/gui/kconfiggroupgui.cpp | 21 +- src/gui/kconfiggui.cpp | 20 +- src/gui/kconfiggui.h | 20 +- src/gui/kconfigloader.cpp | 21 +- src/gui/kconfigloader.h | 21 +- src/gui/kconfigloader_p.h | 21 +- src/gui/kconfigloaderhandler_p.h | 23 +- src/gui/kconfigskeleton.cpp | 21 +- src/gui/kconfigskeleton.h | 26 +- src/gui/kstandardshortcut.cpp | 25 +- src/gui/kstandardshortcut.h | 25 +- src/gui/kwindowconfig.cpp | 20 +- src/gui/kwindowconfig.h | 20 +- src/kconf_update/kconf_update.cpp | 23 +- src/kconf_update/kconfigutils.cpp | 23 +- src/kconf_update/kconfigutils.h | 26 +- .../KConfigCodeGeneratorBase.cpp | 34 +- .../KConfigCodeGeneratorBase.h | 32 +- src/kconfig_compiler/KConfigCommonStructs.h | 38 +- .../KConfigHeaderGenerator.cpp | 38 +- src/kconfig_compiler/KConfigHeaderGenerator.h | 30 +- src/kconfig_compiler/KConfigParameters.cpp | 30 +- src/kconfig_compiler/KConfigParameters.h | 27 +- .../KConfigSourceGenerator.cpp | 42 +- src/kconfig_compiler/KConfigSourceGenerator.h | 28 +- src/kconfig_compiler/KConfigXmlParser.cpp | 47 +- src/kconfig_compiler/KConfigXmlParser.h | 29 +- src/kconfig_compiler/kcfg.xsd | 10 +- src/kconfig_compiler/kconfig_compiler.cpp | 27 +- src/kreadconfig/kreadconfig.cpp | 18 +- src/kreadconfig/kwriteconfig.cpp | 17 +- 123 files changed, 2440 insertions(+), 2052 deletions(-) create mode 100644 LICENSES/BSD-2-Clause.txt create mode 100644 LICENSES/BSD-3-Clause.txt create mode 100644 LICENSES/GPL-2.0-or-later.txt create mode 100644 LICENSES/LGPL-2.0-only.txt create mode 100644 LICENSES/LGPL-2.0-or-later.txt create mode 100644 LICENSES/LGPL-2.1-only.txt create mode 100644 LICENSES/LGPL-3.0-only.txt create mode 100644 LICENSES/LicenseRef-KDE-Accepted-LGPL.txt create mode 100644 LICENSES/MIT.txt diff --git a/KF5ConfigMacros.cmake b/KF5ConfigMacros.cmake index df668e9c..99897792 100644 --- a/KF5ConfigMacros.cmake +++ b/KF5ConfigMacros.cmake @@ -5,33 +5,11 @@ # Use optional USE_RELATIVE_PATH to generate the classes in the build following the given # relative path to the file. # -# Copyright (c) 2006-2009 Alexander Neundorf, -# Copyright (c) 2006, 2007, Laurent Montel, -# Copyright (c) 2007 Matthias Kretz +# SPDX-FileCopyrightText: 2006-2009 Alexander Neundorf +# SPDX-FileCopyrightText: 2006, 2007, Laurent Montel +# SPDX-FileCopyrightText: 2007 Matthias Kretz # -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 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. -# 3. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. +# SPDX-License-Identifier: BSD-3-Clause include(CMakeParseArguments) diff --git a/LICENSES/BSD-2-Clause.txt b/LICENSES/BSD-2-Clause.txt new file mode 100644 index 00000000..2d2bab11 --- /dev/null +++ b/LICENSES/BSD-2-Clause.txt @@ -0,0 +1,22 @@ +Copyright (c) . All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. + +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. + +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. diff --git a/LICENSES/BSD-3-Clause.txt b/LICENSES/BSD-3-Clause.txt new file mode 100644 index 00000000..0741db78 --- /dev/null +++ b/LICENSES/BSD-3-Clause.txt @@ -0,0 +1,26 @@ +Copyright (c) . All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. + +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. + +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. + +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. diff --git a/LICENSES/GPL-2.0-or-later.txt b/LICENSES/GPL-2.0-or-later.txt new file mode 100644 index 00000000..1d80ac36 --- /dev/null +++ b/LICENSES/GPL-2.0-or-later.txt @@ -0,0 +1,319 @@ +GNU GENERAL PUBLIC LICENSE + +Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. + +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +Everyone is permitted to copy and distribute verbatim copies of this license +document, but changing it is not allowed. + +Preamble + +The licenses for most software are designed to take away your freedom to share +and change it. By contrast, the GNU General Public License is intended to +guarantee your freedom to share and change free software--to make sure the +software is free for all its users. This General Public License applies to +most of the Free Software Foundation's software and to any other program whose +authors commit to using it. (Some other Free Software Foundation software +is covered by the GNU Lesser General Public License instead.) You can apply +it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our +General Public Licenses are designed to make sure that you have the freedom +to distribute copies of free software (and charge for this service if you +wish), that you receive source code or can get it if you want it, that you +can change the software or use pieces of it in new free programs; and that +you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to +deny you these rights or to ask you to surrender the rights. These restrictions +translate to certain responsibilities for you if you distribute copies of +the software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or +for a fee, you must give the recipients all the rights that you have. You +must make sure that they, too, receive or can get the source code. And you +must show them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and (2) +offer you this license which gives you legal permission to copy, distribute +and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that +everyone understands that there is no warranty for this free software. If +the software is modified by someone else and passed on, we want its recipients +to know that what they have is not the original, so that any problems introduced +by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We +wish to avoid the danger that redistributors of a free program will individually +obtain patent licenses, in effect making the program proprietary. To prevent +this, we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification +follow. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License applies to any program or other work which contains a notice +placed by the copyright holder saying it may be distributed under the terms +of this General Public License. The "Program", below, refers to any such program +or work, and a "work based on the Program" means either the Program or any +derivative work under copyright law: that is to say, a work containing the +Program or a portion of it, either verbatim or with modifications and/or translated +into another language. (Hereinafter, translation is included without limitation +in the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not covered +by this License; they are outside its scope. The act of running the Program +is not restricted, and the output from the Program is covered only if its +contents constitute a work based on the Program (independent of having been +made by running the Program). Whether that is true depends on what the Program +does. + +1. You may copy and distribute verbatim copies of the Program's source code +as you receive it, in any medium, provided that you conspicuously and appropriately +publish on each copy an appropriate copyright notice and disclaimer of warranty; +keep intact all the notices that refer to this License and to the absence +of any warranty; and give any other recipients of the Program a copy of this +License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you +may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, +thus forming a work based on the Program, and copy and distribute such modifications +or work under the terms of Section 1 above, provided that you also meet all +of these conditions: + +a) You must cause the modified files to carry prominent notices stating that +you changed the files and the date of any change. + +b) You must cause any work that you distribute or publish, that in whole or +in part contains or is derived from the Program or any part thereof, to be +licensed as a whole at no charge to all third parties under the terms of this +License. + +c) If the modified program normally reads commands interactively when run, +you must cause it, when started running for such interactive use in the most +ordinary way, to print or display an announcement including an appropriate +copyright notice and a notice that there is no warranty (or else, saying that +you provide a warranty) and that users may redistribute the program under +these conditions, and telling the user how to view a copy of this License. +(Exception: if the Program itself is interactive but does not normally print +such an announcement, your work based on the Program is not required to print +an announcement.) + +These requirements apply to the modified work as a whole. If identifiable +sections of that work are not derived from the Program, and can be reasonably +considered independent and separate works in themselves, then this License, +and its terms, do not apply to those sections when you distribute them as +separate works. But when you distribute the same sections as part of a whole +which is a work based on the Program, the distribution of the whole must be +on the terms of this License, whose permissions for other licensees extend +to the entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest your +rights to work written entirely by you; rather, the intent is to exercise +the right to control the distribution of derivative or collective works based +on the Program. + +In addition, mere aggregation of another work not based on the Program with +the Program (or with a work based on the Program) on a volume of a storage +or distribution medium does not bring the other work under the scope of this +License. + +3. You may copy and distribute the Program (or a work based on it, under Section +2) in object code or executable form under the terms of Sections 1 and 2 above +provided that you also do one of the following: + +a) Accompany it with the complete corresponding machine-readable source code, +which must be distributed under the terms of Sections 1 and 2 above on a medium +customarily used for software interchange; or, + +b) Accompany it with a written offer, valid for at least three years, to give +any third party, for a charge no more than your cost of physically performing +source distribution, a complete machine-readable copy of the corresponding +source code, to be distributed under the terms of Sections 1 and 2 above on +a medium customarily used for software interchange; or, + +c) Accompany it with the information you received as to the offer to distribute +corresponding source code. (This alternative is allowed only for noncommercial +distribution and only if you received the program in object code or executable +form with such an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for making +modifications to it. For an executable work, complete source code means all +the source code for all modules it contains, plus any associated interface +definition files, plus the scripts used to control compilation and installation +of the executable. However, as a special exception, the source code distributed +need not include anything that is normally distributed (in either source or +binary form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component itself +accompanies the executable. + +If distribution of executable or object code is made by offering access to +copy from a designated place, then offering equivalent access to copy the +source code from the same place counts as distribution of the source code, +even though third parties are not compelled to copy the source along with +the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except +as expressly provided under this License. Any attempt otherwise to copy, modify, +sublicense or distribute the Program is void, and will automatically terminate +your rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses terminated +so long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed +it. However, nothing else grants you permission to modify or distribute the +Program or its derivative works. These actions are prohibited by law if you +do not accept this License. Therefore, by modifying or distributing the Program +(or any work based on the Program), you indicate your acceptance of this License +to do so, and all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), +the recipient automatically receives a license from the original licensor +to copy, distribute or modify the Program subject to these terms and conditions. +You may not impose any further restrictions on the recipients' exercise of +the rights granted herein. You are not responsible for enforcing compliance +by third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent infringement +or for any other reason (not limited to patent issues), conditions are imposed +on you (whether by court order, agreement or otherwise) that contradict the +conditions of this License, they do not excuse you from the conditions of +this License. If you cannot distribute so as to satisfy simultaneously your +obligations under this License and any other pertinent obligations, then as +a consequence you may not distribute the Program at all. For example, if a +patent license would not permit royalty-free redistribution of the Program +by all those who receive copies directly or indirectly through you, then the +only way you could satisfy both it and this License would be to refrain entirely +from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply and +the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents +or other property right claims or to contest validity of any such claims; +this section has the sole purpose of protecting the integrity of the free +software distribution system, which is implemented by public license practices. +Many people have made generous contributions to the wide range of software +distributed through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing to +distribute software through any other system and a licensee cannot impose +that choice. + +This section is intended to make thoroughly clear what is believed to be a +consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain +countries either by patents or by copyrighted interfaces, the original copyright +holder who places the Program under this License may add an explicit geographical +distribution limitation excluding those countries, so that distribution is +permitted only in or among countries not thus excluded. In such case, this +License incorporates the limitation as if written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new versions of +the General Public License from time to time. Such new versions will be similar +in spirit to the present version, but may differ in detail to address new +problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies +a version number of this License which applies to it and "any later version", +you have the option of following the terms and conditions either of that version +or of any later version published by the Free Software Foundation. If the +Program does not specify a version number of this License, you may choose +any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs +whose distribution conditions are different, write to the author to ask for +permission. For software which is copyrighted by the Free Software Foundation, +write to the Free Software Foundation; we sometimes make exceptions for this. +Our decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing and reuse +of software generally. + + NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR +THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE +STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM +"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE +OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE +OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA +OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES +OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH +HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible +use to the public, the best way to achieve this is to make it free software +which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach +them to the start of each source file to most effectively convey the exclusion +of warranty; and each file should have at least the "copyright" line and a +pointer to where the full notice is found. + + + +Copyright (C) + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 51 Franklin +Street, Fifth Floor, Boston, MA 02110-1301, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this when +it starts in an interactive mode: + +Gnomovision version 69, Copyright (C) year name of author Gnomovision comes +with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, +and you are welcome to redistribute it under certain conditions; type `show +c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may be +called something other than `show w' and `show c'; they could even be mouse-clicks +or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your school, +if any, to sign a "copyright disclaimer" for the program, if necessary. Here +is a sample; alter the names: + +Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' +(which makes passes at compilers) written by James Hacker. + +, 1 April 1989 Ty Coon, President of Vice This General +Public License does not permit incorporating your program into proprietary +programs. If your program is a subroutine library, you may consider it more +useful to permit linking proprietary applications with the library. If this +is what you want to do, use the GNU Lesser General Public License instead +of this License. diff --git a/LICENSES/LGPL-2.0-only.txt b/LICENSES/LGPL-2.0-only.txt new file mode 100644 index 00000000..5c96471a --- /dev/null +++ b/LICENSES/LGPL-2.0-only.txt @@ -0,0 +1,446 @@ +GNU LIBRARY GENERAL PUBLIC LICENSE + +Version 2, June 1991 Copyright (C) 1991 Free Software Foundation, Inc. + +51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + +Everyone is permitted to copy and distribute verbatim copies of this license +document, but changing it is not allowed. + +[This is the first released version of the library GPL. It is numbered 2 because +it goes with version 2 of the ordinary GPL.] + +Preamble + +The licenses for most software are designed to take away your freedom to share +and change it. By contrast, the GNU General Public Licenses are intended to +guarantee your freedom to share and change free software--to make sure the +software is free for all its users. + +This license, the Library General Public License, applies to some specially +designated Free Software Foundation software, and to any other libraries whose +authors decide to use it. You can use it for your libraries, too. + +When we speak of free software, we are referring to freedom, not price. Our +General Public Licenses are designed to make sure that you have the freedom +to distribute copies of free software (and charge for this service if you +wish), that you receive source code or can get it if you want it, that you +can change the software or use pieces of it in new free programs; and that +you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to +deny you these rights or to ask you to surrender the rights. These restrictions +translate to certain responsibilities for you if you distribute copies of +the library, or if you modify it. + +For example, if you distribute copies of the library, whether gratis or for +a fee, you must give the recipients all the rights that we gave you. You must +make sure that they, too, receive or can get the source code. If you link +a program with the library, you must provide complete object files to the +recipients so that they can relink them with the library, after making changes +to the library and recompiling it. And you must show them these terms so they +know their rights. + +Our method of protecting your rights has two steps: (1) copyright the library, +and (2) offer you this license which gives you legal permission to copy, distribute +and/or modify the library. + +Also, for each distributor's protection, we want to make certain that everyone +understands that there is no warranty for this free library. If the library +is modified by someone else and passed on, we want its recipients to know +that what they have is not the original version, so that any problems introduced +by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We +wish to avoid the danger that companies distributing free software will individually +obtain patent licenses, thus in effect transforming the program into proprietary +software. To prevent this, we have made it clear that any patent must be licensed +for everyone's free use or not licensed at all. + +Most GNU software, including some libraries, is covered by the ordinary GNU +General Public License, which was designed for utility programs. This license, +the GNU Library General Public License, applies to certain designated libraries. +This license is quite different from the ordinary one; be sure to read it +in full, and don't assume that anything in it is the same as in the ordinary +license. + +The reason we have a separate public license for some libraries is that they +blur the distinction we usually make between modifying or adding to a program +and simply using it. Linking a program with a library, without changing the +library, is in some sense simply using the library, and is analogous to running +a utility program or application program. However, in a textual and legal +sense, the linked executable is a combined work, a derivative of the original +library, and the ordinary General Public License treats it as such. + +Because of this blurred distinction, using the ordinary General Public License +for libraries did not effectively promote software sharing, because most developers +did not use the libraries. We concluded that weaker conditions might promote +sharing better. + +However, unrestricted linking of non-free programs would deprive the users +of those programs of all benefit from the free status of the libraries themselves. +This Library General Public License is intended to permit developers of non-free +programs to use free libraries, while preserving your freedom as a user of +such programs to change the free libraries that are incorporated in them. +(We have not seen how to achieve this as regards changes in header files, +but we have achieved it as regards changes in the actual functions of the +Library.) The hope is that this will lead to faster development of free libraries. + +The precise terms and conditions for copying, distribution and modification +follow. Pay close attention to the difference between a "work based on the +library" and a "work that uses the library". The former contains code derived +from the library, while the latter only works together with the library. + +Note that it is possible for a library to be covered by the ordinary General +Public License rather than by this special one. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License Agreement applies to any software library which contains a +notice placed by the copyright holder or other authorized party saying it +may be distributed under the terms of this Library General Public License +(also called "this License"). Each licensee is addressed as "you". + +A "library" means a collection of software functions and/or data prepared +so as to be conveniently linked with application programs (which use some +of those functions and data) to form executables. + +The "Library", below, refers to any such software library or work which has +been distributed under these terms. A "work based on the Library" means either +the Library or any derivative work under copyright law: that is to say, a +work containing the Library or a portion of it, either verbatim or with modifications +and/or translated straightforwardly into another language. (Hereinafter, translation +is included without limitation in the term "modification".) + +"Source code" for a work means the preferred form of the work for making modifications +to it. For a library, complete source code means all the source code for all +modules it contains, plus any associated interface definition files, plus +the scripts used to control compilation and installation of the library. + +Activities other than copying, distribution and modification are not covered +by this License; they are outside its scope. The act of running a program +using the Library is not restricted, and output from such a program is covered +only if its contents constitute a work based on the Library (independent of +the use of the Library in a tool for writing it). Whether that is true depends +on what the Library does and what the program that uses the Library does. + +1. You may copy and distribute verbatim copies of the Library's complete source +code as you receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice and disclaimer +of warranty; keep intact all the notices that refer to this License and to +the absence of any warranty; and distribute a copy of this License along with +the Library. + +You may charge a fee for the physical act of transferring a copy, and you +may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Library or any portion of it, +thus forming a work based on the Library, and copy and distribute such modifications +or work under the terms of Section 1 above, provided that you also meet all +of these conditions: + + a) The modified work must itself be a software library. + +b) You must cause the files modified to carry prominent notices stating that +you changed the files and the date of any change. + +c) You must cause the whole of the work to be licensed at no charge to all +third parties under the terms of this License. + +d) If a facility in the modified Library refers to a function or a table of +data to be supplied by an application program that uses the facility, other +than as an argument passed when the facility is invoked, then you must make +a good faith effort to ensure that, in the event an application does not supply +such function or table, the facility still operates, and performs whatever +part of its purpose remains meaningful. + +(For example, a function in a library to compute square roots has a purpose +that is entirely well-defined independent of the application. Therefore, Subsection +2d requires that any application-supplied function or table used by this function +must be optional: if the application does not supply it, the square root function +must still compute square roots.) + +These requirements apply to the modified work as a whole. If identifiable +sections of that work are not derived from the Library, and can be reasonably +considered independent and separate works in themselves, then this License, +and its terms, do not apply to those sections when you distribute them as +separate works. But when you distribute the same sections as part of a whole +which is a work based on the Library, the distribution of the whole must be +on the terms of this License, whose permissions for other licensees extend +to the entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest your +rights to work written entirely by you; rather, the intent is to exercise +the right to control the distribution of derivative or collective works based +on the Library. + +In addition, mere aggregation of another work not based on the Library with +the Library (or with a work based on the Library) on a volume of a storage +or distribution medium does not bring the other work under the scope of this +License. + +3. You may opt to apply the terms of the ordinary GNU General Public License +instead of this License to a given copy of the Library. To do this, you must +alter all the notices that refer to this License, so that they refer to the +ordinary GNU General Public License, version 2, instead of to this License. +(If a newer version than version 2 of the ordinary GNU General Public License +has appeared, then you can specify that version instead if you wish.) Do not +make any other change in these notices. + +Once this change is made in a given copy, it is irreversible for that copy, +so the ordinary GNU General Public License applies to all subsequent copies +and derivative works made from that copy. + +This option is useful when you wish to copy part of the code of the Library +into a program that is not a library. + +4. You may copy and distribute the Library (or a portion or derivative of +it, under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you accompany it with the complete corresponding +machine-readable source code, which must be distributed under the terms of +Sections 1 and 2 above on a medium customarily used for software interchange. + +If distribution of object code is made by offering access to copy from a designated +place, then offering equivalent access to copy the source code from the same +place satisfies the requirement to distribute the source code, even though +third parties are not compelled to copy the source along with the object code. + +5. A program that contains no derivative of any portion of the Library, but +is designed to work with the Library by being compiled or linked with it, +is called a "work that uses the Library". Such a work, in isolation, is not +a derivative work of the Library, and therefore falls outside the scope of +this License. + +However, linking a "work that uses the Library" with the Library creates an +executable that is a derivative of the Library (because it contains portions +of the Library), rather than a "work that uses the library". The executable +is therefore covered by this License. Section 6 states terms for distribution +of such executables. + +When a "work that uses the Library" uses material from a header file that +is part of the Library, the object code for the work may be a derivative work +of the Library even though the source code is not. Whether this is true is +especially significant if the work can be linked without the Library, or if +the work is itself a library. The threshold for this to be true is not precisely +defined by law. + +If such an object file uses only numerical parameters, data structure layouts +and accessors, and small macros and small inline functions (ten lines or less +in length), then the use of the object file is unrestricted, regardless of +whether it is legally a derivative work. (Executables containing this object +code plus portions of the Library will still fall under Section 6.) + +Otherwise, if the work is a derivative of the Library, you may distribute +the object code for the work under the terms of Section 6. Any executables +containing that work also fall under Section 6, whether or not they are linked +directly with the Library itself. + +6. As an exception to the Sections above, you may also compile or link a "work +that uses the Library" with the Library to produce a work containing portions +of the Library, and distribute that work under terms of your choice, provided +that the terms permit modification of the work for the customer's own use +and reverse engineering for debugging such modifications. + +You must give prominent notice with each copy of the work that the Library +is used in it and that the Library and its use are covered by this License. +You must supply a copy of this License. If the work during execution displays +copyright notices, you must include the copyright notice for the Library among +them, as well as a reference directing the user to the copy of this License. +Also, you must do one of these things: + +a) Accompany the work with the complete corresponding machine-readable source +code for the Library including whatever changes were used in the work (which +must be distributed under Sections 1 and 2 above); and, if the work is an +executable linked with the Library, with the complete machine-readable "work +that uses the Library", as object code and/or source code, so that the user +can modify the Library and then relink to produce a modified executable containing +the modified Library. (It is understood that the user who changes the contents +of definitions files in the Library will not necessarily be able to recompile +the application to use the modified definitions.) + +b) Accompany the work with a written offer, valid for at least three years, +to give the same user the materials specified in Subsection 6a, above, for +a charge no more than the cost of performing this distribution. + +c) If distribution of the work is made by offering access to copy from a designated +place, offer equivalent access to copy the above specified materials from +the same place. + +d) Verify that the user has already received a copy of these materials or +that you have already sent this user a copy. + +For an executable, the required form of the "work that uses the Library" must +include any data and utility programs needed for reproducing the executable +from it. However, as a special exception, the source code distributed need +not include anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the operating +system on which the executable runs, unless that component itself accompanies +the executable. + +It may happen that this requirement contradicts the license restrictions of +other proprietary libraries that do not normally accompany the operating system. +Such a contradiction means you cannot use both them and the Library together +in an executable that you distribute. + +7. You may place library facilities that are a work based on the Library side-by-side +in a single library together with other library facilities not covered by +this License, and distribute such a combined library, provided that the separate +distribution of the work based on the Library and of the other library facilities +is otherwise permitted, and provided that you do these two things: + +a) Accompany the combined library with a copy of the same work based on the +Library, uncombined with any other library facilities. This must be distributed +under the terms of the Sections above. + +b) Give prominent notice with the combined library of the fact that part of +it is a work based on the Library, and explaining where to find the accompanying +uncombined form of the same work. + +8. You may not copy, modify, sublicense, link with, or distribute the Library +except as expressly provided under this License. Any attempt otherwise to +copy, modify, sublicense, link with, or distribute the Library is void, and +will automatically terminate your rights under this License. However, parties +who have received copies, or rights, from you under this License will not +have their licenses terminated so long as such parties remain in full compliance. + +9. You are not required to accept this License, since you have not signed +it. However, nothing else grants you permission to modify or distribute the +Library or its derivative works. These actions are prohibited by law if you +do not accept this License. Therefore, by modifying or distributing the Library +(or any work based on the Library), you indicate your acceptance of this License +to do so, and all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + +10. Each time you redistribute the Library (or any work based on the Library), +the recipient automatically receives a license from the original licensor +to copy, distribute, link with or modify the Library subject to these terms +and conditions. You may not impose any further restrictions on the recipients' +exercise of the rights granted herein. You are not responsible for enforcing +compliance by third parties to this License. + +11. If, as a consequence of a court judgment or allegation of patent infringement +or for any other reason (not limited to patent issues), conditions are imposed +on you (whether by court order, agreement or otherwise) that contradict the +conditions of this License, they do not excuse you from the conditions of +this License. If you cannot distribute so as to satisfy simultaneously your +obligations under this License and any other pertinent obligations, then as +a consequence you may not distribute the Library at all. For example, if a +patent license would not permit royalty-free redistribution of the Library +by all those who receive copies directly or indirectly through you, then the +only way you could satisfy both it and this License would be to refrain entirely +from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents +or other property right claims or to contest validity of any such claims; +this section has the sole purpose of protecting the integrity of the free +software distribution system which is implemented by public license practices. +Many people have made generous contributions to the wide range of software +distributed through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing to +distribute software through any other system and a licensee cannot impose +that choice. + +This section is intended to make thoroughly clear what is believed to be a +consequence of the rest of this License. + +12. If the distribution and/or use of the Library is restricted in certain +countries either by patents or by copyrighted interfaces, the original copyright +holder who places the Library under this License may add an explicit geographical +distribution limitation excluding those countries, so that distribution is +permitted only in or among countries not thus excluded. In such case, this +License incorporates the limitation as if written in the body of this License. + +13. The Free Software Foundation may publish revised and/or new versions of +the Library General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to address +new problems or concerns. + +Each version is given a distinguishing version number. If the Library specifies +a version number of this License which applies to it and "any later version", +you have the option of following the terms and conditions either of that version +or of any later version published by the Free Software Foundation. If the +Library does not specify a license version number, you may choose any version +ever published by the Free Software Foundation. + +14. If you wish to incorporate parts of the Library into other free programs +whose distribution conditions are incompatible with these, write to the author +to ask for permission. For software which is copyrighted by the Free Software +Foundation, write to the Free Software Foundation; we sometimes make exceptions +for this. Our decision will be guided by the two goals of preserving the free +status of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + +15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR +THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE +STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY +"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE +OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE +THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE +OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA +OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES +OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH +HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Libraries + +If you develop a new library, and you want it to be of the greatest possible +use to the public, we recommend making it free software that everyone can +redistribute and change. You can do so by permitting redistribution under +these terms (or, alternatively, under the terms of the ordinary General Public +License). + +To apply these terms, attach the following notices to the library. It is safest +to attach them to the start of each source file to most effectively convey +the exclusion of warranty; and each file should have at least the "copyright" +line and a pointer to where the full notice is found. + +one line to give the library's name and an idea of what it does. + +Copyright (C) year name of author + +This library is free software; you can redistribute it and/or modify it under +the terms of the GNU Library General Public License as published by the Free +Software Foundation; either version 2 of the License, or (at your option) +any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more +details. + +You should have received a copy of the GNU Library General Public License +along with this library; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your school, +if any, to sign a "copyright disclaimer" for the library, if necessary. Here +is a sample; alter the names: + +Yoyodyne, Inc., hereby disclaims all copyright interest in + +the library `Frob' (a library for tweaking knobs) written + +by James Random Hacker. + +signature of Ty Coon, 1 April 1990 + +Ty Coon, President of Vice + +That's all there is to it! diff --git a/LICENSES/LGPL-2.0-or-later.txt b/LICENSES/LGPL-2.0-or-later.txt new file mode 100644 index 00000000..5c96471a --- /dev/null +++ b/LICENSES/LGPL-2.0-or-later.txt @@ -0,0 +1,446 @@ +GNU LIBRARY GENERAL PUBLIC LICENSE + +Version 2, June 1991 Copyright (C) 1991 Free Software Foundation, Inc. + +51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + +Everyone is permitted to copy and distribute verbatim copies of this license +document, but changing it is not allowed. + +[This is the first released version of the library GPL. It is numbered 2 because +it goes with version 2 of the ordinary GPL.] + +Preamble + +The licenses for most software are designed to take away your freedom to share +and change it. By contrast, the GNU General Public Licenses are intended to +guarantee your freedom to share and change free software--to make sure the +software is free for all its users. + +This license, the Library General Public License, applies to some specially +designated Free Software Foundation software, and to any other libraries whose +authors decide to use it. You can use it for your libraries, too. + +When we speak of free software, we are referring to freedom, not price. Our +General Public Licenses are designed to make sure that you have the freedom +to distribute copies of free software (and charge for this service if you +wish), that you receive source code or can get it if you want it, that you +can change the software or use pieces of it in new free programs; and that +you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to +deny you these rights or to ask you to surrender the rights. These restrictions +translate to certain responsibilities for you if you distribute copies of +the library, or if you modify it. + +For example, if you distribute copies of the library, whether gratis or for +a fee, you must give the recipients all the rights that we gave you. You must +make sure that they, too, receive or can get the source code. If you link +a program with the library, you must provide complete object files to the +recipients so that they can relink them with the library, after making changes +to the library and recompiling it. And you must show them these terms so they +know their rights. + +Our method of protecting your rights has two steps: (1) copyright the library, +and (2) offer you this license which gives you legal permission to copy, distribute +and/or modify the library. + +Also, for each distributor's protection, we want to make certain that everyone +understands that there is no warranty for this free library. If the library +is modified by someone else and passed on, we want its recipients to know +that what they have is not the original version, so that any problems introduced +by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We +wish to avoid the danger that companies distributing free software will individually +obtain patent licenses, thus in effect transforming the program into proprietary +software. To prevent this, we have made it clear that any patent must be licensed +for everyone's free use or not licensed at all. + +Most GNU software, including some libraries, is covered by the ordinary GNU +General Public License, which was designed for utility programs. This license, +the GNU Library General Public License, applies to certain designated libraries. +This license is quite different from the ordinary one; be sure to read it +in full, and don't assume that anything in it is the same as in the ordinary +license. + +The reason we have a separate public license for some libraries is that they +blur the distinction we usually make between modifying or adding to a program +and simply using it. Linking a program with a library, without changing the +library, is in some sense simply using the library, and is analogous to running +a utility program or application program. However, in a textual and legal +sense, the linked executable is a combined work, a derivative of the original +library, and the ordinary General Public License treats it as such. + +Because of this blurred distinction, using the ordinary General Public License +for libraries did not effectively promote software sharing, because most developers +did not use the libraries. We concluded that weaker conditions might promote +sharing better. + +However, unrestricted linking of non-free programs would deprive the users +of those programs of all benefit from the free status of the libraries themselves. +This Library General Public License is intended to permit developers of non-free +programs to use free libraries, while preserving your freedom as a user of +such programs to change the free libraries that are incorporated in them. +(We have not seen how to achieve this as regards changes in header files, +but we have achieved it as regards changes in the actual functions of the +Library.) The hope is that this will lead to faster development of free libraries. + +The precise terms and conditions for copying, distribution and modification +follow. Pay close attention to the difference between a "work based on the +library" and a "work that uses the library". The former contains code derived +from the library, while the latter only works together with the library. + +Note that it is possible for a library to be covered by the ordinary General +Public License rather than by this special one. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License Agreement applies to any software library which contains a +notice placed by the copyright holder or other authorized party saying it +may be distributed under the terms of this Library General Public License +(also called "this License"). Each licensee is addressed as "you". + +A "library" means a collection of software functions and/or data prepared +so as to be conveniently linked with application programs (which use some +of those functions and data) to form executables. + +The "Library", below, refers to any such software library or work which has +been distributed under these terms. A "work based on the Library" means either +the Library or any derivative work under copyright law: that is to say, a +work containing the Library or a portion of it, either verbatim or with modifications +and/or translated straightforwardly into another language. (Hereinafter, translation +is included without limitation in the term "modification".) + +"Source code" for a work means the preferred form of the work for making modifications +to it. For a library, complete source code means all the source code for all +modules it contains, plus any associated interface definition files, plus +the scripts used to control compilation and installation of the library. + +Activities other than copying, distribution and modification are not covered +by this License; they are outside its scope. The act of running a program +using the Library is not restricted, and output from such a program is covered +only if its contents constitute a work based on the Library (independent of +the use of the Library in a tool for writing it). Whether that is true depends +on what the Library does and what the program that uses the Library does. + +1. You may copy and distribute verbatim copies of the Library's complete source +code as you receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice and disclaimer +of warranty; keep intact all the notices that refer to this License and to +the absence of any warranty; and distribute a copy of this License along with +the Library. + +You may charge a fee for the physical act of transferring a copy, and you +may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Library or any portion of it, +thus forming a work based on the Library, and copy and distribute such modifications +or work under the terms of Section 1 above, provided that you also meet all +of these conditions: + + a) The modified work must itself be a software library. + +b) You must cause the files modified to carry prominent notices stating that +you changed the files and the date of any change. + +c) You must cause the whole of the work to be licensed at no charge to all +third parties under the terms of this License. + +d) If a facility in the modified Library refers to a function or a table of +data to be supplied by an application program that uses the facility, other +than as an argument passed when the facility is invoked, then you must make +a good faith effort to ensure that, in the event an application does not supply +such function or table, the facility still operates, and performs whatever +part of its purpose remains meaningful. + +(For example, a function in a library to compute square roots has a purpose +that is entirely well-defined independent of the application. Therefore, Subsection +2d requires that any application-supplied function or table used by this function +must be optional: if the application does not supply it, the square root function +must still compute square roots.) + +These requirements apply to the modified work as a whole. If identifiable +sections of that work are not derived from the Library, and can be reasonably +considered independent and separate works in themselves, then this License, +and its terms, do not apply to those sections when you distribute them as +separate works. But when you distribute the same sections as part of a whole +which is a work based on the Library, the distribution of the whole must be +on the terms of this License, whose permissions for other licensees extend +to the entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest your +rights to work written entirely by you; rather, the intent is to exercise +the right to control the distribution of derivative or collective works based +on the Library. + +In addition, mere aggregation of another work not based on the Library with +the Library (or with a work based on the Library) on a volume of a storage +or distribution medium does not bring the other work under the scope of this +License. + +3. You may opt to apply the terms of the ordinary GNU General Public License +instead of this License to a given copy of the Library. To do this, you must +alter all the notices that refer to this License, so that they refer to the +ordinary GNU General Public License, version 2, instead of to this License. +(If a newer version than version 2 of the ordinary GNU General Public License +has appeared, then you can specify that version instead if you wish.) Do not +make any other change in these notices. + +Once this change is made in a given copy, it is irreversible for that copy, +so the ordinary GNU General Public License applies to all subsequent copies +and derivative works made from that copy. + +This option is useful when you wish to copy part of the code of the Library +into a program that is not a library. + +4. You may copy and distribute the Library (or a portion or derivative of +it, under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you accompany it with the complete corresponding +machine-readable source code, which must be distributed under the terms of +Sections 1 and 2 above on a medium customarily used for software interchange. + +If distribution of object code is made by offering access to copy from a designated +place, then offering equivalent access to copy the source code from the same +place satisfies the requirement to distribute the source code, even though +third parties are not compelled to copy the source along with the object code. + +5. A program that contains no derivative of any portion of the Library, but +is designed to work with the Library by being compiled or linked with it, +is called a "work that uses the Library". Such a work, in isolation, is not +a derivative work of the Library, and therefore falls outside the scope of +this License. + +However, linking a "work that uses the Library" with the Library creates an +executable that is a derivative of the Library (because it contains portions +of the Library), rather than a "work that uses the library". The executable +is therefore covered by this License. Section 6 states terms for distribution +of such executables. + +When a "work that uses the Library" uses material from a header file that +is part of the Library, the object code for the work may be a derivative work +of the Library even though the source code is not. Whether this is true is +especially significant if the work can be linked without the Library, or if +the work is itself a library. The threshold for this to be true is not precisely +defined by law. + +If such an object file uses only numerical parameters, data structure layouts +and accessors, and small macros and small inline functions (ten lines or less +in length), then the use of the object file is unrestricted, regardless of +whether it is legally a derivative work. (Executables containing this object +code plus portions of the Library will still fall under Section 6.) + +Otherwise, if the work is a derivative of the Library, you may distribute +the object code for the work under the terms of Section 6. Any executables +containing that work also fall under Section 6, whether or not they are linked +directly with the Library itself. + +6. As an exception to the Sections above, you may also compile or link a "work +that uses the Library" with the Library to produce a work containing portions +of the Library, and distribute that work under terms of your choice, provided +that the terms permit modification of the work for the customer's own use +and reverse engineering for debugging such modifications. + +You must give prominent notice with each copy of the work that the Library +is used in it and that the Library and its use are covered by this License. +You must supply a copy of this License. If the work during execution displays +copyright notices, you must include the copyright notice for the Library among +them, as well as a reference directing the user to the copy of this License. +Also, you must do one of these things: + +a) Accompany the work with the complete corresponding machine-readable source +code for the Library including whatever changes were used in the work (which +must be distributed under Sections 1 and 2 above); and, if the work is an +executable linked with the Library, with the complete machine-readable "work +that uses the Library", as object code and/or source code, so that the user +can modify the Library and then relink to produce a modified executable containing +the modified Library. (It is understood that the user who changes the contents +of definitions files in the Library will not necessarily be able to recompile +the application to use the modified definitions.) + +b) Accompany the work with a written offer, valid for at least three years, +to give the same user the materials specified in Subsection 6a, above, for +a charge no more than the cost of performing this distribution. + +c) If distribution of the work is made by offering access to copy from a designated +place, offer equivalent access to copy the above specified materials from +the same place. + +d) Verify that the user has already received a copy of these materials or +that you have already sent this user a copy. + +For an executable, the required form of the "work that uses the Library" must +include any data and utility programs needed for reproducing the executable +from it. However, as a special exception, the source code distributed need +not include anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the operating +system on which the executable runs, unless that component itself accompanies +the executable. + +It may happen that this requirement contradicts the license restrictions of +other proprietary libraries that do not normally accompany the operating system. +Such a contradiction means you cannot use both them and the Library together +in an executable that you distribute. + +7. You may place library facilities that are a work based on the Library side-by-side +in a single library together with other library facilities not covered by +this License, and distribute such a combined library, provided that the separate +distribution of the work based on the Library and of the other library facilities +is otherwise permitted, and provided that you do these two things: + +a) Accompany the combined library with a copy of the same work based on the +Library, uncombined with any other library facilities. This must be distributed +under the terms of the Sections above. + +b) Give prominent notice with the combined library of the fact that part of +it is a work based on the Library, and explaining where to find the accompanying +uncombined form of the same work. + +8. You may not copy, modify, sublicense, link with, or distribute the Library +except as expressly provided under this License. Any attempt otherwise to +copy, modify, sublicense, link with, or distribute the Library is void, and +will automatically terminate your rights under this License. However, parties +who have received copies, or rights, from you under this License will not +have their licenses terminated so long as such parties remain in full compliance. + +9. You are not required to accept this License, since you have not signed +it. However, nothing else grants you permission to modify or distribute the +Library or its derivative works. These actions are prohibited by law if you +do not accept this License. Therefore, by modifying or distributing the Library +(or any work based on the Library), you indicate your acceptance of this License +to do so, and all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + +10. Each time you redistribute the Library (or any work based on the Library), +the recipient automatically receives a license from the original licensor +to copy, distribute, link with or modify the Library subject to these terms +and conditions. You may not impose any further restrictions on the recipients' +exercise of the rights granted herein. You are not responsible for enforcing +compliance by third parties to this License. + +11. If, as a consequence of a court judgment or allegation of patent infringement +or for any other reason (not limited to patent issues), conditions are imposed +on you (whether by court order, agreement or otherwise) that contradict the +conditions of this License, they do not excuse you from the conditions of +this License. If you cannot distribute so as to satisfy simultaneously your +obligations under this License and any other pertinent obligations, then as +a consequence you may not distribute the Library at all. For example, if a +patent license would not permit royalty-free redistribution of the Library +by all those who receive copies directly or indirectly through you, then the +only way you could satisfy both it and this License would be to refrain entirely +from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents +or other property right claims or to contest validity of any such claims; +this section has the sole purpose of protecting the integrity of the free +software distribution system which is implemented by public license practices. +Many people have made generous contributions to the wide range of software +distributed through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing to +distribute software through any other system and a licensee cannot impose +that choice. + +This section is intended to make thoroughly clear what is believed to be a +consequence of the rest of this License. + +12. If the distribution and/or use of the Library is restricted in certain +countries either by patents or by copyrighted interfaces, the original copyright +holder who places the Library under this License may add an explicit geographical +distribution limitation excluding those countries, so that distribution is +permitted only in or among countries not thus excluded. In such case, this +License incorporates the limitation as if written in the body of this License. + +13. The Free Software Foundation may publish revised and/or new versions of +the Library General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to address +new problems or concerns. + +Each version is given a distinguishing version number. If the Library specifies +a version number of this License which applies to it and "any later version", +you have the option of following the terms and conditions either of that version +or of any later version published by the Free Software Foundation. If the +Library does not specify a license version number, you may choose any version +ever published by the Free Software Foundation. + +14. If you wish to incorporate parts of the Library into other free programs +whose distribution conditions are incompatible with these, write to the author +to ask for permission. For software which is copyrighted by the Free Software +Foundation, write to the Free Software Foundation; we sometimes make exceptions +for this. Our decision will be guided by the two goals of preserving the free +status of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + +15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR +THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE +STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY +"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE +OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE +THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE +OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA +OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES +OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH +HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Libraries + +If you develop a new library, and you want it to be of the greatest possible +use to the public, we recommend making it free software that everyone can +redistribute and change. You can do so by permitting redistribution under +these terms (or, alternatively, under the terms of the ordinary General Public +License). + +To apply these terms, attach the following notices to the library. It is safest +to attach them to the start of each source file to most effectively convey +the exclusion of warranty; and each file should have at least the "copyright" +line and a pointer to where the full notice is found. + +one line to give the library's name and an idea of what it does. + +Copyright (C) year name of author + +This library is free software; you can redistribute it and/or modify it under +the terms of the GNU Library General Public License as published by the Free +Software Foundation; either version 2 of the License, or (at your option) +any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more +details. + +You should have received a copy of the GNU Library General Public License +along with this library; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your school, +if any, to sign a "copyright disclaimer" for the library, if necessary. Here +is a sample; alter the names: + +Yoyodyne, Inc., hereby disclaims all copyright interest in + +the library `Frob' (a library for tweaking knobs) written + +by James Random Hacker. + +signature of Ty Coon, 1 April 1990 + +Ty Coon, President of Vice + +That's all there is to it! diff --git a/LICENSES/LGPL-2.1-only.txt b/LICENSES/LGPL-2.1-only.txt new file mode 100644 index 00000000..130dffb3 --- /dev/null +++ b/LICENSES/LGPL-2.1-only.txt @@ -0,0 +1,467 @@ +GNU LESSER GENERAL PUBLIC LICENSE + +Version 2.1, February 1999 + +Copyright (C) 1991, 1999 Free Software Foundation, Inc. + +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Everyone is permitted to copy and distribute verbatim copies of this license +document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts as the +successor of the GNU Library Public License, version 2, hence the version +number 2.1.] + +Preamble + +The licenses for most software are designed to take away your freedom to share +and change it. By contrast, the GNU General Public Licenses are intended to +guarantee your freedom to share and change free software--to make sure the +software is free for all its users. + +This license, the Lesser General Public License, applies to some specially +designated software packages--typically libraries--of the Free Software Foundation +and other authors who decide to use it. You can use it too, but we suggest +you first think carefully about whether this license or the ordinary General +Public License is the better strategy to use in any particular case, based +on the explanations below. + +When we speak of free software, we are referring to freedom of use, not price. +Our General Public Licenses are designed to make sure that you have the freedom +to distribute copies of free software (and charge for this service if you +wish); that you receive source code or can get it if you want it; that you +can change the software and use pieces of it in new free programs; and that +you are informed that you can do these things. + +To protect your rights, we need to make restrictions that forbid distributors +to deny you these rights or to ask you to surrender these rights. These restrictions +translate to certain responsibilities for you if you distribute copies of +the library or if you modify it. + +For example, if you distribute copies of the library, whether gratis or for +a fee, you must give the recipients all the rights that we gave you. You must +make sure that they, too, receive or can get the source code. If you link +other code with the library, you must provide complete object files to the +recipients, so that they can relink them with the library after making changes +to the library and recompiling it. And you must show them these terms so they +know their rights. + +We protect your rights with a two-step method: (1) we copyright the library, +and (2) we offer you this license, which gives you legal permission to copy, +distribute and/or modify the library. + +To protect each distributor, we want to make it very clear that there is no +warranty for the free library. Also, if the library is modified by someone +else and passed on, the recipients should know that what they have is not +the original version, so that the original author's reputation will not be +affected by problems that might be introduced by others. + +Finally, software patents pose a constant threat to the existence of any free +program. We wish to make sure that a company cannot effectively restrict the +users of a free program by obtaining a restrictive license from a patent holder. +Therefore, we insist that any patent license obtained for a version of the +library must be consistent with the full freedom of use specified in this +license. + +Most GNU software, including some libraries, is covered by the ordinary GNU +General Public License. This license, the GNU Lesser General Public License, +applies to certain designated libraries, and is quite different from the ordinary +General Public License. We use this license for certain libraries in order +to permit linking those libraries into non-free programs. + +When a program is linked with a library, whether statically or using a shared +library, the combination of the two is legally speaking a combined work, a +derivative of the original library. The ordinary General Public License therefore +permits such linking only if the entire combination fits its criteria of freedom. +The Lesser General Public License permits more lax criteria for linking other +code with the library. + +We call this license the "Lesser" General Public License because it does Less +to protect the user's freedom than the ordinary General Public License. It +also provides other free software developers Less of an advantage over competing +non-free programs. These disadvantages are the reason we use the ordinary +General Public License for many libraries. However, the Lesser license provides +advantages in certain special circumstances. + +For example, on rare occasions, there may be a special need to encourage the +widest possible use of a certain library, so that it becomes a de-facto standard. +To achieve this, non-free programs must be allowed to use the library. A more +frequent case is that a free library does the same job as widely used non-free +libraries. In this case, there is little to gain by limiting the free library +to free software only, so we use the Lesser General Public License. + +In other cases, permission to use a particular library in non-free programs +enables a greater number of people to use a large body of free software. For +example, permission to use the GNU C Library in non-free programs enables +many more people to use the whole GNU operating system, as well as its variant, +the GNU/Linux operating system. + +Although the Lesser General Public License is Less protective of the users' +freedom, it does ensure that the user of a program that is linked with the +Library has the freedom and the wherewithal to run that program using a modified +version of the Library. + +The precise terms and conditions for copying, distribution and modification +follow. Pay close attention to the difference between a "work based on the +library" and a "work that uses the library". The former contains code derived +from the library, whereas the latter must be combined with the library in +order to run. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License Agreement applies to any software library or other program +which contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Lesser General +Public License (also called "this License"). Each licensee is addressed as +"you". + +A "library" means a collection of software functions and/or data prepared +so as to be conveniently linked with application programs (which use some +of those functions and data) to form executables. + +The "Library", below, refers to any such software library or work which has +been distributed under these terms. A "work based on the Library" means either +the Library or any derivative work under copyright law: that is to say, a +work containing the Library or a portion of it, either verbatim or with modifications +and/or translated straightforwardly into another language. (Hereinafter, translation +is included without limitation in the term "modification".) + +"Source code" for a work means the preferred form of the work for making modifications +to it. For a library, complete source code means all the source code for all +modules it contains, plus any associated interface definition files, plus +the scripts used to control compilation and installation of the library. + +Activities other than copying, distribution and modification are not covered +by this License; they are outside its scope. The act of running a program +using the Library is not restricted, and output from such a program is covered +only if its contents constitute a work based on the Library (independent of +the use of the Library in a tool for writing it). Whether that is true depends +on what the Library does and what the program that uses the Library does. + +1. You may copy and distribute verbatim copies of the Library's complete source +code as you receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice and disclaimer +of warranty; keep intact all the notices that refer to this License and to +the absence of any warranty; and distribute a copy of this License along with +the Library. + +You may charge a fee for the physical act of transferring a copy, and you +may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Library or any portion of it, +thus forming a work based on the Library, and copy and distribute such modifications +or work under the terms of Section 1 above, provided that you also meet all +of these conditions: + + a) The modified work must itself be a software library. + +b) You must cause the files modified to carry prominent notices stating that +you changed the files and the date of any change. + +c) You must cause the whole of the work to be licensed at no charge to all +third parties under the terms of this License. + +d) If a facility in the modified Library refers to a function or a table of +data to be supplied by an application program that uses the facility, other +than as an argument passed when the facility is invoked, then you must make +a good faith effort to ensure that, in the event an application does not supply +such function or table, the facility still operates, and performs whatever +part of its purpose remains meaningful. + +(For example, a function in a library to compute square roots has a purpose +that is entirely well-defined independent of the application. Therefore, Subsection +2d requires that any application-supplied function or table used by this function +must be optional: if the application does not supply it, the square root function +must still compute square roots.) + +These requirements apply to the modified work as a whole. If identifiable +sections of that work are not derived from the Library, and can be reasonably +considered independent and separate works in themselves, then this License, +and its terms, do not apply to those sections when you distribute them as +separate works. But when you distribute the same sections as part of a whole +which is a work based on the Library, the distribution of the whole must be +on the terms of this License, whose permissions for other licensees extend +to the entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest your +rights to work written entirely by you; rather, the intent is to exercise +the right to control the distribution of derivative or collective works based +on the Library. + +In addition, mere aggregation of another work not based on the Library with +the Library (or with a work based on the Library) on a volume of a storage +or distribution medium does not bring the other work under the scope of this +License. + +3. You may opt to apply the terms of the ordinary GNU General Public License +instead of this License to a given copy of the Library. To do this, you must +alter all the notices that refer to this License, so that they refer to the +ordinary GNU General Public License, version 2, instead of to this License. +(If a newer version than version 2 of the ordinary GNU General Public License +has appeared, then you can specify that version instead if you wish.) Do not +make any other change in these notices. + +Once this change is made in a given copy, it is irreversible for that copy, +so the ordinary GNU General Public License applies to all subsequent copies +and derivative works made from that copy. + +This option is useful when you wish to copy part of the code of the Library +into a program that is not a library. + +4. You may copy and distribute the Library (or a portion or derivative of +it, under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you accompany it with the complete corresponding +machine-readable source code, which must be distributed under the terms of +Sections 1 and 2 above on a medium customarily used for software interchange. + +If distribution of object code is made by offering access to copy from a designated +place, then offering equivalent access to copy the source code from the same +place satisfies the requirement to distribute the source code, even though +third parties are not compelled to copy the source along with the object code. + +5. A program that contains no derivative of any portion of the Library, but +is designed to work with the Library by being compiled or linked with it, +is called a "work that uses the Library". Such a work, in isolation, is not +a derivative work of the Library, and therefore falls outside the scope of +this License. + +However, linking a "work that uses the Library" with the Library creates an +executable that is a derivative of the Library (because it contains portions +of the Library), rather than a "work that uses the library". The executable +is therefore covered by this License. Section 6 states terms for distribution +of such executables. + +When a "work that uses the Library" uses material from a header file that +is part of the Library, the object code for the work may be a derivative work +of the Library even though the source code is not. Whether this is true is +especially significant if the work can be linked without the Library, or if +the work is itself a library. The threshold for this to be true is not precisely +defined by law. + +If such an object file uses only numerical parameters, data structure layouts +and accessors, and small macros and small inline functions (ten lines or less +in length), then the use of the object file is unrestricted, regardless of +whether it is legally a derivative work. (Executables containing this object +code plus portions of the Library will still fall under Section 6.) + +Otherwise, if the work is a derivative of the Library, you may distribute +the object code for the work under the terms of Section 6. Any executables +containing that work also fall under Section 6, whether or not they are linked +directly with the Library itself. + +6. As an exception to the Sections above, you may also combine or link a "work +that uses the Library" with the Library to produce a work containing portions +of the Library, and distribute that work under terms of your choice, provided +that the terms permit modification of the work for the customer's own use +and reverse engineering for debugging such modifications. + +You must give prominent notice with each copy of the work that the Library +is used in it and that the Library and its use are covered by this License. +You must supply a copy of this License. If the work during execution displays +copyright notices, you must include the copyright notice for the Library among +them, as well as a reference directing the user to the copy of this License. +Also, you must do one of these things: + +a) Accompany the work with the complete corresponding machine-readable source +code for the Library including whatever changes were used in the work (which +must be distributed under Sections 1 and 2 above); and, if the work is an +executable linked with the Library, with the complete machine-readable "work +that uses the Library", as object code and/or source code, so that the user +can modify the Library and then relink to produce a modified executable containing +the modified Library. (It is understood that the user who changes the contents +of definitions files in the Library will not necessarily be able to recompile +the application to use the modified definitions.) + +b) Use a suitable shared library mechanism for linking with the Library. A +suitable mechanism is one that (1) uses at run time a copy of the library +already present on the user's computer system, rather than copying library +functions into the executable, and (2) will operate properly with a modified +version of the library, if the user installs one, as long as the modified +version is interface-compatible with the version that the work was made with. + +c) Accompany the work with a written offer, valid for at least three years, +to give the same user the materials specified in Subsection 6a, above, for +a charge no more than the cost of performing this distribution. + +d) If distribution of the work is made by offering access to copy from a designated +place, offer equivalent access to copy the above specified materials from +the same place. + +e) Verify that the user has already received a copy of these materials or +that you have already sent this user a copy. + +For an executable, the required form of the "work that uses the Library" must +include any data and utility programs needed for reproducing the executable +from it. However, as a special exception, the materials to be distributed +need not include anything that is normally distributed (in either source or +binary form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component itself +accompanies the executable. + +It may happen that this requirement contradicts the license restrictions of +other proprietary libraries that do not normally accompany the operating system. +Such a contradiction means you cannot use both them and the Library together +in an executable that you distribute. + +7. You may place library facilities that are a work based on the Library side-by-side +in a single library together with other library facilities not covered by +this License, and distribute such a combined library, provided that the separate +distribution of the work based on the Library and of the other library facilities +is otherwise permitted, and provided that you do these two things: + +a) Accompany the combined library with a copy of the same work based on the +Library, uncombined with any other library facilities. This must be distributed +under the terms of the Sections above. + +b) Give prominent notice with the combined library of the fact that part of +it is a work based on the Library, and explaining where to find the accompanying +uncombined form of the same work. + +8. You may not copy, modify, sublicense, link with, or distribute the Library +except as expressly provided under this License. Any attempt otherwise to +copy, modify, sublicense, link with, or distribute the Library is void, and +will automatically terminate your rights under this License. However, parties +who have received copies, or rights, from you under this License will not +have their licenses terminated so long as such parties remain in full compliance. + +9. You are not required to accept this License, since you have not signed +it. However, nothing else grants you permission to modify or distribute the +Library or its derivative works. These actions are prohibited by law if you +do not accept this License. Therefore, by modifying or distributing the Library +(or any work based on the Library), you indicate your acceptance of this License +to do so, and all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + +10. Each time you redistribute the Library (or any work based on the Library), +the recipient automatically receives a license from the original licensor +to copy, distribute, link with or modify the Library subject to these terms +and conditions. You may not impose any further restrictions on the recipients' +exercise of the rights granted herein. You are not responsible for enforcing +compliance by third parties with this License. + +11. If, as a consequence of a court judgment or allegation of patent infringement +or for any other reason (not limited to patent issues), conditions are imposed +on you (whether by court order, agreement or otherwise) that contradict the +conditions of this License, they do not excuse you from the conditions of +this License. If you cannot distribute so as to satisfy simultaneously your +obligations under this License and any other pertinent obligations, then as +a consequence you may not distribute the Library at all. For example, if a +patent license would not permit royalty-free redistribution of the Library +by all those who receive copies directly or indirectly through you, then the +only way you could satisfy both it and this License would be to refrain entirely +from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents +or other property right claims or to contest validity of any such claims; +this section has the sole purpose of protecting the integrity of the free +software distribution system which is implemented by public license practices. +Many people have made generous contributions to the wide range of software +distributed through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing to +distribute software through any other system and a licensee cannot impose +that choice. + +This section is intended to make thoroughly clear what is believed to be a +consequence of the rest of this License. + +12. If the distribution and/or use of the Library is restricted in certain +countries either by patents or by copyrighted interfaces, the original copyright +holder who places the Library under this License may add an explicit geographical +distribution limitation excluding those countries, so that distribution is +permitted only in or among countries not thus excluded. In such case, this +License incorporates the limitation as if written in the body of this License. + +13. The Free Software Foundation may publish revised and/or new versions of +the Lesser General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to address +new problems or concerns. + +Each version is given a distinguishing version number. If the Library specifies +a version number of this License which applies to it and "any later version", +you have the option of following the terms and conditions either of that version +or of any later version published by the Free Software Foundation. If the +Library does not specify a license version number, you may choose any version +ever published by the Free Software Foundation. + +14. If you wish to incorporate parts of the Library into other free programs +whose distribution conditions are incompatible with these, write to the author +to ask for permission. For software which is copyrighted by the Free Software +Foundation, write to the Free Software Foundation; we sometimes make exceptions +for this. Our decision will be guided by the two goals of preserving the free +status of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + +15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR +THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE +STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY +"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE +OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE +THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE +OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA +OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES +OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH +HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Libraries + +If you develop a new library, and you want it to be of the greatest possible +use to the public, we recommend making it free software that everyone can +redistribute and change. You can do so by permitting redistribution under +these terms (or, alternatively, under the terms of the ordinary General Public +License). + +To apply these terms, attach the following notices to the library. It is safest +to attach them to the start of each source file to most effectively convey +the exclusion of warranty; and each file should have at least the "copyright" +line and a pointer to where the full notice is found. + +< one line to give the library's name and an idea of what it does. > + +Copyright (C) < year > < name of author > + +This library is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free +Software Foundation; either version 2.1 of the License, or (at your option) +any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. + +You should have received a copy of the GNU Lesser General Public License along +with this library; if not, write to the Free Software Foundation, Inc., 51 +Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information +on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your school, +if any, to sign a "copyright disclaimer" for the library, if necessary. Here +is a sample; alter the names: + +Yoyodyne, Inc., hereby disclaims all copyright interest in + +the library `Frob' (a library for tweaking knobs) written + +by James Random Hacker. + +< signature of Ty Coon > , 1 April 1990 + +Ty Coon, President of Vice + +That's all there is to it! diff --git a/LICENSES/LGPL-3.0-only.txt b/LICENSES/LGPL-3.0-only.txt new file mode 100644 index 00000000..bd405afb --- /dev/null +++ b/LICENSES/LGPL-3.0-only.txt @@ -0,0 +1,163 @@ +GNU LESSER GENERAL PUBLIC LICENSE + +Version 3, 29 June 2007 + +Copyright (C) 2007 Free Software Foundation, Inc. + +Everyone is permitted to copy and distribute verbatim copies of this license +document, but changing it is not allowed. + +This version of the GNU Lesser General Public License incorporates the terms +and conditions of version 3 of the GNU General Public License, supplemented +by the additional permissions listed below. + + 0. Additional Definitions. + + + +As used herein, "this License" refers to version 3 of the GNU Lesser General +Public License, and the "GNU GPL" refers to version 3 of the GNU General Public +License. + + + +"The Library" refers to a covered work governed by this License, other than +an Application or a Combined Work as defined below. + + + +An "Application" is any work that makes use of an interface provided by the +Library, but which is not otherwise based on the Library. Defining a subclass +of a class defined by the Library is deemed a mode of using an interface provided +by the Library. + + + +A "Combined Work" is a work produced by combining or linking an Application +with the Library. The particular version of the Library with which the Combined +Work was made is also called the "Linked Version". + + + +The "Minimal Corresponding Source" for a Combined Work means the Corresponding +Source for the Combined Work, excluding any source code for portions of the +Combined Work that, considered in isolation, are based on the Application, +and not on the Linked Version. + + + +The "Corresponding Application Code" for a Combined Work means the object +code and/or source code for the Application, including any data and utility +programs needed for reproducing the Combined Work from the Application, but +excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + +You may convey a covered work under sections 3 and 4 of this License without +being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + +If you modify a copy of the Library, and, in your modifications, a facility +refers to a function or data to be supplied by an Application that uses the +facility (other than as an argument passed when the facility is invoked), +then you may convey a copy of the modified version: + +a) under this License, provided that you make a good faith effort to ensure +that, in the event an Application does not supply the function or data, the +facility still operates, and performs whatever part of its purpose remains +meaningful, or + +b) under the GNU GPL, with none of the additional permissions of this License +applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + +The object code form of an Application may incorporate material from a header +file that is part of the Library. You may convey such object code under terms +of your choice, provided that, if the incorporated material is not limited +to numerical parameters, data structure layouts and accessors, or small macros, +inline functions and templates (ten or fewer lines in length), you do both +of the following: + +a) Give prominent notice with each copy of the object code that the Library +is used in it and that the Library and its use are covered by this License. + +b) Accompany the object code with a copy of the GNU GPL and this license document. + + 4. Combined Works. + +You may convey a Combined Work under terms of your choice that, taken together, +effectively do not restrict modification of the portions of the Library contained +in the Combined Work and reverse engineering for debugging such modifications, +if you also do each of the following: + +a) Give prominent notice with each copy of the Combined Work that the Library +is used in it and that the Library and its use are covered by this License. + +b) Accompany the Combined Work with a copy of the GNU GPL and this license +document. + +c) For a Combined Work that displays copyright notices during execution, include +the copyright notice for the Library among these notices, as well as a reference +directing the user to the copies of the GNU GPL and this license document. + + d) Do one of the following: + +0) Convey the Minimal Corresponding Source under the terms of this License, +and the Corresponding Application Code in a form suitable for, and under terms +that permit, the user to recombine or relink the Application with a modified +version of the Linked Version to produce a modified Combined Work, in the +manner specified by section 6 of the GNU GPL for conveying Corresponding Source. + +1) Use a suitable shared library mechanism for linking with the Library. A +suitable mechanism is one that (a) uses at run time a copy of the Library +already present on the user's computer system, and (b) will operate properly +with a modified version of the Library that is interface-compatible with the +Linked Version. + +e) Provide Installation Information, but only if you would otherwise be required +to provide such information under section 6 of the GNU GPL, and only to the +extent that such information is necessary to install and execute a modified +version of the Combined Work produced by recombining or relinking the Application +with a modified version of the Linked Version. (If you use option 4d0, the +Installation Information must accompany the Minimal Corresponding Source and +Corresponding Application Code. If you use option 4d1, you must provide the +Installation Information in the manner specified by section 6 of the GNU GPL +for conveying Corresponding Source.) + + 5. Combined Libraries. + +You may place library facilities that are a work based on the Library side +by side in a single library together with other library facilities that are +not Applications and are not covered by this License, and convey such a combined +library under terms of your choice, if you do both of the following: + +a) Accompany the combined library with a copy of the same work based on the +Library, uncombined with any other library facilities, conveyed under the +terms of this License. + +b) Give prominent notice with the combined library that part of it is a work +based on the Library, and explaining where to find the accompanying uncombined +form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + +The Free Software Foundation may publish revised and/or new versions of the +GNU Lesser General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to address +new problems or concerns. + +Each version is given a distinguishing version number. If the Library as you +received it specifies that a certain numbered version of the GNU Lesser General +Public License "or any later version" applies to it, you have the option of +following the terms and conditions either of that published version or of +any later version published by the Free Software Foundation. If the Library +as you received it does not specify a version number of the GNU Lesser General +Public License, you may choose any version of the GNU Lesser General Public +License ever published by the Free Software Foundation. + +If the Library as you received it specifies that a proxy can decide whether +future versions of the GNU Lesser General Public License shall apply, that +proxy's public statement of acceptance of any version is permanent authorization +for you to choose that version for the Library. diff --git a/LICENSES/LicenseRef-KDE-Accepted-LGPL.txt b/LICENSES/LicenseRef-KDE-Accepted-LGPL.txt new file mode 100644 index 00000000..232b3c5d --- /dev/null +++ b/LICENSES/LicenseRef-KDE-Accepted-LGPL.txt @@ -0,0 +1,12 @@ +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 3 of the license or (at your option) any later version +that is accepted by the membership of KDE e.V. (or its successor +approved by the membership of KDE e.V.), which shall act as a +proxy as defined in Section 6 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. diff --git a/LICENSES/MIT.txt b/LICENSES/MIT.txt new file mode 100644 index 00000000..204b93da --- /dev/null +++ b/LICENSES/MIT.txt @@ -0,0 +1,19 @@ +MIT License Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice (including the next +paragraph) shall be included in all copies or substantial portions of the +Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS +OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/autotests/fallbackconfigresourcestest.cpp b/autotests/fallbackconfigresourcestest.cpp index 2a9d1be7..8d7768ee 100644 --- a/autotests/fallbackconfigresourcestest.cpp +++ b/autotests/fallbackconfigresourcestest.cpp @@ -1,21 +1,8 @@ /* This file is part of the KDE libraries - Copyright (c) 2015 Christoph Cullmann - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + SPDX-FileCopyrightText: 2015 Christoph Cullmann + + SPDX-License-Identifier: LGPL-2.0-or-later */ #include diff --git a/autotests/helper.h b/autotests/helper.h index 83f1a8bc..20aed445 100644 --- a/autotests/helper.h +++ b/autotests/helper.h @@ -1,21 +1,7 @@ /* - * Copyright 2014 Martin Gräßlin - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) version 3, or any - * later version accepted by the membership of KDE e.V. (or its - * successor approved by the membership of KDE e.V.), which shall - * act as a proxy defined in Section 6 of version 3 of the license. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . + SPDX-FileCopyrightText: 2014 Martin Gräßlin + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef KCONFIG_AUTOTESTS_HELPER_H #define KCONFIG_AUTOTESTS_HELPER_H diff --git a/autotests/kconfig_compiler/kconfigcompiler_test.cpp b/autotests/kconfig_compiler/kconfigcompiler_test.cpp index e4892e4f..dc848f9d 100644 --- a/autotests/kconfig_compiler/kconfigcompiler_test.cpp +++ b/autotests/kconfig_compiler/kconfigcompiler_test.cpp @@ -1,17 +1,10 @@ /* Tests for KConfig Compiler - Copyright (c) 2005 by Duncan Mac-Vicar - Copyright (c) 2009 by Pino Toscano - - ************************************************************************* - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - ************************************************************************* + SPDX-FileCopyrightText: 2005 Duncan Mac-Vicar + SPDX-FileCopyrightText: 2009 Pino Toscano + + SPDX-License-Identifier: LGPL-2.0-or-later */ #include diff --git a/autotests/kconfig_compiler/kconfigcompiler_test.h b/autotests/kconfig_compiler/kconfigcompiler_test.h index d7de5474..e0506db0 100644 --- a/autotests/kconfig_compiler/kconfigcompiler_test.h +++ b/autotests/kconfig_compiler/kconfigcompiler_test.h @@ -1,17 +1,10 @@ /* Tests for KConfig Compiler - Copyright (c) 2005 by Duncan Mac-Vicar - Copyright (c) 2009 by Pino Toscano - - ************************************************************************* - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - ************************************************************************* + SPDX-FileCopyrightText: 2005 Duncan Mac-Vicar + SPDX-FileCopyrightText: 2009 Pino Toscano + + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KCONFIGCOMPILER_TEST_H diff --git a/autotests/kconfig_compiler/kconfigcompiler_test_signals.cpp b/autotests/kconfig_compiler/kconfigcompiler_test_signals.cpp index c9943727..3637b1ff 100644 --- a/autotests/kconfig_compiler/kconfigcompiler_test_signals.cpp +++ b/autotests/kconfig_compiler/kconfigcompiler_test_signals.cpp @@ -1,22 +1,7 @@ /* -Copyright (c) 2014 Alexander Richardson - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + SPDX-FileCopyrightText: 2014 Alexander Richardson + + SPDX-License-Identifier: MIT */ #include "signals_test_singleton.h" diff --git a/autotests/kconfig_compiler/klocalizedstring.h b/autotests/kconfig_compiler/klocalizedstring.h index 1a878d9d..1bd54bef 100644 --- a/autotests/kconfig_compiler/klocalizedstring.h +++ b/autotests/kconfig_compiler/klocalizedstring.h @@ -1,22 +1,7 @@ /* -Copyright (c) 2015 Chusslove Illich - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + SPDX-FileCopyrightText: 2015 Chusslove Illich + + SPDX-License-Identifier: MIT */ /* This file is needed for test_translation_kde. diff --git a/autotests/kconfig_compiler/test10main.cpp b/autotests/kconfig_compiler/test10main.cpp index 6dccda1b..b7d35c4a 100644 --- a/autotests/kconfig_compiler/test10main.cpp +++ b/autotests/kconfig_compiler/test10main.cpp @@ -1,22 +1,7 @@ /* -Copyright (c) 2007 Andreas Pakulat + SPDX-FileCopyrightText: 2007 Andreas Pakulat -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + SPDX-License-Identifier: MIT */ #include "test10.h" diff --git a/autotests/kconfig_compiler/test11_types.h b/autotests/kconfig_compiler/test11_types.h index 5b21aa97..b6aa5d80 100644 --- a/autotests/kconfig_compiler/test11_types.h +++ b/autotests/kconfig_compiler/test11_types.h @@ -1,22 +1,7 @@ /* -Copyright (c) 2009 Pino Toscano + SPDX-FileCopyrightText: 2009 Pino Toscano -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + SPDX-License-Identifier: MIT */ #ifndef TEST11_TYPES_H diff --git a/autotests/kconfig_compiler/test11main.cpp b/autotests/kconfig_compiler/test11main.cpp index 339ecc71..115f7cea 100644 --- a/autotests/kconfig_compiler/test11main.cpp +++ b/autotests/kconfig_compiler/test11main.cpp @@ -1,22 +1,7 @@ /* -Copyright (c) 2009 Pino Toscano + SPDX-FileCopyrightText: 2009 Pino Toscano -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + SPDX-License-Identifier: MIT */ #include "test11.h" #include "test11a.h" diff --git a/autotests/kconfig_compiler/test12main.cpp b/autotests/kconfig_compiler/test12main.cpp index 9c049f1b..ec45539a 100644 --- a/autotests/kconfig_compiler/test12main.cpp +++ b/autotests/kconfig_compiler/test12main.cpp @@ -1,22 +1,7 @@ /* -Copyright (c) 2003 Cornelius Schumacher + SPDX-FileCopyrightText: 2003 Cornelius Schumacher -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + SPDX-License-Identifier: MIT */ #include "test12.h" diff --git a/autotests/kconfig_compiler/test13main.cpp b/autotests/kconfig_compiler/test13main.cpp index e732c17c..d13d1de6 100644 --- a/autotests/kconfig_compiler/test13main.cpp +++ b/autotests/kconfig_compiler/test13main.cpp @@ -1,22 +1,7 @@ /* -Copyright (c) 2003 Cornelius Schumacher + SPDX-FileCopyrightText: 2003 Cornelius Schumacher -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + SPDX-License-Identifier: MIT */ #include "test13.h" diff --git a/autotests/kconfig_compiler/test1main.cpp b/autotests/kconfig_compiler/test1main.cpp index 1f9d32ad..5a7eda0c 100644 --- a/autotests/kconfig_compiler/test1main.cpp +++ b/autotests/kconfig_compiler/test1main.cpp @@ -1,22 +1,7 @@ /* -Copyright (c) 2003 Cornelius Schumacher + SPDX-FileCopyrightText: 2003 Cornelius Schumacher -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + SPDX-License-Identifier: MIT */ #include "test1.h" #include diff --git a/autotests/kconfig_compiler/test2main.cpp b/autotests/kconfig_compiler/test2main.cpp index a70241f7..796115a2 100644 --- a/autotests/kconfig_compiler/test2main.cpp +++ b/autotests/kconfig_compiler/test2main.cpp @@ -1,22 +1,7 @@ /* -Copyright (c) 2003 Cornelius Schumacher + SPDX-FileCopyrightText: 2003 Cornelius Schumacher -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + SPDX-License-Identifier: MIT */ #include "test2.h" #include diff --git a/autotests/kconfig_compiler/test3amain.cpp b/autotests/kconfig_compiler/test3amain.cpp index e08bf7ac..5cfd0bef 100644 --- a/autotests/kconfig_compiler/test3amain.cpp +++ b/autotests/kconfig_compiler/test3amain.cpp @@ -1,22 +1,7 @@ /* -Copyright (c) 2009 Pino Toscano + SPDX-FileCopyrightText: 2009 Pino Toscano -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + SPDX-License-Identifier: MIT */ #include "test3a.h" #include diff --git a/autotests/kconfig_compiler/test3main.cpp b/autotests/kconfig_compiler/test3main.cpp index 82680bf8..52f5dff2 100644 --- a/autotests/kconfig_compiler/test3main.cpp +++ b/autotests/kconfig_compiler/test3main.cpp @@ -1,22 +1,7 @@ /* -Copyright (c) 2003 Cornelius Schumacher + SPDX-FileCopyrightText: 2003 Cornelius Schumacher -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + SPDX-License-Identifier: MIT */ #include "test3.h" #include diff --git a/autotests/kconfig_compiler/test4main.cpp b/autotests/kconfig_compiler/test4main.cpp index 2c63e13e..2d48e440 100644 --- a/autotests/kconfig_compiler/test4main.cpp +++ b/autotests/kconfig_compiler/test4main.cpp @@ -1,22 +1,7 @@ /* -Copyright (c) 2003,2004 Waldo Bastian + SPDX-FileCopyrightText: 2003, 2004 Waldo Bastian -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + SPDX-License-Identifier: MIT */ #include "test4.h" diff --git a/autotests/kconfig_compiler/test5main.cpp b/autotests/kconfig_compiler/test5main.cpp index 95ed498b..d3df1c2d 100644 --- a/autotests/kconfig_compiler/test5main.cpp +++ b/autotests/kconfig_compiler/test5main.cpp @@ -1,22 +1,7 @@ /* -Copyright (c) 2004 Waldo Bastian + SPDX-FileCopyrightText: 2004 Waldo Bastian -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + SPDX-License-Identifier: MIT */ #include "test5.h" diff --git a/autotests/kconfig_compiler/test6main.cpp b/autotests/kconfig_compiler/test6main.cpp index 48932475..ad082d88 100644 --- a/autotests/kconfig_compiler/test6main.cpp +++ b/autotests/kconfig_compiler/test6main.cpp @@ -1,22 +1,7 @@ /* -Copyright (c) 2004 Waldo Bastian + SPDX-FileCopyrightText: 2004 Waldo Bastian -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + SPDX-License-Identifier: MIT */ #include "test6.h" diff --git a/autotests/kconfig_compiler/test7main.cpp b/autotests/kconfig_compiler/test7main.cpp index 16fee863..9fbff1b9 100644 --- a/autotests/kconfig_compiler/test7main.cpp +++ b/autotests/kconfig_compiler/test7main.cpp @@ -1,22 +1,7 @@ /* -Copyright (c) 2004 Waldo Bastian + SPDX-FileCopyrightText: 2004 Waldo Bastian -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + SPDX-License-Identifier: MIT */ #include "test7.h" diff --git a/autotests/kconfig_compiler/test8main.cpp b/autotests/kconfig_compiler/test8main.cpp index 9843df72..959efe2d 100644 --- a/autotests/kconfig_compiler/test8main.cpp +++ b/autotests/kconfig_compiler/test8main.cpp @@ -1,22 +1,7 @@ /* -Copyright (c) 2005 Michael Brade + SPDX-FileCopyrightText: 2005 Michael Brade -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + SPDX-License-Identifier: MIT */ #include "test8a.h" diff --git a/autotests/kconfig_compiler/test9main.cpp b/autotests/kconfig_compiler/test9main.cpp index 56e2c38b..03c43f1b 100644 --- a/autotests/kconfig_compiler/test9main.cpp +++ b/autotests/kconfig_compiler/test9main.cpp @@ -1,23 +1,9 @@ /* -Copyright (c) 2005 Helge Deller + SPDX-FileCopyrightText: 2005 Helge Deller -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + SPDX-License-Identifier: MIT */ + #include "test9.h" #include #include diff --git a/autotests/kconfig_compiler/test_dpointer_main.cpp b/autotests/kconfig_compiler/test_dpointer_main.cpp index 884b1e1b..751c5915 100644 --- a/autotests/kconfig_compiler/test_dpointer_main.cpp +++ b/autotests/kconfig_compiler/test_dpointer_main.cpp @@ -1,22 +1,7 @@ /* -Copyright (c) 2005 Duncan Mac-Vicar P. + SPDX-FileCopyrightText: 2005 Duncan Mac-Vicar P. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + SPDX-License-Identifier: MIT */ #include "test_dpointer.h" diff --git a/autotests/kconfig_compiler/test_emptyentries_main.cpp b/autotests/kconfig_compiler/test_emptyentries_main.cpp index 9396df77..18c750a5 100644 --- a/autotests/kconfig_compiler/test_emptyentries_main.cpp +++ b/autotests/kconfig_compiler/test_emptyentries_main.cpp @@ -1,22 +1,7 @@ /* -Copyright (c) 2007 Andreas Pakulat + SPDX-FileCopyrightText: 2007 Andreas Pakulat -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + SPDX-License-Identifier: MIT */ #include "test_emptyentries.h" diff --git a/autotests/kconfig_compiler/test_fileextensions_main.cxx b/autotests/kconfig_compiler/test_fileextensions_main.cxx index e19fb102..c6f5d754 100644 --- a/autotests/kconfig_compiler/test_fileextensions_main.cxx +++ b/autotests/kconfig_compiler/test_fileextensions_main.cxx @@ -1,22 +1,7 @@ /* -Copyright 2019 Friedrich W. H. Kossebau + SPDX-FileCopyrightText: 2019 Friedrich W. H. Kossebau -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + SPDX-License-Identifier: MIT */ #include "test_fileextensions.hxx" diff --git a/autotests/kconfig_compiler/test_notifiers_main.cpp b/autotests/kconfig_compiler/test_notifiers_main.cpp index a4c6ba2c..dd1bbe8c 100644 --- a/autotests/kconfig_compiler/test_notifiers_main.cpp +++ b/autotests/kconfig_compiler/test_notifiers_main.cpp @@ -1,22 +1,7 @@ /* -Copyright (c) 2019 Kai Uwe Broulik + SPDX-FileCopyrightText: 2019 Kai Uwe Broulik -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + SPDX-License-Identifier: MIT */ #include "test_notifiers.h" diff --git a/autotests/kconfig_compiler/test_qdebugcategorymain.cpp b/autotests/kconfig_compiler/test_qdebugcategorymain.cpp index 247ffe4c..b61e622d 100644 --- a/autotests/kconfig_compiler/test_qdebugcategorymain.cpp +++ b/autotests/kconfig_compiler/test_qdebugcategorymain.cpp @@ -1,22 +1,7 @@ /* -Copyright (c) 2004 Waldo Bastian + SPDX-FileCopyrightText: 2004 Waldo Bastian -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + SPDX-License-Identifier: MIT */ #include "test_qdebugcategory.h" diff --git a/autotests/kconfig_compiler/test_signal_main.cpp b/autotests/kconfig_compiler/test_signal_main.cpp index 09e23ed5..66ec3e1d 100644 --- a/autotests/kconfig_compiler/test_signal_main.cpp +++ b/autotests/kconfig_compiler/test_signal_main.cpp @@ -1,22 +1,7 @@ /* -Copyright (c) 2006 Michael Larouche + SPDX-FileCopyrightText: 2006 Michael Larouche -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + SPDX-License-Identifier: MIT */ #include "test_signal.h" diff --git a/autotests/kconfig_compiler/test_translation_kde_domain_main.cpp b/autotests/kconfig_compiler/test_translation_kde_domain_main.cpp index 64f8d59d..f3f92980 100644 --- a/autotests/kconfig_compiler/test_translation_kde_domain_main.cpp +++ b/autotests/kconfig_compiler/test_translation_kde_domain_main.cpp @@ -1,22 +1,7 @@ /* -Copyright (c) 2015 Chusslove Illich + SPDX-FileCopyrightText: 2015 Chusslove Illich -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + SPDX-License-Identifier: MIT */ #include "test_translation_kde_domain.h" diff --git a/autotests/kconfig_compiler/test_translation_kde_main.cpp b/autotests/kconfig_compiler/test_translation_kde_main.cpp index a6a597c6..cf347dc7 100644 --- a/autotests/kconfig_compiler/test_translation_kde_main.cpp +++ b/autotests/kconfig_compiler/test_translation_kde_main.cpp @@ -1,22 +1,7 @@ /* -Copyright (c) 2015 Chusslove Illich + SPDX-FileCopyrightText: 2015 Chusslove Illich -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + SPDX-License-Identifier: MIT */ #include "test_translation_kde.h" diff --git a/autotests/kconfig_compiler/test_translation_qt_main.cpp b/autotests/kconfig_compiler/test_translation_qt_main.cpp index 5e142fba..3fcf632e 100644 --- a/autotests/kconfig_compiler/test_translation_qt_main.cpp +++ b/autotests/kconfig_compiler/test_translation_qt_main.cpp @@ -1,22 +1,7 @@ /* -Copyright (c) 2015 Chusslove Illich + SPDX-FileCopyrightText: 2015 Chusslove Illich -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + SPDX-License-Identifier: MIT */ #include "test_translation_qt.h" diff --git a/autotests/kconfigguitest.cpp b/autotests/kconfigguitest.cpp index 25fd210c..2a618ce2 100644 --- a/autotests/kconfigguitest.cpp +++ b/autotests/kconfigguitest.cpp @@ -1,20 +1,7 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. +/* This file is part of the KDE libraries + SPDX-FileCopyrightText: 1997 Matthias Kalle Dalheimer + + SPDX-License-Identifier: LGPL-2.0-or-later */ #include diff --git a/autotests/kconfigguitest.h b/autotests/kconfigguitest.h index b842d13b..607575db 100644 --- a/autotests/kconfigguitest.h +++ b/autotests/kconfigguitest.h @@ -1,20 +1,7 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) +/* This file is part of the KDE libraries + SPDX-FileCopyrightText: 1997 Matthias Kalle Dalheimer - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KCONFIGTEST_H #define KCONFIGTEST_H diff --git a/autotests/kconfigloadertest.cpp b/autotests/kconfigloadertest.cpp index eae1e2b2..afc58a1b 100644 --- a/autotests/kconfigloadertest.cpp +++ b/autotests/kconfigloadertest.cpp @@ -1,21 +1,8 @@ -/******************************************************************************** -* Copyright 2010 by Martin Blumenstingl * -* * -* This library is free software; you can redistribute it and/or * -* modify it under the terms of the GNU Library General Public * -* License as published by the Free Software Foundation; either * -* version 2 of the License, or (at your option) any later version. * -* * -* This library is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * -* Library General Public License for more details. * -* * -* You should have received a copy of the GNU Library General Public License * -* along with this library; see the file COPYING.LIB. If not, write to * -* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * -* Boston, MA 02110-1301, USA. * -*********************************************************************************/ +/* + SPDX-FileCopyrightText: 2010 Martin Blumenstingl + + SPDX-License-Identifier: LGPL-2.0-or-later +*/ #include "kconfigloadertest.h" #include diff --git a/autotests/kconfigloadertest.h b/autotests/kconfigloadertest.h index 2eed4fc0..697aa06b 100644 --- a/autotests/kconfigloadertest.h +++ b/autotests/kconfigloadertest.h @@ -1,21 +1,8 @@ -/******************************************************************************** -* Copyright 2010 by Martin Blumenstingl * -* * -* This library is free software; you can redistribute it and/or * -* modify it under the terms of the GNU Library General Public * -* License as published by the Free Software Foundation; either * -* version 2 of the License, or (at your option) any later version. * -* * -* This library is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * -* Library General Public License for more details. * -* * -* You should have received a copy of the GNU Library General Public License * -* along with this library; see the file COPYING.LIB. If not, write to * -* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * -* Boston, MA 02110-1301, USA. * -*********************************************************************************/ +/* + SPDX-FileCopyrightText: 2010 Martin Blumenstingl + + SPDX-License-Identifier: LGPL-2.0-or-later +*/ #ifndef KCONFIGLOADERTEST_H #define KCONFIGLOADERTEST_H diff --git a/autotests/kconfignokdehometest.cpp b/autotests/kconfignokdehometest.cpp index 9080c174..8c29fb37 100644 --- a/autotests/kconfignokdehometest.cpp +++ b/autotests/kconfignokdehometest.cpp @@ -1,20 +1,7 @@ -/* This file is part of the KDE libraries - Copyright (C) 2011 David Faure +/* This file is part of the KDE libraries + SPDX-FileCopyrightText: 2011 David Faure - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + SPDX-License-Identifier: LGPL-2.0-or-later */ #include diff --git a/autotests/kconfigskeletontest.cpp b/autotests/kconfigskeletontest.cpp index 1971da78..896d4ee1 100644 --- a/autotests/kconfigskeletontest.cpp +++ b/autotests/kconfigskeletontest.cpp @@ -1,20 +1,7 @@ -/* This file is part of the KDE libraries - Copyright (C) 2006 Olivier Goffart - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. +/* This file is part of the KDE libraries + SPDX-FileCopyrightText: 2006 Olivier Goffart + + SPDX-License-Identifier: LGPL-2.0-or-later */ #include "kconfigskeletontest.h" diff --git a/autotests/kconfigskeletontest.h b/autotests/kconfigskeletontest.h index a5c63c9c..6bac81d2 100644 --- a/autotests/kconfigskeletontest.h +++ b/autotests/kconfigskeletontest.h @@ -1,20 +1,7 @@ -/* This file is part of the KDE libraries - Copyright (C) 2006 Olivier Goffart +/* This file is part of the KDE libraries + SPDX-FileCopyrightText: 2006 Olivier Goffart - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KCONFIGSKELETONTEST_H #define KCONFIGSKELETONTEST_H diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index 069513d4..736274c6 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -1,20 +1,7 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. +/* This file is part of the KDE libraries + SPDX-FileCopyrightText: 1997 Matthias Kalle Dalheimer + + SPDX-License-Identifier: LGPL-2.0-or-later */ // Qt5 TODO: re-enable. No point in doing it before, it breaks on QString::fromUtf8(QByteArray), which exists in qt5. diff --git a/autotests/kconfigtest.h b/autotests/kconfigtest.h index 9963d476..e97e4a5d 100644 --- a/autotests/kconfigtest.h +++ b/autotests/kconfigtest.h @@ -1,20 +1,7 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) +/* This file is part of the KDE libraries + SPDX-FileCopyrightText: 1997 Matthias Kalle Dalheimer - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KCONFIGTEST_H diff --git a/autotests/kdesktopfiletest.cpp b/autotests/kdesktopfiletest.cpp index ed13be8e..983ac68d 100644 --- a/autotests/kdesktopfiletest.cpp +++ b/autotests/kdesktopfiletest.cpp @@ -1,20 +1,8 @@ /* - * Copyright (C) 2006 David Faure - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License version 2 as published by the Free Software Foundation; - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ + SPDX-FileCopyrightText: 2006 David Faure + + SPDX-License-Identifier: LGPL-2.0-only +*/ #include "kdesktopfiletest.h" #include "helper.h" #include diff --git a/autotests/kdesktopfiletest.h b/autotests/kdesktopfiletest.h index 621c7934..1ab1498c 100644 --- a/autotests/kdesktopfiletest.h +++ b/autotests/kdesktopfiletest.h @@ -1,20 +1,8 @@ /* - * Copyright (C) 2006 David Faure - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License version 2 as published by the Free Software Foundation; - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ + SPDX-FileCopyrightText: 2006 David Faure + + SPDX-License-Identifier: LGPL-2.0-only +*/ #ifndef KDESKTOPFILETEST_H #define KDESKTOPFILETEST_H diff --git a/autotests/kentrymaptest.cpp b/autotests/kentrymaptest.cpp index 090e497a..507a88f6 100644 --- a/autotests/kentrymaptest.cpp +++ b/autotests/kentrymaptest.cpp @@ -1,20 +1,7 @@ -/* This file is part of the KDE libraries - Copyright (C) 2007 Thomas Braxton (kde.braxton@gmail.com) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. +/* This file is part of the KDE libraries + SPDX-FileCopyrightText: 2007 Thomas Braxton + + SPDX-License-Identifier: LGPL-2.0-or-later */ #include "kentrymaptest.h" diff --git a/autotests/kentrymaptest.h b/autotests/kentrymaptest.h index b0e7d7d3..b1bcea74 100644 --- a/autotests/kentrymaptest.h +++ b/autotests/kentrymaptest.h @@ -1,20 +1,7 @@ -/* This file is part of the KDE libraries - Copyright (C) 2007 Thomas Braxton (kde.braxton@gmail.com) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. +/* This file is part of the KDE libraries + SPDX-FileCopyrightText: 2007 Thomas Braxton + + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KENTRYMAPTEST_H diff --git a/autotests/ksharedconfig_in_global_object.cpp b/autotests/ksharedconfig_in_global_object.cpp index ff7f581e..aab982c2 100644 --- a/autotests/ksharedconfig_in_global_object.cpp +++ b/autotests/ksharedconfig_in_global_object.cpp @@ -1,19 +1,7 @@ /* This file is part of the KDE project - Copyright (C) 2007 Matthias Kretz + SPDX-FileCopyrightText: 2007 Matthias Kretz - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + SPDX-License-Identifier: LGPL-2.0-only */ diff --git a/autotests/ksharedconfigtest.cpp b/autotests/ksharedconfigtest.cpp index 281f7755..97a9d69c 100644 --- a/autotests/ksharedconfigtest.cpp +++ b/autotests/ksharedconfigtest.cpp @@ -1,21 +1,8 @@ /* This file is part of the KDE libraries - Copyright (c) 2012 David Faure + SPDX-FileCopyrightText: 2012 David Faure - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + SPDX-License-Identifier: LGPL-2.0-or-later */ #include diff --git a/autotests/kstandardshortcuttest.cpp b/autotests/kstandardshortcuttest.cpp index da1e2d2b..53a724f9 100644 --- a/autotests/kstandardshortcuttest.cpp +++ b/autotests/kstandardshortcuttest.cpp @@ -1,20 +1,7 @@ -/* This file is part of the KDE libraries - Copyright (c) 2005 David Faure - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. +/* This file is part of the KDE libraries + SPDX-FileCopyrightText: 2005 David Faure + + SPDX-License-Identifier: LGPL-2.0-or-later */ #include diff --git a/autotests/kstandardshortcuttest.h b/autotests/kstandardshortcuttest.h index 77dd3443..3d186226 100644 --- a/autotests/kstandardshortcuttest.h +++ b/autotests/kstandardshortcuttest.h @@ -1,20 +1,7 @@ -/* This file is part of the KDE libraries - Copyright (c) 2005 David Faure +/* This file is part of the KDE libraries + SPDX-FileCopyrightText: 2005 David Faure - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KSTDACCELTEST_H diff --git a/autotests/test_kconf_update.cpp b/autotests/test_kconf_update.cpp index 6a0f60b1..13cde111 100644 --- a/autotests/test_kconf_update.cpp +++ b/autotests/test_kconf_update.cpp @@ -1,22 +1,8 @@ -/* This file is part of the KDE libraries - Copyright 2010 Canonical Ltd - Author: Aurélien Gâteau - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License (LGPL) as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later - version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. +/* This file is part of the KDE libraries + SPDX-FileCopyrightText: 2010 Canonical Ltd + SPDX-FileContributor: Aurélien Gâteau + + SPDX-License-Identifier: LGPL-2.0-or-later */ #include "test_kconf_update.h" diff --git a/autotests/test_kconf_update.h b/autotests/test_kconf_update.h index ca8fe3ba..5d419fe7 100644 --- a/autotests/test_kconf_update.h +++ b/autotests/test_kconf_update.h @@ -1,22 +1,8 @@ -/* This file is part of the KDE libraries - Copyright 2010 Canonical Ltd - Author: Aurélien Gâteau +/* This file is part of the KDE libraries + SPDX-FileCopyrightText: 2010 Canonical Ltd + SPDX-FileContributor: Aurélien Gâteau - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License (LGPL) as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later - version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef TEST_KCONF_UPDATE_H #define TEST_KCONF_UPDATE_H diff --git a/autotests/test_kconfigutils.cpp b/autotests/test_kconfigutils.cpp index a57f0592..1e6c49f7 100644 --- a/autotests/test_kconfigutils.cpp +++ b/autotests/test_kconfigutils.cpp @@ -1,22 +1,8 @@ -/* This file is part of the KDE libraries - Copyright 2010 Canonical Ltd - Author: Aurélien Gâteau - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License (LGPL) as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later - version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. +/* This file is part of the KDE libraries + SPDX-FileCopyrightText: 2010 Canonical Ltd + SPDX-FileContributor: Aurélien Gâteau + + SPDX-License-Identifier: LGPL-2.0-or-later */ #include "test_kconfigutils.h" diff --git a/autotests/test_kconfigutils.h b/autotests/test_kconfigutils.h index 2b8c5762..67757fb9 100644 --- a/autotests/test_kconfigutils.h +++ b/autotests/test_kconfigutils.h @@ -1,22 +1,8 @@ -/* This file is part of the KDE libraries - Copyright 2010 Canonical Ltd - Author: Aurélien Gâteau +/* This file is part of the KDE libraries + SPDX-FileCopyrightText: 2010 Canonical Ltd + SPDX-FileContributor: Aurélien Gâteau - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License (LGPL) as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later - version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef TEST_KCONFIGUTILS_H #define TEST_KCONFIGUTILS_H diff --git a/cmake/rules_PyKF5.py b/cmake/rules_PyKF5.py index fea0982f..e510340e 100644 --- a/cmake/rules_PyKF5.py +++ b/cmake/rules_PyKF5.py @@ -1,29 +1,8 @@ # -# Copyright 2016 by Shaheed Haque (srhaque@theiet.org) -# Copyright 2016 Stephen Kelly +# SPDX-FileCopyrightText: 2016 Shaheed Haque +# SPDX-FileCopyrightText: 2016 Stephen Kelly # -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. The name of the author may not be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. +# SPDX-License-Identifier: BSD-3-Clause import os, sys diff --git a/src/core/bufferfragment_p.h b/src/core/bufferfragment_p.h index b4aff92a..ba100ef7 100644 --- a/src/core/bufferfragment_p.h +++ b/src/core/bufferfragment_p.h @@ -1,21 +1,8 @@ /* - This file is part of the KDE libraries - Copyright (c) 2008 Jakub Stachowski - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + This file is part of the KDE libraries + SPDX-FileCopyrightText: 2008 Jakub Stachowski + + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef BUFFERFRAGMENT_H diff --git a/src/core/conversioncheck.h b/src/core/conversioncheck.h index 4ba0c111..7f0e78a4 100644 --- a/src/core/conversioncheck.h +++ b/src/core/conversioncheck.h @@ -1,21 +1,8 @@ /* - This file is part of the KDE libraries - Copyright (c) 2006 Thomas Braxton + This file is part of the KDE libraries + SPDX-FileCopyrightText: 2006 Thomas Braxton - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef CONVERSION_CHECK_H diff --git a/src/core/kauthorized.cpp b/src/core/kauthorized.cpp index 167136c8..fd79930e 100644 --- a/src/core/kauthorized.cpp +++ b/src/core/kauthorized.cpp @@ -1,21 +1,8 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) - Copyright (C) 1998, 1999, 2000 Waldo Bastian - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. +/* This file is part of the KDE libraries + SPDX-FileCopyrightText: 1997 Matthias Kalle Dalheimer + SPDX-FileCopyrightText: 1998, 1999, 2000 Waldo Bastian + + SPDX-License-Identifier: LGPL-2.0-or-later */ #include "kauthorized.h" diff --git a/src/core/kauthorized.h b/src/core/kauthorized.h index 5f67b6ec..88d2e398 100644 --- a/src/core/kauthorized.h +++ b/src/core/kauthorized.h @@ -1,21 +1,8 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) - Copyright (c) 1998, 1999 Waldo Bastian +/* This file is part of the KDE libraries + SPDX-FileCopyrightText: 1997 Matthias Kalle Dalheimer + SPDX-FileCopyrightText: 1998, 1999 Waldo Bastian - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KAUTHORIZED_H diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index 0b68f3fe..b8fbba53 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -1,23 +1,10 @@ /* - This file is part of the KDE libraries - Copyright (c) 2006, 2007 Thomas Braxton - Copyright (c) 1999 Preston Brown - Copyright (c) 1997-1999 Matthias Kalle Dalheimer - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + This file is part of the KDE libraries + SPDX-FileCopyrightText: 2006, 2007 Thomas Braxton + SPDX-FileCopyrightText: 1999 Preston Brown + SPDX-FileCopyrightText: 1997-1999 Matthias Kalle Dalheimer + + SPDX-License-Identifier: LGPL-2.0-or-later */ #include "kconfig.h" diff --git a/src/core/kconfig.h b/src/core/kconfig.h index 30a2881a..2693f91e 100644 --- a/src/core/kconfig.h +++ b/src/core/kconfig.h @@ -1,24 +1,11 @@ /* - This file is part of the KDE libraries - Copyright (c) 2006, 2007 Thomas Braxton - Copyright (c) 2001 Waldo Bastian - Copyright (c) 1999 Preston Brown - Copyright (c) 1997 Matthias Kalle Dalheimer - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + This file is part of the KDE libraries + SPDX-FileCopyrightText: 2006, 2007 Thomas Braxton + SPDX-FileCopyrightText: 2001 Waldo Bastian + SPDX-FileCopyrightText: 1999 Preston Brown + SPDX-FileCopyrightText: 1997 Matthias Kalle Dalheimer + + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KCONFIG_H diff --git a/src/core/kconfig_p.h b/src/core/kconfig_p.h index ac4cd631..917872f3 100644 --- a/src/core/kconfig_p.h +++ b/src/core/kconfig_p.h @@ -1,24 +1,11 @@ /* - This file is part of the KDE libraries - Copyright (c) 2006, 2007 Thomas Braxton - Copyright (c) 2001 Waldo Bastian - Copyright (c) 1999 Preston Brown - Copyright (c) 1997 Matthias Kalle Dalheimer - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + This file is part of the KDE libraries + SPDX-FileCopyrightText: 2006, 2007 Thomas Braxton + SPDX-FileCopyrightText: 2001 Waldo Bastian + SPDX-FileCopyrightText: 1999 Preston Brown + SPDX-FileCopyrightText: 1997 Matthias Kalle Dalheimer + + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KCONFIG_P_H diff --git a/src/core/kconfigbackend.cpp b/src/core/kconfigbackend.cpp index 0adde97d..0f95a5f6 100644 --- a/src/core/kconfigbackend.cpp +++ b/src/core/kconfigbackend.cpp @@ -1,23 +1,10 @@ /* - This file is part of the KDE libraries - Copyright (c) 2006 Thomas Braxton - Copyright (c) 1999 Preston Brown - Copyright (c) 1997-1999 Matthias Kalle Dalheimer - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + This file is part of the KDE libraries + SPDX-FileCopyrightText: 2006 Thomas Braxton + SPDX-FileCopyrightText: 1999 Preston Brown + SPDX-FileCopyrightText: 1997-1999 Matthias Kalle Dalheimer + + SPDX-License-Identifier: LGPL-2.0-or-later */ #include "kconfigbackend_p.h" diff --git a/src/core/kconfigbackend_p.h b/src/core/kconfigbackend_p.h index 31e728bf..5f8b61b5 100644 --- a/src/core/kconfigbackend_p.h +++ b/src/core/kconfigbackend_p.h @@ -1,23 +1,10 @@ /* - This file is part of the KDE libraries - Copyright (c) 2006, 2007 Thomas Braxton - Copyright (c) 1999 Preston Brown - Portions copyright (c) 1997 Matthias Kalle Dalheimer - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + This file is part of the KDE libraries + SPDX-FileCopyrightText: 2006, 2007 Thomas Braxton + SPDX-FileCopyrightText: 1999 Preston Brown + SPDX-FileCopyrightText: 1997 Matthias Kalle Dalheimer + + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KCONFIGBACKEND_H diff --git a/src/core/kconfigbase.cpp b/src/core/kconfigbase.cpp index d22cc20a..6bae0e25 100644 --- a/src/core/kconfigbase.cpp +++ b/src/core/kconfigbase.cpp @@ -1,23 +1,10 @@ /* - This file is part of the KDE libraries - Copyright (c) 2006, 2007 Thomas Braxton - Copyright (c) 1999 Preston Brown - Copyright (c) 1997-1999 Matthias Kalle Dalheimer - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + This file is part of the KDE libraries + SPDX-FileCopyrightText: 2006, 2007 Thomas Braxton + SPDX-FileCopyrightText: 1999 Preston Brown + SPDX-FileCopyrightText: 1997-1999 Matthias Kalle Dalheimer + + SPDX-License-Identifier: LGPL-2.0-or-later */ #include "kconfigbase.h" diff --git a/src/core/kconfigbase.h b/src/core/kconfigbase.h index c4ad7a57..927eb78a 100644 --- a/src/core/kconfigbase.h +++ b/src/core/kconfigbase.h @@ -1,24 +1,11 @@ /* - This file is part of the KDE libraries - Copyright (c) 2006, 2007 Thomas Braxton - Copyright (c) 2001 Waldo Bastian - Copyright (c) 1999 Preston Brown - Copyright (c) 1997 Matthias Kalle Dalheimer - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + This file is part of the KDE libraries + SPDX-FileCopyrightText: 2006, 2007 Thomas Braxton + SPDX-FileCopyrightText: 2001 Waldo Bastian + SPDX-FileCopyrightText: 1999 Preston Brown + SPDX-FileCopyrightText: 1997 Matthias Kalle Dalheimer + + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KCONFIGBASE_H diff --git a/src/core/kconfigbase_p.h b/src/core/kconfigbase_p.h index fe1c193e..97ee1df9 100644 --- a/src/core/kconfigbase_p.h +++ b/src/core/kconfigbase_p.h @@ -1,22 +1,9 @@ /* - This file is part of the KDE libraries - Copyright (c) 1999 Preston Brown - Copyright (C) 1997 Matthias Kalle Dalheimer + This file is part of the KDE libraries + SPDX-FileCopyrightText: 1999 Preston Brown + SPDX-FileCopyrightText: 1997 Matthias Kalle Dalheimer - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KCONFIGBASE_P_H diff --git a/src/core/kconfigdata.cpp b/src/core/kconfigdata.cpp index e1f4ee73..bfa662a0 100644 --- a/src/core/kconfigdata.cpp +++ b/src/core/kconfigdata.cpp @@ -1,23 +1,10 @@ /* - This file is part of the KDE libraries - Copyright (c) 2006, 2007 Thomas Braxton - Copyright (c) 1999-2000 Preston Brown - Copyright (C) 1996-2000 Matthias Kalle Dalheimer - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + This file is part of the KDE libraries + SPDX-FileCopyrightText: 2006, 2007 Thomas Braxton + SPDX-FileCopyrightText: 1999-2000 Preston Brown + SPDX-FileCopyrightText: 1996-2000 Matthias Kalle Dalheimer + + SPDX-License-Identifier: LGPL-2.0-or-later */ #include diff --git a/src/core/kconfigdata.h b/src/core/kconfigdata.h index 2d095034..d92076d9 100644 --- a/src/core/kconfigdata.h +++ b/src/core/kconfigdata.h @@ -1,23 +1,10 @@ /* - This file is part of the KDE libraries - Copyright (c) 2006, 2007 Thomas Braxton - Copyright (c) 1999-2000 Preston Brown - Copyright (C) 1996-2000 Matthias Kalle Dalheimer - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + This file is part of the KDE libraries + SPDX-FileCopyrightText: 2006, 2007 Thomas Braxton + SPDX-FileCopyrightText: 1999-2000 Preston Brown + SPDX-FileCopyrightText: 1996-2000 Matthias Kalle Dalheimer + + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KCONFIGDATA_H diff --git a/src/core/kconfiggroup.cpp b/src/core/kconfiggroup.cpp index c9c93d00..cc4f8d0c 100644 --- a/src/core/kconfiggroup.cpp +++ b/src/core/kconfiggroup.cpp @@ -1,23 +1,10 @@ /* - This file is part of the KDE libraries - Copyright (c) 2006, 2007 Thomas Braxton - Copyright (c) 1999 Preston Brown - Copyright (c) 1997 Matthias Kalle Dalheimer - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + This file is part of the KDE libraries + SPDX-FileCopyrightText: 2006, 2007 Thomas Braxton + SPDX-FileCopyrightText: 1999 Preston Brown + SPDX-FileCopyrightText: 1997 Matthias Kalle Dalheimer + + SPDX-License-Identifier: LGPL-2.0-or-later */ #include "kconfiggroup.h" diff --git a/src/core/kconfiggroup.h b/src/core/kconfiggroup.h index 54946b86..bd554c75 100644 --- a/src/core/kconfiggroup.h +++ b/src/core/kconfiggroup.h @@ -1,24 +1,11 @@ /* - This file is part of the KDE libraries - Copyright (c) 2006, 2007 Thomas Braxton - Copyright (c) 1999 Preston Brown - Copyright (c) 1997 Matthias Kalle Dalheimer - Copyright (c) 2001 Waldo Bastian - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + This file is part of the KDE libraries + SPDX-FileCopyrightText: 2006, 2007 Thomas Braxton + SPDX-FileCopyrightText: 1999 Preston Brown + SPDX-FileCopyrightText: 1997 Matthias Kalle Dalheimer + SPDX-FileCopyrightText: 2001 Waldo Bastian + + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KCONFIGGROUP_H diff --git a/src/core/kconfiggroup_p.h b/src/core/kconfiggroup_p.h index 8e33ce05..923387e7 100644 --- a/src/core/kconfiggroup_p.h +++ b/src/core/kconfiggroup_p.h @@ -1,21 +1,8 @@ /* - This file is part of the KDE libraries - Copyright (c) 2007 Thiago Macieira - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + This file is part of the KDE libraries + SPDX-FileCopyrightText: 2007 Thiago Macieira + + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KCONFIGGROUP_P_H diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp index 4b3123eb..2cea7338 100644 --- a/src/core/kconfigini.cpp +++ b/src/core/kconfigini.cpp @@ -1,23 +1,10 @@ /* - This file is part of the KDE libraries - Copyright (c) 2006, 2007 Thomas Braxton - Copyright (c) 1999 Preston Brown - Copyright (C) 1997-1999 Matthias Kalle Dalheimer (kalle@kde.org) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + This file is part of the KDE libraries + SPDX-FileCopyrightText: 2006, 2007 Thomas Braxton + SPDX-FileCopyrightText: 1999 Preston Brown + SPDX-FileCopyrightText: 1997-1999 Matthias Kalle Dalheimer + + SPDX-License-Identifier: LGPL-2.0-or-later */ #include "kconfigini_p.h" diff --git a/src/core/kconfigini_p.h b/src/core/kconfigini_p.h index 2c17bf60..923ddb32 100644 --- a/src/core/kconfigini_p.h +++ b/src/core/kconfigini_p.h @@ -1,23 +1,10 @@ /* This file is part of the KDE libraries - Copyright (c) 2006, 2007 Thomas Braxton - Copyright (c) 1999 Preston Brown - Portions copyright (c) 1997 Matthias Kalle Dalheimer + SPDX-FileCopyrightText: 2006, 2007 Thomas Braxton + SPDX-FileCopyrightText: 1999 Preston Brown + SPDX-FileCopyrightText: 1997 Matthias Kalle Dalheimer - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KCONFIGINI_P_H diff --git a/src/core/kconfigwatcher.cpp b/src/core/kconfigwatcher.cpp index c4a877c5..495195c0 100644 --- a/src/core/kconfigwatcher.cpp +++ b/src/core/kconfigwatcher.cpp @@ -1,21 +1,8 @@ /* - * Copyright 2018 David Edmundson - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ + SPDX-FileCopyrightText: 2018 David Edmundson + + SPDX-License-Identifier: LGPL-2.0-or-later +*/ #include "kconfigwatcher.h" diff --git a/src/core/kconfigwatcher.h b/src/core/kconfigwatcher.h index 5b057263..75612831 100644 --- a/src/core/kconfigwatcher.h +++ b/src/core/kconfigwatcher.h @@ -1,21 +1,8 @@ /* - * Copyright 2018 David Edmundson - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ + SPDX-FileCopyrightText: 2018 David Edmundson + + SPDX-License-Identifier: LGPL-2.0-or-later +*/ #ifndef KCONFIGWATCHER_H #define KCONFIGWATCHER_H diff --git a/src/core/kcoreconfigskeleton.cpp b/src/core/kcoreconfigskeleton.cpp index 575ee721..d02705d9 100644 --- a/src/core/kcoreconfigskeleton.cpp +++ b/src/core/kcoreconfigskeleton.cpp @@ -1,22 +1,9 @@ /* This file is part of KOrganizer. - Copyright (c) 2000,2001 Cornelius Schumacher - Copyright (c) 2003 Waldo Bastian - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + SPDX-FileCopyrightText: 2000, 2001 Cornelius Schumacher + SPDX-FileCopyrightText: 2003 Waldo Bastian + + SPDX-License-Identifier: LGPL-2.0-or-later */ #include "kcoreconfigskeleton.h" diff --git a/src/core/kcoreconfigskeleton.h b/src/core/kcoreconfigskeleton.h index 9d84583e..9cf131b2 100644 --- a/src/core/kcoreconfigskeleton.h +++ b/src/core/kcoreconfigskeleton.h @@ -1,24 +1,11 @@ /* - * This file is part of KDE. - * - * Copyright (c) 2001,2002,2003 Cornelius Schumacher - * Copyright (c) 2003 Waldo Bastian - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ + This file is part of KDE. + + SPDX-FileCopyrightText: 2001, 2002, 2003 Cornelius Schumacher + SPDX-FileCopyrightText: 2003 Waldo Bastian + + SPDX-License-Identifier: LGPL-2.0-or-later +*/ #ifndef KCORECONFIGSKELETON_H #define KCORECONFIGSKELETON_H diff --git a/src/core/kcoreconfigskeleton_p.h b/src/core/kcoreconfigskeleton_p.h index fcc9bc13..389bc4f7 100644 --- a/src/core/kcoreconfigskeleton_p.h +++ b/src/core/kcoreconfigskeleton_p.h @@ -1,22 +1,9 @@ /* This file is part of KOrganizer. - Copyright (c) 2000,2001 Cornelius Schumacher - Copyright (c) 2003 Waldo Bastian + SPDX-FileCopyrightText: 2000, 2001 Cornelius Schumacher + SPDX-FileCopyrightText: 2003 Waldo Bastian - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KCORECONFIGSKELETON_P_H diff --git a/src/core/kdesktopfile.cpp b/src/core/kdesktopfile.cpp index 2292a6c7..73524a59 100644 --- a/src/core/kdesktopfile.cpp +++ b/src/core/kdesktopfile.cpp @@ -1,22 +1,9 @@ /* - This file is part of the KDE libraries - Copyright (c) 1999 Pietro Iglio - Copyright (c) 1999 Preston Brown - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + This file is part of the KDE libraries + SPDX-FileCopyrightText: 1999 Pietro Iglio + SPDX-FileCopyrightText: 1999 Preston Brown + + SPDX-License-Identifier: LGPL-2.0-or-later */ #include "kdesktopfile.h" diff --git a/src/core/kdesktopfile.h b/src/core/kdesktopfile.h index 44220035..4d817181 100644 --- a/src/core/kdesktopfile.h +++ b/src/core/kdesktopfile.h @@ -1,20 +1,8 @@ -/* This file is part of the KDE libraries - Copyright (c) 1999 Pietro Iglio - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. +/* + This file is part of the KDE libraries + SPDX-FileCopyrightText: 1999 Pietro Iglio + + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KDESKTOPFILE_H #define KDESKTOPFILE_H diff --git a/src/core/kemailsettings.cpp b/src/core/kemailsettings.cpp index c6aa5d20..ed4255b5 100644 --- a/src/core/kemailsettings.cpp +++ b/src/core/kemailsettings.cpp @@ -1,28 +1,8 @@ /* - * Copyright (c) 2000 Alex Zepeda - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. - */ + SPDX-FileCopyrightText: 2000 Alex Zepeda + + SPDX-License-Identifier: BSD-2-Clause +*/ #include "kemailsettings.h" diff --git a/src/core/kemailsettings.h b/src/core/kemailsettings.h index 801e63b7..5a14bb02 100644 --- a/src/core/kemailsettings.h +++ b/src/core/kemailsettings.h @@ -1,29 +1,8 @@ -/*- - * Copyright (c) 2000 Alex Zepeda - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. - * - */ +/* + SPDX-FileCopyrightText: 2000 Alex Zepeda + + SPDX-License-Identifier: BSD-2-Clause +*/ #ifndef _KEMAILSETTINGS_H #define _KEMAILSETTINGS_H diff --git a/src/core/ksharedconfig.cpp b/src/core/ksharedconfig.cpp index 0530abac..e448e508 100644 --- a/src/core/ksharedconfig.cpp +++ b/src/core/ksharedconfig.cpp @@ -1,22 +1,9 @@ /* - This file is part of the KDE libraries - Copyright (c) 1999 Preston Brown - Copyright (C) 1997-1999 Matthias Kalle Dalheimer (kalle@kde.org) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + This file is part of the KDE libraries + SPDX-FileCopyrightText: 1999 Preston Brown + SPDX-FileCopyrightText: 1997-1999 Matthias Kalle Dalheimer + + SPDX-License-Identifier: LGPL-2.0-or-later */ #include "ksharedconfig.h" diff --git a/src/core/ksharedconfig.h b/src/core/ksharedconfig.h index 0a35f9f4..be01401c 100644 --- a/src/core/ksharedconfig.h +++ b/src/core/ksharedconfig.h @@ -1,22 +1,9 @@ /* - This file is part of the KDE libraries - Copyright (c) 1999 Preston Brown - Copyright (C) 1997-1999 Matthias Kalle Dalheimer (kalle@kde.org) + This file is part of the KDE libraries + SPDX-FileCopyrightText: 1999 Preston Brown + SPDX-FileCopyrightText: 1997-1999 Matthias Kalle Dalheimer - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KSHAREDCONFIG_H diff --git a/src/gui/kconfiggroupgui.cpp b/src/gui/kconfiggroupgui.cpp index ab9d4e20..358e84e4 100644 --- a/src/gui/kconfiggroupgui.cpp +++ b/src/gui/kconfiggroupgui.cpp @@ -1,21 +1,8 @@ /* - This file is part of the KDE libraries - Copyright (c) 2007 Thiago Macieira - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + This file is part of the KDE libraries + SPDX-FileCopyrightText: 2007 Thiago Macieira + + SPDX-License-Identifier: LGPL-2.0-or-later */ #include diff --git a/src/gui/kconfiggui.cpp b/src/gui/kconfiggui.cpp index 7eb4711e..1daeec45 100644 --- a/src/gui/kconfiggui.cpp +++ b/src/gui/kconfiggui.cpp @@ -1,22 +1,8 @@ /* - This file is part of the KDE libraries - Copyright (c) 1999 Matthias Ettrich + This file is part of the KDE libraries + SPDX-FileCopyrightText: 1999 Matthias Ettrich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "kconfiggui.h" diff --git a/src/gui/kconfiggui.h b/src/gui/kconfiggui.h index bc4248f3..c32e108f 100644 --- a/src/gui/kconfiggui.h +++ b/src/gui/kconfiggui.h @@ -1,22 +1,8 @@ /* - This file is part of the KDE libraries - Copyright (c) 1999 Matthias Ettrich + This file is part of the KDE libraries + SPDX-FileCopyrightText: 1999 Matthias Ettrich - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef KCONFIGGUI_H diff --git a/src/gui/kconfigloader.cpp b/src/gui/kconfigloader.cpp index 1e33f4ea..198ef63f 100644 --- a/src/gui/kconfigloader.cpp +++ b/src/gui/kconfigloader.cpp @@ -1,21 +1,8 @@ /* - * Copyright 2007 Aaron Seigo - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ + SPDX-FileCopyrightText: 2007 Aaron Seigo + + SPDX-License-Identifier: LGPL-2.0-or-later +*/ #include "kconfigloader.h" #include "kconfigloader_p.h" diff --git a/src/gui/kconfigloader.h b/src/gui/kconfigloader.h index e46e4c6e..2e97ccd8 100644 --- a/src/gui/kconfigloader.h +++ b/src/gui/kconfigloader.h @@ -1,21 +1,8 @@ /* - * Copyright 2007 Aaron Seigo - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ + SPDX-FileCopyrightText: 2007 Aaron Seigo + + SPDX-License-Identifier: LGPL-2.0-or-later +*/ #ifndef KCONFIGLOADER_H #define KCONFIGLOADER_H diff --git a/src/gui/kconfigloader_p.h b/src/gui/kconfigloader_p.h index b030fc30..b5b4e49b 100644 --- a/src/gui/kconfigloader_p.h +++ b/src/gui/kconfigloader_p.h @@ -1,21 +1,8 @@ /* - * Copyright 2007-2008 Aaron Seigo - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ + SPDX-FileCopyrightText: 2007-2008 Aaron Seigo + + SPDX-License-Identifier: LGPL-2.0-or-later +*/ #ifndef KCONFIGLOADER_P_H #define KCONFIGLOADER_P_H diff --git a/src/gui/kconfigloaderhandler_p.h b/src/gui/kconfigloaderhandler_p.h index 18e9622a..cf9b7081 100644 --- a/src/gui/kconfigloaderhandler_p.h +++ b/src/gui/kconfigloaderhandler_p.h @@ -1,22 +1,9 @@ /* - * Copyright 2007-2008 Aaron Seigo - * Copyright 2013 Marco Martin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ + SPDX-FileCopyrightText: 2007-2008 Aaron Seigo + SPDX-FileCopyrightText: 2013 Marco Martin + + SPDX-License-Identifier: LGPL-2.0-or-later +*/ #ifndef KCONFIGLOADERHANDLER_P_H #define KCONFIGLOADERHANDLER_P_H diff --git a/src/gui/kconfigskeleton.cpp b/src/gui/kconfigskeleton.cpp index 25ab8751..031c7fbb 100644 --- a/src/gui/kconfigskeleton.cpp +++ b/src/gui/kconfigskeleton.cpp @@ -1,22 +1,9 @@ /* This file is part of KOrganizer. - Copyright (c) 2000,2001 Cornelius Schumacher - Copyright (c) 2003 Waldo Bastian - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + SPDX-FileCopyrightText: 2000, 2001 Cornelius Schumacher + SPDX-FileCopyrightText: 2003 Waldo Bastian + + SPDX-License-Identifier: LGPL-2.0-or-later */ #include "kconfigskeleton.h" diff --git a/src/gui/kconfigskeleton.h b/src/gui/kconfigskeleton.h index c7cb5a10..8e88e8d8 100644 --- a/src/gui/kconfigskeleton.h +++ b/src/gui/kconfigskeleton.h @@ -1,24 +1,10 @@ /* - * This file is part of KDE. - * - * Copyright (c) 2001,2002,2003 Cornelius Schumacher - * Copyright (c) 2003 Waldo Bastian - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ + This file is part of KDE. + SPDX-FileCopyrightText: 2001, 2002, 2003 Cornelius Schumacher + SPDX-FileCopyrightText: 2003 Waldo Bastian + + SPDX-License-Identifier: LGPL-2.0-or-later +*/ #ifndef KCONFIGSKELETON_H #define KCONFIGSKELETON_H diff --git a/src/gui/kstandardshortcut.cpp b/src/gui/kstandardshortcut.cpp index b845f612..2bf978cc 100644 --- a/src/gui/kstandardshortcut.cpp +++ b/src/gui/kstandardshortcut.cpp @@ -1,21 +1,10 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 Stefan Taferner (taferner@alpin.or.at) - Copyright (C) 2000 Nicolas Hadacek (haadcek@kde.org) - Copyright (C) 2001,2002 Ellis Whitehead (ellis@kde.org) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. +/* + This file is part of the KDE libraries + SPDX-FileCopyrightText: 1997 Stefan Taferner + SPDX-FileCopyrightText: 2000 Nicolas Hadacek + SPDX-FileCopyrightText: 2001, 2002 Ellis Whitehead + + SPDX-License-Identifier: LGPL-2.0-only */ #include "kstandardshortcut.h" diff --git a/src/gui/kstandardshortcut.h b/src/gui/kstandardshortcut.h index 6f673272..e8fce220 100644 --- a/src/gui/kstandardshortcut.h +++ b/src/gui/kstandardshortcut.h @@ -1,21 +1,10 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 Stefan Taferner (taferner@kde.org) - Copyright (C) 2000 Nicolas Hadacek (hadacek@kde.org) - Copyright (C) 2001,2002 Ellis Whitehead (ellis@kde.org) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. +/* + This file is part of the KDE libraries + SPDX-FileCopyrightText: 1997 Stefan Taferner + SPDX-FileCopyrightText: 2000 Nicolas Hadacek + SPDX-FileCopyrightText: 2001, 2002 Ellis Whitehead + + SPDX-License-Identifier: LGPL-2.0-only */ #ifndef KSTANDARDSHORTCUT_H #define KSTANDARDSHORTCUT_H diff --git a/src/gui/kwindowconfig.cpp b/src/gui/kwindowconfig.cpp index d2f355c8..2f787a2f 100644 --- a/src/gui/kwindowconfig.cpp +++ b/src/gui/kwindowconfig.cpp @@ -1,22 +1,8 @@ /* - This file is part of the KDE libraries - Copyright (c) 2012 Benjamin Port + This file is part of the KDE libraries + SPDX-FileCopyrightText: 2012 Benjamin Port - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "kwindowconfig.h" diff --git a/src/gui/kwindowconfig.h b/src/gui/kwindowconfig.h index a97e9d38..ad03f3ef 100644 --- a/src/gui/kwindowconfig.h +++ b/src/gui/kwindowconfig.h @@ -1,22 +1,8 @@ /* - This file is part of the KDE libraries - Copyright (c) 2012 Benjamin Port + This file is part of the KDE libraries + SPDX-FileCopyrightText: 2012 Benjamin Port - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef KWINDOWCONFIG_H diff --git a/src/kconf_update/kconf_update.cpp b/src/kconf_update/kconf_update.cpp index 22798cd4..7c3220f5 100644 --- a/src/kconf_update/kconf_update.cpp +++ b/src/kconf_update/kconf_update.cpp @@ -1,22 +1,9 @@ /* - * - * This file is part of the KDE libraries - * Copyright (c) 2001 Waldo Bastian - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License version 2 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - **/ + This file is part of the KDE libraries + SPDX-FileCopyrightText: 2001 Waldo Bastian + + SPDX-License-Identifier: LGPL-2.0-only +*/ #include // CMAKE_INSTALL_PREFIX diff --git a/src/kconf_update/kconfigutils.cpp b/src/kconf_update/kconfigutils.cpp index 8f0aa90c..a47ef53a 100644 --- a/src/kconf_update/kconfigutils.cpp +++ b/src/kconf_update/kconfigutils.cpp @@ -1,22 +1,9 @@ -/* This file is part of the KDE libraries - Copyright 2010 Canonical Ltd - Author: Aurélien Gâteau +/* + This file is part of the KDE libraries + SPDX-FileCopyrightText: 2010 Canonical Ltd + SPDX-FileContributor: Aurélien Gâteau - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License (LGPL) as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later - version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + SPDX-License-Identifier: LGPL-2.0-or-later */ #include "kconfigutils.h" diff --git a/src/kconf_update/kconfigutils.h b/src/kconf_update/kconfigutils.h index 606495e6..4656be1d 100644 --- a/src/kconf_update/kconfigutils.h +++ b/src/kconf_update/kconfigutils.h @@ -1,22 +1,10 @@ -/* This file is part of the KDE libraries - Copyright 2010 Canonical Ltd - Author: Aurélien Gâteau - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License (LGPL) as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later - version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. +/* + This file is part of the KDE libraries + + SPDX-FileCopyrightText: 2010 Canonical Ltd + SPDX-FileContributor: Aurélien Gâteau + + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KCONFIGUTILS_H #define KCONFIGUTILS_H diff --git a/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp b/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp index efe4fb7e..dcbb30c3 100644 --- a/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp +++ b/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp @@ -1,26 +1,14 @@ -/* m_this file is part of the KDE libraries - Copyright (C) 2020 Tomaz Cananbrava (tcanabrava@kde.org) - Copyright (c) 2003 Cornelius Schumacher - Copyright (c) 2003 Waldo Bastian - Copyright (c) 2003 Zack Rusin - Copyright (c) 2006 Michaël Larouche - Copyright (c) 2008 Allen Winter - Copyright (C) 2020 Tomaz Cananbrava (tcanabrava@kde.org) - - m_this library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - m_this library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. +/* + This file is part of the KDE libraries. + + SPDX-FileCopyrightText: 2003 Cornelius Schumacher + SPDX-FileCopyrightText: 2003 Waldo Bastian + SPDX-FileCopyrightText: 2003 Zack Rusin + SPDX-FileCopyrightText: 2006 Michaël Larouche + SPDX-FileCopyrightText: 2008 Allen Winter + SPDX-FileCopyrightText: 2020 Tomaz Cananbrava + + SPDX-License-Identifier: LGPL-2.0-or-later */ #include "KConfigCodeGeneratorBase.h" diff --git a/src/kconfig_compiler/KConfigCodeGeneratorBase.h b/src/kconfig_compiler/KConfigCodeGeneratorBase.h index 0c815c9b..6059e26f 100644 --- a/src/kconfig_compiler/KConfigCodeGeneratorBase.h +++ b/src/kconfig_compiler/KConfigCodeGeneratorBase.h @@ -1,28 +1,14 @@ /* This file is part of KDE. - Copyright (C) 2020 Tomaz Cananbrava (tcanabrava@kde.org) - Copyright (c) 2003 Cornelius Schumacher - Copyright (c) 2003 Waldo Bastian - Copyright (c) 2003 Zack Rusin - Copyright (c) 2006 Michaël Larouche - Copyright (c) 2008 Allen Winter - Copyright (C) 2020 Tomaz Cananbrava (tcanabrava@kde.org) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + SPDX-FileCopyrightText: 2003 Cornelius Schumacher + SPDX-FileCopyrightText: 2003 Waldo Bastian + SPDX-FileCopyrightText: 2003 Zack Rusin + SPDX-FileCopyrightText: 2006 Michaël Larouche + SPDX-FileCopyrightText: 2008 Allen Winter + SPDX-FileCopyrightText: 2020 Tomaz Cananbrava + + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KCONFIGCODEGENERATORBASE_H @@ -67,7 +53,7 @@ class KConfigCodeGeneratorBase { // start a block scope `{` and increase indentation level. void endScope(ScopeFinalizer finalizer = None); - + // end a block scope `}` and decrease indentation level. void startScope(); diff --git a/src/kconfig_compiler/KConfigCommonStructs.h b/src/kconfig_compiler/KConfigCommonStructs.h index fef45a9f..70249d47 100644 --- a/src/kconfig_compiler/KConfigCommonStructs.h +++ b/src/kconfig_compiler/KConfigCommonStructs.h @@ -1,26 +1,14 @@ -/* This file is part of the KDE libraries - Copyright (C) 2020 Tomaz Cananbrava (tcanabrava@kde.org) - Copyright (c) 2003 Cornelius Schumacher - Copyright (c) 2003 Waldo Bastian - Copyright (c) 2003 Zack Rusin - Copyright (c) 2006 Michaël Larouche - Copyright (c) 2008 Allen Winter - Copyright (C) 2020 Tomaz Cananbrava (tcanabrava@kde.org) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. +/* + This file is part of the KDE libraries. + + SPDX-FileCopyrightText: 2003 Cornelius Schumacher + SPDX-FileCopyrightText: 2003 Waldo Bastian + SPDX-FileCopyrightText: 2003 Zack Rusin + SPDX-FileCopyrightText: 2006 Michaël Larouche + SPDX-FileCopyrightText: 2008 Allen Winter + SPDX-FileCopyrightText: 2020 Tomaz Cananbrava + + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KCONFIGCOMMONSTRUCTS_H @@ -174,7 +162,7 @@ QString itemDeclaration(const CfgEntry *e, const KConfigParameters &cfg); QString translatedString( const KConfigParameters &cfg, - const QString &string, + const QString &string, const QString &context = QString(), const QString ¶m = QString(), const QString ¶mValue = QString()); @@ -197,7 +185,7 @@ QString newInnerItem( QString userTextsFunctions( const CfgEntry *e, const KConfigParameters &cfg, - QString itemVarStr = QString(), + QString itemVarStr = QString(), const QString &i = QString()); QString paramString(const QString &s, const CfgEntry *e, int i); diff --git a/src/kconfig_compiler/KConfigHeaderGenerator.cpp b/src/kconfig_compiler/KConfigHeaderGenerator.cpp index 84f89e26..ec353158 100644 --- a/src/kconfig_compiler/KConfigHeaderGenerator.cpp +++ b/src/kconfig_compiler/KConfigHeaderGenerator.cpp @@ -1,26 +1,14 @@ -/* This file is part of the KDE libraries - Copyright (C) 2020 Tomaz Cananbrava (tcanabrava@kde.org) - Copyright (c) 2003 Cornelius Schumacher - Copyright (c) 2003 Waldo Bastian - Copyright (c) 2003 Zack Rusin - Copyright (c) 2006 Michaël Larouche - Copyright (c) 2008 Allen Winter - Copyright (C) 2020 Tomaz Cananbrava (tcanabrava@kde.org) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. +/* + This file is part of the KDE libraries. + + SPDX-FileCopyrightText: 2003 Cornelius Schumacher + SPDX-FileCopyrightText: 2003 Waldo Bastian + SPDX-FileCopyrightText: 2003 Zack Rusin + SPDX-FileCopyrightText: 2006 Michaël Larouche + SPDX-FileCopyrightText: 2008 Allen Winter + SPDX-FileCopyrightText: 2020 Tomaz Cananbrava + + SPDX-License-Identifier: LGPL-2.0-or-later */ #include "KConfigHeaderGenerator.h" @@ -39,7 +27,7 @@ KConfigHeaderGenerator::KConfigHeaderGenerator( { } -void KConfigHeaderGenerator::start() +void KConfigHeaderGenerator::start() { KConfigCodeGeneratorBase::start(); startHeaderGuards(); @@ -156,7 +144,7 @@ void KConfigHeaderGenerator::startHeaderGuards() stream() << '\n'; } -void KConfigHeaderGenerator::endHeaderGuards() +void KConfigHeaderGenerator::endHeaderGuards() { stream() << '\n'; stream() << "#endif"; diff --git a/src/kconfig_compiler/KConfigHeaderGenerator.h b/src/kconfig_compiler/KConfigHeaderGenerator.h index d780b850..b93a47db 100644 --- a/src/kconfig_compiler/KConfigHeaderGenerator.h +++ b/src/kconfig_compiler/KConfigHeaderGenerator.h @@ -1,28 +1,14 @@ /* This file is part of KDE. - Copyright (C) 2020 Tomaz Cananbrava (tcanabrava@kde.org) - Copyright (c) 2003 Cornelius Schumacher - Copyright (c) 2003 Waldo Bastian - Copyright (c) 2003 Zack Rusin - Copyright (c) 2006 Michaël Larouche - Copyright (c) 2008 Allen Winter - Copyright (C) 2020 Tomaz Cananbrava (tcanabrava@kde.org) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + SPDX-FileCopyrightText: 2003 Cornelius Schumacher + SPDX-FileCopyrightText: 2003 Waldo Bastian + SPDX-FileCopyrightText: 2003 Zack Rusin + SPDX-FileCopyrightText: 2006 Michaël Larouche + SPDX-FileCopyrightText: 2008 Allen Winter + SPDX-FileCopyrightText: 2020 Tomaz Cananbrava + + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KCONFIGHEADERGENERATOR_H diff --git a/src/kconfig_compiler/KConfigParameters.cpp b/src/kconfig_compiler/KConfigParameters.cpp index e715818a..7999475e 100644 --- a/src/kconfig_compiler/KConfigParameters.cpp +++ b/src/kconfig_compiler/KConfigParameters.cpp @@ -1,26 +1,14 @@ -/* This file is part of the KDE libraries - Copyright (C) 2020 Tomaz Cananbrava (tcanabrava@kde.org) - Copyright (c) 2003 Cornelius Schumacher - Copyright (c) 2003 Waldo Bastian - Copyright (c) 2003 Zack Rusin - Copyright (c) 2006 Michaël Larouche - Copyright (c) 2008 Allen Winter - Copyright (C) 2020 Tomaz Cananbrava (tcanabrava@kde.org) +/* + This file is part of the KDE libraries. - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + SPDX-FileCopyrightText: 2003 Cornelius Schumacher + SPDX-FileCopyrightText: 2003 Waldo Bastian + SPDX-FileCopyrightText: 2003 Zack Rusin + SPDX-FileCopyrightText: 2006 Michaël Larouche + SPDX-FileCopyrightText: 2008 Allen Winter + SPDX-FileCopyrightText: 2020 Tomaz Cananbrava - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + SPDX-License-Identifier: LGPL-2.0-or-later */ #include "KConfigParameters.h" diff --git a/src/kconfig_compiler/KConfigParameters.h b/src/kconfig_compiler/KConfigParameters.h index b114dcc9..1984bb96 100644 --- a/src/kconfig_compiler/KConfigParameters.h +++ b/src/kconfig_compiler/KConfigParameters.h @@ -1,27 +1,14 @@ /* This file is part of KDE. - Copyright (C) 2020 Tomaz Cananbrava (tcanabrava@kde.org) - Copyright (c) 2003 Cornelius Schumacher - Copyright (c) 2003 Waldo Bastian - Copyright (c) 2003 Zack Rusin - Copyright (c) 2006 Michaël Larouche - Copyright (c) 2008 Allen Winter - Copyright (C) 2020 Tomaz Cananbrava (tcanabrava@kde.org) - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + SPDX-FileCopyrightText: 2003 Cornelius Schumacher + SPDX-FileCopyrightText: 2003 Waldo Bastian + SPDX-FileCopyrightText: 2003 Zack Rusin + SPDX-FileCopyrightText: 2006 Michaël Larouche + SPDX-FileCopyrightText: 2008 Allen Winter + SPDX-FileCopyrightText: 2020 Tomaz Cananbrava - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KCONFIGXTPARAMETERS_H diff --git a/src/kconfig_compiler/KConfigSourceGenerator.cpp b/src/kconfig_compiler/KConfigSourceGenerator.cpp index 3e8a8156..0da8d4df 100644 --- a/src/kconfig_compiler/KConfigSourceGenerator.cpp +++ b/src/kconfig_compiler/KConfigSourceGenerator.cpp @@ -1,26 +1,14 @@ -/* This file is part of the KDE libraries - Copyright (C) 2020 Tomaz Cananbrava (tcanabrava@kde.org) - Copyright (c) 2003 Cornelius Schumacher - Copyright (c) 2003 Waldo Bastian - Copyright (c) 2003 Zack Rusin - Copyright (c) 2006 Michaël Larouche - Copyright (c) 2008 Allen Winter - Copyright (C) 2020 Tomaz Cananbrava (tcanabrava@kde.org) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. +/* + This file is part of the KDE libraries + + SPDX-FileCopyrightText: 2003 Cornelius Schumacher + SPDX-FileCopyrightText: 2003 Waldo Bastian + SPDX-FileCopyrightText: 2003 Zack Rusin + SPDX-FileCopyrightText: 2006 Michaël Larouche + SPDX-FileCopyrightText: 2008 Allen Winter + SPDX-FileCopyrightText: 2020 Tomaz Cananbrava + + SPDX-License-Identifier: LGPL-2.0-or-later */ #include "KConfigSourceGenerator.h" @@ -36,7 +24,7 @@ KConfigSourceGenerator::KConfigSourceGenerator( { } -void KConfigSourceGenerator::start() +void KConfigSourceGenerator::start() { KConfigCodeGeneratorBase::start(); stream() << '\n'; @@ -208,7 +196,7 @@ void KConfigSourceGenerator::createPreamble() if (entry->paramValues.isEmpty()) { continue; } - + cppPreamble += QStringLiteral("const char* const ") + cfg().className + QStringLiteral("::") + enumName(entry->param); cppPreamble += cfg().globalEnums ? QStringLiteral("ToString[] = { \"") + entry->paramValues.join(QStringLiteral("\", \"")) + QStringLiteral("\" };\n") @@ -284,7 +272,7 @@ void KConfigSourceGenerator::createEnums(const CfgEntry *entry) return; } stream() << " QList<" << cfg().inherits << "::ItemEnum::Choice> values" << entry->name << ";\n"; - + for (const auto &choice : qAsConst(entry->choices.choices)) { stream() << " {\n"; stream() << " " << cfg().inherits << "::ItemEnum::Choice choice;\n"; @@ -668,7 +656,7 @@ void KConfigSourceGenerator::createNonModifyingSignalsHelper() endScope(); } -void KConfigSourceGenerator::createSignalFlagsHandler() +void KConfigSourceGenerator::createSignalFlagsHandler() { if (parseResult.signalList.isEmpty()) { return; diff --git a/src/kconfig_compiler/KConfigSourceGenerator.h b/src/kconfig_compiler/KConfigSourceGenerator.h index 1e1ffc97..76897f39 100644 --- a/src/kconfig_compiler/KConfigSourceGenerator.h +++ b/src/kconfig_compiler/KConfigSourceGenerator.h @@ -1,28 +1,14 @@ /* This file is part of KDE. - Copyright (C) 2020 Tomaz Cananbrava (tcanabrava@kde.org) - Copyright (c) 2003 Cornelius Schumacher - Copyright (c) 2003 Waldo Bastian - Copyright (c) 2003 Zack Rusin - Copyright (c) 2006 Michaël Larouche - Copyright (c) 2008 Allen Winter - Copyright (C) 2020 Tomaz Cananbrava (tcanabrava@kde.org) + SPDX-FileCopyrightText: 2003 Cornelius Schumacher + SPDX-FileCopyrightText: 2003 Waldo Bastian + SPDX-FileCopyrightText: 2003 Zack Rusin + SPDX-FileCopyrightText: 2006 Michaël Larouche + SPDX-FileCopyrightText: 2008 Allen Winter + SPDX-FileCopyrightText: 2020 Tomaz Cananbrava - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KCONFIGSOURCEGENERATOR_H diff --git a/src/kconfig_compiler/KConfigXmlParser.cpp b/src/kconfig_compiler/KConfigXmlParser.cpp index 045018de..dcbe869f 100644 --- a/src/kconfig_compiler/KConfigXmlParser.cpp +++ b/src/kconfig_compiler/KConfigXmlParser.cpp @@ -1,25 +1,14 @@ -/* This file is part of the KDE libraries - Copyright (c) 2003 Cornelius Schumacher - Copyright (c) 2003 Waldo Bastian - Copyright (c) 2003 Zack Rusin - Copyright (c) 2006 Michaël Larouche - Copyright (c) 2008 Allen Winter - Copyright (C) 2020 Tomaz Cananbrava (tcanabrava@kde.org) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. +/* + This file is part of the KDE libraries + + SPDX-FileCopyrightText: 2003 Cornelius Schumacher + SPDX-FileCopyrightText: 2003 Waldo Bastian + SPDX-FileCopyrightText: 2003 Zack Rusin + SPDX-FileCopyrightText: 2006 Michaël Larouche + SPDX-FileCopyrightText: 2008 Allen Winter + SPDX-FileCopyrightText: 2020 Tomaz Cananbrava + + SPDX-License-Identifier: LGPL-2.0-or-later */ #include "KConfigXmlParser.h" @@ -133,12 +122,12 @@ void KConfigXmlParser::readParameterFromEntry(CfgEntry &readEntry, const QDomEle { readEntry.param = e.attribute(QStringLiteral("name")); readEntry.paramType = e.attribute(QStringLiteral("type")); - + if (readEntry.param.isEmpty()) { std::cerr << "Parameter must have a name: " << qPrintable(dumpNode(e)) << std::endl; exit (1); } - + if (readEntry.paramType.isEmpty()) { std::cerr << "Parameter must have a type: " << qPrintable(dumpNode(e)) << std::endl; exit(1); @@ -220,7 +209,7 @@ void KConfigXmlParser::readChoicesFromEntry(CfgEntry &readEntry, const QDomEleme } chlist.append(choice); } - + QString name = e.attribute(QStringLiteral("name")); QString prefix = e.attribute(QStringLiteral("prefix")); @@ -406,7 +395,7 @@ CfgEntry *KConfigXmlParser::parseEntry(const QString &group, const QDomElement & preProcessDefault(readEntry.defaultValue, readEntry.name, readEntry.type, readEntry.choices, readEntry.code, cfg); } - // TODO: Try to Just return the CfgEntry we populated instead of + // TODO: Try to Just return the CfgEntry we populated instead of // creating another one to fill the code. CfgEntry *result = new CfgEntry(); result->group = readEntry.group; @@ -446,7 +435,7 @@ KConfigXmlParser::KConfigXmlParser(const KConfigParameters &cfg, const QString & { mValidNameRegexp.setPattern(QRegularExpression::anchoredPattern(QStringLiteral("[a-zA-Z_][a-zA-Z0-9_]*"))); } - + void KConfigXmlParser::start() { QFile input(mInputFileName); @@ -459,7 +448,7 @@ void KConfigXmlParser::start() std::cerr << "Parse error in " << qPrintable(mInputFileName) << ", line " << errorRow << ", col " << errorCol << ": " << qPrintable(errorMsg) << std::endl; exit (1); } - + QDomElement cfgElement = doc.documentElement(); if (cfgElement.isNull()) { std::cerr << "No document in kcfg file" << std::endl; @@ -557,6 +546,6 @@ void KConfigXmlParser::readSignalTag(const QDomElement &e) theSignal.label = e2.text(); } } - + mParseResult.signalList.append(theSignal); } diff --git a/src/kconfig_compiler/KConfigXmlParser.h b/src/kconfig_compiler/KConfigXmlParser.h index 5dbd2745..fa46e4b9 100644 --- a/src/kconfig_compiler/KConfigXmlParser.h +++ b/src/kconfig_compiler/KConfigXmlParser.h @@ -1,25 +1,14 @@ -/* This file is part of the KDE libraries - Copyright (c) 2003 Cornelius Schumacher - Copyright (c) 2003 Waldo Bastian - Copyright (c) 2003 Zack Rusin - Copyright (c) 2006 Michaël Larouche - Copyright (c) 2008 Allen Winter - Copyright (C) 2020 Tomaz Cananbrava (tcanabrava@kde.org) +/* + This file is part of the KDE libraries - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + SPDX-FileCopyrightText: 2003 Cornelius Schumacher + SPDX-FileCopyrightText: 2003 Waldo Bastian + SPDX-FileCopyrightText: 2003 Zack Rusin + SPDX-FileCopyrightText: 2006 Michaël Larouche + SPDX-FileCopyrightText: 2008 Allen Winter + SPDX-FileCopyrightText: 2020 Tomaz Cananbrava - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KCONFIGXMLPARSER_H diff --git a/src/kconfig_compiler/kcfg.xsd b/src/kconfig_compiler/kcfg.xsd index 11196d45..f28a70d7 100644 --- a/src/kconfig_compiler/kcfg.xsd +++ b/src/kconfig_compiler/kcfg.xsd @@ -11,11 +11,11 @@ - Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> - Copyright (c) 2003 Waldo Bastian <bastian@kde.org> - Copyright (c) 2003 Zack Rusin <zack@kde.org> - Copyright (c) 2004 Frans Englich <frans.englich@telia.com> - Copyright (c) 2006 Michaël Larouche <michael.larouche@kdemail.net> + SPDX-FileCopyrightText: 2003 Cornelius Schumacher <schumacher@kde.org> + SPDX-FileCopyrightText: 2003 Waldo Bastian <bastian@kde.org> + SPDX-FileCopyrightText: 2003 Zack Rusin <zack@kde.org> + SPDX-FileCopyrightText: 2004 Frans Englich <frans.englich@telia.com> + SPDX-FileCopyrightText: 2006 Michaël Larouche <michael.larouche@kdemail.net> Permission to use, copy, modify and distribute this DTD and its accompanying documentation for any purpose and without fee diff --git a/src/kconfig_compiler/kconfig_compiler.cpp b/src/kconfig_compiler/kconfig_compiler.cpp index f4349420..605dd2b5 100644 --- a/src/kconfig_compiler/kconfig_compiler.cpp +++ b/src/kconfig_compiler/kconfig_compiler.cpp @@ -1,26 +1,13 @@ /* This file is part of KDE. - Copyright (c) 2003 Cornelius Schumacher - Copyright (c) 2003 Waldo Bastian - Copyright (c) 2003 Zack Rusin - Copyright (c) 2006 Michaël Larouche - Copyright (c) 2008 Allen Winter - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. + SPDX-FileCopyrightText: 2003 Cornelius Schumacher + SPDX-FileCopyrightText: 2003 Waldo Bastian + SPDX-FileCopyrightText: 2003 Zack Rusin + SPDX-FileCopyrightText: 2006 Michaël Larouche + SPDX-FileCopyrightText: 2008 Allen Winter + + SPDX-License-Identifier: LGPL-2.0-or-later */ // Compiling this file with this flag is just crazy diff --git a/src/kreadconfig/kreadconfig.cpp b/src/kreadconfig/kreadconfig.cpp index 70e40b29..3d26c3b8 100644 --- a/src/kreadconfig/kreadconfig.cpp +++ b/src/kreadconfig/kreadconfig.cpp @@ -1,21 +1,9 @@ /* Read KConfig() entries - for use in shell scripts. - Copyright (c) 2001 Red Hat, Inc. + SPDX-FileCopyrightText: 2001 Red Hat, Inc. + SPDX-FileContributor: Programmed by Bernhard Rosenkraenzer - Programmed by Bernhard Rosenkraenzer - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . + SPDX-License-Identifier: GPL-2.0-or-later */ /* diff --git a/src/kreadconfig/kwriteconfig.cpp b/src/kreadconfig/kwriteconfig.cpp index 0d9fdfef..c5ad5689 100644 --- a/src/kreadconfig/kwriteconfig.cpp +++ b/src/kreadconfig/kwriteconfig.cpp @@ -1,23 +1,12 @@ /* Write KConfig() entries - for use in shell scripts. - Copyright (c) 2001 Red Hat, Inc. - Copyright (c) 2001 Luís Pedro Coelho + SPDX-FileCopyrightText: 2001 Red Hat , Inc. + SPDX-FileCopyrightText: 2001 Luís Pedro Coelho Programmed by Luís Pedro Coelho based on kreadconfig by Bernhard Rosenkraenzer - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . + SPDX-License-Identifier: GPL-2.0-or-later */ #include From ec9522ae73ffa4e0ff750c52b412f4d6ad020590 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Tue, 3 Mar 2020 20:42:51 +0200 Subject: [PATCH 003/259] [KConfigGui] Check font weight when clearing styleName property Summary: This is an addendum for commit a2774ff5b41987c3919a9e; making the check tighter. Test Plan: make && ctest Reviewers: #frameworks, dfaure, davidedmundson, cfeck, ervin, meven, bport Reviewed By: dfaure Subscribers: kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D27811 --- src/gui/kconfiggroupgui.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/kconfiggroupgui.cpp b/src/gui/kconfiggroupgui.cpp index 358e84e4..1ffd249c 100644 --- a/src/gui/kconfiggroupgui.cpp +++ b/src/gui/kconfiggroupgui.cpp @@ -161,10 +161,11 @@ static bool writeEntryGui(KConfigGroup *cg, const char *key, const QVariant &pro // than the former. For more details see: // https://bugreports.qt.io/browse/QTBUG-63792 // https://bugs.kde.org/show_bug.cgi?id=378523 - if (f.styleName() == QLatin1String("Regular") + if (f.weight() == QFont::Normal + && (f.styleName() == QLatin1String("Regular") || f.styleName() == QLatin1String("Normal") || f.styleName() == QLatin1String("Book") - || f.styleName() == QLatin1String("Roman")) { + || f.styleName() == QLatin1String("Roman"))) { f.setStyleName(QString()); } cg->writeEntry(key, f.toString().toUtf8(), pFlags); From 066c2bd90db50f67214bca5fee171f1d43391dc2 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Mon, 30 Mar 2020 10:21:40 +0200 Subject: [PATCH 004/259] QAtomicInteger::loadRelaxed/storeRelaxed() are available since Qt 5.14 A similar patch was approved in https://phabricator.kde.org/D26102 --- src/core/kconfig.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index b8fbba53..0d430792 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -57,7 +57,7 @@ KConfigPrivate::KConfigPrivate(KConfig::OpenFlags flags, configState(KConfigBase::NoAccess) { static QBasicAtomicInt use_etc_kderc = Q_BASIC_ATOMIC_INITIALIZER(-1); -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) if (use_etc_kderc.load() < 0) { use_etc_kderc.store( !qEnvironmentVariableIsSet("KDE_SKIP_KDERC")); // for unit tests } @@ -75,7 +75,7 @@ KConfigPrivate::KConfigPrivate(KConfig::OpenFlags flags, QStringLiteral("/etc/kde5rc"); #endif if (!QFileInfo(etc_kderc).isReadable()) { -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) use_etc_kderc.store(false); #else use_etc_kderc.storeRelaxed(false); @@ -253,7 +253,7 @@ KConfig::KConfig(KConfigPrivate &d) KConfig::~KConfig() { Q_D(KConfig); -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) if (d->bDirty && (d->mBackend && d->mBackend->ref.load() == 1)) { #else if (d->bDirty && (d->mBackend && d->mBackend->ref.loadRelaxed() == 1)) { From 0d113fb5845ed39fe4ad2ef04750ffce3dd6ca12 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 4 Apr 2020 22:33:24 +0000 Subject: [PATCH 005/259] GIT_SILENT Upgrade ECM and KF5 version requirements for 5.69.0 release. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c927ba0..fe3937f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ set(KF5_VERSION "5.69.0") # handled by release scripts project(KConfig VERSION ${KF5_VERSION}) include(FeatureSummary) -find_package(ECM 5.68.0 NO_MODULE) +find_package(ECM 5.69.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) From dd478895004757bd1583c77e79a7f882575df1c0 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 11 Apr 2020 09:24:07 +0000 Subject: [PATCH 006/259] GIT_SILENT Upgrade KF5 version to 5.70.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe3937f7..4902bcd6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.5) -set(KF5_VERSION "5.69.0") # handled by release scripts +set(KF5_VERSION "5.70.0") # handled by release scripts project(KConfig VERSION ${KF5_VERSION}) include(FeatureSummary) From 65cc12ab3ec8ca313d0e9d9b6d506e9fa9042bc1 Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Mon, 13 Apr 2020 12:21:57 -0600 Subject: [PATCH 007/259] Add standard shortcut for "Show/Hide Hidden Files" Summary: Add a standard shortcut for this action so it can be synchronized between different apps and the file dialog; see https://bugs.kde.org/show_bug.cgi?id=262551. The action in Dolphin also has F8 bound to this, but the definition here only accept two default shortcuts, and F8 seems kind of random. CCBUG: 262551 Test Plan: Apply D28803 to KIO and D28804 to Dolphin and test there Reviewers: dfaure, #frameworks Reviewed By: dfaure Subscribers: kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D28802 --- src/gui/kstandardshortcut.cpp | 6 ++++++ src/gui/kstandardshortcut.h | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/src/gui/kstandardshortcut.cpp b/src/gui/kstandardshortcut.cpp index 2bf978cc..b9bce5ed 100644 --- a/src/gui/kstandardshortcut.cpp +++ b/src/gui/kstandardshortcut.cpp @@ -166,6 +166,7 @@ static KStandardShortcutInfo g_infoStandardShortcut[] = { { RenameFile, "RenameFile", QT_TRANSLATE_NOOP3("KStandardShortcut", "Rename", "@action"), Qt::Key_F2, 0, QList(), false }, { MoveToTrash, "MoveToTrash", QT_TRANSLATE_NOOP3("KStandardShortcut", "Move to Trash", "@action"), Qt::Key_Delete, 0, QList(), false }, { Donate, "Donate", QT_TRANSLATE_NOOP3("KStandardShortcut", "Donate", "@action"), 0, 0, QList(), false }, + { ShowHideHiddenFiles, "ShowHideHiddenFiles", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show/Hide Hidden Files", "@action"), CTRL(H), ALT(Period), QList(), false }, //dummy entry to catch simple off-by-one errors. Insert new entries before this line. { AccelNone, nullptr, {nullptr, nullptr}, 0, 0, QList(), false } @@ -557,4 +558,9 @@ const QList &preferences() return shortcut(Preferences); } +const QList &showHideHiddenFiles() +{ + return shortcut(ShowHideHiddenFiles); +} + } diff --git a/src/gui/kstandardshortcut.h b/src/gui/kstandardshortcut.h index e8fce220..69feee61 100644 --- a/src/gui/kstandardshortcut.h +++ b/src/gui/kstandardshortcut.h @@ -141,6 +141,7 @@ enum StandardShortcut { RenameFile, ///< Rename files or folders. @since 5.25 MoveToTrash, ///< Move files or folders to the trash. @since 5.25 Donate, ///< Open donation page on kde.org. @since 5.26 + ShowHideHiddenFiles, ///< Toggle showing or hiding hidden files @since 5.70 // Insert new items here! StandardShortcutCount // number of standard shortcuts @@ -526,6 +527,14 @@ KCONFIGGUI_EXPORT const QList &moveToTrash(); * @since 5.64 */ KCONFIGGUI_EXPORT const QList &preferences(); + +/** + * Shows or hides hidden files. Defaults: Ctrl+H, Alt+. + * @return the shortcut of the standard accelerator + * @since 5.70 + */ +KCONFIGGUI_EXPORT const QList &showHideHiddenFiles(); + } #endif // KSTANDARDSHORTCUT_H From be28e096c5337b61a5e2f6e048ea297b2cc4b916 Mon Sep 17 00:00:00 2001 From: Benjamin Port Date: Tue, 17 Mar 2020 15:13:11 +0100 Subject: [PATCH 008/259] Add force save behavior to KEntryMap Summary: Fix the following bug, if an entry is set on HOME/.config/kdeglobals and on a specific config file like kcmfonts When you hit restore defaults button and apply, value will be not wrote on the specific file, but then the value is the one from kdeglobals This patch ensure we write the key to the specific configuration file on those case with an empty value. KConfig will take default value automatically Test Plan: Added a test to ensure flag is working Tested using some KCM to ensure all is working fine Reviewers: ervin, dfaure, meven, crossi, hchain Reviewed By: ervin, dfaure, meven Subscribers: kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D28128 --- autotests/kconfigtest.cpp | 27 +++++++++++++++++++++++++++ autotests/kconfigtest.h | 2 ++ src/core/kconfigdata.cpp | 4 ++++ src/core/kconfigdata.h | 7 ++++++- src/core/kconfigini.cpp | 5 ++++- 5 files changed, 43 insertions(+), 2 deletions(-) diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index 736274c6..4d38b150 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -1949,3 +1949,30 @@ void KConfigTest::testNotify() QCOMPARE(otherWatcherSpy[0][0].value().name(), QStringLiteral("TopLevelGroup")); QCOMPARE(otherWatcherSpy[0][1].value(), QByteArrayList({"someGlobalEntry"})); } + +void KConfigTest::testKdeglobalsVsDefault() +{ + // Add testRestore key with global value in kdeglobals + KConfig glob(QStringLiteral("kdeglobals")); + KConfigGroup generalGlob(&glob, "General"); + generalGlob.writeEntry("testRestore", "global"); + QVERIFY(glob.sync()); + + KConfig local(QStringLiteral(TEST_SUBDIR "restorerc")); + KConfigGroup generalLocal(&local, "General"); + // Check if we get global and not the default value from cpp (defaultcpp) when reading data from restorerc + QCOMPARE(generalLocal.readEntry("testRestore", "defaultcpp"), "global"); + + // Add test restore key with restore value in restorerc file + generalLocal.writeEntry("testRestore", "restore"); + QVERIFY(local.sync()); + local.reparseConfiguration(); + // We expect to get the value from restorerc file + QCOMPARE(generalLocal.readEntry("testRestore", "defaultcpp"), "restore"); + + // Revert to default testRestore key and we expect to get default value and not the global one + generalLocal.revertToDefault("testRestore"); + local.sync(); + local.reparseConfiguration(); + QCOMPARE(generalLocal.readEntry("testRestore", "defaultcpp"), "defaultcpp"); +} diff --git a/autotests/kconfigtest.h b/autotests/kconfigtest.h index e97e4a5d..7617d0e7 100644 --- a/autotests/kconfigtest.h +++ b/autotests/kconfigtest.h @@ -73,6 +73,8 @@ private Q_SLOTS: void testThreads(); + void testKdeglobalsVsDefault(); + // should be last void testSyncOnExit(); }; diff --git a/src/core/kconfigdata.cpp b/src/core/kconfigdata.cpp index bfa662a0..5ead8167 100644 --- a/src/core/kconfigdata.cpp +++ b/src/core/kconfigdata.cpp @@ -100,6 +100,10 @@ bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const Q k = it.key(); e = *it; //qDebug() << "found existing entry for key" << k; + // If overridden entry is global and not default. And it's overridden by a non global + if (e.bGlobal && !(options & EntryGlobal) && !k.bDefault) { + e.bOverridesGlobal = true; + } } else { // make sure the group marker is in the map KEntryMap const *that = this; diff --git a/src/core/kconfigdata.h b/src/core/kconfigdata.h index d92076d9..2f36b1bb 100644 --- a/src/core/kconfigdata.h +++ b/src/core/kconfigdata.h @@ -24,7 +24,7 @@ struct KEntry { KEntry() : mValue(), bDirty(false), bGlobal(false), bImmutable(false), bDeleted(false), bExpand(false), bReverted(false), - bLocalizedCountry(false), bNotify(false) {} + bLocalizedCountry(false), bNotify(false), bOverridesGlobal(false) {} /** @internal */ QByteArray mValue; /** @@ -58,6 +58,11 @@ struct KEntry { bool bLocalizedCountry: 1; bool bNotify: 1; + + /** + * Entry will need to be written on a non global file even if it matches default value + */ + bool bOverridesGlobal: 1; }; // These operators are used to check whether an entry which is about diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp index 2cea7338..9601d036 100644 --- a/src/core/kconfigini.cpp +++ b/src/core/kconfigini.cpp @@ -429,7 +429,10 @@ bool KConfigIniBackend::writeConfig(const QByteArray &locale, KEntryMap &entryMa // only write entries that have the same "globality" as the file if (it->bGlobal == bGlobal) { - if (it->bReverted) { + if (it->bReverted && it->bOverridesGlobal) { + it->bDeleted = true; + writeMap[key] = *it; + } else if (it->bReverted) { writeMap.remove(key); } else if (!it->bDeleted) { writeMap[key] = *it; From aa28a2433e55cc909c49ed4dbb7ce5c48baa1b24 Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Mon, 20 Apr 2020 02:57:02 +0200 Subject: [PATCH 009/259] API dox: document Q_DECLARE_FLAGS-based flags Summary: KApiDox & ECMAddQch have been just teached about Q_DECLARE_FLAGS, so the underlying typedefs are no longer skipped by doxygen, but can be documented now, allowing links to be generated for these types e.g. when used as arguments. The "#" prefix to the enum name in the description text of all the Q_DECLARE_FLAGS docs seems needed to properly trigger doxygen autolinks. GIT_SILENT --- src/core/kconfig.h | 4 ++++ src/core/kconfigbase.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/core/kconfig.h b/src/core/kconfig.h index 2693f91e..1c9d23d7 100644 --- a/src/core/kconfig.h +++ b/src/core/kconfig.h @@ -77,6 +77,7 @@ class KCONFIGCORE_EXPORT KConfig : public KConfigBase * Note that all values other than IncludeGlobals and CascadeConfig are * convenience definitions for the basic mode. * Do @em not combine them with anything. + * @see OpenFlags */ enum OpenFlag { IncludeGlobals = 0x01, ///< Blend kdeglobals into the config object. @@ -87,6 +88,9 @@ class KCONFIGCORE_EXPORT KConfig : public KConfigBase NoGlobals = CascadeConfig, ///< Cascade to system settings, but omit user's globals. FullConfig = IncludeGlobals | CascadeConfig ///< Fully-fledged config, including globals and cascading to system settings }; + /** + * Stores a combination of #OpenFlag values. + */ Q_DECLARE_FLAGS(OpenFlags, OpenFlag) /** diff --git a/src/core/kconfigbase.h b/src/core/kconfigbase.h index 927eb78a..12a8e875 100644 --- a/src/core/kconfigbase.h +++ b/src/core/kconfigbase.h @@ -32,6 +32,7 @@ class KCONFIGCORE_EXPORT KConfigBase public: /** * Flags to control write entry + * @see WriteConfigFlags */ enum WriteConfigFlag { Persistent = 0x01, @@ -60,6 +61,9 @@ class KCONFIGCORE_EXPORT KConfigBase */ }; + /** + * Stores a combination of #WriteConfigFlag values. + */ Q_DECLARE_FLAGS(WriteConfigFlags, WriteConfigFlag) /** From fb29718d3ac64bdc9e1f2a3d15a506f7798e4a76 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Tue, 4 Feb 2020 20:32:10 +0200 Subject: [PATCH 010/259] Fix some compiler warnings Summary: - Fix order of member initialisation (compiling with -Wreorder) - Use Q_UNUSED where needed - QAtomicInteger::loadRelaxed() has been available since Qt 5.14 Test Plan: make && ctest Reviewers: #frameworks, dfaure, apol Reviewed By: dfaure Subscribers: kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D27158 --- src/kconfig_compiler/KConfigCodeGeneratorBase.cpp | 2 +- src/kconfig_compiler/KConfigXmlParser.cpp | 1 + src/kconfig_compiler/kconfig_compiler.cpp | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp b/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp index dcbb30c3..48a24af5 100644 --- a/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp +++ b/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp @@ -30,7 +30,7 @@ KConfigCodeGeneratorBase::KConfigCodeGeneratorBase( const QString &fileName, const KConfigParameters ¶meters, ParseResult &parseResult) - : m_inputFile(inputFile), m_baseDir(baseDir), m_fileName(fileName), m_cfg(parameters), parseResult(parseResult) + : parseResult(parseResult), m_inputFile(inputFile), m_baseDir(baseDir), m_fileName(fileName), m_cfg(parameters) { m_file.setFileName(m_fileName); if (!m_file.open(QIODevice::WriteOnly)) { diff --git a/src/kconfig_compiler/KConfigXmlParser.cpp b/src/kconfig_compiler/KConfigXmlParser.cpp index dcbe869f..46ce0921 100644 --- a/src/kconfig_compiler/KConfigXmlParser.cpp +++ b/src/kconfig_compiler/KConfigXmlParser.cpp @@ -166,6 +166,7 @@ void KConfigXmlParser::readParameterFromEntry(CfgEntry &readEntry, const QDomEle bool KConfigXmlParser::hasDefaultCode(CfgEntry &readEntry, const QDomElement &element) { Q_UNUSED(readEntry) + for (QDomElement e = element.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { if (e.attribute(QStringLiteral("param")).isEmpty()) { if (e.attribute(QStringLiteral("code")) == QLatin1String("true")) { diff --git a/src/kconfig_compiler/kconfig_compiler.cpp b/src/kconfig_compiler/kconfig_compiler.cpp index 605dd2b5..4f9fa3f2 100644 --- a/src/kconfig_compiler/kconfig_compiler.cpp +++ b/src/kconfig_compiler/kconfig_compiler.cpp @@ -665,6 +665,8 @@ QString indent(QString text, int spaces) bool hasErrors(KConfigXmlParser &parser, const ParseResult& parseResult, const KConfigParameters &cfg) { + Q_UNUSED(parser) + if (cfg.className.isEmpty()) { std::cerr << "Class name missing" << std::endl; return true; From 00213a3a0906f0e1b5fa97a9e8de235a1e3cdcbf Mon Sep 17 00:00:00 2001 From: Cyril Rossi Date: Mon, 3 Feb 2020 13:50:17 +0100 Subject: [PATCH 011/259] kconfig_compiler : generate kconfig settings with subgroup Summary: Following D27059, add `parentGroupName` attribute to `group` element to generate kconfig settings with subgroups Reviewers: ervin, dfaure, #frameworks, meven Reviewed By: ervin, meven Subscribers: apol, meven, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D27133 --- autotests/kconfig_compiler/CMakeLists.txt | 10 ++ .../kconfig_compiler/kconfigcompiler_test.cpp | 2 + .../kconfig_compiler/test_subgroups.cpp.ref | 47 ++++++++ .../kconfig_compiler/test_subgroups.h.ref | 102 ++++++++++++++++++ .../kconfig_compiler/test_subgroups.kcfg | 31 ++++++ .../kconfig_compiler/test_subgroups.kcfgc | 3 + .../kconfig_compiler/test_subgroups_main.cpp | 32 ++++++ src/kconfig_compiler/KConfigCommonStructs.h | 1 + .../KConfigSourceGenerator.cpp | 30 +++++- src/kconfig_compiler/KConfigSourceGenerator.h | 1 + src/kconfig_compiler/KConfigXmlParser.cpp | 8 +- src/kconfig_compiler/KConfigXmlParser.h | 2 +- src/kconfig_compiler/kcfg.xsd | 1 + 13 files changed, 265 insertions(+), 5 deletions(-) create mode 100644 autotests/kconfig_compiler/test_subgroups.cpp.ref create mode 100644 autotests/kconfig_compiler/test_subgroups.h.ref create mode 100644 autotests/kconfig_compiler/test_subgroups.kcfg create mode 100644 autotests/kconfig_compiler/test_subgroups.kcfgc create mode 100644 autotests/kconfig_compiler/test_subgroups_main.cpp diff --git a/autotests/kconfig_compiler/CMakeLists.txt b/autotests/kconfig_compiler/CMakeLists.txt index 2b31a4da..2a4b343b 100644 --- a/autotests/kconfig_compiler/CMakeLists.txt +++ b/autotests/kconfig_compiler/CMakeLists.txt @@ -179,6 +179,16 @@ gen_kcfg_test_source(test_emptyentries test_emptyentries_SRCS GENERATE_MOC) ecm_add_test(TEST_NAME test_emptyentries ${test_emptyentries_SRCS}) target_link_libraries(test_emptyentries KF5::ConfigGui) +########### next target ############### + +set(test_subgroups_SRCS test_subgroups_main.cpp ) + +gen_kcfg_test_source(test_subgroups test_subgroups_SRCS GENERATE_MOC) + +ecm_add_test(TEST_NAME test_subgroups ${test_subgroups_SRCS}) +target_link_libraries(test_subgroups KF5::ConfigGui) + + ########### next target ############### set(test_dpointer_SRCS test_dpointer_main.cpp ) diff --git a/autotests/kconfig_compiler/kconfigcompiler_test.cpp b/autotests/kconfig_compiler/kconfigcompiler_test.cpp index dc848f9d..bb4dd7c0 100644 --- a/autotests/kconfig_compiler/kconfigcompiler_test.cpp +++ b/autotests/kconfig_compiler/kconfigcompiler_test.cpp @@ -48,6 +48,7 @@ static CompilerTestSet testCases = { "test_emptyentries.cpp", "test_emptyentries.h", "test_properties_minmax.cpp", "test_properties_minmax.h", "test_param_minmax.cpp", "test_param_minmax.h", + "test_subgroups.cpp", "test_subgroups.h", nullptr }; @@ -75,6 +76,7 @@ static CompilerTestSet testCasesToRun = { "test_emptyentries", "test_properties_minmax", "test_param_minmax", + "test_subgroups", nullptr }; diff --git a/autotests/kconfig_compiler/test_subgroups.cpp.ref b/autotests/kconfig_compiler/test_subgroups.cpp.ref new file mode 100644 index 00000000..0c16742a --- /dev/null +++ b/autotests/kconfig_compiler/test_subgroups.cpp.ref @@ -0,0 +1,47 @@ +// This file is generated by kconfig_compiler_kf5 from test_subgroups.kcfg. +// All changes you do to this file will be lost. + +#include "test_subgroups.h" + +TestSubgroups::TestSubgroups( const QString & GeneralGroup, const QString & SubGroup, const QString & AnotherSubGroup ) + : KConfigSkeleton( QStringLiteral( "kconfig_compiler_kf5_test_rc" ) ) + , mParamGeneralGroup(GeneralGroup) + , mParamSubGroup(SubGroup) + , mParamAnotherSubGroup(AnotherSubGroup) +{ + KConfigGroup cgGeneralGroup(this->config(), QStringLiteral( "%1" ).arg( mParamGeneralGroup )); + KConfigGroup cgSubGroup = cgGeneralGroup.group(QStringLiteral( "%1" ).arg( mParamSubGroup )); + KConfigSkeleton::ItemBool *itemFoo; + itemFoo = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "Foo" ), mFoo, true ); + itemFoo->setWriteFlags(KConfigBase::Notify); + itemFoo->setGroup(cgSubGroup); + addItem( itemFoo, QStringLiteral( "Foo" ) ); + + KConfigGroup cgother = cgGeneralGroup.group(QStringLiteral( "other" )); + KConfigSkeleton::ItemInt *itemBar; + itemBar = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "Bar" ), mBar, 42 ); + itemBar->setWriteFlags(KConfigBase::Notify); + itemBar->setGroup(cgother); + addItem( itemBar, QStringLiteral( "Bar" ) ); + + KConfigGroup cgParentGroup(this->config(), QStringLiteral( "ParentGroup" )); + KConfigGroup cgAnotherSubGroup = cgParentGroup.group(QStringLiteral( "%1" ).arg( mParamAnotherSubGroup )); + KConfigSkeleton::ItemBool *itemBaz; + itemBaz = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "Baz" ), mBaz, true ); + itemBaz->setWriteFlags(KConfigBase::Notify); + itemBaz->setGroup(cgAnotherSubGroup); + addItem( itemBaz, QStringLiteral( "Baz" ) ); + + KConfigGroup cgSimpleParentGroup(this->config(), QStringLiteral( "SimpleParentGroup" )); + KConfigGroup cgSimpleGroup = cgSimpleParentGroup.group(QStringLiteral( "SimpleGroup" )); + KConfigSkeleton::ItemBool *itemFoobar; + itemFoobar = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "Foobar" ), mFoobar, true ); + itemFoobar->setWriteFlags(KConfigBase::Notify); + itemFoobar->setGroup(cgSimpleGroup); + addItem( itemFoobar, QStringLiteral( "Foobar" ) ); +} + +TestSubgroups::~TestSubgroups() +{ +} + diff --git a/autotests/kconfig_compiler/test_subgroups.h.ref b/autotests/kconfig_compiler/test_subgroups.h.ref new file mode 100644 index 00000000..11665710 --- /dev/null +++ b/autotests/kconfig_compiler/test_subgroups.h.ref @@ -0,0 +1,102 @@ +// This file is generated by kconfig_compiler_kf5 from test_subgroups.kcfg. +// All changes you do to this file will be lost. +#ifndef TESTSUBGROUPS_H +#define TESTSUBGROUPS_H + +#include +#include +#include + +class TestSubgroups : public KConfigSkeleton +{ + public: + + TestSubgroups( const QString & GeneralGroup, const QString & SubGroup, const QString & AnotherSubGroup ); + ~TestSubgroups(); + + /** + Get Foo + */ + bool foo() const + { + return mFoo; + } + + /** + Is Foo Immutable + */ + bool isFooImmutable() const + { + return isImmutable( QStringLiteral( "Foo" ) ); + } + + /** + Get Bar + */ + int bar() const + { + return mBar; + } + + /** + Is Bar Immutable + */ + bool isBarImmutable() const + { + return isImmutable( QStringLiteral( "Bar" ) ); + } + + /** + Get Baz + */ + bool baz() const + { + return mBaz; + } + + /** + Is Baz Immutable + */ + bool isBazImmutable() const + { + return isImmutable( QStringLiteral( "Baz" ) ); + } + + /** + Get Foobar + */ + bool foobar() const + { + return mFoobar; + } + + /** + Is Foobar Immutable + */ + bool isFoobarImmutable() const + { + return isImmutable( QStringLiteral( "Foobar" ) ); + } + + protected: + QString mParamGeneralGroup; + QString mParamSubGroup; + QString mParamAnotherSubGroup; + + // $(SubGroup) + bool mFoo; + + // other + int mBar; + + // $(AnotherSubGroup) + bool mBaz; + + // SimpleGroup + bool mFoobar; + + private: +}; + +#endif + diff --git a/autotests/kconfig_compiler/test_subgroups.kcfg b/autotests/kconfig_compiler/test_subgroups.kcfg new file mode 100644 index 00000000..aa4ef948 --- /dev/null +++ b/autotests/kconfig_compiler/test_subgroups.kcfg @@ -0,0 +1,31 @@ + + + + + + + + + + true + + + + + 42 + + + + + true + + + + + true + + + diff --git a/autotests/kconfig_compiler/test_subgroups.kcfgc b/autotests/kconfig_compiler/test_subgroups.kcfgc new file mode 100644 index 00000000..971964b3 --- /dev/null +++ b/autotests/kconfig_compiler/test_subgroups.kcfgc @@ -0,0 +1,3 @@ +File=test_subgroups.kcfg +ClassName=TestSubgroups +Notifiers=true diff --git a/autotests/kconfig_compiler/test_subgroups_main.cpp b/autotests/kconfig_compiler/test_subgroups_main.cpp new file mode 100644 index 00000000..d034859c --- /dev/null +++ b/autotests/kconfig_compiler/test_subgroups_main.cpp @@ -0,0 +1,32 @@ +/* + This file is part of KDE. + + Copyright (C) 2020 Cyril Rossi + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "test_subgroups.h" +#include + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + Q_UNUSED(app); + TestSubgroups *t = new TestSubgroups(QStringLiteral("General"), QStringLiteral("Sub"), QStringLiteral("AnotherSub")); + delete t; + return 0; +} diff --git a/src/kconfig_compiler/KConfigCommonStructs.h b/src/kconfig_compiler/KConfigCommonStructs.h index 70249d47..8ed1d22f 100644 --- a/src/kconfig_compiler/KConfigCommonStructs.h +++ b/src/kconfig_compiler/KConfigCommonStructs.h @@ -83,6 +83,7 @@ class CfgEntry public: QString group; + QString parentGroup; QString type; QString key; QString name; diff --git a/src/kconfig_compiler/KConfigSourceGenerator.cpp b/src/kconfig_compiler/KConfigSourceGenerator.cpp index 0da8d4df..bb2694b2 100644 --- a/src/kconfig_compiler/KConfigSourceGenerator.cpp +++ b/src/kconfig_compiler/KConfigSourceGenerator.cpp @@ -333,6 +333,10 @@ void KConfigSourceGenerator::createNormalEntry(const CfgEntry *entry, const QStr } } + if (!entry->parentGroup.isEmpty()) { + stream() << " " << itemVarStr << "->setGroup(cg" << QString(entry->group).remove(QRegExp(QStringLiteral("\\W"))) << ");\n"; + } + stream() << " addItem( " << itemVarStr; QString quotedName = entry->name; addQuotes(quotedName); @@ -342,6 +346,11 @@ void KConfigSourceGenerator::createNormalEntry(const CfgEntry *entry, const QStr stream() << " );\n"; } +// TODO : Some compiler option won't work or generate bogus settings file. +// * Does not manage properly Notifiers=true kcfgc option for parameterized entries : +// ** KConfigCompilerSignallingItem generated with wrong userData parameter (4th one). +// ** setWriteFlags() is missing. +// * Q_PROPERTY signal won't work void KConfigSourceGenerator::createIndexedEntry(const CfgEntry *entry, const QString &key) { for (int i = 0; i <= entry->paramMax; i++) { @@ -410,8 +419,25 @@ void KConfigSourceGenerator::handleCurrentGroupChange(const CfgEntry *entry) } mCurrentGroup = entry->group; - stream() << " setCurrentGroup( " << paramString(mCurrentGroup, parseResult.parameters) << " );"; - stream() << "\n\n"; + + if (!entry->parentGroup.isEmpty()) { + QString parentGroup = QString(entry->parentGroup).remove(QRegExp(QStringLiteral("\\W"))); + if (!mConfigGroupList.contains(parentGroup)) { + stream() << " KConfigGroup cg" << parentGroup + << "(this->config(), " << paramString(entry->parentGroup, parseResult.parameters) << ");\n"; + mConfigGroupList << parentGroup; + } + QString currentGroup = QString(mCurrentGroup).remove(QRegExp(QStringLiteral("\\W"))); + if (!mConfigGroupList.contains(currentGroup)) { + stream() << " KConfigGroup cg" << currentGroup + << " = cg" << QString(entry->parentGroup).remove(QRegExp(QStringLiteral("\\W"))) + << ".group(" << paramString(mCurrentGroup, parseResult.parameters) << ");\n"; + mConfigGroupList << currentGroup; + } + } else { + stream() << " setCurrentGroup( " << paramString(mCurrentGroup, parseResult.parameters) << " );"; + stream() << "\n\n"; + } } void KConfigSourceGenerator::doConstructor() diff --git a/src/kconfig_compiler/KConfigSourceGenerator.h b/src/kconfig_compiler/KConfigSourceGenerator.h index 76897f39..db2c8e72 100644 --- a/src/kconfig_compiler/KConfigSourceGenerator.h +++ b/src/kconfig_compiler/KConfigSourceGenerator.h @@ -68,6 +68,7 @@ class KConfigSourceGenerator : public KConfigCodeGeneratorBase { private: QString mCurrentGroup; + QStringList mConfigGroupList; // keeps track of generated KConfigGroup; }; #endif diff --git a/src/kconfig_compiler/KConfigXmlParser.cpp b/src/kconfig_compiler/KConfigXmlParser.cpp index 46ce0921..3120d006 100644 --- a/src/kconfig_compiler/KConfigXmlParser.cpp +++ b/src/kconfig_compiler/KConfigXmlParser.cpp @@ -344,7 +344,7 @@ void KConfigXmlParser::readParamDefaultValues(CfgEntry &readEntry, const QDomEle } } -CfgEntry *KConfigXmlParser::parseEntry(const QString &group, const QDomElement &element) +CfgEntry *KConfigXmlParser::parseEntry(const QString &group, const QString &parentGroup, const QDomElement &element) { CfgEntry readEntry; readEntry.type = element.attribute(QStringLiteral("type")); @@ -352,6 +352,7 @@ CfgEntry *KConfigXmlParser::parseEntry(const QString &group, const QDomElement & readEntry.key = element.attribute(QStringLiteral("key")); readEntry.hidden = element.attribute(QStringLiteral("hidden")) == QLatin1String("true");; readEntry.group = group; + readEntry.parentGroup = parentGroup; const bool nameIsEmpty = readEntry.name.isEmpty(); @@ -400,6 +401,7 @@ CfgEntry *KConfigXmlParser::parseEntry(const QString &group, const QDomElement & // creating another one to fill the code. CfgEntry *result = new CfgEntry(); result->group = readEntry.group; + result->parentGroup = readEntry.parentGroup; result->type = readEntry.type; result->key = readEntry.key; result->name = readEntry.name; @@ -492,11 +494,13 @@ void KConfigXmlParser::readGroupTag(const QDomElement &e) exit (1); } + const QString parentGroup = e.attribute(QStringLiteral("parentGroupName")); + for (QDomElement e2 = e.firstChildElement(); !e2.isNull(); e2 = e2.nextSiblingElement()) { if (e2.tagName() != QLatin1String("entry")) { continue; } - CfgEntry *entry = parseEntry(group, e2); + CfgEntry *entry = parseEntry(group, parentGroup, e2); if (entry) { mParseResult.entries.append(entry); } else { diff --git a/src/kconfig_compiler/KConfigXmlParser.h b/src/kconfig_compiler/KConfigXmlParser.h index fa46e4b9..742cb496 100644 --- a/src/kconfig_compiler/KConfigXmlParser.h +++ b/src/kconfig_compiler/KConfigXmlParser.h @@ -46,7 +46,7 @@ class KConfigXmlParser // TODO: Use std::optional and CfgEntry (without heap allocation) for this function // *or* fail hard if the parse fails. - CfgEntry *parseEntry(const QString &group, const QDomElement &element); + CfgEntry *parseEntry(const QString &group, const QString &parentGroup, const QDomElement &element); // Steps void readIncludeTag(const QDomElement &element); diff --git a/src/kconfig_compiler/kcfg.xsd b/src/kconfig_compiler/kcfg.xsd index f28a70d7..1ec1dc81 100644 --- a/src/kconfig_compiler/kcfg.xsd +++ b/src/kconfig_compiler/kcfg.xsd @@ -155,6 +155,7 @@ + From 1c8da80c5f10a25c2c6ba23981e6050d0555423d Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 2 May 2020 21:56:10 +0000 Subject: [PATCH 012/259] GIT_SILENT Upgrade ECM and KF5 version requirements for 5.70.0 release. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4902bcd6..77f4b0ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ set(KF5_VERSION "5.70.0") # handled by release scripts project(KConfig VERSION ${KF5_VERSION}) include(FeatureSummary) -find_package(ECM 5.69.0 NO_MODULE) +find_package(ECM 5.70.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) From 2789bb2c7b263803b2708d021c8e47ea9f5207dc Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 1 May 2020 20:41:13 +0200 Subject: [PATCH 013/259] KAuthorized: export method to reload restrictions Summary: This is useful for unittests. Example: ``` KCONFIGCORE_EXPORT void reloadUrlActionRestrictions(); void someTestMethod() { KConfigGroup cg(KSharedConfig::openConfig(), "KDE URL Restrictions"); cg.writeEntry("rule_count", 1); cg.writeEntry("rule_1", QStringList{"open", {}, {}, {}, "file", "", "", "false"}); cg.sync(); reloadUrlActionRestrictions(); // Some test for code that uses KUrlAuthorized cg.deleteEntry("rule_1"); cg.deleteEntry("rule_count"); cg.sync(); reloadUrlActionRestrictions(); } ``` This is consistent with the fact that other functions used by KUrlAuthorized are defined here and exported internally. Test Plan: Used this in a KIO unittest I'm writing for the future OpenUrlJob Reviewers: aacid, apol, mdawson Reviewed By: aacid Subscribers: kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D29347 --- src/core/kauthorized.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/kauthorized.cpp b/src/core/kauthorized.cpp index fd79930e..ca98bffa 100644 --- a/src/core/kauthorized.cpp +++ b/src/core/kauthorized.cpp @@ -244,7 +244,7 @@ QStringList KAuthorized::authorizeControlModules(const QStringList &menuIds) return result; } -static void initUrlActionRestrictions() +KCONFIGCORE_EXPORT void reloadUrlActionRestrictions() { MY_D const QString Any; @@ -368,7 +368,7 @@ KCONFIGCORE_EXPORT bool authorizeUrlActionInternal(const QString &action, const bool result = false; if (d->urlActionRestrictions.isEmpty()) { - initUrlActionRestrictions(); + reloadUrlActionRestrictions(); } QUrl baseURL(_baseURL); From 311e30857e33f9222b28b6d3b841ab6e61558237 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 3 May 2020 13:38:51 +0200 Subject: [PATCH 014/259] GIT_SILENT add comment --- src/core/kauthorized.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/kauthorized.cpp b/src/core/kauthorized.cpp index ca98bffa..f7515428 100644 --- a/src/core/kauthorized.cpp +++ b/src/core/kauthorized.cpp @@ -244,6 +244,7 @@ QStringList KAuthorized::authorizeControlModules(const QStringList &menuIds) return result; } +// Exported for unittests (e.g. in KIO, we're missing tests for this in kconfig) KCONFIGCORE_EXPORT void reloadUrlActionRestrictions() { MY_D From 8e0f84030cc1d1e517ca75311ed9850ce88fac41 Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 8 May 2020 11:04:35 +0200 Subject: [PATCH 015/259] Adjust name of internally-exported method as suggested in D29347 --- src/core/kauthorized.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/kauthorized.cpp b/src/core/kauthorized.cpp index f7515428..8e459d47 100644 --- a/src/core/kauthorized.cpp +++ b/src/core/kauthorized.cpp @@ -245,7 +245,7 @@ QStringList KAuthorized::authorizeControlModules(const QStringList &menuIds) } // Exported for unittests (e.g. in KIO, we're missing tests for this in kconfig) -KCONFIGCORE_EXPORT void reloadUrlActionRestrictions() +KCONFIGCORE_EXPORT void loadUrlActionRestrictions(const KConfigGroup &cg) { MY_D const QString Any; @@ -291,7 +291,6 @@ KCONFIGCORE_EXPORT void reloadUrlActionRestrictions() d->urlActionRestrictions.append( URLActionRule("redirect", QStringLiteral("about"), Any, Any, Any, Any, Any, true)); - KConfigGroup cg(KSharedConfig::openConfig(), "KDE URL Restrictions"); int count = cg.readEntry("rule_count", 0); QString keyFormat = QStringLiteral("rule_%1"); for (int i = 1; i <= count; i++) { @@ -369,7 +368,8 @@ KCONFIGCORE_EXPORT bool authorizeUrlActionInternal(const QString &action, const bool result = false; if (d->urlActionRestrictions.isEmpty()) { - reloadUrlActionRestrictions(); + KConfigGroup cg(KSharedConfig::openConfig(), "KDE URL Restrictions"); + loadUrlActionRestrictions(cg); } QUrl baseURL(_baseURL); From 15ecb79b0220b0d8d77e0f7146f854aefacf415d Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 9 May 2020 11:25:55 +0000 Subject: [PATCH 016/259] GIT_SILENT Upgrade KF5 version to 5.71.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 77f4b0ff..0055484c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.5) -set(KF5_VERSION "5.70.0") # handled by release scripts +set(KF5_VERSION "5.71.0") # handled by release scripts project(KConfig VERSION ${KF5_VERSION}) include(FeatureSummary) From cb9b6ca3193b5c571b28f2151a52367f0026797c Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Tue, 19 May 2020 07:12:55 +0200 Subject: [PATCH 017/259] GIT_SILENT: we don't use phabricator anymore --- .arcconfig | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .arcconfig diff --git a/.arcconfig b/.arcconfig deleted file mode 100644 index 377c7ecb..00000000 --- a/.arcconfig +++ /dev/null @@ -1,3 +0,0 @@ -{ - "phabricator.uri" : "https://phabricator.kde.org/" -} From 9bbf7cf53f573fa48f4bddd9b632cfba7171914d Mon Sep 17 00:00:00 2001 From: David Redondo Date: Fri, 22 May 2020 21:41:34 +0200 Subject: [PATCH 018/259] Fix KStandardShortcut::find(const char*) qstrcmp returns 0 if two strings are equal. --- src/gui/kstandardshortcut.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kstandardshortcut.cpp b/src/gui/kstandardshortcut.cpp index b9bce5ed..7d788919 100644 --- a/src/gui/kstandardshortcut.cpp +++ b/src/gui/kstandardshortcut.cpp @@ -321,7 +321,7 @@ StandardShortcut find(const QKeySequence &seq) StandardShortcut find(const char *keyName) { for (const KStandardShortcutInfo &shortcutInfo : g_infoStandardShortcut) { - if (qstrcmp(shortcutInfo.name, keyName)) { + if (qstrcmp(shortcutInfo.name, keyName) == 0) { return shortcutInfo.id; } } From 24e0799ccc85967d958b1de706186ec154f64226 Mon Sep 17 00:00:00 2001 From: David Redondo Date: Fri, 22 May 2020 22:54:17 +0200 Subject: [PATCH 019/259] Add KStandardShortcut::findByName(const QString&) and deprecate find(const char*) KStandardShortcut::name returns a QString, this makes the api symmetric and more straightforward to use. --- autotests/kstandardshortcuttest.cpp | 7 +++++++ autotests/kstandardshortcuttest.h | 1 + src/gui/CMakeLists.txt | 2 +- src/gui/kstandardshortcut.cpp | 14 ++++++++++++++ src/gui/kstandardshortcut.h | 14 ++++++++++++++ 5 files changed, 37 insertions(+), 1 deletion(-) diff --git a/autotests/kstandardshortcuttest.cpp b/autotests/kstandardshortcuttest.cpp index 53a724f9..8c4df027 100644 --- a/autotests/kstandardshortcuttest.cpp +++ b/autotests/kstandardshortcuttest.cpp @@ -44,3 +44,10 @@ void KStandardShortcutTest::testFindStdAccel() QCOMPARE(KStandardShortcut::find(QString("Ctrl+Shift+Alt+G")), KStandardShortcut::AccelNone); } +void KStandardShortcutTest::testFindByName() +{ + for (int i = KStandardShortcut::AccelNone + 1; i < KStandardShortcut::StandardShortcutCount; ++i) { + const auto id = static_cast(i); + QCOMPARE(id, KStandardShortcut::findByName(KStandardShortcut::name(id))); + } +} diff --git a/autotests/kstandardshortcuttest.h b/autotests/kstandardshortcuttest.h index 3d186226..ae484458 100644 --- a/autotests/kstandardshortcuttest.h +++ b/autotests/kstandardshortcuttest.h @@ -19,6 +19,7 @@ private Q_SLOTS: void testLabel(); void testShortcut(); void testFindStdAccel(); + void testFindByName(); }; #endif diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 7c0c2f58..5a276f97 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -15,7 +15,7 @@ ecm_generate_export_header(KF5ConfigGui GROUP_BASE_NAME KF VERSION ${KF5_VERSION} DEPRECATED_BASE_VERSION 0 - DEPRECATION_VERSIONS 5.11 5.39 + DEPRECATION_VERSIONS 5.11 5.39 5.71 EXCLUDE_DEPRECATED_BEFORE_AND_AT ${EXCLUDE_DEPRECATED_BEFORE_AND_AT} ) diff --git a/src/gui/kstandardshortcut.cpp b/src/gui/kstandardshortcut.cpp index 7d788919..825dfb8a 100644 --- a/src/gui/kstandardshortcut.cpp +++ b/src/gui/kstandardshortcut.cpp @@ -318,6 +318,8 @@ StandardShortcut find(const QKeySequence &seq) return AccelNone; } + +#if KCONFIGGUI_BUILD_DEPRECATED_SINCE(5, 71) StandardShortcut find(const char *keyName) { for (const KStandardShortcutInfo &shortcutInfo : g_infoStandardShortcut) { @@ -328,6 +330,18 @@ StandardShortcut find(const char *keyName) return AccelNone; } +#endif + +StandardShortcut findByName(const QString &name) +{ + + for (const KStandardShortcutInfo &shortcutInfo : g_infoStandardShortcut) { + if (QString::fromLatin1(shortcutInfo.name) == name) { + return shortcutInfo.id; + } + } + return AccelNone; +} QList hardcodedDefaultShortcut(StandardShortcut id) { diff --git a/src/gui/kstandardshortcut.h b/src/gui/kstandardshortcut.h index 69feee61..cda9fe96 100644 --- a/src/gui/kstandardshortcut.h +++ b/src/gui/kstandardshortcut.h @@ -186,6 +186,7 @@ KCONFIGGUI_EXPORT QString whatsThis(StandardShortcut id); */ KCONFIGGUI_EXPORT StandardShortcut find(const QKeySequence &keySeq); +#if KCONFIGGUI_ENABLE_DEPRECATED_SINCE(5, 71) /** * Return the StandardShortcut id of the standard accel action which * has \a keyName as its name, or AccelNone if none of them do. @@ -193,8 +194,21 @@ KCONFIGGUI_EXPORT StandardShortcut find(const QKeySequence &keySeq); * @param keyName the key sequence to search * @return the id of the standard accelerator, or AccelNone if there * is none + * @deprecated since 5.71, use findByName(const QString &name) instead */ +KCONFIGGUI_DEPRECATED_VERSION(5, 71, "Use findByName(const QString &name) instead") KCONFIGGUI_EXPORT StandardShortcut find(const char *keyName); +#endif + +/** + * Return the StandardShortcut id of the standard accelerator action which + * has \p name as its name, or AccelNone if none of them do. + * @param name the name as returned by name(StandardShortcut id) + * @return the id of the standard accelerator with the given name or AccelNone + * if there is no such accelerator + * @since 5.71 + */ +KCONFIGGUI_EXPORT StandardShortcut findByName(const QString &name); /** * Returns the hardcoded default shortcut for @p id. From d57a4a0d1ef51b3861745480e536724740c171d7 Mon Sep 17 00:00:00 2001 From: David Redondo Date: Sat, 23 May 2020 09:50:05 +0200 Subject: [PATCH 020/259] Don't try to initalize deprecated SaveOptions enum value It will assert. --- src/gui/kstandardshortcut.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/kstandardshortcut.cpp b/src/gui/kstandardshortcut.cpp index 825dfb8a..8eb61102 100644 --- a/src/gui/kstandardshortcut.cpp +++ b/src/gui/kstandardshortcut.cpp @@ -305,7 +305,11 @@ StandardShortcut find(const QKeySequence &seq) if (!seq.isEmpty()) { for (const KStandardShortcutInfo &shortcutInfo : g_infoStandardShortcut) { const StandardShortcut id = shortcutInfo.id; +#if KCONFIGGUI_BUILD_DEPRECATED_SINCE(5, 39) if (id != AccelNone) { +#else + if (id != AccelNone && id != SaveOptions_DEPRECATED_DO_NOT_USE) { +#endif if (!shortcutInfo.isInitialized) { initialize(id); } From 94b1b005b87bce66f88897db7433c602f9deb49b Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sun, 31 May 2020 20:18:31 +0200 Subject: [PATCH 021/259] SVN_SILENT made messages (.desktop file) - always resolve ours In case of conflict in i18n, keep the version of the branch "ours" To resolve a particular conflict, "git checkout --ours path/to/file.desktop" --- src/core/kconfigbackend.desktop | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/kconfigbackend.desktop b/src/core/kconfigbackend.desktop index 0a7793fd..56702e15 100644 --- a/src/core/kconfigbackend.desktop +++ b/src/core/kconfigbackend.desktop @@ -5,6 +5,7 @@ X-KDE-ServiceType=KConfigBackend Comment=Storage backend for KConfig Comment[ar]=سند «ضبطك» للتخزين Comment[as]=KConfig ৰ বাবে ভঁৰালৰ বেকএন্ড +Comment[az]=KConfig Ayarlarını Saxlama Modulu Comment[be@latin]=Słužba schovišča dla systemy „KConfig” Comment[bg]=Storage backend for KConfig Comment[bn]=KConfig-এর স্টোরেজ ব্যাকেন্ড From 19565e624c2f73b633d388d06952fbbee636a3ed Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 6 Jun 2020 19:33:45 +0000 Subject: [PATCH 022/259] GIT_SILENT Upgrade ECM and KF5 version requirements for 5.71.0 release. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0055484c..6c8cc3b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ set(KF5_VERSION "5.71.0") # handled by release scripts project(KConfig VERSION ${KF5_VERSION}) include(FeatureSummary) -find_package(ECM 5.70.0 NO_MODULE) +find_package(ECM 5.71.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) From 6344c2fccf1512d10e640fdf433959ad3dfec36c Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 13 Jun 2020 12:38:31 +0000 Subject: [PATCH 023/259] GIT_SILENT Upgrade KF5 version to 5.72.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c8cc3b2..0ac2358d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.5) -set(KF5_VERSION "5.71.0") # handled by release scripts +set(KF5_VERSION "5.72.0") # handled by release scripts project(KConfig VERSION ${KF5_VERSION}) include(FeatureSummary) From 27882eb23d0a0ecfdd4e2d06120ef3c047c733f3 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Wed, 17 Jun 2020 13:58:15 +0200 Subject: [PATCH 024/259] SVN_SILENT made messages (.desktop file) - always resolve ours In case of conflict in i18n, keep the version of the branch "ours" To resolve a particular conflict, "git checkout --ours path/to/file.desktop" --- src/core/kconfigbackend.desktop | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/kconfigbackend.desktop b/src/core/kconfigbackend.desktop index 56702e15..fa4268d9 100644 --- a/src/core/kconfigbackend.desktop +++ b/src/core/kconfigbackend.desktop @@ -82,7 +82,6 @@ Comment[ug]=KConfig نىڭ ساقلاش ئارقا ئۇچى Comment[uk]=Модуль зберігання даних для KConfig Comment[vi]=Hậu trường lưu trữ cho KConfig Comment[wa]=Bouye di fond di stocaedje po KConfig -Comment[x-test]=xxStorage backend for KConfigxx Comment[zh_CN]=KConfig 存储后端 Comment[zh_TW]=KConfig 儲存後端介面 From 56a44a5de2e2bbb0041d6cd56575969cc254160c Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Thu, 18 Jun 2020 05:30:19 +0200 Subject: [PATCH 025/259] SVN_SILENT made messages (.desktop file) - always resolve ours In case of conflict in i18n, keep the version of the branch "ours" To resolve a particular conflict, "git checkout --ours path/to/file.desktop" --- src/core/kconfigbackend.desktop | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/kconfigbackend.desktop b/src/core/kconfigbackend.desktop index fa4268d9..56702e15 100644 --- a/src/core/kconfigbackend.desktop +++ b/src/core/kconfigbackend.desktop @@ -82,6 +82,7 @@ Comment[ug]=KConfig نىڭ ساقلاش ئارقا ئۇچى Comment[uk]=Модуль зберігання даних для KConfig Comment[vi]=Hậu trường lưu trữ cho KConfig Comment[wa]=Bouye di fond di stocaedje po KConfig +Comment[x-test]=xxStorage backend for KConfigxx Comment[zh_CN]=KConfig 存储后端 Comment[zh_TW]=KConfig 儲存後端介面 From a316687c2de2f8078195f72a9c8fcf61e29e04f7 Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Mon, 15 Jun 2020 13:38:35 -0600 Subject: [PATCH 026/259] Make "Switch Application Language..." text more consistent This makes it follow the pattern of other "Configure X" style actions. See also the discussion in https://invent.kde.org/frameworks/kxmlgui/-/merge_requests/4#note_60691 --- src/gui/kstandardshortcut.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kstandardshortcut.cpp b/src/gui/kstandardshortcut.cpp index 8eb61102..3e9d35d6 100644 --- a/src/gui/kstandardshortcut.cpp +++ b/src/gui/kstandardshortcut.cpp @@ -157,7 +157,7 @@ static KStandardShortcutInfo g_infoStandardShortcut[] = { { ConfigureNotifications, "ConfigureNotifications", QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Notifications", "@action"), 0, 0, QList(), false }, { TipofDay, "TipofDay", QT_TRANSLATE_NOOP3("KStandardShortcut", "Tip Of Day", "@action"), 0, 0, QList(), false }, { ReportBug, "ReportBug", QT_TRANSLATE_NOOP3("KStandardShortcut", "Report Bug", "@action"), 0, 0, QList(), false }, - { SwitchApplicationLanguage, "SwitchApplicationLanguage", QT_TRANSLATE_NOOP3("KStandardShortcut", "Switch Application Language", "@action"), 0, 0, QList(), false }, + { SwitchApplicationLanguage, "SwitchApplicationLanguage", QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Language...", "@action"), 0, 0, QList(), false }, { AboutApp, "AboutApp", QT_TRANSLATE_NOOP3("KStandardShortcut", "About Application", "@action"), 0, 0, QList(), false }, { AboutKDE, "AboutKDE", QT_TRANSLATE_NOOP3("KStandardShortcut", "About KDE", "@action"), 0, 0, QList(), false }, // Both "Cut" and "Delete" use Shift+Delete, but this is okay; see From 7c672e59c83746bed3eb21b2c9e8e2b0f5ec33ae Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Thu, 18 Jun 2020 17:03:41 +0200 Subject: [PATCH 027/259] Also pass locationType to KConfigSkeleton when construction from group locationType is used to determine where the config file should be saved. If it is not passed on to the KConfigSkeleton constructor, the default (GenericConfigLocation) will be used and any value the application had set will be ignored. --- src/gui/kconfigloader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kconfigloader.cpp b/src/gui/kconfigloader.cpp index 198ef63f..bfc7e9e8 100644 --- a/src/gui/kconfigloader.cpp +++ b/src/gui/kconfigloader.cpp @@ -366,7 +366,7 @@ KConfigLoader::KConfigLoader(KSharedConfigPtr config, QIODevice *xml, QObject *p // but KConfigSkeleton does not currently support this. it will eventually though, // at which point this can be addressed properly KConfigLoader::KConfigLoader(const KConfigGroup &config, QIODevice *xml, QObject *parent) - : KConfigSkeleton(KSharedConfig::openConfig(config.config()->name(), config.config()->openFlags()), parent), + : KConfigSkeleton(KSharedConfig::openConfig(config.config()->name(), config.config()->openFlags(), config.config()->locationType()), parent), d(new ConfigLoaderPrivate) { KConfigGroup group = config.parent(); From d4cd9edd6f90b4e593f4e64af2848dc79fc53fae Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 4 Jul 2020 09:46:46 +0000 Subject: [PATCH 028/259] GIT_SILENT Upgrade ECM and KF5 version requirements for 5.72.0 release. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ac2358d..3a27202a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ set(KF5_VERSION "5.72.0") # handled by release scripts project(KConfig VERSION ${KF5_VERSION}) include(FeatureSummary) -find_package(ECM 5.71.0 NO_MODULE) +find_package(ECM 5.72.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) From 5d73eed1c377001631193e39340558ca8ce735a7 Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Tue, 7 Jul 2020 20:59:51 +0200 Subject: [PATCH 029/259] Use camelcase include. (scripted) --- src/core/kconfig.cpp | 14 +++++++------- src/core/kconfig.h | 2 +- src/core/kconfigini.cpp | 14 +++++++------- src/core/kdesktopfile.cpp | 2 +- src/kconf_update/kconf_update.cpp | 6 +++--- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index 0d430792..0b742a36 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -19,13 +19,13 @@ #include "kconfigbackend_p.h" #include "kconfiggroup.h" -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/core/kconfig.h b/src/core/kconfig.h index 1c9d23d7..ccea1bce 100644 --- a/src/core/kconfig.h +++ b/src/core/kconfig.h @@ -19,7 +19,7 @@ #include #include #include -#include +#include class KConfigGroup; class KEntryMap; diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp index 9601d036..b5f40373 100644 --- a/src/core/kconfigini.cpp +++ b/src/core/kconfigini.cpp @@ -15,13 +15,13 @@ #include "kconfigdata.h" #include "kconfig_core_log_settings.h" -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include #ifndef Q_OS_WIN diff --git a/src/core/kdesktopfile.cpp b/src/core/kdesktopfile.cpp index 73524a59..41f9e818 100644 --- a/src/core/kdesktopfile.cpp +++ b/src/core/kdesktopfile.cpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include "kauthorized.h" #include "kconfig_p.h" diff --git a/src/kconf_update/kconf_update.cpp b/src/kconf_update/kconf_update.cpp index 7c3220f5..1571ea27 100644 --- a/src/kconf_update/kconf_update.cpp +++ b/src/kconf_update/kconf_update.cpp @@ -21,9 +21,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include "kconf_update_debug.h" #include "kconfigutils.h" From 762523d41508aacc26b5d6e1ff0774f2b8728bff Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sun, 12 Jul 2020 21:34:56 +0000 Subject: [PATCH 030/259] GIT_SILENT Upgrade KF5 version to 5.73.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a27202a..b0a568c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.5) -set(KF5_VERSION "5.72.0") # handled by release scripts +set(KF5_VERSION "5.73.0") # handled by release scripts project(KConfig VERSION ${KF5_VERSION}) include(FeatureSummary) From 2f7207fcaa9b228a777fd82908dbf28b9a32d090 Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Mon, 13 Jul 2020 02:27:38 +0200 Subject: [PATCH 031/259] Use KF-standardized Qt logging categories See https://community.kde.org/Frameworks/Frameworks_Logging_Policy --- src/core/CMakeLists.txt | 3 ++- src/kconf_update/CMakeLists.txt | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 65386957..0744409f 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -16,7 +16,8 @@ set(libkconfigcore_SRCS ecm_qt_declare_logging_category(libkconfigcore_SRCS HEADER kconfig_core_log_settings.h IDENTIFIER KCONFIG_CORE_LOG - CATEGORY_NAME kf5.kconfig.core + CATEGORY_NAME kf.config.core + OLD_CATEGORY_NAMES kf5.kconfig.core DESCRIPTION "KConfig Core" EXPORT KCONFIG ) diff --git a/src/kconf_update/CMakeLists.txt b/src/kconf_update/CMakeLists.txt index 32a43251..4a551f59 100644 --- a/src/kconf_update/CMakeLists.txt +++ b/src/kconf_update/CMakeLists.txt @@ -10,7 +10,8 @@ set(kconf_update_SRCS ecm_qt_declare_logging_category(kconf_update_SRCS HEADER kconf_update_debug.h IDENTIFIER KCONF_UPDATE_LOG - CATEGORY_NAME kf5.kconfig.update + CATEGORY_NAME kf.config.kconf_update + OLD_CATEGORY_NAMES kf5.kconfig.update DESCRIPTION "kconf_update" EXPORT KCONFIG ) From 538cf784734434e5478f7b3dab8af131304dd656 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Tue, 14 Jul 2020 05:53:21 +0200 Subject: [PATCH 032/259] SVN_SILENT made messages (.desktop file) - always resolve ours In case of conflict in i18n, keep the version of the branch "ours" To resolve a particular conflict, "git checkout --ours path/to/file.desktop" --- src/core/kconfigbackend.desktop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/kconfigbackend.desktop b/src/core/kconfigbackend.desktop index 56702e15..496eb7b4 100644 --- a/src/core/kconfigbackend.desktop +++ b/src/core/kconfigbackend.desktop @@ -11,7 +11,7 @@ Comment[bg]=Storage backend for KConfig Comment[bn]=KConfig-এর স্টোরেজ ব্যাকেন্ড Comment[bn_IN]=KConfig-র জন্য ব্যবহৃত ব্যাক-এন্ড সংগ্রহস্থল Comment[bs]=Skladišna pozadina za K‑konfig -Comment[ca]=Dorsal d'emmagatzematge pel KConfig +Comment[ca]=Dorsal de l'emmagatzematge per al KConfig Comment[ca@valencia]=Dorsal d'emmagatzematge pel KConfig Comment[cs]=Úložiště pro KConfig Comment[csb]=Zôpisownô zbiérnica dlô KConfig From f0cf93864bd7b72377aebead108dd0da8749ba93 Mon Sep 17 00:00:00 2001 From: David Redondo Date: Fri, 3 Jul 2020 09:20:28 +0200 Subject: [PATCH 033/259] Fix test when build with EXCLUDE_DEPRECATED_BEFORE_AND_AT=CURRENT --- autotests/kstandardshortcuttest.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/autotests/kstandardshortcuttest.cpp b/autotests/kstandardshortcuttest.cpp index 8c4df027..e2447037 100644 --- a/autotests/kstandardshortcuttest.cpp +++ b/autotests/kstandardshortcuttest.cpp @@ -47,6 +47,12 @@ void KStandardShortcutTest::testFindStdAccel() void KStandardShortcutTest::testFindByName() { for (int i = KStandardShortcut::AccelNone + 1; i < KStandardShortcut::StandardShortcutCount; ++i) { +#if !KCONFIGGUI_BUILD_DEPRECATED_SINCE(5, 39) + // building without deprecated enumerator, so have to skip hole in values list + if (i == KStandardShortcut::SaveOptions_DEPRECATED_DO_NOT_USE) { + continue; + } +#endif const auto id = static_cast(i); QCOMPARE(id, KStandardShortcut::findByName(KStandardShortcut::name(id))); } From d1edad3cc4de378e0065933f3bbdce692678a381 Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Fri, 24 Jul 2020 18:49:01 +0200 Subject: [PATCH 034/259] API dox: state explicitly expected encoding for KConfig key & group names While the API might have been once designed to allow random byte strings to be used as ids and only converted QString to UTF-8, the current implementation in many places assumes the byte strings passed via const char* or QByteArray are also in of UTF-8 encoding (or at least ASCII7-only). See e.g. KConfigGroup::entryMap() or KConfigGroup::name(). Stating the supported encoding explicitly should avoid any misassumptions. --- src/core/kconfigbase.h | 94 ++++++++++++++++----- src/core/kconfiggroup.h | 173 ++++++++++++++++++++++++++++++-------- src/core/kconfigwatcher.h | 2 +- 3 files changed, 212 insertions(+), 57 deletions(-) diff --git a/src/core/kconfigbase.h b/src/core/kconfigbase.h index 12a8e875..a4fed200 100644 --- a/src/core/kconfigbase.h +++ b/src/core/kconfigbase.h @@ -81,37 +81,78 @@ class KCONFIGCORE_EXPORT KConfigBase /** * Returns true if the specified group is known about. * - * @param group The group to search for. + * @param group name of group to search for * @return true if the group exists. */ bool hasGroup(const QString &group) const; + /** + * Overload for hasGroup(const QString&) const + * + * @param group name of group to search for, encoded in UTF-8 + */ bool hasGroup(const char *group) const; + /** + * Overload for hasGroup(const QString&) const + * + * @param group name of group to search for, encoded in UTF-8 + */ bool hasGroup(const QByteArray &group) const; /** * Returns an object for the named subgroup. * - * @param group the group to open. Pass a null string on to the KConfig + * @param group the group to open. Pass an empty string here to the KConfig * object to obtain a handle on the root group. - * @return The list of groups. - **/ - KConfigGroup group(const QByteArray &group); + * @return config group object for the given group name. + */ KConfigGroup group(const QString &group); + /** + * Overload for group(const QString&) + * + * @param group name of group, encoded in UTF-8 + */ + KConfigGroup group(const QByteArray &group); + /** + * Overload for group(const QString&) + * + * @param group name of group, encoded in UTF-8 + */ KConfigGroup group(const char *group); /** - * @overload - **/ - const KConfigGroup group(const QByteArray &group) const; + * Const overload for group(const QString&) + */ const KConfigGroup group(const QString &group) const; + /** + * Const overload for group(const QString&) + * + * @param group name of group, encoded in UTF-8 + */ + const KConfigGroup group(const QByteArray &group) const; + /** + * Const overload for group(const QString&) + * + * @param group name of group, encoded in UTF-8 + */ const KConfigGroup group(const char *group) const; /** - * Delete @p aGroup. This marks @p aGroup as @em deleted in the config object. This effectively + * Delete @p group. + * This marks @p group as @em deleted in the config object. This effectively * removes any cascaded values from config files earlier in the stack. */ - void deleteGroup(const QByteArray &group, WriteConfigFlags flags = Normal); void deleteGroup(const QString &group, WriteConfigFlags flags = Normal); + /** + * Overload for deleteGroup(const QString&, WriteConfigFlags) + * + * @param group name of group to delete, encoded in UTF-8 + */ + void deleteGroup(const QByteArray &group, WriteConfigFlags flags = Normal); + /** + * Overload for deleteGroup(const QString&, WriteConfigFlags) + * + * @param group name of group to delete, encoded in UTF-8 + */ void deleteGroup(const char *group, WriteConfigFlags flags = Normal); /** @@ -154,23 +195,38 @@ class KCONFIGCORE_EXPORT KConfigBase virtual bool isImmutable() const = 0; /** - * Can changes be made to the entries in @p aGroup? + * Can changes be made to the entries in @p group? + * + * @param group The group to check for immutability. + * @return @c false if the entries in @p group can be modified, otherwise @c true + */ + bool isGroupImmutable(const QString &group) const; + /** + * Overload for isGroupImmutable(const QString&) const + * + * @param group name of group, encoded in UTF-8 + */ + bool isGroupImmutable(const QByteArray &group) const; + /** + * Overload for isGroupImmutable(const QString&) const * - * @param aGroup The group to check for immutability. - * @return @c false if the entries in @p aGroup can be modified. + * @param group name of group, encoded in UTF-8 */ - bool isGroupImmutable(const QByteArray &aGroup) const; - bool isGroupImmutable(const QString &aGroup) const; - bool isGroupImmutable(const char *aGroup) const; + bool isGroupImmutable(const char *group) const; protected: KConfigBase(); + /// @param group name of group, encoded in UTF-8 virtual bool hasGroupImpl(const QByteArray &group) const = 0; - virtual KConfigGroup groupImpl(const QByteArray &b) = 0; - virtual const KConfigGroup groupImpl(const QByteArray &b) const = 0; + /// @param group name of group, encoded in UTF-8 + virtual KConfigGroup groupImpl(const QByteArray &group) = 0; + /// @param group name of group, encoded in UTF-8 + virtual const KConfigGroup groupImpl(const QByteArray &group) const = 0; + /// @param group name of group, encoded in UTF-8 virtual void deleteGroupImpl(const QByteArray &group, WriteConfigFlags flags = Normal) = 0; - virtual bool isGroupImmutableImpl(const QByteArray &aGroup) const = 0; + /// @param group name of group, encoded in UTF-8 + virtual bool isGroupImmutableImpl(const QByteArray &group) const = 0; /** Virtual hook, used to add new "virtual" functions while maintaining * binary compatibility. Unused in this class. diff --git a/src/core/kconfiggroup.h b/src/core/kconfiggroup.h index bd554c75..620f04c0 100644 --- a/src/core/kconfiggroup.h +++ b/src/core/kconfiggroup.h @@ -51,10 +51,14 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase * This allows the creation of subgroups by passing another * group as @p master. * - * @p group is the group name encoded in UTF-8. + * @param group name of group */ KConfigGroup(KConfigBase *master, const QString &group); - /** Overload for KConfigGroup(KConfigBase*,const QString&) */ + /** + * Overload for KConfigGroup(KConfigBase*,const QString&) + * + * @param group name of group, encoded in UTF-8 + */ KConfigGroup(KConfigBase *master, const char *group); /** @@ -66,12 +70,20 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase * as @p master. */ KConfigGroup(const KConfigBase *master, const QString &group); - /** Overload for KConfigGroup(const KConfigBase*,const QString&) */ + /** + * Overload for KConfigGroup(const KConfigBase*,const QString&) + * + * @param group name of group, encoded in UTF-8 + */ KConfigGroup(const KConfigBase *master, const char *group); /** Overload for KConfigGroup(const KConfigBase*,const QString&) */ KConfigGroup(const QExplicitlySharedDataPointer &master, const QString &group); - /** Overload for KConfigGroup(const KConfigBase*,const QString&) */ + /** + * Overload for KConfigGroup(const KConfigBase*,const QString&) + * + * @param group name of group, encoded in UTF-8 + */ KConfigGroup(const QExplicitlySharedDataPointer &master, const char *group); /** @@ -143,6 +155,8 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase /** * Overload for changeGroup(const QString&) * + * @param group name of group, encoded in UTF-8 + * * @deprecated Since 5.0. * Create another KConfigGroup from the parent of this group instead. */ @@ -237,7 +251,10 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase { return readEntry(key.toUtf8().constData(), aDefault); } - /** Overload for readEntry(const QString&, const T&) const */ + /** + * Overload for readEntry(const QString&, const T&) const + * @param key name of key, encoded in UTF-8 + */ template T readEntry(const char *key, const T &aDefault) const; @@ -251,7 +268,10 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase * @see writeEntry(), deleteEntry(), hasKey() */ QVariant readEntry(const QString &key, const QVariant &aDefault) const; - /** Overload for readEntry(const QString&, const QVariant&) */ + /** + * Overload for readEntry(const QString&, const QVariant&) const + * @param key name of key, encoded in UTF-8 + */ QVariant readEntry(const char *key, const QVariant &aDefault) const; /** @@ -266,12 +286,18 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase * @see readPathEntry(), writeEntry(), deleteEntry(), hasKey() */ QString readEntry(const QString &key, const QString &aDefault) const; - /** Overload for readEntry(const QString&, const QString&) */ + /** + * Overload for readEntry(const QString&, const QString&) const + * @param key name of key, encoded in UTF-8 + */ QString readEntry(const char *key, const QString &aDefault) const; - /** Overload for readEntry(const QString&, const QString&) */ + /** Overload for readEntry(const QString&, const QString&) const */ QString readEntry(const QString &key, const char *aDefault = nullptr) const; - /** Overload for readEntry(const QString&, const QString&) */ + /** + * Overload for readEntry(const QString&, const QString&) const + * @param key name of key, encoded in UTF-8 + */ QString readEntry(const char *key, const char *aDefault = nullptr) const; /** @@ -283,7 +309,10 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase * readEntry(const char*, const QList&) const */ QVariantList readEntry(const QString &key, const QVariantList &aDefault) const; - /** Overload for readEntry(const QString&, const QVariantList&) */ + /** + * Overload for readEntry(const QString&, const QVariantList&) const + * @param key name of key, encoded in UTF-8 + */ QVariantList readEntry(const char *key, const QVariantList &aDefault) const; /** @@ -296,7 +325,10 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase * @see readXdgListEntry(), writeEntry(), deleteEntry(), hasKey() */ QStringList readEntry(const QString &key, const QStringList &aDefault) const; - /** Overload for readEntry(const QString&, const QStringList&) */ + /** + * Overload for readEntry(const QString&, const QStringList&) const + * @param key name of key, encoded in UTF-8 + */ QStringList readEntry(const char *key, const QStringList &aDefault) const; /** @@ -313,7 +345,10 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase { return readEntry(key.toUtf8().constData(), aDefault); } - /** Overload for readEntry(const QString&, const QList&) */ + /** + * Overload for readEntry(const QString&, const QList&) const + * @param key name of key, encoded in UTF-8 + */ template QList readEntry(const char *key, const QList &aDefault) const; @@ -328,8 +363,11 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase * @see readEntry(const QString&, const QStringList&) const */ QStringList readXdgListEntry(const QString &pKey, const QStringList &aDefault = QStringList()) const; - /** Overload for readXdgListEntry(const QString&, const QStringList&) */ - QStringList readXdgListEntry(const char *pKey, const QStringList &aDefault = QStringList()) const; + /** + * Overload for readXdgListEntry(const QString&, const QStringList&) const + * @param key name of key, encoded in UTF-8 + */ + QStringList readXdgListEntry(const char *key, const QStringList &aDefault = QStringList()) const; /** * Reads a path @@ -343,7 +381,10 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase * @return The value for this key. Can be QString() if @p aDefault is null. */ QString readPathEntry(const QString &pKey, const QString &aDefault) const; - /** Overload for readPathEntry(const QString&, const QString&) */ + /** + * Overload for readPathEntry(const QString&, const QString&) const + * @param key name of key, encoded in UTF-8 + */ QString readPathEntry(const char *key, const QString &aDefault) const; /** @@ -358,7 +399,10 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase * @return the list, or @p aDefault if the key does not exist */ QStringList readPathEntry(const QString &pKey, const QStringList &aDefault) const; - /** Overload for readPathEntry(const QString&, const QStringList&) */ + /** + * Overload for readPathEntry(const QString&, const QStringList&) const + * @param key name of key, encoded in UTF-8 + */ QStringList readPathEntry(const char *key, const QStringList &aDefault) const; /** @@ -372,7 +416,10 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase */ QString readEntryUntranslated(const QString &pKey, const QString &aDefault = QString()) const; - /** Overload for readEntryUntranslated(const QString&, const QString&) */ + /** + * Overload for readEntryUntranslated(const QString&, const QString&) const + * @param key name of key, encoded in UTF-8 + */ QString readEntryUntranslated(const char *key, const QString &aDefault = QString()) const; @@ -387,30 +434,45 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase */ void writeEntry(const QString &key, const QVariant &value, WriteConfigFlags pFlags = Normal); - /** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */ + /** + * Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) + * @param key name of key, encoded in UTF-8 + */ void writeEntry(const char *key, const QVariant &value, WriteConfigFlags pFlags = Normal); /** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */ void writeEntry(const QString &key, const QString &value, WriteConfigFlags pFlags = Normal); - /** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */ + /** + * Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) + * @param key name of key, encoded in UTF-8 + */ void writeEntry(const char *key, const QString &value, WriteConfigFlags pFlags = Normal); /** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */ void writeEntry(const QString &key, const QByteArray &value, WriteConfigFlags pFlags = Normal); - /** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */ + /** + * Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) + * @param key name of key, encoded in UTF-8 + */ void writeEntry(const char *key, const QByteArray &value, WriteConfigFlags pFlags = Normal); /** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */ void writeEntry(const QString &key, const char *value, WriteConfigFlags pFlags = Normal); - /** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */ + /** + * Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) + * @param key name of key, encoded in UTF-8 + */ void writeEntry(const char *key, const char *value, WriteConfigFlags pFlags = Normal); - /** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */ + /** + * Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) + * @param key name of key, encoded in UTF-8 + */ template void writeEntry(const char *key, const T &value, WriteConfigFlags pFlags = Normal); /** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */ @@ -423,14 +485,20 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase /** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */ void writeEntry(const QString &key, const QStringList &value, WriteConfigFlags pFlags = Normal); - /** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */ + /** + * Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) + * @param key name of key, encoded in UTF-8 + */ void writeEntry(const char *key, const QStringList &value, WriteConfigFlags pFlags = Normal); /** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */ void writeEntry(const QString &key, const QVariantList &value, WriteConfigFlags pFlags = Normal); - /** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */ + /** + * Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) + * @param key name of key, encoded in UTF-8 + */ void writeEntry(const char *key, const QVariantList &value, WriteConfigFlags pFlags = Normal); @@ -440,7 +508,10 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase { writeEntry(key.toUtf8().constData(), value, pFlags); } - /** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */ + /** + * Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) + * @param key name of key, encoded in UTF-8 + */ template void writeEntry(const char *key, const QList &value, WriteConfigFlags pFlags = Normal); @@ -456,8 +527,11 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase */ void writeXdgListEntry(const QString &pKey, const QStringList &value, WriteConfigFlags pFlags = Normal); - /** Overload for writeXdgListEntry(const QString&, const QStringList&, WriteConfigFlags) */ - void writeXdgListEntry(const char *pKey, const QStringList &value, + /** + * Overload for writeXdgListEntry(const QString&, const QStringList&, WriteConfigFlags) + * @param key name of key, encoded in UTF-8 + */ + void writeXdgListEntry(const char *key, const QStringList &value, WriteConfigFlags pFlags = Normal); /** @@ -475,8 +549,11 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase */ void writePathEntry(const QString &pKey, const QString &path, WriteConfigFlags pFlags = Normal); - /** Overload for writePathEntry(const QString&, const QString&, WriteConfigFlags) */ - void writePathEntry(const char *pKey, const QString &path, + /** + * Overload for writePathEntry(const QString&, const QString&, WriteConfigFlags) + * @param key name of key, encoded in UTF-8 + */ + void writePathEntry(const char *Key, const QString &path, WriteConfigFlags pFlags = Normal); /** @@ -494,8 +571,11 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase */ void writePathEntry(const QString &pKey, const QStringList &value, WriteConfigFlags pFlags = Normal); - /** Overload for writePathEntry(const QString&, const QStringList&, WriteConfigFlags) */ - void writePathEntry(const char *pKey, const QStringList &value, + /** + * Overload for writePathEntry(const QString&, const QStringList&, WriteConfigFlags) + * @param key name of key, encoded in UTF-8 + */ + void writePathEntry(const char *key, const QStringList &value, WriteConfigFlags pFlags = Normal); /** @@ -509,8 +589,11 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase * @see deleteGroup(), readEntry(), writeEntry() */ void deleteEntry(const QString &pKey, WriteConfigFlags pFlags = Normal); - /** Overload for deleteEntry(const QString&, WriteConfigFlags) */ - void deleteEntry(const char *pKey, WriteConfigFlags pFlags = Normal); + /** + * Overload for deleteEntry(const QString&, WriteConfigFlags) + * @param key name of key, encoded in UTF-8 + */ + void deleteEntry(const char *key, WriteConfigFlags pFlags = Normal); /** * Checks whether the key has an entry in this group @@ -528,7 +611,10 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase * @see readEntry() */ bool hasKey(const QString &key) const; - /** Overload for hasKey(const QString&) const */ + /** + * Overload for hasKey(const QString&) const + * @param key name of key, encoded in UTF-8 + */ bool hasKey(const char *key) const; /** @@ -549,7 +635,10 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase * group object, @c true otherwise */ bool isEntryImmutable(const QString &key) const; - /** Overload for isEntryImmutable(const QString&) const */ + /** + * Overload for isEntryImmutable(const QString&) const + * @param key name of key, encoded in UTF-8 + */ bool isEntryImmutable(const char *key) const; /** @@ -572,9 +661,16 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase void revertToDefault(const QString &key); void revertToDefault(const QString &key, WriteConfigFlags pFlag); - /** Overload for revertToDefault(const QString&) */ // TODO KF6 merge with the other one + /** + * Overload for revertToDefault(const QString&) + * @param key name of key, encoded in UTF-8 + */ void revertToDefault(const char *key); + /** + * Overload for revertToDefault(const QString&, WriteConfigFlags) + * @param key name of key, encoded in UTF-8 + */ void revertToDefault(const char *key, WriteConfigFlags pFlag); /** @@ -605,7 +701,10 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase * for @p key in this group, @c false otherwise */ bool hasDefault(const QString &key) const; - /** Overload for hasDefault(const QString&) const */ + /** + * Overload for hasDefault(const QString&) const + * @param key name of key, encoded in UTF-8 + */ bool hasDefault(const char *key) const; /** diff --git a/src/core/kconfigwatcher.h b/src/core/kconfigwatcher.h index 75612831..28576bb4 100644 --- a/src/core/kconfigwatcher.h +++ b/src/core/kconfigwatcher.h @@ -50,7 +50,7 @@ class KCONFIGCORE_EXPORT KConfigWatcher: public QObject * The config will be reloaded before this signal is emitted * * @arg group the config group that has changed - * @arg names a list of entries that have changed within that group + * @arg names a list of entries that have changed within that group (UTF-8 encoded) */ void configChanged(const KConfigGroup &group, const QByteArrayList &names); From 7c96cf22f148d47317a21b1c73de84708c6ffab1 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Sat, 25 Jul 2020 09:43:29 +0000 Subject: [PATCH 035/259] Update sGlobalFileName when QStandardPaths TestMode is toggled When running unit tests, usually QStandardPaths TestMode is enabled so as not to mess up the config files in the home dir of the dev running the unit tests; sGlobalFileName, a global static, was defined only once, which meant that if KSharedConfig::openConfig() is called before the unit test has had a chance to call QStandardPaths::setTestModeEnabled(true), then sGlobalFileName will go on referring to the wrong kdeglobals file (as can be seen in dfaure's debugging of the issue at [1]). Change the code so as to detect QStandardPaths TestMode status and change sGlobalFileName as needed. All unit tests still pass. [1] https://invent.kde.org/frameworks/kio/-/merge_requests/77#note_74124 --- src/core/kconfig.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index 0b742a36..d9232fa5 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -39,6 +39,9 @@ bool KConfigPrivate::mappingsRegistered = false; +// For caching purposes +static bool s_wasTestModeEnabled = false; + Q_GLOBAL_STATIC(QStringList, s_globalFiles) // For caching purposes. static QBasicMutex s_globalFilesMutex; Q_GLOBAL_STATIC_WITH_ARGS(QString, sGlobalFileName, (QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1String("/kdeglobals"))) @@ -56,6 +59,14 @@ KConfigPrivate::KConfigPrivate(KConfig::OpenFlags flags, bFileImmutable(false), bForceGlobal(false), bSuppressGlobal(false), configState(KConfigBase::NoAccess) { + const bool isTestMode = QStandardPaths::isTestModeEnabled(); + // If sGlobalFileName was initialised and testMode has been toggled, + // sGlobalFileName may need to be updated to point to the correct kdeglobals file + if (sGlobalFileName.exists() && s_wasTestModeEnabled != isTestMode) { + s_wasTestModeEnabled = isTestMode; + *sGlobalFileName = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1String("/kdeglobals"); + } + static QBasicAtomicInt use_etc_kderc = Q_BASIC_ATOMIC_INITIALIZER(-1); #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) if (use_etc_kderc.load() < 0) { From 3e5e2ea59ea66ffaa5eff81a6f220c8469f19733 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 1 Aug 2020 17:01:50 +0000 Subject: [PATCH 036/259] GIT_SILENT Upgrade ECM and KF5 version requirements for 5.73.0 release. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b0a568c0..176c2212 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ set(KF5_VERSION "5.73.0") # handled by release scripts project(KConfig VERSION ${KF5_VERSION}) include(FeatureSummary) -find_package(ECM 5.72.0 NO_MODULE) +find_package(ECM 5.73.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) From 1434257972de28f183e701cb7da3bd333fa71f3c Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Wed, 29 Jul 2020 21:22:22 -0600 Subject: [PATCH 037/259] Add functions to save and restore window positions on non-Wayland platforms These functions allow an application to save and restore the positions of its windows. Positions are stored on a per-screen-arrangement basis. For example with a single screen connected, the config file would have entries like this in it: eDP-1 XPosition=140 eDP-1 YPosition=340 When a second screen is connected, the following gets saved: eDP-1 HDMI-1 XPosition=3878 eDP-1 HDMI-1 YPosition=29 This ensures that each separate screen arrangement can have its own saved window position, which is handy for the use case where you have a laptop that you plug into an external screen some of the time. It also allows the position to get restored to the correct screen when there are multiple screens. This is a necessary first step to getting KDE apps to save their window positions on X11 The next step would be calling the new functions from KXMLGui and Kirigami apps, and then porting all apps that manually invoke KWindowConfig::saveWindowSize() and KWindowConfig::restoreWindowSize() to also invoke KWindowConfig::saveWindowPosition() and KWindowConfig::restoreWindowPosition() in the same places. The functions only work on X11 or other non-Wayland platforms. On Wayland, the compositor has sole dominion over window positioning so a compositor-specific solution much be adopted instead, such as https://bugs.kde.org/show_bug.cgi?id=15329. CCBUG: 415150 --- src/gui/kwindowconfig.cpp | 58 +++++++++++++++++++++++++++++++++++++++ src/gui/kwindowconfig.h | 27 ++++++++++++++++++ 2 files changed, 85 insertions(+) diff --git a/src/gui/kwindowconfig.cpp b/src/gui/kwindowconfig.cpp index 2f787a2f..07f1a307 100644 --- a/src/gui/kwindowconfig.cpp +++ b/src/gui/kwindowconfig.cpp @@ -7,6 +7,7 @@ #include "kwindowconfig.h" +#include #include #include @@ -71,3 +72,60 @@ void KWindowConfig::restoreWindowSize(QWindow *window, const KConfigGroup &confi window->setWindowState(Qt::WindowMaximized); } } + +void KWindowConfig::saveWindowPosition(const QWindow *window, KConfigGroup &config, KConfigGroup::WriteConfigFlags options) +{ + // On Wayland, the compositor is solely responsible for window positioning, + // So this needs to be a no-op + if (!window || QGuiApplication::platformName() == QStringLiteral("wayland")) { + return; + } + + // Prepend the names of all connected screens so that we save the position + // on a per-screen-arrangement basis, since people often like to have + // windows positioned differently depending on their screen arrangements + QStringList names; + const auto screens = QGuiApplication::screens(); + names.reserve(screens.length()); + for (auto screen : screens) { + names << screen->name(); + } + const QString allScreens = names.join(QStringLiteral(" ")); + config.writeEntry(allScreens + QStringLiteral(" XPosition"), window->x(), options); + config.writeEntry(allScreens + QStringLiteral(" YPosition"), window->y(), options); +} + +void KWindowConfig::restoreWindowPosition(QWindow *window, const KConfigGroup &config) +{ + // On Wayland, the compositor is solely responsible for window positioning, + // So this needs to be a no-op + if (!window || QGuiApplication::platformName() == QStringLiteral("wayland")) { + return; + } + + const QRect desk = window->screen()->geometry(); + const bool isMaximized = config.readEntry(QStringLiteral("Window-Maximized %1x%2").arg(desk.height()).arg(desk.width()), false); + + // Don't need to restore position if the window was maximized + if (isMaximized) { + window->setWindowState(Qt::WindowMaximized); + return; + } + + QStringList names; + const auto screens = QGuiApplication::screens(); + names.reserve(screens.length()); + for (auto screen : screens) { + names << screen->name(); + } + const QString allScreens = names.join(QStringLiteral(" ")); + const int xPos = config.readEntry(allScreens + QStringLiteral(" XPosition"), -1); + const int yPos = config.readEntry(allScreens + QStringLiteral(" YPosition"), -1); + + if (xPos == -1 || yPos == -1) { + return; + } + + window->setX(xPos); + window->setY(yPos); +} diff --git a/src/gui/kwindowconfig.h b/src/gui/kwindowconfig.h index ad03f3ef..04af27d1 100644 --- a/src/gui/kwindowconfig.h +++ b/src/gui/kwindowconfig.h @@ -55,6 +55,33 @@ KCONFIGGUI_EXPORT void saveWindowSize(const QWindow *window, KConfigGroup &confi * @since 5.0. */ KCONFIGGUI_EXPORT void restoreWindowSize(QWindow *window, const KConfigGroup &config); + +/** + * Saves the window's position either to the global or application config file. + * This function has no effect on Wayland, where the compositor is responsible + * for window positioning. + * + * @note the group must be set before calling + * + * @param window The window whose position to save. + * @param config The config group to read from. + * @param options passed to KConfigGroup::writeEntry() + * @since 5.74 + */ +KCONFIGGUI_EXPORT void saveWindowPosition(const QWindow *window, KConfigGroup &config, KConfigGroup::WriteConfigFlags options = KConfigGroup::Normal); + +/** + * Restores the window's position from the configuration. + * This function has no effect on Wayland, where the compositor is responsible + * for window positioning. + * + * @note the group must be set before calling + * + * @param window The window whose position to restore. + * @param config The config group to read from. + * @since 5.74 + */ +KCONFIGGUI_EXPORT void restoreWindowPosition(QWindow *window, const KConfigGroup &config); } #endif // KWINDOWCONFIG_H From bc25027aeb0fad8de48d47a87cf3101e8e4304f6 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 8 Aug 2020 10:12:05 +0000 Subject: [PATCH 038/259] GIT_SILENT Upgrade KF5 version to 5.74.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 176c2212..862d7366 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.5) -set(KF5_VERSION "5.73.0") # handled by release scripts +set(KF5_VERSION "5.74.0") # handled by release scripts project(KConfig VERSION ${KF5_VERSION}) include(FeatureSummary) From 45d8532f09fbefa14cfaf4d76b7a9672d27e104f Mon Sep 17 00:00:00 2001 From: Cyril Rossi Date: Thu, 9 Jul 2020 18:30:16 +0200 Subject: [PATCH 039/259] Add documentation for ParentInConstructor option --- src/kconfig_compiler/README.dox | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/kconfig_compiler/README.dox b/src/kconfig_compiler/README.dox index 55e59736..bf72f3eb 100644 --- a/src/kconfig_compiler/README.dox +++ b/src/kconfig_compiler/README.dox @@ -245,6 +245,15 @@ The following options are read from the kcfgc file: and the Q_OBJECT macro will be added to the generated class. Note that you will also need to pass the GENERATE_MOC option to the kconfig_add_kcfg_files macro. + + ParentInConstructor + bool + false + If set to true, the generated constructor will take an additional QObject* parameter that will be used as the object's parent. + This is useful when working with KQuickAddons::ManagedConfigModule to set it as the parent of the generated class to allow automatic settings discovery and handle the deallocation. + Note this parameter is incompatible with Singleton set to true. + + From c032237955343f4a9c8ba67434dc4198d1ceece2 Mon Sep 17 00:00:00 2001 From: David Redondo Date: Fri, 3 Jul 2020 09:23:56 +0200 Subject: [PATCH 040/259] Categorize standard shortcuts We have a huge amount of standard shortcuts. By adding the ability to divide them into categories, they can be presented to the user in a way that enables them to easier find the shortcut that they want. Internally some shortcuts were already grouped but that seems to have stopped for the later additions. (The related standard actions from KConfigWidgets also seem to have this not exposed internal grouping.) See plasma-desktop!26 --- src/gui/kstandardshortcut.cpp | 192 ++++++++++++++++++---------------- src/gui/kstandardshortcut.h | 20 ++++ 2 files changed, 120 insertions(+), 92 deletions(-) diff --git a/src/gui/kstandardshortcut.cpp b/src/gui/kstandardshortcut.cpp index 3e9d35d6..a91a2397 100644 --- a/src/gui/kstandardshortcut.cpp +++ b/src/gui/kstandardshortcut.cpp @@ -42,6 +42,9 @@ struct KStandardShortcutInfo { //! If this struct is initialized. If not initialized @cut is not valid bool isInitialized; + + // Category of this Shortcut + Category category; }; #define CTRL(x) Qt::CTRL+Qt::Key_##x @@ -58,118 +61,118 @@ struct KStandardShortcutInfo { // Read the comments of the big enum in kstandardshortcut.h before you change anything! static KStandardShortcutInfo g_infoStandardShortcut[] = { //Group File, - { AccelNone, nullptr, {nullptr, nullptr}, 0, 0, QList(), false }, - { Open, "Open", QT_TRANSLATE_NOOP3("KStandardShortcut", "Open", "@action"), CTRL(O), 0, QList(), false }, - { New, "New", QT_TRANSLATE_NOOP3("KStandardShortcut", "New", "@action"), CTRL(N), 0, QList(), false }, - { Close, "Close", QT_TRANSLATE_NOOP3("KStandardShortcut", "Close", "@action"), CTRL(W), CTRL(Escape), QList(), false }, - { Save, "Save", QT_TRANSLATE_NOOP3("KStandardShortcut", "Save", "@action"), CTRL(S), 0, QList(), false }, - { Print, "Print", QT_TRANSLATE_NOOP3("KStandardShortcut", "Print", "@action"), CTRL(P), 0, QList(), false }, - { Quit, "Quit", QT_TRANSLATE_NOOP3("KStandardShortcut", "Quit", "@action"), CTRL(Q), 0, QList(), false }, + { AccelNone, nullptr, {nullptr, nullptr}, 0, 0, QList(), false, Category::InvalidCategory }, + { Open, "Open", QT_TRANSLATE_NOOP3("KStandardShortcut", "Open", "@action"), CTRL(O), 0, QList(), false, Category::File }, + { New, "New", QT_TRANSLATE_NOOP3("KStandardShortcut", "New", "@action"), CTRL(N), 0, QList(), false, Category::File }, + { Close, "Close", QT_TRANSLATE_NOOP3("KStandardShortcut", "Close", "@action"), CTRL(W), CTRL(Escape), QList(), false, Category::File }, + { Save, "Save", QT_TRANSLATE_NOOP3("KStandardShortcut", "Save", "@action"), CTRL(S), 0, QList(), false, Category::File }, + { Print, "Print", QT_TRANSLATE_NOOP3("KStandardShortcut", "Print", "@action"), CTRL(P), 0, QList(), false, Category::File }, + { Quit, "Quit", QT_TRANSLATE_NOOP3("KStandardShortcut", "Quit", "@action"), CTRL(Q), 0, QList(), false, Category::Navigation }, //Group Edit - { Undo, "Undo", QT_TRANSLATE_NOOP3("KStandardShortcut", "Undo", "@action"), CTRL(Z), 0, QList(), false }, - { Redo, "Redo", QT_TRANSLATE_NOOP3("KStandardShortcut", "Redo", "@action"), CTRLSHIFT(Z), 0, QList(), false }, + { Undo, "Undo", QT_TRANSLATE_NOOP3("KStandardShortcut", "Undo", "@action"), CTRL(Z), 0, QList(), false, Category::Edit }, + { Redo, "Redo", QT_TRANSLATE_NOOP3("KStandardShortcut", "Redo", "@action"), CTRLSHIFT(Z), 0, QList(), false, Category::Edit }, // Both "Cut" and "Delete" use Shift+Delete, but this is okay; see // https://commits.kde.org/kxmlgui/8eabbf6725386e716b7536c71a9181dfe5d959f0 - { Cut, "Cut", QT_TRANSLATE_NOOP3("KStandardShortcut", "Cut", "@action"), CTRL(X), SHIFT(Delete), QList(), false }, - { Copy, "Copy", QT_TRANSLATE_NOOP3("KStandardShortcut", "Copy", "@action"), CTRL(C), CTRL(Insert), QList(), false }, - { Paste, "Paste", QT_TRANSLATE_NOOP3("KStandardShortcut", "Paste", "@action"), CTRL(V), SHIFT(Insert), QList(), false }, - { PasteSelection, "Paste Selection", QT_TRANSLATE_NOOP3("KStandardShortcut", "Paste Selection", "@action"), CTRLSHIFT(Insert), 0, QList(), false }, + { Cut, "Cut", QT_TRANSLATE_NOOP3("KStandardShortcut", "Cut", "@action"), CTRL(X), SHIFT(Delete), QList(), false, Category::Edit }, + { Copy, "Copy", QT_TRANSLATE_NOOP3("KStandardShortcut", "Copy", "@action"), CTRL(C), CTRL(Insert), QList(), false, Category::Edit}, + { Paste, "Paste", QT_TRANSLATE_NOOP3("KStandardShortcut", "Paste", "@action"), CTRL(V), SHIFT(Insert), QList(), false, Category::Edit }, + { PasteSelection, "Paste Selection", QT_TRANSLATE_NOOP3("KStandardShortcut", "Paste Selection", "@action"), CTRLSHIFT(Insert), 0, QList(), false, Category::Edit }, - { SelectAll, "SelectAll", QT_TRANSLATE_NOOP3("KStandardShortcut", "Select All", "@action"), CTRL(A), 0, QList(), false }, - { Deselect, "Deselect", QT_TRANSLATE_NOOP3("KStandardShortcut", "Deselect", "@action"), CTRLSHIFT(A), 0, QList(), false }, - { DeleteWordBack, "DeleteWordBack", QT_TRANSLATE_NOOP3("KStandardShortcut", "Delete Word Backwards", "@action"), CTRL(Backspace), 0, QList(), false }, - { DeleteWordForward, "DeleteWordForward", QT_TRANSLATE_NOOP3("KStandardShortcut", "Delete Word Forward", "@action"), CTRL(Delete), 0, QList(), false }, + { SelectAll, "SelectAll", QT_TRANSLATE_NOOP3("KStandardShortcut", "Select All", "@action"), CTRL(A), 0, QList(), false, Category::Edit }, + { Deselect, "Deselect", QT_TRANSLATE_NOOP3("KStandardShortcut", "Deselect", "@action"), CTRLSHIFT(A), 0, QList(), false, Category::Edit }, + { DeleteWordBack, "DeleteWordBack", QT_TRANSLATE_NOOP3("KStandardShortcut", "Delete Word Backwards", "@action"), CTRL(Backspace), 0, QList(), false, Category::Edit }, + { DeleteWordForward, "DeleteWordForward", QT_TRANSLATE_NOOP3("KStandardShortcut", "Delete Word Forward", "@action"), CTRL(Delete), 0, QList(), false, Category::Edit }, - { Find, "Find", QT_TRANSLATE_NOOP3("KStandardShortcut", "Find", "@action"), CTRL(F), 0, QList(), false }, - { FindNext, "FindNext", QT_TRANSLATE_NOOP3("KStandardShortcut", "Find Next", "@action"), Qt::Key_F3, 0, QList(), false }, - { FindPrev, "FindPrev", QT_TRANSLATE_NOOP3("KStandardShortcut", "Find Prev", "@action"), SHIFT(F3), 0, QList(), false }, - { Replace, "Replace", QT_TRANSLATE_NOOP3("KStandardShortcut", "Replace", "@action"), CTRL(R), 0, QList(), false }, + { Find, "Find", QT_TRANSLATE_NOOP3("KStandardShortcut", "Find", "@action"), CTRL(F), 0, QList(), false, Category::Edit }, + { FindNext, "FindNext", QT_TRANSLATE_NOOP3("KStandardShortcut", "Find Next", "@action"), Qt::Key_F3, 0, QList(), false, Category::Edit }, + { FindPrev, "FindPrev", QT_TRANSLATE_NOOP3("KStandardShortcut", "Find Prev", "@action"), SHIFT(F3), 0, QList(), false, Category::Edit }, + { Replace, "Replace", QT_TRANSLATE_NOOP3("KStandardShortcut", "Replace", "@action"), CTRL(R), 0, QList(), false, Category::Edit }, //Group Navigation - { Home, "Home", QT_TRANSLATE_NOOP3("KStandardShortcut", "Home", "@action Go to main page"), ALT(Home), Qt::Key_HomePage, QList(), false }, - { Begin, "Begin", QT_TRANSLATE_NOOP3("KStandardShortcut", "Begin", "@action Beginning of document"), CTRL(Home), 0, QList(), false }, - { End, "End", QT_TRANSLATE_NOOP3("KStandardShortcut", "End", "@action End of document"), CTRL(End), 0, QList(), false }, - { Prior, "Prior", QT_TRANSLATE_NOOP3("KStandardShortcut", "Prior", "@action"), Qt::Key_PageUp, 0, QList(), false }, - { Next, "Next", QT_TRANSLATE_NOOP3("KStandardShortcut", "Next", "@action Opposite to Prior"), Qt::Key_PageDown, 0, QList(), false }, - - { Up, "Up", QT_TRANSLATE_NOOP3("KStandardShortcut", "Up", "@action"), ALT(Up), 0, QList(), false }, - { Back, "Back", QT_TRANSLATE_NOOP3("KStandardShortcut", "Back", "@action"), ALT(Left), Qt::Key_Back, QList(), false }, - { Forward, "Forward", QT_TRANSLATE_NOOP3("KStandardShortcut", "Forward", "@action"), ALT(Right), Qt::Key_Forward, QList(), false }, - { Reload, "Reload", QT_TRANSLATE_NOOP3("KStandardShortcut", "Reload", "@action"), Qt::Key_F5, Qt::Key_Refresh, QList(), false }, - - { BeginningOfLine, "BeginningOfLine", QT_TRANSLATE_NOOP3("KStandardShortcut", "Beginning of Line", "@action"), Qt::Key_Home, 0, QList(), false }, - { EndOfLine, "EndOfLine", QT_TRANSLATE_NOOP3("KStandardShortcut", "End of Line", "@action"), Qt::Key_End, 0, QList(), false }, - { GotoLine, "GotoLine", QT_TRANSLATE_NOOP3("KStandardShortcut", "Go to Line", "@action"), CTRL(G), 0, QList(), false }, - { BackwardWord, "BackwardWord", QT_TRANSLATE_NOOP3("KStandardShortcut", "Backward Word", "@action"), CTRL(Left), 0, QList(), false }, - { ForwardWord, "ForwardWord", QT_TRANSLATE_NOOP3("KStandardShortcut", "Forward Word", "@action"), CTRL(Right), 0, QList(), false }, - - { AddBookmark, "AddBookmark", QT_TRANSLATE_NOOP3("KStandardShortcut", "Add Bookmark", "@action"), CTRL(B), 0, QList(), false }, - { ZoomIn, "ZoomIn", QT_TRANSLATE_NOOP3("KStandardShortcut", "Zoom In", "@action"), CTRL(Plus), CTRL(Equal), QList(), false }, - { ZoomOut, "ZoomOut", QT_TRANSLATE_NOOP3("KStandardShortcut", "Zoom Out", "@action"), CTRL(Minus), 0, QList(), false }, - { FullScreen, "FullScreen", QT_TRANSLATE_NOOP3("KStandardShortcut", "Full Screen Mode", "@action"), CTRLSHIFT(F), 0, QList(), false }, - - { ShowMenubar, "ShowMenubar", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show Menu Bar", "@action"), CTRL(M), 0, QList(), false }, - { TabNext, "Activate Next Tab", QT_TRANSLATE_NOOP3("KStandardShortcut", "Activate Next Tab", "@action"), CTRL(PageDown), CTRL(BracketRight), QList(), false }, - { TabPrev, "Activate Previous Tab", QT_TRANSLATE_NOOP3("KStandardShortcut", "Activate Previous Tab", "@action"), CTRL(PageUp), CTRL(BracketLeft), QList(), false }, + { Home, "Home", QT_TRANSLATE_NOOP3("KStandardShortcut", "Home", "@action Go to main page"), ALT(Home), Qt::Key_HomePage, QList(), false, Category::Navigation }, + { Begin, "Begin", QT_TRANSLATE_NOOP3("KStandardShortcut", "Begin", "@action Beginning of document"), CTRL(Home), 0, QList(), false, Category::Navigation }, + { End, "End", QT_TRANSLATE_NOOP3("KStandardShortcut", "End", "@action End of document"), CTRL(End), 0, QList(), false, Category::Navigation }, + { Prior, "Prior", QT_TRANSLATE_NOOP3("KStandardShortcut", "Prior", "@action"), Qt::Key_PageUp, 0, QList(), false, Category::Navigation }, + { Next, "Next", QT_TRANSLATE_NOOP3("KStandardShortcut", "Next", "@action Opposite to Prior"), Qt::Key_PageDown, 0, QList(), false, Category::Navigation }, + + { Up, "Up", QT_TRANSLATE_NOOP3("KStandardShortcut", "Up", "@action"), ALT(Up), 0, QList(), false, Category::Navigation }, + { Back, "Back", QT_TRANSLATE_NOOP3("KStandardShortcut", "Back", "@action"), ALT(Left), Qt::Key_Back, QList(), false, Category::Navigation }, + { Forward, "Forward", QT_TRANSLATE_NOOP3("KStandardShortcut", "Forward", "@action"), ALT(Right), Qt::Key_Forward, QList(), false, Category::Navigation }, + { Reload, "Reload", QT_TRANSLATE_NOOP3("KStandardShortcut", "Reload", "@action"), Qt::Key_F5, Qt::Key_Refresh, QList(), false, Category::Navigation }, + + { BeginningOfLine, "BeginningOfLine", QT_TRANSLATE_NOOP3("KStandardShortcut", "Beginning of Line", "@action"), Qt::Key_Home, 0, QList(), false, Category::Navigation }, + { EndOfLine, "EndOfLine", QT_TRANSLATE_NOOP3("KStandardShortcut", "End of Line", "@action"), Qt::Key_End, 0, QList(), false, Category::Navigation }, + { GotoLine, "GotoLine", QT_TRANSLATE_NOOP3("KStandardShortcut", "Go to Line", "@action"), CTRL(G), 0, QList(), false, Category::Navigation }, + { BackwardWord, "BackwardWord", QT_TRANSLATE_NOOP3("KStandardShortcut", "Backward Word", "@action"), CTRL(Left), 0, QList(), false, Category::Navigation }, + { ForwardWord, "ForwardWord", QT_TRANSLATE_NOOP3("KStandardShortcut", "Forward Word", "@action"), CTRL(Right), 0, QList(), false, Category::Navigation }, + + { AddBookmark, "AddBookmark", QT_TRANSLATE_NOOP3("KStandardShortcut", "Add Bookmark", "@action"), CTRL(B), 0, QList(), false, Category::Navigation }, + { ZoomIn, "ZoomIn", QT_TRANSLATE_NOOP3("KStandardShortcut", "Zoom In", "@action"), CTRL(Plus), CTRL(Equal), QList(), false, Category::View }, + { ZoomOut, "ZoomOut", QT_TRANSLATE_NOOP3("KStandardShortcut", "Zoom Out", "@action"), CTRL(Minus), 0, QList(), false, Category::View }, + { FullScreen, "FullScreen", QT_TRANSLATE_NOOP3("KStandardShortcut", "Full Screen Mode", "@action"), CTRLSHIFT(F), 0, QList(), false, Category::View }, + + { ShowMenubar, "ShowMenubar", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show Menu Bar", "@action"), CTRL(M), 0, QList(), false, Category::View }, + { TabNext, "Activate Next Tab", QT_TRANSLATE_NOOP3("KStandardShortcut", "Activate Next Tab", "@action"), CTRL(PageDown), CTRL(BracketRight), QList(), false, Category::Navigation }, + { TabPrev, "Activate Previous Tab", QT_TRANSLATE_NOOP3("KStandardShortcut", "Activate Previous Tab", "@action"), CTRL(PageUp), CTRL(BracketLeft), QList(), false, Category::Navigation }, //Group Help - { Help, "Help", QT_TRANSLATE_NOOP3("KStandardShortcut", "Help", "@action"), Qt::Key_F1, 0, QList(), false }, - { WhatsThis, "WhatsThis", QT_TRANSLATE_NOOP3("KStandardShortcut", "What's This", "@action"), SHIFT(F1), 0, QList(), false }, + { Help, "Help", QT_TRANSLATE_NOOP3("KStandardShortcut", "Help", "@action"), Qt::Key_F1, 0, QList(), false, Category::Help }, + { WhatsThis, "WhatsThis", QT_TRANSLATE_NOOP3("KStandardShortcut", "What's This", "@action"), SHIFT(F1), 0, QList(), false, Category::Help }, //Group TextCompletion - { TextCompletion, "TextCompletion", QT_TRANSLATE_NOOP3("KStandardShortcut", "Text Completion", "@action"), CTRL(E), 0, QList(), false }, - { PrevCompletion, "PrevCompletion", QT_TRANSLATE_NOOP3("KStandardShortcut", "Previous Completion Match", "@action"), CTRL(Up), 0, QList(), false }, - { NextCompletion, "NextCompletion", QT_TRANSLATE_NOOP3("KStandardShortcut", "Next Completion Match", "@action"), CTRL(Down), 0, QList(), false }, - { SubstringCompletion, "SubstringCompletion", QT_TRANSLATE_NOOP3("KStandardShortcut", "Substring Completion", "@action"), CTRL(T), 0, QList(), false }, - - { RotateUp, "RotateUp", QT_TRANSLATE_NOOP3("KStandardShortcut", "Previous Item in List", "@action"), Qt::Key_Up, 0, QList(), false }, - { RotateDown, "RotateDown", QT_TRANSLATE_NOOP3("KStandardShortcut", "Next Item in List", "@action"), Qt::Key_Down, 0, QList(), false }, - - { OpenRecent, "OpenRecent", QT_TRANSLATE_NOOP3("KStandardShortcut", "Open Recent", "@action"), 0, 0, QList(), false }, - { SaveAs, "SaveAs", QT_TRANSLATE_NOOP3("KStandardShortcut", "Save As", "@action"), CTRLSHIFT(S), 0, QList(), false }, - { Revert, "Revert", QT_TRANSLATE_NOOP3("KStandardShortcut", "Revert", "@action"), 0, 0, QList(), false }, - { PrintPreview, "PrintPreview", QT_TRANSLATE_NOOP3("KStandardShortcut", "Print Preview", "@action"), 0, 0, QList(), false }, - { Mail, "Mail", QT_TRANSLATE_NOOP3("KStandardShortcut", "Mail", "@action"), 0, 0, QList(), false }, - { Clear, "Clear", QT_TRANSLATE_NOOP3("KStandardShortcut", "Clear", "@action"), 0, 0, QList(), false }, - { ActualSize, "ActualSize", QT_TRANSLATE_NOOP3("KStandardShortcut", "Actual Size", "@action"), CTRL(0), 0, QList(), false }, - { FitToPage, "FitToPage", QT_TRANSLATE_NOOP3("KStandardShortcut", "Fit To Page", "@action"), 0, 0, QList(), false }, - { FitToWidth, "FitToWidth", QT_TRANSLATE_NOOP3("KStandardShortcut", "Fit To Width", "@action"), 0, 0, QList(), false }, - { FitToHeight, "FitToHeight", QT_TRANSLATE_NOOP3("KStandardShortcut", "Fit To Height", "@action"), 0, 0, QList(), false }, - { Zoom, "Zoom", QT_TRANSLATE_NOOP3("KStandardShortcut", "Zoom", "@action"), 0, 0, QList(), false }, - { Goto, "Goto", QT_TRANSLATE_NOOP3("KStandardShortcut", "Goto", "@action"), 0, 0, QList(), false }, - { GotoPage, "GotoPage", QT_TRANSLATE_NOOP3("KStandardShortcut", "Goto Page", "@action"), 0, 0, QList(), false }, - { DocumentBack, "DocumentBack", QT_TRANSLATE_NOOP3("KStandardShortcut", "Document Back", "@action"), ALTSHIFT(Left), 0, QList(), false }, - { DocumentForward, "DocumentForward", QT_TRANSLATE_NOOP3("KStandardShortcut", "Document Forward", "@action"), ALTSHIFT(Right), 0, QList(), false }, - { EditBookmarks, "EditBookmarks", QT_TRANSLATE_NOOP3("KStandardShortcut", "Edit Bookmarks", "@action"), 0, 0, QList(), false }, - { Spelling, "Spelling", QT_TRANSLATE_NOOP3("KStandardShortcut", "Spelling", "@action"), 0, 0, QList(), false }, - { ShowToolbar, "ShowToolbar", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show Toolbar", "@action"), 0, 0, QList(), false }, - { ShowStatusbar, "ShowStatusbar", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show Statusbar", "@action"), 0, 0, QList(), false }, + { TextCompletion, "TextCompletion", QT_TRANSLATE_NOOP3("KStandardShortcut", "Text Completion", "@action"), CTRL(E), 0, QList(), false, Category::Edit }, + { PrevCompletion, "PrevCompletion", QT_TRANSLATE_NOOP3("KStandardShortcut", "Previous Completion Match", "@action"), CTRL(Up), 0, QList(), false, Category::Edit }, + { NextCompletion, "NextCompletion", QT_TRANSLATE_NOOP3("KStandardShortcut", "Next Completion Match", "@action"), CTRL(Down), 0, QList(), false, Category::Edit }, + { SubstringCompletion, "SubstringCompletion", QT_TRANSLATE_NOOP3("KStandardShortcut", "Substring Completion", "@action"), CTRL(T), 0, QList(), false, Category::Edit }, + + { RotateUp, "RotateUp", QT_TRANSLATE_NOOP3("KStandardShortcut", "Previous Item in List", "@action"), Qt::Key_Up, 0, QList(), false, Category::Navigation }, + { RotateDown, "RotateDown", QT_TRANSLATE_NOOP3("KStandardShortcut", "Next Item in List", "@action"), Qt::Key_Down, 0, QList(), false, Category::Navigation }, + + { OpenRecent, "OpenRecent", QT_TRANSLATE_NOOP3("KStandardShortcut", "Open Recent", "@action"), 0, 0, QList(), false, Category::File }, + { SaveAs, "SaveAs", QT_TRANSLATE_NOOP3("KStandardShortcut", "Save As", "@action"), CTRLSHIFT(S), 0, QList(), false, Category::File }, + { Revert, "Revert", QT_TRANSLATE_NOOP3("KStandardShortcut", "Revert", "@action"), 0, 0, QList(), false, Category::Edit }, + { PrintPreview, "PrintPreview", QT_TRANSLATE_NOOP3("KStandardShortcut", "Print Preview", "@action"), 0, 0, QList(), false, Category::File }, + { Mail, "Mail", QT_TRANSLATE_NOOP3("KStandardShortcut", "Mail", "@action"), 0, 0, QList(), false, Category::Help }, + { Clear, "Clear", QT_TRANSLATE_NOOP3("KStandardShortcut", "Clear", "@action"), 0, 0, QList(), false, Category::Edit }, + { ActualSize, "ActualSize", QT_TRANSLATE_NOOP3("KStandardShortcut", "Actual Size", "@action"), CTRL(0), 0, QList(), false, Category::View }, + { FitToPage, "FitToPage", QT_TRANSLATE_NOOP3("KStandardShortcut", "Fit To Page", "@action"), 0, 0, QList(), false, Category::View }, + { FitToWidth, "FitToWidth", QT_TRANSLATE_NOOP3("KStandardShortcut", "Fit To Width", "@action"), 0, 0, QList(), false, Category::View }, + { FitToHeight, "FitToHeight", QT_TRANSLATE_NOOP3("KStandardShortcut", "Fit To Height", "@action"), 0, 0, QList(), false, Category::View }, + { Zoom, "Zoom", QT_TRANSLATE_NOOP3("KStandardShortcut", "Zoom", "@action"), 0, 0, QList(), false, Category::View }, + { Goto, "Goto", QT_TRANSLATE_NOOP3("KStandardShortcut", "Goto", "@action"), 0, 0, QList(), false, Category::Navigation }, + { GotoPage, "GotoPage", QT_TRANSLATE_NOOP3("KStandardShortcut", "Goto Page", "@action"), 0, 0, QList(), false, Category::Navigation }, + { DocumentBack, "DocumentBack", QT_TRANSLATE_NOOP3("KStandardShortcut", "Document Back", "@action"), ALTSHIFT(Left), 0, QList(), false, Category::Navigation }, + { DocumentForward, "DocumentForward", QT_TRANSLATE_NOOP3("KStandardShortcut", "Document Forward", "@action"), ALTSHIFT(Right), 0, QList(), false, Category::Navigation }, + { EditBookmarks, "EditBookmarks", QT_TRANSLATE_NOOP3("KStandardShortcut", "Edit Bookmarks", "@action"), 0, 0, QList(), false, Category::Navigation }, + { Spelling, "Spelling", QT_TRANSLATE_NOOP3("KStandardShortcut", "Spelling", "@action"), 0, 0, QList(), false, Category::Edit }, + { ShowToolbar, "ShowToolbar", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show Toolbar", "@action"), 0, 0, QList(), false, Category::View }, + { ShowStatusbar, "ShowStatusbar", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show Statusbar", "@action"), 0, 0, QList(), false, Category::View }, #if KCONFIGGUI_BUILD_DEPRECATED_SINCE(5, 39) - { SaveOptions, "SaveOptions", QT_TRANSLATE_NOOP3("KStandardShortcut", "Save Options", "@action"), 0, 0, QList(), false }, + { SaveOptions, "SaveOptions", QT_TRANSLATE_NOOP3("KStandardShortcut", "Save Options", "@action"), 0, 0, QList(), false, Category::Settings }, #else // dummy entry - { SaveOptions_DEPRECATED_DO_NOT_USE, nullptr, {nullptr, nullptr}, 0, 0, QList(), false }, + { SaveOptions_DEPRECATED_DO_NOT_USE, nullptr, {nullptr, nullptr}, 0, 0, QList(), false, Category::InvalidCategory }, #endif - { KeyBindings, "KeyBindings", QT_TRANSLATE_NOOP3("KStandardShortcut", "Key Bindings", "@action"), 0, 0, QList(), false }, - { Preferences, "Preferences", QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Application", "@action"), CTRLSHIFT(Comma), 0, QList(), false }, - { ConfigureToolbars, "ConfigureToolbars", QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Toolbars", "@action"), 0, 0, QList(), false }, - { ConfigureNotifications, "ConfigureNotifications", QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Notifications", "@action"), 0, 0, QList(), false }, - { TipofDay, "TipofDay", QT_TRANSLATE_NOOP3("KStandardShortcut", "Tip Of Day", "@action"), 0, 0, QList(), false }, - { ReportBug, "ReportBug", QT_TRANSLATE_NOOP3("KStandardShortcut", "Report Bug", "@action"), 0, 0, QList(), false }, - { SwitchApplicationLanguage, "SwitchApplicationLanguage", QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Language...", "@action"), 0, 0, QList(), false }, - { AboutApp, "AboutApp", QT_TRANSLATE_NOOP3("KStandardShortcut", "About Application", "@action"), 0, 0, QList(), false }, - { AboutKDE, "AboutKDE", QT_TRANSLATE_NOOP3("KStandardShortcut", "About KDE", "@action"), 0, 0, QList(), false }, + { KeyBindings, "KeyBindings", QT_TRANSLATE_NOOP3("KStandardShortcut", "Key Bindings", "@action"), 0, 0, QList(), false, Category::Settings }, + { Preferences, "Preferences", QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Application", "@action"), CTRLSHIFT(Comma), 0, QList(), false, Category::Settings }, + { ConfigureToolbars, "ConfigureToolbars", QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Toolbars", "@action"), 0, 0, QList(), false, Category::Settings }, + { ConfigureNotifications, "ConfigureNotifications", QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Notifications", "@action"), 0, 0, QList(), false, Category::Settings }, + { TipofDay, "TipofDay", QT_TRANSLATE_NOOP3("KStandardShortcut", "Tip Of Day", "@action"), 0, 0, QList(), false, Category::Help }, + { ReportBug, "ReportBug", QT_TRANSLATE_NOOP3("KStandardShortcut", "Report Bug", "@action"), 0, 0, QList(), false, Category::Help }, + { SwitchApplicationLanguage, "SwitchApplicationLanguage", QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Language...", "@action"), 0, 0, QList(), false, Category::Settings }, + { AboutApp, "AboutApp", QT_TRANSLATE_NOOP3("KStandardShortcut", "About Application", "@action"), 0, 0, QList(), false, Category::Help }, + { AboutKDE, "AboutKDE", QT_TRANSLATE_NOOP3("KStandardShortcut", "About KDE", "@action"), 0, 0, QList(), false, Category::Help }, // Both "Cut" and "Delete" use Shift+Delete, but this is okay; see // https://commits.kde.org/kxmlgui/8eabbf6725386e716b7536c71a9181dfe5d959f0 - { DeleteFile, "DeleteFile", QT_TRANSLATE_NOOP3("KStandardShortcut", "Delete", "@action"), SHIFT(Delete), 0, QList(), false }, - { RenameFile, "RenameFile", QT_TRANSLATE_NOOP3("KStandardShortcut", "Rename", "@action"), Qt::Key_F2, 0, QList(), false }, - { MoveToTrash, "MoveToTrash", QT_TRANSLATE_NOOP3("KStandardShortcut", "Move to Trash", "@action"), Qt::Key_Delete, 0, QList(), false }, - { Donate, "Donate", QT_TRANSLATE_NOOP3("KStandardShortcut", "Donate", "@action"), 0, 0, QList(), false }, - { ShowHideHiddenFiles, "ShowHideHiddenFiles", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show/Hide Hidden Files", "@action"), CTRL(H), ALT(Period), QList(), false }, + { DeleteFile, "DeleteFile", QT_TRANSLATE_NOOP3("KStandardShortcut", "Delete", "@action"), SHIFT(Delete), 0, QList(), false, Category::File }, + { RenameFile, "RenameFile", QT_TRANSLATE_NOOP3("KStandardShortcut", "Rename", "@action"), Qt::Key_F2, 0, QList(), false, Category::File }, + { MoveToTrash, "MoveToTrash", QT_TRANSLATE_NOOP3("KStandardShortcut", "Move to Trash", "@action"), Qt::Key_Delete, 0, QList(), false, Category::File }, + { Donate, "Donate", QT_TRANSLATE_NOOP3("KStandardShortcut", "Donate", "@action"), 0, 0, QList(), false, Category::Help }, + { ShowHideHiddenFiles, "ShowHideHiddenFiles", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show/Hide Hidden Files", "@action"), CTRL(H), ALT(Period), QList(), false, Category::View }, //dummy entry to catch simple off-by-one errors. Insert new entries before this line. - { AccelNone, nullptr, {nullptr, nullptr}, 0, 0, QList(), false } + { AccelNone, nullptr, {nullptr, nullptr}, 0, 0, QList(), false, Category::InvalidCategory } }; /** Search for the KStandardShortcutInfo object associated with the given @p id. @@ -367,6 +370,11 @@ QList hardcodedDefaultShortcut(StandardShortcut id) return cut; } +Category category(StandardShortcut id) +{ + return guardedStandardShortcutInfo(id)->category; +} + const QList &open() { return shortcut(Open); diff --git a/src/gui/kstandardshortcut.h b/src/gui/kstandardshortcut.h index cda9fe96..89d1fe9b 100644 --- a/src/gui/kstandardshortcut.h +++ b/src/gui/kstandardshortcut.h @@ -147,6 +147,20 @@ enum StandardShortcut { StandardShortcutCount // number of standard shortcuts }; +/** + * Categories in which the standard shortcuts can be classified + * @since 5.74 + */ +enum class Category { + InvalidCategory = -1, + File, + Edit, + Navigation, + View, + Settings, + Help, +}; + /** * Returns the keybinding for @p accel. * On X11, if QApplication was initialized with GUI disabled, the @@ -223,6 +237,12 @@ KCONFIGGUI_EXPORT QList hardcodedDefaultShortcut(StandardShortcut */ KCONFIGGUI_EXPORT void saveShortcut(StandardShortcut id, const QList &newShortcut); +/** + * Returns the appropriate category for the given StandardShortcut \p id. + * @since 5.73 + */ +KCONFIGGUI_EXPORT Category category(StandardShortcut id); + /** * Open file. Default: Ctrl-o * @return the shortcut of the standard accelerator From 9574fe42b6a93ebbc116d0fc2bd0a962af0dd020 Mon Sep 17 00:00:00 2001 From: Andreas Cord-Landwehr Date: Mon, 17 Aug 2020 08:00:58 +0200 Subject: [PATCH 041/259] Remove obsolete COPYING files --- COPYING.LIB | 510 ---------------------------------------------------- 1 file changed, 510 deletions(-) delete mode 100644 COPYING.LIB diff --git a/COPYING.LIB b/COPYING.LIB deleted file mode 100644 index 2d2d780e..00000000 --- a/COPYING.LIB +++ /dev/null @@ -1,510 +0,0 @@ - - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations -below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it -becomes a de-facto standard. To achieve this, non-free programs must -be allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control -compilation and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at least - three years, to give the same user the materials specified in - Subsection 6a, above, for a charge no more than the cost of - performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply, and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License -may add an explicit geographical distribution limitation excluding those -countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms -of the ordinary General Public License). - - To apply these terms, attach the following notices to the library. -It is safest to attach them to the start of each source file to most -effectively convey the exclusion of warranty; and each file should -have at least the "copyright" line and a pointer to where the full -notice is found. - - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or -your school, if any, to sign a "copyright disclaimer" for the library, -if necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James - Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - From a3d55917068c99fc343ad4163be2ed52d25fc691 Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Mon, 24 Aug 2020 07:29:22 +0200 Subject: [PATCH 042/259] Fix qt warning: "QtPrivate::DeprecatedRefClassBehavior::warn|?libKF5ConfigCore.so.5?|?libKF5ConfigCore.so.5? Using QCharRef with an index pointing outside the valid range of a QString. The corresponding behavior is deprecated, and will be changed in a future version of Qt." We try to access to an invalid index. --- src/core/kconfig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index d9232fa5..19e82ffe 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -190,7 +190,7 @@ QString KConfigPrivate::expandString(const QString &value) nEndPos++; aVarName = aValue.midRef(nDollarPos + 2, nEndPos - nDollarPos - 3); } else { - while (nEndPos <= aValue.length() && + while (nEndPos < aValue.length() && (aValue[nEndPos].isNumber() || aValue[nEndPos].isLetter() || aValue[nEndPos] == QLatin1Char('_'))) { From 803b9f16e0b9133ddfef40dd16a368c39fa1b0a6 Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Thu, 20 Aug 2020 12:04:34 -0600 Subject: [PATCH 043/259] Extract code to get list of connected screens into a re-usable function Right now it's duplicated twice, and once we add per-screen-arrangement memory for window sizes as well, it will be duplicated four times unless we put it into a function. --- src/gui/kwindowconfig.cpp | 27 +++++++++++++-------------- src/gui/kwindowconfig.h | 8 +++++++- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/gui/kwindowconfig.cpp b/src/gui/kwindowconfig.cpp index 07f1a307..fcbbf196 100644 --- a/src/gui/kwindowconfig.cpp +++ b/src/gui/kwindowconfig.cpp @@ -84,13 +84,7 @@ void KWindowConfig::saveWindowPosition(const QWindow *window, KConfigGroup &conf // Prepend the names of all connected screens so that we save the position // on a per-screen-arrangement basis, since people often like to have // windows positioned differently depending on their screen arrangements - QStringList names; - const auto screens = QGuiApplication::screens(); - names.reserve(screens.length()); - for (auto screen : screens) { - names << screen->name(); - } - const QString allScreens = names.join(QStringLiteral(" ")); + const QString allScreens = allConnectedScreens(); config.writeEntry(allScreens + QStringLiteral(" XPosition"), window->x(), options); config.writeEntry(allScreens + QStringLiteral(" YPosition"), window->y(), options); } @@ -112,13 +106,7 @@ void KWindowConfig::restoreWindowPosition(QWindow *window, const KConfigGroup &c return; } - QStringList names; - const auto screens = QGuiApplication::screens(); - names.reserve(screens.length()); - for (auto screen : screens) { - names << screen->name(); - } - const QString allScreens = names.join(QStringLiteral(" ")); + const QString allScreens = allConnectedScreens(); const int xPos = config.readEntry(allScreens + QStringLiteral(" XPosition"), -1); const int yPos = config.readEntry(allScreens + QStringLiteral(" YPosition"), -1); @@ -129,3 +117,14 @@ void KWindowConfig::restoreWindowPosition(QWindow *window, const KConfigGroup &c window->setX(xPos); window->setY(yPos); } + +QString KWindowConfig::allConnectedScreens() +{ + QStringList names; + const auto screens = QGuiApplication::screens(); + names.reserve(screens.length()); + for (auto screen : screens) { + names << screen->name(); + } + return names.join(QStringLiteral(" ")); +} diff --git a/src/gui/kwindowconfig.h b/src/gui/kwindowconfig.h index 04af27d1..0d36fa48 100644 --- a/src/gui/kwindowconfig.h +++ b/src/gui/kwindowconfig.h @@ -82,6 +82,12 @@ KCONFIGGUI_EXPORT void saveWindowPosition(const QWindow *window, KConfigGroup &c * @since 5.74 */ KCONFIGGUI_EXPORT void restoreWindowPosition(QWindow *window, const KConfigGroup &config); -} +/** + * Convenience function to get a space-separated list of all connected screens. + * + * @since 5.75 + */ +QString allConnectedScreens(); +} #endif // KWINDOWCONFIG_H From 0f1b47f2ab4b374a6d85dcf9dd63e1159cc7ea65 Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Thu, 20 Aug 2020 12:09:05 -0600 Subject: [PATCH 044/259] Remember window sizes on a per-screen-arrangement basis This is done for window positions, so it should also be done for window sizes. The combination of both should substantially improve the use case of maintaining a consistent window arrangement for multiple display setups (e.g. laptop and laptop + external screen). --- src/gui/kwindowconfig.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/gui/kwindowconfig.cpp b/src/gui/kwindowconfig.cpp index fcbbf196..5785bdbc 100644 --- a/src/gui/kwindowconfig.cpp +++ b/src/gui/kwindowconfig.cpp @@ -25,15 +25,19 @@ void KWindowConfig::saveWindowSize(const QWindow *window, KConfigGroup &config, const QSize sizeToSave = window->size(); const bool isMaximized = window->windowState() & Qt::WindowMaximized; - const QString screenMaximizedString(QStringLiteral("Window-Maximized %1x%2").arg(desk.height()).arg(desk.width())); + // Prepend the names of all connected screens so that we save the size + // on a per-screen-arrangement basis, since people often like to have + // windows laid out differently depending on their screen arrangements + const QString allScreens = allConnectedScreens(); + const QString screenMaximizedString(allScreens + QStringLiteral(" Window-Maximized %1x%2").arg(desk.height()).arg(desk.width())); // Save size only if window is not maximized if (!isMaximized) { const QSize defaultSize(window->property(s_initialSizePropertyName).toSize()); const QSize defaultScreenSize(window->property(s_initialScreenSizePropertyName).toSize()); const bool sizeValid = defaultSize.isValid() && defaultScreenSize.isValid(); if (!sizeValid || (sizeValid && (defaultSize != sizeToSave || defaultScreenSize != desk.size()))) { - const QString wString(QStringLiteral("Width %1").arg(desk.width())); - const QString hString(QStringLiteral("Height %1").arg(desk.height())); + const QString wString(allScreens + QStringLiteral(" Width %1").arg(desk.width())); + const QString hString(allScreens + QStringLiteral(" Height %1").arg(desk.height())); config.writeEntry(wString, sizeToSave.width(), options); config.writeEntry(hString, sizeToSave.height(), options); } @@ -54,9 +58,15 @@ void KWindowConfig::restoreWindowSize(QWindow *window, const KConfigGroup &confi const QRect desk = window->screen()->geometry(); - const int width = config.readEntry(QStringLiteral("Width %1").arg(desk.width()), window->size().width()); - const int height = config.readEntry(QStringLiteral("Height %1").arg(desk.height()), window->size().height()); - const bool isMaximized = config.readEntry(QStringLiteral("Window-Maximized %1x%2").arg(desk.height()).arg(desk.width()), false); + // Fall back to non-per-screen-arrangement info if it's available but + // per-screen-arrangement information is not + const int fallbackWidth = config.readEntry(QStringLiteral("Width %1").arg(desk.width()), window->size().width()); + const int fallbackHeight = config.readEntry(QStringLiteral("Height %1").arg(desk.height()), window->size().height()); + + const QString allScreens = allConnectedScreens(); + const int width = config.readEntry(allScreens + QStringLiteral(" Width %1").arg(desk.width()), fallbackWidth); + const int height = config.readEntry(allScreens + QStringLiteral(" Height %1").arg(desk.height()), fallbackHeight); + const bool isMaximized = config.readEntry(allScreens + QStringLiteral(" Window-Maximized %1x%2").arg(desk.height()).arg(desk.width()), false); // Check default size const QSize defaultSize(window->property(s_initialSizePropertyName).toSize()); From 60f18e6c3c816f4bca7c72e5a4f114787309485a Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Thu, 27 Aug 2020 12:52:48 +0100 Subject: [PATCH 045/259] Introduce method to query KConfigSkeletonItem default value 5.64 added an isDefault method however this doesn't suffice for usage in KConfigDialogManager which compares a current value to the default. KConfigDialogManager currently uses a hack with side effects. Exposing the value directly solves that. --- src/core/kcoreconfigskeleton.cpp | 17 +++++++++++++++++ src/core/kcoreconfigskeleton.h | 9 +++++++++ src/core/kcoreconfigskeleton_p.h | 1 + 3 files changed, 27 insertions(+) diff --git a/src/core/kcoreconfigskeleton.cpp b/src/core/kcoreconfigskeleton.cpp index d02705d9..bfa3a60f 100644 --- a/src/core/kcoreconfigskeleton.cpp +++ b/src/core/kcoreconfigskeleton.cpp @@ -167,6 +167,12 @@ bool KConfigSkeletonItem::isSaveNeeded() const return d->mIsSaveNeededImpl(); } +QVariant KConfigSkeletonItem::getDefault() const +{ + Q_D(const KConfigSkeletonItem); + return d->mGetDefaultImpl(); +} + void KConfigSkeletonItem::readImmutability(const KConfigGroup &group) { Q_D(KConfigSkeletonItem); @@ -185,6 +191,12 @@ void KConfigSkeletonItem::setIsSaveNeededImpl(const std::function &impl d->mIsSaveNeededImpl = impl; } +void KConfigSkeletonItem::setGetDefaultImpl(const std::function &impl) +{ + Q_D(KConfigSkeletonItem); + d->mGetDefaultImpl = impl; +} + KPropertySkeletonItem::KPropertySkeletonItem(QObject *object, const QByteArray &propertyName, const QVariant &defaultValue) : KConfigSkeletonItem(*new KPropertySkeletonItemPrivate(object, propertyName, defaultValue), {}, {}) { @@ -196,6 +208,10 @@ KPropertySkeletonItem::KPropertySkeletonItem(QObject *object, const QByteArray & Q_D(const KPropertySkeletonItem); return d->mReference != d->mLoadedValue; }); + setGetDefaultImpl([this] { + Q_D(const KPropertySkeletonItem); + return d->mDefaultValue; + }); } QVariant KPropertySkeletonItem::property() const @@ -1555,6 +1571,7 @@ KConfigCompilerSignallingItem::KConfigCompilerSignallingItem(KConfigSkeletonItem setIsDefaultImpl([this] { return mItem->isDefault(); }); setIsSaveNeededImpl([this] { return mItem->isSaveNeeded(); }); + setGetDefaultImpl([this] {return mItem->getDefault(); }); } KConfigCompilerSignallingItem::~KConfigCompilerSignallingItem() diff --git a/src/core/kcoreconfigskeleton.h b/src/core/kcoreconfigskeleton.h index 9cf131b2..69f52060 100644 --- a/src/core/kcoreconfigskeleton.h +++ b/src/core/kcoreconfigskeleton.h @@ -230,6 +230,12 @@ class KCONFIGCORE_EXPORT KConfigSkeletonItem */ bool isSaveNeeded() const; + /** + * Returns the default value + * @since 5.74 + */ + QVariant getDefault() const; + protected: explicit KConfigSkeletonItem(KConfigSkeletonItemPrivate &dd, const QString &_group, const QString &_key); @@ -247,6 +253,7 @@ class KCONFIGCORE_EXPORT KConfigSkeletonItem // KF6: Use proper pure virtuals in KConfigSkeletonItem void setIsDefaultImpl(const std::function &impl); void setIsSaveNeededImpl(const std::function &impl); + void setGetDefaultImpl(const std::function &impl); KConfigSkeletonItemPrivate *const d_ptr; }; @@ -324,6 +331,8 @@ template < typename T > class KConfigSkeletonGenericItem: public KConfigSkeleton { setIsDefaultImpl([this] { return mReference == mDefault; }); setIsSaveNeededImpl([this] { return mReference != mLoadedValue; }); + setGetDefaultImpl([this] { return QVariant::fromValue(mDefault); }); + } /** diff --git a/src/core/kcoreconfigskeleton_p.h b/src/core/kcoreconfigskeleton_p.h index 389bc4f7..006bd45f 100644 --- a/src/core/kcoreconfigskeleton_p.h +++ b/src/core/kcoreconfigskeleton_p.h @@ -54,6 +54,7 @@ class KConfigSkeletonItemPrivate // HACK: Necessary to avoid introducing new virtuals in KConfigSkeletonItem std::function mIsDefaultImpl; std::function mIsSaveNeededImpl; + std::function mGetDefaultImpl; }; class KPropertySkeletonItemPrivate : public KConfigSkeletonItemPrivate From 7dbe2eb69e5b251b0c193f1a4dbbf4c69e2a3330 Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Sat, 29 Aug 2020 01:48:42 +0200 Subject: [PATCH 046/259] API dox: consistently use version number without product name for @deprecated GIT_SILENT --- src/core/kemailsettings.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/kemailsettings.h b/src/core/kemailsettings.h index 5a14bb02..876b569e 100644 --- a/src/core/kemailsettings.h +++ b/src/core/kemailsettings.h @@ -50,15 +50,15 @@ class KCONFIGCORE_EXPORT KEMailSettings OutServerPass, #if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(5, 0) /** - * @deprecated since Frameworks 5.0 + * @deprecated since 5.0 */ OutServerType, /** - * @deprecated since Frameworks 5.0 + * @deprecated since 5.0 */ OutServerCommand, /** - * @deprecated since Frameworks 5.0 + * @deprecated since 5.0 */ OutServerTLS, #else @@ -71,15 +71,15 @@ class KCONFIGCORE_EXPORT KEMailSettings InServerPass, #if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(5, 0) /** - * @deprecated since Frameworks 5.0 + * @deprecated since 5.0 */ InServerType, /** - * @deprecated since Frameworks 5.0 + * @deprecated since 5.0 */ InServerMBXType, /** - * @deprecated since Frameworks 5.0 + * @deprecated since 5.0 */ InServerTLS #endif From eeb2bbeff7f1ee74b907d92acb0eae6a65590ad7 Mon Sep 17 00:00:00 2001 From: Domenico Panella Date: Sat, 29 Aug 2020 18:06:07 +0000 Subject: [PATCH 047/259] Add standard shortcut for "Create Folder" --- src/gui/kstandardshortcut.cpp | 5 +++++ src/gui/kstandardshortcut.h | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/src/gui/kstandardshortcut.cpp b/src/gui/kstandardshortcut.cpp index a91a2397..70fef713 100644 --- a/src/gui/kstandardshortcut.cpp +++ b/src/gui/kstandardshortcut.cpp @@ -167,6 +167,7 @@ static KStandardShortcutInfo g_infoStandardShortcut[] = { // https://commits.kde.org/kxmlgui/8eabbf6725386e716b7536c71a9181dfe5d959f0 { DeleteFile, "DeleteFile", QT_TRANSLATE_NOOP3("KStandardShortcut", "Delete", "@action"), SHIFT(Delete), 0, QList(), false, Category::File }, { RenameFile, "RenameFile", QT_TRANSLATE_NOOP3("KStandardShortcut", "Rename", "@action"), Qt::Key_F2, 0, QList(), false, Category::File }, + { CreateFolder, "CreateFolder", QT_TRANSLATE_NOOP3("KStandardShortcut", "Create Folder", "@action"), Qt::Key_F10, 0, QList(), false, Category::File }, { MoveToTrash, "MoveToTrash", QT_TRANSLATE_NOOP3("KStandardShortcut", "Move to Trash", "@action"), Qt::Key_Delete, 0, QList(), false, Category::File }, { Donate, "Donate", QT_TRANSLATE_NOOP3("KStandardShortcut", "Donate", "@action"), 0, 0, QList(), false, Category::Help }, { ShowHideHiddenFiles, "ShowHideHiddenFiles", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show/Hide Hidden Files", "@action"), CTRL(H), ALT(Period), QList(), false, Category::View }, @@ -575,6 +576,10 @@ const QList &renameFile() { return shortcut(RenameFile); } +const QList &createFolder() +{ + return shortcut(CreateFolder); +} const QList &moveToTrash() { return shortcut(MoveToTrash); diff --git a/src/gui/kstandardshortcut.h b/src/gui/kstandardshortcut.h index 89d1fe9b..46885e28 100644 --- a/src/gui/kstandardshortcut.h +++ b/src/gui/kstandardshortcut.h @@ -139,6 +139,7 @@ enum StandardShortcut { AboutKDE, ///< Display the About KDE dialog. DeleteFile, ///< Permanently delete files or folders. @since 5.25 RenameFile, ///< Rename files or folders. @since 5.25 + CreateFolder, ///< Create a folder. @since 5.74 MoveToTrash, ///< Move files or folders to the trash. @since 5.25 Donate, ///< Open donation page on kde.org. @since 5.26 ShowHideHiddenFiles, ///< Toggle showing or hiding hidden files @since 5.70 @@ -548,6 +549,13 @@ KCONFIGGUI_EXPORT const QList &deleteFile(); */ KCONFIGGUI_EXPORT const QList &renameFile(); +/** + * Create a folder. Default: F10 + * @return the shortcut of the standard accelerator + * @since 5.74 + */ +KCONFIGGUI_EXPORT const QList &createFolder(); + /** * Moves files or folders to the trash. Default: Delete * @return the shortcut of the standard accelerator From 0804a38b5f2c74185e0a8a1f399938bfc4fa6dcd Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 30 Aug 2020 23:41:48 +0200 Subject: [PATCH 048/259] Port from QSharedPointer to unique_ptr. There's no sharing going on here. NO_CHANGELOG --- autotests/test_kconf_update.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/autotests/test_kconf_update.cpp b/autotests/test_kconf_update.cpp index 13cde111..52292083 100644 --- a/autotests/test_kconf_update.cpp +++ b/autotests/test_kconf_update.cpp @@ -6,6 +6,8 @@ */ #include "test_kconf_update.h" +#include + // Qt #include #include @@ -50,9 +52,9 @@ static QString readFile(const QString &path) return ret; } -static QTemporaryFile *writeUpdFile(const QString &content) +static std::unique_ptr writeUpdFile(const QString &content) { - QTemporaryFile *file = new QTemporaryFile(QDir::tempPath() + QLatin1String("/test_kconf_update_XXXXXX.upd")); + std::unique_ptr file{new QTemporaryFile(QDir::tempPath() + QLatin1String("/test_kconf_update_XXXXXX.upd"))}; bool ok = file->open(); Q_UNUSED(ok) // silence warnings Q_ASSERT(ok); @@ -326,7 +328,7 @@ void TestKConfUpdate::test() writeFile(oldConfPath, oldConfContent); QCOMPARE(readFile(oldConfPath), oldConfContent); - QSharedPointer updFile(writeUpdFile(updContent)); + std::unique_ptr updFile(writeUpdFile(updContent)); runKConfUpdate(updFile->fileName()); QString updateInfo = QStringLiteral("%1:%2") @@ -611,7 +613,7 @@ void TestKConfUpdate::testScript() // Prepend the Version and Id= field to the upd content updContent = QStringLiteral("Version=5\nId=%1\n").arg(QTest::currentDataTag()) + updContent; - QSharedPointer updFile(writeUpdFile(updContent)); + std::unique_ptr updFile(writeUpdFile(updContent)); const QString scriptDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/kconf_update"; QVERIFY(QDir().mkpath(scriptDir)); From 565fa66f7ec31eac15927d4c0ce2a40b87b3887c Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 30 Aug 2020 23:46:38 +0200 Subject: [PATCH 049/259] kconf_update: test the return value of QTemporaryFile::open() for good measure --- src/kconf_update/kconf_update.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/kconf_update/kconf_update.cpp b/src/kconf_update/kconf_update.cpp index 1571ea27..02317a25 100644 --- a/src/kconf_update/kconf_update.cpp +++ b/src/kconf_update/kconf_update.cpp @@ -783,9 +783,11 @@ void KonfUpdate::gotScript(const QString &_script) } QTemporaryFile scriptIn; - scriptIn.open(); QTemporaryFile scriptOut; - scriptOut.open(); + if (!scriptIn.open() || !scriptOut.open()) { + qCDebugFile(KCONF_UPDATE_LOG) << "Could not create temporary file!"; + return; + } int result; QProcess proc; From f12ffa5b5528d1c9c38c62e75801bbe217ce5543 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 30 Aug 2020 23:48:38 +0200 Subject: [PATCH 050/259] autotests: stop polluting /tmp with kconf_update.* temp files --- src/kconf_update/kconf_update.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/kconf_update/kconf_update.cpp b/src/kconf_update/kconf_update.cpp index 02317a25..bd5f630f 100644 --- a/src/kconf_update/kconf_update.cpp +++ b/src/kconf_update/kconf_update.cpp @@ -796,7 +796,7 @@ void KonfUpdate::gotScript(const QString &_script) proc.setStandardOutputFile(scriptOut.fileName()); if (m_oldConfig1) { if (m_debug) { - scriptIn.setAutoRemove(false); + //scriptIn.setAutoRemove(false); qCDebug(KCONF_UPDATE_LOG) << "Script input stored in" << scriptIn.fileName(); } KConfig cfg(scriptIn.fileName(), KConfig::SimpleConfig); @@ -855,7 +855,7 @@ void KonfUpdate::gotScript(const QString &_script) } if (m_debug) { - scriptOut.setAutoRemove(false); + //scriptOut.setAutoRemove(false); qCDebug(KCONF_UPDATE_LOG) << "Script output stored in" << scriptOut.fileName(); QFile output(scriptOut.fileName()); if (output.open(QIODevice::ReadOnly)) { From 5674ebfdc2a450319a2c49568daac2af7ea15ef0 Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Tue, 1 Sep 2020 11:06:23 +0200 Subject: [PATCH 051/259] Fix placement of new CreateFilder enumerator Needs to be added at end of list for ABI reasons. GIT_SILENT --- src/gui/kstandardshortcut.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kstandardshortcut.h b/src/gui/kstandardshortcut.h index 46885e28..30d62f98 100644 --- a/src/gui/kstandardshortcut.h +++ b/src/gui/kstandardshortcut.h @@ -139,10 +139,10 @@ enum StandardShortcut { AboutKDE, ///< Display the About KDE dialog. DeleteFile, ///< Permanently delete files or folders. @since 5.25 RenameFile, ///< Rename files or folders. @since 5.25 - CreateFolder, ///< Create a folder. @since 5.74 MoveToTrash, ///< Move files or folders to the trash. @since 5.25 Donate, ///< Open donation page on kde.org. @since 5.26 ShowHideHiddenFiles, ///< Toggle showing or hiding hidden files @since 5.70 + CreateFolder, ///< Create a folder. @since 5.74 // Insert new items here! StandardShortcutCount // number of standard shortcuts From 7ce130f3c6de55d834bd8f0b24498e4ea0626c25 Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Tue, 1 Sep 2020 11:13:43 +0200 Subject: [PATCH 052/259] Missing g_infoStandardShortcut update for last commit GIT_SILENT --- src/gui/kstandardshortcut.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kstandardshortcut.cpp b/src/gui/kstandardshortcut.cpp index 70fef713..df5ebe4b 100644 --- a/src/gui/kstandardshortcut.cpp +++ b/src/gui/kstandardshortcut.cpp @@ -167,10 +167,10 @@ static KStandardShortcutInfo g_infoStandardShortcut[] = { // https://commits.kde.org/kxmlgui/8eabbf6725386e716b7536c71a9181dfe5d959f0 { DeleteFile, "DeleteFile", QT_TRANSLATE_NOOP3("KStandardShortcut", "Delete", "@action"), SHIFT(Delete), 0, QList(), false, Category::File }, { RenameFile, "RenameFile", QT_TRANSLATE_NOOP3("KStandardShortcut", "Rename", "@action"), Qt::Key_F2, 0, QList(), false, Category::File }, - { CreateFolder, "CreateFolder", QT_TRANSLATE_NOOP3("KStandardShortcut", "Create Folder", "@action"), Qt::Key_F10, 0, QList(), false, Category::File }, { MoveToTrash, "MoveToTrash", QT_TRANSLATE_NOOP3("KStandardShortcut", "Move to Trash", "@action"), Qt::Key_Delete, 0, QList(), false, Category::File }, { Donate, "Donate", QT_TRANSLATE_NOOP3("KStandardShortcut", "Donate", "@action"), 0, 0, QList(), false, Category::Help }, { ShowHideHiddenFiles, "ShowHideHiddenFiles", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show/Hide Hidden Files", "@action"), CTRL(H), ALT(Period), QList(), false, Category::View }, + { CreateFolder, "CreateFolder", QT_TRANSLATE_NOOP3("KStandardShortcut", "Create Folder", "@action"), Qt::Key_F10, 0, QList(), false, Category::File }, //dummy entry to catch simple off-by-one errors. Insert new entries before this line. { AccelNone, nullptr, {nullptr, nullptr}, 0, 0, QList(), false, Category::InvalidCategory } From 89c99164b4c235dfc61aa3cdd6997dc1413281ce Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Thu, 3 Sep 2020 11:21:14 -0600 Subject: [PATCH 053/259] Fix @since tag for recently-added function --- src/gui/kwindowconfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kwindowconfig.h b/src/gui/kwindowconfig.h index 0d36fa48..3fda43c1 100644 --- a/src/gui/kwindowconfig.h +++ b/src/gui/kwindowconfig.h @@ -86,7 +86,7 @@ KCONFIGGUI_EXPORT void restoreWindowPosition(QWindow *window, const KConfigGrou /** * Convenience function to get a space-separated list of all connected screens. * - * @since 5.75 + * @since 5.74 */ QString allConnectedScreens(); } From a1ffd1418f355ae927c9b7859cffcb6caa767306 Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Thu, 3 Sep 2020 11:27:49 -0600 Subject: [PATCH 054/259] Make KWindowConfig::allConnectedScreens() static and internal It doesn't need to be public since it's just an internal convenience function. So let's make it static. BUG: 425953 --- src/gui/kwindowconfig.cpp | 23 ++++++++++++----------- src/gui/kwindowconfig.h | 7 ------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/gui/kwindowconfig.cpp b/src/gui/kwindowconfig.cpp index 5785bdbc..bb541b8e 100644 --- a/src/gui/kwindowconfig.cpp +++ b/src/gui/kwindowconfig.cpp @@ -14,6 +14,18 @@ static const char s_initialSizePropertyName[] = "_kconfig_initial_size"; static const char s_initialScreenSizePropertyName[] = "_kconfig_initial_screen_size"; +// Convenience function to get a space-separated list of all connected screens +static QString allConnectedScreens() +{ + QStringList names; + const auto screens = QGuiApplication::screens(); + names.reserve(screens.length()); + for (auto screen : screens) { + names << screen->name(); + } + return names.join(QLatin1Char(' ')); +} + void KWindowConfig::saveWindowSize(const QWindow *window, KConfigGroup &config, KConfigGroup::WriteConfigFlags options) { // QWindow::screen() shouldn't return null, but it sometimes does due to bugs. @@ -127,14 +139,3 @@ void KWindowConfig::restoreWindowPosition(QWindow *window, const KConfigGroup &c window->setX(xPos); window->setY(yPos); } - -QString KWindowConfig::allConnectedScreens() -{ - QStringList names; - const auto screens = QGuiApplication::screens(); - names.reserve(screens.length()); - for (auto screen : screens) { - names << screen->name(); - } - return names.join(QStringLiteral(" ")); -} diff --git a/src/gui/kwindowconfig.h b/src/gui/kwindowconfig.h index 3fda43c1..4bb56e12 100644 --- a/src/gui/kwindowconfig.h +++ b/src/gui/kwindowconfig.h @@ -82,12 +82,5 @@ KCONFIGGUI_EXPORT void saveWindowPosition(const QWindow *window, KConfigGroup &c * @since 5.74 */ KCONFIGGUI_EXPORT void restoreWindowPosition(QWindow *window, const KConfigGroup &config); - -/** - * Convenience function to get a space-separated list of all connected screens. - * - * @since 5.74 - */ -QString allConnectedScreens(); } #endif // KWINDOWCONFIG_H From ae029a7df5cbbbbdf197dfa7ab5e4dfad2722df0 Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Tue, 1 Sep 2020 13:30:35 +0200 Subject: [PATCH 055/259] Drop outdated note about updating kdoctools/genshortcutents.cpp genshortcutents.cpp disappeared from kdoctools during preparations of kdelibs for KDE Frameworks (commits.kde.org/kdelibs/64537ae5bf1a4e91ba99befc016e67e8e0c9dff0) Cmp. also http://lists.kde.org/?t=137113303000003&r=1&w=2 --- src/gui/kstandardshortcut.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/kstandardshortcut.h b/src/gui/kstandardshortcut.h index 30d62f98..c37712b3 100644 --- a/src/gui/kstandardshortcut.h +++ b/src/gui/kstandardshortcut.h @@ -31,7 +31,6 @@ namespace KStandardShortcut *the big array g_infoStandardShortcut[] ABSOLUTELY MUST BE THE SAME. * !!! !!!! !!!!! !!!! * !!!! !!! !!!! !!!! - * Remember to also update kdoctools/genshortcutents.cpp. * * Other Rules: * From 992b938d3f97c9d10572e3b197d5a2651c2d83d0 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sun, 6 Sep 2020 09:10:21 +0000 Subject: [PATCH 056/259] GIT_SILENT Upgrade ECM and KF5 version requirements for 5.74.0 release. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 862d7366..5daf55e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ set(KF5_VERSION "5.74.0") # handled by release scripts project(KConfig VERSION ${KF5_VERSION}) include(FeatureSummary) -find_package(ECM 5.73.0 NO_MODULE) +find_package(ECM 5.74.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) From c7708ffb77debb58103f6cbb7baf3c305db03b28 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 12 Sep 2020 11:34:46 +0000 Subject: [PATCH 057/259] GIT_SILENT Upgrade KF5 version to 5.75.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5daf55e9..6766332b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.5) -set(KF5_VERSION "5.74.0") # handled by release scripts +set(KF5_VERSION "5.75.0") # handled by release scripts project(KConfig VERSION ${KF5_VERSION}) include(FeatureSummary) From 0283103ff2286a2bc54e6e3abb508bd00c8b9d57 Mon Sep 17 00:00:00 2001 From: Jeremy Whiting Date: Sun, 13 Sep 2020 22:39:34 -0600 Subject: [PATCH 058/259] Use reverse order in KDesktopFile::locateLocal to iterate over generic config paths. Since windows has some generic config paths that are parents of other generic config paths e.g. c:/CraftRoot/build/_//build/bin followed by c:/CraftRoot/build/_//build/bin/data we need to search for locations from the last location to the first. --- src/core/kdesktopfile.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/kdesktopfile.cpp b/src/core/kdesktopfile.cpp index 41f9e818..0dccd2d2 100644 --- a/src/core/kdesktopfile.cpp +++ b/src/core/kdesktopfile.cpp @@ -70,7 +70,11 @@ QString KDesktopFile::locateLocal(const QString &path) QChar plus(QLatin1Char('/')); // Relative to config? (e.g. for autostart) const QStringList lstGenericConfigLocation = QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation); - for (const QString &dir : lstGenericConfigLocation) { + // Iterate from the last item since some items may be subfolders of others. + for (QStringList::const_reverse_iterator constIterator = lstGenericConfigLocation.crbegin(); + constIterator != lstGenericConfigLocation.crend(); + ++constIterator) { + const QString &dir = (*constIterator); if (path.startsWith(dir + plus)) { relativePath = path.mid(dir.length() + 1); return QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1Char('/') + relativePath; From f9079c8413e52071bacced70bf0394dd65f14ce3 Mon Sep 17 00:00:00 2001 From: Kevin Funk Date: Fri, 18 Sep 2020 09:55:18 +0200 Subject: [PATCH 059/259] CMake: Also set SKIP_AUTOUIC on generated files Otherwise we get a CMake warning, just as: ``` CMake Warning (dev) in resources/sugarcrm/CMakeLists.txt: Policy CMP0071 is not set: Let AUTOMOC and AUTOUIC process GENERATED files. Run "cmake --help-policy CMP0071" for policy details. Use the cmake_policy command to set the policy and suppress this warning. For compatibility, CMake is excluding the GENERATED source file(s): "/home/kfunk/devel/build/kdab/FatCRM/resources/sugarcrm/settings.cpp" "/home/kfunk/devel/build/kdab/FatCRM/resources/sugarcrm/settings.h" from processing by AUTOMOC and AUTOUIC. (...) ``` Also merge calls to set_source_files_properties() as it can handle multiple files at once. --- KF5ConfigMacros.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/KF5ConfigMacros.cmake b/KF5ConfigMacros.cmake index 99897792..7938e4cf 100644 --- a/KF5ConfigMacros.cmake +++ b/KF5ConfigMacros.cmake @@ -96,8 +96,10 @@ function (KCONFIG_ADD_KCFG_FILES _target_or_source_var) MAIN_DEPENDENCY ${_tmp_FILE} DEPENDS ${_kcfg_FILE} KF5::kconfig_compiler) - set_source_files_properties(${_header_FILE} PROPERTIES SKIP_AUTOMOC ON) # don't run automoc on this file - set_source_files_properties(${_src_FILE} PROPERTIES SKIP_AUTOMOC ON) # don't run automoc on this file + set_source_files_properties(${_header_FILE} ${_src_FILE} PROPERTIES + SKIP_AUTOMOC ON + SKIP_AUTOUIC ON + ) if(ARG_GENERATE_MOC) list(APPEND sources ${_moc_FILE}) From 21a40e05397f15aea066cabd36b9ada9d6ba412b Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Mon, 21 Sep 2020 05:53:34 +0200 Subject: [PATCH 060/259] SVN_SILENT made messages (.desktop file) - always resolve ours In case of conflict in i18n, keep the version of the branch "ours" To resolve a particular conflict, "git checkout --ours path/to/file.desktop" --- src/core/kconfigbackend.desktop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/kconfigbackend.desktop b/src/core/kconfigbackend.desktop index 496eb7b4..44f67b0d 100644 --- a/src/core/kconfigbackend.desktop +++ b/src/core/kconfigbackend.desktop @@ -80,7 +80,7 @@ Comment[tr]=KConfig için Depolama Arka Ucu Comment[tt]=KConfig өчен саклау бэкенды Comment[ug]=KConfig نىڭ ساقلاش ئارقا ئۇچى Comment[uk]=Модуль зберігання даних для KConfig -Comment[vi]=Hậu trường lưu trữ cho KConfig +Comment[vi]=Hậu phương lưu trữ cho KConfig Comment[wa]=Bouye di fond di stocaedje po KConfig Comment[x-test]=xxStorage backend for KConfigxx Comment[zh_CN]=KConfig 存储后端 From 23a91a4e92e946d8869e7426b6fc93c06bcd4466 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sun, 4 Oct 2020 09:47:53 +0000 Subject: [PATCH 061/259] GIT_SILENT Upgrade ECM and KF5 version requirements for 5.75.0 release. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6766332b..1a040bb9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ set(KF5_VERSION "5.75.0") # handled by release scripts project(KConfig VERSION ${KF5_VERSION}) include(FeatureSummary) -find_package(ECM 5.74.0 NO_MODULE) +find_package(ECM 5.75.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) From 3d43fb00ac762a51259b8cb07466fc7a303f6e57 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 10 Oct 2020 15:37:39 +0000 Subject: [PATCH 062/259] GIT_SILENT Upgrade KF5 version to 5.76.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a040bb9..7468005e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.5) -set(KF5_VERSION "5.75.0") # handled by release scripts +set(KF5_VERSION "5.76.0") # handled by release scripts project(KConfig VERSION ${KF5_VERSION}) include(FeatureSummary) From bc620cca1f4154704744fcdeb4f706e0c54e46f8 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Thu, 8 Oct 2020 20:46:51 +0200 Subject: [PATCH 063/259] Port QRegExp to QRegularExpression --- src/kconfig_compiler/KConfigSourceGenerator.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/kconfig_compiler/KConfigSourceGenerator.cpp b/src/kconfig_compiler/KConfigSourceGenerator.cpp index bb2694b2..2a8cf7f3 100644 --- a/src/kconfig_compiler/KConfigSourceGenerator.cpp +++ b/src/kconfig_compiler/KConfigSourceGenerator.cpp @@ -14,6 +14,7 @@ #include "KConfigSourceGenerator.h" #include "KConfigCommonStructs.h" +#include KConfigSourceGenerator::KConfigSourceGenerator( const QString &inputFile, @@ -334,7 +335,7 @@ void KConfigSourceGenerator::createNormalEntry(const CfgEntry *entry, const QStr } if (!entry->parentGroup.isEmpty()) { - stream() << " " << itemVarStr << "->setGroup(cg" << QString(entry->group).remove(QRegExp(QStringLiteral("\\W"))) << ");\n"; + stream() << " " << itemVarStr << "->setGroup(cg" << QString(entry->group).remove(QRegularExpression(QStringLiteral("\\W"))) << ");\n"; } stream() << " addItem( " << itemVarStr; @@ -421,16 +422,16 @@ void KConfigSourceGenerator::handleCurrentGroupChange(const CfgEntry *entry) mCurrentGroup = entry->group; if (!entry->parentGroup.isEmpty()) { - QString parentGroup = QString(entry->parentGroup).remove(QRegExp(QStringLiteral("\\W"))); + QString parentGroup = QString(entry->parentGroup).remove(QRegularExpression(QStringLiteral("\\W"))); if (!mConfigGroupList.contains(parentGroup)) { stream() << " KConfigGroup cg" << parentGroup << "(this->config(), " << paramString(entry->parentGroup, parseResult.parameters) << ");\n"; mConfigGroupList << parentGroup; } - QString currentGroup = QString(mCurrentGroup).remove(QRegExp(QStringLiteral("\\W"))); + QString currentGroup = QString(mCurrentGroup).remove(QRegularExpression(QStringLiteral("\\W"))); if (!mConfigGroupList.contains(currentGroup)) { stream() << " KConfigGroup cg" << currentGroup - << " = cg" << QString(entry->parentGroup).remove(QRegExp(QStringLiteral("\\W"))) + << " = cg" << QString(entry->parentGroup).remove(QRegularExpression(QStringLiteral("\\W"))) << ".group(" << paramString(mCurrentGroup, parseResult.parameters) << ");\n"; mConfigGroupList << currentGroup; } From c81dfc9c2006293dc9a48f0aaba204af28fa6b98 Mon Sep 17 00:00:00 2001 From: David Hurka Date: Sat, 5 Sep 2020 16:24:59 +0200 Subject: [PATCH 064/259] kconf_update: Allow repeated tests in --testmode by ignoring kconf_updaterc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://techbase.kde.org/Development/Tools/Using_kconf_update#Debugging_and_testing describes how to run repeated tests of kconf_update scripts in --testmode. It is necessary to delete update group flags from kconf_updaterc, which is inconvenient. With this patch, kconf_update will not use kconf_updaterc when in --testmode, so this step is no longer necessary. Additionally, running all installed update scripts automatically is no longer possible in --testmode, since that is probably only useful if you have your home directory in ~/.qttest/config/. I don’t expect problems, since this affects only --testmode, and the update group flags are still present in the modified config files themselves. --- src/kconf_update/kconf_update.cpp | 75 ++++++++++++++++++------------- 1 file changed, 44 insertions(+), 31 deletions(-) diff --git a/src/kconf_update/kconf_update.cpp b/src/kconf_update/kconf_update.cpp index bd5f630f..99f6fd5c 100644 --- a/src/kconf_update/kconf_update.cpp +++ b/src/kconf_update/kconf_update.cpp @@ -71,11 +71,13 @@ class KonfUpdate QStringList parseGroupString(const QString &_str); protected: + /** kconf_updaterc */ KConfig *m_config; QString m_currentFilename; bool m_skip; bool m_skipFile; - bool m_debug; + bool m_bTestMode; + bool m_bDebugOutput; QString m_id; QString m_oldFile; @@ -110,8 +112,8 @@ KonfUpdate::KonfUpdate(QCommandLineParser *parser) QStringList updateFiles; - m_debug = parser->isSet(QStringLiteral("debug")); - if (m_debug) { + m_bDebugOutput = parser->isSet(QStringLiteral("debug")); + if (m_bDebugOutput) { // The only way to enable debug reliably is through a filter rule. // The category itself is const, so we can't just go around changing // its mode. This can however be overridden by the environment, so @@ -125,7 +127,8 @@ KonfUpdate::KonfUpdate(QCommandLineParser *parser) } } - if (parser->isSet(QStringLiteral("testmode"))) { + m_bTestMode = parser->isSet(QStringLiteral("testmode")); + if (m_bTestMode) { QStandardPaths::setTestModeEnabled(true); } @@ -141,6 +144,9 @@ KonfUpdate::KonfUpdate(QCommandLineParser *parser) updateFiles.append(file); } else if (!parser->positionalArguments().isEmpty()) { updateFiles += parser->positionalArguments(); + } else if (m_bTestMode) { + qWarning("Test mode enabled, but no files given."); + return; } else { if (cg.readEntry("autoUpdateDisabled", false)) { return; @@ -294,6 +300,7 @@ bool KonfUpdate::updateFile(const QString &filename) m_skip = true; QFile file(filename); if (!file.open(QIODevice::ReadOnly)) { + qWarning("Could not open update-file '%s'.", qUtf8Printable(filename)); return false; } @@ -358,19 +365,24 @@ bool KonfUpdate::updateFile(const QString &filename) // Flush. gotId(QString()); - QFileInfo info(filename); - KConfigGroup cg(m_config, m_currentFilename); - if (info.birthTime().isValid()) { - cg.writeEntry("ctime", info.birthTime().toSecsSinceEpoch()); + // Remember that this file was updated: + if (!m_bTestMode) { + QFileInfo info(filename); + KConfigGroup cg(m_config, m_currentFilename); + if (info.birthTime().isValid()) { + cg.writeEntry("ctime", info.birthTime().toSecsSinceEpoch()); + } + cg.writeEntry("mtime", info.lastModified().toSecsSinceEpoch()); + cg.sync(); } - cg.writeEntry("mtime", info.lastModified().toSecsSinceEpoch()); - cg.sync(); + return true; } void KonfUpdate::gotId(const QString &_id) { - if (!m_id.isEmpty() && !m_skip) { + // Remember that the last update group has been done: + if (!m_id.isEmpty() && !m_skip && !m_bTestMode) { KConfigGroup cg(m_config, m_currentFilename); QStringList ids = cg.readEntry("done", QStringList()); @@ -383,25 +395,26 @@ void KonfUpdate::gotId(const QString &_id) // Flush pending changes gotFile(QString()); - KConfigGroup cg(m_config, m_currentFilename); + if (_id.isEmpty()) { + return; + } + + // Check whether this update group needs to be done: + KConfigGroup cg(m_config, m_currentFilename); QStringList ids = cg.readEntry("done", QStringList()); - if (!_id.isEmpty()) { - if (ids.contains(_id)) { - //qDebug("Id '%s' was already in done-list", _id.toLatin1().constData()); - if (!m_bUseConfigInfo) { - m_skip = true; - return; - } - } - m_skip = false; - m_skipFile = false; - m_id = _id; - if (m_bUseConfigInfo) { - qCDebug(KCONF_UPDATE_LOG) << m_currentFilename << ": Checking update" << _id; - } else { - qCDebug(KCONF_UPDATE_LOG) << m_currentFilename << ": Found new update" << _id; - } + if (ids.contains(_id) && !m_bUseConfigInfo) { + //qDebug("Id '%s' was already in done-list", _id.toLatin1().constData()); + m_skip = true; + return; + } + m_skip = false; + m_skipFile = false; + m_id = _id; + if (m_bUseConfigInfo) { + qCDebug(KCONF_UPDATE_LOG) << m_currentFilename << ": Checking update" << _id; + } else { + qCDebug(KCONF_UPDATE_LOG) << m_currentFilename << ": Found new update" << _id; } } @@ -795,7 +808,7 @@ void KonfUpdate::gotScript(const QString &_script) proc.setStandardInputFile(scriptIn.fileName()); proc.setStandardOutputFile(scriptOut.fileName()); if (m_oldConfig1) { - if (m_debug) { + if (m_bDebugOutput) { //scriptIn.setAutoRemove(false); qCDebug(KCONF_UPDATE_LOG) << "Script input stored in" << scriptIn.fileName(); } @@ -818,7 +831,7 @@ void KonfUpdate::gotScript(const QString &_script) } qCDebug(KCONF_UPDATE_LOG) << "About to run" << cmd; - if (m_debug) { + if (m_bDebugOutput) { QFile scriptFile(path); if (scriptFile.open(QIODevice::ReadOnly)) { qCDebug(KCONF_UPDATE_LOG) << "Script contents is:\n" << scriptFile.readAll(); @@ -854,7 +867,7 @@ void KonfUpdate::gotScript(const QString &_script) return; // Nothing to merge } - if (m_debug) { + if (m_bDebugOutput) { //scriptOut.setAutoRemove(false); qCDebug(KCONF_UPDATE_LOG) << "Script output stored in" << scriptOut.fileName(); QFile output(scriptOut.fileName()); From 945ff64855fc742ab06185767ce769d78495c9cb Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Fri, 23 Oct 2020 08:32:00 +0200 Subject: [PATCH 065/259] If include is define in .h remove it if it's defined in .cpp too (scripted) --- autotests/kconfig_compiler/kconfigcompiler_test.cpp | 1 - autotests/kentrymaptest.cpp | 1 - src/core/kconfig.cpp | 1 - src/kconfig_compiler/KConfigCodeGeneratorBase.cpp | 3 --- src/kconfig_compiler/KConfigHeaderGenerator.cpp | 1 - src/kconfig_compiler/KConfigSourceGenerator.cpp | 1 - src/kconfig_compiler/KConfigXmlParser.cpp | 1 - 7 files changed, 9 deletions(-) diff --git a/autotests/kconfig_compiler/kconfigcompiler_test.cpp b/autotests/kconfig_compiler/kconfigcompiler_test.cpp index bb4dd7c0..c16075d6 100644 --- a/autotests/kconfig_compiler/kconfigcompiler_test.cpp +++ b/autotests/kconfig_compiler/kconfigcompiler_test.cpp @@ -8,7 +8,6 @@ */ #include -#include #include #include #include diff --git a/autotests/kentrymaptest.cpp b/autotests/kentrymaptest.cpp index 507a88f6..a84c4b4e 100644 --- a/autotests/kentrymaptest.cpp +++ b/autotests/kentrymaptest.cpp @@ -7,7 +7,6 @@ #include "kentrymaptest.h" #include -#include "kconfigdata.h" const QByteArray group1("A Group"); const QByteArray key1("A Key"); diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index 19e82ffe..92c05bae 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -21,7 +21,6 @@ #include #include -#include #include #include #include diff --git a/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp b/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp index 48a24af5..6bcd2911 100644 --- a/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp +++ b/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp @@ -12,10 +12,7 @@ */ #include "KConfigCodeGeneratorBase.h" -#include "KConfigParameters.h" -#include "KConfigCommonStructs.h" -#include #include #include diff --git a/src/kconfig_compiler/KConfigHeaderGenerator.cpp b/src/kconfig_compiler/KConfigHeaderGenerator.cpp index ec353158..8bc5f47d 100644 --- a/src/kconfig_compiler/KConfigHeaderGenerator.cpp +++ b/src/kconfig_compiler/KConfigHeaderGenerator.cpp @@ -12,7 +12,6 @@ */ #include "KConfigHeaderGenerator.h" -#include "KConfigCommonStructs.h" #include #include diff --git a/src/kconfig_compiler/KConfigSourceGenerator.cpp b/src/kconfig_compiler/KConfigSourceGenerator.cpp index 2a8cf7f3..97db81ba 100644 --- a/src/kconfig_compiler/KConfigSourceGenerator.cpp +++ b/src/kconfig_compiler/KConfigSourceGenerator.cpp @@ -12,7 +12,6 @@ */ #include "KConfigSourceGenerator.h" -#include "KConfigCommonStructs.h" #include diff --git a/src/kconfig_compiler/KConfigXmlParser.cpp b/src/kconfig_compiler/KConfigXmlParser.cpp index 3120d006..e1010564 100644 --- a/src/kconfig_compiler/KConfigXmlParser.cpp +++ b/src/kconfig_compiler/KConfigXmlParser.cpp @@ -12,7 +12,6 @@ */ #include "KConfigXmlParser.h" -#include "KConfigParameters.h" #include #include From 637775da175a59f7fae60b8abdc95d302dd24612 Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Sat, 24 Oct 2020 04:25:11 +0000 Subject: [PATCH 066/259] Find missing Qt5DBus dependency Matters for static builds. Fixes the static KContacts build for me --- KF5ConfigConfig.cmake.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/KF5ConfigConfig.cmake.in b/KF5ConfigConfig.cmake.in index f8e5eb0b..d24ae2ba 100644 --- a/KF5ConfigConfig.cmake.in +++ b/KF5ConfigConfig.cmake.in @@ -8,6 +8,10 @@ include("${CMAKE_CURRENT_LIST_DIR}/KF5ConfigTargets.cmake") include(CMakeFindDependencyMacro) find_dependency(Qt5Xml "@REQUIRED_QT_VERSION@") +if(@KCONFIG_USE_DBUS@) + find_dependency(Qt5DBus "@REQUIRED_QT_VERSION@") +endif() + if(CMAKE_CROSSCOMPILING AND KF5_HOST_TOOLING) find_file(KCONFIGCOMPILER_PATH KF5Config/KF5ConfigCompilerTargets.cmake PATHS ${KF5_HOST_TOOLING} ${CMAKE_CURRENT_LIST_DIR} From 0ce10a9dbfffe37bcede198a92210402e5260030 Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Mon, 2 Nov 2020 18:56:46 +0100 Subject: [PATCH 067/259] ConfigLoaderHandler::parse(): fix inverted sanity check logic at parse end No caller cares for success flag, so this just has confused human code readers for now. NO_CHANGELOG --- src/gui/kconfigloader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kconfigloader.cpp b/src/gui/kconfigloader.cpp index bfc7e9e8..085b03bb 100644 --- a/src/gui/kconfigloader.cpp +++ b/src/gui/kconfigloader.cpp @@ -70,7 +70,7 @@ bool ConfigLoaderHandler::parse(QIODevice *input) } } - if (reader.isEndDocument()) { + if (!reader.isEndDocument()) { return false; } From 2c272cdddbd85b7f8388c29b6427b9f61bf11284 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 7 Nov 2020 11:34:22 +0000 Subject: [PATCH 068/259] GIT_SILENT Upgrade ECM and KF5 version requirements for 5.76.0 release. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7468005e..d9def8c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ set(KF5_VERSION "5.76.0") # handled by release scripts project(KConfig VERSION ${KF5_VERSION}) include(FeatureSummary) -find_package(ECM 5.75.0 NO_MODULE) +find_package(ECM 5.76.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) From 2f68c5427c4a1643018b9a41bff2c83e50c5a03f Mon Sep 17 00:00:00 2001 From: Fabian Vogt Date: Sat, 7 Nov 2020 14:54:36 +0100 Subject: [PATCH 069/259] Fix KConfigGroup::copyTo with KConfigBase::Notify Without this, bNotify was not set on copies, making Notify a noop. CCBUG: 428771 --- src/core/kconfig.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index 92c05bae..f9257632 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -162,6 +162,10 @@ void KConfigPrivate::copyGroup(const QByteArray &source, const QByteArray &desti entry.bGlobal = true; } + if (flags & KConfigBase::Notify) { + entry.bNotify = true; + } + otherMap[newKey] = entry; } From af232ec74629cec56a5b67b79f77dd903e106719 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sat, 7 Nov 2020 19:03:44 +0100 Subject: [PATCH 070/259] Add KF6 TODO to use the just-approved (*) XDG_STATE_HOME env var. See https://gitlab.freedesktop.org/xdg/xdg-specs/-/merge_requests/4 (*) by me :-) --- src/core/ksharedconfig.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/ksharedconfig.cpp b/src/core/ksharedconfig.cpp index e448e508..42b80fa7 100644 --- a/src/core/ksharedconfig.cpp +++ b/src/core/ksharedconfig.cpp @@ -110,6 +110,8 @@ KSharedConfigPtr KSharedConfig::openConfig(const QString &_fileName, KSharedConfig::Ptr KSharedConfig::openStateConfig(const QString &_fileName) { + // KF6 TODO: port this to XDG_STATE_HOME (default ~/.local/state) + // See https://gitlab.freedesktop.org/xdg/xdg-specs/-/blob/master/basedir/basedir-spec.xml QString fileName(_fileName); if (fileName.isEmpty()) { From 0d456013e44f595dbfdb30427e7e5483d3ae1870 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Mon, 16 Nov 2020 09:10:38 +0000 Subject: [PATCH 071/259] GIT_SILENT Upgrade KF5 version to 5.77.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d9def8c3..22918841 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.5) -set(KF5_VERSION "5.76.0") # handled by release scripts +set(KF5_VERSION "5.77.0") # handled by release scripts project(KConfig VERSION ${KF5_VERSION}) include(FeatureSummary) From 1538a581eb1cbb573750bf67a159dd06d8fefaed Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Fri, 27 Nov 2020 00:39:19 +0100 Subject: [PATCH 072/259] GIT_SILENT Upgrade Qt5 version requirement to 5.13.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 22918841..66318c7d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKA set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) -set(REQUIRED_QT_VERSION 5.12.0) +set(REQUIRED_QT_VERSION 5.13.0) find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Xml) option(KCONFIG_USE_GUI "Build components using Qt5Gui" ON) From 500cbfaaa77d3a5fab1d0f9a3a80f20c4c7fe45d Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Thu, 3 Dec 2020 12:51:47 +0200 Subject: [PATCH 073/259] Remove redundant comment, foreach is long gone GIT_SILENT --- autotests/kconfigtest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index 4d38b150..41f293a7 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -1863,7 +1863,7 @@ void KConfigTest::testThreads() // QEXPECT_FAIL triggers race conditions, it should be fixed to use QThreadStorage... //futures << QtConcurrent::run(this, &KConfigTest::testDeleteWhenLocalized); //futures << QtConcurrent::run(this, &KConfigTest::testEntryMap); - for (QFuture f : qAsConst(futures)) { // krazy:exclude=foreach + for (QFuture f : qAsConst(futures)) { f.waitForFinished(); } } From acfbe17bf5574e268d1261587e9194bd225a9867 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Thu, 3 Dec 2020 12:53:42 +0200 Subject: [PATCH 074/259] Fix comment GIT_SILENT --- src/core/kconfig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index f9257632..4584a65e 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -128,7 +128,7 @@ void KConfigPrivate::copyGroup(const QByteArray &source, const QByteArray &desti const int len = source.length(); const bool sameName = (destination == source); - // we keep this bool outside the foreach loop so that if + // we keep this bool outside the for loop so that if // the group is empty, we don't end up marking the other config // as dirty erroneously bool dirtied = false; From d894326ecce3ec63d8a909099263eaf1a2a0427a Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 5 Dec 2020 10:03:58 +0000 Subject: [PATCH 075/259] GIT_SILENT Upgrade ECM and KF5 version requirements for 5.77.0 release. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 66318c7d..848ddaa8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ set(KF5_VERSION "5.77.0") # handled by release scripts project(KConfig VERSION ${KF5_VERSION}) include(FeatureSummary) -find_package(ECM 5.76.0 NO_MODULE) +find_package(ECM 5.77.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) From e5fb03b6e915b176ae8804ae7317ff1977848487 Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Mon, 7 Dec 2020 12:26:11 -0700 Subject: [PATCH 076/259] Fix window sizing and positioning on Windows The feature to make windows remember their sizes and positions across screen layouts relied on calling QScreen::name() to identify screens. Unfortunately this function returns garbage on Windows; see https://bugreports.qt.io/browse/QTBUG-74317 So on Windows, let's identify displays by serial number as a workaround. BUG: 429943 FIXED-IN: 5.78 --- src/gui/kwindowconfig.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gui/kwindowconfig.cpp b/src/gui/kwindowconfig.cpp index bb541b8e..4181651f 100644 --- a/src/gui/kwindowconfig.cpp +++ b/src/gui/kwindowconfig.cpp @@ -21,7 +21,13 @@ static QString allConnectedScreens() const auto screens = QGuiApplication::screens(); names.reserve(screens.length()); for (auto screen : screens) { +#ifdef Q_OS_WIN + // QScreen::name() returns garbage on Windows; see https://bugreports.qt.io/browse/QTBUG-74317 + // So we use the screens' serial numbers to identify them instead + names << screen->serialNumber(); +#else names << screen->name(); +#endif } return names.join(QLatin1Char(' ')); } From 1be7af75767d579133e71f70f4629ac9c1e027fd Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Tue, 8 Dec 2020 12:05:12 -0700 Subject: [PATCH 077/259] Correct format of window maximized string All other resolutions are stored in the form of width x height, but a silly transposition error had the maximized strong being height x width. That's fixed now. --- src/gui/kwindowconfig.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/kwindowconfig.cpp b/src/gui/kwindowconfig.cpp index 4181651f..ddbc89a5 100644 --- a/src/gui/kwindowconfig.cpp +++ b/src/gui/kwindowconfig.cpp @@ -47,7 +47,7 @@ void KWindowConfig::saveWindowSize(const QWindow *window, KConfigGroup &config, // on a per-screen-arrangement basis, since people often like to have // windows laid out differently depending on their screen arrangements const QString allScreens = allConnectedScreens(); - const QString screenMaximizedString(allScreens + QStringLiteral(" Window-Maximized %1x%2").arg(desk.height()).arg(desk.width())); + const QString screenMaximizedString(allScreens + QStringLiteral(" Window-Maximized %1x%2").arg(desk.width()).arg(desk.height())); // Save size only if window is not maximized if (!isMaximized) { const QSize defaultSize(window->property(s_initialSizePropertyName).toSize()); @@ -84,7 +84,7 @@ void KWindowConfig::restoreWindowSize(QWindow *window, const KConfigGroup &confi const QString allScreens = allConnectedScreens(); const int width = config.readEntry(allScreens + QStringLiteral(" Width %1").arg(desk.width()), fallbackWidth); const int height = config.readEntry(allScreens + QStringLiteral(" Height %1").arg(desk.height()), fallbackHeight); - const bool isMaximized = config.readEntry(allScreens + QStringLiteral(" Window-Maximized %1x%2").arg(desk.height()).arg(desk.width()), false); + const bool isMaximized = config.readEntry(allScreens + QStringLiteral(" Window-Maximized %1x%2").arg(desk.width()).arg(desk.height()), false); // Check default size const QSize defaultSize(window->property(s_initialSizePropertyName).toSize()); From a62e53e1b1fdb363fefb74907dca339b238e99b9 Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Tue, 8 Dec 2020 12:01:49 -0700 Subject: [PATCH 078/259] Fix windows being inappropriately maximized on launch When a window is closed while maximized, we write a special string to the config file so that it gets restored in its maximized state. But we don't ever delete that thing when the window is un-maximized and closed again, causing the window to always be maximized when launched. BUG: 426813 FIXED-IN: 5.78 --- src/gui/kwindowconfig.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/kwindowconfig.cpp b/src/gui/kwindowconfig.cpp index ddbc89a5..c28ed0ff 100644 --- a/src/gui/kwindowconfig.cpp +++ b/src/gui/kwindowconfig.cpp @@ -58,6 +58,9 @@ void KWindowConfig::saveWindowSize(const QWindow *window, KConfigGroup &config, const QString hString(allScreens + QStringLiteral(" Height %1").arg(desk.height())); config.writeEntry(wString, sizeToSave.width(), options); config.writeEntry(hString, sizeToSave.height(), options); + // Don't keep the maximized string in the file since the window is + // no longer maximized at this point + config.deleteEntry(screenMaximizedString); } } if ((isMaximized == false) && !config.hasDefault(screenMaximizedString)) { From 5ec83d6cb9ad7e987e56323f8cad8139b64769e7 Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Thu, 10 Dec 2020 22:07:34 +0100 Subject: [PATCH 079/259] Use | instead of + for combining keys The latter breaks with Qt6 --- src/gui/kstandardshortcut.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gui/kstandardshortcut.cpp b/src/gui/kstandardshortcut.cpp index df5ebe4b..c55d71c3 100644 --- a/src/gui/kstandardshortcut.cpp +++ b/src/gui/kstandardshortcut.cpp @@ -47,11 +47,11 @@ struct KStandardShortcutInfo { Category category; }; -#define CTRL(x) Qt::CTRL+Qt::Key_##x -#define SHIFT(x) Qt::SHIFT+Qt::Key_##x -#define CTRLSHIFT(x) Qt::CTRL+Qt::SHIFT+Qt::Key_##x -#define ALT(x) Qt::ALT+Qt::Key_##x -#define ALTSHIFT(x) Qt::ALT+Qt::SHIFT+Qt::Key_##x +#define CTRL(x) Qt::CTRL|Qt::Key_##x +#define SHIFT(x) Qt::SHIFT|Qt::Key_##x +#define CTRLSHIFT(x) Qt::CTRL|Qt::SHIFT|Qt::Key_##x +#define ALT(x) Qt::ALT|Qt::Key_##x +#define ALTSHIFT(x) Qt::ALT|Qt::SHIFT|Qt::Key_##x /** Array of predefined KStandardShortcutInfo objects, which cover all the "standard" accelerators. Each enum value from StandardShortcut From 2f8a0d60914e3a42b154c86019ee00387bc4e620 Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Thu, 10 Dec 2020 20:52:54 +0100 Subject: [PATCH 080/259] Remove unused include --- src/gui/kconfiggroupgui.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/kconfiggroupgui.cpp b/src/gui/kconfiggroupgui.cpp index 1ffd249c..96b042af 100644 --- a/src/gui/kconfiggroupgui.cpp +++ b/src/gui/kconfiggroupgui.cpp @@ -7,7 +7,6 @@ #include -#include #include #include #include From 28a077b06d2d5052525b0e234b5971ace5675154 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 12 Dec 2020 13:07:50 +0000 Subject: [PATCH 081/259] GIT_SILENT Upgrade KF5 version to 5.78.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 848ddaa8..f0cc3df9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.5) -set(KF5_VERSION "5.77.0") # handled by release scripts +set(KF5_VERSION "5.78.0") # handled by release scripts project(KConfig VERSION ${KF5_VERSION}) include(FeatureSummary) From b3b17d054970e48479aa3afe0a9dfd836efb8536 Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Thu, 10 Dec 2020 20:47:31 +0100 Subject: [PATCH 082/259] Properly include QStringList Forward declaring it breaks with Qt6 --- src/core/kauthorized.h | 3 ++- src/core/kconfigbase.h | 2 +- src/kconf_update/kconfigutils.h | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/kauthorized.h b/src/core/kauthorized.h index 88d2e398..57a99e23 100644 --- a/src/core/kauthorized.h +++ b/src/core/kauthorized.h @@ -10,9 +10,10 @@ #include +#include + class QUrl; class QString; -class QStringList; /** * The functions in this namespace provide the core of the Kiosk action diff --git a/src/core/kconfigbase.h b/src/core/kconfigbase.h index a4fed200..0682a6b5 100644 --- a/src/core/kconfigbase.h +++ b/src/core/kconfigbase.h @@ -13,9 +13,9 @@ #include +#include #include -class QStringList; class KConfigGroup; class KConfigBasePrivate; diff --git a/src/kconf_update/kconfigutils.h b/src/kconf_update/kconfigutils.h index 4656be1d..5b07c4fe 100644 --- a/src/kconf_update/kconfigutils.h +++ b/src/kconf_update/kconfigutils.h @@ -9,8 +9,9 @@ #ifndef KCONFIGUTILS_H #define KCONFIGUTILS_H +#include + class QString; -class QStringList; class KConfig; class KConfigGroup; From 854a5e65cba175ed9f9654c967822aa4b170927b Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Sun, 13 Dec 2020 10:05:01 +0100 Subject: [PATCH 083/259] Don't include QtTest as it includes all QtCore includes --- autotests/fallbackconfigresourcestest.cpp | 2 +- autotests/kconfig_compiler/kconfigcompiler_test.cpp | 2 +- autotests/kconfigloadertest.h | 2 +- autotests/kconfignokdehometest.cpp | 2 +- autotests/kconfigtest.cpp | 4 +++- autotests/kdesktopfiletest.cpp | 2 +- autotests/kentrymaptest.cpp | 2 +- autotests/ksharedconfigtest.cpp | 2 +- autotests/kstandardshortcuttest.cpp | 2 +- 9 files changed, 11 insertions(+), 9 deletions(-) diff --git a/autotests/fallbackconfigresourcestest.cpp b/autotests/fallbackconfigresourcestest.cpp index 8d7768ee..0b1a3697 100644 --- a/autotests/fallbackconfigresourcestest.cpp +++ b/autotests/fallbackconfigresourcestest.cpp @@ -5,7 +5,7 @@ SPDX-License-Identifier: LGPL-2.0-or-later */ -#include +#include #include #include diff --git a/autotests/kconfig_compiler/kconfigcompiler_test.cpp b/autotests/kconfig_compiler/kconfigcompiler_test.cpp index c16075d6..6afc0096 100644 --- a/autotests/kconfig_compiler/kconfigcompiler_test.cpp +++ b/autotests/kconfig_compiler/kconfigcompiler_test.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include "kconfigcompiler_test.h" diff --git a/autotests/kconfigloadertest.h b/autotests/kconfigloadertest.h index 697aa06b..0a4b58a1 100644 --- a/autotests/kconfigloadertest.h +++ b/autotests/kconfigloadertest.h @@ -7,7 +7,7 @@ #ifndef KCONFIGLOADERTEST_H #define KCONFIGLOADERTEST_H -#include +#include class KConfigLoader; diff --git a/autotests/kconfignokdehometest.cpp b/autotests/kconfignokdehometest.cpp index 8c29fb37..1d05d98d 100644 --- a/autotests/kconfignokdehometest.cpp +++ b/autotests/kconfignokdehometest.cpp @@ -6,7 +6,7 @@ #include -#include +#include #include #include diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index 41f293a7..20414e45 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -12,9 +12,11 @@ #include "config-kconfig.h" -#include +#include #include #include +#include +#include #include #include diff --git a/autotests/kdesktopfiletest.cpp b/autotests/kdesktopfiletest.cpp index 983ac68d..e1b9c997 100644 --- a/autotests/kdesktopfiletest.cpp +++ b/autotests/kdesktopfiletest.cpp @@ -11,7 +11,7 @@ #include "kdesktopfile.h" -#include +#include QTEST_MAIN(KDesktopFileTest) diff --git a/autotests/kentrymaptest.cpp b/autotests/kentrymaptest.cpp index a84c4b4e..406e4e99 100644 --- a/autotests/kentrymaptest.cpp +++ b/autotests/kentrymaptest.cpp @@ -6,7 +6,7 @@ #include "kentrymaptest.h" -#include +#include const QByteArray group1("A Group"); const QByteArray key1("A Key"); diff --git a/autotests/ksharedconfigtest.cpp b/autotests/ksharedconfigtest.cpp index 97a9d69c..957b509f 100644 --- a/autotests/ksharedconfigtest.cpp +++ b/autotests/ksharedconfigtest.cpp @@ -5,7 +5,7 @@ SPDX-License-Identifier: LGPL-2.0-or-later */ -#include +#include #include #include diff --git a/autotests/kstandardshortcuttest.cpp b/autotests/kstandardshortcuttest.cpp index e2447037..33fdf2f1 100644 --- a/autotests/kstandardshortcuttest.cpp +++ b/autotests/kstandardshortcuttest.cpp @@ -4,7 +4,7 @@ SPDX-License-Identifier: LGPL-2.0-or-later */ -#include +#include #include "kstandardshortcuttest.h" QTEST_MAIN(KStandardShortcutTest) // GUI needed by KAccel From b6f0f66e5c0dc4f95e8cece1b9ec7241691c065e Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Sun, 13 Dec 2020 11:00:59 +0100 Subject: [PATCH 084/259] Make sure to use en language --- autotests/kstandardshortcuttest.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/autotests/kstandardshortcuttest.cpp b/autotests/kstandardshortcuttest.cpp index 33fdf2f1..69e234ab 100644 --- a/autotests/kstandardshortcuttest.cpp +++ b/autotests/kstandardshortcuttest.cpp @@ -11,6 +11,15 @@ QTEST_MAIN(KStandardShortcutTest) // GUI needed by KAccel #include +#ifndef Q_OS_WIN +void initLocale() +{ + setenv("LC_ALL", "en_US.utf-8", 1); +} + +Q_CONSTRUCTOR_FUNCTION(initLocale) +#endif + void KStandardShortcutTest::testShortcutDefault() { QCOMPARE(QKeySequence::listToString(KStandardShortcut::hardcodedDefaultShortcut(KStandardShortcut::FullScreen)), QLatin1String("Ctrl+Shift+F")); From 6399823048ffe243767d7ccf75a9a802b1ab7513 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Fri, 18 Dec 2020 18:54:04 +0100 Subject: [PATCH 085/259] GIT_SILENT Upgrade Qt5 version requirement to 5.14.0. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f0cc3df9..dda24d39 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKA set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) -set(REQUIRED_QT_VERSION 5.13.0) +set(REQUIRED_QT_VERSION 5.14.0) find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Xml) option(KCONFIG_USE_GUI "Build components using Qt5Gui" ON) @@ -52,7 +52,7 @@ ecm_setup_version(PROJECT VARIABLE_PREFIX KCONFIG SOVERSION 5) add_definitions(-DQT_NO_FOREACH) -add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050d00) +add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050e00) add_subdirectory(src) if (BUILD_TESTING) From d9eb723d528c63265a6a534a3a6b660eded95d45 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Fri, 18 Dec 2020 19:16:53 +0100 Subject: [PATCH 086/259] Remove ifdefs, we require Qt 5.14 now --- src/core/kconfig.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index 4584a65e..2a3c614f 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -67,17 +67,10 @@ KConfigPrivate::KConfigPrivate(KConfig::OpenFlags flags, } static QBasicAtomicInt use_etc_kderc = Q_BASIC_ATOMIC_INITIALIZER(-1); -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) - if (use_etc_kderc.load() < 0) { - use_etc_kderc.store( !qEnvironmentVariableIsSet("KDE_SKIP_KDERC")); // for unit tests - } - if (use_etc_kderc.load()) { -#else if (use_etc_kderc.loadRelaxed() < 0) { use_etc_kderc.storeRelaxed( !qEnvironmentVariableIsSet("KDE_SKIP_KDERC")); // for unit tests } if (use_etc_kderc.loadRelaxed()) { -#endif etc_kderc = #ifdef Q_OS_WIN QFile::decodeName(qgetenv("WINDIR") + "/kde5rc"); @@ -85,11 +78,7 @@ KConfigPrivate::KConfigPrivate(KConfig::OpenFlags flags, QStringLiteral("/etc/kde5rc"); #endif if (!QFileInfo(etc_kderc).isReadable()) { -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) - use_etc_kderc.store(false); -#else use_etc_kderc.storeRelaxed(false); -#endif etc_kderc.clear(); } } @@ -267,11 +256,7 @@ KConfig::KConfig(KConfigPrivate &d) KConfig::~KConfig() { Q_D(KConfig); -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) - if (d->bDirty && (d->mBackend && d->mBackend->ref.load() == 1)) { -#else if (d->bDirty && (d->mBackend && d->mBackend->ref.loadRelaxed() == 1)) { -#endif sync(); } delete d; From 5744d5c2127c6235f3615a1596937fb971003eaf Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 2 Jan 2021 12:22:49 +0000 Subject: [PATCH 087/259] GIT_SILENT Upgrade ECM and KF5 version requirements for 5.78.0 release. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dda24d39..ecd8e3d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ set(KF5_VERSION "5.78.0") # handled by release scripts project(KConfig VERSION ${KF5_VERSION}) include(FeatureSummary) -find_package(ECM 5.77.0 NO_MODULE) +find_package(ECM 5.78.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) From bd46a52f9f968e811178e460f395fcf5257c0d93 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 9 Jan 2021 09:52:19 +0000 Subject: [PATCH 088/259] GIT_SILENT Upgrade KF5 version to 5.79.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ecd8e3d3..2bbe0f75 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.5) -set(KF5_VERSION "5.78.0") # handled by release scripts +set(KF5_VERSION "5.79.0") # handled by release scripts project(KConfig VERSION ${KF5_VERSION}) include(FeatureSummary) From 80e1cd8c5d9a5027f86bd2d233d2984b11d54d51 Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Sun, 10 Jan 2021 17:09:43 +0100 Subject: [PATCH 089/259] Port to QRecursiveMutex Using QMutex in recursive mode is deprecated. --- src/core/kauthorized.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/kauthorized.cpp b/src/core/kauthorized.cpp index 8e459d47..3a06c887 100644 --- a/src/core/kauthorized.cpp +++ b/src/core/kauthorized.cpp @@ -21,7 +21,7 @@ #include -#include +#include #include extern bool kde_kiosk_exception; @@ -160,7 +160,7 @@ class KAuthorizedPrivate { public: KAuthorizedPrivate() - : actionRestrictions(false), blockEverything(false), mutex(QMutex::Recursive) + : actionRestrictions(false), blockEverything(false) { Q_ASSERT_X(QCoreApplication::instance(), "KAuthorizedPrivate()", "There has to be an existing QCoreApplication::instance() pointer"); @@ -181,7 +181,7 @@ class KAuthorizedPrivate bool actionRestrictions : 1; bool blockEverything : 1; QList urlActionRestrictions; - QMutex mutex; + QRecursiveMutex mutex; }; Q_GLOBAL_STATIC(KAuthorizedPrivate, authPrivate) From 6aa8ad50cec0ac1a0e798d2f141f18cff35d8009 Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Thu, 14 Jan 2021 19:05:03 +0100 Subject: [PATCH 090/259] QString::split(QChar, Qt::SplitBehavior, ...) is already in Qt 5.14 NO_CHANGELOG --- src/gui/kconfigloader.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/gui/kconfigloader.cpp b/src/gui/kconfigloader.cpp index 085b03bb..18ec3d9f 100644 --- a/src/gui/kconfigloader.cpp +++ b/src/gui/kconfigloader.cpp @@ -225,11 +225,7 @@ void ConfigLoaderHandler::addItem() //FIXME: the split() is naive and will break on lists with ,'s in them //empty parts are not wanted in this case item = m_config->addItemStringList(m_name, *d->newStringList(), -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) - m_default.split(QLatin1Char(','), QString::SkipEmptyParts), m_key); -#else m_default.split(QLatin1Char(','), Qt::SkipEmptyParts), m_key); -#endif } else if (m_type == QLatin1String("uint")) { KConfigSkeleton::ItemUInt *uintItem = m_config->addItemUInt(m_name, *d->newUint(), m_default.toUInt(), m_key); From e4a8a8806c3ebefea4841a59ddee2db8f0d8117a Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Thu, 14 Jan 2021 19:07:26 +0100 Subject: [PATCH 091/259] Qt::dec & Qt::hex are already in Qt 5.14 NO_CHANGELOG --- src/kconfig_compiler/KConfigHeaderGenerator.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/kconfig_compiler/KConfigHeaderGenerator.cpp b/src/kconfig_compiler/KConfigHeaderGenerator.cpp index 8bc5f47d..43a80a60 100644 --- a/src/kconfig_compiler/KConfigHeaderGenerator.cpp +++ b/src/kconfig_compiler/KConfigHeaderGenerator.cpp @@ -245,12 +245,7 @@ void KConfigHeaderGenerator::createSignals() for (int i = 0, end = parseResult.signalList.size(); i < end; i++) { auto signal = parseResult.signalList.at(i); stream() << whitespace() << " " << signalEnumName(signal.name) << " = 0x" - << - #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0)) - hex - #else - Qt::hex - #endif + << Qt::hex << val; if (i != end-1) { stream() << ",\n"; @@ -260,12 +255,7 @@ void KConfigHeaderGenerator::createSignals() } stream() << '\n'; stream() << whitespace() << "};" - << - #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0)) - dec - #else - Qt::dec - #endif + << Qt::dec << "\n\n"; stream() << " Q_SIGNALS:"; From 63b88fed74445e64f05f4cade352a56c7291375e Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Thu, 10 Dec 2020 21:15:56 +0100 Subject: [PATCH 092/259] Adapt to Qt6 text codec changes In Qt6 QTextCodec/QTextStream::setCodec is replaced with QTextStream::setEncoding(QStringConverter::Encoding) Also UTF-8 is the new default for QTextStream. --- autotests/kconfigtest.cpp | 10 ++++++++++ src/kconf_update/kconf_update.cpp | 17 ++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index 20414e45..6f79f072 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -518,7 +518,9 @@ void KConfigTest::testPath() QFile file(testConfigDir() + "/pathtest"); file.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream out(&file); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) out.setCodec("UTF-8"); +#endif out << "[Test Group]\n" << "homePath=$HOME/foo\n" << "homePath2=file://$HOME/foo\n" @@ -580,7 +582,9 @@ void KConfigTest::testPathQtHome() QFile file(testConfigDir() + "/pathtest"); file.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream out(&file); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) out.setCodec("UTF-8"); +#endif out << "[Test Group]\n" << "dataDir[$e]=$QT_DATA_HOME/kconfigtest\n" << "cacheDir[$e]=$QT_CACHE_HOME/kconfigtest\n" @@ -1020,7 +1024,9 @@ void KConfigTest::testMerge() QFile file(testConfigDir() + "/mergetest"); file.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream out(&file); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) out.setCodec("UTF-8"); +#endif out << "[Merged Group]\n" << "entry1=Testing\n" << "entry2=More Testing\n" @@ -1058,7 +1064,9 @@ void KConfigTest::testImmutable() QFile file(testConfigDir() + "/immutabletest"); file.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream out(&file); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) out.setCodec("UTF-8"); +#endif out << "[$i]\n" << "entry1=Testing\n" << "[group][$i]\n" @@ -1083,7 +1091,9 @@ void KConfigTest::testOptionOrder() QFile file(testConfigDir() + "/doubleattrtest"); file.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream out(&file); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) out.setCodec("UTF-8"); +#endif out << "[group3]\n" << "entry2=unlocalized\n" << "entry2[$i][de_DE]=t2\n"; diff --git a/src/kconf_update/kconf_update.cpp b/src/kconf_update/kconf_update.cpp index 99f6fd5c..08b4e224 100644 --- a/src/kconf_update/kconf_update.cpp +++ b/src/kconf_update/kconf_update.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -18,6 +17,10 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#include +#endif + #include #include @@ -219,7 +222,11 @@ bool KonfUpdate::checkFile(const QString &filename) } QTextStream ts(&file); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) ts.setCodec(QTextCodec::codecForName("ISO-8859-1")); +#else + ts.setEncoding(QStringConverter::Encoding::Latin1); +#endif int lineCount = 0; resetOptions(); QString id; @@ -307,7 +314,11 @@ bool KonfUpdate::updateFile(const QString &filename) qCDebug(KCONF_UPDATE_LOG) << "Checking update-file" << filename << "for new updates"; QTextStream ts(&file); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) ts.setCodec(QTextCodec::codecForName("ISO-8859-1")); +#else + ts.setEncoding(QStringConverter::Encoding::Latin1); +#endif m_lineCount = 0; resetOptions(); bool foundVersion = false; @@ -848,7 +859,9 @@ void KonfUpdate::gotScript(const QString &_script) // Copy script stderr to log file { QTextStream ts(proc.readAllStandardError()); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) ts.setCodec(QTextCodec::codecForName("UTF-8")); +#endif while (!ts.atEnd()) { QString line = ts.readLine(); qCDebug(KCONF_UPDATE_LOG) << "[Script]" << line; @@ -882,7 +895,9 @@ void KonfUpdate::gotScript(const QString &_script) QFile output(scriptOut.fileName()); if (output.open(QIODevice::ReadOnly)) { QTextStream ts(&output); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) ts.setCodec(QTextCodec::codecForName("UTF-8")); +#endif while (!ts.atEnd()) { QString line = ts.readLine(); if (line.startsWith('[')) { From d1c58a842196c229913f908f42e8e3799b0717fc Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Mon, 18 Jan 2021 12:05:31 +0200 Subject: [PATCH 093/259] Use Q_EMIT instead of emit In C++20 there are new classes that have member functions named emit(). c.f.: https://lists.qt-project.org/pipermail/development/2020-February/038812.html https://en.cppreference.com/w/cpp/io/basic_osyncstream/emit GIT_SILENT --- src/core/kconfigwatcher.cpp | 2 +- src/core/kcoreconfigskeleton.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/kconfigwatcher.cpp b/src/core/kconfigwatcher.cpp index 495195c0..f63c39c1 100644 --- a/src/core/kconfigwatcher.cpp +++ b/src/core/kconfigwatcher.cpp @@ -96,7 +96,7 @@ void KConfigWatcher::onConfigChangeNotification(const QHashmConfig->sync()) { return false; } - emit configChanged(); + Q_EMIT configChanged(); } return true; } From b132648084df231c196e726c899761d83d0766cc Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 26 Mar 2021 10:05:31 +0100 Subject: [PATCH 094/259] KConfig: preserve the milliseconds component of QDateTime I stored a file's lastModified() into KConfig, to compare with it again on next start, and the loss of milliseconds made the code think the timestamps didn't match, even when they did. --- autotests/kconfigtest.cpp | 8 ++++++-- src/core/kconfiggroup.cpp | 13 +++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index 6f79f072..6ab50b2f 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -66,6 +66,7 @@ static QString homePath() #define SIZEENTRY QSize( 10, 20 ) #define RECTENTRY QRect( 10, 23, 5321, 13 ) #define DATETIMEENTRY QDateTime( QDate( 2002, 06, 23 ), QTime( 12, 55, 40 ) ) +#define DATETIMEWITHMSENTRY QDateTime( QDate( 2002, 06, 23 ), QTime( 12, 55, 40, 532 ) ) #define STRINGLISTENTRY (QStringList( "Hello," ) << " World") #define STRINGLISTEMPTYENTRY QStringList() #define STRINGLISTJUSTEMPTYELEMENT QStringList(QString()) @@ -154,6 +155,7 @@ void KConfigTest::initTestCase() cg.writeEntry("sizeEntry", SIZEENTRY); cg.writeEntry("dateTimeEntry", DATETIMEENTRY); cg.writeEntry("dateEntry", DATETIMEENTRY.date()); + cg.writeEntry("dateTimeWithMSEntry", DATETIMEWITHMSENTRY); KConfigGroup ct = cg; cg = KConfigGroup(&ct, "Nested Group 1"); @@ -620,10 +622,12 @@ void KConfigTest::testComplex() QCOMPARE(sc3.readEntry("pointEntry", QPoint()), POINTENTRY); QCOMPARE(sc3.readEntry("sizeEntry", SIZEENTRY), SIZEENTRY); QCOMPARE(sc3.readEntry("rectEntry", QRect(1, 2, 3, 4)), RECTENTRY); - QCOMPARE(sc3.readEntry("dateTimeEntry", QDateTime()).toString(Qt::ISODate), - DATETIMEENTRY.toString(Qt::ISODate)); + QCOMPARE(sc3.readEntry("dateTimeEntry", QDateTime()).toString(Qt::ISODateWithMs), + DATETIMEENTRY.toString(Qt::ISODateWithMs)); QCOMPARE(sc3.readEntry("dateEntry", QDate()).toString(Qt::ISODate), DATETIMEENTRY.date().toString(Qt::ISODate)); + QCOMPARE(sc3.readEntry("dateTimeWithMSEntry", QDateTime()).toString(Qt::ISODateWithMs), + DATETIMEWITHMSENTRY.toString(Qt::ISODateWithMs)); QCOMPARE(sc3.readEntry("dateTimeEntry", QDate()), DATETIMEENTRY.date()); } diff --git a/src/core/kconfiggroup.cpp b/src/core/kconfiggroup.cpp index cc4f8d0c..14cbcab8 100644 --- a/src/core/kconfiggroup.cpp +++ b/src/core/kconfiggroup.cpp @@ -27,6 +27,7 @@ #include #include +#include class KConfigGroupPrivate : public QSharedData { @@ -325,14 +326,18 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val return size; } case QMetaType::QDateTime: { - const auto list = asIntList(value); - if (list.count() != 6) { + const auto list = asRealList(value); + if (list.count() < 6) { qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(6, list.count()); return aDefault; } const QDate date(list.at(0), list.at(1), list.at(2)); - const QTime time(list.at(3), list.at(4), list.at(5)); + const qreal totalSeconds = list.at(5); + qreal seconds; + const qreal fractional = modf(totalSeconds, &seconds); + const qreal milliseconds = round(fractional * 1000.0); + const QTime time(list.at(3), list.at(4), seconds, milliseconds); const QDateTime dt(date, time); if (!dt.isValid()) { qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault); @@ -1044,7 +1049,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value, time.hour(), time.minute(), - time.second(), + time.second() + time.msec()/1000.0, }; writeEntry(key, list, flags); From b912232762e23c08e77d01aabc50ccca7a0acd72 Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Wed, 27 Jan 2021 00:17:31 +0100 Subject: [PATCH 095/259] Remove dead cmake code KDEWIN_LIBRARIES is never defined --- src/core/CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 0744409f..e35da083 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -48,10 +48,6 @@ if(KCONFIG_USE_DBUS) target_link_libraries(KF5ConfigCore PRIVATE Qt5::DBus) endif() -if(WIN32) - target_link_libraries(KF5ConfigCore PRIVATE ${KDEWIN_LIBRARIES}) -endif() - set_target_properties(KF5ConfigCore PROPERTIES VERSION ${KCONFIG_VERSION_STRING} SOVERSION ${KCONFIG_SOVERSION} EXPORT_NAME ConfigCore From 2b3bb53fde806a776e3fa27d219584f450a7f853 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Fri, 29 Jan 2021 20:38:38 +0000 Subject: [PATCH 096/259] GIT_SILENT Upgrade ECM and KF5 version requirements for 5.79.0 release. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2bbe0f75..2cdc6b98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ set(KF5_VERSION "5.79.0") # handled by release scripts project(KConfig VERSION ${KF5_VERSION}) include(FeatureSummary) -find_package(ECM 5.78.0 NO_MODULE) +find_package(ECM 5.79.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) From 1605a2b5cf459cf72b960e32702f5a32ad2cc711 Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Fri, 29 Jan 2021 22:23:01 +0100 Subject: [PATCH 097/259] Replace KF5_VERSION with KF_VERSION Frameworks will be Frameworks 6 at some point and there is no good reason to have the major version in the variable name. Given this is purely internal we can to this now, making it a bit more future-proof GIT_SILENT NO_CHANGELOG --- CMakeLists.txt | 4 ++-- src/CMakeLists.txt | 2 +- src/core/CMakeLists.txt | 2 +- src/gui/CMakeLists.txt | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2cdc6b98..4bd2df6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.5) -set(KF5_VERSION "5.79.0") # handled by release scripts -project(KConfig VERSION ${KF5_VERSION}) +set(KF_VERSION "5.79.0") # handled by release scripts +project(KConfig VERSION ${KF_VERSION}) include(FeatureSummary) find_package(ECM 5.79.0 NO_MODULE) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4f61c001..151c3249 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -17,7 +17,7 @@ if (BUILD_QCH) KF5Config_QCH NAME KConfig BASE_NAME KF5Config - VERSION ${KF5_VERSION} + VERSION ${KF_VERSION} ORG_DOMAIN org.kde SOURCES # using only public headers, to cover only public API ${KConfigCore_APIDOX_SRCS} diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index e35da083..eb16d039 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -29,7 +29,7 @@ add_library(KF5::ConfigCore ALIAS KF5ConfigCore) ecm_generate_export_header(KF5ConfigCore BASE_NAME KConfigCore GROUP_BASE_NAME KF - VERSION ${KF5_VERSION} + VERSION ${KF_VERSION} DEPRECATED_BASE_VERSION 0 DEPRECATION_VERSIONS 4.0 5.0 5.24 5.42 EXCLUDE_DEPRECATED_BEFORE_AND_AT ${EXCLUDE_DEPRECATED_BEFORE_AND_AT} diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 5a276f97..2de87570 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -13,7 +13,7 @@ add_library(KF5::ConfigGui ALIAS KF5ConfigGui) ecm_generate_export_header(KF5ConfigGui BASE_NAME KConfigGui GROUP_BASE_NAME KF - VERSION ${KF5_VERSION} + VERSION ${KF_VERSION} DEPRECATED_BASE_VERSION 0 DEPRECATION_VERSIONS 5.11 5.39 5.71 EXCLUDE_DEPRECATED_BEFORE_AND_AT ${EXCLUDE_DEPRECATED_BEFORE_AND_AT} From 828ba0e02269a072a95729f415cef07b77e897a5 Mon Sep 17 00:00:00 2001 From: Alexander Lohnau Date: Sat, 30 Jan 2021 18:33:30 +0100 Subject: [PATCH 098/259] GIT_SILENT Add auto generated .clang-format file to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3330ae38..75e91077 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ random_seed CMakeLists.txt.user* *.unc-backup* .cmake/ +/.clang-format From b57c7ad9acf45928a6debefcd432cc50432fefdb Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Mon, 1 Feb 2021 13:24:03 -0700 Subject: [PATCH 099/259] Fix restoring window size when closed while maximized The maximization string was being saved to the config file including the connected screens, but the code to read it was not, and was also looking for the old incorrect format. This could have resulted in old config values being used forever, and the window always being opened in a maximized state. BUG: 430521 FIXED-IN: 5.79 --- src/gui/kwindowconfig.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/kwindowconfig.cpp b/src/gui/kwindowconfig.cpp index c28ed0ff..98fb5165 100644 --- a/src/gui/kwindowconfig.cpp +++ b/src/gui/kwindowconfig.cpp @@ -129,7 +129,8 @@ void KWindowConfig::restoreWindowPosition(QWindow *window, const KConfigGroup &c } const QRect desk = window->screen()->geometry(); - const bool isMaximized = config.readEntry(QStringLiteral("Window-Maximized %1x%2").arg(desk.height()).arg(desk.width()), false); + const QString allScreens = allConnectedScreens(); + const bool isMaximized = config.readEntry(allScreens + QStringLiteral(" Window-Maximized %1x%2").arg(desk.width()).arg(desk.height()), false); // Don't need to restore position if the window was maximized if (isMaximized) { @@ -137,7 +138,6 @@ void KWindowConfig::restoreWindowPosition(QWindow *window, const KConfigGroup &c return; } - const QString allScreens = allConnectedScreens(); const int xPos = config.readEntry(allScreens + QStringLiteral(" XPosition"), -1); const int yPos = config.readEntry(allScreens + QStringLiteral(" YPosition"), -1); From 7766259eb5287d11d2ef60b50da9255b1307df3c Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Tue, 2 Feb 2021 10:10:55 -0700 Subject: [PATCH 100/259] Refactor window geometry save/restore code to be less fragile This commit refactors the code a bit to define the window geometry strings in one place and uses a common method to read and write them. This makes future changes much less fragile and fixes a pre-existing bug that had gone un-noticed which caused window positions to not be saved on a per-resolution basis in addition to a per-display-arrangement basis. Old strings are used if available to that people don't lose their saved position data the first time they upgrade to KF 5.79. --- src/gui/kwindowconfig.cpp | 86 +++++++++++++++++++++++++++------------ 1 file changed, 59 insertions(+), 27 deletions(-) diff --git a/src/gui/kwindowconfig.cpp b/src/gui/kwindowconfig.cpp index 98fb5165..7a47b17a 100644 --- a/src/gui/kwindowconfig.cpp +++ b/src/gui/kwindowconfig.cpp @@ -32,6 +32,42 @@ static QString allConnectedScreens() return names.join(QLatin1Char(' ')); } +// Convenience function to get an appropriate config file key under which to +// save window size, position, or maximization information. +static QString configFileString(const QRect &desk, const QString &key) +{ + // We include resolution data to also save data on a per-resolution basis + const QString returnString = QStringLiteral("%1 %2 %3x%4").arg(allConnectedScreens()).arg(key).arg(desk.width()).arg(desk.height()); + return returnString; +} + +// Convenience function for "window is maximized" string +static QString screenMaximizedString(const QRect &desk) +{ + return configFileString(desk, QStringLiteral("Window-Maximized")); +} +// Convenience function for window width string +static QString windowWidthString(const QRect &desk) +{ + return configFileString(desk, QStringLiteral("Width")); +} +// Convenience function for window height string +static QString windowHeightString(const QRect &desk) +{ + return configFileString(desk, QStringLiteral("Height")); +} +// Convenience function for window X position string +static QString windowXPositionString(const QRect &desk) +{ + return configFileString(desk, QStringLiteral("XPosition")); +} +// Convenience function for window Y position string +static QString windowYPositionString(const QRect &desk) +{ + return configFileString(desk, QStringLiteral("YPosition")); +} + + void KWindowConfig::saveWindowSize(const QWindow *window, KConfigGroup &config, KConfigGroup::WriteConfigFlags options) { // QWindow::screen() shouldn't return null, but it sometimes does due to bugs. @@ -43,30 +79,23 @@ void KWindowConfig::saveWindowSize(const QWindow *window, KConfigGroup &config, const QSize sizeToSave = window->size(); const bool isMaximized = window->windowState() & Qt::WindowMaximized; - // Prepend the names of all connected screens so that we save the size - // on a per-screen-arrangement basis, since people often like to have - // windows laid out differently depending on their screen arrangements - const QString allScreens = allConnectedScreens(); - const QString screenMaximizedString(allScreens + QStringLiteral(" Window-Maximized %1x%2").arg(desk.width()).arg(desk.height())); // Save size only if window is not maximized if (!isMaximized) { const QSize defaultSize(window->property(s_initialSizePropertyName).toSize()); const QSize defaultScreenSize(window->property(s_initialScreenSizePropertyName).toSize()); const bool sizeValid = defaultSize.isValid() && defaultScreenSize.isValid(); if (!sizeValid || (sizeValid && (defaultSize != sizeToSave || defaultScreenSize != desk.size()))) { - const QString wString(allScreens + QStringLiteral(" Width %1").arg(desk.width())); - const QString hString(allScreens + QStringLiteral(" Height %1").arg(desk.height())); - config.writeEntry(wString, sizeToSave.width(), options); - config.writeEntry(hString, sizeToSave.height(), options); + config.writeEntry(windowWidthString(desk), sizeToSave.width(), options); + config.writeEntry(windowHeightString(desk), sizeToSave.height(), options); // Don't keep the maximized string in the file since the window is // no longer maximized at this point - config.deleteEntry(screenMaximizedString); + config.deleteEntry(screenMaximizedString(desk)); } } - if ((isMaximized == false) && !config.hasDefault(screenMaximizedString)) { - config.revertToDefault(screenMaximizedString); + if ((isMaximized == false) && !config.hasDefault(screenMaximizedString(desk))) { + config.revertToDefault(screenMaximizedString(desk)); } else { - config.writeEntry(screenMaximizedString, isMaximized, options); + config.writeEntry(screenMaximizedString(desk), isMaximized, options); } } @@ -81,13 +110,14 @@ void KWindowConfig::restoreWindowSize(QWindow *window, const KConfigGroup &confi // Fall back to non-per-screen-arrangement info if it's available but // per-screen-arrangement information is not + // TODO: Remove in KF6 or maybe even KF5.80 or something. It really only needs + // to be here to transition existing users once they upgrade from 5.73 -> 5.74 const int fallbackWidth = config.readEntry(QStringLiteral("Width %1").arg(desk.width()), window->size().width()); const int fallbackHeight = config.readEntry(QStringLiteral("Height %1").arg(desk.height()), window->size().height()); - const QString allScreens = allConnectedScreens(); - const int width = config.readEntry(allScreens + QStringLiteral(" Width %1").arg(desk.width()), fallbackWidth); - const int height = config.readEntry(allScreens + QStringLiteral(" Height %1").arg(desk.height()), fallbackHeight); - const bool isMaximized = config.readEntry(allScreens + QStringLiteral(" Window-Maximized %1x%2").arg(desk.width()).arg(desk.height()), false); + const int width = config.readEntry(windowWidthString(desk), fallbackWidth); + const int height = config.readEntry(windowHeightString(desk), fallbackHeight); + const bool isMaximized = config.readEntry(configFileString(desk, QStringLiteral("Window-Maximized")), false); // Check default size const QSize defaultSize(window->property(s_initialSizePropertyName).toSize()); @@ -112,12 +142,9 @@ void KWindowConfig::saveWindowPosition(const QWindow *window, KConfigGroup &conf return; } - // Prepend the names of all connected screens so that we save the position - // on a per-screen-arrangement basis, since people often like to have - // windows positioned differently depending on their screen arrangements - const QString allScreens = allConnectedScreens(); - config.writeEntry(allScreens + QStringLiteral(" XPosition"), window->x(), options); - config.writeEntry(allScreens + QStringLiteral(" YPosition"), window->y(), options); + const QRect desk = window->screen()->geometry(); + config.writeEntry(windowXPositionString(desk), window->x(), options); + config.writeEntry(windowYPositionString(desk), window->y(), options); } void KWindowConfig::restoreWindowPosition(QWindow *window, const KConfigGroup &config) @@ -129,8 +156,7 @@ void KWindowConfig::restoreWindowPosition(QWindow *window, const KConfigGroup &c } const QRect desk = window->screen()->geometry(); - const QString allScreens = allConnectedScreens(); - const bool isMaximized = config.readEntry(allScreens + QStringLiteral(" Window-Maximized %1x%2").arg(desk.width()).arg(desk.height()), false); + const bool isMaximized = config.readEntry(configFileString(desk, QStringLiteral("Window-Maximized")), false); // Don't need to restore position if the window was maximized if (isMaximized) { @@ -138,8 +164,14 @@ void KWindowConfig::restoreWindowPosition(QWindow *window, const KConfigGroup &c return; } - const int xPos = config.readEntry(allScreens + QStringLiteral(" XPosition"), -1); - const int yPos = config.readEntry(allScreens + QStringLiteral(" YPosition"), -1); + // Fall back to non-per-resolution info if it's available but + // per-resolution information is not + // TODO: Remove in KF6 or maybe even KF5.85 or something. It really only needs + // to be here to transition existing users once they upgrade from 5.78 -> 5.79 + const int fallbackXPosition = config.readEntry(QStringLiteral("%1 XPosition %2").arg(allConnectedScreens()).arg(desk.width()), window->size().width()); + const int fallbackYPosition = config.readEntry(QStringLiteral("%1 YPosition %2").arg(allConnectedScreens()).arg(desk.height()), window->size().height()); + const int xPos = config.readEntry(windowXPositionString(desk), fallbackXPosition); + const int yPos = config.readEntry(windowYPositionString(desk), fallbackYPosition); if (xPos == -1 || yPos == -1) { return; From 68f8622dc9d40f9a8df7fa49680a109f7f924ddb Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Thu, 4 Feb 2021 06:41:42 +0100 Subject: [PATCH 101/259] SVN_SILENT made messages (.desktop file) - always resolve ours In case of conflict in i18n, keep the version of the branch "ours" To resolve a particular conflict, "git checkout --ours path/to/file.desktop" --- src/core/kconfigbackend.desktop | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/kconfigbackend.desktop b/src/core/kconfigbackend.desktop index 44f67b0d..39e35cd5 100644 --- a/src/core/kconfigbackend.desktop +++ b/src/core/kconfigbackend.desktop @@ -31,6 +31,7 @@ Comment[gd]=Backend stòrais airson KConfig Comment[gl]=Infraestrutura de almacenaxe para KConfig Comment[gu]=KConfig માટે સંગ્રહ પાશ્ર્વભાગ Comment[he]=מנוע שמירה עבור KConfig +Comment[hi]=के-कोन्फिग के लिए संचयन बैकएंड Comment[hne]=के-कानफिग बर भंडार बैकएण्ड Comment[hr]=Skladišna pozadina za KConfig Comment[hsb]=składowanski backend za KConfig From 5d0dac047384e1f46e2de57f9b9ebf4f6fde0e26 Mon Sep 17 00:00:00 2001 From: David Hurka Date: Thu, 4 Feb 2021 12:15:48 +0000 Subject: [PATCH 102/259] Fix kconfig_compiler doxygen formatting * Doxygen sections instead of markdown list items and HTML headers * More descriptive section titles * HTML Definition list instead of a wide HTML table for compiler options * HTML Definition list instead of a markdown item list for data types * Syntax highlighting for examples --- src/kconfig_compiler/README.dox | 549 +++++++++++++++++--------------- 1 file changed, 285 insertions(+), 264 deletions(-) diff --git a/src/kconfig_compiler/README.dox b/src/kconfig_compiler/README.dox index bf72f3eb..90dd4597 100644 --- a/src/kconfig_compiler/README.dox +++ b/src/kconfig_compiler/README.dox @@ -10,7 +10,7 @@ configuration data. The generated C++ source code is output to a .h and a .cpp file, whose base name is the same as that of the .kcfgc file. -

XML description of the configuration options

+\section kcfg_format The .kcfg XML file format: description of the configuration skeleton The structure of the .kcfg file is described by its DTD kcfg.xsd. @@ -41,24 +41,38 @@ by the QVariant with exception of the clearly binary types (e.g. Pixmap, Image...) which are not supported. Besides those basic types the following special types are supported: -- Path This is a string that is specially treated as a file-path. - In particular paths in the home directory are prefixed with $HOME in - when being stored in the configuration file. - -- Enum This indicates an enumeration. The possible enum values and optional - enum name should be provided via the \ tag. Enum values are - accessed as integers by the application but stored as strings in the - configuration file. This makes it possible to add more values at a later - date without breaking compatibility. - -- IntList This indicates a list of integers. This information is provided - to the application as QList. Useful for storing QSplitter - geometries. - -- Color isn't a special type but has special input. It is generated as QColor. - Any valid input to QColor(QString) can be used (hex or SVG keyword notation) - as well as a special format r,g,b,a where the a denotes the alpha channel and - may be omitted. +
+
Path
+
+ This is a string that is specially treated as a file-path. + In particular paths in the home directory are prefixed with $HOME in + when being stored in the configuration file. +
+ +
Enum
+
+ This indicates an enumeration. The possible enum values and optional + enum name should be provided via the \ tag. Enum values are + accessed as integers by the application but stored as strings in the + configuration file. This makes it possible to add more values at a later + date without breaking compatibility. +
+ +
IntList
+
+ This indicates a list of integers. This information is provided + to the application as QList. Useful for storing QSplitter + geometries. +
+ +
Color
+
+ Isn't a special type but has special input. It is generated as QColor. + Any valid input to QColor(QString) can be used (hex or SVG keyword notation) + as well as a special format r,g,b,a where the a denotes the alpha channel and + may be omitted. +
+
An entry can optionally have a default value which is used as default when the value isn't specified in any config file. Default values are interpreted @@ -75,7 +89,7 @@ entry definition via the \ tag. The contents of the \ tag is inserted as-is. A typical use for this is to compute a common default value which can then be referenced by multiple entries that follow. -

Code generation options

+\section kcfgc_format The .kcfgc file format: code generation options The options for generating the C++ sources are read from the file with the extension .kcfgc. To generate a class add the corresponding kcfgc file to the @@ -83,185 +97,189 @@ SOURCES line in the Makefile.am. The following options are read from the kcfgc file: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDefaultDescription
Filestringprogramname.kcfgName of kcfg file containing the options the class is generated for
HeaderExtensionstringhExtension to use for the name of the generated C++ header files. Since KF 5.57
SourceExtensionstringcppExtension to use for the name of the generated C++ source file. Since KF 5.57
NameSpacestring-Optional namespace for generated class
ClassNamestring-Name of generated class (required)
InheritsstringKConfigSkeletonClass the generated class inherits from. This class must inherit - KConfigSkeleton and must provide a default constructor (kcfgfile not specified), a constructor - taking a QString argument (kcfgfile with "name" attribute) and a constructor taking a - KSharedConfig::Ptr as argument (kcfgfile with "arg" attribute). - Please refer to the documentation of KConfigSkeleton. -
Visibilitystring-Inserts visibility directive (for example KDE_EXPORT) between "class" keyword and class - name in header file
SingletonboolfalseGenerated class is a singleton.
CustomAdditionsbool-
MemberVariablesstring: public|protected|private|dpointerprivateC++ access modifier used for member variables holding the configuration - values
IncludeFilescomma separated list of strings-Names of files to be included in the header of the generated class. Enclose a - file name in (escaped) double quotes to generate \#include "..." instead of - \#include \<...\>.
SourceIncludeFilescomma separated list of strings-Names of files to be included in the source file of the generated class. Enclose - a file name in (escaped) double quotes to generate \#include "..." instead of - \#include \<...\>.
Mutatorstrue, false or a comma separated list of optionsfalseIf true, mutator functions for all configuration options are generated. - If false, no mutator functions are generated. If a list is provided, - mutator functions are generated for the options that are listed.
Notifierstrue, false or a comma separated list of optionsfalseIf true, entries will be written with the Notify flag enabled, - so changes can be detected using KConfigWatcher. - If a list is provided, the options that are listed are written with - said flag.
DefaultValueGetterstrue, false or a comma separated list of optionsfalseIf true, functions to return the default value of all configuration options - are generated. If false, no default value functions are generated. If a list - is provided, default value functions are generated for the options that are listed.
ItemAccessorsboolfalseGenerate accessor functions for the KConfigSkeletonItem objects - corresponding to the configuration options. If SetUserTexts is set, - ItemAccessors also has to be set.
SetUserTextsboolfalseSet the label and whatthis texts of the items from the kcfg file.If - SetUserTexts is set, ItemAccessors also has to be set.
GlobalEnumsboolfalseIf set to true all choices of Enum items will be created in the global - scope of the generated class. If set to false, each Enum item whose enum is not - explicitly named will get its own namespace for its choices.
UseEnumTypesboolfalseIf set to true, all Enum items whose enums are named will use enum types for - the return value of accessor functions and for the parameter of mutator - functions. This eliminates the need to cast accessor return values to the enum - type if you want to use the enum type in your own code. If set to false, - accessor return values and mutator parameters will be of type int.
ForceStringFilenameboolfalseIf set to true, forces the first parameter of the generated class to be a QString when using an argument for the filename. This is useful to specify at runtime the filename of the configuration class.
GeneratePropertiesboolfalseIf set to true, a Q_PROPERTY will be generated for each member variable holding a configuration value - and the Q_OBJECT macro will be added to the generated class. - Note that you will also need to pass the GENERATE_MOC option to the kconfig_add_kcfg_files macro.
ParentInConstructorboolfalseIf set to true, the generated constructor will take an additional QObject* parameter that will be used as the object's parent. - This is useful when working with KQuickAddons::ManagedConfigModule to set it as the parent of the generated class to allow automatic settings discovery and handle the deallocation. - Note this parameter is incompatible with Singleton set to true. -
- - -

Advanced options

+ +
+
File=\
+
+ Default: \.kcfg \n + Name of kcfg file containing the options the class is generated for + +
+ +
HeaderExtension=\
+
+ Default: h \n + Since KF 5.57 \n + Extension to use for the name of the generated C++ header files. +
+ +
SourceExtension=\
+
+ Default: cpp \n + Since KF 5.57 \n + Extension to use for the name of the generated C++ source file. +
+ +
NameSpace=\
+
+ Optional namespace for generated class +
+ +
ClassName=\
+
+ Name of generated class (required) +
+ +
Inherits=\
+
+ Default: KConfigSkeleton \n + Class the generated class inherits from. + + This class must inherit KConfigSkeleton and must provide a default + constructor (kcfgfile not specified), a constructor taking a + QString argument (kcfgfile with "name" attribute) and a constructor + taking a KSharedConfig::Ptr as argument (kcfgfile with "arg" attribute). + Please refer to the documentation of KConfigSkeleton. +
+ +
Visibility=\
+
+ Inserts visibility directive (for example KDE_EXPORT) between + "class" keyword and class name in header file +
+ +
Singleton=\
+
+ Default: false \n + Generated class is a singleton. +
+ +
CustomAdditions=\
+
+ +
+ +
MemberVariables=\
+
+ Values: public, protected, private, dpointer \n + Default: private \n + C++ access modifier used for member variables holding the configuration + values +
+ +
IncludeFiles=\, \ ...
+
+ Names of files to be included in the header of the generated class. + + Enclose a file name in (escaped) double quotes to generate + \#include "..." instead of \#include \<...\>. +
+ +
SourceIncludeFiles=\, \ ...
+
+ Names of files to be included in the source file of the generated class. + + Enclose a file name in (escaped) double quotes to generate + \#include "..." instead of \#include \<...\>. +
+ +
Mutators=\
+
+ Values: true, false or a comma separated list of options \n + Default: false \n + If true, mutator functions for all configuration options are generated. + If false, no mutator functions are generated. If a list is provided, + mutator functions are generated for the options that are listed. +
+ +
Notifiers=\
+
+ Values: true, false or a comma separated list of options \n + Default: false \n + If true, entries will be written with the Notify flag enabled, + so changes can be detected using KConfigWatcher. + If a list is provided, the options that are listed are written with + said flag. +
+ +
DefaultValueGetters=\
+
+ Values: true, false or a comma separated list of options \n + Default: false \n + If true, functions to return the default value of all configuration options + are generated. If false, no default value functions are generated. If a list + is provided, default value functions are generated for the options that are listed. +
+ +
ItemAccessors=\
+
+ Default: false \n + Generate accessor functions for the KConfigSkeletonItem objects + corresponding to the configuration options. If SetUserTexts is set, + ItemAccessors also has to be set. +
+ +
SetUserTexts=\
+
+ Default: false \n + Set the label and whatthis texts of the items from the kcfg file. + If SetUserTexts is set, ItemAccessors also has to be set. +
+ +
GlobalEnums=\
+
+ Default: false \n + If set to true all choices of Enum items will be created in the global + scope of the generated class. If set to false, each Enum item whose enum is not + explicitly named will get its own namespace for its choices. +
+ +
UseEnumTypes=\
+
+ Default: false \n + If set to true, all Enum items whose enums are named will use enum types for + the return value of accessor functions and for the parameter of mutator + functions. This eliminates the need to cast accessor return values to the enum + type if you want to use the enum type in your own code. If set to false, + accessor return values and mutator parameters will be of type int. +
+ +
ForceStringFilename=\
+
+ Default: false \n + If set to true, forces the first parameter of the generated class + to be a QString when using an argument for the filename. + This is useful to specify at runtime the filename of the configuration class. +
+ +
GenerateProperties=\
+
+ Default: false \n + If set to true, a Q_PROPERTY will be generated for each member variable holding a + configuration value and the Q_OBJECT macro will be added to the generated class. + Note that you will also need to pass the GENERATE_MOC option to the + kconfig_add_kcfg_files macro. +
+ + +
ParentInConstructor=\
+
+ Default: false \n + If set to true, the generated constructor will take an additional QObject* + parameter that will be used as the object's parent. + This is useful when working with KQuickAddons::ManagedConfigModule + to set it as the parent of the generated class to allow automatic + settings discovery and handle the deallocation. + Note this parameter is incompatible with Singleton set to true. +
+
+ + +\section entry_options Advanced entry options There are several possibilities to parameterize entries. -- Parameterized entries +\subsection parametrized_entries Parameterized entries An entry can be parameterized using a fixed range parameter specified with the \ tag. Such parameter can either be an Enum or an int. An Enum @@ -284,15 +302,15 @@ param attribute is specified the default value only applies to that particular parameter value. Example 1: -\verbatim - - - #ff0000 - #00ff00 - #0000ff - #ffff00 - -\endverbatim +\code{.xml} + + + #ff0000 + #00ff00 + #0000ff + #ffff00 + +\endcode The above describes 4 color configuration entries with the following defaults: @@ -308,75 +326,77 @@ a QColor color(int ColorIndex) and a void setColor(int ColorIndex, const QColor &v) function. Example 2: -\verbatim - - - - Explosion - Crash - Missile - - - boom.wav - crash.wav - missile.wav - -\endverbatim +\code{.xml} + + + + Explosion + Crash + Missile + + + boom.wav + crash.wav + missile.wav + +\endcode The above describes 3 string configuration entries with the following defaults: +\verbatim sound_Explosion=boom.wav sound_Crash=crash.wav sound_Missile=missile.wav +\endverbatim The configuration options will be accessible to the application via a QString sound(int SoundEvent) and a void setSound(int SoundEvent, const QString &v) function. -- Parameterized groups +\subsection parametrized_groups Parameterized groups A group name can be parametrized using a parameter given to the KConfigSkeleton instance (which means this feature cannot be used with singleton classes). Example 1: -\verbatim - - - - - - - -\endverbatim +\code{.xml} + + + + + + + +\endcode In this case passing "Group2" as the 'groupname' parameter to the generated class will make it use group "Group2" for the entry "Text". -- Enums +\subsection enums Enums By default, if GlobalEnums is set to false, a separate named enum will be generated for each Enum entry. Since each enum is defined in a little enclosing class of its own, this allows the same Enum value names to be used in different enums. For example, the .kcfg entry -\verbatim +\code{.xml} -\endverbatim +\endcode will generate this public class containing the enum definition, inside the generated class: -\verbatim - class EnumKeepData - { - public: - enum type { Do, Dont, COUNT }; - }; -\endverbatim +\code{.cpp} +class EnumKeepData +{ + public: + enum type { Do, Dont, COUNT }; +}; +\endcode Since 5.68, if present the value attribute will be used as the choice value written to the backend instead of the name, allowing to write text incompatible with enum naming. @@ -388,21 +408,21 @@ in \ to prevent duplicate enum member names clashing. Using this, the names are prefixed in code with the string you specify. For example, if GlobalEnums is set to true, the .kcfg entry -\verbatim +\code{.xml} -\endverbatim +\endcode will generate config file entries of "KeepData=Do" and "KeepData=Dont", but the enum will be declared -\verbatim - enum { Keep_Do, Keep_Dont }; -\endverbatim +\code{.cpp} +enum { Keep_Do, Keep_Dont }; +\endcode It is possible to specify your own name for a generated enum, by including a 'name' parameter in \. Just like unnamed enums, this enum will be defined in @@ -412,20 +432,20 @@ Therefore the names of Enum values must be unique across both unnamed enums (if An example of a specifically named enum: -\verbatim +\code{.xml} -\endverbatim +\endcode which results in the following enum declaration, inside the generated class: -\verbatim - enum Types { Do, Dont }; -\endverbatim +\code{.cpp} +enum Types { Do, Dont }; +\endcode It is also possible to specify the use of enums external to the generated class, by including the string "::" in the enum name - just ensure that it is sufficiently @@ -433,31 +453,32 @@ qualified to be unambiguous in use. To specify use of an unnamed enum, append a trailing "::". For example, to use the enum 'myEnum' defined in class ClassA, use either of -\verbatim +\code{.xml} -\endverbatim +\endcode To specify an unnamed enum in namespace ProgSpace, use -\verbatim +\code{.xml} -\endverbatim +\endcode To specify a top-level unnamed enum, use -\verbatim +\code{.xml} -\endverbatim +\endcode To specify the top-level enum 'anotherEnum', use -\verbatim +\code{.xml} + -\endverbatim +\endcode -- Signal support. +\subsection notify_signals Notify signals An entry can emit a signal when it gets changed. First of all, you must define a list of signals for the configuration class. The signal's name may be @@ -468,26 +489,26 @@ of the entries defined in the .kcfg file. A signal definition can also contain a \ tag which will be the documentation line in the generated file. -\verbatim +\code{.xml} - stylePath - StyleCSSVariant + stylePath + StyleCSSVariant -\endverbatim +\endcode After defining the signals, you must tell which signal to emit for the entry. A signal can be emitted by multiple entries. Also, you don't need to specify the arguments for a signal, the signal name will suffice. -\verbatim +\code{.xml} -\endverbatim +\endcode You can also use the generic configChanged() signal from KConfigSkeleton to notify your application about configuration changes. From 081f559031fed7cde755e006b226cf06f33bd0f8 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Mon, 1 Feb 2021 01:03:40 +0200 Subject: [PATCH 103/259] General code cleanup Fix some clazy warnings, and some other minor code optimisations. NO_CHANGELOG --- autotests/kconfigtest.cpp | 2 +- autotests/kdesktopfiletest.cpp | 8 +++--- autotests/test_kconf_update.cpp | 8 ++---- src/core/kconfig.cpp | 2 +- src/core/kconfiggroup.cpp | 8 ++---- src/core/kconfigwatcher.cpp | 3 ++- src/core/ksharedconfig.cpp | 2 +- .../KConfigCodeGeneratorBase.cpp | 26 ++++++++---------- .../KConfigHeaderGenerator.cpp | 27 ++++++++----------- .../KConfigSourceGenerator.cpp | 26 ++++++++---------- src/kconfig_compiler/kconfig_compiler.cpp | 16 +++++++---- src/kreadconfig/kwriteconfig.cpp | 2 +- 12 files changed, 58 insertions(+), 72 deletions(-) diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index 6ab50b2f..23bcf195 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -513,7 +513,7 @@ void KConfigTest::testPath() KConfigGroup sc3(&sc2, "Path Type"); QCOMPARE(sc3.readPathEntry("homepath", QString()), HOMEPATH); QCOMPARE(sc3.readPathEntry("homepathescape", QString()), HOMEPATHESCAPE); - QCOMPARE(sc3.entryMap()["homepath"], HOMEPATH); + QCOMPARE(sc3.entryMap().value("homepath"), HOMEPATH); qputenv("WITHSLASH", "/a/"); { diff --git a/autotests/kdesktopfiletest.cpp b/autotests/kdesktopfiletest.cpp index e1b9c997..34391489 100644 --- a/autotests/kdesktopfiletest.cpp +++ b/autotests/kdesktopfiletest.cpp @@ -267,10 +267,10 @@ void KDesktopFileTest::testTryExecWithAuthorizeAction() void KDesktopFileTest::testLocateLocal_data() { - QString systemConfigLocation = QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation).last(); - QString writableConfigLocation = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation); - QString systemDataLocation = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation).last(); - QString writableDataLocation = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); + const QString systemConfigLocation = QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation).constLast(); + const QString writableConfigLocation = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation); + const QString systemDataLocation = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation).constLast(); + const QString writableDataLocation = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); QTest::addColumn("path"); QTest::addColumn("result"); diff --git a/autotests/test_kconf_update.cpp b/autotests/test_kconf_update.cpp index 52292083..ba716f28 100644 --- a/autotests/test_kconf_update.cpp +++ b/autotests/test_kconf_update.cpp @@ -331,9 +331,7 @@ void TestKConfUpdate::test() std::unique_ptr updFile(writeUpdFile(updContent)); runKConfUpdate(updFile->fileName()); - QString updateInfo = QStringLiteral("%1:%2") - .arg(updFile->fileName().section('/', -1)) - .arg(QTest::currentDataTag()); + QString updateInfo = QStringLiteral("%1:%2").arg(updFile->fileName().section(QLatin1Char('/'), -1), QTest::currentDataTag()); QString newConfContentAfter = readFile(newConfPath); if (shouldUpdateWork) { @@ -627,9 +625,7 @@ void TestKConfUpdate::testScript() runKConfUpdate(updFile->fileName()); - QString updateInfo = QStringLiteral("%1:%2") - .arg(updFile->fileName().section('/', -1)) - .arg(QTest::currentDataTag()); + QString updateInfo = QStringLiteral("%1:%2").arg(updFile->fileName().section(QLatin1Char('/'), -1), QTest::currentDataTag()); QString newConfContent = readFile(confPath); expectedNewConfContent = expectedNewConfContent.arg(updateInfo); QCOMPARE(newConfContent, expectedNewConfContent); diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index 2a3c614f..04608b0d 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -742,7 +742,7 @@ void KConfigPrivate::parseConfigFiles() files << mBackend->filePath(); } if (!isSimple()) { - files = extraFiles.toList() + files; + files = QList(extraFiles.cbegin(), extraFiles.cend()) + files; } // qDebug() << "parsing local files" << files; diff --git a/src/core/kconfiggroup.cpp b/src/core/kconfiggroup.cpp index 14cbcab8..d900458f 100644 --- a/src/core/kconfiggroup.cpp +++ b/src/core/kconfiggroup.cpp @@ -1098,13 +1098,9 @@ void KConfigGroup::writeXdgListEntry(const char *key, const QStringList &list, W // XXX List serialization being a separate layer from low-level escaping is // probably a bug. No affected entries are defined, though. - QStringList::ConstIterator it = list.constBegin(); - const QStringList::ConstIterator end = list.constEnd(); - for (; it != end; ++it) { - QString val(*it); + for (QString val : list) { // clazy:exclude=range-loop val.replace(QLatin1Char('\\'), QLatin1String("\\\\")).replace(QLatin1Char(';'), QLatin1String("\\;")); - value += val; - value += QLatin1Char(';'); + value += val + QLatin1Char(';'); } writeEntry(key, value, flags); diff --git a/src/core/kconfigwatcher.cpp b/src/core/kconfigwatcher.cpp index f63c39c1..c5aa6205 100644 --- a/src/core/kconfigwatcher.cpp +++ b/src/core/kconfigwatcher.cpp @@ -57,7 +57,8 @@ KConfigWatcher::KConfigWatcher(const KSharedConfig::Ptr &config): QStringList watchedPaths; watchedPaths << QLatin1Char('/') + d->m_config->name(); - for (const QString &file: d->m_config->additionalConfigSources()) { + const auto cfgSources = d->m_config->additionalConfigSources(); + for (const QString &file : cfgSources) { watchedPaths << QLatin1Char('/') + file; } if (d->m_config->openFlags() & KConfig::IncludeGlobals) { diff --git a/src/core/ksharedconfig.cpp b/src/core/ksharedconfig.cpp index 42b80fa7..cc6adeb9 100644 --- a/src/core/ksharedconfig.cpp +++ b/src/core/ksharedconfig.cpp @@ -77,7 +77,7 @@ KSharedConfigPtr KSharedConfig::openConfig(const QString &_fileName, list->mainConfig = nullptr; } - for (auto cfg : qAsConst(*list)) { + for (auto *cfg : qAsConst(*list)) { if (cfg->name() == fileName && cfg->d_ptr->openFlags == flags && cfg->locationType() == resType diff --git a/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp b/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp index 6bcd2911..3f308cbb 100644 --- a/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp +++ b/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp @@ -108,7 +108,7 @@ void KConfigCodeGeneratorBase::start() void KConfigCodeGeneratorBase::addHeaders(const QStringList &headerList) { - for (auto include : qAsConst(headerList)) { + for (const auto &include : headerList) { if (include.startsWith(QLatin1Char('"'))) { m_stream << "#include " << include << '\n'; } else { @@ -122,7 +122,8 @@ void KConfigCodeGeneratorBase::addHeaders(const QStringList &headerList) void KConfigCodeGeneratorBase::beginNamespaces() { if (!m_cfg.nameSpace.isEmpty()) { - for (const QString &ns : m_cfg.nameSpace.split(QStringLiteral("::"))) { + const auto nameSpaceList = m_cfg.nameSpace.split(QStringLiteral("::")); + for (const QString &ns : nameSpaceList) { m_stream << "namespace " << ns << " {\n"; } m_stream << '\n'; @@ -171,9 +172,6 @@ QString KConfigCodeGeneratorBase::memberAccessorBody(const CfgEntry *e, bool glo void KConfigCodeGeneratorBase::memberImmutableBody(const CfgEntry *e, bool globalEnums) { - QString n = e->name; - QString t = e->type; - stream() << whitespace() << "return " << m_this << "isImmutable( QStringLiteral( \""; if (!e->param.isEmpty()) { stream() << QString(e->paramName).replace(QLatin1String("$(") + e->param + QLatin1Char(')'), QLatin1String("%1")) << "\" ).arg( "; @@ -192,15 +190,13 @@ void KConfigCodeGeneratorBase::memberImmutableBody(const CfgEntry *e, bool globa } stream() << " )"; } else { - stream() << n << "\" )"; + stream() << e->name << "\" )"; } stream() << " );\n"; } void KConfigCodeGeneratorBase::createIfSetLogic(const CfgEntry *e, const QString &varExpression) { - const QString n = e->name; - const QString t = e->type; const bool hasBody = !e->signalList.empty() || m_cfg.generateProperties; m_stream << whitespace() << "if ("; @@ -208,7 +204,7 @@ void KConfigCodeGeneratorBase::createIfSetLogic(const CfgEntry *e, const QString m_stream << "v != " << varExpression << " && "; } - const auto immutablefunction = immutableFunction(n, m_cfg.dpointer ? m_cfg.className : QString()); + const auto immutablefunction = immutableFunction(e->name, m_cfg.dpointer ? m_cfg.className : QString{}); m_stream << "!" << m_this << immutablefunction << "("; if (!e->param.isEmpty()) { m_stream << " i "; @@ -218,15 +214,14 @@ void KConfigCodeGeneratorBase::createIfSetLogic(const CfgEntry *e, const QString void KConfigCodeGeneratorBase::memberMutatorBody(const CfgEntry *e) { - QString n = e->name; - QString t = e->type; // HACK: Don't open '{' manually, use startScope / endScope to automatically handle whitespace indentation. if (!e->min.isEmpty()) { - if (e->min != QLatin1String("0") || !isUnsigned(t)) { // skip writing "if uint<0" (#187579) + if (e->min != QLatin1String("0") || !isUnsigned(e->type)) { // skip writing "if uint<0" (#187579) m_stream << whitespace() << "if (v < " << e->min << ")\n"; m_stream << whitespace() << "{\n"; - m_stream << whitespace(); addDebugMethod(m_stream, m_cfg, n); + m_stream << whitespace(); + addDebugMethod(m_stream, m_cfg, e->name); m_stream << ": value \" << v << \" is less than the minimum value of " << e->min << "\";\n"; m_stream << whitespace() << " v = " << e->min << ";\n"; m_stream << whitespace() << "}\n"; @@ -237,13 +232,14 @@ void KConfigCodeGeneratorBase::memberMutatorBody(const CfgEntry *e) m_stream << '\n'; m_stream << whitespace() << "if (v > " << e->max << ")\n"; m_stream << whitespace() << "{\n"; - m_stream << whitespace(); addDebugMethod(m_stream, m_cfg, n); + m_stream << whitespace(); + addDebugMethod(m_stream, m_cfg, e->name); m_stream << ": value \" << v << \" is greater than the maximum value of " << e->max << "\";\n"; m_stream << whitespace() << " v = " << e->max << ";\n"; m_stream << whitespace() << "}\n\n"; } - const QString varExpression = m_this + varPath(n, m_cfg) + (e->param.isEmpty() ? QString() : QStringLiteral("[i]")); + const QString varExpression = m_this + varPath(e->name, m_cfg) + (e->param.isEmpty() ? QString{} : QStringLiteral("[i]")); // TODO: Remove this `hasBody` logic, always use an '{' for the if. const bool hasBody = !e->signalList.empty() || m_cfg.generateProperties; diff --git a/src/kconfig_compiler/KConfigHeaderGenerator.cpp b/src/kconfig_compiler/KConfigHeaderGenerator.cpp index 43a80a60..7829ab67 100644 --- a/src/kconfig_compiler/KConfigHeaderGenerator.cpp +++ b/src/kconfig_compiler/KConfigHeaderGenerator.cpp @@ -56,13 +56,8 @@ void KConfigHeaderGenerator::doClassDefinition() createConstructor(); createDestructor(); - for (auto *entry : parseResult.entries) { - const QString n = entry->name; - const QString t = entry->type; - - const QString returnType = (cfg().useEnumTypes && t == QLatin1String("Enum")) - ? enumType(entry, cfg().globalEnums) - : cppType(t); + for (const auto *entry : qAsConst(parseResult.entries)) { + const QString returnType = (cfg().useEnumTypes && entry->type == QLatin1String("Enum")) ? enumType(entry, cfg().globalEnums) : cppType(entry->type); createSetters(entry); createProperties(entry, returnType); @@ -90,7 +85,7 @@ void KConfigHeaderGenerator::doClassDefinition() } // Class Parameters - for (const auto ¶meter : parseResult.parameters) { + for (const auto ¶meter : qAsConst(parseResult.parameters)) { stream() << whitespace() << "" << cppType(parameter.type) << " mParam" << parameter.name << ";\n"; } @@ -135,7 +130,7 @@ void KConfigHeaderGenerator::startHeaderGuards() { const bool hasNamespace = !cfg().nameSpace.isEmpty(); const QString namespaceName = QString(QString(cfg().nameSpace).replace(QLatin1String("::"), QLatin1String("_"))).toUpper(); - const QString namespaceStr = hasNamespace ? namespaceName + QLatin1Char('_') : QStringLiteral(""); + const QString namespaceStr = hasNamespace ? namespaceName + QLatin1Char('_') : QString{}; const QString defineName = namespaceStr + cfg().className.toUpper() + QStringLiteral("_H"); stream() << "#ifndef " << defineName << '\n'; @@ -210,7 +205,7 @@ void KConfigHeaderGenerator::implementEnums() return; } - for (const auto entry : parseResult.entries) { + for (const auto *entry : qAsConst(parseResult.entries)) { const CfgEntry::Choices &choices = entry->choices; const QStringList values = entry->paramValues; @@ -259,7 +254,7 @@ void KConfigHeaderGenerator::createSignals() << "\n\n"; stream() << " Q_SIGNALS:"; - for (const Signal &signal : parseResult.signalList) { + for (const Signal &signal : qAsConst(parseResult.signalList)) { stream() << '\n'; if (!signal.label.isEmpty()) { stream() << whitespace() << "/**\n"; @@ -272,7 +267,7 @@ void KConfigHeaderGenerator::createSignals() Param argument = *it; QString type = param(argument.type); if (cfg().useEnumTypes && argument.type == QLatin1String("Enum")) { - for (auto *entry : parseResult.entries) { + for (const auto *entry : qAsConst(parseResult.entries)) { if (entry->name == argument.name) { type = enumType(entry, cfg().globalEnums); break; @@ -301,7 +296,7 @@ void KConfigHeaderGenerator::createDPointer() // use a private class for both member variables and items stream() << " private:\n"; - for (const auto &entry : parseResult.entries) { + for (const auto *entry : qAsConst(parseResult.entries)) { if (cfg().allDefaultGetters || cfg().defaultGetters.contains(entry->name)) { stream() << whitespace() << ""; if (cfg().staticAccessors) { @@ -337,7 +332,7 @@ void KConfigHeaderGenerator::createConstructor() } bool first = true; - for (const auto parameter : parseResult.parameters) { + for (const auto ¶meter : qAsConst(parseResult.parameters)) { if (first) { first = false; } else { @@ -601,7 +596,7 @@ void KConfigHeaderGenerator::createNonDPointerHelpers() } QString group; - for (auto *entry : parseResult.entries) { + for (const auto *entry : qAsConst(parseResult.entries)) { if (entry->group != group) { group = entry->group; stream() << '\n'; @@ -628,7 +623,7 @@ void KConfigHeaderGenerator::createNonDPointerHelpers() stream() << "\n private:\n"; if (cfg().itemAccessors) { - for (auto *entry : parseResult.entries) { + for (const auto *entry : qAsConst(parseResult.entries)) { stream() << whitespace() << "Item" << itemType(entry->type) << " *" << itemVar(entry, cfg()); if (!entry->param.isEmpty()) { stream() << QStringLiteral("[%1]").arg(entry->paramMax + 1); diff --git a/src/kconfig_compiler/KConfigSourceGenerator.cpp b/src/kconfig_compiler/KConfigSourceGenerator.cpp index 97db81ba..663a138f 100644 --- a/src/kconfig_compiler/KConfigSourceGenerator.cpp +++ b/src/kconfig_compiler/KConfigSourceGenerator.cpp @@ -15,12 +15,8 @@ #include -KConfigSourceGenerator::KConfigSourceGenerator( - const QString &inputFile, - const QString &baseDir, - const KConfigParameters &cfg, - ParseResult &result) - : KConfigCodeGeneratorBase(inputFile, baseDir, baseDir + cfg.baseName + QLatin1Char('.') + cfg.sourceExtension, cfg, result) +KConfigSourceGenerator::KConfigSourceGenerator(const QString &inputFile, const QString &baseDir, const KConfigParameters &cfg, ParseResult &parseResult) + : KConfigCodeGeneratorBase(inputFile, baseDir, baseDir + cfg.baseName + QLatin1Char('.') + cfg.sourceExtension, cfg, parseResult) { } @@ -96,7 +92,7 @@ void KConfigSourceGenerator::createPrivateDPointerImplementation() stream() << " public:\n"; // Create Members - for (auto *entry : parseResult.entries) { + for (const auto *entry : qAsConst(parseResult.entries)) { if (entry->group != group) { group = entry->group; stream() << '\n'; @@ -111,7 +107,7 @@ void KConfigSourceGenerator::createPrivateDPointerImplementation() stream() << "\n // items\n"; // Create Items. - for (auto *entry : parseResult.entries) { + for (const auto *entry : qAsConst(parseResult.entries)) { const QString declType = entry->signalList.isEmpty() ? QString(cfg().inherits + QStringLiteral("::Item") + itemType(entry->type)) : QStringLiteral("KConfigCompilerSignallingItem"); @@ -192,7 +188,7 @@ void KConfigSourceGenerator::createSingletonImplementation() void KConfigSourceGenerator::createPreamble() { QString cppPreamble; - for (const auto entry : parseResult.entries) { + for (const auto *entry : qAsConst(parseResult.entries)) { if (entry->paramValues.isEmpty()) { continue; } @@ -257,7 +253,7 @@ void KConfigSourceGenerator::createParentConstructorCall() void KConfigSourceGenerator::createInitializerList() { - for (const auto ¶meter : parseResult.parameters) { + for (const auto ¶meter : qAsConst(parseResult.parameters)) { stream() << " , mParam" << parameter.name << "(" << parameter.name << ")\n"; } @@ -480,7 +476,7 @@ void KConfigSourceGenerator::doConstructor() stream() << '\n'; } - for (auto *entry : parseResult.entries) { + for (const auto *entry : qAsConst(parseResult.entries)) { handleCurrentGroupChange(entry); const QString key = paramString(entry->key, parseResult.parameters); @@ -591,7 +587,7 @@ void KConfigSourceGenerator::doGetterSetterDPointerMode() } // setters and getters go in Cpp if in dpointer mode - for (auto *entry : parseResult.entries) { + for (const auto *entry : qAsConst(parseResult.entries)) { createSetterDPointerMode(entry); createGetterDPointerMode(entry); createImmutableGetterDPointerMode(entry); @@ -603,7 +599,7 @@ void KConfigSourceGenerator::doGetterSetterDPointerMode() void KConfigSourceGenerator::createDefaultValueGetterSetter() { // default value getters always go in Cpp - for (auto *entry : parseResult.entries) { + for (const auto *entry : qAsConst(parseResult.entries)) { QString n = entry->name; QString t = entry->type; @@ -645,7 +641,7 @@ void KConfigSourceGenerator::createNonModifyingSignalsHelper() startScope(); stream() << " const bool res = " << cfg().inherits << "::usrSave();\n"; stream() << " if (!res) return false;\n\n"; - for (const Signal &signal : parseResult.signalList) { + for (const Signal &signal : qAsConst(parseResult.signalList)) { if (signal.modify) { continue; } @@ -696,7 +692,7 @@ void KConfigSourceGenerator::createSignalFlagsHandler() if (!parseResult.signalList.isEmpty()) stream() << '\n'; - for (const Signal &signal : parseResult.signalList) { + for (const Signal &signal : qAsConst(parseResult.signalList)) { if (signal.modify) { stream() << " if ( flags & " << signalEnumName(signal.name) << " ) {\n"; stream() << " Q_EMIT " << signal.name << "();\n"; diff --git a/src/kconfig_compiler/kconfig_compiler.cpp b/src/kconfig_compiler/kconfig_compiler.cpp index 4f9fa3f2..a7ecd83e 100644 --- a/src/kconfig_compiler/kconfig_compiler.cpp +++ b/src/kconfig_compiler/kconfig_compiler.cpp @@ -371,20 +371,26 @@ QString defaultValue(const QString &t) QString itemType(const QString &type) { - QString t; + if (type.isEmpty()) { + return QString{}; + } - t = type; - t.replace(0, 1, t.left(1).toUpper()); + QString str = type; + str[0] = str.at(0).toUpper(); - return t; + return str; } QString itemDeclaration(const CfgEntry *e, const KConfigParameters &cfg) { + if (e->name.isEmpty()) { + return QString{}; + } + const QString type = cfg.inherits + "::Item" + itemType(e->type); QString fCap = e->name; - fCap[0] = fCap[0].toUpper(); + fCap[0] = fCap.at(0).toUpper(); const QString argSuffix = (!e->param.isEmpty()) ? (QStringLiteral("[%1]").arg(e->paramMax + 1)) : QString(); QString result; diff --git a/src/kreadconfig/kwriteconfig.cpp b/src/kreadconfig/kwriteconfig.cpp index c5ad5689..8befa56d 100644 --- a/src/kreadconfig/kwriteconfig.cpp +++ b/src/kreadconfig/kwriteconfig.cpp @@ -38,7 +38,7 @@ int main(int argc, char **argv) QString value; if (del) { - value = QStringLiteral(""); + value = QString{}; } else if (parser.positionalArguments().isEmpty()) { parser.showHelp(1); } else { From 2ac45198cf101f094cf8d94f3a546a57624e59f5 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Mon, 1 Feb 2021 11:06:47 +0200 Subject: [PATCH 104/259] Preincerment/predecrement operator where the post ones aren't needed NO_CHANGELOG --- autotests/kconfigtest.cpp | 2 +- src/core/bufferfragment_p.h | 8 ++++---- src/core/kconfig.cpp | 8 ++++---- src/core/kconfigini.cpp | 19 ++++++++++--------- src/kconf_update/kconf_update.cpp | 2 +- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index 23bcf195..e6d905b0 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -858,7 +858,7 @@ void KConfigTest::testDelete() const QList listLines = readLines(); for (const QByteArray &item : listLines) if (item.startsWith("devices|")) { // krazy:exclude=strings - count++; + ++count; } QCOMPARE(count, 2); cg.deleteEntry("devices|manual|/mnt/ipod"); diff --git a/src/core/bufferfragment_p.h b/src/core/bufferfragment_p.h index ba100ef7..3edbb6b6 100644 --- a/src/core/bufferfragment_p.h +++ b/src/core/bufferfragment_p.h @@ -64,11 +64,11 @@ class KConfigIniBackend::BufferFragment void trim() { while (bf_isspace(*d) && len > 0) { - d++; - len--; + ++d; + --len; } while (len > 0 && bf_isspace(d[len - 1])) { - len--; + --len; } } @@ -160,7 +160,7 @@ class KConfigIniBackend::BufferFragment if (d[from] == c) { return from; } else { - from--; + --from; } return -1; } diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index 04608b0d..ed389ea3 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -177,16 +177,16 @@ QString KConfigPrivate::expandString(const QString &value) QStringRef aVarName; if (aValue[nEndPos] == QLatin1Char('{')) { while ((nEndPos <= aValue.length()) && (aValue[nEndPos] != QLatin1Char('}'))) { - nEndPos++; + ++nEndPos; } - nEndPos++; + ++nEndPos; aVarName = aValue.midRef(nDollarPos + 2, nEndPos - nDollarPos - 3); } else { while (nEndPos < aValue.length() && (aValue[nEndPos].isNumber() || aValue[nEndPos].isLetter() || aValue[nEndPos] == QLatin1Char('_'))) { - nEndPos++; + ++nEndPos; } aVarName = aValue.midRef(nDollarPos + 1, nEndPos - nDollarPos - 1); } @@ -219,7 +219,7 @@ QString KConfigPrivate::expandString(const QString &value) } else { // remove one of the dollar signs aValue.remove(nDollarPos, 1); - nDollarPos++; + ++nDollarPos; } nDollarPos = aValue.indexOf(QLatin1Char('$'), nDollarPos); } diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp index b5f40373..96cd3763 100644 --- a/src/core/kconfigini.cpp +++ b/src/core/kconfigini.cpp @@ -111,7 +111,7 @@ KConfigIniBackend::parseConfig(const QByteArray ¤tLocale, KEntryMap &entry while (startOfLine < len) { BufferFragment line = contents.split('\n', &startOfLine); line.trim(); - lineNo++; + ++lineNo; // skip empty lines and lines beginning with '#' if (line.isEmpty() || line.at(0) == '#') { @@ -122,7 +122,8 @@ KConfigIniBackend::parseConfig(const QByteArray ¤tLocale, KEntryMap &entry groupOptionImmutable = fileOptionImmutable; QByteArray newGroup; - int start = 1, end; + int start = 1; + int end = 0; do { end = start; for (;;) { @@ -134,7 +135,7 @@ KConfigIniBackend::parseConfig(const QByteArray ¤tLocale, KEntryMap &entry if (line.at(end) == ']') { break; } - end++; + ++end; } if (end + 1 == line.length() && start + 2 == end && line.at(start) == '$' && line.at(start + 1) == 'i') { @@ -224,7 +225,7 @@ KConfigIniBackend::parseConfig(const QByteArray ¤tLocale, KEntryMap &entry default: break; } - i++; + ++i; } } else { // found a locale if (!locale.isNull()) { @@ -333,7 +334,7 @@ void KConfigIniBackend::writeEntries(const QByteArray &locale, QIODevice &file, } } file.write("\\x24"); - start++; + ++start; } nope: file.write(stringToPrintable(currentGroup.mid(start), GroupString)); @@ -758,7 +759,7 @@ QByteArray KConfigIniBackend::stringToPrintable(const QByteArray &aString, Strin if (s[0] == ' ' && type != GroupString) { *data++ = '\\'; *data++ = 's'; - i++; + ++i; } Utf8Char utf8; @@ -869,7 +870,7 @@ void KConfigIniBackend::printableToString(BufferFragment *aString, const QFile & *r = str[i]; } else { // Probable escape sequence - i++; + ++i; if (i >= l) { // Line ends after backslash - stop. *r = '\\'; break; @@ -894,13 +895,13 @@ void KConfigIniBackend::printableToString(BufferFragment *aString, const QFile & case ';': // not really an escape sequence, but allowed in .desktop files, don't strip '\;' from the string *r = '\\'; - r++; + ++r; *r = ';'; break; case ',': // not really an escape sequence, but allowed in .desktop files, don't strip '\,' from the string *r = '\\'; - r++; + ++r; *r = ','; break; case 'x': diff --git a/src/kconf_update/kconf_update.cpp b/src/kconf_update/kconf_update.cpp index 08b4e224..a1a1ac72 100644 --- a/src/kconf_update/kconf_update.cpp +++ b/src/kconf_update/kconf_update.cpp @@ -327,7 +327,7 @@ bool KonfUpdate::updateFile(const QString &filename) if (m_line.startsWith(QLatin1String("Version=5"))) { foundVersion = true; } - m_lineCount++; + ++m_lineCount; if (m_line.isEmpty() || (m_line[0] == QLatin1Char('#'))) { continue; } From bce76d2e73a462de673d18dbf6d94da0c592bf08 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Thu, 4 Feb 2021 14:06:34 +0200 Subject: [PATCH 105/259] Less implicit cast from ASCII NO_CHANGELOG --- .../kconfig_compiler/kconfigcompiler_test.cpp | 4 +- autotests/kconfig_compiler/test4main.cpp | 2 +- .../test_emptyentries_main.cpp | 2 +- autotests/kconfigguitest.cpp | 20 ++++--- autotests/kconfigloadertest.cpp | 46 ++++++++-------- autotests/kconfigskeletontest.cpp | 47 ++++++++++------- autotests/kdesktopfiletest.cpp | 48 ++++++++++------- autotests/kstandardshortcuttest.cpp | 4 +- autotests/test_kconf_update.cpp | 25 +++++---- src/kconf_update/kconf_update.cpp | 52 ++++++++++--------- src/kconf_update/kconfigutils.cpp | 49 ++++++++++------- 11 files changed, 167 insertions(+), 132 deletions(-) diff --git a/autotests/kconfig_compiler/kconfigcompiler_test.cpp b/autotests/kconfig_compiler/kconfigcompiler_test.cpp index 6afc0096..014bc0f3 100644 --- a/autotests/kconfig_compiler/kconfigcompiler_test.cpp +++ b/autotests/kconfig_compiler/kconfigcompiler_test.cpp @@ -119,8 +119,8 @@ void KConfigCompiler_Test::testBaselineComparison() qWarning() << "Failed to open" << fileRef.fileName() << "(" << testName << ".ref )"; QFAIL("Can't open file for comparison"); } - QString content = file.readAll(); - QString contentRef = fileRef.readAll(); + const QByteArray content = file.readAll(); + const QByteArray contentRef = fileRef.readAll(); if (content != contentRef) { appendFileDiff(fileRef.fileName(), file.fileName()); diff --git a/autotests/kconfig_compiler/test4main.cpp b/autotests/kconfig_compiler/test4main.cpp index 2d48e440..8792842f 100644 --- a/autotests/kconfig_compiler/test4main.cpp +++ b/autotests/kconfig_compiler/test4main.cpp @@ -19,7 +19,7 @@ int main(int argc, char **argv) group.writeEntry(QStringLiteral("foo bar"), QStringLiteral("Value")); } Test4 *t = Test4::self(); - bool ok = QFile::exists(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/test4rc"); + const bool ok = QFile::exists(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1String{"/test4rc"}); if (!ok) { qWarning() << "config file was not created!"; } diff --git a/autotests/kconfig_compiler/test_emptyentries_main.cpp b/autotests/kconfig_compiler/test_emptyentries_main.cpp index 18c750a5..5dbce8e4 100644 --- a/autotests/kconfig_compiler/test_emptyentries_main.cpp +++ b/autotests/kconfig_compiler/test_emptyentries_main.cpp @@ -11,7 +11,7 @@ int main(int argc, char **argv) { QGuiApplication app(argc, argv); Q_UNUSED(app); - QMakeBuilderSettings::instance("abc"); + QMakeBuilderSettings::instance(QStringLiteral("abc")); auto *t = QMakeBuilderSettings::self(); delete t; return 0; diff --git a/autotests/kconfigguitest.cpp b/autotests/kconfigguitest.cpp index 2a618ce2..87168a7f 100644 --- a/autotests/kconfigguitest.cpp +++ b/autotests/kconfigguitest.cpp @@ -16,10 +16,16 @@ QTEST_MAIN(KConfigTest) -#define COLORENTRY1 QColor("steelblue") -#define COLORENTRY2 QColor(235, 235, 100, 125) -#define COLORENTRY3 QColor(234, 234, 127) -#define FONTENTRY QFont("Times", 16, QFont::Normal) +// clazy:excludeall=non-pod-global-static + +const QColor COLORENTRY1(QLatin1String{"steelblue"}); +const QColor COLORENTRY2(235, 235, 100, 125); +const QColor COLORENTRY3(234, 234, 127); + +static QFont fontEntry() +{ + return QFont{QStringLiteral("Times"), 16, QFont::Normal}; +} void KConfigTest::initTestCase() { @@ -36,7 +42,7 @@ void KConfigTest::initTestCase() cg.writeEntry("colorEntry2", COLORENTRY2); cg.writeEntry("colorEntry3", (QList() << 234 << 234 << 127)); cg.writeEntry("colorEntry4", (QList() << 235 << 235 << 100 << 125)); - cg.writeEntry("fontEntry", FONTENTRY); + cg.writeEntry("fontEntry", fontEntry()); QVERIFY(sc.sync()); KConfig sc1(QStringLiteral("kdebugrc")); @@ -51,7 +57,7 @@ void KConfigTest::initTestCase() // This is fixed by https://codereview.qt-project.org/181645 // It's not in yet, and it depends on the app font, so rather than // a version check, let's do a runtime check. - QFont orig(FONTENTRY); + QFont orig(fontEntry()); QFont f; f.fromString(orig.toString()); m_fontFromStringBug = (f.toString() != orig.toString()); @@ -81,7 +87,7 @@ void KConfigTest::testComplex() if (m_fontFromStringBug) { QEXPECT_FAIL("", "QFont fromString bug from Qt 5.8.0", Continue); } - QCOMPARE(sc3.readEntry("fontEntry", QFont()), FONTENTRY); + QCOMPARE(sc3.readEntry("fontEntry", QFont()), fontEntry()); } void KConfigTest::testInvalid() diff --git a/autotests/kconfigloadertest.cpp b/autotests/kconfigloadertest.cpp index afc58a1b..27a90916 100644 --- a/autotests/kconfigloadertest.cpp +++ b/autotests/kconfigloadertest.cpp @@ -12,7 +12,7 @@ Q_DECLARE_METATYPE(QList) -#define TEST_NAME QString::fromLatin1("kconfigloadertest") +const QString TEST_NAME(QStringLiteral("kconfigloadertest")); #define GET_CONFIG_ITEM_VALUE(type, configName) \ KConfigSkeletonItem* item = cl->findItem(TEST_NAME, configName); \ @@ -38,70 +38,70 @@ void ConfigLoaderTest::cleanup() void ConfigLoaderTest::boolDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemBool *, "DefaultBoolItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemBool *, QStringLiteral("DefaultBoolItem")); QVERIFY(typeItem->isEqual(true)); } void ConfigLoaderTest::colorDefaultValue() { - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemColor *, "DefaultColorItem"); + GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemColor *, QStringLiteral("DefaultColorItem")); QVERIFY(typeItem->isEqual(QColor("#00FF00"))); } void ConfigLoaderTest::dateTimeDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemDateTime *, "DefaultDateTimeItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemDateTime *, QStringLiteral("DefaultDateTimeItem")); - QVERIFY(typeItem->isEqual(QDateTime::fromString("Thu Sep 09 2010"))); + QVERIFY(typeItem->isEqual(QDateTime::fromString(QStringLiteral("Thu Sep 09 2010")))); } void ConfigLoaderTest::enumDefaultValue() { - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemEnum *, "DefaultEnumItem"); + GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemEnum *, QStringLiteral("DefaultEnumItem")); QVERIFY(typeItem->isEqual(3)); } void ConfigLoaderTest::fontDefaultValue() { - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemFont *, "DefaultFontItem"); + GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemFont *, QStringLiteral("DefaultFontItem")); - QVERIFY(typeItem->isEqual(QFont("DejaVu Sans"))); + QVERIFY(typeItem->isEqual(QFont(QStringLiteral("DejaVu Sans")))); } void ConfigLoaderTest::intDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemInt *, "DefaultIntItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemInt *, QStringLiteral("DefaultIntItem")); QVERIFY(typeItem->isEqual(27)); } void ConfigLoaderTest::passwordDefaultValue() { - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemPassword *, "DefaultPasswordItem"); + GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemPassword *, QStringLiteral("DefaultPasswordItem")); QVERIFY(typeItem->isEqual(QString::fromLatin1("h4x."))); } void ConfigLoaderTest::pathDefaultValue() { - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemPath *, "DefaultPathItem"); + GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemPath *, QStringLiteral("DefaultPathItem")); QVERIFY(typeItem->isEqual(QString::fromLatin1("/dev/null"))); } void ConfigLoaderTest::stringDefaultValue() { - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemString *, "DefaultStringItem"); + GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemString *, QStringLiteral("DefaultStringItem")); QVERIFY(typeItem->isEqual(QString::fromLatin1("TestString"))); } void ConfigLoaderTest::stringListDefaultValue() { - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemStringList *, "DefaultStringListItem"); + GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemStringList *, QStringLiteral("DefaultStringListItem")); // Create a string list with the expected values. QStringList expected; @@ -116,28 +116,28 @@ void ConfigLoaderTest::stringListDefaultValue() void ConfigLoaderTest::uintDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemUInt *, "DefaultUIntItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemUInt *, QStringLiteral("DefaultUIntItem")); QVERIFY(typeItem->isEqual(7U)); } void ConfigLoaderTest::urlDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemUrl *, "DefaultUrlItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemUrl *, QStringLiteral("DefaultUrlItem")); - QVERIFY(typeItem->isEqual(QUrl("http://kde.org"))); + QVERIFY(typeItem->isEqual(QUrl(QStringLiteral("http://kde.org")))); } void ConfigLoaderTest::doubleDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemDouble *, "DefaultDoubleItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemDouble *, QStringLiteral("DefaultDoubleItem")); QVERIFY(typeItem->isEqual(13.37)); } void ConfigLoaderTest::intListDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemIntList *, "DefaultIntListItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemIntList *, QStringLiteral("DefaultIntListItem")); // Create a int list with the expected values. QList expected; @@ -153,21 +153,21 @@ void ConfigLoaderTest::intListDefaultValue() void ConfigLoaderTest::longLongDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemLongLong *, "DefaultLongLongItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemLongLong *, QStringLiteral("DefaultLongLongItem")); QVERIFY(typeItem->isEqual(Q_INT64_C(-9211372036854775808))); } void ConfigLoaderTest::pointDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemPoint *, "DefaultPointItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemPoint *, QStringLiteral("DefaultPointItem")); QVERIFY(typeItem->isEqual(QPoint(185, 857))); } void ConfigLoaderTest::rectDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemRect *, "DefaultRectItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemRect *, QStringLiteral("DefaultRectItem")); // Create a new QRect with the expected value. QRect expected; @@ -178,14 +178,14 @@ void ConfigLoaderTest::rectDefaultValue() void ConfigLoaderTest::sizeDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemSize *, "DefaultSizeItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemSize *, QStringLiteral("DefaultSizeItem")); QVERIFY(typeItem->isEqual(QSize(640, 480))); } void ConfigLoaderTest::ulongLongDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemULongLong *, "DefaultULongLongItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemULongLong *, QStringLiteral("DefaultULongLongItem")); QVERIFY(typeItem->isEqual(Q_UINT64_C(9223372036854775806))); } diff --git a/autotests/kconfigskeletontest.cpp b/autotests/kconfigskeletontest.cpp index 896d4ee1..75708bc1 100644 --- a/autotests/kconfigskeletontest.cpp +++ b/autotests/kconfigskeletontest.cpp @@ -14,13 +14,22 @@ QTEST_MAIN(KConfigSkeletonTest) #define DEFAULT_SETTING1 false #define DEFAULT_SETTING2 QColor(1,2,3) -#define DEFAULT_SETTING3 QFont("helvetica",12) -#define DEFAULT_SETTING4 QString("Hello World") +const QString DEFAULT_SETTING4{QStringLiteral("Hello World")}; + #define WRITE_SETTING1 true #define WRITE_SETTING2 QColor(3,2,1) -#define WRITE_SETTING3 QFont("helvetica",14) -#define WRITE_SETTING4 QString("KDE") +const QString WRITE_SETTING4{QStringLiteral("KDE")}; + +static QFont defaultSetting3() +{ + return QFont{QStringLiteral("helvetica"), 12}; +} + +static QFont writeSettings3() +{ + return QFont{QStringLiteral("helvetica"), 14}; +} void KConfigSkeletonTest::initTestCase() { @@ -29,19 +38,19 @@ void KConfigSkeletonTest::initTestCase() void KConfigSkeletonTest::init() { - QFile::remove(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/kconfigskeletontestrc"); + QFile::remove(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1String{"/kconfigskeletontestrc"}); s = new KConfigSkeleton(QStringLiteral("kconfigskeletontestrc")); s->setCurrentGroup(QStringLiteral("MyGroup")); itemBool = s->addItemBool(QStringLiteral("MySetting1"), mMyBool, DEFAULT_SETTING1); s->addItemColor(QStringLiteral("MySetting2"), mMyColor, DEFAULT_SETTING2); s->setCurrentGroup(QStringLiteral("MyOtherGroup")); - s->addItemFont(QStringLiteral("MySetting3"), mMyFont, DEFAULT_SETTING3); + s->addItemFont(QStringLiteral("MySetting3"), mMyFont, defaultSetting3()); s->addItemString(QStringLiteral("MySetting4"), mMyString, DEFAULT_SETTING4); QCOMPARE(mMyBool, DEFAULT_SETTING1); QCOMPARE(mMyColor, DEFAULT_SETTING2); - QCOMPARE(mMyFont, DEFAULT_SETTING3); + QCOMPARE(mMyFont, defaultSetting3()); QCOMPARE(mMyString, DEFAULT_SETTING4); QVERIFY(s->isDefaults()); @@ -57,7 +66,7 @@ void KConfigSkeletonTest::testSimple() { mMyBool = WRITE_SETTING1; mMyColor = WRITE_SETTING2; - mMyFont = WRITE_SETTING3; + mMyFont = writeSettings3(); mMyString = WRITE_SETTING4; QVERIFY(s->isSaveNeeded()); @@ -83,35 +92,35 @@ void KConfigSkeletonTest::testSimple() QCOMPARE(mMyBool, WRITE_SETTING1); QCOMPARE(mMyColor, WRITE_SETTING2); - QCOMPARE(mMyFont, WRITE_SETTING3); + QCOMPARE(mMyFont, writeSettings3()); QCOMPARE(mMyString, WRITE_SETTING4); } void KConfigSkeletonTest::testRemoveItem() { - QVERIFY(s->findItem("MySetting1")); + QVERIFY(s->findItem(QStringLiteral("MySetting1"))); s->removeItem(QStringLiteral("MySetting1")); - QVERIFY(!s->findItem("MySetting1")); + QVERIFY(!s->findItem(QStringLiteral("MySetting1"))); } void KConfigSkeletonTest::testClear() { - QVERIFY(s->findItem("MySetting2")); - QVERIFY(s->findItem("MySetting3")); - QVERIFY(s->findItem("MySetting4")); + QVERIFY(s->findItem(QStringLiteral("MySetting2"))); + QVERIFY(s->findItem(QStringLiteral("MySetting3"))); + QVERIFY(s->findItem(QStringLiteral("MySetting4"))); s->clearItems(); - QVERIFY(!s->findItem("MySetting2")); - QVERIFY(!s->findItem("MySetting3")); - QVERIFY(!s->findItem("MySetting4")); + QVERIFY(!s->findItem(QStringLiteral("MySetting2"))); + QVERIFY(!s->findItem(QStringLiteral("MySetting3"))); + QVERIFY(!s->findItem(QStringLiteral("MySetting4"))); } void KConfigSkeletonTest::testDefaults() { mMyBool = WRITE_SETTING1; mMyColor = WRITE_SETTING2; - mMyFont = WRITE_SETTING3; + mMyFont = writeSettings3(); mMyString = WRITE_SETTING4; QVERIFY(s->isSaveNeeded()); @@ -129,7 +138,7 @@ void KConfigSkeletonTest::testDefaults() QCOMPARE(mMyBool, DEFAULT_SETTING1); QCOMPARE(mMyColor, DEFAULT_SETTING2); - QCOMPARE(mMyFont, DEFAULT_SETTING3); + QCOMPARE(mMyFont, defaultSetting3()); QCOMPARE(mMyString, DEFAULT_SETTING4); s->save(); diff --git a/autotests/kdesktopfiletest.cpp b/autotests/kdesktopfiletest.cpp index 34391489..e45ba44e 100644 --- a/autotests/kdesktopfiletest.cpp +++ b/autotests/kdesktopfiletest.cpp @@ -53,7 +53,7 @@ void KDesktopFileTest::testRead() #if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(5, 0) void KDesktopFileTest::testReadDirectory() { - QTemporaryFile file("testReadDirectoryXXXXXX.directory"); + QTemporaryFile file(QStringLiteral("testReadDirectoryXXXXXX.directory")); QVERIFY(file.open()); const QString fileName = file.fileName(); QTextStream ts(&file); @@ -178,20 +178,20 @@ void KDesktopFileTest::testActionGroup() KDesktopFile df(fileName); QCOMPARE(df.readType(), QString()); QCOMPARE(df.fileName(), QFileInfo(fileName).canonicalFilePath()); - QCOMPARE(df.readActions(), QStringList() << "encrypt" << "semi;colon" << "decrypt"); - QCOMPARE(df.hasActionGroup("encrypt"), true); - QCOMPARE(df.hasActionGroup("semi;colon"), true); - QCOMPARE(df.hasActionGroup("decrypt"), true); - QCOMPARE(df.hasActionGroup("doesnotexist"), false); + QCOMPARE(df.readActions(), (QStringList{QStringLiteral("encrypt"), QStringLiteral("semi;colon"), QStringLiteral("decrypt")})); + QCOMPARE(df.hasActionGroup(QStringLiteral("encrypt")), true); + QCOMPARE(df.hasActionGroup(QStringLiteral("semi;colon")), true); + QCOMPARE(df.hasActionGroup(QStringLiteral("decrypt")), true); + QCOMPARE(df.hasActionGroup(QStringLiteral("doesnotexist")), false); KConfigGroup cg = df.actionGroup(QStringLiteral("encrypt")); QVERIFY(cg.hasKey("Name")); - QCOMPARE(cg.readEntry("Name"), QString("Encrypt file")); + QCOMPARE(cg.readEntry("Name"), QStringLiteral("Encrypt file")); cg = df.actionGroup(QStringLiteral("decrypt")); QVERIFY(cg.hasKey("Name")); - QCOMPARE(cg.readEntry("Name"), QString("Decrypt file")); + QCOMPARE(cg.readEntry("Name"), QStringLiteral("Decrypt file")); cg = df.actionGroup(QStringLiteral("semi;colon")); QVERIFY(cg.hasKey("Name")); - QCOMPARE(cg.readEntry("Name"), QString("With semicolon")); + QCOMPARE(cg.readEntry("Name"), QStringLiteral("With semicolon")); } void KDesktopFileTest::testIsAuthorizedDesktopFile() @@ -275,17 +275,25 @@ void KDesktopFileTest::testLocateLocal_data() QTest::addColumn("path"); QTest::addColumn("result"); - QTest::newRow("configLocation, system-wide") << systemConfigLocation + "/test.desktop" << writableConfigLocation + "/test.desktop"; - QTest::newRow("autostart, system-wide") << systemConfigLocation + "/autostart/test.desktop" << writableConfigLocation + "/autostart/test.desktop"; - QTest::newRow("dataLocation, system-wide") << systemDataLocation + "/test.desktop" << writableDataLocation + "/test.desktop"; - QTest::newRow("applications, system-wide") << systemDataLocation + "/applications/test.desktop" << writableDataLocation + "/applications/test.desktop"; - QTest::newRow("desktop-directories, system-wide") << systemDataLocation + "/desktop-directories/test.directory" << writableDataLocation + "/desktop-directories/test.directory"; - QTest::newRow("configLocation, writable") << writableConfigLocation + "/test.desktop" << writableConfigLocation + "/test.desktop"; - QTest::newRow("autostart, writable") << writableConfigLocation + "/autostart/test.desktop" << writableConfigLocation + "/autostart/test.desktop"; - QTest::newRow("dataLocation, writable") << writableDataLocation + "/test.desktop" << writableDataLocation + "/test.desktop"; - QTest::newRow("applications, writable") << writableDataLocation + "/applications/test.desktop" << writableDataLocation + "/applications/test.desktop"; - QTest::newRow("desktop-directories, writable") << writableDataLocation + "/desktop-directories/test.directory" << writableDataLocation + "/desktop-directories/test.directory"; - QTest::newRow("unknown location") << "/test.desktop" << writableDataLocation + "/test.desktop"; + QTest::newRow("configLocation, system-wide") << systemConfigLocation + QLatin1String{"/test.desktop"} + << writableConfigLocation + QLatin1String{"/test.desktop"}; + QTest::newRow("autostart, system-wide") << systemConfigLocation + QLatin1String{"/autostart/test.desktop"} + << writableConfigLocation + QLatin1String{"/autostart/test.desktop"}; + QTest::newRow("dataLocation, system-wide") << systemDataLocation + QLatin1String{"/test.desktop"} << writableDataLocation + QLatin1String{"/test.desktop"}; + QTest::newRow("applications, system-wide") << systemDataLocation + QLatin1String{"/applications/test.desktop"} + << writableDataLocation + QLatin1String{"/applications/test.desktop"}; + QTest::newRow("desktop-directories, system-wide") << systemDataLocation + QLatin1String{"/desktop-directories/test.directory"} + << writableDataLocation + QLatin1String{"/desktop-directories/test.directory"}; + QTest::newRow("configLocation, writable") << writableConfigLocation + QLatin1String{"/test.desktop"} + << writableConfigLocation + QLatin1String{"/test.desktop"}; + QTest::newRow("autostart, writable") << writableConfigLocation + QLatin1String{"/autostart/test.desktop"} + << writableConfigLocation + QLatin1String{"/autostart/test.desktop"}; + QTest::newRow("dataLocation, writable") << writableDataLocation + QLatin1String{"/test.desktop"} << writableDataLocation + QLatin1String{"/test.desktop"}; + QTest::newRow("applications, writable") << writableDataLocation + QLatin1String{"/applications/test.desktop"} + << writableDataLocation + QLatin1String{"/applications/test.desktop"}; + QTest::newRow("desktop-directories, writable") << writableDataLocation + QLatin1String{"/desktop-directories/test.directory"} + << writableDataLocation + QLatin1String{"/desktop-directories/test.directory"}; + QTest::newRow("unknown location") << QStringLiteral("/test.desktop") << writableDataLocation + QLatin1String{"/test.desktop"}; } void KDesktopFileTest::testLocateLocal() diff --git a/autotests/kstandardshortcuttest.cpp b/autotests/kstandardshortcuttest.cpp index 69e234ab..1b7f88ff 100644 --- a/autotests/kstandardshortcuttest.cpp +++ b/autotests/kstandardshortcuttest.cpp @@ -49,8 +49,8 @@ void KStandardShortcutTest::testShortcut() void KStandardShortcutTest::testFindStdAccel() { - QCOMPARE(KStandardShortcut::find(QString("Ctrl+F")), KStandardShortcut::Find); - QCOMPARE(KStandardShortcut::find(QString("Ctrl+Shift+Alt+G")), KStandardShortcut::AccelNone); + QCOMPARE(KStandardShortcut::find(QKeySequence(Qt::CTRL | Qt::Key_F)), KStandardShortcut::Find); + QCOMPARE(KStandardShortcut::find(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::ALT | Qt::Key_G)), KStandardShortcut::AccelNone); } void KStandardShortcutTest::testFindByName() diff --git a/autotests/test_kconf_update.cpp b/autotests/test_kconf_update.cpp index ba716f28..88ba385f 100644 --- a/autotests/test_kconf_update.cpp +++ b/autotests/test_kconf_update.cpp @@ -65,8 +65,8 @@ static std::unique_ptr writeUpdFile(const QString &content) static void runKConfUpdate(const QString &updPath) { - QVERIFY(QFile::exists(KCONF_UPDATE_EXECUTABLE)); - QCOMPARE(0, QProcess::execute(KCONF_UPDATE_EXECUTABLE, QStringList() << "--testmode" << "--debug" << updPath)); + QVERIFY(QFile::exists(QStringLiteral(KCONF_UPDATE_EXECUTABLE))); + QCOMPARE(0, QProcess::execute(QStringLiteral(KCONF_UPDATE_EXECUTABLE), QStringList{QStringLiteral("--testmode"), QStringLiteral("--debug"), updPath})); } void TestKConfUpdate::test_data() @@ -313,10 +313,11 @@ void TestKConfUpdate::test() QFETCH(bool, shouldUpdateWork); // Prepend Version and the Id= field to the upd content - const QString header = QStringLiteral("Id=%1\n").arg(QTest::currentDataTag()); + const QString header = QLatin1String("Id=%1\n").arg(QLatin1String(QTest::currentDataTag())); updContent = header + updContent; - if (useVersion5) - updContent.prepend("Version=5\n"); + if (useVersion5) { + updContent.prepend(QLatin1String{"Version=5\n"}); + } const QString configDir = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation); QVERIFY(QDir().mkpath(configDir)); @@ -331,7 +332,7 @@ void TestKConfUpdate::test() std::unique_ptr updFile(writeUpdFile(updContent)); runKConfUpdate(updFile->fileName()); - QString updateInfo = QStringLiteral("%1:%2").arg(updFile->fileName().section(QLatin1Char('/'), -1), QTest::currentDataTag()); + QString updateInfo = QLatin1String("%1:%2").arg(updFile->fileName().section(QLatin1Char('/'), -1), QLatin1String{QTest::currentDataTag()}); QString newConfContentAfter = readFile(newConfPath); if (shouldUpdateWork) { @@ -609,26 +610,24 @@ void TestKConfUpdate::testScript() QFETCH(QString, expectedNewConfContent); // Prepend the Version and Id= field to the upd content - updContent = QStringLiteral("Version=5\nId=%1\n").arg(QTest::currentDataTag()) + updContent; + updContent.prepend(QLatin1String("Version=5\nId=%1\n").arg(QLatin1String{QTest::currentDataTag()})); std::unique_ptr updFile(writeUpdFile(updContent)); - const QString scriptDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/kconf_update"; + const QString scriptDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String{"/kconf_update"}; QVERIFY(QDir().mkpath(scriptDir)); - QString scriptPath = scriptDir + "/test.sh"; + const QString scriptPath = scriptDir + QLatin1String{"/test.sh"}; writeFile(scriptPath, updScript); QCOMPARE(readFile(scriptPath), updScript); - QString confPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1Char('/') + "testrc"; + const QString confPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1String{"/testrc"}; writeFile(confPath, oldConfContent); QCOMPARE(readFile(confPath), oldConfContent); runKConfUpdate(updFile->fileName()); - QString updateInfo = QStringLiteral("%1:%2").arg(updFile->fileName().section(QLatin1Char('/'), -1), QTest::currentDataTag()); + const QString updateInfo = QLatin1String("%1:%2").arg(updFile->fileName().section(QLatin1Char{'/'}, -1), QLatin1String{QTest::currentDataTag()}); QString newConfContent = readFile(confPath); expectedNewConfContent = expectedNewConfContent.arg(updateInfo); QCOMPARE(newConfContent, expectedNewConfContent); } - - diff --git a/src/kconf_update/kconf_update.cpp b/src/kconf_update/kconf_update.cpp index a1a1ac72..c2552c23 100644 --- a/src/kconf_update/kconf_update.cpp +++ b/src/kconf_update/kconf_update.cpp @@ -122,7 +122,7 @@ KonfUpdate::KonfUpdate(QCommandLineParser *parser) // its mode. This can however be overridden by the environment, so // we'll want to have a fallback warning if debug is not enabled // after setting the filter. - QLoggingCategory::setFilterRules(QStringLiteral("%1.debug=true").arg(KCONF_UPDATE_LOG().categoryName())); + QLoggingCategory::setFilterRules(QLatin1String("%1.debug=true").arg(QLatin1String{KCONF_UPDATE_LOG().categoryName()})); qDebug() << "Automatically enabled the debug logging category" << KCONF_UPDATE_LOG().categoryName(); if (!KCONF_UPDATE_LOG().isDebugEnabled()) { qWarning("The debug logging category %s needs to be enabled manually to get debug output", @@ -138,7 +138,8 @@ KonfUpdate::KonfUpdate(QCommandLineParser *parser) m_bUseConfigInfo = false; if (parser->isSet(QStringLiteral("check"))) { m_bUseConfigInfo = true; - const QString file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kconf_update/" + parser->value(QStringLiteral("check"))); + const QString file = + QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String{"kconf_update/"} + parser->value(QStringLiteral("check"))); if (file.isEmpty()) { qWarning("File '%s' not found.", parser->value(QStringLiteral("check")).toLocal8Bit().data()); qCDebug(KCONF_UPDATE_LOG) << "File" << parser->value(QStringLiteral("check")) << "passed on command line not found"; @@ -211,7 +212,7 @@ QStringList KonfUpdate::findUpdateFiles(bool dirtyOnly) bool KonfUpdate::checkFile(const QString &filename) { m_currentFilename = filename; - int i = m_currentFilename.lastIndexOf('/'); + const int i = m_currentFilename.lastIndexOf(QLatin1Char{'/'}); if (i != -1) { m_currentFilename = m_currentFilename.mid(i + 1); } @@ -237,7 +238,7 @@ bool KonfUpdate::checkFile(const QString &filename) foundVersion = true; } ++lineCount; - if (line.isEmpty() || (line[0] == '#')) { + if (line.isEmpty() || (line[0] == QLatin1Char{'#'})) { continue; } if (line.startsWith(QLatin1String("Id="))) { @@ -247,7 +248,7 @@ bool KonfUpdate::checkFile(const QString &filename) qUtf8Printable(filename)); return true; } - id = m_currentFilename + ':' + line.mid(3); + id = m_currentFilename + QLatin1Char{':'} + line.mid(3); } else if (line.startsWith(QLatin1String("File="))) { checkGotFile(line.mid(5), id); } @@ -259,7 +260,7 @@ bool KonfUpdate::checkFile(const QString &filename) void KonfUpdate::checkGotFile(const QString &_file, const QString &id) { QString file; - int i = _file.indexOf(','); + const int i = _file.indexOf(QLatin1Char{','}); if (i == -1) { file = _file.trimmed(); } else { @@ -300,7 +301,7 @@ void KonfUpdate::checkGotFile(const QString &_file, const QString &id) bool KonfUpdate::updateFile(const QString &filename) { m_currentFilename = filename; - int i = m_currentFilename.lastIndexOf('/'); + const int i = m_currentFilename.lastIndexOf(QLatin1Char{'/'}); if (i != -1) { m_currentFilename = m_currentFilename.mid(i + 1); } @@ -441,7 +442,7 @@ void KonfUpdate::gotFile(const QString &_file) KConfigGroup cg(m_oldConfig2, "$Version"); QStringList ids = cg.readEntry("update_info", QStringList()); - QString cfg_id = m_currentFilename + ':' + m_id; + QString cfg_id = m_currentFilename + QLatin1Char{':'} + m_id; if (!ids.contains(cfg_id) && !m_skip) { ids.append(cfg_id); cg.writeEntry("update_info", ids); @@ -463,7 +464,7 @@ void KonfUpdate::gotFile(const QString &_file) // Close new file. KConfigGroup cg(m_newConfig, "$Version"); QStringList ids = cg.readEntry("update_info", QStringList()); - QString cfg_id = m_currentFilename + ':' + m_id; + const QString cfg_id = m_currentFilename + QLatin1Char{':'} + m_id; if (!ids.contains(cfg_id) && !m_skip) { ids.append(cfg_id); cg.writeEntry("update_info", ids); @@ -476,7 +477,7 @@ void KonfUpdate::gotFile(const QString &_file) } m_newConfig = nullptr; - int i = _file.indexOf(','); + const int i = _file.indexOf(QLatin1Char{','}); if (i == -1) { m_oldFile = _file.trimmed(); } else { @@ -489,7 +490,7 @@ void KonfUpdate::gotFile(const QString &_file) if (!m_oldFile.isEmpty()) { m_oldConfig2 = new KConfig(m_oldFile, KConfig::NoGlobals); - QString cfg_id = m_currentFilename + ':' + m_id; + const QString cfg_id = m_currentFilename + QLatin1Char{':'} + m_id; KConfigGroup cg(m_oldConfig2, "$Version"); QStringList ids = cg.readEntry("update_info", QStringList()); if (ids.contains(cfg_id)) { @@ -549,7 +550,7 @@ void KonfUpdate::gotGroup(const QString &_group) return; } - QStringList tokens = group.split(','); + const QStringList tokens = group.split(QLatin1Char{','}); m_oldGroup = parseGroupString(tokens.at(0)); if (tokens.count() == 1) { m_newGroup = m_oldGroup; @@ -579,7 +580,7 @@ void KonfUpdate::gotRemoveGroup(const QString &_group) void KonfUpdate::gotKey(const QString &_key) { QString oldKey, newKey; - int i = _key.indexOf(','); + const int i = _key.indexOf(QLatin1Char{','}); if (i == -1) { oldKey = _key.trimmed(); newKey = oldKey; @@ -704,7 +705,7 @@ void KonfUpdate::gotAllGroups() void KonfUpdate::gotOptions(const QString &_options) { - const QStringList options = _options.split(','); + const QStringList options = _options.split(QLatin1Char{','}); for (QStringList::ConstIterator it = options.begin(); it != options.end(); ++it) { @@ -750,8 +751,9 @@ void KonfUpdate::gotScriptArguments(const QString &_arguments) void KonfUpdate::gotScript(const QString &_script) { - QString script, interpreter; - int i = _script.indexOf(','); + QString script; + QString interpreter; + const int i = _script.indexOf(QLatin1Char{','}); if (i == -1) { script = _script.trimmed(); } else { @@ -768,7 +770,7 @@ void KonfUpdate::gotScript(const QString &_script) QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("kconf_update/") + script); if (path.isEmpty()) { if (interpreter.isEmpty()) { - path = CMAKE_INSTALL_PREFIX "/" LIB_INSTALL_DIR "/kconf_update_bin/" + script; + path = QLatin1String{CMAKE_INSTALL_PREFIX "/" LIB_INSTALL_DIR "/kconf_update_bin/"} + script; if (!QFile::exists(path)) { path = QStandardPaths::findExecutable(script); } @@ -899,16 +901,16 @@ void KonfUpdate::gotScript(const QString &_script) ts.setCodec(QTextCodec::codecForName("UTF-8")); #endif while (!ts.atEnd()) { - QString line = ts.readLine(); - if (line.startsWith('[')) { + const QString line = ts.readLine(); + if (line.startsWith(QLatin1Char{'['})) { group = parseGroupString(line); } else if (line.startsWith(QLatin1String("# DELETE "))) { QString key = line.mid(9); - if (key[0] == '[') { - int j = key.lastIndexOf(']') + 1; - if (j > 0) { - group = parseGroupString(key.left(j)); - key = key.mid(j); + if (key.startsWith(QLatin1Char{'['})) { + const int idx = key.lastIndexOf(QLatin1Char{']'}) + 1; + if (idx > 0) { + group = parseGroupString(key.left(idx)); + key = key.mid(idx); } } KConfigGroup cg = KConfigUtils::openGroup(m_oldConfig2, group); @@ -918,7 +920,7 @@ void KonfUpdate::gotScript(const QString &_script) qCDebug(KCONF_UPDATE_LOG) << m_currentFilename << ": Removing empty group " << m_oldFile << ":" << group; } (this should be automatic)*/ } else if (line.startsWith(QLatin1String("# DELETEGROUP"))) { - QString str = line.mid(13).trimmed(); + const QString str = line.mid(13).trimmed(); if (!str.isEmpty()) { group = parseGroupString(str); } diff --git a/src/kconf_update/kconfigutils.cpp b/src/kconf_update/kconfigutils.cpp index a47ef53a..56e5cba7 100644 --- a/src/kconf_update/kconfigutils.cpp +++ b/src/kconf_update/kconfigutils.cpp @@ -38,12 +38,12 @@ QStringList parseGroupString(const QString &_str, bool *ok, QString *error) } *ok = true; - if (str[0] != '[') { + if (!str.startsWith(QLatin1Char{'['})) { // Simplified notation, no '[' - return QStringList() << str; + return QStringList{str}; } - if (!str.endsWith(']')) { + if (!str.endsWith(QLatin1Char{']'})) { *ok = false; *error = QStringLiteral("Missing closing ']' in %1").arg(_str); return QStringList(); @@ -52,16 +52,16 @@ QStringList parseGroupString(const QString &_str, bool *ok, QString *error) str.chop(1); str.remove(0, 1); - return str.split(QStringLiteral("][")); + return str.split(QLatin1String{"]["}); } QString unescapeString(const QString &src, bool *ok, QString *error) { QString dst; - int length = src.length(); + const int length = src.length(); for (int pos = 0; pos < length; ++pos) { QChar ch = src.at(pos); - if (ch != '\\') { + if (ch != QLatin1Char{'\\'}) { dst += ch; } else { ++pos; @@ -70,22 +70,29 @@ QString unescapeString(const QString &src, bool *ok, QString *error) *error = QStringLiteral("Unfinished escape sequence in %1").arg(src); return QString(); } + ch = src.at(pos); - if (ch == 's') { - dst += ' '; - } else if (ch == 't') { - dst += '\t'; - } else if (ch == 'n') { - dst += '\n'; - } else if (ch == 'r') { - dst += '\r'; - } else if (ch == '\\') { - dst += '\\'; - } else if (ch == 'x') { + switch (ch.unicode()) { + case L's': + dst += QLatin1Char{' '}; + break; + case L't': + dst += QLatin1Char{'\t'}; + break; + case L'n': + dst += QLatin1Char{'\n'}; + break; + case L'r': + dst += QLatin1Char{'\r'}; + break; + case L'\\': + dst += QLatin1Char{'\\'}; + break; + case L'x': { if (pos + 2 < length) { char value = src.midRef(pos + 1, 2).toInt(ok, 16); if (*ok) { - dst += QChar::fromLatin1(value); + dst += QLatin1Char{value}; pos += 2; } else { *error = QStringLiteral("Invalid hex escape sequence at column %1 in %2").arg(pos).arg(src); @@ -96,11 +103,15 @@ QString unescapeString(const QString &src, bool *ok, QString *error) *error = QStringLiteral("Unfinished hex escape sequence at column %1 in %2").arg(pos).arg(src); return QString(); } - } else { + + break; + } + default: { *ok = false; *error = QStringLiteral("Invalid escape sequence at column %1 in %2").arg(pos).arg(src); return QString(); } + } } } From 51f0797d763d92445a6532a953b717f83be6028a Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Thu, 4 Feb 2021 14:43:44 +0200 Subject: [PATCH 106/259] kconfigtest: less implicit cast from ASCII NO_CHANGELOG --- autotests/kconfigtest.cpp | 627 +++++++++++++++++++------------------- autotests/kconfigtest.h | 4 + 2 files changed, 312 insertions(+), 319 deletions(-) diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index e6d905b0..5cb31f49 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -4,9 +4,6 @@ SPDX-License-Identifier: LGPL-2.0-or-later */ -// Qt5 TODO: re-enable. No point in doing it before, it breaks on QString::fromUtf8(QByteArray), which exists in qt5. -#undef QT_NO_CAST_FROM_BYTEARRAY - #include "kconfigtest.h" #include "helper.h" @@ -47,50 +44,46 @@ static QString homePath() #endif } -#define BOOLENTRY1 true -#define BOOLENTRY2 false -#define STRINGENTRY1 "hello" -#define STRINGENTRY2 " hello" -#define STRINGENTRY3 "hello " -#define STRINGENTRY4 " hello " -#define STRINGENTRY5 " " -#define STRINGENTRY6 "" -#define UTF8BITENTRY "Hello äöü" -#define TRANSLATEDSTRINGENTRY1 "bonjour" -#define BYTEARRAYENTRY QByteArray( "\x00\xff\x7f\x3c abc\x00\x00", 10 ) -#define ESCAPEKEY " []\0017[]==]" -#define ESCAPEENTRY "[]\170[]]=3=]\\] " -#define DOUBLEENTRY 123456.78912345 -#define FLOATENTRY 123.567f -#define POINTENTRY QPoint( 4351, 1235 ) -#define SIZEENTRY QSize( 10, 20 ) -#define RECTENTRY QRect( 10, 23, 5321, 13 ) -#define DATETIMEENTRY QDateTime( QDate( 2002, 06, 23 ), QTime( 12, 55, 40 ) ) -#define DATETIMEWITHMSENTRY QDateTime( QDate( 2002, 06, 23 ), QTime( 12, 55, 40, 532 ) ) -#define STRINGLISTENTRY (QStringList( "Hello," ) << " World") -#define STRINGLISTEMPTYENTRY QStringList() -#define STRINGLISTJUSTEMPTYELEMENT QStringList(QString()) -#define STRINGLISTEMPTYTRAINLINGELEMENT (QStringList( "Hi" ) << QString()) -#define STRINGLISTESCAPEODDENTRY (QStringList( "Hello\\\\\\" ) << "World") -#define STRINGLISTESCAPEEVENENTRY (QStringList( "Hello\\\\\\\\" ) << "World") -#define STRINGLISTESCAPECOMMAENTRY (QStringList( "Hel\\\\\\,\\\\,\\,\\\\\\\\,lo" ) << "World") -#define INTLISTENTRY1 QList() << 1 << 2 << 3 << 4 -#define BYTEARRAYLISTENTRY1 QList() << "" << "1,2" << "end" -#define VARIANTLISTENTRY (QVariantList() << true << false << QString("joe") << 10023) -#define VARIANTLISTENTRY2 (QVariantList() << POINTENTRY << SIZEENTRY) -#define HOMEPATH QString(homePath()+"/foo") -#define HOMEPATHESCAPE QString(homePath()+"/foo/$HOME") -#define DOLLARGROUP "$i" - -#define TEST_SUBDIR "kconfigtest_subdir/" - -static inline QString testConfigDir() { - return QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/" TEST_SUBDIR; -} - -static inline QString kdeGlobalsPath() { - return QDir::cleanPath(testConfigDir() + "..") + "/kdeglobals"; -} +const bool BOOLENTRY1 = true; +const bool BOOLENTRY2 = false; + +// clazy:excludeall=non-pod-global-static + +const QString STRINGENTRY1(QStringLiteral("hello")); +const QString STRINGENTRY2(QStringLiteral(" hello")); +const QString STRINGENTRY3(QStringLiteral("hello ")); +const QString STRINGENTRY4(QStringLiteral(" hello ")); +const QString STRINGENTRY5(QStringLiteral(" ")); +const QString STRINGENTRY6{}; + +const char UTF8BITENTRY[] = "Hello äöü"; +const QString TRANSLATEDSTRINGENTRY1{QStringLiteral("bonjour")}; +const QByteArray BYTEARRAYENTRY{"\x00\xff\x7f\x3c abc\x00\x00", 10}; +const char ESCAPEKEY[] = " []\0017[]==]"; +const char ESCAPEENTRY[] = "[]\170[]]=3=]\\] "; +const double DOUBLEENTRY{123456.78912345}; +const float FLOATENTRY{123.567f}; +const QPoint POINTENTRY{4351, 1235}; +const QSize SIZEENTRY{10, 20}; +const QRect RECTENTRY{10, 23, 5321, 13}; +const QDateTime DATETIMEENTRY{QDate{2002, 06, 23}, QTime{12, 55, 40}}; +const QDateTime DATETIMEWITHMSENTRY{QDate{2002, 06, 23}, QTime{12, 55, 40, 532}}; +const QStringList STRINGLISTENTRY{QStringLiteral("Hello,"), QStringLiteral("World")}; +const QStringList STRINGLISTEMPTYENTRY{}; +const QStringList STRINGLISTJUSTEMPTYELEMENT{QString{}}; +const QStringList STRINGLISTEMPTYTRAILINGELEMENT{QStringLiteral("Hi"), QString{}}; +const QStringList STRINGLISTESCAPEODDENTRY{QStringLiteral("Hello\\\\\\"), QStringLiteral("World")}; +const QStringList STRINGLISTESCAPEEVENENTRY{QStringLiteral("Hello\\\\\\\\"), QStringLiteral("World")}; +const QStringList STRINGLISTESCAPECOMMAENTRY{QStringLiteral("Hel\\\\\\,\\\\,\\,\\\\\\\\,lo"), QStringLiteral("World")}; +const QList INTLISTENTRY1{1, 2, 3, 4}; +const QList BYTEARRAYLISTENTRY1{"", "1,2", "end"}; +const QVariantList VARIANTLISTENTRY{true, false, QStringLiteral("joe"), 10023}; +const QVariantList VARIANTLISTENTRY2{POINTENTRY, SIZEENTRY}; + +const QString HOMEPATH{homePath() + QLatin1String{"/foo"}}; +const QString HOMEPATH_ESCAPE{homePath() + QLatin1String("/foo/$HOME")}; +const QString DOLLARGROUP{QStringLiteral("$i")}; +const QString TEST_SUBDIR{QStringLiteral("kconfigtest_subdir/")}; #ifndef Q_OS_WIN void initLocale() @@ -106,8 +99,13 @@ void KConfigTest::initTestCase() { // ensure we don't use files in the real config directory QStandardPaths::setTestModeEnabled(true); + qRegisterMetaType(); + // These two need to be assigned here, after setTestModeEnabled(true), and before cleanupTestCase() + m_testConfigDir = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1Char('/') + TEST_SUBDIR; + m_kdeGlobalsPath = QDir::cleanPath(m_testConfigDir + QLatin1String("..")) + QLatin1String("/kdeglobals"); + // to make sure all files from a previous failed run are deleted cleanupTestCase(); @@ -115,7 +113,7 @@ void KConfigTest::initTestCase() mainConfig->group("Main").writeEntry("Key", "Value"); mainConfig->sync(); - KConfig sc(TEST_SUBDIR "kconfigtest"); + KConfig sc(TEST_SUBDIR + QLatin1String("kconfigtest")); KConfigGroup cg(&sc, "AAA"); cg.writeEntry("stringEntry1", STRINGENTRY1, @@ -131,7 +129,7 @@ void KConfigTest::initTestCase() QCOMPARE(QString::fromUtf8(data).length(), 9); cg.writeEntry("Test", data); cg.writeEntry("bytearrayEntry", BYTEARRAYENTRY); - cg.writeEntry(ESCAPEKEY, ESCAPEENTRY); + cg.writeEntry(ESCAPEKEY, QStringLiteral(ESCAPEENTRY)); cg.writeEntry("emptyEntry", ""); cg.writeEntry("stringEntry1", STRINGENTRY1); cg.writeEntry("stringEntry2", STRINGENTRY2); @@ -142,8 +140,7 @@ void KConfigTest::initTestCase() cg.writeEntry("keywith=equalsign", STRINGENTRY1); cg.deleteEntry("stringEntry5"); cg.deleteEntry("stringEntry6"); // deleting a nonexistent entry - cg.writeEntry("byteArrayEntry1", QByteArray(STRINGENTRY1), - KConfig::Global | KConfig::Persistent); + cg.writeEntry("byteArrayEntry1", STRINGENTRY1.toLatin1(), KConfig::Global | KConfig::Persistent); cg.writeEntry("doubleEntry1", DOUBLEENTRY); cg.writeEntry("floatEntry1", FLOATENTRY); @@ -176,7 +173,7 @@ void KConfigTest::initTestCase() cg.writeEntry("stringListEntry", STRINGLISTENTRY); cg.writeEntry("stringListEmptyEntry", STRINGLISTEMPTYENTRY); cg.writeEntry("stringListJustEmptyElement", STRINGLISTJUSTEMPTYELEMENT); - cg.writeEntry("stringListEmptyTrailingElement", STRINGLISTEMPTYTRAINLINGELEMENT); + cg.writeEntry("stringListEmptyTrailingElement", STRINGLISTEMPTYTRAILINGELEMENT); cg.writeEntry("stringListEscapeOddEntry", STRINGLISTESCAPEODDENTRY); cg.writeEntry("stringListEscapeEvenEntry", STRINGLISTESCAPEEVENENTRY); cg.writeEntry("stringListEscapeCommaEntry", STRINGLISTESCAPECOMMAENTRY); @@ -184,7 +181,7 @@ void KConfigTest::initTestCase() cg = KConfigGroup(&sc, "Path Type"); cg.writePathEntry("homepath", HOMEPATH); - cg.writePathEntry("homepathescape", HOMEPATHESCAPE); + cg.writePathEntry("homepathescape", HOMEPATH_ESCAPE); cg = KConfigGroup(&sc, "Enum Types"); #if defined(_MSC_VER) && _MSC_VER == 1600 @@ -210,12 +207,10 @@ void KConfigTest::initTestCase() QVERIFY(sc.sync()); QVERIFY(!sc.isDirty()); - QVERIFY2(QFile::exists(testConfigDir() + QStringLiteral("/kconfigtest")), - qPrintable(testConfigDir() + QStringLiteral("/kconfigtest must exist"))); - QVERIFY2(QFile::exists(kdeGlobalsPath()), - qPrintable(kdeGlobalsPath() + QStringLiteral(" must exist"))); + QVERIFY2(QFile::exists(m_testConfigDir + QLatin1String("/kconfigtest")), qPrintable(m_testConfigDir + QLatin1String("/kconfigtest must exist"))); + QVERIFY2(QFile::exists(m_kdeGlobalsPath), qPrintable(m_kdeGlobalsPath + QStringLiteral(" must exist"))); - KConfig sc1(TEST_SUBDIR "kdebugrc", KConfig::SimpleConfig); + KConfig sc1(TEST_SUBDIR + QLatin1String("kdebugrc"), KConfig::SimpleConfig); KConfigGroup sg0(&sc1, "0"); sg0.writeEntry("AbortFatal", false); sg0.writeEntry("WarnOutput", 0); @@ -223,14 +218,14 @@ void KConfigTest::initTestCase() QVERIFY(sc1.sync()); //Setup stuff to test KConfig::addConfigSources() - KConfig devcfg(TEST_SUBDIR "specificrc"); + KConfig devcfg(TEST_SUBDIR + QLatin1String("specificrc")); KConfigGroup devonlygrp(&devcfg, "Specific Only Group"); devonlygrp.writeEntry("ExistingEntry", "DevValue"); KConfigGroup devandbasegrp(&devcfg, "Shared Group"); devandbasegrp.writeEntry("SomeSharedEntry", "DevValue"); devandbasegrp.writeEntry("SomeSpecificOnlyEntry", "DevValue"); QVERIFY(devcfg.sync()); - KConfig basecfg(TEST_SUBDIR "baserc"); + KConfig basecfg(TEST_SUBDIR + QLatin1String("baserc")); KConfigGroup basegrp(&basecfg, "Base Only Group"); basegrp.writeEntry("ExistingEntry", "BaseValue"); KConfigGroup baseanddevgrp(&basecfg, "Shared Group"); @@ -238,7 +233,7 @@ void KConfigTest::initTestCase() baseanddevgrp.writeEntry("SomeBaseOnlyEntry", "BaseValue"); QVERIFY(basecfg.sync()); - KConfig gecfg(TEST_SUBDIR "groupescapetest", KConfig::SimpleConfig); + KConfig gecfg(TEST_SUBDIR + QLatin1String("groupescapetest"), KConfig::SimpleConfig); cg = KConfigGroup(&gecfg, DOLLARGROUP); cg.writeEntry("entry", "doesntmatter"); @@ -247,16 +242,15 @@ void KConfigTest::initTestCase() void KConfigTest::cleanupTestCase() { //ensure we don't delete the real directory - QDir localConfig(testConfigDir()); + QDir localConfig(m_testConfigDir); //qDebug() << "Erasing" << localConfig; if (localConfig.exists()) { QVERIFY(localConfig.removeRecursively()); } QVERIFY(!localConfig.exists()); - if (QFile::exists(kdeGlobalsPath())) { - QVERIFY(QFile::remove(kdeGlobalsPath())); + if (QFile::exists(m_kdeGlobalsPath)) { + QVERIFY(QFile::remove(m_kdeGlobalsPath)); } - } static QList readLinesFrom(const QString &path) @@ -278,17 +272,18 @@ static QList readLinesFrom(const QString &path) return lines; } -static QList readLines(const char *fileName = TEST_SUBDIR "kconfigtest") +static const QString s_defaultArg = TEST_SUBDIR + QLatin1String("kconfigtest"); +static QList readLines(const QString &fileName = s_defaultArg) { const QString path = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation); Q_ASSERT(!path.isEmpty()); - return readLinesFrom(path + '/' + fileName); + return readLinesFrom(path + QLatin1Char('/') + fileName); } // see also testDefaults, which tests reverting with a defaults (global) file available void KConfigTest::testDirtyAfterRevert() { - KConfig sc(TEST_SUBDIR "kconfigtest_revert"); + KConfig sc(TEST_SUBDIR + QLatin1String("kconfigtest_revert")); KConfigGroup cg(&sc, "Hello"); cg.revertToDefault("does_not_exist"); @@ -312,21 +307,21 @@ void KConfigTest::testRevertAllEntries() // this tests the case were we revert (delete) all entries in a file, // leaving a blank file { - KConfig sc(TEST_SUBDIR "konfigtest2", KConfig::SimpleConfig); + KConfig sc(TEST_SUBDIR + QLatin1String("konfigtest2"), KConfig::SimpleConfig); KConfigGroup cg(&sc, "Hello"); cg.writeEntry("Test", "Correct"); } { - KConfig sc(TEST_SUBDIR "konfigtest2", KConfig::SimpleConfig); + KConfig sc(TEST_SUBDIR + QLatin1String("konfigtest2"), KConfig::SimpleConfig); KConfigGroup cg(&sc, "Hello"); - QCOMPARE(cg.readEntry("Test", "Default"), QString("Correct")); + QCOMPARE(cg.readEntry("Test", "Default"), QStringLiteral("Correct")); cg.revertToDefault("Test"); } - KConfig sc(TEST_SUBDIR "konfigtest2", KConfig::SimpleConfig); + KConfig sc(TEST_SUBDIR + QLatin1String("konfigtest2"), KConfig::SimpleConfig); KConfigGroup cg(&sc, "Hello"); - QCOMPARE(cg.readEntry("Test", "Default"), QString("Default")); + QCOMPARE(cg.readEntry("Test", "Default"), QStringLiteral("Default")); } void KConfigTest::testSimple() @@ -335,13 +330,13 @@ void KConfigTest::testSimple() const QStringList kdeglobals = QStandardPaths::locateAll(QStandardPaths::GenericConfigLocation, QStringLiteral("kdeglobals")); QVERIFY(!kdeglobals.isEmpty()); - KConfig sc2(TEST_SUBDIR "kconfigtest"); - QCOMPARE(sc2.name(), QString(TEST_SUBDIR "kconfigtest")); + KConfig sc2(TEST_SUBDIR + QLatin1String{"kconfigtest"}); + QCOMPARE(sc2.name(), TEST_SUBDIR + QLatin1String{"kconfigtest"}); // make sure groupList() isn't returning something it shouldn't const QStringList lstGroup = sc2.groupList(); for (const QString &group : lstGroup) { - QVERIFY(!group.isEmpty() && group != ""); + QVERIFY(!group.isEmpty() && group != QLatin1String("")); QVERIFY(!group.contains(QChar(0x1d))); } @@ -349,43 +344,43 @@ void KConfigTest::testSimple() QVERIFY(sc3.hasKey("stringEntry1")); // from kdeglobals QVERIFY(!sc3.isEntryImmutable("stringEntry1")); - QCOMPARE(sc3.readEntry("stringEntry1"), QString(STRINGENTRY1)); + QCOMPARE(sc3.readEntry("stringEntry1"), STRINGENTRY1); QVERIFY(!sc3.hasKey("stringEntry2")); - QCOMPARE(sc3.readEntry("stringEntry2", QString("bla")), QString("bla")); + QCOMPARE(sc3.readEntry("stringEntry2", QStringLiteral("bla")), QStringLiteral("bla")); QVERIFY(!sc3.hasDefault("stringEntry1")); sc3 = KConfigGroup(&sc2, "Hello"); QCOMPARE(sc3.readEntry("Test", QByteArray()), QByteArray(UTF8BITENTRY)); QCOMPARE(sc3.readEntry("bytearrayEntry", QByteArray()), BYTEARRAYENTRY); - QCOMPARE(sc3.readEntry(ESCAPEKEY), QString(ESCAPEENTRY)); - QCOMPARE(sc3.readEntry("Test", QString()), QString::fromUtf8(UTF8BITENTRY)); + QCOMPARE(sc3.readEntry(ESCAPEKEY), QString::fromLatin1(ESCAPEENTRY)); + QCOMPARE(sc3.readEntry("Test", QString{}), QString::fromUtf8(UTF8BITENTRY)); QCOMPARE(sc3.readEntry("emptyEntry"/*, QString("Fietsbel")*/), QLatin1String("")); - QCOMPARE(sc3.readEntry("emptyEntry", QString("Fietsbel")).isEmpty(), true); - QCOMPARE(sc3.readEntry("stringEntry1"), QString(STRINGENTRY1)); - QCOMPARE(sc3.readEntry("stringEntry2"), QString(STRINGENTRY2)); - QCOMPARE(sc3.readEntry("stringEntry3"), QString(STRINGENTRY3)); - QCOMPARE(sc3.readEntry("stringEntry4"), QString(STRINGENTRY4)); + QCOMPARE(sc3.readEntry("emptyEntry", QStringLiteral("Fietsbel")).isEmpty(), true); + QCOMPARE(sc3.readEntry("stringEntry1"), STRINGENTRY1); + QCOMPARE(sc3.readEntry("stringEntry2"), STRINGENTRY2); + QCOMPARE(sc3.readEntry("stringEntry3"), STRINGENTRY3); + QCOMPARE(sc3.readEntry("stringEntry4"), STRINGENTRY4); QVERIFY(!sc3.hasKey("stringEntry5")); - QCOMPARE(sc3.readEntry("stringEntry5", QString("test")), QString("test")); + QCOMPARE(sc3.readEntry("stringEntry5", QStringLiteral("test")), QStringLiteral("test")); QVERIFY(!sc3.hasKey("stringEntry6")); - QCOMPARE(sc3.readEntry("stringEntry6", QString("foo")), QString("foo")); - QCOMPARE(sc3.readEntry("urlEntry1", QUrl()), QUrl("http://qt-project.org")); + QCOMPARE(sc3.readEntry("stringEntry6", QStringLiteral("foo")), QStringLiteral("foo")); + QCOMPARE(sc3.readEntry("urlEntry1", QUrl{}), QUrl(QStringLiteral("http://qt-project.org"))); QCOMPARE(sc3.readEntry("boolEntry1", BOOLENTRY1), BOOLENTRY1); QCOMPARE(sc3.readEntry("boolEntry2", false), BOOLENTRY2); - QCOMPARE(sc3.readEntry("keywith=equalsign", QString("wrong")), QString(STRINGENTRY1)); - QCOMPARE(sc3.readEntry("byteArrayEntry1", QByteArray()), - QByteArray(STRINGENTRY1)); + QCOMPARE(sc3.readEntry("keywith=equalsign", QStringLiteral("wrong")), STRINGENTRY1); + QCOMPARE(sc3.readEntry("byteArrayEntry1", QByteArray{}), STRINGENTRY1.toLatin1()); QCOMPARE(sc3.readEntry("doubleEntry1", 0.0), DOUBLEENTRY); QCOMPARE(sc3.readEntry("floatEntry1", 0.0f), FLOATENTRY); } void KConfigTest::testDefaults() { - KConfig config(TEST_SUBDIR "defaulttest", KConfig::NoGlobals); - const QString defaultsFile = TEST_SUBDIR "defaulttest.defaults"; + KConfig config(TEST_SUBDIR + QLatin1String("defaulttest"), KConfig::NoGlobals); + const QString defaultsFile = TEST_SUBDIR + QLatin1String("defaulttest.defaults"); KConfig defaults(defaultsFile, KConfig::SimpleConfig); + const QString defaultsFilePath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1Char('/') + defaultsFile; const QString Default(QStringLiteral("Default")); const QString NotDefault(QStringLiteral("Not Default")); @@ -401,7 +396,7 @@ void KConfigTest::testDefaults() group.writeEntry("entry2", Value2); QVERIFY(group.sync()); - config.addConfigSources(QStringList() << QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + '/' + defaultsFile); + config.addConfigSources(QStringList{defaultsFilePath}); config.setReadDefaults(true); QCOMPARE(group.readEntry("entry1", QString()), Default); @@ -422,8 +417,8 @@ void KConfigTest::testDefaults() group.sync(); // Check that everything is OK on disk, too - KConfig reader(TEST_SUBDIR "defaulttest", KConfig::NoGlobals); - reader.addConfigSources(QStringList() << QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + '/' + defaultsFile); + KConfig reader(TEST_SUBDIR + QLatin1String("defaulttest"), KConfig::NoGlobals); + reader.addConfigSources(QStringList{defaultsFilePath}); KConfigGroup readerGroup = reader.group("any group"); QCOMPARE(readerGroup.readEntry("entry1", QString()), Default); QCOMPARE(readerGroup.readEntry("entry2", QString()), QString()); @@ -431,7 +426,7 @@ void KConfigTest::testDefaults() void KConfigTest::testLocale() { - KConfig config(TEST_SUBDIR "kconfigtest.locales", KConfig::SimpleConfig); + KConfig config(TEST_SUBDIR + QLatin1String("kconfigtest.locales"), KConfig::SimpleConfig); const QString Translated(TRANSLATEDSTRINGENTRY1); const QString Untranslated(STRINGENTRY1); @@ -453,71 +448,69 @@ void KConfigTest::testLocale() void KConfigTest::testEncoding() { - QString groupstr = QString::fromUtf8("UTF-8:\xc3\xb6l"); + const QString groupstr = QString::fromUtf8("UTF-8:\xc3\xb6l"); - KConfig c(TEST_SUBDIR "kconfigtestencodings"); + const QString path = TEST_SUBDIR + QLatin1String("kconfigtestencodings"); + KConfig c(path); KConfigGroup cg(&c, groupstr); cg.writeEntry("key", "value"); QVERIFY(c.sync()); - QList lines = readLines(TEST_SUBDIR "kconfigtestencodings"); + const QList lines = readLines(path); QCOMPARE(lines.count(), 2); QCOMPARE(lines.first(), QByteArray("[UTF-8:\xc3\xb6l]\n")); - KConfig c2(TEST_SUBDIR "kconfigtestencodings"); + KConfig c2(path); KConfigGroup cg2(&c2, groupstr); - QVERIFY(cg2.readEntry("key") == QByteArray("value")); + QCOMPARE(cg2.readEntry("key"), QStringLiteral("value")); QVERIFY(c2.groupList().contains(groupstr)); } void KConfigTest::testLists() { - KConfig sc2(TEST_SUBDIR "kconfigtest"); + KConfig sc2(TEST_SUBDIR + QLatin1String("kconfigtest")); KConfigGroup sc3(&sc2, "List Types"); - QCOMPARE(sc3.readEntry(QString("stringListEntry"), QStringList()), - STRINGLISTENTRY); + QCOMPARE(sc3.readEntry(QStringLiteral("stringListEntry"), QStringList()), STRINGLISTENTRY); - QCOMPARE(sc3.readEntry(QString("stringListEmptyEntry"), QStringList("wrong")), - STRINGLISTEMPTYENTRY); + QCOMPARE(sc3.readEntry(QStringLiteral("stringListEmptyEntry"), QStringList(QStringLiteral("wrong"))), STRINGLISTEMPTYENTRY); - QCOMPARE(sc3.readEntry(QString("stringListJustEmptyElement"), QStringList()), + QCOMPARE(sc3.readEntry(QStringLiteral("stringListJustEmptyElement"), QStringList()), STRINGLISTJUSTEMPTYELEMENT); - QCOMPARE(sc3.readEntry(QString("stringListEmptyTrailingElement"), QStringList()), - STRINGLISTEMPTYTRAINLINGELEMENT); + QCOMPARE(sc3.readEntry(QStringLiteral("stringListEmptyTrailingElement"), QStringList()), + STRINGLISTEMPTYTRAILINGELEMENT); - QCOMPARE(sc3.readEntry(QString("stringListEscapeOddEntry"), QStringList()), + QCOMPARE(sc3.readEntry(QStringLiteral("stringListEscapeOddEntry"), QStringList()), STRINGLISTESCAPEODDENTRY); - QCOMPARE(sc3.readEntry(QString("stringListEscapeEvenEntry"), QStringList()), + QCOMPARE(sc3.readEntry(QStringLiteral("stringListEscapeEvenEntry"), QStringList()), STRINGLISTESCAPEEVENENTRY); - QCOMPARE(sc3.readEntry(QString("stringListEscapeCommaEntry"), QStringList()), + QCOMPARE(sc3.readEntry(QStringLiteral("stringListEscapeCommaEntry"), QStringList()), STRINGLISTESCAPECOMMAENTRY); QCOMPARE(sc3.readEntry("listOfIntsEntry1"), QString::fromLatin1("1,2,3,4")); QList expectedIntList = INTLISTENTRY1; QVERIFY(sc3.readEntry("listOfIntsEntry1", QList()) == expectedIntList); - QCOMPARE(QVariant(sc3.readEntry("variantListEntry", VARIANTLISTENTRY)).toStringList(), - QVariant(VARIANTLISTENTRY).toStringList()); + QCOMPARE(QVariant(sc3.readEntry("variantListEntry", VARIANTLISTENTRY)).toStringList(), QVariant(VARIANTLISTENTRY).toStringList()); QCOMPARE(sc3.readEntry("listOfByteArraysEntry1", QList()), BYTEARRAYLISTENTRY1); } void KConfigTest::testPath() { - KConfig sc2(TEST_SUBDIR "kconfigtest"); + KConfig sc2(TEST_SUBDIR + QLatin1String("kconfigtest")); KConfigGroup sc3(&sc2, "Path Type"); - QCOMPARE(sc3.readPathEntry("homepath", QString()), HOMEPATH); - QCOMPARE(sc3.readPathEntry("homepathescape", QString()), HOMEPATHESCAPE); - QCOMPARE(sc3.entryMap().value("homepath"), HOMEPATH); + QCOMPARE(sc3.readPathEntry(QStringLiteral("homepath"), QString{}), HOMEPATH); + QCOMPARE(sc3.readPathEntry(QStringLiteral("homepathescape"), QString{}), HOMEPATH_ESCAPE); + QCOMPARE(sc3.entryMap().value(QStringLiteral("homepath")), HOMEPATH); qputenv("WITHSLASH", "/a/"); { - QFile file(testConfigDir() + "/pathtest"); + QFile file(m_testConfigDir + QLatin1String("/pathtest")); file.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream out(&file); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) @@ -535,27 +528,27 @@ void KConfigTest::testPath() << "noeol=foo" // no EOL ; } - KConfig cf2(TEST_SUBDIR "pathtest"); + KConfig cf2(TEST_SUBDIR + QLatin1String("pathtest")); KConfigGroup group = cf2.group("Test Group"); QVERIFY(group.hasKey("homePath")); - QCOMPARE(group.readPathEntry("homePath", QString()), HOMEPATH); + QCOMPARE(group.readPathEntry("homePath", QString{}), HOMEPATH); QVERIFY(group.hasKey("homePath2")); - QCOMPARE(group.readPathEntry("homePath2", QString()), QString("file://" + HOMEPATH)); + QCOMPARE(group.readPathEntry("homePath2", QString{}), QLatin1String("file://") + HOMEPATH); QVERIFY(group.hasKey("withSlash")); - QCOMPARE(group.readPathEntry("withSlash", QString()), QStringLiteral("/a//foo")); + QCOMPARE(group.readPathEntry("withSlash", QString{}), QStringLiteral("/a//foo")); QVERIFY(group.hasKey("withSlash2")); - QCOMPARE(group.readPathEntry("withSlash2", QString()), QStringLiteral("/a/")); + QCOMPARE(group.readPathEntry("withSlash2", QString{}), QStringLiteral("/a/")); QVERIFY(group.hasKey("withBraces")); - QCOMPARE(group.readPathEntry("withBraces", QString()), QString("file://" + HOMEPATH)); + QCOMPARE(group.readPathEntry("withBraces", QString{}), QLatin1String("file://") + HOMEPATH); QVERIFY(group.hasKey("URL")); - QCOMPARE(group.readEntry("URL", QString()), QString("file://" + HOMEPATH)); + QCOMPARE(group.readEntry("URL", QString{}), QLatin1String("file://") + HOMEPATH); QVERIFY(group.hasKey("hostname")); - QCOMPARE(group.readEntry("hostname", QString()), QStringLiteral("(hostname)")); // the $ got removed because empty var name + QCOMPARE(group.readEntry("hostname", QString{}), QStringLiteral("(hostname)")); // the $ got removed because empty var name QVERIFY(group.hasKey("noeol")); - QCOMPARE(group.readEntry("noeol", QString()), QString("foo")); + QCOMPARE(group.readEntry("noeol", QString{}), QStringLiteral("foo")); const auto val = QStringList { QStringLiteral("aaa"), QStringLiteral("bb/b"), QStringLiteral("ccc,ccc")}; - QCOMPARE(group.readPathEntry("escapes", QStringList()), val); + QCOMPARE(group.readPathEntry(QStringLiteral("escapes"), QStringList()), val); } void KConfigTest::testPersistenceOfExpandFlagForPath() @@ -567,7 +560,7 @@ void KConfigTest::testPersistenceOfExpandFlagForPath() // 1st step: Open the config, add a new dummy entry and then sync the config // back to the storage. { - KConfig sc2(TEST_SUBDIR "kconfigtest"); + KConfig sc2(TEST_SUBDIR + QLatin1String("kconfigtest")); KConfigGroup sc3(&sc2, "Path Type"); sc3.writeEntry("dummy", "dummy"); QVERIFY(sc2.sync()); @@ -581,7 +574,7 @@ void KConfigTest::testPersistenceOfExpandFlagForPath() void KConfigTest::testPathQtHome() { { - QFile file(testConfigDir() + "/pathtest"); + QFile file(m_testConfigDir + QLatin1String("/pathtest")); file.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream out(&file); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) @@ -592,42 +585,39 @@ void KConfigTest::testPathQtHome() << "cacheDir[$e]=$QT_CACHE_HOME/kconfigtest\n" << "configDir[$e]=$QT_CONFIG_HOME/kconfigtest\n"; } - KConfig cf2(TEST_SUBDIR "pathtest"); + KConfig cf2(TEST_SUBDIR + QLatin1String("pathtest")); KConfigGroup group = cf2.group("Test Group"); qunsetenv("QT_DATA_HOME"); qunsetenv("QT_CACHE_HOME"); qunsetenv("QT_CONFIG_HOME"); QVERIFY(group.hasKey("dataDir")); - QCOMPARE(group.readEntry("dataDir", QString()), QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation).append(QStringLiteral("/kconfigtest"))); + QCOMPARE(group.readEntry("dataDir", QString{}), QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation).append(QStringLiteral("/kconfigtest"))); QVERIFY(group.hasKey("cacheDir")); - QCOMPARE(group.readEntry("cacheDir", QString()), QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation).append(QStringLiteral("/kconfigtest"))); + QCOMPARE(group.readEntry("cacheDir", QString{}), QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation).append(QStringLiteral("/kconfigtest"))); QVERIFY(group.hasKey("configDir")); - QCOMPARE(group.readEntry("configDir", QString()), QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation).append(QStringLiteral("/kconfigtest"))); + QCOMPARE(group.readEntry("configDir", QString{}), QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation).append(QStringLiteral("/kconfigtest"))); qputenv("QT_DATA_HOME","/1"); qputenv("QT_CACHE_HOME","/2"); qputenv("QT_CONFIG_HOME","/3"); QVERIFY(group.hasKey("dataDir")); - QCOMPARE(group.readEntry("dataDir", QString()), QStringLiteral("/1/kconfigtest")); + QCOMPARE(group.readEntry("dataDir", QString{}), QStringLiteral("/1/kconfigtest")); QVERIFY(group.hasKey("cacheDir")); - QCOMPARE(group.readEntry("cacheDir", QString()), QStringLiteral("/2/kconfigtest")); + QCOMPARE(group.readEntry("cacheDir", QString{}), QStringLiteral("/2/kconfigtest")); QVERIFY(group.hasKey("configDir")); - QCOMPARE(group.readEntry("configDir", QString()), QStringLiteral("/3/kconfigtest")); + QCOMPARE(group.readEntry("configDir", QString{}), QStringLiteral("/3/kconfigtest")); } void KConfigTest::testComplex() { - KConfig sc2(TEST_SUBDIR "kconfigtest"); + KConfig sc2(TEST_SUBDIR + QLatin1String("kconfigtest")); KConfigGroup sc3(&sc2, "Complex Types"); QCOMPARE(sc3.readEntry("pointEntry", QPoint()), POINTENTRY); QCOMPARE(sc3.readEntry("sizeEntry", SIZEENTRY), SIZEENTRY); QCOMPARE(sc3.readEntry("rectEntry", QRect(1, 2, 3, 4)), RECTENTRY); - QCOMPARE(sc3.readEntry("dateTimeEntry", QDateTime()).toString(Qt::ISODateWithMs), - DATETIMEENTRY.toString(Qt::ISODateWithMs)); - QCOMPARE(sc3.readEntry("dateEntry", QDate()).toString(Qt::ISODate), - DATETIMEENTRY.date().toString(Qt::ISODate)); - QCOMPARE(sc3.readEntry("dateTimeWithMSEntry", QDateTime()).toString(Qt::ISODateWithMs), - DATETIMEWITHMSENTRY.toString(Qt::ISODateWithMs)); + QCOMPARE(sc3.readEntry("dateTimeEntry", QDateTime()).toString(Qt::ISODateWithMs), DATETIMEENTRY.toString(Qt::ISODateWithMs)); + QCOMPARE(sc3.readEntry("dateEntry", QDate()).toString(Qt::ISODate), DATETIMEENTRY.date().toString(Qt::ISODate)); + QCOMPARE(sc3.readEntry("dateTimeWithMSEntry", QDateTime()).toString(Qt::ISODateWithMs), DATETIMEWITHMSENTRY.toString(Qt::ISODateWithMs)); QCOMPARE(sc3.readEntry("dateTimeEntry", QDate()), DATETIMEENTRY.date()); } @@ -639,14 +629,14 @@ void KConfigTest::testEnums() #if defined(_MSC_VER) && _MSC_VER == 1600 QSKIP("Visual C++ 2010 can't compile this test"); #endif - KConfig sc(TEST_SUBDIR "kconfigtest"); + KConfig sc(TEST_SUBDIR + QLatin1String("kconfigtest")); KConfigGroup sc3(&sc, "Enum Types"); - QCOMPARE(sc3.readEntry("enum-10"), QString("Tens")); + QCOMPARE(sc3.readEntry("enum-10"), QStringLiteral("Tens")); QVERIFY(sc3.readEntry("enum-100", Ones) != Ones); QVERIFY(sc3.readEntry("enum-100", Ones) != Tens); - QCOMPARE(sc3.readEntry("flags-bit0"), QString("bit0")); + QCOMPARE(sc3.readEntry("flags-bit0"), QStringLiteral("bit0")); QVERIFY(sc3.readEntry("flags-bit0", Flags()) == bit0); int eid = staticMetaObject.indexOfEnumerator("Flags"); @@ -654,37 +644,37 @@ void KConfigTest::testEnums() QMetaEnum me = staticMetaObject.enumerator(eid); Flags bitfield = bit0 | bit1; - QCOMPARE(sc3.readEntry("flags-bit0-bit1"), QString(me.valueToKeys(bitfield))); + QCOMPARE(sc3.readEntry("flags-bit0-bit1"), QString::fromLatin1(me.valueToKeys(bitfield))); QVERIFY(sc3.readEntry("flags-bit0-bit1", Flags()) == bitfield); } void KConfigTest::testEntryMap() { - KConfig sc(TEST_SUBDIR "kconfigtest"); + KConfig sc(TEST_SUBDIR + QLatin1String("kconfigtest")); KConfigGroup cg(&sc, "Hello"); QMap entryMap = cg.entryMap(); qDebug() << entryMap.keys(); - QCOMPARE(entryMap.value("stringEntry1"), QString(STRINGENTRY1)); - QCOMPARE(entryMap.value("stringEntry2"), QString(STRINGENTRY2)); - QCOMPARE(entryMap.value("stringEntry3"), QString(STRINGENTRY3)); - QCOMPARE(entryMap.value("stringEntry4"), QString(STRINGENTRY4)); - QVERIFY(!entryMap.contains("stringEntry5")); - QVERIFY(!entryMap.contains("stringEntry6")); - QCOMPARE(entryMap.value("Test"), QString::fromUtf8(UTF8BITENTRY)); - QCOMPARE(entryMap.value("bytearrayEntry"), QString::fromUtf8(BYTEARRAYENTRY.constData())); - QCOMPARE(entryMap.value("emptyEntry"), QString()); - QVERIFY(entryMap.contains("emptyEntry")); - QCOMPARE(entryMap.value("boolEntry1"), QString(BOOLENTRY1 ? "true" : "false")); - QCOMPARE(entryMap.value("boolEntry2"), QString(BOOLENTRY2 ? "true" : "false")); - QCOMPARE(entryMap.value("keywith=equalsign"), QString(STRINGENTRY1)); - QCOMPARE(entryMap.value("byteArrayEntry1"), QString(STRINGENTRY1)); - QCOMPARE(entryMap.value("doubleEntry1").toDouble(), DOUBLEENTRY); - QCOMPARE(entryMap.value("floatEntry1").toFloat(), FLOATENTRY); + QCOMPARE(entryMap.value(QStringLiteral("stringEntry1")), STRINGENTRY1); + QCOMPARE(entryMap.value(QStringLiteral("stringEntry2")), STRINGENTRY2); + QCOMPARE(entryMap.value(QStringLiteral("stringEntry3")), STRINGENTRY3); + QCOMPARE(entryMap.value(QStringLiteral("stringEntry4")), STRINGENTRY4); + QVERIFY(!entryMap.contains(QStringLiteral("stringEntry5"))); + QVERIFY(!entryMap.contains(QStringLiteral("stringEntry6"))); + QCOMPARE(entryMap.value(QStringLiteral("Test")), QString::fromUtf8(UTF8BITENTRY)); + QCOMPARE(entryMap.value(QStringLiteral("bytearrayEntry")), QString::fromUtf8(BYTEARRAYENTRY.constData())); + QCOMPARE(entryMap.value(QStringLiteral("emptyEntry")), QString{}); + QVERIFY(entryMap.contains(QStringLiteral("emptyEntry"))); + QCOMPARE(entryMap.value(QStringLiteral("boolEntry1")), BOOLENTRY1 ? QStringLiteral("true") : QStringLiteral("false")); + QCOMPARE(entryMap.value(QStringLiteral("boolEntry2")), BOOLENTRY2 ? QStringLiteral("true") : QStringLiteral("false")); + QCOMPARE(entryMap.value(QStringLiteral("keywith=equalsign")), STRINGENTRY1); + QCOMPARE(entryMap.value(QStringLiteral("byteArrayEntry1")), STRINGENTRY1); + QCOMPARE(entryMap.value(QStringLiteral("doubleEntry1")).toDouble(), DOUBLEENTRY); + QCOMPARE(entryMap.value(QStringLiteral("floatEntry1")).toFloat(), FLOATENTRY); } void KConfigTest::testInvalid() { - KConfig sc(TEST_SUBDIR "kconfigtest"); + KConfig sc(TEST_SUBDIR + QLatin1String("kconfigtest")); // all of these should print a message to the kdebug.dbg file KConfigGroup sc3(&sc, "Invalid Types"); @@ -751,37 +741,38 @@ void KConfigTest::testInvalid() void KConfigTest::testChangeGroup() { - KConfig sc(TEST_SUBDIR "kconfigtest"); + KConfig sc(TEST_SUBDIR + QLatin1String("kconfigtest")); KConfigGroup sc3(&sc, "Hello"); - QCOMPARE(sc3.name(), QString("Hello")); + QCOMPARE(sc3.name(), QStringLiteral("Hello")); KConfigGroup newGroup(sc3); #if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(5, 0) newGroup.changeGroup("FooBar"); // deprecated! - QCOMPARE(newGroup.name(), QString("FooBar")); - QCOMPARE(sc3.name(), QString("Hello")); // unchanged + QCOMPARE(newGroup.name(), QStringLiteral("FooBar")); + QCOMPARE(sc3.name(), QStringLiteral("Hello")); // unchanged // Write into the "changed group" and check that it works newGroup.writeEntry("InFooBar", "FB"); - QCOMPARE(KConfigGroup(&sc, "FooBar").entryMap().value("InFooBar"), QString("FB")); - QCOMPARE(KConfigGroup(&sc, "Hello").entryMap().value("InFooBar"), QString()); + QCOMPARE(KConfigGroup(&sc, "FooBar").entryMap().value(QStringLiteral("InFooBar")), QStringLiteral("FB")); + QCOMPARE(KConfigGroup(&sc, "Hello").entryMap().value(QStringLiteral("InFooBar")), QString{}); #endif KConfigGroup rootGroup(sc.group("")); - QCOMPARE(rootGroup.name(), QString("")); + QCOMPARE(rootGroup.name(), QStringLiteral("")); KConfigGroup sc32(rootGroup.group("Hello")); - QCOMPARE(sc32.name(), QString("Hello")); + QCOMPARE(sc32.name(), QStringLiteral("Hello")); KConfigGroup newGroup2(sc32); #if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(5, 0) newGroup2.changeGroup("FooBar"); // deprecated! - QCOMPARE(newGroup2.name(), QString("FooBar")); - QCOMPARE(sc32.name(), QString("Hello")); // unchanged + QCOMPARE(newGroup2.name(), QStringLiteral("FooBar")); + QCOMPARE(sc32.name(), QStringLiteral("Hello")); // unchanged #endif } // Simple test for deleteEntry void KConfigTest::testDeleteEntry() { - const char *configFile = TEST_SUBDIR "kconfigdeletetest"; + const QString configFile = TEST_SUBDIR + QLatin1String("kconfigdeletetest"); + { KConfig conf(configFile); conf.group("Hello").writeEntry("DelKey", "ToBeDeleted"); @@ -794,16 +785,16 @@ void KConfigTest::testDeleteEntry() KConfigGroup group(&sc, "Hello"); group.deleteEntry("DelKey"); - QCOMPARE(group.readEntry("DelKey", QString("Fietsbel")), QString("Fietsbel")); + QCOMPARE(group.readEntry("DelKey", QStringLiteral("Fietsbel")), QStringLiteral("Fietsbel")); QVERIFY(group.sync()); Q_ASSERT(!readLines(configFile).contains("DelKey=ToBeDeleted\n")); - QCOMPARE(group.readEntry("DelKey", QString("still deleted")), QString("still deleted")); + QCOMPARE(group.readEntry("DelKey", QStringLiteral("still deleted")), QStringLiteral("still deleted")); } void KConfigTest::testDelete() { - KConfig sc(TEST_SUBDIR "kconfigtest"); + KConfig sc(TEST_SUBDIR + QLatin1String("kconfigtest")); KConfigGroup ct(&sc, "Complex Types"); @@ -814,7 +805,7 @@ void KConfigTest::testDelete() delgr.deleteGroup(); QVERIFY(!delgr.exists()); QVERIFY(!ct.hasGroup("Nested Group 3")); - QVERIFY(ct.groupList().contains("Nested Group 3")); + QVERIFY(ct.groupList().contains(QStringLiteral("Nested Group 3"))); KConfigGroup ng(&ct, "Nested Group 2"); QVERIFY(sc.hasGroup("Complex Types")); @@ -831,10 +822,10 @@ void KConfigTest::testDelete() KConfigGroup cg(&sc, "AAA"); cg.deleteGroup(); - QVERIFY(sc.entryMap("Complex Types").isEmpty()); - QVERIFY(sc.entryMap("AAA").isEmpty()); - QVERIFY(!sc.entryMap("Hello").isEmpty()); //not deleted group - QVERIFY(sc.entryMap("FooBar").isEmpty()); //inexistant group + QVERIFY(sc.entryMap(QStringLiteral("Complex Types")).isEmpty()); + QVERIFY(sc.entryMap(QStringLiteral("AAA")).isEmpty()); + QVERIFY(!sc.entryMap(QStringLiteral("Hello")).isEmpty()); //not deleted group + QVERIFY(sc.entryMap(QStringLiteral("FooBar")).isEmpty()); //inexistant group QVERIFY(cg.sync()); // Check what happens on disk @@ -848,7 +839,7 @@ void KConfigTest::testDelete() QVERIFY(lines.contains("[Hello]\n")); // a group that was not deleted // test for entries that are marked as deleted when there is no default - KConfig cf(TEST_SUBDIR "kconfigtest", KConfig::SimpleConfig); // make sure there are no defaults + KConfig cf(TEST_SUBDIR + QLatin1String("kconfigtest"), KConfig::SimpleConfig); // make sure there are no defaults cg = cf.group("Portable Devices"); cg.writeEntry("devices|manual|(null)", "whatever"); cg.writeEntry("devices|manual|/mnt/ipod", "/mnt/ipod"); @@ -871,40 +862,41 @@ void KConfigTest::testDelete() void KConfigTest::testDefaultGroup() { - KConfig sc(TEST_SUBDIR "kconfigtest"); + KConfig sc(TEST_SUBDIR + QLatin1String("kconfigtest")); KConfigGroup defaultGroup(&sc, ""); - QCOMPARE(defaultGroup.name(), QString("")); + QCOMPARE(defaultGroup.name(), QStringLiteral("")); QVERIFY(!defaultGroup.exists()); defaultGroup.writeEntry("TestKey", "defaultGroup"); QVERIFY(defaultGroup.exists()); - QCOMPARE(defaultGroup.readEntry("TestKey", QString()), QString("defaultGroup")); + QCOMPARE(defaultGroup.readEntry("TestKey", QString{}), QStringLiteral("defaultGroup")); QVERIFY(sc.sync()); { // Test reading it - KConfig sc2(TEST_SUBDIR "kconfigtest"); + KConfig sc2(TEST_SUBDIR + QLatin1String("kconfigtest")); KConfigGroup defaultGroup2(&sc2, ""); - QCOMPARE(defaultGroup2.name(), QString("")); + QCOMPARE(defaultGroup2.name(), QStringLiteral("")); QVERIFY(defaultGroup2.exists()); - QCOMPARE(defaultGroup2.readEntry("TestKey", QString()), QString("defaultGroup")); + QCOMPARE(defaultGroup2.readEntry("TestKey", QString{}), QStringLiteral("defaultGroup")); } { // Test reading it - KConfig sc2(TEST_SUBDIR "kconfigtest"); + KConfig sc2(TEST_SUBDIR + QLatin1String("kconfigtest")); KConfigGroup emptyGroup(&sc2, ""); - QCOMPARE(emptyGroup.name(), QString("")); + QCOMPARE(emptyGroup.name(), QStringLiteral("")); QVERIFY(emptyGroup.exists()); - QCOMPARE(emptyGroup.readEntry("TestKey", QString()), QString("defaultGroup")); + QCOMPARE(emptyGroup.readEntry("TestKey", QString{}), QStringLiteral("defaultGroup")); } QList lines = readLines(); QVERIFY(!lines.contains("[]\n")); + QVERIFY(!lines.isEmpty()); QCOMPARE(lines.first(), QByteArray("TestKey=defaultGroup\n")); // Now that the group exists make sure it isn't returned from groupList() const QStringList groupList = sc.groupList(); for (const QString &group : groupList) { - QVERIFY(!group.isEmpty() && group != ""); + QVERIFY(!group.isEmpty() && group != QLatin1String("")); } defaultGroup.deleteGroup(); @@ -917,30 +909,30 @@ void KConfigTest::testDefaultGroup() void KConfigTest::testEmptyGroup() { - KConfig sc(TEST_SUBDIR "kconfigtest"); + KConfig sc(TEST_SUBDIR + QLatin1String("kconfigtest")); KConfigGroup emptyGroup(&sc, ""); - QCOMPARE(emptyGroup.name(), QString("")); // confusing, heh? + QCOMPARE(emptyGroup.name(), QStringLiteral("")); // confusing, heh? QVERIFY(!emptyGroup.exists()); emptyGroup.writeEntry("TestKey", "emptyGroup"); QVERIFY(emptyGroup.exists()); - QCOMPARE(emptyGroup.readEntry("TestKey", QString()), QString("emptyGroup")); + QCOMPARE(emptyGroup.readEntry("TestKey", QString{}), QStringLiteral("emptyGroup")); QVERIFY(sc.sync()); { // Test reading it - KConfig sc2(TEST_SUBDIR "kconfigtest"); + KConfig sc2(TEST_SUBDIR + QLatin1String("kconfigtest")); KConfigGroup defaultGroup(&sc2, ""); - QCOMPARE(defaultGroup.name(), QString("")); + QCOMPARE(defaultGroup.name(), QStringLiteral("")); QVERIFY(defaultGroup.exists()); - QCOMPARE(defaultGroup.readEntry("TestKey", QString()), QString("emptyGroup")); + QCOMPARE(defaultGroup.readEntry("TestKey", QString{}), QStringLiteral("emptyGroup")); } { // Test reading it - KConfig sc2(TEST_SUBDIR "kconfigtest"); + KConfig sc2(TEST_SUBDIR + QLatin1String("kconfigtest")); KConfigGroup emptyGroup2(&sc2, ""); - QCOMPARE(emptyGroup2.name(), QString("")); + QCOMPARE(emptyGroup2.name(), QStringLiteral("")); QVERIFY(emptyGroup2.exists()); - QCOMPARE(emptyGroup2.readEntry("TestKey", QString()), QString("emptyGroup")); + QCOMPARE(emptyGroup2.readEntry("TestKey", QString{}), QStringLiteral("emptyGroup")); } QList lines = readLines(); @@ -950,7 +942,7 @@ void KConfigTest::testEmptyGroup() // Now that the group exists make sure it isn't returned from groupList() const QStringList groupList = sc.groupList(); for (const QString &group : groupList) { - QVERIFY(!group.isEmpty() && group != ""); + QVERIFY(!group.isEmpty() && group != QLatin1String("")); } emptyGroup.deleteGroup(); QVERIFY(sc.sync()); @@ -971,11 +963,11 @@ void KConfigTest::testCascadingWithLocale() #ifdef Q_XDG_PLATFORM QTemporaryDir middleDir; QTemporaryDir globalDir; - qputenv("XDG_CONFIG_DIRS", qPrintable(middleDir.path() + QString(":") + globalDir.path())); + qputenv("XDG_CONFIG_DIRS", qPrintable(middleDir.path() + QLatin1Char(':') + globalDir.path())); - const QString globalConfigDir = globalDir.path() + "/" TEST_SUBDIR; + const QString globalConfigDir = globalDir.path() + QLatin1Char('/') + TEST_SUBDIR; QVERIFY(QDir().mkpath(globalConfigDir)); - QFile global(globalConfigDir + "foo.desktop"); + QFile global(globalConfigDir + QLatin1String("foo.desktop")); QVERIFY(global.open(QIODevice::WriteOnly | QIODevice::Text)); QTextStream globalOut(&global); globalOut << "[Group]\n" @@ -987,9 +979,9 @@ void KConfigTest::testCascadingWithLocale() << "Other[fr]=Global_FR\n"; global.close(); - const QString middleConfigDir = middleDir.path() + "/" TEST_SUBDIR; + const QString middleConfigDir = middleDir.path() + QLatin1Char('/') + TEST_SUBDIR; QVERIFY(QDir().mkpath(middleConfigDir)); - QFile local(middleConfigDir + "foo.desktop"); + QFile local(middleConfigDir + QLatin1String("foo.desktop")); QVERIFY(local.open(QIODevice::WriteOnly | QIODevice::Text)); QTextStream out(&local); out << "[Group]\n" @@ -1000,16 +992,16 @@ void KConfigTest::testCascadingWithLocale() << "Other=English Only\n"; local.close(); - KConfig config(TEST_SUBDIR "foo.desktop"); + KConfig config(TEST_SUBDIR + QLatin1String("foo.desktop")); KConfigGroup group = config.group("Group"); - QCOMPARE(group.readEntry("FromGlobal"), QString("true")); - QCOMPARE(group.readEntry("FromLocal"), QString("true")); - QCOMPARE(group.readEntry("Name"), QString("Local Testing")); + QCOMPARE(group.readEntry("FromGlobal"), QStringLiteral("true")); + QCOMPARE(group.readEntry("FromLocal"), QStringLiteral("true")); + QCOMPARE(group.readEntry("Name"), QStringLiteral("Local Testing")); config.setLocale(QStringLiteral("fr")); - QCOMPARE(group.readEntry("FromGlobal"), QString("vrai")); - QCOMPARE(group.readEntry("FromLocal"), QString("vrai")); - QCOMPARE(group.readEntry("Name"), QString("FR")); - QCOMPARE(group.readEntry("Other"), QString("English Only")); // Global_FR is locally overriden + QCOMPARE(group.readEntry("FromGlobal"), QStringLiteral("vrai")); + QCOMPARE(group.readEntry("FromLocal"), QStringLiteral("vrai")); + QCOMPARE(group.readEntry("Name"), QStringLiteral("FR")); + QCOMPARE(group.readEntry("Other"), QStringLiteral("English Only")); // Global_FR is locally overriden #endif } @@ -1017,7 +1009,7 @@ void KConfigTest::testMerge() { DefaultLocale defaultLocale; QLocale::setDefault(QLocale::c()); - KConfig config(TEST_SUBDIR "mergetest", KConfig::SimpleConfig); + KConfig config(TEST_SUBDIR + QLatin1String("mergetest"), KConfig::SimpleConfig); KConfigGroup cg = config.group("some group"); cg.writeEntry("entry", " random entry"); @@ -1025,7 +1017,7 @@ void KConfigTest::testMerge() { // simulate writing by another process - QFile file(testConfigDir() + "/mergetest"); + QFile file(m_testConfigDir + QLatin1String("/mergetest")); file.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream out(&file); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) @@ -1054,7 +1046,7 @@ void KConfigTest::testMerge() << "entry[de]=German\n" << "entry[es]=Spanish\n" << "entry[fr]=French\n"; - QFile file(testConfigDir() + "/mergetest"); + QFile file(m_testConfigDir + QLatin1String("/mergetest")); file.open(QIODevice::ReadOnly | QIODevice::Text); for (const QByteArray &line : qAsConst(lines)) { QCOMPARE(line, file.readLine()); @@ -1065,7 +1057,7 @@ void KConfigTest::testMerge() void KConfigTest::testImmutable() { { - QFile file(testConfigDir() + "/immutabletest"); + QFile file(m_testConfigDir + QLatin1String("/immutabletest")); file.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream out(&file); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) @@ -1077,7 +1069,7 @@ void KConfigTest::testImmutable() << "[group][subgroup][$i]\n"; } - KConfig config(TEST_SUBDIR "immutabletest", KConfig::SimpleConfig); + KConfig config(TEST_SUBDIR + QLatin1String("immutabletest"), KConfig::SimpleConfig); QVERIFY(config.isGroupImmutable(QByteArray())); KConfigGroup cg = config.group(QByteArray()); QVERIFY(cg.isEntryImmutable("entry1")); @@ -1092,7 +1084,7 @@ void KConfigTest::testImmutable() void KConfigTest::testOptionOrder() { { - QFile file(testConfigDir() + "/doubleattrtest"); + QFile file(m_testConfigDir + QLatin1String("/doubleattrtest")); file.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream out(&file); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) @@ -1102,14 +1094,14 @@ void KConfigTest::testOptionOrder() << "entry2=unlocalized\n" << "entry2[$i][de_DE]=t2\n"; } - KConfig config(TEST_SUBDIR "doubleattrtest", KConfig::SimpleConfig); + KConfig config(TEST_SUBDIR + QLatin1String("doubleattrtest"), KConfig::SimpleConfig); config.setLocale(QStringLiteral("de_DE")); KConfigGroup cg3 = config.group("group3"); QVERIFY(!cg3.isImmutable()); - QCOMPARE(cg3.readEntry("entry2", ""), QString("t2")); + QCOMPARE(cg3.readEntry("entry2", ""), QStringLiteral("t2")); QVERIFY(cg3.isEntryImmutable("entry2")); config.setLocale(QStringLiteral("C")); - QCOMPARE(cg3.readEntry("entry2", ""), QString("unlocalized")); + QCOMPARE(cg3.readEntry("entry2", ""), QStringLiteral("unlocalized")); QVERIFY(!cg3.isEntryImmutable("entry2")); cg3.writeEntry("entry2", "modified"); QVERIFY(config.sync()); @@ -1121,7 +1113,7 @@ void KConfigTest::testOptionOrder() << "entry2=modified\n" << "entry2[de_DE][$i]=t2\n"; - QFile file(testConfigDir() + "/doubleattrtest"); + QFile file(m_testConfigDir + QLatin1String("/doubleattrtest")); file.open(QIODevice::ReadOnly | QIODevice::Text); for (const QByteArray &line : qAsConst(lines)) { QCOMPARE(line, file.readLine()); @@ -1131,35 +1123,35 @@ void KConfigTest::testOptionOrder() void KConfigTest::testGroupEscape() { - KConfig config(TEST_SUBDIR "groupescapetest", KConfig::SimpleConfig); + KConfig config(TEST_SUBDIR + QLatin1String("groupescapetest"), KConfig::SimpleConfig); QVERIFY(config.group(DOLLARGROUP).exists()); } void KConfigTest::testSubGroup() { - KConfig sc(TEST_SUBDIR "kconfigtest"); + KConfig sc(TEST_SUBDIR + QLatin1String("kconfigtest")); KConfigGroup cg(&sc, "ParentGroup"); - QCOMPARE(cg.readEntry("parentgrpstring", ""), QString("somevalue")); + QCOMPARE(cg.readEntry("parentgrpstring", ""), QStringLiteral("somevalue")); KConfigGroup subcg1(&cg, "SubGroup1"); - QCOMPARE(subcg1.name(), QString("SubGroup1")); - QCOMPARE(subcg1.readEntry("somestring", ""), QString("somevalue")); + QCOMPARE(subcg1.name(), QStringLiteral("SubGroup1")); + QCOMPARE(subcg1.readEntry("somestring", ""), QStringLiteral("somevalue")); KConfigGroup subcg2(&cg, "SubGroup2"); - QCOMPARE(subcg2.name(), QString("SubGroup2")); - QCOMPARE(subcg2.readEntry("substring", ""), QString("somevalue")); + QCOMPARE(subcg2.name(), QStringLiteral("SubGroup2")); + QCOMPARE(subcg2.readEntry("substring", ""), QStringLiteral("somevalue")); KConfigGroup subcg3(&cg, "SubGroup/3"); - QCOMPARE(subcg3.readEntry("sub3string", ""), QString("somevalue")); - QCOMPARE(subcg3.name(), QString("SubGroup/3")); + QCOMPARE(subcg3.readEntry("sub3string", ""), QStringLiteral("somevalue")); + QCOMPARE(subcg3.name(), QStringLiteral("SubGroup/3")); KConfigGroup rcg(&sc, ""); KConfigGroup srcg(&rcg, "ParentGroup"); - QCOMPARE(srcg.readEntry("parentgrpstring", ""), QString("somevalue")); + QCOMPARE(srcg.readEntry("parentgrpstring", ""), QStringLiteral("somevalue")); QStringList groupList = cg.groupList(); groupList.sort(); // comes from QSet, so order is undefined - QCOMPARE(groupList, (QStringList() << "SubGroup/3" << "SubGroup1" << "SubGroup2")); + QCOMPARE(groupList, (QStringList{QStringLiteral("SubGroup/3"), QStringLiteral("SubGroup1"), QStringLiteral("SubGroup2")})); - const QStringList expectedSubgroup3Keys = (QStringList() << QStringLiteral("sub3string")); + const QStringList expectedSubgroup3Keys{QStringLiteral("sub3string")}; QCOMPARE(subcg3.keyList(), expectedSubgroup3Keys); - const QStringList expectedParentGroupKeys(QStringList() << QStringLiteral("parentgrpstring")); + const QStringList expectedParentGroupKeys{QStringLiteral("parentgrpstring")}; QCOMPARE(cg.keyList(), expectedParentGroupKeys); @@ -1199,15 +1191,15 @@ void KConfigTest::testSubGroup() // This is what happens QStringList groups = neg.groupList(); groups.sort(); // Qt5 made the ordering unreliable, due to QHash - QCOMPARE(groups, QStringList() << "NEG Child1" << "NEG Child4"); + QCOMPARE(groups, (QStringList{QStringLiteral("NEG Child1"), QStringLiteral("NEG Child4")})); // make sure groupList() isn't returning something it shouldn't const QStringList listGroup = sc.groupList(); for (const QString &group : listGroup) { - QVERIFY(!group.isEmpty() && group != ""); + QVERIFY(!group.isEmpty() && group != QLatin1String("")); QVERIFY(!group.contains(QChar(0x1d))); - QVERIFY(!group.contains("subgroup")); - QVERIFY(!group.contains("SubGroup")); + QVERIFY(!group.contains(QLatin1String("subgroup"))); + QVERIFY(!group.contains(QLatin1String("SubGroup"))); } QVERIFY(sc.sync()); @@ -1223,21 +1215,21 @@ void KConfigTest::testSubGroup() void KConfigTest::testAddConfigSources() { - KConfig cf(TEST_SUBDIR "specificrc"); + KConfig cf(TEST_SUBDIR + QLatin1String("specificrc")); - cf.addConfigSources(QStringList() << testConfigDir() + "/baserc"); + cf.addConfigSources(QStringList{m_testConfigDir + QLatin1String("/baserc")}); cf.reparseConfiguration(); KConfigGroup specificgrp(&cf, "Specific Only Group"); - QCOMPARE(specificgrp.readEntry("ExistingEntry", ""), QString("DevValue")); + QCOMPARE(specificgrp.readEntry("ExistingEntry", ""), QStringLiteral("DevValue")); KConfigGroup sharedgrp(&cf, "Shared Group"); - QCOMPARE(sharedgrp.readEntry("SomeSpecificOnlyEntry", ""), QString("DevValue")); - QCOMPARE(sharedgrp.readEntry("SomeBaseOnlyEntry", ""), QString("BaseValue")); - QCOMPARE(sharedgrp.readEntry("SomeSharedEntry", ""), QString("DevValue")); + QCOMPARE(sharedgrp.readEntry("SomeSpecificOnlyEntry", ""), QStringLiteral("DevValue")); + QCOMPARE(sharedgrp.readEntry("SomeBaseOnlyEntry", ""), QStringLiteral("BaseValue")); + QCOMPARE(sharedgrp.readEntry("SomeSharedEntry", ""), QStringLiteral("DevValue")); KConfigGroup basegrp(&cf, "Base Only Group"); - QCOMPARE(basegrp.readEntry("ExistingEntry", ""), QString("BaseValue")); + QCOMPARE(basegrp.readEntry("ExistingEntry", ""), QStringLiteral("BaseValue")); basegrp.writeEntry("New Entry Base Only", "SomeValue"); KConfigGroup newgrp(&cf, "New Group"); @@ -1245,25 +1237,25 @@ void KConfigTest::testAddConfigSources() QVERIFY(cf.sync()); - KConfig plaincfg(TEST_SUBDIR "specificrc"); + KConfig plaincfg(TEST_SUBDIR + QLatin1String("specificrc")); KConfigGroup newgrp2(&plaincfg, "New Group"); - QCOMPARE(newgrp2.readEntry("New Entry", ""), QString("SomeValue")); + QCOMPARE(newgrp2.readEntry("New Entry", ""), QStringLiteral("SomeValue")); KConfigGroup basegrp2(&plaincfg, "Base Only Group"); - QCOMPARE(basegrp2.readEntry("New Entry Base Only", ""), QString("SomeValue")); + QCOMPARE(basegrp2.readEntry("New Entry Base Only", ""), QStringLiteral("SomeValue")); } void KConfigTest::testGroupCopyTo() { - KConfig cf1(TEST_SUBDIR "kconfigtest"); + KConfig cf1(TEST_SUBDIR + QLatin1String("kconfigtest")); KConfigGroup original = cf1.group("Enum Types"); KConfigGroup copy = cf1.group("Enum Types Copy"); original.copyTo(©); // copy from one group to another QCOMPARE(copy.entryMap(), original.entryMap()); - KConfig cf2(TEST_SUBDIR "copy_of_kconfigtest", KConfig::SimpleConfig); + KConfig cf2(TEST_SUBDIR + QLatin1String("copy_of_kconfigtest"), KConfig::SimpleConfig); QVERIFY(!cf2.hasGroup(original.name())); QVERIFY(!cf2.hasGroup(copy.name())); @@ -1276,23 +1268,23 @@ void KConfigTest::testGroupCopyTo() void KConfigTest::testConfigCopyToSync() { - KConfig cf1(TEST_SUBDIR "kconfigtest"); + KConfig cf1(TEST_SUBDIR + QLatin1String("kconfigtest")); // Prepare source file KConfigGroup group(&cf1, "CopyToTest"); group.writeEntry("Type", "Test"); QVERIFY(cf1.sync()); // Copy to "destination" - const QString destination = testConfigDir() + "/kconfigcopytotest"; + const QString destination = m_testConfigDir + QLatin1String("/kconfigcopytotest"); QFile::remove(destination); - KConfig cf2(TEST_SUBDIR "kconfigcopytotest"); + KConfig cf2(TEST_SUBDIR + QLatin1String("kconfigcopytotest")); KConfigGroup group2(&cf2, "CopyToTest"); group.copyTo(&group2); QString testVal = group2.readEntry("Type"); - QCOMPARE(testVal, QString("Test")); + QCOMPARE(testVal, QStringLiteral("Test")); // should write to disk the copied data from group QVERIFY(cf2.sync()); QVERIFY(QFile::exists(destination)); @@ -1300,7 +1292,7 @@ void KConfigTest::testConfigCopyToSync() void KConfigTest::testConfigCopyTo() { - KConfig cf1(TEST_SUBDIR "kconfigtest"); + KConfig cf1(TEST_SUBDIR + QLatin1String("kconfigtest")); { // Prepare source file KConfigGroup group(&cf1, "CopyToTest"); @@ -1310,27 +1302,27 @@ void KConfigTest::testConfigCopyTo() { // Copy to "destination" - const QString destination = testConfigDir() + "/kconfigcopytotest"; + const QString destination = m_testConfigDir + QLatin1String("/kconfigcopytotest"); QFile::remove(destination); KConfig cf2; cf1.copyTo(destination, &cf2); KConfigGroup group2(&cf2, "CopyToTest"); QString testVal = group2.readEntry("Type"); - QCOMPARE(testVal, QString("Test")); + QCOMPARE(testVal, QStringLiteral("Test")); QVERIFY(cf2.sync()); QVERIFY(QFile::exists(destination)); } // Check copied config file on disk - KConfig cf3(TEST_SUBDIR "kconfigcopytotest"); + KConfig cf3(TEST_SUBDIR + QLatin1String("kconfigcopytotest")); KConfigGroup group3(&cf3, "CopyToTest"); QString testVal = group3.readEntry("Type"); - QCOMPARE(testVal, QString("Test")); + QCOMPARE(testVal, QStringLiteral("Test")); } void KConfigTest::testReparent() { - KConfig cf(TEST_SUBDIR "kconfigtest"); + KConfig cf(TEST_SUBDIR + QLatin1String("kconfigtest")); const QString name(QStringLiteral("Enum Types")); KConfigGroup group = cf.group(name); const QMap originalMap = group.entryMap(); @@ -1356,7 +1348,7 @@ static void ageTimeStamp(const QString &path, int nsec) struct utimbuf utbuf; utbuf.actime = mtime.toSecsSinceEpoch(); utbuf.modtime = utbuf.actime; - utime(QFile::encodeName(path), &utbuf); + utime(QFile::encodeName(path).constData(), &utbuf); #else QTest::qSleep(nsec * 1000); #endif @@ -1365,10 +1357,10 @@ static void ageTimeStamp(const QString &path, int nsec) void KConfigTest::testWriteOnSync() { QDateTime oldStamp, newStamp; - KConfig sc(TEST_SUBDIR "kconfigtest", KConfig::IncludeGlobals); + KConfig sc(TEST_SUBDIR + QLatin1String("kconfigtest"), KConfig::IncludeGlobals); // Age the timestamp of global config file a few sec, and collect it. - QString globFile = kdeGlobalsPath(); + QString globFile = m_kdeGlobalsPath; ageTimeStamp(globFile, 2); // age 2 sec oldStamp = QFileInfo(globFile).lastModified(); @@ -1383,7 +1375,7 @@ void KConfigTest::testWriteOnSync() QCOMPARE(newStamp, oldStamp); // Age the timestamp of local config file a few sec, and collect it. - QString locFile = testConfigDir() + "/kconfigtest"; + QString locFile = m_testConfigDir + QLatin1String("/kconfigtest"); ageTimeStamp(locFile, 2); // age 2 sec oldStamp = QFileInfo(locFile).lastModified(); @@ -1401,13 +1393,13 @@ void KConfigTest::testWriteOnSync() void KConfigTest::testFailOnReadOnlyFileSync() { - KConfig sc(TEST_SUBDIR "kconfigfailonreadonlytest"); + KConfig sc(TEST_SUBDIR + QLatin1String("kconfigfailonreadonlytest")); KConfigGroup cgLocal(&sc, "Locals"); cgLocal.writeEntry("someLocalString", "whatever"); QVERIFY(cgLocal.sync()); - QFile f(testConfigDir() + "kconfigfailonreadonlytest"); + QFile f(m_testConfigDir + QLatin1String("kconfigfailonreadonlytest")); QVERIFY(f.exists()); QVERIFY(f.setPermissions(QFileDevice::ReadOwner)); @@ -1425,7 +1417,7 @@ void KConfigTest::testFailOnReadOnlyFileSync() void KConfigTest::testDirtyOnEqual() { QDateTime oldStamp, newStamp; - KConfig sc(TEST_SUBDIR "kconfigtest"); + KConfig sc(TEST_SUBDIR + QLatin1String("kconfigtest")); // Initialize value KConfigGroup cgLocal(&sc, "random"); @@ -1433,7 +1425,7 @@ void KConfigTest::testDirtyOnEqual() QVERIFY(sc.sync()); // Age the timestamp of local config file a few sec, and collect it. - QString locFile = testConfigDir() + "/kconfigtest"; + QString locFile = m_testConfigDir + QLatin1String("/kconfigtest"); ageTimeStamp(locFile, 2); // age 2 sec oldStamp = QFileInfo(locFile).lastModified(); @@ -1453,7 +1445,7 @@ void KConfigTest::testDirtyOnEqualOverdo() QByteArray val2("\0""two", 4); QByteArray defvalr; - KConfig sc(TEST_SUBDIR "kconfigtest"); + KConfig sc(TEST_SUBDIR + QLatin1String("kconfigtest")); KConfigGroup cgLocal(&sc, "random"); cgLocal.writeEntry("someKey", val1); QCOMPARE(cgLocal.readEntry("someKey", defvalr), val1); @@ -1464,9 +1456,9 @@ void KConfigTest::testDirtyOnEqualOverdo() void KConfigTest::testCreateDir() { // Test auto-creating the parent directory when needed (KConfigIniBackend::createEnclosing) - QString kdehome = QDir::home().canonicalPath() + "/.kde-unit-test"; - QString subdir = kdehome + "/newsubdir"; - QString file = subdir + "/foo.desktop"; + const QString kdehome = QDir::home().canonicalPath() + QLatin1String("/.kde-unit-test"); + const QString subdir = kdehome + QLatin1String("/newsubdir"); + const QString file = subdir + QLatin1String("/foo.desktop"); QFile::remove(file); QDir().rmdir(subdir); QVERIFY(!QDir().exists(subdir)); @@ -1485,7 +1477,7 @@ void KConfigTest::testSyncOnExit() // Often, the KGlobalPrivate global static's destructor ends up calling ~KConfig -> // KConfig::sync ... and if that code triggers KGlobal code again then things could crash. // So here's a test for modifying KSharedConfig::openConfig() and not syncing, the process exit will sync. - KConfigGroup grp(KSharedConfig::openConfig(TEST_SUBDIR "syncOnExitRc"), "syncOnExit"); + KConfigGroup grp(KSharedConfig::openConfig(TEST_SUBDIR + QLatin1String("syncOnExitRc")), "syncOnExit"); grp.writeEntry("key", "value"); } @@ -1494,24 +1486,22 @@ void KConfigTest::testSharedConfig() // Can I use a KConfigGroup even after the KSharedConfigPtr goes out of scope? KConfigGroup myConfigGroup; { - KSharedConfigPtr config = KSharedConfig::openConfig(TEST_SUBDIR "kconfigtest"); + KSharedConfigPtr config = KSharedConfig::openConfig(TEST_SUBDIR + QLatin1String("kconfigtest")); myConfigGroup = KConfigGroup(config, "Hello"); } - QCOMPARE(myConfigGroup.readEntry("stringEntry1"), QString(STRINGENTRY1)); + QCOMPARE(myConfigGroup.readEntry("stringEntry1"), STRINGENTRY1); // Get the main config KSharedConfigPtr mainConfig = KSharedConfig::openConfig(); KConfigGroup mainGroup(mainConfig, "Main"); - QCOMPARE(mainGroup.readEntry("Key", QString()), QString("Value")); + QCOMPARE(mainGroup.readEntry("Key", QString{}), QStringLiteral("Value")); } void KConfigTest::testLocaleConfig() { // Initialize the testdata - QDir dir; - QString subdir = testConfigDir(); - dir.mkpath(subdir); - QString file = subdir + "/localized.test"; + QDir().mkpath(m_testConfigDir); + const QString file = m_testConfigDir + QLatin1String("/localized.test"); QFile::remove(file); QFile f(file); QVERIFY(f.open(QIODevice::WriteOnly)); @@ -1546,11 +1536,11 @@ void KConfigTest::testLocaleConfig() // Now check the correct config group KConfigGroup cg2(&config, "Test_Right"); - QCOMPARE(cg2.readEntry("foo"), QString("5")); + QCOMPARE(cg2.readEntry("foo"), QStringLiteral("5")); QCOMPARE(cg2.readEntry("foo", 3), 5); - QCOMPARE(cg2.readEntry("foostring"), QString("nice")); - QCOMPARE(cg2.readEntry("foostring", "ugly"), QString("nice")); - QCOMPARE(cg2.readEntry("foobool"), QString("true")); + QCOMPARE(cg2.readEntry("foostring"), QStringLiteral("nice")); + QCOMPARE(cg2.readEntry("foostring", "ugly"), QStringLiteral("nice")); + QCOMPARE(cg2.readEntry("foobool"), QStringLiteral("true")); QCOMPARE(cg2.readEntry("foobool", false), true); // Clean up after the testcase @@ -1560,10 +1550,9 @@ void KConfigTest::testLocaleConfig() void KConfigTest::testDeleteWhenLocalized() { // Initialize the testdata - QDir dir; - QString subdir = QDir::home().canonicalPath() + "/.kde-unit-test/"; - dir.mkpath(subdir); - QString file = subdir + "/localized_delete.test"; + const QString subdir = QDir::home().canonicalPath() + QLatin1String("/.kde-unit-test/"); + QDir().mkpath(subdir); + const QString file = subdir + QLatin1String("/localized_delete.test"); QFile::remove(file); QFile f(file); QVERIFY(f.open(QIODevice::WriteOnly)); @@ -1615,7 +1604,7 @@ void KConfigTest::testDeleteWhenLocalized() QVERIFY(cg.hasKey("foo")); // Check where the wrong values come from. // We get the "de" value. - QCOMPARE(cg.readEntry("foostring", "nothing"), QString("schoen")); + QCOMPARE(cg.readEntry("foostring", "nothing"), QStringLiteral("schoen")); // We get the "de" value. QCOMPARE(cg.readEntry("foobool", false), true); @@ -1631,7 +1620,7 @@ void KConfigTest::testDeleteWhenLocalized() QVERIFY(cg.hasKey("foo")); // Check where the wrong values come from. // We get the primary value because the "ca" value was deleted. - QCOMPARE(cg.readEntry("foostring", "nothing"), QString("ugly")); + QCOMPARE(cg.readEntry("foostring", "nothing"), QStringLiteral("ugly")); // We get the "ca" value. QCOMPARE(cg.readEntry("foobool", false), true); @@ -1660,7 +1649,7 @@ void KConfigTest::testDeleteWhenLocalized() QVERIFY(!cg.hasKey("foobool")); // Check where the wrong values come from. // We get the "de" value. - QCOMPARE(cg.readEntry("foostring", "nothing"), QString("schoen")); + QCOMPARE(cg.readEntry("foostring", "nothing"), QStringLiteral("schoen")); // We get the "de" value. QCOMPARE(cg.readEntry("foobool", false), true); // We get the "de" value. @@ -1696,10 +1685,10 @@ void KConfigTest::testKdeGlobals() KConfig globRead(QStringLiteral("kdeglobals")); const KConfigGroup general(&globRead, "General"); - QCOMPARE(general.readEntry("testKG"), QString("1")); + QCOMPARE(general.readEntry("testKG"), QStringLiteral("1")); // Check we wrote into kdeglobals - const QList lines = readLines("kdeglobals"); + const QList lines = readLines(QStringLiteral("kdeglobals")); QVERIFY(lines.contains("[General]\n")); QVERIFY(lines.contains("testKG=1\n")); @@ -1711,13 +1700,13 @@ void KConfigTest::testKdeGlobals() QVERIFY(glob.sync()); } globRead.reparseConfiguration(); - QCOMPARE(general.readEntry("testKG"), QString("2")); + QCOMPARE(general.readEntry("testKG"), QStringLiteral("2")); // Reading using NoGlobals { KConfig globReadNoGlob(QStringLiteral("kdeglobals"), KConfig::NoGlobals); const KConfigGroup generalNoGlob(&globReadNoGlob, "General"); - QCOMPARE(generalNoGlob.readEntry("testKG"), QString("2")); + QCOMPARE(generalNoGlob.readEntry("testKG"), QStringLiteral("2")); } // TODO now use kconfigtest and writeEntry(,Global) -> should go into kdeglobals @@ -1729,7 +1718,7 @@ void KConfigTest::testAnonymousConfig() KConfigGroup general(&anonConfig, "General"); QCOMPARE(general.readEntry("testKG"), QString()); // no kdeglobals merging general.writeEntry("Foo", "Bar"); - QCOMPARE(general.readEntry("Foo"), QString("Bar")); + QCOMPARE(general.readEntry("Foo"), QStringLiteral("Bar")); } void KConfigTest::testQByteArrayUtf8() @@ -1853,12 +1842,12 @@ void KConfigTest::testXdgListEntry() KConfigGroup grp = anonConfig.group("General"); QStringList invalidList; // use this as a default when an empty list is expected invalidList << QStringLiteral("Error! Default value read!"); - QCOMPARE(grp.readXdgListEntry("Key1", invalidList), QStringList()); - QCOMPARE(grp.readXdgListEntry("Key2", invalidList), QStringList() << QString()); - QCOMPARE(grp.readXdgListEntry("Key3", invalidList), QStringList() << QString() << QString()); - QCOMPARE(grp.readXdgListEntry("Key4", invalidList), QStringList()<< QString() << QString() << QString()); - QCOMPARE(grp.readXdgListEntry("Key5", invalidList), QStringList() << ";"); - QCOMPARE(grp.readXdgListEntry("Key6", invalidList), QStringList() << "1" << "2;3" << QString()); + QCOMPARE(grp.readXdgListEntry("Key1", invalidList), (QStringList{})); + QCOMPARE(grp.readXdgListEntry("Key2", invalidList), (QStringList{QString{}})); + QCOMPARE(grp.readXdgListEntry("Key3", invalidList), (QStringList{QString{}, QString{}})); + QCOMPARE(grp.readXdgListEntry("Key4", invalidList), (QStringList{QString{}, QString{}, QString{}})); + QCOMPARE(grp.readXdgListEntry("Key5", invalidList), (QStringList{QStringLiteral(";")})); + QCOMPARE(grp.readXdgListEntry("Key6", invalidList), (QStringList{QStringLiteral("1"), QStringLiteral("2;3"), QString{}})); } #include @@ -1890,15 +1879,15 @@ void KConfigTest::testNotify() QSKIP("KConfig notification requires DBus"); #endif - KConfig config(TEST_SUBDIR "kconfigtest"); + KConfig config(TEST_SUBDIR + QLatin1String("kconfigtest")); auto myConfigGroup = KConfigGroup(&config, "TopLevelGroup"); //mimics a config in another process, which is watching for events - auto remoteConfig = KSharedConfig::openConfig(TEST_SUBDIR "kconfigtest"); + auto remoteConfig = KSharedConfig::openConfig(TEST_SUBDIR + QLatin1String("kconfigtest")); KConfigWatcher::Ptr watcher = KConfigWatcher::create(remoteConfig); //some random config that shouldn't be changing when kconfigtest changes, only on kdeglobals - auto otherRemoteConfig = KSharedConfig::openConfig(TEST_SUBDIR "kconfigtest2"); + auto otherRemoteConfig = KSharedConfig::openConfig(TEST_SUBDIR + QLatin1String("kconfigtest2")); KConfigWatcher::Ptr otherWatcher = KConfigWatcher::create(otherRemoteConfig); QSignalSpy watcherSpy(watcher.data(), &KConfigWatcher::configChanged); @@ -1974,21 +1963,21 @@ void KConfigTest::testKdeglobalsVsDefault() generalGlob.writeEntry("testRestore", "global"); QVERIFY(glob.sync()); - KConfig local(QStringLiteral(TEST_SUBDIR "restorerc")); + KConfig local(TEST_SUBDIR + QLatin1String("restorerc")); KConfigGroup generalLocal(&local, "General"); // Check if we get global and not the default value from cpp (defaultcpp) when reading data from restorerc - QCOMPARE(generalLocal.readEntry("testRestore", "defaultcpp"), "global"); + QCOMPARE(generalLocal.readEntry("testRestore", "defaultcpp"), QStringLiteral("global")); // Add test restore key with restore value in restorerc file generalLocal.writeEntry("testRestore", "restore"); QVERIFY(local.sync()); local.reparseConfiguration(); // We expect to get the value from restorerc file - QCOMPARE(generalLocal.readEntry("testRestore", "defaultcpp"), "restore"); + QCOMPARE(generalLocal.readEntry("testRestore", "defaultcpp"), QStringLiteral("restore")); // Revert to default testRestore key and we expect to get default value and not the global one generalLocal.revertToDefault("testRestore"); local.sync(); local.reparseConfiguration(); - QCOMPARE(generalLocal.readEntry("testRestore", "defaultcpp"), "defaultcpp"); + QCOMPARE(generalLocal.readEntry("testRestore", "defaultcpp"), QStringLiteral("defaultcpp")); } diff --git a/autotests/kconfigtest.h b/autotests/kconfigtest.h index 7617d0e7..1a248c74 100644 --- a/autotests/kconfigtest.h +++ b/autotests/kconfigtest.h @@ -77,6 +77,10 @@ private Q_SLOTS: // should be last void testSyncOnExit(); + +private: + QString m_testConfigDir; + QString m_kdeGlobalsPath; }; Q_DECLARE_OPERATORS_FOR_FLAGS(KConfigTest::Flags) From bb16fda4e5f7caa9e892540ec69a202cec9eb16f Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Wed, 3 Feb 2021 18:20:34 +0200 Subject: [PATCH 107/259] Compile without implicit cast from ASCII NO_CHANGELOG --- autotests/CMakeLists.txt | 3 - src/kconf_update/CMakeLists.txt | 2 - src/kconfig_compiler/KConfigParameters.cpp | 3 - src/kconfig_compiler/kconfig_compiler.cpp | 91 ++++++++++------------ 4 files changed, 42 insertions(+), 57 deletions(-) diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt index efc36b7b..f07bf557 100644 --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -1,6 +1,3 @@ - -remove_definitions(-DQT_NO_CAST_FROM_ASCII) - include(ECMAddTests) find_package(Qt5Test ${REQUIRED_QT_VERSION} CONFIG QUIET) diff --git a/src/kconf_update/CMakeLists.txt b/src/kconf_update/CMakeLists.txt index 4a551f59..917a471b 100644 --- a/src/kconf_update/CMakeLists.txt +++ b/src/kconf_update/CMakeLists.txt @@ -1,5 +1,3 @@ -remove_definitions(-DQT_NO_CAST_FROM_ASCII) - ########### next target ############### set(kconf_update_SRCS diff --git a/src/kconfig_compiler/KConfigParameters.cpp b/src/kconfig_compiler/KConfigParameters.cpp index 7999475e..1d61236d 100644 --- a/src/kconfig_compiler/KConfigParameters.cpp +++ b/src/kconfig_compiler/KConfigParameters.cpp @@ -13,9 +13,6 @@ #include "KConfigParameters.h" -// TODO: Remove this. -#undef QT_NO_CAST_FROM_ASCII - #include #include diff --git a/src/kconfig_compiler/kconfig_compiler.cpp b/src/kconfig_compiler/kconfig_compiler.cpp index a7ecd83e..e358f665 100644 --- a/src/kconfig_compiler/kconfig_compiler.cpp +++ b/src/kconfig_compiler/kconfig_compiler.cpp @@ -10,9 +10,6 @@ SPDX-License-Identifier: LGPL-2.0-or-later */ -// Compiling this file with this flag is just crazy -#undef QT_NO_CAST_FROM_ASCII - #include #include #include @@ -52,7 +49,7 @@ QString varPath(const QString &n, const KConfigParameters &cfg) { QString result; if (cfg.dpointer) { - result = "d->" + varName(n, cfg); + result = QLatin1String{"d->"} + varName(n, cfg); } else { result = varName(n, cfg); } @@ -145,7 +142,7 @@ QString immutableFunction(const QString &n, const QString &className) { QString result = QLatin1String("is") + n; result[2] = result[2].toUpper(); - result += "Immutable"; + result += QLatin1String{"Immutable"}; if (!className.isEmpty()) { result = className + QLatin1String("::") + result; @@ -188,7 +185,6 @@ QString literalString(const QString &s) } } - QString signalEnumName(const QString &signalName) { QString result; @@ -387,7 +383,7 @@ QString itemDeclaration(const CfgEntry *e, const KConfigParameters &cfg) return QString{}; } - const QString type = cfg.inherits + "::Item" + itemType(e->type); + const QString type = cfg.inherits + QLatin1String{"::Item"} + itemType(e->type); QString fCap = e->name; fCap[0] = fCap.at(0).toUpper(); @@ -395,12 +391,12 @@ QString itemDeclaration(const CfgEntry *e, const KConfigParameters &cfg) QString result; if (!cfg.itemAccessors && !cfg.dpointer) { - result += " " + (!e->signalList.isEmpty() ? QStringLiteral("KConfigCompilerSignallingItem") : type) + - " *item" + fCap + argSuffix + ";\n"; + result += QLatin1String{" "} + (!e->signalList.isEmpty() ? QStringLiteral("KConfigCompilerSignallingItem") : type) + + QLatin1String{" *item"} + fCap + argSuffix + QLatin1String{";\n"}; } if (!e->signalList.isEmpty()) { - result += " " + type + " *" + innerItemVar(e, cfg) + argSuffix + ";\n"; + result += QLatin1String{" "} + type + QLatin1String{" *"} + innerItemVar(e, cfg) + argSuffix + QLatin1String{";\n"}; } return result; @@ -414,14 +410,14 @@ QString itemVar(const CfgEntry *e, const KConfigParameters &cfg) QString result; if (cfg.itemAccessors) { if (!cfg.dpointer) { - result = 'm' + e->name + "Item"; + result = QLatin1Char{'m'} + e->name + QLatin1String{"Item"}; result[1] = result[1].toUpper(); } else { - result = e->name + "Item"; + result = e->name + QLatin1String{"Item"}; result[0] = result[0].toLower(); } } else { - result = "item" + e->name; + result = QLatin1String{"item"} + e->name; result[4] = result[4].toUpper(); } return result; @@ -435,7 +431,7 @@ QString innerItemVar(const CfgEntry *e, const KConfigParameters &cfg) if (e->signalList.isEmpty()) { return itemPath(e, cfg); } else { - QString result = "innerItem" + e->name; + QString result = QLatin1String{"innerItem"} + e->name; result[9] = result[9].toUpper(); return result; } @@ -445,20 +441,20 @@ QString itemPath(const CfgEntry *e, const KConfigParameters &cfg) { QString result; if (cfg.dpointer) { - result = "d->" + itemVar(e, cfg); + result = QLatin1String{"d->"} + itemVar(e, cfg); } else { result = itemVar(e, cfg); } return result; } -QString newInnerItem(const CfgEntry *entry, const QString &key, const QString &defaultValue, - const KConfigParameters &cfg, const QString ¶m) { - QString t = "new "+ cfg.inherits + "::Item" + itemType(entry->type) + "( currentGroup(), " - + key + ", " + varPath( entry->name, cfg ) + param; +QString newInnerItem(const CfgEntry *entry, const QString &key, const QString &defaultValue, const KConfigParameters &cfg, const QString ¶m) +{ + QString t = QLatin1String{"new "} + cfg.inherits + QLatin1String{"::Item"} + itemType(entry->type) + + QLatin1String{"( currentGroup(), "} + key + QLatin1String{", "} + varPath( entry->name, cfg ) + param; if (entry->type == QLatin1String("Enum")) { - t += ", values" + entry->name; + t += QLatin1String{", values"} + entry->name; } if (!defaultValue.isEmpty()) { t += QLatin1String(", ") + defaultValue; @@ -492,14 +488,9 @@ QString newItem(const CfgEntry *entry, const QString &key, const QString &defaul QString paramString(const QString &s, const CfgEntry *e, int i) { QString result = s; - QString needle = "$(" + e->param + ')'; + const QString needle = QLatin1String{"$("} + e->param + QLatin1Char{')'}; if (result.contains(needle)) { - QString tmp; - if (e->paramType == QLatin1String("Enum")) { - tmp = e->paramValues.at(i); - } else { - tmp = QString::number(i); - } + const QString tmp = e->paramType == QLatin1String{"Enum"} ? e->paramValues.at(i) : QString::number(i); result.replace(needle, tmp); } @@ -513,17 +504,17 @@ QString paramString(const QString &group, const QList ¶meters) int i = 1; for (QList::ConstIterator it = parameters.constBegin(); it != parameters.constEnd(); ++it) { - if (paramString.contains("$(" + (*it).name + ')')) { + if (paramString.contains(QLatin1String{"$("} + (*it).name + QLatin1Char{')'})) { const QString tmp = QStringLiteral("%%1").arg(i++); - paramString.replace("$(" + (*it).name + ')', tmp); - arguments += ".arg( mParam" + (*it).name + " )"; + paramString.replace(QLatin1String{"$("} + (*it).name + QLatin1Char{')'}, tmp); + arguments += QLatin1String{".arg( mParam"} + (*it).name + QLatin1String{" )"}; } } if (arguments.isEmpty()) { - return "QStringLiteral( \"" + group + "\" )"; + return QLatin1String{"QStringLiteral( \""} + group + QLatin1String{"\" )"}; } - return "QStringLiteral( \"" + paramString + "\" )" + arguments; + return QLatin1String{"QStringLiteral( \""} + paramString + QLatin1String{"\" )"} + arguments; } QString translatedString(const KConfigParameters &cfg, const QString &string, const QString &context, const QString ¶m, const QString ¶mValue) @@ -533,35 +524,36 @@ QString translatedString(const KConfigParameters &cfg, const QString &string, co switch (cfg.translationSystem) { case KConfigParameters::QtTranslation: if (!context.isEmpty()) { - result += "/*: " + context + " */ QCoreApplication::translate(\""; + result += QLatin1String{"/*: "} + context + QLatin1String{" */ QCoreApplication::translate(\""}; } else { - result += QLatin1String("QCoreApplication::translate(\""); + result += QLatin1String{"QCoreApplication::translate(\""}; } - result += cfg.className + "\", "; + result += cfg.className + QLatin1String{"\", "}; break; case KConfigParameters::KdeTranslation: if (!cfg.translationDomain.isEmpty() && !context.isEmpty()) { - result += "i18ndc(" + quoteString(cfg.translationDomain) + ", " + quoteString(context) + ", "; + result += QLatin1String{"i18ndc("} + quoteString(cfg.translationDomain) + QLatin1String{", "} + + quoteString(context) + QLatin1String{", "}; } else if (!cfg.translationDomain.isEmpty()) { - result += "i18nd(" + quoteString(cfg.translationDomain) + ", "; + result += QLatin1String{"i18nd("} + quoteString(cfg.translationDomain) + QLatin1String{", "}; } else if (!context.isEmpty()) { - result += "i18nc(" + quoteString(context) + ", "; + result += QLatin1String{"i18nc("} + quoteString(context) + QLatin1String{", "}; } else { - result += QLatin1String("i18n("); + result += QLatin1String{"i18n("}; } break; } if (!param.isEmpty()) { QString resolvedString = string; - resolvedString.replace("$(" + param + ')', paramValue); + resolvedString.replace(QLatin1String{"$("} + param + QLatin1Char{')'}, paramValue); result += quoteString(resolvedString); } else { result += quoteString(string); } - result += ')'; + result += QLatin1Char{')'}; return result; } @@ -574,17 +566,17 @@ QString userTextsFunctions(const CfgEntry *e, const KConfigParameters &cfg, QStr itemVarStr = itemPath(e, cfg); } if (!e->label.isEmpty()) { - txt += " " + itemVarStr + "->setLabel( "; + txt += QLatin1String{" "} + itemVarStr + QLatin1String{"->setLabel( "}; txt += translatedString(cfg, e->label, e->labelContext, e->param, i); txt += QLatin1String(" );\n"); } if (!e->toolTip.isEmpty()) { - txt += " " + itemVarStr + "->setToolTip( "; + txt += QLatin1String{" "} + itemVarStr + QLatin1String{"->setToolTip( "}; txt += translatedString(cfg, e->toolTip, e->toolTipContext, e->param, i); txt += QLatin1String(" );\n"); } if (!e->whatsThis.isEmpty()) { - txt += " " + itemVarStr + "->setWhatsThis( "; + txt += QLatin1String{" "} + itemVarStr + QLatin1String{"->setWhatsThis( "}; txt += translatedString(cfg, e->whatsThis, e->whatsThisContext, e->param, i); txt += QLatin1String(" );\n"); } @@ -625,7 +617,7 @@ QString memberGetDefaultBody(const CfgEntry *e) QString defaultValue = e->defaultValue; out << " default:\n"; - out << " return " << defaultValue.replace("$(" + e->param + ')', QLatin1String("i")) << ";\n"; + out << " return " << defaultValue.replace(QLatin1String{"$("} + e->param + QLatin1Char{')'}, QLatin1String("i")) << ";\n"; out << " }\n"; } else { out << " return " << e->defaultValue << ';'; @@ -764,16 +756,17 @@ int main(int argc, char **argv) QString baseDir = parser.value(targetDirectoryOption); #ifdef Q_OS_WIN - if (!baseDir.endsWith('/') && !baseDir.endsWith('\\')) + if (!baseDir.endsWith(QLatin1Char{'/'}) && !baseDir.endsWith(QLatin1Char{'\\'})) { #else - if (!baseDir.endsWith('/')) + if (!baseDir.endsWith(QLatin1Char{'/'})) { #endif - baseDir.append("/"); + baseDir.append(QLatin1Char{'/'}); + } KConfigParameters cfg(codegenFilename); KConfigXmlParser xmlParser(cfg, inputFilename); - + // The Xml Parser aborts in the case of an error, so if we get // to parseResult, we have a working Xml file. xmlParser.start(); From dc878289c01011c59615746655b4e78d4bc90b91 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Wed, 3 Feb 2021 15:28:38 +0200 Subject: [PATCH 108/259] Minor code optimisations - Use a global var for a QString that's used many times - Break up long-all-cap variable names, it makes it harder to read (and I've fixed one typo in one of those ALLCAPS) - Fix some clazy warnings, make global QString objects in unit tests static (so that the compiler doesn't create symbols for them, it doesn't matter in a unit test but KF code acts as a reference sometimes that others copy from, tip from dfaure) - Add TODO note about changing kconfig_compiler to generate C++ code that uses multi-arg QString::arg(QString, QString, QString) instead of QString::arg().arg() - More const; more QString::at() instead of operator[] where appropriate - Use a ternary where it makes the code more readable (and uses less lines :)) NO_CHANGELOG --- autotests/kconfigguitest.cpp | 20 +- autotests/kconfigloadertest.cpp | 6 +- autotests/kconfigskeletontest.cpp | 49 +-- autotests/kconfigtest.cpp | 405 +++++++++++----------- autotests/kentrymaptest.cpp | 12 +- src/core/kauthorized.cpp | 10 +- src/gui/kconfigloader.cpp | 6 +- src/kconfig_compiler/kconfig_compiler.cpp | 118 +++---- 8 files changed, 307 insertions(+), 319 deletions(-) diff --git a/autotests/kconfigguitest.cpp b/autotests/kconfigguitest.cpp index 87168a7f..2744d272 100644 --- a/autotests/kconfigguitest.cpp +++ b/autotests/kconfigguitest.cpp @@ -18,9 +18,9 @@ QTEST_MAIN(KConfigTest) // clazy:excludeall=non-pod-global-static -const QColor COLORENTRY1(QLatin1String{"steelblue"}); -const QColor COLORENTRY2(235, 235, 100, 125); -const QColor COLORENTRY3(234, 234, 127); +static const QColor s_color_entry1(QLatin1String{"steelblue"}); +static const QColor s_color_entry2(235, 235, 100, 125); +static const QColor s_color_entry3(234, 234, 127); static QFont fontEntry() { @@ -38,8 +38,8 @@ void KConfigTest::initTestCase() KConfig sc(QStringLiteral("kconfigtest")); KConfigGroup cg(&sc, "ComplexTypes"); - cg.writeEntry("colorEntry1", COLORENTRY1); - cg.writeEntry("colorEntry2", COLORENTRY2); + cg.writeEntry("colorEntry1", s_color_entry1); + cg.writeEntry("colorEntry2", s_color_entry2); cg.writeEntry("colorEntry3", (QList() << 234 << 234 << 127)); cg.writeEntry("colorEntry4", (QList() << 235 << 235 << 100 << 125)); cg.writeEntry("fontEntry", fontEntry()); @@ -78,11 +78,11 @@ void KConfigTest::testComplex() KConfigGroup sc3(&sc2, "ComplexTypes"); QCOMPARE(QVariant(sc3.readEntry("colorEntry1", QColor(Qt::black))).toString(), - QVariant(COLORENTRY1).toString()); - QCOMPARE(sc3.readEntry("colorEntry1", QColor()), COLORENTRY1); - QCOMPARE(sc3.readEntry("colorEntry2", QColor()), COLORENTRY2); - QCOMPARE(sc3.readEntry("colorEntry3", QColor()), COLORENTRY3); - QCOMPARE(sc3.readEntry("colorEntry4", QColor()), COLORENTRY2); + QVariant(s_color_entry1).toString()); + QCOMPARE(sc3.readEntry("colorEntry1", QColor()), s_color_entry1); + QCOMPARE(sc3.readEntry("colorEntry2", QColor()), s_color_entry2); + QCOMPARE(sc3.readEntry("colorEntry3", QColor()), s_color_entry3); + QCOMPARE(sc3.readEntry("colorEntry4", QColor()), s_color_entry2); QCOMPARE(sc3.readEntry("defaultColorTest", QColor("black")), QColor("black")); if (m_fontFromStringBug) { QEXPECT_FAIL("", "QFont fromString bug from Qt 5.8.0", Continue); diff --git a/autotests/kconfigloadertest.cpp b/autotests/kconfigloadertest.cpp index 27a90916..ab93c1da 100644 --- a/autotests/kconfigloadertest.cpp +++ b/autotests/kconfigloadertest.cpp @@ -12,10 +12,10 @@ Q_DECLARE_METATYPE(QList) -const QString TEST_NAME(QStringLiteral("kconfigloadertest")); +static const QString s_testName(QStringLiteral("kconfigloadertest")); // clazy:exclude=non-pod-global-static #define GET_CONFIG_ITEM_VALUE(type, configName) \ - KConfigSkeletonItem* item = cl->findItem(TEST_NAME, configName); \ + KConfigSkeletonItem* item = cl->findItem(s_testName, configName); \ /* Check if we got back a valid item. */ \ QVERIFY(item != nullptr); \ /* Cast the item to the given type. */ \ @@ -25,7 +25,7 @@ const QString TEST_NAME(QStringLiteral("kconfigloadertest")); void ConfigLoaderTest::init() { - QString fileName = TEST_NAME + QLatin1String(".xml"); + QString fileName = s_testName + QLatin1String(".xml"); configFile = new QFile(QFINDTESTDATA(QString::fromLatin1("/") + fileName)); cl = new KConfigLoader(configFile->fileName(), configFile); } diff --git a/autotests/kconfigskeletontest.cpp b/autotests/kconfigskeletontest.cpp index 75708bc1..950e6581 100644 --- a/autotests/kconfigskeletontest.cpp +++ b/autotests/kconfigskeletontest.cpp @@ -12,14 +12,15 @@ QTEST_MAIN(KConfigSkeletonTest) -#define DEFAULT_SETTING1 false -#define DEFAULT_SETTING2 QColor(1,2,3) -const QString DEFAULT_SETTING4{QStringLiteral("Hello World")}; +// clazy:excludeall=non-pod-global-static +static const bool s_default_setting1{false}; +static const QColor s_default_setting2{1,2,3}; +static const QString s_default_setting4{QStringLiteral("Hello World")}; -#define WRITE_SETTING1 true -#define WRITE_SETTING2 QColor(3,2,1) -const QString WRITE_SETTING4{QStringLiteral("KDE")}; +static const bool s_write_setting1{true}; +static const QColor s_write_setting2{3,2,1}; +static const QString s_write_setting4{QStringLiteral("KDE")}; static QFont defaultSetting3() { @@ -41,17 +42,17 @@ void KConfigSkeletonTest::init() QFile::remove(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1String{"/kconfigskeletontestrc"}); s = new KConfigSkeleton(QStringLiteral("kconfigskeletontestrc")); s->setCurrentGroup(QStringLiteral("MyGroup")); - itemBool = s->addItemBool(QStringLiteral("MySetting1"), mMyBool, DEFAULT_SETTING1); - s->addItemColor(QStringLiteral("MySetting2"), mMyColor, DEFAULT_SETTING2); + itemBool = s->addItemBool(QStringLiteral("MySetting1"), mMyBool, s_default_setting1); + s->addItemColor(QStringLiteral("MySetting2"), mMyColor, s_default_setting2); s->setCurrentGroup(QStringLiteral("MyOtherGroup")); s->addItemFont(QStringLiteral("MySetting3"), mMyFont, defaultSetting3()); - s->addItemString(QStringLiteral("MySetting4"), mMyString, DEFAULT_SETTING4); + s->addItemString(QStringLiteral("MySetting4"), mMyString, s_default_setting4); - QCOMPARE(mMyBool, DEFAULT_SETTING1); - QCOMPARE(mMyColor, DEFAULT_SETTING2); + QCOMPARE(mMyBool, s_default_setting1); + QCOMPARE(mMyColor, s_default_setting2); QCOMPARE(mMyFont, defaultSetting3()); - QCOMPARE(mMyString, DEFAULT_SETTING4); + QCOMPARE(mMyString, s_default_setting4); QVERIFY(s->isDefaults()); QVERIFY(!s->isSaveNeeded()); @@ -64,10 +65,10 @@ void KConfigSkeletonTest::cleanup() void KConfigSkeletonTest::testSimple() { - mMyBool = WRITE_SETTING1; - mMyColor = WRITE_SETTING2; + mMyBool = s_write_setting1; + mMyColor = s_write_setting2; mMyFont = writeSettings3(); - mMyString = WRITE_SETTING4; + mMyString = s_write_setting4; QVERIFY(s->isSaveNeeded()); QVERIFY(!s->isDefaults()); @@ -90,10 +91,10 @@ void KConfigSkeletonTest::testSimple() QVERIFY(!s->isSaveNeeded()); QVERIFY(!s->isDefaults()); - QCOMPARE(mMyBool, WRITE_SETTING1); - QCOMPARE(mMyColor, WRITE_SETTING2); + QCOMPARE(mMyBool, s_write_setting1); + QCOMPARE(mMyColor, s_write_setting2); QCOMPARE(mMyFont, writeSettings3()); - QCOMPARE(mMyString, WRITE_SETTING4); + QCOMPARE(mMyString, s_write_setting4); } void KConfigSkeletonTest::testRemoveItem() @@ -118,10 +119,10 @@ void KConfigSkeletonTest::testClear() void KConfigSkeletonTest::testDefaults() { - mMyBool = WRITE_SETTING1; - mMyColor = WRITE_SETTING2; + mMyBool = s_write_setting1; + mMyColor = s_write_setting2; mMyFont = writeSettings3(); - mMyString = WRITE_SETTING4; + mMyString = s_write_setting4; QVERIFY(s->isSaveNeeded()); QVERIFY(!s->isDefaults()); @@ -136,10 +137,10 @@ void KConfigSkeletonTest::testDefaults() QVERIFY(s->isSaveNeeded()); QVERIFY(s->isDefaults()); - QCOMPARE(mMyBool, DEFAULT_SETTING1); - QCOMPARE(mMyColor, DEFAULT_SETTING2); + QCOMPARE(mMyBool, s_default_setting1); + QCOMPARE(mMyColor, s_default_setting2); QCOMPARE(mMyFont, defaultSetting3()); - QCOMPARE(mMyString, DEFAULT_SETTING4); + QCOMPARE(mMyString, s_default_setting4); s->save(); diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index 5cb31f49..0619f97f 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -44,46 +44,47 @@ static QString homePath() #endif } -const bool BOOLENTRY1 = true; -const bool BOOLENTRY2 = false; - // clazy:excludeall=non-pod-global-static -const QString STRINGENTRY1(QStringLiteral("hello")); -const QString STRINGENTRY2(QStringLiteral(" hello")); -const QString STRINGENTRY3(QStringLiteral("hello ")); -const QString STRINGENTRY4(QStringLiteral(" hello ")); -const QString STRINGENTRY5(QStringLiteral(" ")); -const QString STRINGENTRY6{}; - -const char UTF8BITENTRY[] = "Hello äöü"; -const QString TRANSLATEDSTRINGENTRY1{QStringLiteral("bonjour")}; -const QByteArray BYTEARRAYENTRY{"\x00\xff\x7f\x3c abc\x00\x00", 10}; -const char ESCAPEKEY[] = " []\0017[]==]"; -const char ESCAPEENTRY[] = "[]\170[]]=3=]\\] "; -const double DOUBLEENTRY{123456.78912345}; -const float FLOATENTRY{123.567f}; -const QPoint POINTENTRY{4351, 1235}; -const QSize SIZEENTRY{10, 20}; -const QRect RECTENTRY{10, 23, 5321, 13}; -const QDateTime DATETIMEENTRY{QDate{2002, 06, 23}, QTime{12, 55, 40}}; -const QDateTime DATETIMEWITHMSENTRY{QDate{2002, 06, 23}, QTime{12, 55, 40, 532}}; -const QStringList STRINGLISTENTRY{QStringLiteral("Hello,"), QStringLiteral("World")}; -const QStringList STRINGLISTEMPTYENTRY{}; -const QStringList STRINGLISTJUSTEMPTYELEMENT{QString{}}; -const QStringList STRINGLISTEMPTYTRAILINGELEMENT{QStringLiteral("Hi"), QString{}}; -const QStringList STRINGLISTESCAPEODDENTRY{QStringLiteral("Hello\\\\\\"), QStringLiteral("World")}; -const QStringList STRINGLISTESCAPEEVENENTRY{QStringLiteral("Hello\\\\\\\\"), QStringLiteral("World")}; -const QStringList STRINGLISTESCAPECOMMAENTRY{QStringLiteral("Hel\\\\\\,\\\\,\\,\\\\\\\\,lo"), QStringLiteral("World")}; -const QList INTLISTENTRY1{1, 2, 3, 4}; -const QList BYTEARRAYLISTENTRY1{"", "1,2", "end"}; -const QVariantList VARIANTLISTENTRY{true, false, QStringLiteral("joe"), 10023}; -const QVariantList VARIANTLISTENTRY2{POINTENTRY, SIZEENTRY}; - -const QString HOMEPATH{homePath() + QLatin1String{"/foo"}}; -const QString HOMEPATH_ESCAPE{homePath() + QLatin1String("/foo/$HOME")}; -const QString DOLLARGROUP{QStringLiteral("$i")}; -const QString TEST_SUBDIR{QStringLiteral("kconfigtest_subdir/")}; +static const bool s_bool_entry1 = true; +static const bool s_bool_entry2 = false; + +static const QString s_string_entry1(QStringLiteral("hello")); +static const QString s_string_entry2(QStringLiteral(" hello")); +static const QString s_string_entry3(QStringLiteral("hello ")); +static const QString s_string_entry4(QStringLiteral(" hello ")); +static const QString s_string_entry5(QStringLiteral(" ")); +static const QString s_string_entry6{}; + +static const char s_utf8bit_entry[] = "Hello äöü"; +static const QString s_translated_string_entry1{QStringLiteral("bonjour")}; +static const QByteArray s_bytearray_entry{"\x00\xff\x7f\x3c abc\x00\x00", 10}; +static const char s_escapekey[] = " []\0017[]==]"; +static const char s_escape_entry[] = "[]\170[]]=3=]\\] "; +static const double s_double_entry{123456.78912345}; +static const float s_float_entry{123.567f}; +static const QPoint s_point_entry{4351, 1235}; +static const QSize s_size_entry{10, 20}; +static const QRect s_rect_entry{10, 23, 5321, 13}; +static const QDateTime s_date_time_entry{QDate{2002, 06, 23}, QTime{12, 55, 40}}; +static const QDateTime s_date_time_with_ms_entry{QDate{2002, 06, 23}, QTime{12, 55, 40, 532}}; +static const QStringList s_stringlist_entry{QStringLiteral("Hello,"), QStringLiteral("World")}; +static const QStringList s_stringlist_empty_entry{}; +static const QStringList s_stringlist_just_empty_element{QString{}}; +static const QStringList s_stringlist_empty_trailing_element{QStringLiteral("Hi"), QString{}}; +static const QStringList s_stringlist_escape_odd_entry{QStringLiteral("Hello\\\\\\"), QStringLiteral("World")}; +static const QStringList s_stringlist_escape_even_entry{QStringLiteral("Hello\\\\\\\\"), QStringLiteral("World")}; +static const QStringList s_stringlist_escape_comma_entry{QStringLiteral("Hel\\\\\\,\\\\,\\,\\\\\\\\,lo"), QStringLiteral("World")}; +static const QList s_int_listentry1{1, 2, 3, 4}; +static const QList s_bytearray_list_entry1{"", "1,2", "end"}; +static const QVariantList s_variantlist_entry{true, false, QStringLiteral("joe"), 10023}; +static const QVariantList s_variantlist_entry2{s_point_entry, s_size_entry}; + +static const QString s_homepath{homePath() + QLatin1String{"/foo"}}; +static const QString s_homepath_escape{homePath() + QLatin1String("/foo/$HOME")}; +static const QString s_dollargroup{QStringLiteral("$i")}; +static const QString s_test_subdir{QStringLiteral("kconfigtest_subdir/")}; +static const QString s_kconfig_test_subdir(s_test_subdir + QLatin1String("kconfigtest")); #ifndef Q_OS_WIN void initLocale() @@ -103,7 +104,7 @@ void KConfigTest::initTestCase() qRegisterMetaType(); // These two need to be assigned here, after setTestModeEnabled(true), and before cleanupTestCase() - m_testConfigDir = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1Char('/') + TEST_SUBDIR; + m_testConfigDir = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1Char('/') + s_test_subdir; m_kdeGlobalsPath = QDir::cleanPath(m_testConfigDir + QLatin1String("..")) + QLatin1String("/kdeglobals"); // to make sure all files from a previous failed run are deleted @@ -113,75 +114,74 @@ void KConfigTest::initTestCase() mainConfig->group("Main").writeEntry("Key", "Value"); mainConfig->sync(); - KConfig sc(TEST_SUBDIR + QLatin1String("kconfigtest")); + KConfig sc(s_kconfig_test_subdir); KConfigGroup cg(&sc, "AAA"); - cg.writeEntry("stringEntry1", STRINGENTRY1, - KConfig::Persistent | KConfig::Global); + cg.writeEntry("stringEntry1", s_string_entry1, KConfig::Persistent | KConfig::Global); cg.deleteEntry("stringEntry2", KConfig::Global); cg = KConfigGroup(&sc, "Hello"); - cg.writeEntry("boolEntry1", BOOLENTRY1); - cg.writeEntry("boolEntry2", BOOLENTRY2); + cg.writeEntry("boolEntry1", s_bool_entry1); + cg.writeEntry("boolEntry2", s_bool_entry2); - QByteArray data(UTF8BITENTRY); + QByteArray data(s_utf8bit_entry); QCOMPARE(data.size(), 12); // the source file is in utf8 QCOMPARE(QString::fromUtf8(data).length(), 9); cg.writeEntry("Test", data); - cg.writeEntry("bytearrayEntry", BYTEARRAYENTRY); - cg.writeEntry(ESCAPEKEY, QStringLiteral(ESCAPEENTRY)); + cg.writeEntry("bytearrayEntry", s_bytearray_entry); + cg.writeEntry(s_escapekey, QString::fromLatin1(s_escape_entry)); cg.writeEntry("emptyEntry", ""); - cg.writeEntry("stringEntry1", STRINGENTRY1); - cg.writeEntry("stringEntry2", STRINGENTRY2); - cg.writeEntry("stringEntry3", STRINGENTRY3); - cg.writeEntry("stringEntry4", STRINGENTRY4); - cg.writeEntry("stringEntry5", STRINGENTRY5); + cg.writeEntry("stringEntry1", s_string_entry1); + cg.writeEntry("stringEntry2", s_string_entry2); + cg.writeEntry("stringEntry3", s_string_entry3); + cg.writeEntry("stringEntry4", s_string_entry4); + cg.writeEntry("stringEntry5", s_string_entry5); cg.writeEntry("urlEntry1", QUrl(QStringLiteral("http://qt-project.org"))); - cg.writeEntry("keywith=equalsign", STRINGENTRY1); + cg.writeEntry("keywith=equalsign", s_string_entry1); cg.deleteEntry("stringEntry5"); cg.deleteEntry("stringEntry6"); // deleting a nonexistent entry - cg.writeEntry("byteArrayEntry1", STRINGENTRY1.toLatin1(), KConfig::Global | KConfig::Persistent); - cg.writeEntry("doubleEntry1", DOUBLEENTRY); - cg.writeEntry("floatEntry1", FLOATENTRY); + cg.writeEntry("byteArrayEntry1", s_string_entry1.toLatin1(), KConfig::Global | KConfig::Persistent); + cg.writeEntry("doubleEntry1", s_double_entry); + cg.writeEntry("floatEntry1", s_float_entry); sc.deleteGroup("deleteMe"); // deleting a nonexistent group cg = KConfigGroup(&sc, "Complex Types"); - cg.writeEntry("rectEntry", RECTENTRY); - cg.writeEntry("pointEntry", POINTENTRY); - cg.writeEntry("sizeEntry", SIZEENTRY); - cg.writeEntry("dateTimeEntry", DATETIMEENTRY); - cg.writeEntry("dateEntry", DATETIMEENTRY.date()); - cg.writeEntry("dateTimeWithMSEntry", DATETIMEWITHMSENTRY); + cg.writeEntry("rectEntry", s_rect_entry); + cg.writeEntry("pointEntry", s_point_entry); + cg.writeEntry("sizeEntry", s_size_entry); + cg.writeEntry("dateTimeEntry", s_date_time_entry); + cg.writeEntry("dateEntry", s_date_time_entry.date()); + cg.writeEntry("dateTimeWithMSEntry", s_date_time_with_ms_entry); KConfigGroup ct = cg; cg = KConfigGroup(&ct, "Nested Group 1"); - cg.writeEntry("stringentry1", STRINGENTRY1); + cg.writeEntry("stringentry1", s_string_entry1); cg = KConfigGroup(&ct, "Nested Group 2"); - cg.writeEntry("stringEntry2", STRINGENTRY2); + cg.writeEntry("stringEntry2", s_string_entry2); cg = KConfigGroup(&cg, "Nested Group 2.1"); - cg.writeEntry("stringEntry3", STRINGENTRY3); + cg.writeEntry("stringEntry3", s_string_entry3); cg = KConfigGroup(&ct, "Nested Group 3"); - cg.writeEntry("stringEntry3", STRINGENTRY3); + cg.writeEntry("stringEntry3", s_string_entry3); cg = KConfigGroup(&sc, "List Types"); - cg.writeEntry("listOfIntsEntry1", INTLISTENTRY1); - cg.writeEntry("listOfByteArraysEntry1", BYTEARRAYLISTENTRY1); - cg.writeEntry("stringListEntry", STRINGLISTENTRY); - cg.writeEntry("stringListEmptyEntry", STRINGLISTEMPTYENTRY); - cg.writeEntry("stringListJustEmptyElement", STRINGLISTJUSTEMPTYELEMENT); - cg.writeEntry("stringListEmptyTrailingElement", STRINGLISTEMPTYTRAILINGELEMENT); - cg.writeEntry("stringListEscapeOddEntry", STRINGLISTESCAPEODDENTRY); - cg.writeEntry("stringListEscapeEvenEntry", STRINGLISTESCAPEEVENENTRY); - cg.writeEntry("stringListEscapeCommaEntry", STRINGLISTESCAPECOMMAENTRY); - cg.writeEntry("variantListEntry", VARIANTLISTENTRY); + cg.writeEntry("listOfIntsEntry1", s_int_listentry1); + cg.writeEntry("listOfByteArraysEntry1", s_bytearray_list_entry1); + cg.writeEntry("stringListEntry", s_stringlist_entry); + cg.writeEntry("stringListEmptyEntry", s_stringlist_empty_entry); + cg.writeEntry("stringListJustEmptyElement", s_stringlist_just_empty_element); + cg.writeEntry("stringListEmptyTrailingElement", s_stringlist_empty_trailing_element); + cg.writeEntry("stringListEscapeOddEntry", s_stringlist_escape_odd_entry); + cg.writeEntry("stringListEscapeEvenEntry", s_stringlist_escape_even_entry); + cg.writeEntry("stringListEscapeCommaEntry", s_stringlist_escape_comma_entry); + cg.writeEntry("variantListEntry", s_variantlist_entry); cg = KConfigGroup(&sc, "Path Type"); - cg.writePathEntry("homepath", HOMEPATH); - cg.writePathEntry("homepathescape", HOMEPATH_ESCAPE); + cg.writePathEntry("homepath", s_homepath); + cg.writePathEntry("homepathescape", s_homepath_escape); cg = KConfigGroup(&sc, "Enum Types"); #if defined(_MSC_VER) && _MSC_VER == 1600 @@ -210,7 +210,7 @@ void KConfigTest::initTestCase() QVERIFY2(QFile::exists(m_testConfigDir + QLatin1String("/kconfigtest")), qPrintable(m_testConfigDir + QLatin1String("/kconfigtest must exist"))); QVERIFY2(QFile::exists(m_kdeGlobalsPath), qPrintable(m_kdeGlobalsPath + QStringLiteral(" must exist"))); - KConfig sc1(TEST_SUBDIR + QLatin1String("kdebugrc"), KConfig::SimpleConfig); + KConfig sc1(s_test_subdir + QLatin1String("kdebugrc"), KConfig::SimpleConfig); KConfigGroup sg0(&sc1, "0"); sg0.writeEntry("AbortFatal", false); sg0.writeEntry("WarnOutput", 0); @@ -218,14 +218,14 @@ void KConfigTest::initTestCase() QVERIFY(sc1.sync()); //Setup stuff to test KConfig::addConfigSources() - KConfig devcfg(TEST_SUBDIR + QLatin1String("specificrc")); + KConfig devcfg(s_test_subdir + QLatin1String("specificrc")); KConfigGroup devonlygrp(&devcfg, "Specific Only Group"); devonlygrp.writeEntry("ExistingEntry", "DevValue"); KConfigGroup devandbasegrp(&devcfg, "Shared Group"); devandbasegrp.writeEntry("SomeSharedEntry", "DevValue"); devandbasegrp.writeEntry("SomeSpecificOnlyEntry", "DevValue"); QVERIFY(devcfg.sync()); - KConfig basecfg(TEST_SUBDIR + QLatin1String("baserc")); + KConfig basecfg(s_test_subdir + QLatin1String("baserc")); KConfigGroup basegrp(&basecfg, "Base Only Group"); basegrp.writeEntry("ExistingEntry", "BaseValue"); KConfigGroup baseanddevgrp(&basecfg, "Shared Group"); @@ -233,8 +233,8 @@ void KConfigTest::initTestCase() baseanddevgrp.writeEntry("SomeBaseOnlyEntry", "BaseValue"); QVERIFY(basecfg.sync()); - KConfig gecfg(TEST_SUBDIR + QLatin1String("groupescapetest"), KConfig::SimpleConfig); - cg = KConfigGroup(&gecfg, DOLLARGROUP); + KConfig gecfg(s_test_subdir + QLatin1String("groupescapetest"), KConfig::SimpleConfig); + cg = KConfigGroup(&gecfg, s_dollargroup); cg.writeEntry("entry", "doesntmatter"); } @@ -272,7 +272,7 @@ static QList readLinesFrom(const QString &path) return lines; } -static const QString s_defaultArg = TEST_SUBDIR + QLatin1String("kconfigtest"); +static const QString s_defaultArg = s_test_subdir + QLatin1String("kconfigtest"); static QList readLines(const QString &fileName = s_defaultArg) { const QString path = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation); @@ -283,7 +283,7 @@ static QList readLines(const QString &fileName = s_defaultArg) // see also testDefaults, which tests reverting with a defaults (global) file available void KConfigTest::testDirtyAfterRevert() { - KConfig sc(TEST_SUBDIR + QLatin1String("kconfigtest_revert")); + KConfig sc(s_test_subdir + QLatin1String("kconfigtest_revert")); KConfigGroup cg(&sc, "Hello"); cg.revertToDefault("does_not_exist"); @@ -307,19 +307,19 @@ void KConfigTest::testRevertAllEntries() // this tests the case were we revert (delete) all entries in a file, // leaving a blank file { - KConfig sc(TEST_SUBDIR + QLatin1String("konfigtest2"), KConfig::SimpleConfig); + KConfig sc(s_test_subdir + QLatin1String("konfigtest2"), KConfig::SimpleConfig); KConfigGroup cg(&sc, "Hello"); cg.writeEntry("Test", "Correct"); } { - KConfig sc(TEST_SUBDIR + QLatin1String("konfigtest2"), KConfig::SimpleConfig); + KConfig sc(s_test_subdir + QLatin1String("konfigtest2"), KConfig::SimpleConfig); KConfigGroup cg(&sc, "Hello"); QCOMPARE(cg.readEntry("Test", "Default"), QStringLiteral("Correct")); cg.revertToDefault("Test"); } - KConfig sc(TEST_SUBDIR + QLatin1String("konfigtest2"), KConfig::SimpleConfig); + KConfig sc(s_test_subdir + QLatin1String("konfigtest2"), KConfig::SimpleConfig); KConfigGroup cg(&sc, "Hello"); QCOMPARE(cg.readEntry("Test", "Default"), QStringLiteral("Default")); } @@ -330,8 +330,8 @@ void KConfigTest::testSimple() const QStringList kdeglobals = QStandardPaths::locateAll(QStandardPaths::GenericConfigLocation, QStringLiteral("kdeglobals")); QVERIFY(!kdeglobals.isEmpty()); - KConfig sc2(TEST_SUBDIR + QLatin1String{"kconfigtest"}); - QCOMPARE(sc2.name(), TEST_SUBDIR + QLatin1String{"kconfigtest"}); + KConfig sc2(s_kconfig_test_subdir); + QCOMPARE(sc2.name(), s_test_subdir + QLatin1String{"kconfigtest"}); // make sure groupList() isn't returning something it shouldn't const QStringList lstGroup = sc2.groupList(); @@ -344,7 +344,7 @@ void KConfigTest::testSimple() QVERIFY(sc3.hasKey("stringEntry1")); // from kdeglobals QVERIFY(!sc3.isEntryImmutable("stringEntry1")); - QCOMPARE(sc3.readEntry("stringEntry1"), STRINGENTRY1); + QCOMPARE(sc3.readEntry("stringEntry1"), s_string_entry1); QVERIFY(!sc3.hasKey("stringEntry2")); QCOMPARE(sc3.readEntry("stringEntry2", QStringLiteral("bla")), QStringLiteral("bla")); @@ -352,40 +352,40 @@ void KConfigTest::testSimple() QVERIFY(!sc3.hasDefault("stringEntry1")); sc3 = KConfigGroup(&sc2, "Hello"); - QCOMPARE(sc3.readEntry("Test", QByteArray()), QByteArray(UTF8BITENTRY)); - QCOMPARE(sc3.readEntry("bytearrayEntry", QByteArray()), BYTEARRAYENTRY); - QCOMPARE(sc3.readEntry(ESCAPEKEY), QString::fromLatin1(ESCAPEENTRY)); - QCOMPARE(sc3.readEntry("Test", QString{}), QString::fromUtf8(UTF8BITENTRY)); + QCOMPARE(sc3.readEntry("Test", QByteArray()), QByteArray(s_utf8bit_entry)); + QCOMPARE(sc3.readEntry("bytearrayEntry", QByteArray()), s_bytearray_entry); + QCOMPARE(sc3.readEntry(s_escapekey), QString::fromLatin1(s_escape_entry)); + QCOMPARE(sc3.readEntry("Test", QString{}), QString::fromUtf8(s_utf8bit_entry)); QCOMPARE(sc3.readEntry("emptyEntry"/*, QString("Fietsbel")*/), QLatin1String("")); QCOMPARE(sc3.readEntry("emptyEntry", QStringLiteral("Fietsbel")).isEmpty(), true); - QCOMPARE(sc3.readEntry("stringEntry1"), STRINGENTRY1); - QCOMPARE(sc3.readEntry("stringEntry2"), STRINGENTRY2); - QCOMPARE(sc3.readEntry("stringEntry3"), STRINGENTRY3); - QCOMPARE(sc3.readEntry("stringEntry4"), STRINGENTRY4); + QCOMPARE(sc3.readEntry("stringEntry1"), s_string_entry1); + QCOMPARE(sc3.readEntry("stringEntry2"), s_string_entry2); + QCOMPARE(sc3.readEntry("stringEntry3"), s_string_entry3); + QCOMPARE(sc3.readEntry("stringEntry4"), s_string_entry4); QVERIFY(!sc3.hasKey("stringEntry5")); QCOMPARE(sc3.readEntry("stringEntry5", QStringLiteral("test")), QStringLiteral("test")); QVERIFY(!sc3.hasKey("stringEntry6")); QCOMPARE(sc3.readEntry("stringEntry6", QStringLiteral("foo")), QStringLiteral("foo")); QCOMPARE(sc3.readEntry("urlEntry1", QUrl{}), QUrl(QStringLiteral("http://qt-project.org"))); - QCOMPARE(sc3.readEntry("boolEntry1", BOOLENTRY1), BOOLENTRY1); - QCOMPARE(sc3.readEntry("boolEntry2", false), BOOLENTRY2); - QCOMPARE(sc3.readEntry("keywith=equalsign", QStringLiteral("wrong")), STRINGENTRY1); - QCOMPARE(sc3.readEntry("byteArrayEntry1", QByteArray{}), STRINGENTRY1.toLatin1()); - QCOMPARE(sc3.readEntry("doubleEntry1", 0.0), DOUBLEENTRY); - QCOMPARE(sc3.readEntry("floatEntry1", 0.0f), FLOATENTRY); + QCOMPARE(sc3.readEntry("boolEntry1", s_bool_entry1), s_bool_entry1); + QCOMPARE(sc3.readEntry("boolEntry2", false), s_bool_entry2); + QCOMPARE(sc3.readEntry("keywith=equalsign", QStringLiteral("wrong")), s_string_entry1); + QCOMPARE(sc3.readEntry("byteArrayEntry1", QByteArray{}), s_string_entry1.toLatin1()); + QCOMPARE(sc3.readEntry("doubleEntry1", 0.0), s_double_entry); + QCOMPARE(sc3.readEntry("floatEntry1", 0.0f), s_float_entry); } void KConfigTest::testDefaults() { - KConfig config(TEST_SUBDIR + QLatin1String("defaulttest"), KConfig::NoGlobals); - const QString defaultsFile = TEST_SUBDIR + QLatin1String("defaulttest.defaults"); + KConfig config(s_test_subdir + QLatin1String("defaulttest"), KConfig::NoGlobals); + const QString defaultsFile = s_test_subdir + QLatin1String("defaulttest.defaults"); KConfig defaults(defaultsFile, KConfig::SimpleConfig); const QString defaultsFilePath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1Char('/') + defaultsFile; const QString Default(QStringLiteral("Default")); const QString NotDefault(QStringLiteral("Not Default")); - const QString Value1(STRINGENTRY1); - const QString Value2(STRINGENTRY2); + const QString Value1(s_string_entry1); + const QString Value2(s_string_entry2); KConfigGroup group = defaults.group("any group"); group.writeEntry("entry1", Default); @@ -417,7 +417,7 @@ void KConfigTest::testDefaults() group.sync(); // Check that everything is OK on disk, too - KConfig reader(TEST_SUBDIR + QLatin1String("defaulttest"), KConfig::NoGlobals); + KConfig reader(s_test_subdir + QLatin1String("defaulttest"), KConfig::NoGlobals); reader.addConfigSources(QStringList{defaultsFilePath}); KConfigGroup readerGroup = reader.group("any group"); QCOMPARE(readerGroup.readEntry("entry1", QString()), Default); @@ -426,9 +426,9 @@ void KConfigTest::testDefaults() void KConfigTest::testLocale() { - KConfig config(TEST_SUBDIR + QLatin1String("kconfigtest.locales"), KConfig::SimpleConfig); - const QString Translated(TRANSLATEDSTRINGENTRY1); - const QString Untranslated(STRINGENTRY1); + KConfig config(s_test_subdir + QLatin1String("kconfigtest.locales"), KConfig::SimpleConfig); + const QString Translated(s_translated_string_entry1); + const QString Untranslated(s_string_entry1); KConfigGroup group = config.group("Hello"); group.writeEntry("stringEntry1", Untranslated); @@ -450,7 +450,7 @@ void KConfigTest::testEncoding() { const QString groupstr = QString::fromUtf8("UTF-8:\xc3\xb6l"); - const QString path = TEST_SUBDIR + QLatin1String("kconfigtestencodings"); + const QString path = s_test_subdir + QLatin1String("kconfigtestencodings"); KConfig c(path); KConfigGroup cg(&c, groupstr); cg.writeEntry("key", "value"); @@ -469,44 +469,39 @@ void KConfigTest::testEncoding() void KConfigTest::testLists() { - KConfig sc2(TEST_SUBDIR + QLatin1String("kconfigtest")); + KConfig sc2(s_kconfig_test_subdir); KConfigGroup sc3(&sc2, "List Types"); - QCOMPARE(sc3.readEntry(QStringLiteral("stringListEntry"), QStringList()), STRINGLISTENTRY); + QCOMPARE(sc3.readEntry("stringListEntry", QStringList{}), s_stringlist_entry); - QCOMPARE(sc3.readEntry(QStringLiteral("stringListEmptyEntry"), QStringList(QStringLiteral("wrong"))), STRINGLISTEMPTYENTRY); + QCOMPARE(sc3.readEntry(QStringLiteral("stringListEmptyEntry"), QStringList(QStringLiteral("wrong"))), s_stringlist_empty_entry); - QCOMPARE(sc3.readEntry(QStringLiteral("stringListJustEmptyElement"), QStringList()), - STRINGLISTJUSTEMPTYELEMENT); + QCOMPARE(sc3.readEntry(QStringLiteral("stringListJustEmptyElement"), QStringList()), s_stringlist_just_empty_element); - QCOMPARE(sc3.readEntry(QStringLiteral("stringListEmptyTrailingElement"), QStringList()), - STRINGLISTEMPTYTRAILINGELEMENT); + QCOMPARE(sc3.readEntry(QStringLiteral("stringListEmptyTrailingElement"), QStringList()), s_stringlist_empty_trailing_element); - QCOMPARE(sc3.readEntry(QStringLiteral("stringListEscapeOddEntry"), QStringList()), - STRINGLISTESCAPEODDENTRY); + QCOMPARE(sc3.readEntry(QStringLiteral("stringListEscapeOddEntry"), QStringList()), s_stringlist_escape_odd_entry); - QCOMPARE(sc3.readEntry(QStringLiteral("stringListEscapeEvenEntry"), QStringList()), - STRINGLISTESCAPEEVENENTRY); + QCOMPARE(sc3.readEntry(QStringLiteral("stringListEscapeEvenEntry"), QStringList()), s_stringlist_escape_even_entry); - QCOMPARE(sc3.readEntry(QStringLiteral("stringListEscapeCommaEntry"), QStringList()), - STRINGLISTESCAPECOMMAENTRY); + QCOMPARE(sc3.readEntry(QStringLiteral("stringListEscapeCommaEntry"), QStringList()), s_stringlist_escape_comma_entry); QCOMPARE(sc3.readEntry("listOfIntsEntry1"), QString::fromLatin1("1,2,3,4")); - QList expectedIntList = INTLISTENTRY1; + QList expectedIntList = s_int_listentry1; QVERIFY(sc3.readEntry("listOfIntsEntry1", QList()) == expectedIntList); - QCOMPARE(QVariant(sc3.readEntry("variantListEntry", VARIANTLISTENTRY)).toStringList(), QVariant(VARIANTLISTENTRY).toStringList()); + QCOMPARE(QVariant(sc3.readEntry("variantListEntry", s_variantlist_entry)).toStringList(), QVariant(s_variantlist_entry).toStringList()); - QCOMPARE(sc3.readEntry("listOfByteArraysEntry1", QList()), BYTEARRAYLISTENTRY1); + QCOMPARE(sc3.readEntry("listOfByteArraysEntry1", QList()), s_bytearray_list_entry1); } void KConfigTest::testPath() { - KConfig sc2(TEST_SUBDIR + QLatin1String("kconfigtest")); + KConfig sc2(s_kconfig_test_subdir); KConfigGroup sc3(&sc2, "Path Type"); - QCOMPARE(sc3.readPathEntry(QStringLiteral("homepath"), QString{}), HOMEPATH); - QCOMPARE(sc3.readPathEntry(QStringLiteral("homepathescape"), QString{}), HOMEPATH_ESCAPE); - QCOMPARE(sc3.entryMap().value(QStringLiteral("homepath")), HOMEPATH); + QCOMPARE(sc3.readPathEntry(QStringLiteral("homepath"), QString{}), s_homepath); + QCOMPARE(sc3.readPathEntry(QStringLiteral("homepathescape"), QString{}), s_homepath_escape); + QCOMPARE(sc3.entryMap().value(QStringLiteral("homepath")), s_homepath); qputenv("WITHSLASH", "/a/"); { @@ -528,20 +523,20 @@ void KConfigTest::testPath() << "noeol=foo" // no EOL ; } - KConfig cf2(TEST_SUBDIR + QLatin1String("pathtest")); + KConfig cf2(s_test_subdir + QLatin1String("pathtest")); KConfigGroup group = cf2.group("Test Group"); QVERIFY(group.hasKey("homePath")); - QCOMPARE(group.readPathEntry("homePath", QString{}), HOMEPATH); + QCOMPARE(group.readPathEntry("homePath", QString{}), s_homepath); QVERIFY(group.hasKey("homePath2")); - QCOMPARE(group.readPathEntry("homePath2", QString{}), QLatin1String("file://") + HOMEPATH); + QCOMPARE(group.readPathEntry("homePath2", QString{}), QLatin1String("file://") + s_homepath); QVERIFY(group.hasKey("withSlash")); QCOMPARE(group.readPathEntry("withSlash", QString{}), QStringLiteral("/a//foo")); QVERIFY(group.hasKey("withSlash2")); QCOMPARE(group.readPathEntry("withSlash2", QString{}), QStringLiteral("/a/")); QVERIFY(group.hasKey("withBraces")); - QCOMPARE(group.readPathEntry("withBraces", QString{}), QLatin1String("file://") + HOMEPATH); + QCOMPARE(group.readPathEntry("withBraces", QString{}), QLatin1String("file://") + s_homepath); QVERIFY(group.hasKey("URL")); - QCOMPARE(group.readEntry("URL", QString{}), QLatin1String("file://") + HOMEPATH); + QCOMPARE(group.readEntry("URL", QString{}), QLatin1String("file://") + s_homepath); QVERIFY(group.hasKey("hostname")); QCOMPARE(group.readEntry("hostname", QString{}), QStringLiteral("(hostname)")); // the $ got removed because empty var name QVERIFY(group.hasKey("noeol")); @@ -560,7 +555,7 @@ void KConfigTest::testPersistenceOfExpandFlagForPath() // 1st step: Open the config, add a new dummy entry and then sync the config // back to the storage. { - KConfig sc2(TEST_SUBDIR + QLatin1String("kconfigtest")); + KConfig sc2(s_kconfig_test_subdir); KConfigGroup sc3(&sc2, "Path Type"); sc3.writeEntry("dummy", "dummy"); QVERIFY(sc2.sync()); @@ -585,7 +580,7 @@ void KConfigTest::testPathQtHome() << "cacheDir[$e]=$QT_CACHE_HOME/kconfigtest\n" << "configDir[$e]=$QT_CONFIG_HOME/kconfigtest\n"; } - KConfig cf2(TEST_SUBDIR + QLatin1String("pathtest")); + KConfig cf2(s_test_subdir + QLatin1String("pathtest")); KConfigGroup group = cf2.group("Test Group"); qunsetenv("QT_DATA_HOME"); qunsetenv("QT_CACHE_HOME"); @@ -609,16 +604,16 @@ void KConfigTest::testPathQtHome() void KConfigTest::testComplex() { - KConfig sc2(TEST_SUBDIR + QLatin1String("kconfigtest")); + KConfig sc2(s_kconfig_test_subdir); KConfigGroup sc3(&sc2, "Complex Types"); - QCOMPARE(sc3.readEntry("pointEntry", QPoint()), POINTENTRY); - QCOMPARE(sc3.readEntry("sizeEntry", SIZEENTRY), SIZEENTRY); - QCOMPARE(sc3.readEntry("rectEntry", QRect(1, 2, 3, 4)), RECTENTRY); - QCOMPARE(sc3.readEntry("dateTimeEntry", QDateTime()).toString(Qt::ISODateWithMs), DATETIMEENTRY.toString(Qt::ISODateWithMs)); - QCOMPARE(sc3.readEntry("dateEntry", QDate()).toString(Qt::ISODate), DATETIMEENTRY.date().toString(Qt::ISODate)); - QCOMPARE(sc3.readEntry("dateTimeWithMSEntry", QDateTime()).toString(Qt::ISODateWithMs), DATETIMEWITHMSENTRY.toString(Qt::ISODateWithMs)); - QCOMPARE(sc3.readEntry("dateTimeEntry", QDate()), DATETIMEENTRY.date()); + QCOMPARE(sc3.readEntry("pointEntry", QPoint()), s_point_entry); + QCOMPARE(sc3.readEntry("sizeEntry", s_size_entry), s_size_entry); + QCOMPARE(sc3.readEntry("rectEntry", QRect(1, 2, 3, 4)), s_rect_entry); + QCOMPARE(sc3.readEntry("dateTimeEntry", QDateTime()).toString(Qt::ISODateWithMs), s_date_time_entry.toString(Qt::ISODateWithMs)); + QCOMPARE(sc3.readEntry("dateEntry", QDate()).toString(Qt::ISODate), s_date_time_entry.date().toString(Qt::ISODate)); + QCOMPARE(sc3.readEntry("dateTimeWithMSEntry", QDateTime()).toString(Qt::ISODateWithMs), s_date_time_with_ms_entry.toString(Qt::ISODateWithMs)); + QCOMPARE(sc3.readEntry("dateTimeEntry", QDate()), s_date_time_entry.date()); } void KConfigTest::testEnums() @@ -629,7 +624,7 @@ void KConfigTest::testEnums() #if defined(_MSC_VER) && _MSC_VER == 1600 QSKIP("Visual C++ 2010 can't compile this test"); #endif - KConfig sc(TEST_SUBDIR + QLatin1String("kconfigtest")); + KConfig sc(s_kconfig_test_subdir); KConfigGroup sc3(&sc, "Enum Types"); QCOMPARE(sc3.readEntry("enum-10"), QStringLiteral("Tens")); @@ -650,35 +645,35 @@ void KConfigTest::testEnums() void KConfigTest::testEntryMap() { - KConfig sc(TEST_SUBDIR + QLatin1String("kconfigtest")); + KConfig sc(s_kconfig_test_subdir); KConfigGroup cg(&sc, "Hello"); QMap entryMap = cg.entryMap(); qDebug() << entryMap.keys(); - QCOMPARE(entryMap.value(QStringLiteral("stringEntry1")), STRINGENTRY1); - QCOMPARE(entryMap.value(QStringLiteral("stringEntry2")), STRINGENTRY2); - QCOMPARE(entryMap.value(QStringLiteral("stringEntry3")), STRINGENTRY3); - QCOMPARE(entryMap.value(QStringLiteral("stringEntry4")), STRINGENTRY4); + QCOMPARE(entryMap.value(QStringLiteral("stringEntry1")), s_string_entry1); + QCOMPARE(entryMap.value(QStringLiteral("stringEntry2")), s_string_entry2); + QCOMPARE(entryMap.value(QStringLiteral("stringEntry3")), s_string_entry3); + QCOMPARE(entryMap.value(QStringLiteral("stringEntry4")), s_string_entry4); QVERIFY(!entryMap.contains(QStringLiteral("stringEntry5"))); QVERIFY(!entryMap.contains(QStringLiteral("stringEntry6"))); - QCOMPARE(entryMap.value(QStringLiteral("Test")), QString::fromUtf8(UTF8BITENTRY)); - QCOMPARE(entryMap.value(QStringLiteral("bytearrayEntry")), QString::fromUtf8(BYTEARRAYENTRY.constData())); + QCOMPARE(entryMap.value(QStringLiteral("Test")), QString::fromUtf8(s_utf8bit_entry)); + QCOMPARE(entryMap.value(QStringLiteral("bytearrayEntry")), QString::fromUtf8(s_bytearray_entry.constData())); QCOMPARE(entryMap.value(QStringLiteral("emptyEntry")), QString{}); QVERIFY(entryMap.contains(QStringLiteral("emptyEntry"))); - QCOMPARE(entryMap.value(QStringLiteral("boolEntry1")), BOOLENTRY1 ? QStringLiteral("true") : QStringLiteral("false")); - QCOMPARE(entryMap.value(QStringLiteral("boolEntry2")), BOOLENTRY2 ? QStringLiteral("true") : QStringLiteral("false")); - QCOMPARE(entryMap.value(QStringLiteral("keywith=equalsign")), STRINGENTRY1); - QCOMPARE(entryMap.value(QStringLiteral("byteArrayEntry1")), STRINGENTRY1); - QCOMPARE(entryMap.value(QStringLiteral("doubleEntry1")).toDouble(), DOUBLEENTRY); - QCOMPARE(entryMap.value(QStringLiteral("floatEntry1")).toFloat(), FLOATENTRY); + QCOMPARE(entryMap.value(QStringLiteral("boolEntry1")), s_bool_entry1 ? QStringLiteral("true") : QStringLiteral("false")); + QCOMPARE(entryMap.value(QStringLiteral("boolEntry2")), s_bool_entry2 ? QStringLiteral("true") : QStringLiteral("false")); + QCOMPARE(entryMap.value(QStringLiteral("keywith=equalsign")), s_string_entry1); + QCOMPARE(entryMap.value(QStringLiteral("byteArrayEntry1")), s_string_entry1); + QCOMPARE(entryMap.value(QStringLiteral("doubleEntry1")).toDouble(), s_double_entry); + QCOMPARE(entryMap.value(QStringLiteral("floatEntry1")).toFloat(), s_float_entry); } void KConfigTest::testInvalid() { - KConfig sc(TEST_SUBDIR + QLatin1String("kconfigtest")); + KConfig sc(s_kconfig_test_subdir); // all of these should print a message to the kdebug.dbg file KConfigGroup sc3(&sc, "Invalid Types"); - sc3.writeEntry("badList", VARIANTLISTENTRY2); + sc3.writeEntry("badList", s_variantlist_entry2); QList list; @@ -741,7 +736,7 @@ void KConfigTest::testInvalid() void KConfigTest::testChangeGroup() { - KConfig sc(TEST_SUBDIR + QLatin1String("kconfigtest")); + KConfig sc(s_kconfig_test_subdir); KConfigGroup sc3(&sc, "Hello"); QCOMPARE(sc3.name(), QStringLiteral("Hello")); KConfigGroup newGroup(sc3); @@ -771,7 +766,7 @@ void KConfigTest::testChangeGroup() // Simple test for deleteEntry void KConfigTest::testDeleteEntry() { - const QString configFile = TEST_SUBDIR + QLatin1String("kconfigdeletetest"); + const QString configFile = s_test_subdir + QLatin1String("kconfigdeletetest"); { KConfig conf(configFile); @@ -794,7 +789,7 @@ void KConfigTest::testDeleteEntry() void KConfigTest::testDelete() { - KConfig sc(TEST_SUBDIR + QLatin1String("kconfigtest")); + KConfig sc(s_kconfig_test_subdir); KConfigGroup ct(&sc, "Complex Types"); @@ -839,7 +834,7 @@ void KConfigTest::testDelete() QVERIFY(lines.contains("[Hello]\n")); // a group that was not deleted // test for entries that are marked as deleted when there is no default - KConfig cf(TEST_SUBDIR + QLatin1String("kconfigtest"), KConfig::SimpleConfig); // make sure there are no defaults + KConfig cf(s_kconfig_test_subdir, KConfig::SimpleConfig); // make sure there are no defaults cg = cf.group("Portable Devices"); cg.writeEntry("devices|manual|(null)", "whatever"); cg.writeEntry("devices|manual|/mnt/ipod", "/mnt/ipod"); @@ -862,7 +857,7 @@ void KConfigTest::testDelete() void KConfigTest::testDefaultGroup() { - KConfig sc(TEST_SUBDIR + QLatin1String("kconfigtest")); + KConfig sc(s_kconfig_test_subdir); KConfigGroup defaultGroup(&sc, ""); QCOMPARE(defaultGroup.name(), QStringLiteral("")); QVERIFY(!defaultGroup.exists()); @@ -873,7 +868,7 @@ void KConfigTest::testDefaultGroup() { // Test reading it - KConfig sc2(TEST_SUBDIR + QLatin1String("kconfigtest")); + KConfig sc2(s_kconfig_test_subdir); KConfigGroup defaultGroup2(&sc2, ""); QCOMPARE(defaultGroup2.name(), QStringLiteral("")); QVERIFY(defaultGroup2.exists()); @@ -881,7 +876,7 @@ void KConfigTest::testDefaultGroup() } { // Test reading it - KConfig sc2(TEST_SUBDIR + QLatin1String("kconfigtest")); + KConfig sc2(s_kconfig_test_subdir); KConfigGroup emptyGroup(&sc2, ""); QCOMPARE(emptyGroup.name(), QStringLiteral("")); QVERIFY(emptyGroup.exists()); @@ -909,7 +904,7 @@ void KConfigTest::testDefaultGroup() void KConfigTest::testEmptyGroup() { - KConfig sc(TEST_SUBDIR + QLatin1String("kconfigtest")); + KConfig sc(s_kconfig_test_subdir); KConfigGroup emptyGroup(&sc, ""); QCOMPARE(emptyGroup.name(), QStringLiteral("")); // confusing, heh? QVERIFY(!emptyGroup.exists()); @@ -920,7 +915,7 @@ void KConfigTest::testEmptyGroup() { // Test reading it - KConfig sc2(TEST_SUBDIR + QLatin1String("kconfigtest")); + KConfig sc2(s_kconfig_test_subdir); KConfigGroup defaultGroup(&sc2, ""); QCOMPARE(defaultGroup.name(), QStringLiteral("")); QVERIFY(defaultGroup.exists()); @@ -928,7 +923,7 @@ void KConfigTest::testEmptyGroup() } { // Test reading it - KConfig sc2(TEST_SUBDIR + QLatin1String("kconfigtest")); + KConfig sc2(s_kconfig_test_subdir); KConfigGroup emptyGroup2(&sc2, ""); QCOMPARE(emptyGroup2.name(), QStringLiteral("")); QVERIFY(emptyGroup2.exists()); @@ -965,7 +960,7 @@ void KConfigTest::testCascadingWithLocale() QTemporaryDir globalDir; qputenv("XDG_CONFIG_DIRS", qPrintable(middleDir.path() + QLatin1Char(':') + globalDir.path())); - const QString globalConfigDir = globalDir.path() + QLatin1Char('/') + TEST_SUBDIR; + const QString globalConfigDir = globalDir.path() + QLatin1Char('/') + s_test_subdir; QVERIFY(QDir().mkpath(globalConfigDir)); QFile global(globalConfigDir + QLatin1String("foo.desktop")); QVERIFY(global.open(QIODevice::WriteOnly | QIODevice::Text)); @@ -979,7 +974,7 @@ void KConfigTest::testCascadingWithLocale() << "Other[fr]=Global_FR\n"; global.close(); - const QString middleConfigDir = middleDir.path() + QLatin1Char('/') + TEST_SUBDIR; + const QString middleConfigDir = middleDir.path() + QLatin1Char('/') + s_test_subdir; QVERIFY(QDir().mkpath(middleConfigDir)); QFile local(middleConfigDir + QLatin1String("foo.desktop")); QVERIFY(local.open(QIODevice::WriteOnly | QIODevice::Text)); @@ -992,7 +987,7 @@ void KConfigTest::testCascadingWithLocale() << "Other=English Only\n"; local.close(); - KConfig config(TEST_SUBDIR + QLatin1String("foo.desktop")); + KConfig config(s_test_subdir + QLatin1String("foo.desktop")); KConfigGroup group = config.group("Group"); QCOMPARE(group.readEntry("FromGlobal"), QStringLiteral("true")); QCOMPARE(group.readEntry("FromLocal"), QStringLiteral("true")); @@ -1009,7 +1004,7 @@ void KConfigTest::testMerge() { DefaultLocale defaultLocale; QLocale::setDefault(QLocale::c()); - KConfig config(TEST_SUBDIR + QLatin1String("mergetest"), KConfig::SimpleConfig); + KConfig config(s_test_subdir + QLatin1String("mergetest"), KConfig::SimpleConfig); KConfigGroup cg = config.group("some group"); cg.writeEntry("entry", " random entry"); @@ -1069,7 +1064,7 @@ void KConfigTest::testImmutable() << "[group][subgroup][$i]\n"; } - KConfig config(TEST_SUBDIR + QLatin1String("immutabletest"), KConfig::SimpleConfig); + KConfig config(s_test_subdir + QLatin1String("immutabletest"), KConfig::SimpleConfig); QVERIFY(config.isGroupImmutable(QByteArray())); KConfigGroup cg = config.group(QByteArray()); QVERIFY(cg.isEntryImmutable("entry1")); @@ -1094,7 +1089,7 @@ void KConfigTest::testOptionOrder() << "entry2=unlocalized\n" << "entry2[$i][de_DE]=t2\n"; } - KConfig config(TEST_SUBDIR + QLatin1String("doubleattrtest"), KConfig::SimpleConfig); + KConfig config(s_test_subdir + QLatin1String("doubleattrtest"), KConfig::SimpleConfig); config.setLocale(QStringLiteral("de_DE")); KConfigGroup cg3 = config.group("group3"); QVERIFY(!cg3.isImmutable()); @@ -1123,13 +1118,13 @@ void KConfigTest::testOptionOrder() void KConfigTest::testGroupEscape() { - KConfig config(TEST_SUBDIR + QLatin1String("groupescapetest"), KConfig::SimpleConfig); - QVERIFY(config.group(DOLLARGROUP).exists()); + KConfig config(s_test_subdir + QLatin1String("groupescapetest"), KConfig::SimpleConfig); + QVERIFY(config.group(s_dollargroup).exists()); } void KConfigTest::testSubGroup() { - KConfig sc(TEST_SUBDIR + QLatin1String("kconfigtest")); + KConfig sc(s_kconfig_test_subdir); KConfigGroup cg(&sc, "ParentGroup"); QCOMPARE(cg.readEntry("parentgrpstring", ""), QStringLiteral("somevalue")); KConfigGroup subcg1(&cg, "SubGroup1"); @@ -1215,7 +1210,7 @@ void KConfigTest::testSubGroup() void KConfigTest::testAddConfigSources() { - KConfig cf(TEST_SUBDIR + QLatin1String("specificrc")); + KConfig cf(s_test_subdir + QLatin1String("specificrc")); cf.addConfigSources(QStringList{m_testConfigDir + QLatin1String("/baserc")}); cf.reparseConfiguration(); @@ -1237,7 +1232,7 @@ void KConfigTest::testAddConfigSources() QVERIFY(cf.sync()); - KConfig plaincfg(TEST_SUBDIR + QLatin1String("specificrc")); + KConfig plaincfg(s_test_subdir + QLatin1String("specificrc")); KConfigGroup newgrp2(&plaincfg, "New Group"); QCOMPARE(newgrp2.readEntry("New Entry", ""), QStringLiteral("SomeValue")); @@ -1248,14 +1243,14 @@ void KConfigTest::testAddConfigSources() void KConfigTest::testGroupCopyTo() { - KConfig cf1(TEST_SUBDIR + QLatin1String("kconfigtest")); + KConfig cf1(s_kconfig_test_subdir); KConfigGroup original = cf1.group("Enum Types"); KConfigGroup copy = cf1.group("Enum Types Copy"); original.copyTo(©); // copy from one group to another QCOMPARE(copy.entryMap(), original.entryMap()); - KConfig cf2(TEST_SUBDIR + QLatin1String("copy_of_kconfigtest"), KConfig::SimpleConfig); + KConfig cf2(s_test_subdir + QLatin1String("copy_of_kconfigtest"), KConfig::SimpleConfig); QVERIFY(!cf2.hasGroup(original.name())); QVERIFY(!cf2.hasGroup(copy.name())); @@ -1268,7 +1263,7 @@ void KConfigTest::testGroupCopyTo() void KConfigTest::testConfigCopyToSync() { - KConfig cf1(TEST_SUBDIR + QLatin1String("kconfigtest")); + KConfig cf1(s_kconfig_test_subdir); // Prepare source file KConfigGroup group(&cf1, "CopyToTest"); group.writeEntry("Type", "Test"); @@ -1278,7 +1273,7 @@ void KConfigTest::testConfigCopyToSync() const QString destination = m_testConfigDir + QLatin1String("/kconfigcopytotest"); QFile::remove(destination); - KConfig cf2(TEST_SUBDIR + QLatin1String("kconfigcopytotest")); + KConfig cf2(s_test_subdir + QLatin1String("kconfigcopytotest")); KConfigGroup group2(&cf2, "CopyToTest"); group.copyTo(&group2); @@ -1292,7 +1287,7 @@ void KConfigTest::testConfigCopyToSync() void KConfigTest::testConfigCopyTo() { - KConfig cf1(TEST_SUBDIR + QLatin1String("kconfigtest")); + KConfig cf1(s_kconfig_test_subdir); { // Prepare source file KConfigGroup group(&cf1, "CopyToTest"); @@ -1314,7 +1309,7 @@ void KConfigTest::testConfigCopyTo() } // Check copied config file on disk - KConfig cf3(TEST_SUBDIR + QLatin1String("kconfigcopytotest")); + KConfig cf3(s_test_subdir + QLatin1String("kconfigcopytotest")); KConfigGroup group3(&cf3, "CopyToTest"); QString testVal = group3.readEntry("Type"); QCOMPARE(testVal, QStringLiteral("Test")); @@ -1322,7 +1317,7 @@ void KConfigTest::testConfigCopyTo() void KConfigTest::testReparent() { - KConfig cf(TEST_SUBDIR + QLatin1String("kconfigtest")); + KConfig cf(s_kconfig_test_subdir); const QString name(QStringLiteral("Enum Types")); KConfigGroup group = cf.group(name); const QMap originalMap = group.entryMap(); @@ -1357,7 +1352,7 @@ static void ageTimeStamp(const QString &path, int nsec) void KConfigTest::testWriteOnSync() { QDateTime oldStamp, newStamp; - KConfig sc(TEST_SUBDIR + QLatin1String("kconfigtest"), KConfig::IncludeGlobals); + KConfig sc(s_kconfig_test_subdir, KConfig::IncludeGlobals); // Age the timestamp of global config file a few sec, and collect it. QString globFile = m_kdeGlobalsPath; @@ -1393,7 +1388,7 @@ void KConfigTest::testWriteOnSync() void KConfigTest::testFailOnReadOnlyFileSync() { - KConfig sc(TEST_SUBDIR + QLatin1String("kconfigfailonreadonlytest")); + KConfig sc(s_test_subdir + QLatin1String("kconfigfailonreadonlytest")); KConfigGroup cgLocal(&sc, "Locals"); cgLocal.writeEntry("someLocalString", "whatever"); @@ -1417,7 +1412,7 @@ void KConfigTest::testFailOnReadOnlyFileSync() void KConfigTest::testDirtyOnEqual() { QDateTime oldStamp, newStamp; - KConfig sc(TEST_SUBDIR + QLatin1String("kconfigtest")); + KConfig sc(s_kconfig_test_subdir); // Initialize value KConfigGroup cgLocal(&sc, "random"); @@ -1445,7 +1440,7 @@ void KConfigTest::testDirtyOnEqualOverdo() QByteArray val2("\0""two", 4); QByteArray defvalr; - KConfig sc(TEST_SUBDIR + QLatin1String("kconfigtest")); + KConfig sc(s_kconfig_test_subdir); KConfigGroup cgLocal(&sc, "random"); cgLocal.writeEntry("someKey", val1); QCOMPARE(cgLocal.readEntry("someKey", defvalr), val1); @@ -1477,7 +1472,7 @@ void KConfigTest::testSyncOnExit() // Often, the KGlobalPrivate global static's destructor ends up calling ~KConfig -> // KConfig::sync ... and if that code triggers KGlobal code again then things could crash. // So here's a test for modifying KSharedConfig::openConfig() and not syncing, the process exit will sync. - KConfigGroup grp(KSharedConfig::openConfig(TEST_SUBDIR + QLatin1String("syncOnExitRc")), "syncOnExit"); + KConfigGroup grp(KSharedConfig::openConfig(s_test_subdir + QLatin1String("syncOnExitRc")), "syncOnExit"); grp.writeEntry("key", "value"); } @@ -1486,10 +1481,10 @@ void KConfigTest::testSharedConfig() // Can I use a KConfigGroup even after the KSharedConfigPtr goes out of scope? KConfigGroup myConfigGroup; { - KSharedConfigPtr config = KSharedConfig::openConfig(TEST_SUBDIR + QLatin1String("kconfigtest")); + KSharedConfigPtr config = KSharedConfig::openConfig(s_kconfig_test_subdir); myConfigGroup = KConfigGroup(config, "Hello"); } - QCOMPARE(myConfigGroup.readEntry("stringEntry1"), STRINGENTRY1); + QCOMPARE(myConfigGroup.readEntry("stringEntry1"), s_string_entry1); // Get the main config KSharedConfigPtr mainConfig = KSharedConfig::openConfig(); @@ -1876,18 +1871,18 @@ void KConfigTest::testThreads() void KConfigTest::testNotify() { #if !KCONFIG_USE_DBUS - QSKIP("KConfig notification requires DBus"); + QSKIP("KConfig notification requires DBus"); #endif - KConfig config(TEST_SUBDIR + QLatin1String("kconfigtest")); + KConfig config(s_kconfig_test_subdir); auto myConfigGroup = KConfigGroup(&config, "TopLevelGroup"); //mimics a config in another process, which is watching for events - auto remoteConfig = KSharedConfig::openConfig(TEST_SUBDIR + QLatin1String("kconfigtest")); + auto remoteConfig = KSharedConfig::openConfig(s_kconfig_test_subdir); KConfigWatcher::Ptr watcher = KConfigWatcher::create(remoteConfig); //some random config that shouldn't be changing when kconfigtest changes, only on kdeglobals - auto otherRemoteConfig = KSharedConfig::openConfig(TEST_SUBDIR + QLatin1String("kconfigtest2")); + auto otherRemoteConfig = KSharedConfig::openConfig(s_test_subdir + QLatin1String("kconfigtest2")); KConfigWatcher::Ptr otherWatcher = KConfigWatcher::create(otherRemoteConfig); QSignalSpy watcherSpy(watcher.data(), &KConfigWatcher::configChanged); @@ -1963,7 +1958,7 @@ void KConfigTest::testKdeglobalsVsDefault() generalGlob.writeEntry("testRestore", "global"); QVERIFY(glob.sync()); - KConfig local(TEST_SUBDIR + QLatin1String("restorerc")); + KConfig local(s_test_subdir + QLatin1String("restorerc")); KConfigGroup generalLocal(&local, "General"); // Check if we get global and not the default value from cpp (defaultcpp) when reading data from restorerc QCOMPARE(generalLocal.readEntry("testRestore", "defaultcpp"), QStringLiteral("global")); diff --git a/autotests/kentrymaptest.cpp b/autotests/kentrymaptest.cpp index 406e4e99..d571f761 100644 --- a/autotests/kentrymaptest.cpp +++ b/autotests/kentrymaptest.cpp @@ -8,11 +8,13 @@ #include -const QByteArray group1("A Group"); -const QByteArray key1("A Key"); -const QByteArray key2("Another Key"); -const QByteArray value1("A value"); -const QByteArray value2("A different value"); +// clazy:excludeall=non-pod-global-static + +static const QByteArray group1{"A Group"}; +static const QByteArray key1{"A Key"}; +static const QByteArray key2{"Another Key"}; +static const QByteArray value1{"A value"}; +static const QByteArray value2{"A different value"}; QTEST_MAIN(KEntryMapTest) diff --git a/src/core/kauthorized.cpp b/src/core/kauthorized.cpp index 3a06c887..1abd83eb 100644 --- a/src/core/kauthorized.cpp +++ b/src/core/kauthorized.cpp @@ -300,13 +300,13 @@ KCONFIGCORE_EXPORT void loadUrlActionRestrictions(const KConfigGroup &cg) continue; } const QByteArray action = rule[0].toLatin1(); - QString refProt = rule[1]; - QString refHost = rule[2]; + const QString refProt = rule[1]; + const QString refHost = rule[2]; QString refPath = rule[3]; - QString urlProt = rule[4]; - QString urlHost = rule[5]; + const QString urlProt = rule[4]; + const QString urlHost = rule[5]; QString urlPath = rule[6]; - bool bEnabled = (rule[7].toLower() == QLatin1String("true")); + const bool bEnabled = (rule[7].toLower() == QLatin1String("true")); if (refPath.startsWith(QLatin1String("$HOME"))) { refPath.replace(0, 5, QDir::homePath()); diff --git a/src/gui/kconfigloader.cpp b/src/gui/kconfigloader.cpp index 18ec3d9f..538a38ff 100644 --- a/src/gui/kconfigloader.cpp +++ b/src/gui/kconfigloader.cpp @@ -278,7 +278,7 @@ void ConfigLoaderHandler::addItem() */ } else if (m_type == QLatin1String("point")) { QPoint defaultPoint; - QStringList tmpList = m_default.split(QLatin1Char(',')); + const QStringList tmpList = m_default.split(QLatin1Char(',')); if (tmpList.size() >= 2) { defaultPoint.setX(tmpList[0].toInt()); defaultPoint.setY(tmpList[1].toInt()); @@ -286,7 +286,7 @@ void ConfigLoaderHandler::addItem() item = m_config->addItemPoint(m_name, *d->newPoint(), defaultPoint, m_key); } else if (m_type == QLatin1String("rect")) { QRect defaultRect; - QStringList tmpList = m_default.split(QLatin1Char(',')); + const QStringList tmpList = m_default.split(QLatin1Char(',')); if (tmpList.size() >= 4) { defaultRect.setCoords(tmpList[0].toInt(), tmpList[1].toInt(), tmpList[2].toInt(), tmpList[3].toInt()); @@ -294,7 +294,7 @@ void ConfigLoaderHandler::addItem() item = m_config->addItemRect(m_name, *d->newRect(), defaultRect, m_key); } else if (m_type == QLatin1String("size")) { QSize defaultSize; - QStringList tmpList = m_default.split(QLatin1Char(',')); + const QStringList tmpList = m_default.split(QLatin1Char(',')); if (tmpList.size() >= 2) { defaultSize.setWidth(tmpList[0].toInt()); defaultSize.setHeight(tmpList[1].toInt()); diff --git a/src/kconfig_compiler/kconfig_compiler.cpp b/src/kconfig_compiler/kconfig_compiler.cpp index e358f665..dd7b793c 100644 --- a/src/kconfig_compiler/kconfig_compiler.cpp +++ b/src/kconfig_compiler/kconfig_compiler.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include "../../kconfig_version.h" #include "KConfigParameters.h" @@ -37,10 +38,10 @@ QString varName(const QString &n, const KConfigParameters &cfg) QString result; if (!cfg.dpointer) { result = QChar::fromLatin1('m') + n; - result[1] = result[1].toUpper(); + result[1] = result.at(1).toUpper(); } else { result = n; - result[0] = result[0].toLower(); + result[0] = result.at(0).toLower(); } return result; } @@ -59,7 +60,7 @@ QString varPath(const QString &n, const KConfigParameters &cfg) QString enumName(const QString &n) { QString result = QLatin1String("Enum") + n; - result[4] = result[4].toUpper(); + result[4] = result.at(4).toUpper(); return result; } @@ -68,7 +69,7 @@ QString enumName(const QString &n, const CfgEntry::Choices &c) QString result = c.name(); if (result.isEmpty()) { result = QLatin1String("Enum") + n; - result[4] = result[4].toUpper(); + result[4] = result.at(4).toUpper(); } return result; } @@ -81,7 +82,7 @@ QString enumType(const CfgEntry *e, bool globalEnums) if (!globalEnums) { result += QLatin1String("::type"); } - result[4] = result[4].toUpper(); + result[4] = result.at(4).toUpper(); } return result; } @@ -91,7 +92,7 @@ QString enumTypeQualifier(const QString &n, const CfgEntry::Choices &c) QString result = c.name(); if (result.isEmpty()) { result = QLatin1String("Enum") + n + QLatin1String("::"); - result[4] = result[4].toUpper(); + result[4] = result.at(4).toUpper(); } else if (c.external()) { result = c.externalQualifier(); } else { @@ -103,7 +104,7 @@ QString enumTypeQualifier(const QString &n, const CfgEntry::Choices &c) QString setFunction(const QString &n, const QString &className) { QString result = QLatin1String("set") + n; - result[3] = result[3].toUpper(); + result[3] = result.at(3).toUpper(); if (!className.isEmpty()) { result = className + QLatin1String("::") + result; @@ -119,7 +120,7 @@ QString changeSignalName(const QString &n) QString getDefaultFunction(const QString &n, const QString &className) { QString result = QLatin1String("default") + n + QLatin1String("Value"); - result[7] = result[7].toUpper(); + result[7] = result.at(7).toUpper(); if (!className.isEmpty()) { result = className + QLatin1String("::") + result; @@ -130,7 +131,7 @@ QString getDefaultFunction(const QString &n, const QString &className) QString getFunction(const QString &n, const QString &className) { QString result = n; - result[0] = result[0].toLower(); + result[0] = result.at(0).toLower(); if (!className.isEmpty()) { result = className + QLatin1String("::") + result; @@ -141,7 +142,7 @@ QString getFunction(const QString &n, const QString &className) QString immutableFunction(const QString &n, const QString &className) { QString result = QLatin1String("is") + n; - result[2] = result[2].toUpper(); + result[2] = result.at(2).toUpper(); result += QLatin1String{"Immutable"}; if (!className.isEmpty()) { @@ -170,18 +171,14 @@ static QString quoteString(const QString &s) return QLatin1Char('\"') + r + QLatin1Char('\"'); } -QString literalString(const QString &s) +QString literalString(const QString &str) { - bool isAscii = true; - for (int i = s.length(); i--;) - if (s[i].unicode() > 127) { - isAscii = false; - } + const bool isAscii = std::none_of(str.cbegin(), str.cend(), [](const QChar ch) { return ch.unicode() > 127; }); if (isAscii) { - return QLatin1String("QStringLiteral( ") + quoteString(s) + QLatin1String(" )"); + return QLatin1String{"QStringLiteral( "} + quoteString(str) + QLatin1String{" )"}; } else { - return QLatin1String("QString::fromUtf8( ") + quoteString(s) + QLatin1String(" )"); + return QLatin1String{"QString::fromUtf8( "} + quoteString(str) + QLatin1String{" )"}; } } @@ -189,21 +186,14 @@ QString signalEnumName(const QString &signalName) { QString result; result = QLatin1String("signal") + signalName; - result[6] = result[6].toUpper(); + result[6] = result.at(6).toUpper(); return result; } - bool isUnsigned(const QString &type) { - if (type == QLatin1String("UInt")) { - return true; - } - if (type == QLatin1String("ULongLong")) { - return true; - } - return false; + return type == QLatin1String("UInt") || type == QLatin1String("ULongLong"); } /** @@ -411,14 +401,14 @@ QString itemVar(const CfgEntry *e, const KConfigParameters &cfg) if (cfg.itemAccessors) { if (!cfg.dpointer) { result = QLatin1Char{'m'} + e->name + QLatin1String{"Item"}; - result[1] = result[1].toUpper(); + result[1] = result.at(1).toUpper(); } else { result = e->name + QLatin1String{"Item"}; - result[0] = result[0].toLower(); + result[0] = result.at(0).toLower(); } } else { result = QLatin1String{"item"} + e->name; - result[4] = result[4].toUpper(); + result[4] = result.at(4).toUpper(); } return result; } @@ -430,22 +420,16 @@ QString innerItemVar(const CfgEntry *e, const KConfigParameters &cfg) { if (e->signalList.isEmpty()) { return itemPath(e, cfg); - } else { - QString result = QLatin1String{"innerItem"} + e->name; - result[9] = result[9].toUpper(); - return result; } + + QString result = QLatin1String{"innerItem"} + e->name; + result[9] = result.at(9).toUpper(); + return result; } QString itemPath(const CfgEntry *e, const KConfigParameters &cfg) { - QString result; - if (cfg.dpointer) { - result = QLatin1String{"d->"} + itemVar(e, cfg); - } else { - result = itemVar(e, cfg); - } - return result; + return cfg.dpointer ? QLatin1String{"d->"} + itemVar(e, cfg) : itemVar(e, cfg); } QString newInnerItem(const CfgEntry *entry, const QString &key, const QString &defaultValue, const KConfigParameters &cfg, const QString ¶m) @@ -464,25 +448,27 @@ QString newInnerItem(const CfgEntry *entry, const QString &key, const QString &d return t; } -QString newItem(const CfgEntry *entry, const QString &key, const QString &defaultValue, - const KConfigParameters &cfg, const QString ¶m) { +QString newItem(const CfgEntry *entry, const QString &key, const QString &defaultValue, const KConfigParameters &cfg, const QString ¶m) +{ + const QList sigs = entry->signalList; + if (sigs.isEmpty()) { + return newInnerItem(entry, key, defaultValue, cfg, param); + } - QList sigs = entry->signalList; - QString t; - if (!sigs.isEmpty()) { - t += QLatin1String("new KConfigCompilerSignallingItem(") + innerItemVar(entry, cfg) + param; - t += QLatin1String(", this, notifyFunction, "); - //append the signal flags - for (int i = 0; i < sigs.size(); ++i) { - if (i != 0) - t += QLatin1String(" | "); - t += signalEnumName(sigs[i].name); + QString str; + str += QLatin1String("new KConfigCompilerSignallingItem(") + innerItemVar(entry, cfg) + param; + str += QLatin1String(", this, notifyFunction, "); + // Append the signal flags + const int listSize = sigs.size(); + for (int i = 0; i < listSize; ++i) { + if (i != 0) { + str += QLatin1String(" | "); } - t += QLatin1String(");"); - } else { - t += newInnerItem(entry, key, defaultValue, cfg, param); + str += signalEnumName(sigs[i].name); } - return t; + str += QLatin1String(");"); + + return str; } QString paramString(const QString &s, const CfgEntry *e, int i) @@ -502,14 +488,18 @@ QString paramString(const QString &group, const QList ¶meters) QString paramString = group; QString arguments; int i = 1; - for (QList::ConstIterator it = parameters.constBegin(); - it != parameters.constEnd(); ++it) { - if (paramString.contains(QLatin1String{"$("} + (*it).name + QLatin1Char{')'})) { + for (const auto ¶m : parameters) { + const QString paramName = param.name; + const QString str = QLatin1String{"$("} + paramName + QLatin1Char{')'}; + if (paramString.contains(str)) { const QString tmp = QStringLiteral("%%1").arg(i++); - paramString.replace(QLatin1String{"$("} + (*it).name + QLatin1Char{')'}, tmp); - arguments += QLatin1String{".arg( mParam"} + (*it).name + QLatin1String{" )"}; + paramString.replace(str, tmp); + // TODO: change the code here to get C++ code generated by KConfig to use + // QString::arg(QString, QString, QString) instead of QString().arg().arg() + arguments += QLatin1String{".arg( mParam"} + paramName + QLatin1String{" )"}; } } + if (arguments.isEmpty()) { return QLatin1String{"QStringLiteral( \""} + group + QLatin1String{"\" )"}; } @@ -653,7 +643,7 @@ QString indent(QString text, int spaces) while (!in.atEnd()) { currLine = in.readLine(); if (!currLine.isEmpty()) - for (int i = 0; i < spaces; i++) { + for (int i = 0; i < spaces; ++i) { out << " "; } out << currLine << '\n'; @@ -783,7 +773,7 @@ int main(int argc, char **argv) } // remove '.kcfg' from the name. - const QString baseName = inputFilename.mid(0, inputFilename.size()-5); + const QString baseName = inputFilename.mid(0, inputFilename.size() - 5); KConfigHeaderGenerator headerGenerator(baseName, baseDir, cfg, parseResult); headerGenerator.start(); headerGenerator.save(); From 65e5f9f01078ec993648da3a132f60c7f07ff27d Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Sat, 6 Feb 2021 22:49:41 +0200 Subject: [PATCH 109/259] Fix windows build on the CI I didn't consider the '#ifdef Q_OS_WIN' code paths (since that compiles just fine locally). GIT_SILENT --- autotests/kconfig_compiler/kconfigcompiler_test.cpp | 2 +- autotests/kconfigtest.cpp | 2 +- autotests/test_kconf_update.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/autotests/kconfig_compiler/kconfigcompiler_test.cpp b/autotests/kconfig_compiler/kconfigcompiler_test.cpp index 014bc0f3..4467a211 100644 --- a/autotests/kconfig_compiler/kconfigcompiler_test.cpp +++ b/autotests/kconfig_compiler/kconfigcompiler_test.cpp @@ -143,7 +143,7 @@ void KConfigCompiler_Test::testRunning() QFETCH(QString, testName); #ifdef Q_OS_WIN - testName += QStringLiteral(".exe"); + testName += QLatin1String{".exe"}; #endif QString program = QFINDTESTDATA(testName); diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index 0619f97f..2417d56e 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -1786,7 +1786,7 @@ void KConfigTest::testQStringUtf8() QVERIFY(readFile.open(QFile::ReadOnly)); QByteArray fileBytes = readFile.readAll(); #ifdef Q_OS_WIN - fileBytes.replace("\r\n", "\n"); + fileBytes.replace(QLatin1String{"\r\n"}, QLatin1String{"\n"}); #endif QCOMPARE(fileBytes, QByteArrayLiteral("[General]\nkey=") + serialized + QByteArrayLiteral("\n")); diff --git a/autotests/test_kconf_update.cpp b/autotests/test_kconf_update.cpp index 88ba385f..f08e06ca 100644 --- a/autotests/test_kconf_update.cpp +++ b/autotests/test_kconf_update.cpp @@ -47,7 +47,7 @@ static QString readFile(const QString &path) QString ret = QString::fromUtf8(file.readAll()); #ifdef Q_OS_WIN // KConfig always writes files with the native line ending, the test comparison uses \n - ret.replace("\r\n", "\n"); + ret.replace(QLatin1String{"\r\n"}, QLatin1String{"\n"}); #endif return ret; } From 073f3cb9f414fa91b21057e808eed6c34319e922 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Sat, 6 Feb 2021 23:02:20 +0200 Subject: [PATCH 110/259] Fix build on windows on the CI, again It's a QByteArray not a QString. GIT_SILENT --- autotests/kconfigtest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index 2417d56e..be84efec 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -1786,7 +1786,7 @@ void KConfigTest::testQStringUtf8() QVERIFY(readFile.open(QFile::ReadOnly)); QByteArray fileBytes = readFile.readAll(); #ifdef Q_OS_WIN - fileBytes.replace(QLatin1String{"\r\n"}, QLatin1String{"\n"}); + fileBytes.replace(QByteArrayLiteral("\r\n"), QByteArrayLiteral("\n")); #endif QCOMPARE(fileBytes, QByteArrayLiteral("[General]\nkey=") + serialized + QByteArrayLiteral("\n")); From 97accd14d732f3eda1c25bb58290cb9311040798 Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Mon, 8 Feb 2021 11:53:28 -0700 Subject: [PATCH 111/259] Fix window positioning regression due to incorrect fallback in fallback We have a fallback string that gets searched for in the KCM, but that fallback itself should not have a fallback, or else we always use that second fallback and the window gets positioned incorrectly the first time it's opened. So let's replace the second fallback with -1. BUG: 432661 FIXED-IN: 5.79 --- src/gui/kwindowconfig.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/kwindowconfig.cpp b/src/gui/kwindowconfig.cpp index 7a47b17a..4f3ac73a 100644 --- a/src/gui/kwindowconfig.cpp +++ b/src/gui/kwindowconfig.cpp @@ -168,8 +168,8 @@ void KWindowConfig::restoreWindowPosition(QWindow *window, const KConfigGroup &c // per-resolution information is not // TODO: Remove in KF6 or maybe even KF5.85 or something. It really only needs // to be here to transition existing users once they upgrade from 5.78 -> 5.79 - const int fallbackXPosition = config.readEntry(QStringLiteral("%1 XPosition %2").arg(allConnectedScreens()).arg(desk.width()), window->size().width()); - const int fallbackYPosition = config.readEntry(QStringLiteral("%1 YPosition %2").arg(allConnectedScreens()).arg(desk.height()), window->size().height()); + const int fallbackXPosition = config.readEntry(QStringLiteral("%1 XPosition %2").arg(allConnectedScreens()).arg(desk.width()), -1); + const int fallbackYPosition = config.readEntry(QStringLiteral("%1 YPosition %2").arg(allConnectedScreens()).arg(desk.height()), -1); const int xPos = config.readEntry(windowXPositionString(desk), fallbackXPosition); const int yPos = config.readEntry(windowYPositionString(desk), fallbackYPosition); From 4af0de0506e41784235fec21173dec88e8ccf668 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Thu, 11 Feb 2021 14:09:37 +0200 Subject: [PATCH 112/259] Add compile_commands.json to .gitignore See https://invent.kde.org/sdk/kdesrc-build/-/merge_requests/82 GIT_SILENT --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 75e91077..6e9efad9 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ CMakeLists.txt.user* *.unc-backup* .cmake/ /.clang-format +/compile_commands.json From a06ffb355573f3ad7d6ae475685843f18e38f2d4 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 13 Feb 2021 12:14:21 +0000 Subject: [PATCH 113/259] GIT_SILENT Upgrade KF version to 5.80.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4bd2df6b..63366aee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.5) -set(KF_VERSION "5.79.0") # handled by release scripts +set(KF_VERSION "5.80.0") # handled by release scripts project(KConfig VERSION ${KF_VERSION}) include(FeatureSummary) From 186755fd56b58dc97250846c5305ef89f9487f86 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Mon, 22 Feb 2021 17:34:03 +0200 Subject: [PATCH 114/259] Add a trailing comma to last member in enum GIT_SILENT --- autotests/kconfig_compiler/test11_types.h | 7 ++++++- autotests/kconfigtest.h | 4 ++-- src/core/kconfig.h | 2 +- src/core/kconfigbackend_p.h | 4 ++-- src/core/kconfigbase.h | 8 ++++++-- src/core/kconfigdata.h | 4 ++-- src/core/kconfigini_p.h | 2 +- src/core/kcoreconfigskeleton.h | 6 +++++- src/core/kemailsettings.h | 2 +- src/gui/kstandardshortcut.h | 2 +- src/kconfig_compiler/KConfigCodeGeneratorBase.h | 2 +- src/kconfig_compiler/KConfigParameters.h | 2 +- 12 files changed, 29 insertions(+), 16 deletions(-) diff --git a/autotests/kconfig_compiler/test11_types.h b/autotests/kconfig_compiler/test11_types.h index b6aa5d80..553ae54a 100644 --- a/autotests/kconfig_compiler/test11_types.h +++ b/autotests/kconfig_compiler/test11_types.h @@ -10,7 +10,12 @@ class TimePeriod { public: - enum Units { Minutes, HoursMinutes, Days, Weeks }; + enum Units { + Minutes, + HoursMinutes, + Days, + Weeks, + }; }; #endif diff --git a/autotests/kconfigtest.h b/autotests/kconfigtest.h index 1a248c74..cb6e3712 100644 --- a/autotests/kconfigtest.h +++ b/autotests/kconfigtest.h @@ -14,9 +14,9 @@ class KConfigTest : public QObject Q_OBJECT public: - enum Testing { Ones = 1, Tens = 10, Hundreds = 100}; + enum Testing { Ones = 1, Tens = 10, Hundreds = 100,}; Q_ENUM(Testing) - enum bits { bit0 = 1, bit1 = 2, bit2 = 4, bit3 = 8 }; + enum bits { bit0 = 1, bit1 = 2, bit2 = 4, bit3 = 8, }; Q_DECLARE_FLAGS(Flags, bits) Q_FLAG(Flags) diff --git a/src/core/kconfig.h b/src/core/kconfig.h index ccea1bce..4b652059 100644 --- a/src/core/kconfig.h +++ b/src/core/kconfig.h @@ -86,7 +86,7 @@ class KCONFIGCORE_EXPORT KConfig : public KConfigBase SimpleConfig = 0x00, ///< Just a single config file. NoCascade = IncludeGlobals, ///< Include user's globals, but omit system settings. NoGlobals = CascadeConfig, ///< Cascade to system settings, but omit user's globals. - FullConfig = IncludeGlobals | CascadeConfig ///< Fully-fledged config, including globals and cascading to system settings + FullConfig = IncludeGlobals | CascadeConfig, ///< Fully-fledged config, including globals and cascading to system settings }; /** * Stores a combination of #OpenFlag values. diff --git a/src/core/kconfigbackend_p.h b/src/core/kconfigbackend_p.h index 5f8b61b5..7eb1774e 100644 --- a/src/core/kconfigbackend_p.h +++ b/src/core/kconfigbackend_p.h @@ -70,7 +70,7 @@ class KConfigBackend : public QObject, public QSharedData enum ParseOption { ParseGlobal = 1, /// entries should be marked as @em global ParseDefaults = 2, /// entries should be marked as @em default - ParseExpansions = 4 /// entries are allowed to be marked as @em expandable + ParseExpansions = 4, /// entries are allowed to be marked as @em expandable }; Q_FLAG(ParseOption) /// @typedef typedef QFlags ParseOptions @@ -88,7 +88,7 @@ class KConfigBackend : public QObject, public QSharedData enum ParseInfo { ParseOk, /// the configuration was opened read/write ParseImmutable, /// the configuration is @em immutable - ParseOpenError /// the configuration could not be opened + ParseOpenError, /// the configuration could not be opened }; /** diff --git a/src/core/kconfigbase.h b/src/core/kconfigbase.h index 0682a6b5..a7693275 100644 --- a/src/core/kconfigbase.h +++ b/src/core/kconfigbase.h @@ -54,7 +54,7 @@ class KCONFIGCORE_EXPORT KConfigBase * Implied persistent * @since 5.51 */ - Normal = Persistent + Normal = Persistent, /**< * Save the entry to the application specific config file without * a locale tag. This is the default. @@ -172,7 +172,11 @@ class KCONFIGCORE_EXPORT KConfigBase /** * Possible return values for accessMode(). */ - enum AccessMode { NoAccess, ReadOnly, ReadWrite }; + enum AccessMode { + NoAccess, + ReadOnly, + ReadWrite, + }; /** * Returns the access mode of the app-config object. diff --git a/src/core/kconfigdata.h b/src/core/kconfigdata.h index 2f36b1bb..36d90335 100644 --- a/src/core/kconfigdata.h +++ b/src/core/kconfigdata.h @@ -154,7 +154,7 @@ class KEntryMap : public QMap public: enum SearchFlag { SearchDefaults = 1, - SearchLocalized = 2 + SearchLocalized = 2, }; Q_DECLARE_FLAGS(SearchFlags, SearchFlag) @@ -168,7 +168,7 @@ class KEntryMap : public QMap EntryLocalizedCountry = 64, EntryNotify = 128, EntryDefault = (SearchDefaults << 16), - EntryLocalized = (SearchLocalized << 16) + EntryLocalized = (SearchLocalized << 16), }; Q_DECLARE_FLAGS(EntryOptions, EntryOption) diff --git a/src/core/kconfigini_p.h b/src/core/kconfigini_p.h index 923ddb32..d760170d 100644 --- a/src/core/kconfigini_p.h +++ b/src/core/kconfigini_p.h @@ -52,7 +52,7 @@ Q_OBJECT enum StringType { GroupString = 0, KeyString = 1, - ValueString = 2 + ValueString = 2, }; // Warning: this modifies data in-place. Other BufferFragment objects referencing the same buffer // fragment will get their data modified too. diff --git a/src/core/kcoreconfigskeleton.h b/src/core/kcoreconfigskeleton.h index 69f52060..e7b814e8 100644 --- a/src/core/kcoreconfigskeleton.h +++ b/src/core/kcoreconfigskeleton.h @@ -543,7 +543,11 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject class KCONFIGCORE_EXPORT ItemString: public KConfigSkeletonGenericItem < QString > { public: - enum Type { Normal, Password, Path }; + enum Type { + Normal, + Password, + Path, + }; /** @enum Type The type of string that is held in this item diff --git a/src/core/kemailsettings.h b/src/core/kemailsettings.h index 876b569e..30f9942c 100644 --- a/src/core/kemailsettings.h +++ b/src/core/kemailsettings.h @@ -91,7 +91,7 @@ class KCONFIGCORE_EXPORT KEMailSettings enum Extension { POP3, SMTP, - OTHER + OTHER, }; /** diff --git a/src/gui/kstandardshortcut.h b/src/gui/kstandardshortcut.h index c37712b3..3757a593 100644 --- a/src/gui/kstandardshortcut.h +++ b/src/gui/kstandardshortcut.h @@ -144,7 +144,7 @@ enum StandardShortcut { CreateFolder, ///< Create a folder. @since 5.74 // Insert new items here! - StandardShortcutCount // number of standard shortcuts + StandardShortcutCount, // number of standard shortcuts }; /** diff --git a/src/kconfig_compiler/KConfigCodeGeneratorBase.h b/src/kconfig_compiler/KConfigCodeGeneratorBase.h index 6059e26f..e9d2a955 100644 --- a/src/kconfig_compiler/KConfigCodeGeneratorBase.h +++ b/src/kconfig_compiler/KConfigCodeGeneratorBase.h @@ -28,7 +28,7 @@ struct ParseResult; /* This class manages the base of writing a C - Based code */ class KConfigCodeGeneratorBase { public: - enum ScopeFinalizer {None, Semicolon}; + enum ScopeFinalizer {None, Semicolon,}; KConfigCodeGeneratorBase( const QString &inputFileName, // The kcfg file diff --git a/src/kconfig_compiler/KConfigParameters.h b/src/kconfig_compiler/KConfigParameters.h index 1984bb96..f8619b2a 100644 --- a/src/kconfig_compiler/KConfigParameters.h +++ b/src/kconfig_compiler/KConfigParameters.h @@ -29,7 +29,7 @@ class KConfigParameters public: enum TranslationSystem { QtTranslation, - KdeTranslation + KdeTranslation, }; // These are read from the .kcfgc configuration file From 8bed00ab34e31f2b9c70026d418d923913325798 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Mon, 22 Feb 2021 17:38:09 +0200 Subject: [PATCH 115/259] Run clang-format on all cpp/h files NO_CHANGELOG --- CMakeLists.txt | 8 +- autotests/fallbackconfigresourcestest.cpp | 2 +- autotests/helper.h | 3 +- .../kconfig_compiler/kconfigcompiler_test.cpp | 153 ++-- .../kconfig_compiler/kconfigcompiler_test.h | 2 +- .../kconfigcompiler_test_signals.cpp | 103 +-- autotests/kconfig_compiler/myprefs.h | 5 +- autotests/kconfig_compiler/test1main.cpp | 2 +- autotests/kconfig_compiler/test4main.cpp | 2 +- autotests/kconfig_compiler/test9main.cpp | 2 +- .../test_param_minmax_main.cpp | 1 - .../test_qdebugcategory_debug.cpp | 2 - .../test_qdebugcategory_debug.h | 1 - autotests/kconfigguitest.cpp | 13 +- autotests/kconfigloadertest.cpp | 17 +- autotests/kconfignokdehometest.cpp | 2 +- autotests/kconfigskeletontest.cpp | 8 +- autotests/kconfigskeletontest.h | 2 - autotests/kconfigtest.cpp | 126 +-- autotests/kconfigtest.h | 13 +- autotests/kdesktopfiletest.cpp | 141 ++-- autotests/kdesktopfiletest.h | 1 - autotests/kentrymaptest.h | 2 +- autotests/ksharedconfig_in_global_object.cpp | 4 +- autotests/ksharedconfigtest.cpp | 7 +- autotests/kstandardshortcuttest.cpp | 4 +- autotests/test_kconf_update.cpp | 757 +++++++----------- autotests/test_kconfigutils.cpp | 101 +-- src/core/bufferfragment_p.h | 12 +- src/core/conversioncheck.h | 31 +- src/core/kauthorized.cpp | 156 ++-- src/core/kauthorized.h | 14 +- src/core/kconfig.cpp | 116 ++- src/core/kconfig.h | 19 +- src/core/kconfig_p.h | 36 +- src/core/kconfigbackend.cpp | 10 +- src/core/kconfigbackend_p.h | 17 +- src/core/kconfigbase.cpp | 9 +- src/core/kconfigbase.h | 6 +- src/core/kconfigdata.cpp | 58 +- src/core/kconfigdata.h | 89 +- src/core/kconfiggroup.cpp | 180 ++--- src/core/kconfiggroup.h | 194 +++-- src/core/kconfiggroup_p.h | 8 +- src/core/kconfigini.cpp | 258 +++--- src/core/kconfigini_p.h | 20 +- src/core/kconfigwatcher.cpp | 28 +- src/core/kconfigwatcher.h | 4 +- src/core/kcoreconfigskeleton.cpp | 307 +++---- src/core/kcoreconfigskeleton.h | 256 +++--- src/core/kcoreconfigskeleton_p.h | 10 +- src/core/kdesktopfile.cpp | 32 +- src/core/kdesktopfile.h | 3 +- src/core/kemailsettings.cpp | 8 +- src/core/kemailsettings.h | 98 +-- src/core/ksharedconfig.cpp | 27 +- src/core/ksharedconfig.h | 13 +- src/gui/kconfiggroupgui.cpp | 30 +- src/gui/kconfiggui.cpp | 11 +- src/gui/kconfigloader.cpp | 63 +- src/gui/kconfigloader.h | 2 +- src/gui/kconfigloaderhandler_p.h | 1 - src/gui/kconfigskeleton.cpp | 21 +- src/gui/kconfigskeleton.h | 20 +- src/gui/kstandardshortcut.cpp | 471 ++++++++--- src/gui/kstandardshortcut.h | 6 +- src/gui/kwindowconfig.cpp | 4 +- src/gui/kwindowconfig.h | 4 +- src/kconf_update/kconf_update.cpp | 99 ++- src/kconf_update/kconfigutils.cpp | 1 - src/kconf_update/kconfigutils.h | 1 - .../KConfigCodeGeneratorBase.cpp | 30 +- .../KConfigCodeGeneratorBase.h | 70 +- src/kconfig_compiler/KConfigCommonStructs.h | 52 +- .../KConfigHeaderGenerator.cpp | 46 +- src/kconfig_compiler/KConfigHeaderGenerator.h | 13 +- src/kconfig_compiler/KConfigParameters.h | 10 +- .../KConfigSourceGenerator.cpp | 74 +- src/kconfig_compiler/KConfigSourceGenerator.h | 11 +- src/kconfig_compiler/KConfigXmlParser.cpp | 69 +- src/kconfig_compiler/KConfigXmlParser.h | 2 +- src/kconfig_compiler/kconfig_compiler.cpp | 99 ++- src/kreadconfig/kreadconfig.cpp | 100 +-- src/kreadconfig/kwriteconfig.cpp | 51 +- 84 files changed, 2343 insertions(+), 2521 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 63366aee..dba7a7ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,7 @@ endif() include(KDEInstallDirs) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(KDECMakeSettings) - +include(KDEGitCommitHooks) include(ECMGenerateExportHeader) include(ECMSetupVersion) @@ -104,3 +104,9 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kconfig_version.h feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) + +kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT) +# Remove these 3 lines when the ECM version is bumped to 5.80 +include(KDEClangFormat) +file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h) +kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES}) diff --git a/autotests/fallbackconfigresourcestest.cpp b/autotests/fallbackconfigresourcestest.cpp index 0b1a3697..56d065cc 100644 --- a/autotests/fallbackconfigresourcestest.cpp +++ b/autotests/fallbackconfigresourcestest.cpp @@ -6,8 +6,8 @@ */ #include -#include #include +#include class FallbackConfigResourcesTest : public QObject { diff --git a/autotests/helper.h b/autotests/helper.h index 20aed445..513916a6 100644 --- a/autotests/helper.h +++ b/autotests/helper.h @@ -15,13 +15,14 @@ class DefaultLocale { public: DefaultLocale() - : m_defaultLocale() + : m_defaultLocale() { } ~DefaultLocale() { QLocale::setDefault(m_defaultLocale); } + private: QLocale m_defaultLocale; }; diff --git a/autotests/kconfig_compiler/kconfigcompiler_test.cpp b/autotests/kconfig_compiler/kconfigcompiler_test.cpp index 4467a211..090fe01d 100644 --- a/autotests/kconfig_compiler/kconfigcompiler_test.cpp +++ b/autotests/kconfig_compiler/kconfigcompiler_test.cpp @@ -7,77 +7,101 @@ SPDX-License-Identifier: LGPL-2.0-or-later */ +#include "kconfigcompiler_test.h" #include #include #include #include #include -#include "kconfigcompiler_test.h" // QT5 TODO QTEST_GUILESS_MAIN(KConfigCompiler_Test) QTEST_MAIN(KConfigCompiler_Test) typedef const char *CompilerTestSet[]; -static CompilerTestSet testCases = { - "test1.cpp", "test1.h", - "test2.cpp", "test2.h", - "test3.cpp", "test3.h", - "test3a.cpp", "test3a.h", - "test4.cpp", "test4.h", - "test5.cpp", "test5.h", - "test6.cpp", "test6.h", - "test7.cpp", "test7.h", - "test8a.cpp", "test8a.h", - "test8b.cpp", "test8b.h", - "test8c.cpp", "test8c.h", - "test9.h", "test9.cpp", - "test10.h", "test10.cpp", - "test11.h", "test11.cpp", - "test11a.h", "test11a.cpp", - "test12.h", "test12.cpp", - "test13.h", "test13.cpp", - "test_dpointer.cpp", "test_dpointer.h", - "test_qdebugcategory.cpp", "test_qdebugcategory.h", - "test_signal.cpp", "test_signal.h", - "test_notifiers.cpp", "test_notifiers.h", - "test_translation_kde.cpp", "test_translation_kde.h", - "test_translation_kde_domain.cpp", "test_translation_kde_domain.h", - "test_translation_qt.cpp", "test_translation_qt.h", - "test_emptyentries.cpp", "test_emptyentries.h", - "test_properties_minmax.cpp", "test_properties_minmax.h", - "test_param_minmax.cpp", "test_param_minmax.h", - "test_subgroups.cpp", "test_subgroups.h", - nullptr -}; - -static CompilerTestSet testCasesToRun = { - "test1", - "test2", - "test3", - "test3a", - "test4", - "test5", - "test6", - "test7", - "test8", - "test9", - "test10", - "test11", - "test12", - "test13", - "test_dpointer", - "test_qdebugcategory", - "test_signal", - "test_translation_kde", - "test_translation_kde_domain", - "test_translation_qt", - "test_emptyentries", - "test_properties_minmax", - "test_param_minmax", - "test_subgroups", - nullptr -}; +static CompilerTestSet testCases = {"test1.cpp", + "test1.h", + "test2.cpp", + "test2.h", + "test3.cpp", + "test3.h", + "test3a.cpp", + "test3a.h", + "test4.cpp", + "test4.h", + "test5.cpp", + "test5.h", + "test6.cpp", + "test6.h", + "test7.cpp", + "test7.h", + "test8a.cpp", + "test8a.h", + "test8b.cpp", + "test8b.h", + "test8c.cpp", + "test8c.h", + "test9.h", + "test9.cpp", + "test10.h", + "test10.cpp", + "test11.h", + "test11.cpp", + "test11a.h", + "test11a.cpp", + "test12.h", + "test12.cpp", + "test13.h", + "test13.cpp", + "test_dpointer.cpp", + "test_dpointer.h", + "test_qdebugcategory.cpp", + "test_qdebugcategory.h", + "test_signal.cpp", + "test_signal.h", + "test_notifiers.cpp", + "test_notifiers.h", + "test_translation_kde.cpp", + "test_translation_kde.h", + "test_translation_kde_domain.cpp", + "test_translation_kde_domain.h", + "test_translation_qt.cpp", + "test_translation_qt.h", + "test_emptyentries.cpp", + "test_emptyentries.h", + "test_properties_minmax.cpp", + "test_properties_minmax.h", + "test_param_minmax.cpp", + "test_param_minmax.h", + "test_subgroups.cpp", + "test_subgroups.h", + nullptr}; + +static CompilerTestSet testCasesToRun = {"test1", + "test2", + "test3", + "test3a", + "test4", + "test5", + "test6", + "test7", + "test8", + "test9", + "test10", + "test11", + "test12", + "test13", + "test_dpointer", + "test_qdebugcategory", + "test_signal", + "test_translation_kde", + "test_translation_kde_domain", + "test_translation_qt", + "test_emptyentries", + "test_properties_minmax", + "test_param_minmax", + "test_subgroups", + nullptr}; #if 0 static CompilerTestSet willFailCases = { @@ -89,7 +113,7 @@ static CompilerTestSet willFailCases = { void KConfigCompiler_Test::initTestCase() { - m_diffExe = QStandardPaths::findExecutable( QStringLiteral("diff") ); + m_diffExe = QStandardPaths::findExecutable(QStringLiteral("diff")); if (m_diffExe.isEmpty()) { qDebug() << "diff command not found, detailed info on comparison failure will not be available."; } @@ -122,7 +146,7 @@ void KConfigCompiler_Test::testBaselineComparison() const QByteArray content = file.readAll(); const QByteArray contentRef = fileRef.readAll(); - if (content != contentRef) { + if (content != contentRef) { appendFileDiff(fileRef.fileName(), file.fileName()); } @@ -164,10 +188,7 @@ void KConfigCompiler_Test::appendFileDiff(const QString &oldFile, const QString return; } - QStringList args({ - QStringLiteral("-u"), - QFileInfo(oldFile).absoluteFilePath(), - QFileInfo(newFile).absoluteFilePath() }); + QStringList args({QStringLiteral("-u"), QFileInfo(oldFile).absoluteFilePath(), QFileInfo(newFile).absoluteFilePath()}); QProcess process; process.start(m_diffExe, args, QIODevice::ReadOnly); diff --git a/autotests/kconfig_compiler/kconfigcompiler_test.h b/autotests/kconfig_compiler/kconfigcompiler_test.h index e0506db0..c8242cfd 100644 --- a/autotests/kconfig_compiler/kconfigcompiler_test.h +++ b/autotests/kconfig_compiler/kconfigcompiler_test.h @@ -24,6 +24,7 @@ private Q_SLOTS: void testBaselineComparison(); void testRunning_data(); void testRunning(); + private: void appendFileDiff(const QString &oldFile, const QString &newFile); @@ -31,4 +32,3 @@ private Q_SLOTS: }; #endif - diff --git a/autotests/kconfig_compiler/kconfigcompiler_test_signals.cpp b/autotests/kconfig_compiler/kconfigcompiler_test_signals.cpp index 3637b1ff..f493d35f 100644 --- a/autotests/kconfig_compiler/kconfigcompiler_test_signals.cpp +++ b/autotests/kconfig_compiler/kconfigcompiler_test_signals.cpp @@ -4,17 +4,17 @@ SPDX-License-Identifier: MIT */ -#include "signals_test_singleton.h" #include "signals_test_no_singleton.h" -#include "signals_test_singleton_dpointer.h" #include "signals_test_no_singleton_dpointer.h" -#include -#include -#include -#include +#include "signals_test_singleton.h" +#include "signals_test_singleton_dpointer.h" #include -#include #include +#include +#include +#include +#include +#include #include class KConfigCompiler_Test_Signals : public QObject @@ -29,17 +29,17 @@ private Q_SLOTS: void cleanupTestCase(); }; -static SignalsTestNoSingleton* noSingleton; -static SignalsTestNoSingletonDpointer* noSingletonDpointer; +static SignalsTestNoSingleton *noSingleton; +static SignalsTestNoSingletonDpointer *noSingletonDpointer; void KConfigCompiler_Test_Signals::initTestCase() { // These tests do a lot quite a few I/O operations, speed that up by using a QTemporaryFile. // At least on Linux this is often a tmpfs which means only RAM operations - QTemporaryFile* tempFile1 = new QTemporaryFile(this); - QTemporaryFile* tempFile2 = new QTemporaryFile(this); - QTemporaryFile* tempFile3 = new QTemporaryFile(this); - QTemporaryFile* tempFile4 = new QTemporaryFile(this); + QTemporaryFile *tempFile1 = new QTemporaryFile(this); + QTemporaryFile *tempFile2 = new QTemporaryFile(this); + QTemporaryFile *tempFile3 = new QTemporaryFile(this); + QTemporaryFile *tempFile4 = new QTemporaryFile(this); QVERIFY(tempFile1->open()); QVERIFY(tempFile2->open()); QVERIFY(tempFile3->open()); @@ -47,15 +47,13 @@ void KConfigCompiler_Test_Signals::initTestCase() SignalsTestSingleton::instance(QFileInfo(*tempFile1).absoluteFilePath()); SignalsTestSingletonDpointer::instance(QFileInfo(*tempFile2).absoluteFilePath()); - noSingleton = new SignalsTestNoSingleton( - KSharedConfig::openConfig(QFileInfo(*tempFile3).absoluteFilePath(), KConfig::SimpleConfig)); - noSingletonDpointer = new SignalsTestNoSingletonDpointer( - KSharedConfig::openConfig(QFileInfo(*tempFile4).absoluteFilePath(), KConfig::SimpleConfig)); + noSingleton = new SignalsTestNoSingleton(KSharedConfig::openConfig(QFileInfo(*tempFile3).absoluteFilePath(), KConfig::SimpleConfig)); + noSingletonDpointer = new SignalsTestNoSingletonDpointer(KSharedConfig::openConfig(QFileInfo(*tempFile4).absoluteFilePath(), KConfig::SimpleConfig)); } void KConfigCompiler_Test_Signals::cleanupTestCase() { - //ensure these instances are deleted before the temporary files are closed + // ensure these instances are deleted before the temporary files are closed delete noSingleton; delete noSingletonDpointer; delete SignalsTestSingleton::self(); @@ -64,18 +62,29 @@ void KConfigCompiler_Test_Signals::cleanupTestCase() struct TestSettersArg { // default constructor required for Q_DECLARE_METATYPE - TestSettersArg() : obj(nullptr) {} + TestSettersArg() + : obj(nullptr) + { + } template - TestSettersArg(T* object) : obj(object) { + TestSettersArg(T *object) + : obj(object) + { // we can also call static methods using object->foo() so this works for all four cases - getter = [object]() { return object->foo(); }; - defaultGetter = [object]() { return object->defaultFooValue(); }; - setter = [object](const QString& s) { object->setFoo(s); }; + getter = [object]() { + return object->foo(); + }; + defaultGetter = [object]() { + return object->defaultFooValue(); + }; + setter = [object](const QString &s) { + object->setFoo(s); + }; } - KCoreConfigSkeleton* obj; + KCoreConfigSkeleton *obj; std::function getter; std::function defaultGetter; - std::function setter; + std::function setter; }; Q_DECLARE_METATYPE(TestSettersArg) // so that QFETCH works @@ -93,7 +102,7 @@ void KConfigCompiler_Test_Signals::testSetters_data() void KConfigCompiler_Test_Signals::testSetters() { QFETCH(TestSettersArg, params); - const char* signal = SIGNAL(fooChanged(QString)); + const char *signal = SIGNAL(fooChanged(QString)); const QString defaultValue = QStringLiteral("default"); const QString changedValue = QStringLiteral("changed"); @@ -105,21 +114,21 @@ void KConfigCompiler_Test_Signals::testSetters() QSignalSpy spy(params.obj, signal); QVERIFY2(spy.isValid(), signal); - //change value via setter, should get signal + // change value via setter, should get signal QCOMPARE(params.getter(), defaultValue); QCOMPARE(defaultValue, params.defaultGetter()); QCOMPARE(params.getter(), params.defaultGetter()); QVERIFY(changedValue != params.getter()); params.setter(changedValue); QCOMPARE(params.getter(), changedValue); - QCOMPARE(spy.count(), 0); //should have no change yet, only after save() + QCOMPARE(spy.count(), 0); // should have no change yet, only after save() params.obj->save(); QCOMPARE(spy.count(), 1); args = spy.takeFirst(); QCOMPARE(args.size(), 1); QCOMPARE(args[0].toString(), changedValue); - //reset to default values via setDefaults() + // reset to default values via setDefaults() QVERIFY(params.getter() != params.defaultGetter()); QVERIFY(params.getter() != defaultValue); QCOMPARE(params.getter(), changedValue); @@ -127,67 +136,67 @@ void KConfigCompiler_Test_Signals::testSetters() QCOMPARE(params.getter(), params.defaultGetter()); QCOMPARE(params.getter(), defaultValue); - QCOMPARE(spy.count(), 0); //should have no change yet, only after save() + QCOMPARE(spy.count(), 0); // should have no change yet, only after save() params.obj->save(); - //TODO: This currently fails since setDefaults() does not yet cause emitting a signal + // TODO: This currently fails since setDefaults() does not yet cause emitting a signal QCOMPARE(spy.count(), 1); args = spy.takeFirst(); QCOMPARE(args.size(), 1); QCOMPARE(args[0].value(), defaultValue); } -Q_DECLARE_METATYPE(KCoreConfigSkeleton*) +Q_DECLARE_METATYPE(KCoreConfigSkeleton *) void KConfigCompiler_Test_Signals::testSetProperty_data() { - QTest::addColumn("obj"); - QTest::newRow("singleton") << static_cast(SignalsTestSingleton::self()); - QTest::newRow("singleton dpointer") << static_cast(SignalsTestSingletonDpointer::self()); - QTest::newRow("non-singleton") << static_cast(noSingleton); - QTest::newRow("non-singleton dpointer") << static_cast(noSingletonDpointer); + QTest::addColumn("obj"); + QTest::newRow("singleton") << static_cast(SignalsTestSingleton::self()); + QTest::newRow("singleton dpointer") << static_cast(SignalsTestSingletonDpointer::self()); + QTest::newRow("non-singleton") << static_cast(noSingleton); + QTest::newRow("non-singleton dpointer") << static_cast(noSingletonDpointer); } /** Test that the signal is emitted when modifying the values using the underlying KConfigSkeletonItem (bypassing the setters) */ void KConfigCompiler_Test_Signals::testSetProperty() { - QFETCH(KCoreConfigSkeleton*, obj); - const char* signal = SIGNAL(fooChanged(QString)); + QFETCH(KCoreConfigSkeleton *, obj); + const char *signal = SIGNAL(fooChanged(QString)); const QString propertyName = QStringLiteral("foo"); const QString defaultValue = QStringLiteral("default"); const QString newValue = QStringLiteral("changed"); obj->setDefaults(); obj->save(); - KConfigSkeletonItem* item = obj->findItem(propertyName); + KConfigSkeletonItem *item = obj->findItem(propertyName); QVERIFY2(item, "Item must exist"); QVERIFY2(!item->isImmutable(), "Item must not be immutable"); QVERIFY2(!obj->isImmutable(propertyName), "Item must not be immutable"); - //listen for all expected signals + // listen for all expected signals QSignalSpy spy(obj, signal); QVERIFY2(spy.isValid(), signal); QVERIFY(item->isEqual(defaultValue)); QVERIFY(!item->isEqual(newValue)); - item->setProperty(newValue); //change value now - //should have no change yet, only after save() + item->setProperty(newValue); // change value now + // should have no change yet, only after save() QCOMPARE(spy.count(), 0); obj->save(); - //now check for the signal emissions + // now check for the signal emissions QCOMPARE(spy.count(), 1); QList args = spy.takeFirst(); QCOMPARE(args.size(), 1); QVERIFY(item->isEqual(args[0])); - //now reset to default + // now reset to default QVERIFY(!item->isEqual(defaultValue)); item->setDefault(); QVERIFY(item->isEqual(defaultValue)); - //should have no change yet, only after save() + // should have no change yet, only after save() QCOMPARE(spy.count(), 0); obj->save(); - //now check for the signal emissions + // now check for the signal emissions QCOMPARE(spy.count(), 1); args = spy.takeFirst(); QCOMPARE(args.size(), 1); diff --git a/autotests/kconfig_compiler/myprefs.h b/autotests/kconfig_compiler/myprefs.h index 609fc546..073352b9 100644 --- a/autotests/kconfig_compiler/myprefs.h +++ b/autotests/kconfig_compiler/myprefs.h @@ -6,7 +6,10 @@ class MyPrefs : public KConfigSkeleton { public: - MyPrefs(const QString &a) : KConfigSkeleton(a) {} + MyPrefs(const QString &a) + : KConfigSkeleton(a) + { + } }; #endif diff --git a/autotests/kconfig_compiler/test1main.cpp b/autotests/kconfig_compiler/test1main.cpp index 5a7eda0c..43dcd2c1 100644 --- a/autotests/kconfig_compiler/test1main.cpp +++ b/autotests/kconfig_compiler/test1main.cpp @@ -4,9 +4,9 @@ SPDX-License-Identifier: MIT */ #include "test1.h" -#include #include #include +#include int main(int argc, char **argv) { diff --git a/autotests/kconfig_compiler/test4main.cpp b/autotests/kconfig_compiler/test4main.cpp index 8792842f..fa9bf7dc 100644 --- a/autotests/kconfig_compiler/test4main.cpp +++ b/autotests/kconfig_compiler/test4main.cpp @@ -5,9 +5,9 @@ */ #include "test4.h" +#include #include #include -#include int main(int argc, char **argv) { diff --git a/autotests/kconfig_compiler/test9main.cpp b/autotests/kconfig_compiler/test9main.cpp index 03c43f1b..0a7256f1 100644 --- a/autotests/kconfig_compiler/test9main.cpp +++ b/autotests/kconfig_compiler/test9main.cpp @@ -5,9 +5,9 @@ */ #include "test9.h" +#include #include #include -#include int main(int argc, char **argv) { diff --git a/autotests/kconfig_compiler/test_param_minmax_main.cpp b/autotests/kconfig_compiler/test_param_minmax_main.cpp index 57fc26a7..9756a32f 100644 --- a/autotests/kconfig_compiler/test_param_minmax_main.cpp +++ b/autotests/kconfig_compiler/test_param_minmax_main.cpp @@ -26,4 +26,3 @@ int main(int, char **) delete t; return 0; } - diff --git a/autotests/kconfig_compiler/test_qdebugcategory_debug.cpp b/autotests/kconfig_compiler/test_qdebugcategory_debug.cpp index 7c4f9f55..2526254c 100644 --- a/autotests/kconfig_compiler/test_qdebugcategory_debug.cpp +++ b/autotests/kconfig_compiler/test_qdebugcategory_debug.cpp @@ -1,4 +1,2 @@ #include "test_qdebugcategory_debug.h" Q_LOGGING_CATEGORY(CATEGORY_LOG, "log_category") - - diff --git a/autotests/kconfig_compiler/test_qdebugcategory_debug.h b/autotests/kconfig_compiler/test_qdebugcategory_debug.h index 88ac4f35..a92e54ca 100644 --- a/autotests/kconfig_compiler/test_qdebugcategory_debug.h +++ b/autotests/kconfig_compiler/test_qdebugcategory_debug.h @@ -5,4 +5,3 @@ Q_DECLARE_LOGGING_CATEGORY(CATEGORY_LOG) #endif - diff --git a/autotests/kconfigguitest.cpp b/autotests/kconfigguitest.cpp index 2744d272..a9d3931a 100644 --- a/autotests/kconfigguitest.cpp +++ b/autotests/kconfigguitest.cpp @@ -4,13 +4,13 @@ SPDX-License-Identifier: LGPL-2.0-or-later */ -#include #include "kconfigguitest.h" +#include -#include #include #include #include +#include #include #include @@ -77,8 +77,7 @@ void KConfigTest::testComplex() KConfig sc2(QStringLiteral("kconfigtest")); KConfigGroup sc3(&sc2, "ComplexTypes"); - QCOMPARE(QVariant(sc3.readEntry("colorEntry1", QColor(Qt::black))).toString(), - QVariant(s_color_entry1).toString()); + QCOMPARE(QVariant(sc3.readEntry("colorEntry1", QColor(Qt::black))).toString(), QVariant(s_color_entry1).toString()); QCOMPARE(sc3.readEntry("colorEntry1", QColor()), s_color_entry1); QCOMPARE(sc3.readEntry("colorEntry2", QColor()), s_color_entry2); QCOMPARE(sc3.readEntry("colorEntry3", QColor()), s_color_entry3); @@ -118,19 +117,19 @@ void KConfigTest::testInvalid() sc3.writeEntry("badList", list); QVERIFY(sc.sync()); - QVERIFY(sc3.readEntry("badList", QColor()) == QColor()); // out of bounds + QVERIFY(sc3.readEntry("badList", QColor()) == QColor()); // out of bounds // 4 element list list << 4; sc3.writeEntry("badList", list); QVERIFY(sc.sync()); - QVERIFY(sc3.readEntry("badList", QColor()) == QColor()); // out of bounds + QVERIFY(sc3.readEntry("badList", QColor()) == QColor()); // out of bounds list[2] = -3; sc3.writeEntry("badList", list); QVERIFY(sc.sync()); - QVERIFY(sc3.readEntry("badList", QColor()) == QColor()); // out of bounds + QVERIFY(sc3.readEntry("badList", QColor()) == QColor()); // out of bounds // 5 element list list[2] = 3; diff --git a/autotests/kconfigloadertest.cpp b/autotests/kconfigloadertest.cpp index ab93c1da..17bfe403 100644 --- a/autotests/kconfigloadertest.cpp +++ b/autotests/kconfigloadertest.cpp @@ -7,20 +7,20 @@ #include #include -#include #include +#include Q_DECLARE_METATYPE(QList) static const QString s_testName(QStringLiteral("kconfigloadertest")); // clazy:exclude=non-pod-global-static -#define GET_CONFIG_ITEM_VALUE(type, configName) \ - KConfigSkeletonItem* item = cl->findItem(s_testName, configName); \ - /* Check if we got back a valid item. */ \ - QVERIFY(item != nullptr); \ - /* Cast the item to the given type. */ \ - type typeItem = dynamic_cast(item); \ - /* Make sure the cast was successful. */ \ +#define GET_CONFIG_ITEM_VALUE(type, configName) \ + KConfigSkeletonItem *item = cl->findItem(s_testName, configName); \ + /* Check if we got back a valid item. */ \ + QVERIFY(item != nullptr); \ + /* Cast the item to the given type. */ \ + type typeItem = dynamic_cast(item); \ + /* Make sure the cast was successful. */ \ QVERIFY(typeItem != nullptr); void ConfigLoaderTest::init() @@ -191,4 +191,3 @@ void ConfigLoaderTest::ulongLongDefaultValue() } QTEST_MAIN(ConfigLoaderTest) - diff --git a/autotests/kconfignokdehometest.cpp b/autotests/kconfignokdehometest.cpp index 1d05d98d..6cb105ef 100644 --- a/autotests/kconfignokdehometest.cpp +++ b/autotests/kconfignokdehometest.cpp @@ -6,8 +6,8 @@ #include -#include #include +#include #include #include diff --git a/autotests/kconfigskeletontest.cpp b/autotests/kconfigskeletontest.cpp index 950e6581..88936f1e 100644 --- a/autotests/kconfigskeletontest.cpp +++ b/autotests/kconfigskeletontest.cpp @@ -6,20 +6,20 @@ #include "kconfigskeletontest.h" -#include #include #include +#include QTEST_MAIN(KConfigSkeletonTest) // clazy:excludeall=non-pod-global-static static const bool s_default_setting1{false}; -static const QColor s_default_setting2{1,2,3}; +static const QColor s_default_setting2{1, 2, 3}; static const QString s_default_setting4{QStringLiteral("Hello World")}; static const bool s_write_setting1{true}; -static const QColor s_write_setting2{3,2,1}; +static const QColor s_write_setting2{3, 2, 1}; static const QString s_write_setting4{QStringLiteral("KDE")}; static QFont defaultSetting3() @@ -29,7 +29,7 @@ static QFont defaultSetting3() static QFont writeSettings3() { - return QFont{QStringLiteral("helvetica"), 14}; + return QFont{QStringLiteral("helvetica"), 14}; } void KConfigSkeletonTest::initTestCase() diff --git a/autotests/kconfigskeletontest.h b/autotests/kconfigskeletontest.h index 6bac81d2..8c6d3aa7 100644 --- a/autotests/kconfigskeletontest.h +++ b/autotests/kconfigskeletontest.h @@ -12,7 +12,6 @@ class KConfigSkeletonTest : public QObject { Q_OBJECT public: - private Q_SLOTS: void initTestCase(); void init(); @@ -31,7 +30,6 @@ private Q_SLOTS: QColor mMyColor; QFont mMyFont; QString mMyString; - }; #endif diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index be84efec..bf7882f0 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -9,16 +9,16 @@ #include "config-kconfig.h" -#include -#include -#include #include +#include #include +#include #include +#include -#include #include #include +#include #ifdef Q_OS_UNIX #include @@ -125,7 +125,7 @@ void KConfigTest::initTestCase() cg.writeEntry("boolEntry2", s_bool_entry2); QByteArray data(s_utf8bit_entry); - QCOMPARE(data.size(), 12); // the source file is in utf8 + QCOMPARE(data.size(), 12); // the source file is in utf8 QCOMPARE(QString::fromUtf8(data).length(), 9); cg.writeEntry("Test", data); cg.writeEntry("bytearrayEntry", s_bytearray_entry); @@ -139,7 +139,7 @@ void KConfigTest::initTestCase() cg.writeEntry("urlEntry1", QUrl(QStringLiteral("http://qt-project.org"))); cg.writeEntry("keywith=equalsign", s_string_entry1); cg.deleteEntry("stringEntry5"); - cg.deleteEntry("stringEntry6"); // deleting a nonexistent entry + cg.deleteEntry("stringEntry6"); // deleting a nonexistent entry cg.writeEntry("byteArrayEntry1", s_string_entry1.toLatin1(), KConfig::Global | KConfig::Persistent); cg.writeEntry("doubleEntry1", s_double_entry); cg.writeEntry("floatEntry1", s_float_entry); @@ -187,7 +187,7 @@ void KConfigTest::initTestCase() #if defined(_MSC_VER) && _MSC_VER == 1600 cg.writeEntry("dummy", 42); #else - //Visual C++ 2010 throws an Internal Compiler Error here + // Visual C++ 2010 throws an Internal Compiler Error here cg.writeEntry("enum-10", Tens); cg.writeEntry("enum-100", Hundreds); cg.writeEntry("flags-bit0", Flags(bit0)); @@ -217,7 +217,7 @@ void KConfigTest::initTestCase() sg0.writeEntry("FatalOutput", 0); QVERIFY(sc1.sync()); - //Setup stuff to test KConfig::addConfigSources() + // Setup stuff to test KConfig::addConfigSources() KConfig devcfg(s_test_subdir + QLatin1String("specificrc")); KConfigGroup devonlygrp(&devcfg, "Specific Only Group"); devonlygrp.writeEntry("ExistingEntry", "DevValue"); @@ -236,14 +236,13 @@ void KConfigTest::initTestCase() KConfig gecfg(s_test_subdir + QLatin1String("groupescapetest"), KConfig::SimpleConfig); cg = KConfigGroup(&gecfg, s_dollargroup); cg.writeEntry("entry", "doesntmatter"); - } void KConfigTest::cleanupTestCase() { - //ensure we don't delete the real directory + // ensure we don't delete the real directory QDir localConfig(m_testConfigDir); - //qDebug() << "Erasing" << localConfig; + // qDebug() << "Erasing" << localConfig; if (localConfig.exists()) { QVERIFY(localConfig.removeRecursively()); } @@ -342,7 +341,7 @@ void KConfigTest::testSimple() KConfigGroup sc3(&sc2, "AAA"); - QVERIFY(sc3.hasKey("stringEntry1")); // from kdeglobals + QVERIFY(sc3.hasKey("stringEntry1")); // from kdeglobals QVERIFY(!sc3.isEntryImmutable("stringEntry1")); QCOMPARE(sc3.readEntry("stringEntry1"), s_string_entry1); @@ -356,7 +355,7 @@ void KConfigTest::testSimple() QCOMPARE(sc3.readEntry("bytearrayEntry", QByteArray()), s_bytearray_entry); QCOMPARE(sc3.readEntry(s_escapekey), QString::fromLatin1(s_escape_entry)); QCOMPARE(sc3.readEntry("Test", QString{}), QString::fromUtf8(s_utf8bit_entry)); - QCOMPARE(sc3.readEntry("emptyEntry"/*, QString("Fietsbel")*/), QLatin1String("")); + QCOMPARE(sc3.readEntry("emptyEntry" /*, QString("Fietsbel")*/), QLatin1String("")); QCOMPARE(sc3.readEntry("emptyEntry", QStringLiteral("Fietsbel")).isEmpty(), true); QCOMPARE(sc3.readEntry("stringEntry1"), s_string_entry1); QCOMPARE(sc3.readEntry("stringEntry2"), s_string_entry2); @@ -542,7 +541,7 @@ void KConfigTest::testPath() QVERIFY(group.hasKey("noeol")); QCOMPARE(group.readEntry("noeol", QString{}), QStringLiteral("foo")); - const auto val = QStringList { QStringLiteral("aaa"), QStringLiteral("bb/b"), QStringLiteral("ccc,ccc")}; + const auto val = QStringList{QStringLiteral("aaa"), QStringLiteral("bb/b"), QStringLiteral("ccc,ccc")}; QCOMPARE(group.readPathEntry(QStringLiteral("escapes"), QStringList()), val); } @@ -586,14 +585,17 @@ void KConfigTest::testPathQtHome() qunsetenv("QT_CACHE_HOME"); qunsetenv("QT_CONFIG_HOME"); QVERIFY(group.hasKey("dataDir")); - QCOMPARE(group.readEntry("dataDir", QString{}), QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation).append(QStringLiteral("/kconfigtest"))); + QCOMPARE(group.readEntry("dataDir", QString{}), + QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation).append(QStringLiteral("/kconfigtest"))); QVERIFY(group.hasKey("cacheDir")); - QCOMPARE(group.readEntry("cacheDir", QString{}), QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation).append(QStringLiteral("/kconfigtest"))); + QCOMPARE(group.readEntry("cacheDir", QString{}), + QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation).append(QStringLiteral("/kconfigtest"))); QVERIFY(group.hasKey("configDir")); - QCOMPARE(group.readEntry("configDir", QString{}), QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation).append(QStringLiteral("/kconfigtest"))); - qputenv("QT_DATA_HOME","/1"); - qputenv("QT_CACHE_HOME","/2"); - qputenv("QT_CONFIG_HOME","/3"); + QCOMPARE(group.readEntry("configDir", QString{}), + QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation).append(QStringLiteral("/kconfigtest"))); + qputenv("QT_DATA_HOME", "/1"); + qputenv("QT_CACHE_HOME", "/2"); + qputenv("QT_CONFIG_HOME", "/3"); QVERIFY(group.hasKey("dataDir")); QCOMPARE(group.readEntry("dataDir", QString{}), QStringLiteral("/1/kconfigtest")); QVERIFY(group.hasKey("cacheDir")); @@ -618,9 +620,9 @@ void KConfigTest::testComplex() void KConfigTest::testEnums() { - //Visual C++ 2010 (compiler version 16.0) throws an Internal Compiler Error - //when compiling the code in initTestCase that creates these KConfig entries, - //so we can't run this test + // Visual C++ 2010 (compiler version 16.0) throws an Internal Compiler Error + // when compiling the code in initTestCase that creates these KConfig entries, + // so we can't run this test #if defined(_MSC_VER) && _MSC_VER == 1600 QSKIP("Visual C++ 2010 can't compile this test"); #endif @@ -702,7 +704,7 @@ void KConfigTest::testInvalid() QVERIFY(sc3.readEntry("badList", QPoint()) == QPoint()); QVERIFY(sc3.readEntry("badList", QRect()) == QRect()); QVERIFY(sc3.readEntry("badList", QSize()) == QSize()); - QVERIFY(sc3.readEntry("badList", QDate()) == QDate()); // out of bounds + QVERIFY(sc3.readEntry("badList", QDate()) == QDate()); // out of bounds QVERIFY(sc3.readEntry("badList", QDateTime()) == QDateTime()); // 4 element list @@ -819,13 +821,13 @@ void KConfigTest::testDelete() cg.deleteGroup(); QVERIFY(sc.entryMap(QStringLiteral("Complex Types")).isEmpty()); QVERIFY(sc.entryMap(QStringLiteral("AAA")).isEmpty()); - QVERIFY(!sc.entryMap(QStringLiteral("Hello")).isEmpty()); //not deleted group - QVERIFY(sc.entryMap(QStringLiteral("FooBar")).isEmpty()); //inexistant group + QVERIFY(!sc.entryMap(QStringLiteral("Hello")).isEmpty()); // not deleted group + QVERIFY(sc.entryMap(QStringLiteral("FooBar")).isEmpty()); // inexistant group QVERIFY(cg.sync()); // Check what happens on disk const QList lines = readLines(); - //qDebug() << lines; + // qDebug() << lines; QVERIFY(!lines.contains("[Complex Types]\n")); QVERIFY(!lines.contains("[Complex Types][Nested Group 1]\n")); QVERIFY(!lines.contains("[Complex Types][Nested Group 2]\n")); @@ -1181,8 +1183,8 @@ void KConfigTest::testSubGroup() QVERIFY(negsub4.exists()); // Only subgroups with content show up in groupList() - //QEXPECT_FAIL("", "Empty subgroups do not show up in groupList()", Continue); - //QCOMPARE(neg.groupList(), QStringList() << "NEG Child1" << "NEG Child2" << "NEG Child3" << "NEG Child4"); + // QEXPECT_FAIL("", "Empty subgroups do not show up in groupList()", Continue); + // QCOMPARE(neg.groupList(), QStringList() << "NEG Child1" << "NEG Child2" << "NEG Child3" << "NEG Child4"); // This is what happens QStringList groups = neg.groupList(); groups.sort(); // Qt5 made the ordering unreliable, due to QHash @@ -1332,7 +1334,7 @@ void KConfigTest::testReparent() QCOMPARE(group.entryMap(), originalMap); group.reparent(&cf); // see if it can make it a top-level group again -// QVERIFY(!parent.hasGroup(name)); + // QVERIFY(!parent.hasGroup(name)); QCOMPARE(group.entryMap(), originalMap); } @@ -1377,8 +1379,7 @@ void KConfigTest::testWriteOnSync() // Add a global entry and sync the config. // Should not rewrite the local config file. KConfigGroup cgGlobal(&sc, "Globals"); - cgGlobal.writeEntry("someGlobalString", "whatever", - KConfig::Persistent | KConfig::Global); + cgGlobal.writeEntry("someGlobalString", "whatever", KConfig::Persistent | KConfig::Global); QVERIFY(sc.sync()); // Verify that the timestamp of local config file didn't change. @@ -1436,8 +1437,14 @@ void KConfigTest::testDirtyOnEqual() void KConfigTest::testDirtyOnEqualOverdo() { - QByteArray val1("\0""one", 4); - QByteArray val2("\0""two", 4); + QByteArray val1( + "\0" + "one", + 4); + QByteArray val2( + "\0" + "two", + 4); QByteArray defvalr; KConfig sc(s_kconfig_test_subdir); @@ -1624,7 +1631,7 @@ void KConfigTest::testDeleteWhenLocalized() QVERIFY(config.sync()); // Current state: [ca] and [de] entries left... oops. - //qDebug() << readLinesFrom(file); + // qDebug() << readLinesFrom(file); // Bug: The group still exists [because of the localized entries]... QVERIFY(cg.exists()); @@ -1732,7 +1739,17 @@ void KConfigTest::testQByteArrayUtf8() file.close(); QFile readFile(file.fileName()); QVERIFY(readFile.open(QFile::ReadOnly)); -#define VALUE "Utf8=\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\t\\n\\x0b\\x0c\\r\\x0e\\x0f\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\x7f\\x80\\x81\\x82\\x83\\x84\\x85\\x86\\x87\\x88\\x89\\x8a\\x8b\\x8c\\x8d\\x8e\\x8f\\x90\\x91\\x92\\x93\\x94\\x95\\x96\\x97\\x98\\x99\\x9a\\x9b\\x9c\\x9d\\x9e\\x9f\\xa0\\xa1\\xa2\\xa3\\xa4\\xa5\\xa6\\xa7\\xa8\\xa9\\xaa\\xab\\xac\\xad\\xae\\xaf\\xb0\\xb1\\xb2\\xb3\\xb4\\xb5\\xb6\\xb7\\xb8\\xb9\\xba\\xbb\\xbc\\xbd\\xbe\\xbf\\xc0\\xc1\\xc2\\xc3\\xc4\\xc5\\xc6\\xc7\\xc8\\xc9\\xca\\xcb\\xcc\\xcd\\xce\\xcf\\xd0\\xd1\\xd2\\xd3\\xd4\\xd5\\xd6\\xd7\\xd8\\xd9\\xda\\xdb\\xdc\\xdd\\xde\\xdf\\xe0\\xe1\\xe2\\xe3\\xe4\\xe5\\xe6\\xe7\\xe8\\xe9\\xea\\xeb\\xec\\xed\\xee\\xef\\xf0\\xf1\\xf2\\xf3\\xf4\\xf5\\xf6\\xf7\\xf8\\xf9\\xfa\\xfb\\xfc\\xfd\\xfe\\xff" +#define VALUE \ + "Utf8=" \ + "\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\t\\n\\x0b\\x0c\\r\\x0e\\x0f\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x" \ + "1f " \ + "!\"#$%&'()*+,-./" \ + "0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" \ + "\\x7f\\x80\\x81\\x82\\x83\\x84\\x85\\x86\\x87\\x88\\x89\\x8a\\x8b\\x8c\\x8d\\x8e\\x8f\\x90\\x91\\x92\\x93\\x94\\x95\\x96\\x97\\x98\\x99\\x9a\\x9b\\x9c\\" \ + "x9d\\x9e\\x9f\\xa0\\xa1\\xa2\\xa3\\xa4\\xa5\\xa6\\xa7\\xa8\\xa9\\xaa\\xab\\xac\\xad\\xae\\xaf\\xb0\\xb1\\xb2\\xb3\\xb4\\xb5\\xb6\\xb7\\xb8\\xb9\\xba\\xb" \ + "b\\xbc\\xbd\\xbe\\xbf\\xc0\\xc1\\xc2\\xc3\\xc4\\xc5\\xc6\\xc7\\xc8\\xc9\\xca\\xcb\\xcc\\xcd\\xce\\xcf\\xd0\\xd1\\xd2\\xd3\\xd4\\xd5\\xd6\\xd7\\xd8\\xd9" \ + "\\xda\\xdb\\xdc\\xdd\\xde\\xdf\\xe0\\xe1\\xe2\\xe3\\xe4\\xe5\\xe6\\xe7\\xe8\\xe9\\xea\\xeb\\xec\\xed\\xee\\xef\\xf0\\xf1\\xf2\\xf3\\xf4\\xf5\\xf6\\xf7\\" \ + "xf8\\xf9\\xfa\\xfb\\xfc\\xfd\\xfe\\xff" const QByteArray fileBytes = readFile.readAll(); #ifndef Q_OS_WIN QCOMPARE(fileBytes, QByteArrayLiteral("[General]\n" VALUE "\n")); @@ -1815,7 +1832,6 @@ void KConfigTest::testNewlines() #else QCOMPARE(readFile.readAll(), QByteArrayLiteral("[General]\r\nBar=Foo\r\nFoo=Bar\r\n")); #endif - } void KConfigTest::testXdgListEntry() @@ -1823,7 +1839,7 @@ void KConfigTest::testXdgListEntry() QTemporaryFile file; QVERIFY(file.open()); QTextStream out(&file); - out << "[General]\n" + out << "[General]\n" << "Key1=\n" // empty list // emtpty entries << "Key2=;\n" @@ -1852,7 +1868,7 @@ void KConfigTest::testXdgListEntry() void KConfigTest::testThreads() { QThreadPool::globalInstance()->setMaxThreadCount(6); - QList > futures; + QList> futures; // Run in parallel some tests that work on different config files, // otherwise unexpected things might indeed happen. futures << QtConcurrent::run(this, &KConfigTest::testAddConfigSources); @@ -1861,8 +1877,8 @@ void KConfigTest::testThreads() futures << QtConcurrent::run(this, &KConfigTest::testSharedConfig); futures << QtConcurrent::run(this, &KConfigTest::testSharedConfig); // QEXPECT_FAIL triggers race conditions, it should be fixed to use QThreadStorage... - //futures << QtConcurrent::run(this, &KConfigTest::testDeleteWhenLocalized); - //futures << QtConcurrent::run(this, &KConfigTest::testEntryMap); + // futures << QtConcurrent::run(this, &KConfigTest::testDeleteWhenLocalized); + // futures << QtConcurrent::run(this, &KConfigTest::testEntryMap); for (QFuture f : qAsConst(futures)) { f.waitForFinished(); } @@ -1877,28 +1893,28 @@ void KConfigTest::testNotify() KConfig config(s_kconfig_test_subdir); auto myConfigGroup = KConfigGroup(&config, "TopLevelGroup"); - //mimics a config in another process, which is watching for events + // mimics a config in another process, which is watching for events auto remoteConfig = KSharedConfig::openConfig(s_kconfig_test_subdir); KConfigWatcher::Ptr watcher = KConfigWatcher::create(remoteConfig); - //some random config that shouldn't be changing when kconfigtest changes, only on kdeglobals + // some random config that shouldn't be changing when kconfigtest changes, only on kdeglobals auto otherRemoteConfig = KSharedConfig::openConfig(s_test_subdir + QLatin1String("kconfigtest2")); KConfigWatcher::Ptr otherWatcher = KConfigWatcher::create(otherRemoteConfig); QSignalSpy watcherSpy(watcher.data(), &KConfigWatcher::configChanged); QSignalSpy otherWatcherSpy(otherWatcher.data(), &KConfigWatcher::configChanged); - //write entries in a group and subgroup - myConfigGroup.writeEntry("entryA", "foo", KConfig::Persistent | KConfig::Notify); + // write entries in a group and subgroup + myConfigGroup.writeEntry("entryA", "foo", KConfig::Persistent | KConfig::Notify); auto subGroup = myConfigGroup.group("aSubGroup"); - subGroup.writeEntry("entry1", "foo", KConfig::Persistent | KConfig::Notify); - subGroup.writeEntry("entry2", "foo", KConfig::Persistent | KConfig::Notify); + subGroup.writeEntry("entry1", "foo", KConfig::Persistent | KConfig::Notify); + subGroup.writeEntry("entry2", "foo", KConfig::Persistent | KConfig::Notify); config.sync(); watcherSpy.wait(); QCOMPARE(watcherSpy.count(), 2); - std::sort(watcherSpy.begin(), watcherSpy.end(), [] (QList a, QList b) { - return a[0].value().name() < b[0].value().name(); + std::sort(watcherSpy.begin(), watcherSpy.end(), [](QList a, QList b) { + return a[0].value().name() < b[0].value().name(); }); QCOMPARE(watcherSpy[0][0].value().name(), QStringLiteral("TopLevelGroup")); @@ -1908,7 +1924,7 @@ void KConfigTest::testNotify() QCOMPARE(watcherSpy[1][0].value().parent().name(), QStringLiteral("TopLevelGroup")); QCOMPARE(watcherSpy[1][1].value(), QByteArrayList({"entry1", "entry2"})); - //delete an entry + // delete an entry watcherSpy.clear(); myConfigGroup.deleteEntry("entryA", KConfig::Persistent | KConfig::Notify); config.sync(); @@ -1917,7 +1933,7 @@ void KConfigTest::testNotify() QCOMPARE(watcherSpy[0][0].value().name(), QStringLiteral("TopLevelGroup")); QCOMPARE(watcherSpy[0][1].value(), QByteArrayList({"entryA"})); - //revert to default an entry + // revert to default an entry watcherSpy.clear(); myConfigGroup.revertToDefault("entryA", KConfig::Persistent | KConfig::Notify); config.sync(); @@ -1926,7 +1942,7 @@ void KConfigTest::testNotify() QCOMPARE(watcherSpy[0][0].value().name(), QStringLiteral("TopLevelGroup")); QCOMPARE(watcherSpy[0][1].value(), QByteArrayList({"entryA"})); - //deleting a group, should notify that every entry in that group has changed + // deleting a group, should notify that every entry in that group has changed watcherSpy.clear(); myConfigGroup.deleteGroup("aSubGroup", KConfig::Persistent | KConfig::Notify); config.sync(); @@ -1935,16 +1951,16 @@ void KConfigTest::testNotify() QCOMPARE(watcherSpy[0][0].value().name(), QStringLiteral("aSubGroup")); QCOMPARE(watcherSpy[0][1].value(), QByteArrayList({"entry1", "entry2"})); - //global write still triggers our notification + // global write still triggers our notification watcherSpy.clear(); - myConfigGroup.writeEntry("someGlobalEntry", "foo", KConfig::Persistent | KConfig::Notify | KConfig::Global); + myConfigGroup.writeEntry("someGlobalEntry", "foo", KConfig::Persistent | KConfig::Notify | KConfig::Global); config.sync(); watcherSpy.wait(); QCOMPARE(watcherSpy.count(), 1); QCOMPARE(watcherSpy[0][0].value().name(), QStringLiteral("TopLevelGroup")); QCOMPARE(watcherSpy[0][1].value(), QByteArrayList({"someGlobalEntry"})); - //watching another file should have only triggered from the kdeglobals change + // watching another file should have only triggered from the kdeglobals change QCOMPARE(otherWatcherSpy.count(), 1); QCOMPARE(otherWatcherSpy[0][0].value().name(), QStringLiteral("TopLevelGroup")); QCOMPARE(otherWatcherSpy[0][1].value(), QByteArrayList({"someGlobalEntry"})); diff --git a/autotests/kconfigtest.h b/autotests/kconfigtest.h index cb6e3712..d6502331 100644 --- a/autotests/kconfigtest.h +++ b/autotests/kconfigtest.h @@ -14,9 +14,18 @@ class KConfigTest : public QObject Q_OBJECT public: - enum Testing { Ones = 1, Tens = 10, Hundreds = 100,}; + enum Testing { + Ones = 1, + Tens = 10, + Hundreds = 100, + }; Q_ENUM(Testing) - enum bits { bit0 = 1, bit1 = 2, bit2 = 4, bit3 = 8, }; + enum bits { + bit0 = 1, + bit1 = 2, + bit2 = 4, + bit3 = 8, + }; Q_DECLARE_FLAGS(Flags, bits) Q_FLAG(Flags) diff --git a/autotests/kdesktopfiletest.cpp b/autotests/kdesktopfiletest.cpp index e45ba44e..cadc3b3d 100644 --- a/autotests/kdesktopfiletest.cpp +++ b/autotests/kdesktopfiletest.cpp @@ -29,13 +29,12 @@ void KDesktopFileTest::testRead() QVERIFY(file.open()); const QString fileName = file.fileName(); QTextStream ts(&file); - ts << - "[Desktop Entry]\n" - "Type= Application\n" - "Name=My Application\n" - "Icon = foo\n" - "MimeType =text/plain;image/png;\n" - "\n"; + ts << "[Desktop Entry]\n" + "Type= Application\n" + "Name=My Application\n" + "Icon = foo\n" + "MimeType =text/plain;image/png;\n" + "\n"; file.close(); QVERIFY(QFile::exists(fileName)); QVERIFY(KDesktopFile::isDesktopFile(fileName)); @@ -44,8 +43,7 @@ void KDesktopFileTest::testRead() QVERIFY(df.hasApplicationType()); QCOMPARE(df.readName(), QString::fromLatin1("My Application")); QCOMPARE(df.readIcon(), QString::fromLatin1("foo")); - QCOMPARE(df.readMimeTypes(), QStringList() << QString::fromLatin1("text/plain") - << QString::fromLatin1("image/png")); + QCOMPARE(df.readMimeTypes(), QStringList() << QString::fromLatin1("text/plain") << QString::fromLatin1("image/png")); QVERIFY(!df.hasLinkType()); QCOMPARE(df.fileName(), QFileInfo(fileName).canonicalFilePath()); } @@ -57,17 +55,15 @@ void KDesktopFileTest::testReadDirectory() QVERIFY(file.open()); const QString fileName = file.fileName(); QTextStream ts(&file); - ts << - "[Desktop Entry]\n" - "Type=Directory\n" - "SortOrder=2.desktop;1.desktop;\n" - "\n"; + ts << "[Desktop Entry]\n" + "Type=Directory\n" + "SortOrder=2.desktop;1.desktop;\n" + "\n"; file.close(); QVERIFY(QFile::exists(fileName)); KDesktopFile df(fileName); QCOMPARE(df.readType(), QString::fromLatin1("Directory")); - QCOMPARE(df.sortOrder(), QStringList() << QString::fromLatin1("2.desktop") - << QString::fromLatin1("1.desktop")); + QCOMPARE(df.sortOrder(), QStringList() << QString::fromLatin1("2.desktop") << QString::fromLatin1("1.desktop")); } #endif @@ -77,19 +73,19 @@ void KDesktopFileTest::testReadLocalized_data() QTest::addColumn("translation"); const QString german = QStringLiteral("Meine Anwendung"); - const QString swiss = QStringLiteral("Mein Anwendungsli"); + const QString swiss = QStringLiteral("Mein Anwendungsli"); - QTest::newRow("de") << QLocale(QLocale::German) << german; - QTest::newRow("de_DE") << QLocale(QStringLiteral("de_DE")) << german; + QTest::newRow("de") << QLocale(QLocale::German) << german; + QTest::newRow("de_DE") << QLocale(QStringLiteral("de_DE")) << german; QTest::newRow("de_DE@bayern") << QLocale(QStringLiteral("de_DE@bayern")) << german; - QTest::newRow("de@bayern") << QLocale(QStringLiteral("de@bayern")) << german; - QTest::newRow("de@freiburg") << QLocale(QStringLiteral("de@freiburg")) << QStringLiteral("Mein Anwendungsle"); + QTest::newRow("de@bayern") << QLocale(QStringLiteral("de@bayern")) << german; + QTest::newRow("de@freiburg") << QLocale(QStringLiteral("de@freiburg")) << QStringLiteral("Mein Anwendungsle"); // For CH we have a special translation - QTest::newRow("de_CH") << QLocale(QLocale::German, QLocale::Switzerland) << swiss; - QTest::newRow("de_CH@bern") << QLocale(QStringLiteral("de_CH@bern")) << swiss; + QTest::newRow("de_CH") << QLocale(QLocale::German, QLocale::Switzerland) << swiss; + QTest::newRow("de_CH@bern") << QLocale(QStringLiteral("de_CH@bern")) << swiss; // Austria should fall back to "de" - QTest::newRow("de_AT") << QLocale(QLocale::German, QLocale::Austria) << german; - QTest::newRow("de_AT@tirol") << QLocale(QStringLiteral("de_AT@tirol")) << german; + QTest::newRow("de_AT") << QLocale(QLocale::German, QLocale::Austria) << german; + QTest::newRow("de_AT@tirol") << QLocale(QStringLiteral("de_AT@tirol")) << german; // no translation for French QTest::newRow("fr") << QLocale(QLocale::French) << QStringLiteral("My Application"); } @@ -100,15 +96,14 @@ void KDesktopFileTest::testReadLocalized() QVERIFY(file.open()); const QString fileName = file.fileName(); QTextStream ts(&file); - ts << - "[Desktop Entry]\n" - "Type=Application\n" - "Name=My Application\n" - "Name[de]=Meine Anwendung\n" - "Name[de@freiburg]=Mein Anwendungsle\n" - "Name[de_CH]=Mein Anwendungsli\n" - "Icon=foo\n" - "\n"; + ts << "[Desktop Entry]\n" + "Type=Application\n" + "Name=My Application\n" + "Name[de]=Meine Anwendung\n" + "Name[de@freiburg]=Mein Anwendungsle\n" + "Name[de_CH]=Mein Anwendungsli\n" + "Icon=foo\n" + "\n"; file.close(); QVERIFY(QFile::exists(fileName)); QVERIFY(KDesktopFile::isDesktopFile(fileName)); @@ -129,10 +124,9 @@ void KDesktopFileTest::testSuccessfulTryExec() QVERIFY(file.open()); const QString fileName = file.fileName(); QTextStream ts(&file); - ts << - "[Desktop Entry]\n" - "TryExec=whoami\n" - "\n"; + ts << "[Desktop Entry]\n" + "TryExec=whoami\n" + "\n"; file.close(); QVERIFY(QFile::exists(fileName)); KDesktopFile df(fileName); @@ -145,10 +139,9 @@ void KDesktopFileTest::testUnsuccessfulTryExec() QVERIFY(file.open()); const QString fileName = file.fileName(); QTextStream ts(&file); - ts << - "[Desktop Entry]\n" - "TryExec=/does/not/exist\n" - "\n"; + ts << "[Desktop Entry]\n" + "TryExec=/does/not/exist\n" + "\n"; file.close(); QVERIFY(QFile::exists(fileName)); KDesktopFile df(fileName); @@ -161,18 +154,17 @@ void KDesktopFileTest::testActionGroup() QVERIFY(file.open()); const QString fileName = file.fileName(); QTextStream ts(&file); - ts << - "[Desktop Entry]\n" - // make sure escaping of ';' using "\;" works - "Actions=encrypt;semi\\;colon;decrypt;\n" - "[Desktop Action encrypt]\n" - "Name=Encrypt file\n" - "[Desktop Action decrypt]\n" - "Name=Decrypt file\n" - // no escaping needed in group header - "[Desktop Action semi;colon]\n" - "Name=With semicolon\n" - "\n"; + ts << "[Desktop Entry]\n" + // make sure escaping of ';' using "\;" works + "Actions=encrypt;semi\\;colon;decrypt;\n" + "[Desktop Action encrypt]\n" + "Name=Encrypt file\n" + "[Desktop Action decrypt]\n" + "Name=Decrypt file\n" + // no escaping needed in group header + "[Desktop Action semi;colon]\n" + "Name=With semicolon\n" + "\n"; file.close(); QVERIFY(QFile::exists(fileName)); KDesktopFile df(fileName); @@ -200,12 +192,11 @@ void KDesktopFileTest::testIsAuthorizedDesktopFile() QVERIFY(file.open()); const QString fileName = file.fileName(); QTextStream ts(&file); - ts << - "[Desktop Entry]\n" - "Type=Application\n" - "Name=My Application\n" - "Exec=kfoo\n" - "\n"; + ts << "[Desktop Entry]\n" + "Type=Application\n" + "Name=My Application\n" + "Exec=kfoo\n" + "\n"; file.close(); QVERIFY(QFile::exists(fileName)); QVERIFY(!KDesktopFile::isAuthorizedDesktopFile(fileName)); @@ -232,14 +223,13 @@ void KDesktopFileTest::testTryExecWithAuthorizeAction() QVERIFY(file.open()); const QString fileName = file.fileName(); QTextStream ts(&file); - ts << - "[Desktop Entry]\n" - "Type=Application\n" - "Name=My Application\n" - "Exec=kfoo\n" - "TryExec=bash\n" - "X-KDE-AuthorizeAction=someAction" - "\n"; + ts << "[Desktop Entry]\n" + "Type=Application\n" + "Name=My Application\n" + "Exec=kfoo\n" + "TryExec=bash\n" + "X-KDE-AuthorizeAction=someAction" + "\n"; file.close(); KDesktopFile desktopFile(fileName); @@ -250,14 +240,13 @@ void KDesktopFileTest::testTryExecWithAuthorizeAction() QVERIFY(file.open()); const QString fileName = file.fileName(); QTextStream ts(&file); - ts << - "[Desktop Entry]\n" - "Type=Application\n" - "Name=My Application\n" - "Exec=kfoo\n" - "TryExec=bash\n" - "X-KDE-AuthorizeAction=someBlockedAction" - "\n"; + ts << "[Desktop Entry]\n" + "Type=Application\n" + "Name=My Application\n" + "Exec=kfoo\n" + "TryExec=bash\n" + "X-KDE-AuthorizeAction=someBlockedAction" + "\n"; file.close(); KDesktopFile desktopFile(fileName); diff --git a/autotests/kdesktopfiletest.h b/autotests/kdesktopfiletest.h index 1ab1498c..6bf97bf8 100644 --- a/autotests/kdesktopfiletest.h +++ b/autotests/kdesktopfiletest.h @@ -28,7 +28,6 @@ private Q_SLOTS: void testTryExecWithAuthorizeAction(); void testLocateLocal_data(); void testLocateLocal(); - }; #endif /* KDESKTOPFILETEST_H */ diff --git a/autotests/kentrymaptest.h b/autotests/kentrymaptest.h index b1bcea74..faf3ad6d 100644 --- a/autotests/kentrymaptest.h +++ b/autotests/kentrymaptest.h @@ -7,8 +7,8 @@ #ifndef KENTRYMAPTEST_H #define KENTRYMAPTEST_H -#include #include "kconfigdata.h" +#include class KEntryMapTest : public QObject { diff --git a/autotests/ksharedconfig_in_global_object.cpp b/autotests/ksharedconfig_in_global_object.cpp index aab982c2..4d9b07d3 100644 --- a/autotests/ksharedconfig_in_global_object.cpp +++ b/autotests/ksharedconfig_in_global_object.cpp @@ -6,10 +6,10 @@ */ #include -#include #include -#include +#include #include +#include #include class Tester diff --git a/autotests/ksharedconfigtest.cpp b/autotests/ksharedconfigtest.cpp index 957b509f..06ed7898 100644 --- a/autotests/ksharedconfigtest.cpp +++ b/autotests/ksharedconfigtest.cpp @@ -6,8 +6,8 @@ */ #include -#include #include +#include class KSharedConfigTest : public QObject { @@ -18,6 +18,7 @@ private Q_SLOTS: void testReadWrite(); void testReadWriteSync(); void testQrcFile(); + private: QString m_path; }; @@ -26,8 +27,8 @@ void KSharedConfigTest::initTestCase() { QStandardPaths::setTestModeEnabled(true); - m_path = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) - + QLatin1Char('/') + QCoreApplication::applicationName() + QStringLiteral("rc"); + m_path = + QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1Char('/') + QCoreApplication::applicationName() + QStringLiteral("rc"); QFile::remove(m_path); } diff --git a/autotests/kstandardshortcuttest.cpp b/autotests/kstandardshortcuttest.cpp index 1b7f88ff..cafad63f 100644 --- a/autotests/kstandardshortcuttest.cpp +++ b/autotests/kstandardshortcuttest.cpp @@ -4,10 +4,10 @@ SPDX-License-Identifier: LGPL-2.0-or-later */ -#include #include "kstandardshortcuttest.h" +#include -QTEST_MAIN(KStandardShortcutTest) // GUI needed by KAccel +QTEST_MAIN(KStandardShortcutTest) // GUI needed by KAccel #include diff --git a/autotests/test_kconf_update.cpp b/autotests/test_kconf_update.cpp index f08e06ca..565a86f8 100644 --- a/autotests/test_kconf_update.cpp +++ b/autotests/test_kconf_update.cpp @@ -9,13 +9,13 @@ #include // Qt -#include +#include "config-kconf.h" #include -#include +#include #include -#include +#include #include -#include "config-kconf.h" +#include #include @@ -80,225 +80,146 @@ void TestKConfUpdate::test_data() QTest::addColumn("useVersion5"); QTest::addColumn("shouldUpdateWork"); - QTest::newRow("moveKeysSameFile") - << - "File=testrc\n" - "Group=group\n" - "Key=old,new\n" - "Options=overwrite\n" - << - "testrc" - << - "[group]\n" - "old=value\n" - << - "testrc" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group]\n" - "new=value\n" - << - "" - << true - << true - ; - QTest::newRow("moveKeysOtherFile") - << - "File=oldrc,newrc\n" - "Group=group1,group2\n" - "Key=old,new\n" - "Options=overwrite\n" - << - "oldrc" - << - "[group1]\n" - "old=value\n" - "[stay]\n" - "foo=bar\n" - << - "newrc" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group2]\n" - "new=value\n" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[stay]\n" - "foo=bar\n" - << true - << true - ; - QTest::newRow("allKeys") - << - "File=testrc\n" - "Group=group1,group2\n" - "AllKeys\n" - << - "testrc" - << - "[group1]\n" - "key1=value1\n" - "key2=value2\n" - "\n" - "[stay]\n" - "foo=bar\n" - << - "testrc" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group2]\n" - "key1=value1\n" - "key2=value2\n" - "\n" - "[stay]\n" - "foo=bar\n" - << - "" - << true - << true - ; - QTest::newRow("allKeysSubGroup") - << - "File=testrc\n" - "Group=[group][sub1],[group][sub2]\n" - "AllKeys\n" - << - "testrc" - << - "[group][sub1]\n" - "key1=value1\n" - "key2=value2\n" - "\n" - "[group][sub1][subsub]\n" - "key3=value3\n" - "key4=value4\n" - "\n" - "[stay]\n" - "foo=bar\n" - << - "testrc" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group][sub2]\n" - "key1=value1\n" - "key2=value2\n" - "\n" - "[group][sub2][subsub]\n" - "key3=value3\n" - "key4=value4\n" - "\n" - "[stay]\n" - "foo=bar\n" - << - "" - << true - << true - ; - QTest::newRow("removeGroup") - << - "File=testrc\n" - "RemoveGroup=remove\n" - << - "testrc" - << - "[keep]\n" - "key=value\n" - "" - "[remove]\n" - "key=value\n" - << - "testrc" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[keep]\n" - "key=value\n" - << - "" - << true - << true - ; - QTest::newRow("moveKeysSameFileDontExist") - << - "File=testrc\n" - "Group=group,group2\n" - "Key=key1\n" - "Key=key2\n" - << - "testrc" - << - "[group]\n" - "key1=value1\n" - "key3=value3\n" - << - "testrc" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group]\n" - "key3=value3\n" - "\n" - "[group2]\n" - "key1=value1\n" - << - "" - << true - << true - ; - QTest::newRow("DontMigrateWhenFileDoesntHaveVersion") - << - "File=testrc\n" - "Group=group\n" - "Key=old,new\n" - "Options=overwrite\n" - << - "testrc" - << - "[group]\n" - "old=value\n" - << - "testrc" - << - "[group]\n" - "old=value\n" - << - "" - << false - << false - ; - - QTest::newRow("DontMigrateWhenUpdateCantDoItMissingFilename") - << - "Group=group\n" - "Key=old,new\n" - "Options=overwrite\n" - << - "testrc" - << - "[group]\n" - "old=value\n" - << - "testrc" - << - "[group]\n" - "old=value\n" - << - "" - << true - << false - ; + QTest::newRow("moveKeysSameFile") << "File=testrc\n" + "Group=group\n" + "Key=old,new\n" + "Options=overwrite\n" + << "testrc" + << "[group]\n" + "old=value\n" + << "testrc" + << "[$Version]\n" + "update_info=%1\n" + "\n" + "[group]\n" + "new=value\n" + << "" << true << true; + QTest::newRow("moveKeysOtherFile") << "File=oldrc,newrc\n" + "Group=group1,group2\n" + "Key=old,new\n" + "Options=overwrite\n" + << "oldrc" + << "[group1]\n" + "old=value\n" + "[stay]\n" + "foo=bar\n" + << "newrc" + << "[$Version]\n" + "update_info=%1\n" + "\n" + "[group2]\n" + "new=value\n" + << "[$Version]\n" + "update_info=%1\n" + "\n" + "[stay]\n" + "foo=bar\n" + << true << true; + QTest::newRow("allKeys") << "File=testrc\n" + "Group=group1,group2\n" + "AllKeys\n" + << "testrc" + << "[group1]\n" + "key1=value1\n" + "key2=value2\n" + "\n" + "[stay]\n" + "foo=bar\n" + << "testrc" + << "[$Version]\n" + "update_info=%1\n" + "\n" + "[group2]\n" + "key1=value1\n" + "key2=value2\n" + "\n" + "[stay]\n" + "foo=bar\n" + << "" << true << true; + QTest::newRow("allKeysSubGroup") << "File=testrc\n" + "Group=[group][sub1],[group][sub2]\n" + "AllKeys\n" + << "testrc" + << "[group][sub1]\n" + "key1=value1\n" + "key2=value2\n" + "\n" + "[group][sub1][subsub]\n" + "key3=value3\n" + "key4=value4\n" + "\n" + "[stay]\n" + "foo=bar\n" + << "testrc" + << "[$Version]\n" + "update_info=%1\n" + "\n" + "[group][sub2]\n" + "key1=value1\n" + "key2=value2\n" + "\n" + "[group][sub2][subsub]\n" + "key3=value3\n" + "key4=value4\n" + "\n" + "[stay]\n" + "foo=bar\n" + << "" << true << true; + QTest::newRow("removeGroup") << "File=testrc\n" + "RemoveGroup=remove\n" + << "testrc" + << "[keep]\n" + "key=value\n" + "" + "[remove]\n" + "key=value\n" + << "testrc" + << "[$Version]\n" + "update_info=%1\n" + "\n" + "[keep]\n" + "key=value\n" + << "" << true << true; + QTest::newRow("moveKeysSameFileDontExist") << "File=testrc\n" + "Group=group,group2\n" + "Key=key1\n" + "Key=key2\n" + << "testrc" + << "[group]\n" + "key1=value1\n" + "key3=value3\n" + << "testrc" + << "[$Version]\n" + "update_info=%1\n" + "\n" + "[group]\n" + "key3=value3\n" + "\n" + "[group2]\n" + "key1=value1\n" + << "" << true << true; + QTest::newRow("DontMigrateWhenFileDoesntHaveVersion") << "File=testrc\n" + "Group=group\n" + "Key=old,new\n" + "Options=overwrite\n" + << "testrc" + << "[group]\n" + "old=value\n" + << "testrc" + << "[group]\n" + "old=value\n" + << "" << false << false; + + QTest::newRow("DontMigrateWhenUpdateCantDoItMissingFilename") << "Group=group\n" + "Key=old,new\n" + "Options=overwrite\n" + << "testrc" + << "[group]\n" + "old=value\n" + << "testrc" + << "[group]\n" + "old=value\n" + << "" << true << false; } void TestKConfUpdate::test() @@ -362,238 +283,172 @@ void TestKConfUpdate::testScript_data() QTest::addColumn("oldConfContent"); QTest::addColumn("expectedNewConfContent"); - QTest::newRow("delete-key") - << - "File=testrc\n" - "Group=group\n" - "Script=test.sh,sh\n" - << - "echo '# DELETE deprecated'\n" - << - "[group]\n" - "deprecated=foo\n" - "valid=bar\n" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group]\n" - "valid=bar\n" - ; - - QTest::newRow("delete-key2") - << - "File=testrc\n" - "Script=test.sh,sh\n" - << - "echo '# DELETE [group]deprecated'\n" - "echo '# DELETE [group][sub]deprecated2'\n" - << - "[group]\n" - "deprecated=foo\n" - "valid=bar\n" - "\n" - "[group][sub]\n" - "deprecated2=foo\n" - "valid2=bar\n" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group]\n" - "valid=bar\n" - "\n" - "[group][sub]\n" - "valid2=bar\n" - ; - - QTest::newRow("delete-group") - << - "File=testrc\n" - "Script=test.sh,sh\n" - << - "echo '# DELETEGROUP [group1]'\n" - "echo '# DELETEGROUP [group2][sub]'\n" - << - "[group1]\n" - "key=value\n" - "\n" - "[group2]\n" - "valid=bar\n" - "\n" - "[group2][sub]\n" - "key=value\n" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group2]\n" - "valid=bar\n" - ; - - QTest::newRow("delete-group2") - << - "File=testrc\n" - "Group=group\n" - "Script=test.sh,sh\n" - << - "echo '# DELETEGROUP'\n" - << - "[group]\n" - "key=value\n" - "\n" - "[group2]\n" - "valid=bar\n" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group2]\n" - "valid=bar\n" - ; - - QTest::newRow("new-key") - << - "File=testrc\n" - "Script=test.sh,sh\n" - << - "echo '[group]'\n" - "echo 'new=value'\n" - << - "[group]\n" - "valid=bar\n" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group]\n" - "new=value\n" - "valid=bar\n" - ; - - QTest::newRow("modify-key-no-overwrite") - << - "File=testrc\n" - "Script=test.sh,sh\n" - << - "echo '[group]'\n" - "echo 'existing=new'\n" - << - "[group]\n" - "existing=old\n" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group]\n" - "existing=old\n" - ; - - QTest::newRow("modify-key-overwrite") - << - "File=testrc\n" - "Options=overwrite\n" - "Script=test.sh,sh\n" - << - "echo '[group]'\n" - "echo 'existing=new'\n" - << - "[group]\n" - "existing=old\n" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group]\n" - "existing=new\n" - ; - - QTest::newRow("new-key-in-subgroup") - << - "File=testrc\n" - "Script=test.sh,sh\n" - << - "echo '[group][sub]'\n" - "echo 'new=value2'\n" - << - "[group][sub]\n" - "existing=foo\n" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group][sub]\n" - "existing=foo\n" - "new=value2\n" - ; - - QTest::newRow("new-key-in-subgroup2") - << - "File=testrc\n" - "Script=test.sh,sh\n" - << - "echo '[group][sub]'\n" - "echo 'new=value3'\n" - << - "[group][sub]\n" - "existing=foo\n" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group][sub]\n" - "existing=foo\n" - "new=value3\n" - ; + QTest::newRow("delete-key") << "File=testrc\n" + "Group=group\n" + "Script=test.sh,sh\n" + << "echo '# DELETE deprecated'\n" + << "[group]\n" + "deprecated=foo\n" + "valid=bar\n" + << "[$Version]\n" + "update_info=%1\n" + "\n" + "[group]\n" + "valid=bar\n"; + + QTest::newRow("delete-key2") << "File=testrc\n" + "Script=test.sh,sh\n" + << "echo '# DELETE [group]deprecated'\n" + "echo '# DELETE [group][sub]deprecated2'\n" + << "[group]\n" + "deprecated=foo\n" + "valid=bar\n" + "\n" + "[group][sub]\n" + "deprecated2=foo\n" + "valid2=bar\n" + << "[$Version]\n" + "update_info=%1\n" + "\n" + "[group]\n" + "valid=bar\n" + "\n" + "[group][sub]\n" + "valid2=bar\n"; + + QTest::newRow("delete-group") << "File=testrc\n" + "Script=test.sh,sh\n" + << "echo '# DELETEGROUP [group1]'\n" + "echo '# DELETEGROUP [group2][sub]'\n" + << "[group1]\n" + "key=value\n" + "\n" + "[group2]\n" + "valid=bar\n" + "\n" + "[group2][sub]\n" + "key=value\n" + << "[$Version]\n" + "update_info=%1\n" + "\n" + "[group2]\n" + "valid=bar\n"; + + QTest::newRow("delete-group2") << "File=testrc\n" + "Group=group\n" + "Script=test.sh,sh\n" + << "echo '# DELETEGROUP'\n" + << "[group]\n" + "key=value\n" + "\n" + "[group2]\n" + "valid=bar\n" + << "[$Version]\n" + "update_info=%1\n" + "\n" + "[group2]\n" + "valid=bar\n"; + + QTest::newRow("new-key") << "File=testrc\n" + "Script=test.sh,sh\n" + << "echo '[group]'\n" + "echo 'new=value'\n" + << "[group]\n" + "valid=bar\n" + << "[$Version]\n" + "update_info=%1\n" + "\n" + "[group]\n" + "new=value\n" + "valid=bar\n"; + + QTest::newRow("modify-key-no-overwrite") << "File=testrc\n" + "Script=test.sh,sh\n" + << "echo '[group]'\n" + "echo 'existing=new'\n" + << "[group]\n" + "existing=old\n" + << "[$Version]\n" + "update_info=%1\n" + "\n" + "[group]\n" + "existing=old\n"; + + QTest::newRow("modify-key-overwrite") << "File=testrc\n" + "Options=overwrite\n" + "Script=test.sh,sh\n" + << "echo '[group]'\n" + "echo 'existing=new'\n" + << "[group]\n" + "existing=old\n" + << "[$Version]\n" + "update_info=%1\n" + "\n" + "[group]\n" + "existing=new\n"; + + QTest::newRow("new-key-in-subgroup") << "File=testrc\n" + "Script=test.sh,sh\n" + << "echo '[group][sub]'\n" + "echo 'new=value2'\n" + << "[group][sub]\n" + "existing=foo\n" + << "[$Version]\n" + "update_info=%1\n" + "\n" + "[group][sub]\n" + "existing=foo\n" + "new=value2\n"; + + QTest::newRow("new-key-in-subgroup2") << "File=testrc\n" + "Script=test.sh,sh\n" + << "echo '[group][sub]'\n" + "echo 'new=value3'\n" + << "[group][sub]\n" + "existing=foo\n" + << "[$Version]\n" + "update_info=%1\n" + "\n" + "[group][sub]\n" + "existing=foo\n" + "new=value3\n"; if (QStandardPaths::findExecutable(QStringLiteral("sed")).isEmpty()) { qWarning("sed executable not found, cannot run all tests!"); } else { - QTest::newRow("filter") - << - "File=testrc\n" - "Script=test.sh,sh\n" - << - "echo '# DELETE [group]changed'\n" - "sed s/value/VALUE/\n" - << - "[group]\n" - "changed=value\n" - "unchanged=value\n" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group]\n" - "changed=VALUE\n" - "unchanged=value\n" - ; - - QTest::newRow("filter-subgroup") - << - "File=testrc\n" - "Script=test.sh,sh\n" - << - "echo '# DELETE [group][sub]changed'\n" - "sed s/value/VALUE/\n" - << - "[group]\n" - "unchanged=value\n" - "\n" - "[group][sub]\n" - "changed=value\n" - "unchanged=value\n" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group]\n" - "unchanged=value\n" - "\n" - "[group][sub]\n" - "changed=VALUE\n" - "unchanged=value\n" - ; + QTest::newRow("filter") << "File=testrc\n" + "Script=test.sh,sh\n" + << "echo '# DELETE [group]changed'\n" + "sed s/value/VALUE/\n" + << "[group]\n" + "changed=value\n" + "unchanged=value\n" + << "[$Version]\n" + "update_info=%1\n" + "\n" + "[group]\n" + "changed=VALUE\n" + "unchanged=value\n"; + + QTest::newRow("filter-subgroup") << "File=testrc\n" + "Script=test.sh,sh\n" + << "echo '# DELETE [group][sub]changed'\n" + "sed s/value/VALUE/\n" + << "[group]\n" + "unchanged=value\n" + "\n" + "[group][sub]\n" + "changed=value\n" + "unchanged=value\n" + << "[$Version]\n" + "update_info=%1\n" + "\n" + "[group]\n" + "unchanged=value\n" + "\n" + "[group][sub]\n" + "changed=VALUE\n" + "unchanged=value\n"; } } diff --git a/autotests/test_kconfigutils.cpp b/autotests/test_kconfigutils.cpp index 1e6c49f7..96959474 100644 --- a/autotests/test_kconfigutils.cpp +++ b/autotests/test_kconfigutils.cpp @@ -20,35 +20,16 @@ void TestKConfigUtils::testParseGroupString_data() QTest::addColumn("expected"); QTest::addColumn("expectedOk"); - QTest::newRow("simple-group") - << " group " - << (QStringList() << QStringLiteral("group")) - << true - ; - - QTest::newRow("sub-group") - << "[group][sub]" - << (QStringList() << QStringLiteral("group") << QStringLiteral("sub")) - << true - ; - - QTest::newRow("crazy-sub-group") - << "[a\\ttab\\x5d[and some hex esc\\x61pe]" - << (QStringList() << QStringLiteral("a\ttab") << QStringLiteral("and some hex escape")) - << true - ; - - QTest::newRow("missing-closing-brace") - << "[group][sub" - << QStringList() - << false - ; - - QTest::newRow("invalid-escape-string") - << "[a\\z]" - << QStringList() - << false - ; + QTest::newRow("simple-group") << " group " << (QStringList() << QStringLiteral("group")) << true; + + QTest::newRow("sub-group") << "[group][sub]" << (QStringList() << QStringLiteral("group") << QStringLiteral("sub")) << true; + + QTest::newRow("crazy-sub-group") << "[a\\ttab\\x5d[and some hex esc\\x61pe]" + << (QStringList() << QStringLiteral("a\ttab") << QStringLiteral("and some hex escape")) << true; + + QTest::newRow("missing-closing-brace") << "[group][sub" << QStringList() << false; + + QTest::newRow("invalid-escape-string") << "[a\\z]" << QStringList() << false; } void TestKConfigUtils::testParseGroupString() @@ -76,47 +57,26 @@ void TestKConfigUtils::testUnescapeString_data() QTest::addColumn("expected"); QTest::addColumn("expectedOk"); - QTest::newRow("plain") - << "Some text" - << "Some text" - << true - ; - - QTest::newRow("single-char-escapes") - << "01\\s23\\t45\\n67\\r89\\\\" - << "01 23\t45\n67\r89\\" - << true - ; - - QTest::newRow("hex-escapes") - << "kd\\x65" - << "kde" - << true - ; - - QTest::newRow("unfinished-hex-escape") - << "kd\\x6" - << "" - << false - ; - - QTest::newRow("invalid-hex-escape") - << "kd\\xzz" - << "" - << false - ; - - QTest::newRow("invalid-escape-sequence") - << "Foo\\a" - << "" - << false - ; - - QTest::newRow("unfinished-escape-sequence") - << "Foo\\" - << "" - << false - ; + QTest::newRow("plain") << "Some text" + << "Some text" << true; + + QTest::newRow("single-char-escapes") << "01\\s23\\t45\\n67\\r89\\\\" + << "01 23\t45\n67\r89\\" << true; + + QTest::newRow("hex-escapes") << "kd\\x65" + << "kde" << true; + + QTest::newRow("unfinished-hex-escape") << "kd\\x6" + << "" << false; + + QTest::newRow("invalid-hex-escape") << "kd\\xzz" + << "" << false; + + QTest::newRow("invalid-escape-sequence") << "Foo\\a" + << "" << false; + + QTest::newRow("unfinished-escape-sequence") << "Foo\\" + << "" << false; } void TestKConfigUtils::testUnescapeString() @@ -137,4 +97,3 @@ void TestKConfigUtils::testUnescapeString() qDebug() << error; } } - diff --git a/src/core/bufferfragment_p.h b/src/core/bufferfragment_p.h index 3edbb6b6..f75af1d6 100644 --- a/src/core/bufferfragment_p.h +++ b/src/core/bufferfragment_p.h @@ -24,14 +24,16 @@ class KConfigIniBackend::BufferFragment { - public: - - BufferFragment() : d(nullptr), len(0) + BufferFragment() + : d(nullptr) + , len(0) { } - BufferFragment(char *buf, int size) : d(buf), len(size) + BufferFragment(char *buf, int size) + : d(buf) + , len(size) { } @@ -184,7 +186,7 @@ class KConfigIniBackend::BufferFragment uint qHash(const KConfigIniBackend::BufferFragment fragment) { - const uchar *p = reinterpret_cast(fragment.constData()); + const uchar *p = reinterpret_cast(fragment.constData()); const int len = fragment.length(); // This algorithm is copied from qhash.cpp (Qt5 version). diff --git a/src/core/conversioncheck.h b/src/core/conversioncheck.h index 7f0e78a4..8537d81e 100644 --- a/src/core/conversioncheck.h +++ b/src/core/conversioncheck.h @@ -8,11 +8,11 @@ #ifndef CONVERSION_CHECK_H #define CONVERSION_CHECK_H -#include #include #include -#include #include +#include +#include #include class QColor; @@ -20,20 +20,21 @@ class QFont; namespace ConversionCheck { - // used to distinguish between supported/unsupported types -struct supported { }; -struct unsupported { }; +struct supported { +}; +struct unsupported { +}; // traits type class to define support for constraints -template +template struct QVconvertible { typedef unsupported toQString; typedef unsupported toQVariant; }; // constraint classes -template +template struct type_toQString { void constraint() { @@ -43,7 +44,7 @@ struct type_toQString { typename QVconvertible::toQString y; }; -template +template struct type_toQVariant { void constraint() { @@ -55,7 +56,7 @@ struct type_toQVariant { // check if T is convertible to QString thru QVariant // if not supported can't be used in QList functions -template +template inline void to_QString() { void (type_toQString::*x)() = &type_toQString::constraint; @@ -63,7 +64,7 @@ inline void to_QString() } // check if T is convertible to QVariant & supported in readEntry/writeEntry -template +template inline void to_QVariant() { void (type_toQVariant::*x)() = &type_toQVariant::constraint; @@ -74,10 +75,11 @@ inline void to_QVariant() // string_support - is supported by QVariant(type).toString(), // can be used in QList functions // variant_support - has a QVariant constructor -#define QVConversions(type, string_support, variant_support) \ - template <> struct QVconvertible {\ - typedef string_support toQString;\ - typedef variant_support toQVariant;\ +#define QVConversions(type, string_support, variant_support) \ + template<> \ + struct QVconvertible { \ + typedef string_support toQString; \ + typedef variant_support toQVariant; \ } // The only types needed here are the types handled in readEntry/writeEntry @@ -108,4 +110,3 @@ QVConversions(QList, unsupported, supported); } #endif - diff --git a/src/core/kauthorized.cpp b/src/core/kauthorized.cpp index 1abd83eb..a08586c5 100644 --- a/src/core/kauthorized.cpp +++ b/src/core/kauthorized.cpp @@ -15,41 +15,54 @@ #include #include // srand(), rand() #ifndef Q_OS_WIN -#include #include +#include #endif #include -#include #include +#include extern bool kde_kiosk_exception; class URLActionRule { public: -#define checkExactMatch(s, b) \ - if (s.isEmpty()) b = true; \ - else if (s[s.length()-1] == QLatin1Char('!')) \ - { b = false; s.chop(1); } \ - else b = true; -#define checkStartWildCard(s, b) \ - if (s.isEmpty()) b = true; \ - else if (s[0] == QLatin1Char('*')) \ - { b = true; s.remove(0, 1); } \ - else b = false; -#define checkEqual(s, b) \ - b = (s == QLatin1String("=")); +#define checkExactMatch(s, b) \ + if (s.isEmpty()) \ + b = true; \ + else if (s[s.length() - 1] == QLatin1Char('!')) { \ + b = false; \ + s.chop(1); \ + } else \ + b = true; +#define checkStartWildCard(s, b) \ + if (s.isEmpty()) \ + b = true; \ + else if (s[0] == QLatin1Char('*')) { \ + b = true; \ + s.remove(0, 1); \ + } else \ + b = false; +#define checkEqual(s, b) b = (s == QLatin1String("=")); URLActionRule(const QByteArray &act, - const QString &bProt, const QString &bHost, const QString &bPath, - const QString &dProt, const QString &dHost, const QString &dPath, + const QString &bProt, + const QString &bHost, + const QString &bPath, + const QString &dProt, + const QString &dHost, + const QString &dPath, bool perm) - : action(act), - baseProt(bProt), baseHost(bHost), basePath(bPath), - destProt(dProt), destHost(dHost), destPath(dPath), - permission(perm) + : action(act) + , baseProt(bProt) + , baseHost(bHost) + , basePath(bPath) + , destProt(dProt) + , destHost(dHost) + , destPath(dPath) + , permission(perm) { checkExactMatch(baseProt, baseProtWildCard); checkStartWildCard(baseHost, baseHostWildCard); @@ -64,13 +77,11 @@ class URLActionRule bool baseMatch(const QUrl &url, const QString &protClass) const { if (baseProtWildCard) { - if (!baseProt.isEmpty() && !url.scheme().startsWith(baseProt) && - (protClass.isEmpty() || (protClass != baseProt))) { + if (!baseProt.isEmpty() && !url.scheme().startsWith(baseProt) && (protClass.isEmpty() || (protClass != baseProt))) { return false; } } else { - if ((url.scheme() != baseProt) && - (protClass.isEmpty() || (protClass != baseProt))) { + if ((url.scheme() != baseProt) && (protClass.isEmpty() || (protClass != baseProt))) { return false; } } @@ -98,18 +109,15 @@ class URLActionRule bool destMatch(const QUrl &url, const QString &protClass, const QUrl &base, const QString &baseClass) const { if (destProtEqual) { - if ((url.scheme() != base.scheme()) && - (protClass.isEmpty() || baseClass.isEmpty() || protClass != baseClass)) { + if ((url.scheme() != base.scheme()) && (protClass.isEmpty() || baseClass.isEmpty() || protClass != baseClass)) { return false; } } else if (destProtWildCard) { - if (!destProt.isEmpty() && !url.scheme().startsWith(destProt) && - (protClass.isEmpty() || (protClass != destProt))) { + if (!destProt.isEmpty() && !url.scheme().startsWith(destProt) && (protClass.isEmpty() || (protClass != destProt))) { return false; } } else { - if ((url.scheme() != destProt) && - (protClass.isEmpty() || (protClass != destProt))) { + if ((url.scheme() != destProt) && (protClass.isEmpty() || (protClass != destProt))) { return false; } } @@ -151,8 +159,8 @@ class URLActionRule bool destProtWildCard : 1; bool destHostWildCard : 1; bool destPathWildCard : 1; - bool destProtEqual : 1; - bool destHostEqual : 1; + bool destProtEqual : 1; + bool destHostEqual : 1; bool permission; }; @@ -160,7 +168,8 @@ class KAuthorizedPrivate { public: KAuthorizedPrivate() - : actionRestrictions(false), blockEverything(false) + : actionRestrictions(false) + , blockEverything(false) { Q_ASSERT_X(QCoreApplication::instance(), "KAuthorizedPrivate()", "There has to be an existing QCoreApplication::instance() pointer"); @@ -185,12 +194,12 @@ class KAuthorizedPrivate }; Q_GLOBAL_STATIC(KAuthorizedPrivate, authPrivate) -#define MY_D KAuthorizedPrivate *d=authPrivate(); +#define MY_D KAuthorizedPrivate *d = authPrivate(); bool KAuthorized::authorize(const QString &genericAction) { - MY_D - if (d->blockEverything) { + MY_D if (d->blockEverything) + { return false; } @@ -204,8 +213,8 @@ bool KAuthorized::authorize(const QString &genericAction) bool KAuthorized::authorizeAction(const QString &action) { - MY_D - if (d->blockEverything) { + MY_D if (d->blockEverything) + { return false; } if (!d->actionRestrictions || action.isEmpty()) { @@ -235,8 +244,7 @@ QStringList KAuthorized::authorizeControlModules(const QStringList &menuIds) { KConfigGroup cg(KSharedConfig::openConfig(), "KDE Control Module Restrictions"); QStringList result; - for (QStringList::ConstIterator it = menuIds.begin(); - it != menuIds.end(); ++it) { + for (QStringList::ConstIterator it = menuIds.begin(); it != menuIds.end(); ++it) { if (cg.readEntry(*it, true)) { result.append(*it); } @@ -247,49 +255,37 @@ QStringList KAuthorized::authorizeControlModules(const QStringList &menuIds) // Exported for unittests (e.g. in KIO, we're missing tests for this in kconfig) KCONFIGCORE_EXPORT void loadUrlActionRestrictions(const KConfigGroup &cg) { - MY_D - const QString Any; + MY_D const QString Any; d->urlActionRestrictions.clear(); - d->urlActionRestrictions.append( - URLActionRule("open", Any, Any, Any, Any, Any, Any, true)); - d->urlActionRestrictions.append( - URLActionRule("list", Any, Any, Any, Any, Any, Any, true)); -// TEST: -// d->urlActionRestrictions.append( -// URLActionRule("list", Any, Any, Any, Any, Any, Any, false)); -// d->urlActionRestrictions.append( -// URLActionRule("list", Any, Any, Any, "file", Any, QDir::homePath(), true)); - d->urlActionRestrictions.append( - URLActionRule("link", Any, Any, Any, QStringLiteral(":internet"), Any, Any, true)); - d->urlActionRestrictions.append( - URLActionRule("redirect", Any, Any, Any, QStringLiteral(":internet"), Any, Any, true)); + d->urlActionRestrictions.append(URLActionRule("open", Any, Any, Any, Any, Any, Any, true)); + d->urlActionRestrictions.append(URLActionRule("list", Any, Any, Any, Any, Any, Any, true)); + // TEST: + // d->urlActionRestrictions.append( + // URLActionRule("list", Any, Any, Any, Any, Any, Any, false)); + // d->urlActionRestrictions.append( + // URLActionRule("list", Any, Any, Any, "file", Any, QDir::homePath(), true)); + d->urlActionRestrictions.append(URLActionRule("link", Any, Any, Any, QStringLiteral(":internet"), Any, Any, true)); + d->urlActionRestrictions.append(URLActionRule("redirect", Any, Any, Any, QStringLiteral(":internet"), Any, Any, true)); // We allow redirections to file: but not from internet protocols, redirecting to file: // is very popular among io-slaves and we don't want to break them - d->urlActionRestrictions.append( - URLActionRule("redirect", Any, Any, Any, QStringLiteral("file"), Any, Any, true)); - d->urlActionRestrictions.append( - URLActionRule("redirect", QStringLiteral(":internet"), Any, Any, QStringLiteral("file"), Any, Any, false)); + d->urlActionRestrictions.append(URLActionRule("redirect", Any, Any, Any, QStringLiteral("file"), Any, Any, true)); + d->urlActionRestrictions.append(URLActionRule("redirect", QStringLiteral(":internet"), Any, Any, QStringLiteral("file"), Any, Any, false)); // local protocols may redirect everywhere - d->urlActionRestrictions.append( - URLActionRule("redirect", QStringLiteral(":local"), Any, Any, Any, Any, Any, true)); + d->urlActionRestrictions.append(URLActionRule("redirect", QStringLiteral(":local"), Any, Any, Any, Any, Any, true)); // Anyone may redirect to about: - d->urlActionRestrictions.append( - URLActionRule("redirect", Any, Any, Any, QStringLiteral("about"), Any, Any, true)); + d->urlActionRestrictions.append(URLActionRule("redirect", Any, Any, Any, QStringLiteral("about"), Any, Any, true)); // Anyone may redirect to mailto: - d->urlActionRestrictions.append( - URLActionRule("redirect", Any, Any, Any, QStringLiteral("mailto"), Any, Any, true)); + d->urlActionRestrictions.append(URLActionRule("redirect", Any, Any, Any, QStringLiteral("mailto"), Any, Any, true)); // Anyone may redirect to itself, cq. within it's own group - d->urlActionRestrictions.append( - URLActionRule("redirect", Any, Any, Any, QStringLiteral("="), Any, Any, true)); + d->urlActionRestrictions.append(URLActionRule("redirect", Any, Any, Any, QStringLiteral("="), Any, Any, true)); - d->urlActionRestrictions.append( - URLActionRule("redirect", QStringLiteral("about"), Any, Any, Any, Any, Any, true)); + d->urlActionRestrictions.append(URLActionRule("redirect", QStringLiteral("about"), Any, Any, Any, Any, Any, true)); int count = cg.readEntry("rule_count", 0); QString keyFormat = QStringLiteral("rule_%1"); @@ -326,8 +322,7 @@ KCONFIGCORE_EXPORT void loadUrlActionRestrictions(const KConfigGroup &cg) urlPath.replace(0, 4, QDir::tempPath()); } - d->urlActionRestrictions.append( - URLActionRule(action, refProt, refHost, refPath, urlProt, urlHost, urlPath, bEnabled)); + d->urlActionRestrictions.append(URLActionRule(action, refProt, refHost, refPath, urlProt, urlHost, urlPath, bEnabled)); } } @@ -339,25 +334,23 @@ namespace KAuthorized */ KCONFIGCORE_EXPORT void allowUrlActionInternal(const QString &action, const QUrl &_baseURL, const QUrl &_destURL) { - MY_D - QMutexLocker locker((&d->mutex)); + MY_D QMutexLocker locker((&d->mutex)); const QString basePath = _baseURL.adjusted(QUrl::StripTrailingSlash).path(); const QString destPath = _destURL.adjusted(QUrl::StripTrailingSlash).path(); - d->urlActionRestrictions.append(URLActionRule - (action.toLatin1(), _baseURL.scheme(), _baseURL.host(), basePath, - _destURL.scheme(), _destURL.host(), destPath, true)); + d->urlActionRestrictions.append( + URLActionRule(action.toLatin1(), _baseURL.scheme(), _baseURL.host(), basePath, _destURL.scheme(), _destURL.host(), destPath, true)); } /** * Helper for KAuthorized::authorizeUrlAction in KIO * @private */ -KCONFIGCORE_EXPORT bool authorizeUrlActionInternal(const QString &action, const QUrl &_baseURL, const QUrl &_destURL, const QString &baseClass, const QString &destClass) +KCONFIGCORE_EXPORT bool +authorizeUrlActionInternal(const QString &action, const QUrl &_baseURL, const QUrl &_destURL, const QString &baseClass, const QString &destClass) { - MY_D - QMutexLocker locker(&(d->mutex)); + MY_D QMutexLocker locker(&(d->mutex)); if (d->blockEverything) { return false; } @@ -380,9 +373,8 @@ KCONFIGCORE_EXPORT bool authorizeUrlActionInternal(const QString &action, const for (const URLActionRule &rule : qAsConst(d->urlActionRestrictions)) { if ((result != rule.permission) && // No need to check if it doesn't make a difference - (action == QLatin1String(rule.action.constData())) && - rule.baseMatch(baseURL, baseClass) && - rule.destMatch(destURL, destClass, baseURL, baseClass)) { + (action == QLatin1String(rule.action.constData())) && rule.baseMatch(baseURL, baseClass) + && rule.destMatch(destURL, destClass, baseURL, baseClass)) { result = rule.permission; } } diff --git a/src/core/kauthorized.h b/src/core/kauthorized.h index 57a99e23..ac3cfa7e 100644 --- a/src/core/kauthorized.h +++ b/src/core/kauthorized.h @@ -16,13 +16,13 @@ class QUrl; class QString; /** -* The functions in this namespace provide the core of the Kiosk action -* restriction system; the KIO and KXMLGui frameworks build on this. -* -* The relevant settings are read from the application's KSharedConfig -* instance, so actions can be disabled on a per-application or global -* basis (by using the kdeglobals file). -*/ + * The functions in this namespace provide the core of the Kiosk action + * restriction system; the KIO and KXMLGui frameworks build on this. + * + * The relevant settings are read from the application's KSharedConfig + * instance, so actions can be disabled on a per-application or global + * basis (by using the kdeglobals file). + */ namespace KAuthorized { /** diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index ed389ea3..2da1dd48 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -19,20 +19,19 @@ #include "kconfigbackend_p.h" #include "kconfiggroup.h" -#include -#include +#include #include +#include +#include #include #include -#include +#include #include #include -#include -#include #if KCONFIG_USE_DBUS -#include #include +#include #include #endif @@ -51,12 +50,17 @@ static const Qt::CaseSensitivity sPathCaseSensitivity = Qt::CaseSensitive; static const Qt::CaseSensitivity sPathCaseSensitivity = Qt::CaseInsensitive; #endif -KConfigPrivate::KConfigPrivate(KConfig::OpenFlags flags, - QStandardPaths::StandardLocation resourceType) - : openFlags(flags), resourceType(resourceType), mBackend(nullptr), - bDynamicBackend(true), bDirty(false), bReadDefaults(false), - bFileImmutable(false), bForceGlobal(false), bSuppressGlobal(false), - configState(KConfigBase::NoAccess) +KConfigPrivate::KConfigPrivate(KConfig::OpenFlags flags, QStandardPaths::StandardLocation resourceType) + : openFlags(flags) + , resourceType(resourceType) + , mBackend(nullptr) + , bDynamicBackend(true) + , bDirty(false) + , bReadDefaults(false) + , bFileImmutable(false) + , bForceGlobal(false) + , bSuppressGlobal(false) + , configState(KConfigBase::NoAccess) { const bool isTestMode = QStandardPaths::isTestModeEnabled(); // If sGlobalFileName was initialised and testMode has been toggled, @@ -68,7 +72,7 @@ KConfigPrivate::KConfigPrivate(KConfig::OpenFlags flags, static QBasicAtomicInt use_etc_kderc = Q_BASIC_ATOMIC_INITIALIZER(-1); if (use_etc_kderc.loadRelaxed() < 0) { - use_etc_kderc.storeRelaxed( !qEnvironmentVariableIsSet("KDE_SKIP_KDERC")); // for unit tests + use_etc_kderc.storeRelaxed(!qEnvironmentVariableIsSet("KDE_SKIP_KDERC")); // for unit tests } if (use_etc_kderc.loadRelaxed()) { etc_kderc = @@ -83,20 +87,20 @@ KConfigPrivate::KConfigPrivate(KConfig::OpenFlags flags, } } -// if (!mappingsRegistered) { -// KEntryMap tmp; -// if (!etc_kderc.isEmpty()) { -// QExplicitlySharedDataPointer backend = KConfigBackend::create(etc_kderc, QLatin1String("INI")); -// backend->parseConfig( "en_US", tmp, KConfigBackend::ParseDefaults); -// } -// const QString kde5rc(QDir::home().filePath(".kde5rc")); -// if (KStandardDirs::checkAccess(kde5rc, R_OK)) { -// QExplicitlySharedDataPointer backend = KConfigBackend::create(kde5rc, QLatin1String("INI")); -// backend->parseConfig( "en_US", tmp, KConfigBackend::ParseOptions()); -// } -// KConfigBackend::registerMappings(tmp); -// mappingsRegistered = true; -// } + // if (!mappingsRegistered) { + // KEntryMap tmp; + // if (!etc_kderc.isEmpty()) { + // QExplicitlySharedDataPointer backend = KConfigBackend::create(etc_kderc, QLatin1String("INI")); + // backend->parseConfig( "en_US", tmp, KConfigBackend::ParseDefaults); + // } + // const QString kde5rc(QDir::home().filePath(".kde5rc")); + // if (KStandardDirs::checkAccess(kde5rc, R_OK)) { + // QExplicitlySharedDataPointer backend = KConfigBackend::create(kde5rc, QLatin1String("INI")); + // backend->parseConfig( "en_US", tmp, KConfigBackend::ParseOptions()); + // } + // KConfigBackend::registerMappings(tmp); + // mappingsRegistered = true; + // } setLocale(QLocale().name()); } @@ -110,8 +114,7 @@ bool KConfigPrivate::lockLocal() return true; } -void KConfigPrivate::copyGroup(const QByteArray &source, const QByteArray &destination, - KConfigGroup *otherGroup, KConfigBase::WriteConfigFlags flags) const +void KConfigPrivate::copyGroup(const QByteArray &source, const QByteArray &destination, KConfigGroup *otherGroup, KConfigBase::WriteConfigFlags flags) const { KEntryMap &otherMap = otherGroup->config()->d_ptr->entryMap; const int len = source.length(); @@ -144,7 +147,7 @@ void KConfigPrivate::copyGroup(const QByteArray &source, const QByteArray &desti newKey.mGroup.replace(0, len, destination); } - KEntry entry = entryMap[ entryMapIt.key() ]; + KEntry entry = entryMap[entryMapIt.key()]; dirtied = entry.bDirty = flags & KConfigBase::Persistent; if (flags & KConfigBase::Global) { @@ -182,10 +185,7 @@ QString KConfigPrivate::expandString(const QString &value) ++nEndPos; aVarName = aValue.midRef(nDollarPos + 2, nEndPos - nDollarPos - 3); } else { - while (nEndPos < aValue.length() && - (aValue[nEndPos].isNumber() || - aValue[nEndPos].isLetter() || - aValue[nEndPos] == QLatin1Char('_'))) { + while (nEndPos < aValue.length() && (aValue[nEndPos].isNumber() || aValue[nEndPos].isLetter() || aValue[nEndPos] == QLatin1Char('_'))) { ++nEndPos; } aVarName = aValue.midRef(nDollarPos + 1, nEndPos - nDollarPos - 1); @@ -227,8 +227,7 @@ QString KConfigPrivate::expandString(const QString &value) return aValue; } -KConfig::KConfig(const QString &file, OpenFlags mode, - QStandardPaths::StandardLocation resourceType) +KConfig::KConfig(const QString &file, OpenFlags mode, QStandardPaths::StandardLocation resourceType) : d_ptr(new KConfigPrivate(mode, resourceType)) { d_ptr->changeFileName(file); // set the local file name @@ -298,7 +297,7 @@ QStringList KConfigPrivate::groupList(const QByteArray &group) const static bool isGroupOrSubGroupMatch(const QByteArray &potentialGroup, const QByteArray &group) { if (!potentialGroup.startsWith(group)) { - return false; + return false; } return potentialGroup.length() == group.length() || potentialGroup[group.length()] == '\x1d'; } @@ -441,7 +440,7 @@ bool KConfig::sync() if (d->configState == ReadWrite && !tmp->lock()) { qCWarning(KCONFIG_CORE_LOG) << "couldn't lock global file"; - //unlock the local config if we're returning early + // unlock the local config if we're returning early if (d->mBackend->isLocked()) { d->mBackend->unlock(); } @@ -484,9 +483,7 @@ void KConfigPrivate::notifyClients(const QHash &changes qDBusRegisterMetaType>(); - QDBusMessage message = QDBusMessage::createSignal(path, - QStringLiteral("org.kde.kconfig.notify"), - QStringLiteral("ConfigChanged")); + QDBusMessage message = QDBusMessage::createSignal(path, QStringLiteral("org.kde.kconfig.notify"), QStringLiteral("ConfigChanged")); message.setArguments({QVariant::fromValue(changes)}); QDBusConnection::sessionBus().send(message); #else @@ -520,7 +517,7 @@ void KConfig::checkUpdate(const QString &id, const QString &updateFile) const QString cfg_id = updateFile + QLatin1Char(':') + id; const QStringList ids = cg.readEntry("update_info", QStringList()); if (!ids.contains(cfg_id)) { - QProcess::execute(QStringLiteral(KCONF_UPDATE_INSTALL_LOCATION), QStringList { QStringLiteral("--check"), updateFile }); + QProcess::execute(QStringLiteral(KCONF_UPDATE_INSTALL_LOCATION), QStringList{QStringLiteral("--check"), updateFile}); reparseConfiguration(); } } @@ -550,15 +547,13 @@ QString KConfig::name() const return d->fileName; } - KConfig::OpenFlags KConfig::openFlags() const { Q_D(const KConfig); return d->openFlags; } -struct KConfigStaticData -{ +struct KConfigStaticData { QString globalMainConfigName; // Keep a copy so we can use it in global dtors, after qApp is gone QStringList appArgs; @@ -572,7 +567,7 @@ void KConfig::setMainConfigName(const QString &str) QString KConfig::mainConfigName() { - KConfigStaticData* data = globalData(); + KConfigStaticData *data = globalData(); if (data->appArgs.isEmpty()) data->appArgs = QCoreApplication::arguments(); @@ -690,7 +685,7 @@ QStringList KConfigPrivate::getGlobalFiles() const void KConfigPrivate::parseGlobalFiles() { const QStringList globalFiles = getGlobalFiles(); -// qDebug() << "parsing global files" << globalFiles; + // qDebug() << "parsing global files" << globalFiles; // TODO: can we cache the values in etc_kderc / other global files // on a per-application basis? @@ -712,7 +707,6 @@ void KConfigPrivate::parseConfigFiles() { // can only read the file if there is a backend and a file name if (mBackend && !fileName.isEmpty()) { - bFileImmutable = false; QList files; @@ -745,7 +739,7 @@ void KConfigPrivate::parseConfigFiles() files = QList(extraFiles.cbegin(), extraFiles.cend()) + files; } -// qDebug() << "parsing local files" << files; + // qDebug() << "parsing local files" << files; const QByteArray utf8Locale = locale.toUtf8(); for (const QString &file : qAsConst(files)) { @@ -762,8 +756,7 @@ void KConfigPrivate::parseConfigFiles() } } else { QExplicitlySharedDataPointer backend = KConfigBackend::create(file); - bFileImmutable = (backend->parseConfig(utf8Locale, entryMap, - KConfigBackend::ParseDefaults | KConfigBackend::ParseExpansions) + bFileImmutable = (backend->parseConfig(utf8Locale, entryMap, KConfigBackend::ParseDefaults | KConfigBackend::ParseExpansions) == KConfigBackend::ParseImmutable); } @@ -844,7 +837,7 @@ bool KConfig::isImmutable() const bool KConfig::isGroupImmutableImpl(const QByteArray &aGroup) const { Q_D(const KConfig); - return isImmutable() || d->entryMap.getEntryOption(aGroup, {},{}, KEntryMap::EntryImmutable); + return isImmutable() || d->entryMap.getEntryOption(aGroup, {}, {}, KEntryMap::EntryImmutable); } #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(4, 0) @@ -925,13 +918,12 @@ bool KConfig::isConfigWritable(bool warnUser) errorMsg += QCoreApplication::translate("KConfig", "Please contact your system administrator."); QString cmdToExec = QStandardPaths::findExecutable(QStringLiteral("kdialog")); if (!cmdToExec.isEmpty()) { - QProcess::execute(cmdToExec, QStringList() - << QStringLiteral("--title") << QCoreApplication::applicationName() - << QStringLiteral("--msgbox") << errorMsg); + QProcess::execute(cmdToExec, + QStringList() << QStringLiteral("--title") << QCoreApplication::applicationName() << QStringLiteral("--msgbox") << errorMsg); } } - d->configState = allWritable ? ReadWrite : ReadOnly; // update the read/write status + d->configState = allWritable ? ReadWrite : ReadOnly; // update the read/write status return allWritable; } @@ -948,15 +940,13 @@ bool KConfig::hasGroupImpl(const QByteArray &aGroup) const bool KConfigPrivate::canWriteEntry(const QByteArray &group, const char *key, bool isDefault) const { - if (bFileImmutable || - entryMap.getEntryOption(group, key, KEntryMap::SearchLocalized, KEntryMap::EntryImmutable)) { + if (bFileImmutable || entryMap.getEntryOption(group, key, KEntryMap::SearchLocalized, KEntryMap::EntryImmutable)) { return isDefault; } return true; } -void KConfigPrivate::putData(const QByteArray &group, const char *key, - const QByteArray &value, KConfigBase::WriteConfigFlags flags, bool expand) +void KConfigPrivate::putData(const QByteArray &group, const char *key, const QByteArray &value, KConfigBase::WriteConfigFlags flags, bool expand) { KEntryMap::EntryOptions options = convertToOptions(flags); @@ -987,8 +977,7 @@ void KConfigPrivate::revertEntry(const QByteArray &group, const char *key, KConf } } -QByteArray KConfigPrivate::lookupData(const QByteArray &group, const char *key, - KEntryMap::SearchFlags flags) const +QByteArray KConfigPrivate::lookupData(const QByteArray &group, const char *key, KEntryMap::SearchFlags flags) const { if (bReadDefaults) { flags |= KEntryMap::SearchDefaults; @@ -1000,8 +989,7 @@ QByteArray KConfigPrivate::lookupData(const QByteArray &group, const char *key, return it->mValue; } -QString KConfigPrivate::lookupData(const QByteArray &group, const char *key, - KEntryMap::SearchFlags flags, bool *expand) const +QString KConfigPrivate::lookupData(const QByteArray &group, const char *key, KEntryMap::SearchFlags flags, bool *expand) const { if (bReadDefaults) { flags |= KEntryMap::SearchDefaults; diff --git a/src/core/kconfig.h b/src/core/kconfig.h index 4b652059..792a9a6b 100644 --- a/src/core/kconfig.h +++ b/src/core/kconfig.h @@ -15,11 +15,11 @@ #include -#include -#include #include #include #include +#include +#include class KConfigGroup; class KEntryMap; @@ -80,13 +80,13 @@ class KCONFIGCORE_EXPORT KConfig : public KConfigBase * @see OpenFlags */ enum OpenFlag { - IncludeGlobals = 0x01, ///< Blend kdeglobals into the config object. - CascadeConfig = 0x02, ///< Cascade to system-wide config files. + IncludeGlobals = 0x01, ///< Blend kdeglobals into the config object. + CascadeConfig = 0x02, ///< Cascade to system-wide config files. - SimpleConfig = 0x00, ///< Just a single config file. - NoCascade = IncludeGlobals, ///< Include user's globals, but omit system settings. - NoGlobals = CascadeConfig, ///< Cascade to system settings, but omit user's globals. - FullConfig = IncludeGlobals | CascadeConfig, ///< Fully-fledged config, including globals and cascading to system settings + SimpleConfig = 0x00, ///< Just a single config file. + NoCascade = IncludeGlobals, ///< Include user's globals, but omit system settings. + NoGlobals = CascadeConfig, ///< Cascade to system settings, but omit user's globals. + FullConfig = IncludeGlobals | CascadeConfig, ///< Fully-fledged config, including globals and cascading to system settings }; /** * Stores a combination of #OpenFlag values. @@ -121,7 +121,8 @@ class KCONFIGCORE_EXPORT KConfig : public KConfigBase * * @sa KSharedConfig::openConfig(const QString&, OpenFlags, QStandardPaths::StandardLocation) */ - explicit KConfig(const QString &file = QString(), OpenFlags mode = FullConfig, + explicit KConfig(const QString &file = QString(), + OpenFlags mode = FullConfig, QStandardPaths::StandardLocation type = QStandardPaths::GenericConfigLocation); /** diff --git a/src/core/kconfig_p.h b/src/core/kconfig_p.h index 917872f3..b201df17 100644 --- a/src/core/kconfig_p.h +++ b/src/core/kconfig_p.h @@ -11,18 +11,19 @@ #ifndef KCONFIG_P_H #define KCONFIG_P_H -#include "kconfigdata.h" #include "kconfigbackend_p.h" +#include "kconfigdata.h" #include "kconfiggroup.h" -#include -#include -#include #include +#include +#include +#include class KConfigPrivate { friend class KConfig; + public: KConfig::OpenFlags openFlags; QStandardPaths::StandardLocation resourceType; @@ -31,19 +32,15 @@ class KConfigPrivate // functions for KConfigGroup bool canWriteEntry(const QByteArray &group, const char *key, bool isDefault = false) const; - QString lookupData(const QByteArray &group, const char *key, KEntryMap::SearchFlags flags, - bool *expand) const; + QString lookupData(const QByteArray &group, const char *key, KEntryMap::SearchFlags flags, bool *expand) const; QByteArray lookupData(const QByteArray &group, const char *key, KEntryMap::SearchFlags flags) const; - void putData(const QByteArray &group, const char *key, const QByteArray &value, - KConfigBase::WriteConfigFlags flags, bool expand = false); - void revertEntry(const QByteArray &group, const char *key, - KConfigBase::WriteConfigFlags flags); + void putData(const QByteArray &group, const char *key, const QByteArray &value, KConfigBase::WriteConfigFlags flags, bool expand = false); + void revertEntry(const QByteArray &group, const char *key, KConfigBase::WriteConfigFlags flags); QStringList groupList(const QByteArray &group) const; // copies the entries from @p source to @p otherGroup changing all occurrences // of @p source with @p destination - void copyGroup(const QByteArray &source, const QByteArray &destination, - KConfigGroup *otherGroup, KConfigBase::WriteConfigFlags flags) const; + void copyGroup(const QByteArray &source, const QByteArray &destination, KConfigGroup *otherGroup, KConfigBase::WriteConfigFlags flags) const; QStringList keyListImpl(const QByteArray &theGroup) const; QSet allSubGroups(const QByteArray &parentGroup) const; bool hasNonDeletedEntries(const QByteArray &group) const; @@ -55,20 +52,19 @@ class KConfigPrivate protected: QExplicitlySharedDataPointer mBackend; - KConfigPrivate(KConfig::OpenFlags flags, - QStandardPaths::StandardLocation type); + KConfigPrivate(KConfig::OpenFlags flags, QStandardPaths::StandardLocation type); virtual ~KConfigPrivate() { } - bool bDynamicBackend: 1; // do we own the backend? + bool bDynamicBackend : 1; // do we own the backend? private: - bool bDirty: 1; - bool bReadDefaults: 1; - bool bFileImmutable: 1; - bool bForceGlobal: 1; - bool bSuppressGlobal: 1; + bool bDirty : 1; + bool bReadDefaults : 1; + bool bFileImmutable : 1; + bool bForceGlobal : 1; + bool bSuppressGlobal : 1; static bool mappingsRegistered; diff --git a/src/core/kconfigbackend.cpp b/src/core/kconfigbackend.cpp index 0f95a5f6..13455dbd 100644 --- a/src/core/kconfigbackend.cpp +++ b/src/core/kconfigbackend.cpp @@ -10,14 +10,14 @@ #include "kconfigbackend_p.h" #include -#include +#include #include #include #include -#include +#include -#include "kconfigini_p.h" #include "kconfigdata.h" +#include "kconfigini_p.h" typedef QExplicitlySharedDataPointer BackendPtr; @@ -38,7 +38,7 @@ void KConfigBackend::registerMappings(const KEntryMap & /*entryMap*/) BackendPtr KConfigBackend::create(const QString &file, const QString &sys) { - //qDebug() << "creating a backend for file" << file << "with system" << sys; + // qDebug() << "creating a backend for file" << file << "with system" << sys; KConfigBackend *backend = nullptr; #if 0 // TODO port to Qt5 plugin loading @@ -61,7 +61,7 @@ BackendPtr KConfigBackend::create(const QString &file, const QString &sys) Q_UNUSED(sys); #endif - //qDebug() << "default creation of the Ini backend"; + // qDebug() << "default creation of the Ini backend"; backend = new KConfigIniBackend; backend->setFilePath(file); return BackendPtr(backend); diff --git a/src/core/kconfigbackend_p.h b/src/core/kconfigbackend_p.h index 7eb1774e..5b38634f 100644 --- a/src/core/kconfigbackend_p.h +++ b/src/core/kconfigbackend_p.h @@ -10,12 +10,12 @@ #ifndef KCONFIGBACKEND_H #define KCONFIGBACKEND_H +#include #include #include -#include -#include #include +#include class KConfigBackendPrivate; class KEntryMap; @@ -48,8 +48,7 @@ class KConfigBackend : public QObject, public QSharedData * @param system the configuration system to use * @return a KConfigBackend object to be used with KConfig */ - static QExplicitlySharedDataPointer create(const QString &fileName = QString(), - const QString &system = QString()); + static QExplicitlySharedDataPointer create(const QString &fileName = QString(), const QString &system = QString()); /** * Registers mappings from directories/files to configuration systems @@ -99,9 +98,7 @@ class KConfigBackend : public QObject, public QSharedData * @param options See ParseOptions * @return See ParseInfo */ - virtual ParseInfo parseConfig(const QByteArray &locale, - KEntryMap &pWriteBackMap, - ParseOptions options = ParseOptions()) = 0; + virtual ParseInfo parseConfig(const QByteArray &locale, KEntryMap &pWriteBackMap, ParseOptions options = ParseOptions()) = 0; /** * Write the @em dirty entries to permanent storage @@ -112,8 +109,7 @@ class KConfigBackend : public QObject, public QSharedData * * @return @c true if the write was successful, @c false if writing the configuration failed */ - virtual bool writeConfig(const QByteArray &locale, KEntryMap &entryMap, - WriteOptions options) = 0; + virtual bool writeConfig(const QByteArray &locale, KEntryMap &entryMap, WriteOptions options) = 0; /** * If isWritable() returns false, writeConfig() will always fail. @@ -185,8 +181,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(KConfigBackend::WriteOptions) /** * Register a KConfig backend when it is contained in a loadable module */ -#define K_EXPORT_KCONFIGBACKEND(libname, classname) \ - K_PLUGIN_FACTORY(factory, registerPlugin();) +#define K_EXPORT_KCONFIGBACKEND(libname, classname) K_PLUGIN_FACTORY(factory, registerPlugin();) #endif #endif // KCONFIGBACKEND_H diff --git a/src/core/kconfigbase.cpp b/src/core/kconfigbase.cpp index 6bae0e25..9eee6420 100644 --- a/src/core/kconfigbase.cpp +++ b/src/core/kconfigbase.cpp @@ -89,10 +89,13 @@ bool KConfigBase::isGroupImmutable(const char *aGroup) const } KConfigBase::~KConfigBase() -{} +{ +} KConfigBase::KConfigBase() -{} +{ +} void KConfigBase::virtual_hook(int, void *) -{} +{ +} diff --git a/src/core/kconfigbase.h b/src/core/kconfigbase.h index a7693275..79af8854 100644 --- a/src/core/kconfigbase.h +++ b/src/core/kconfigbase.h @@ -56,9 +56,9 @@ class KCONFIGCORE_EXPORT KConfigBase */ Normal = Persistent, /**< - * Save the entry to the application specific config file without - * a locale tag. This is the default. - */ + * Save the entry to the application specific config file without + * a locale tag. This is the default. + */ }; /** diff --git a/src/core/kconfigdata.cpp b/src/core/kconfigdata.cpp index 5ead8167..accf869b 100644 --- a/src/core/kconfigdata.cpp +++ b/src/core/kconfigdata.cpp @@ -11,28 +11,26 @@ QDebug operator<<(QDebug dbg, const KEntryKey &key) { - dbg.nospace() << "[" << key.mGroup << ", " << key.mKey << (key.bLocal ? " localized" : "") << - (key.bDefault ? " default" : "") << (key.bRaw ? " raw" : "") << "]"; + dbg.nospace() << "[" << key.mGroup << ", " << key.mKey << (key.bLocal ? " localized" : "") << (key.bDefault ? " default" : "") << (key.bRaw ? " raw" : "") + << "]"; return dbg.space(); } QDebug operator<<(QDebug dbg, const KEntry &entry) { - dbg.nospace() << "[" << entry.mValue << (entry.bDirty ? " dirty" : "") << - (entry.bGlobal ? " global" : "") << (entry.bImmutable ? " immutable" : "") << - (entry.bDeleted ? " deleted" : "") << (entry.bReverted ? " reverted" : "") << - (entry.bExpand ? " expand" : "") << "]"; + dbg.nospace() << "[" << entry.mValue << (entry.bDirty ? " dirty" : "") << (entry.bGlobal ? " global" : "") << (entry.bImmutable ? " immutable" : "") + << (entry.bDeleted ? " deleted" : "") << (entry.bReverted ? " reverted" : "") << (entry.bExpand ? " expand" : "") << "]"; return dbg.space(); } -QMap< KEntryKey, KEntry >::Iterator KEntryMap::findExactEntry(const QByteArray &group, const QByteArray &key, KEntryMap::SearchFlags flags) +QMap::Iterator KEntryMap::findExactEntry(const QByteArray &group, const QByteArray &key, KEntryMap::SearchFlags flags) { KEntryKey theKey(group, key, bool(flags & SearchLocalized), bool(flags & SearchDefaults)); return find(theKey); } -QMap< KEntryKey, KEntry >::Iterator KEntryMap::findEntry(const QByteArray &group, const QByteArray &key, KEntryMap::SearchFlags flags) +QMap::Iterator KEntryMap::findEntry(const QByteArray &group, const QByteArray &key, KEntryMap::SearchFlags flags) { KEntryKey theKey(group, key, false, bool(flags & SearchDefaults)); @@ -50,7 +48,7 @@ QMap< KEntryKey, KEntry >::Iterator KEntryMap::findEntry(const QByteArray &group return find(theKey); } -QMap< KEntryKey, KEntry >::ConstIterator KEntryMap::findEntry(const QByteArray &group, const QByteArray &key, KEntryMap::SearchFlags flags) const +QMap::ConstIterator KEntryMap::findEntry(const QByteArray &group, const QByteArray &key, KEntryMap::SearchFlags flags) const { KEntryKey theKey(group, key, false, bool(flags & SearchDefaults)); @@ -95,11 +93,11 @@ bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const Q if (it != end()) { if (it->bImmutable) { - return false; // we cannot change this entry. Inherits group immutability. + return false; // we cannot change this entry. Inherits group immutability. } k = it.key(); e = *it; - //qDebug() << "found existing entry for key" << k; + // qDebug() << "found existing entry for key" << k; // If overridden entry is global and not default. And it's overridden by a non global if (e.bGlobal && !(options & EntryGlobal) && !k.bDefault) { e.bOverridesGlobal = true; @@ -111,7 +109,7 @@ bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const Q if (cit == constEnd()) { insert(KEntryKey(group), KEntry()); } else if (cit->bImmutable) { - return false; // this group is immutable, so we cannot change this entry. + return false; // this group is immutable, so we cannot change this entry. } k = KEntryKey(group, key); @@ -127,14 +125,14 @@ bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const Q e.bDirty = e.bDirty || (options & EntryDirty); e.bNotify = e.bNotify || (options & EntryNotify); - e.bGlobal = (options & EntryGlobal); //we can't use || here, because changes to entries in - //kdeglobals would be written to kdeglobals instead - //of the local config file, regardless of the globals flag + e.bGlobal = (options & EntryGlobal); // we can't use || here, because changes to entries in + // kdeglobals would be written to kdeglobals instead + // of the local config file, regardless of the globals flag e.bImmutable = e.bImmutable || (options & EntryImmutable); if (value.isNull()) { e.bDeleted = e.bDeleted || (options & EntryDeleted); } else { - e.bDeleted = false; // setting a value to a previously deleted entry + e.bDeleted = false; // setting a value to a previously deleted entry } e.bExpand = (options & EntryExpansion); e.bReverted = false; @@ -145,17 +143,17 @@ bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const Q } if (newKey) { - //qDebug() << "inserting" << k << "=" << value; + // qDebug() << "inserting" << k << "=" << value; insert(k, e); if (k.bDefault) { k.bDefault = false; - //qDebug() << "also inserting" << k << "=" << value; + // qDebug() << "also inserting" << k << "=" << value; insert(k, e); } // TODO check for presence of unlocalized key return true; } else { -// KEntry e2 = it.value(); + // KEntry e2 = it.value(); if (options & EntryLocalized) { // fast exit checks for cases where the existing entry is more specific const KEntry &e2 = it.value(); @@ -165,7 +163,7 @@ bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const Q } } if (it.value() != e) { - //qDebug() << "changing" << k << "from" << e.mValue << "to" << value; + // qDebug() << "changing" << k << "from" << e.mValue << "to" << value; it.value() = e; if (k.bDefault) { KEntryKey nonDefaultKey(k); @@ -174,7 +172,7 @@ bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const Q } if (!(options & EntryLocalized)) { KEntryKey theKey(group, key, true, false); - //qDebug() << "non-localized entry, remove localized one:" << theKey; + // qDebug() << "non-localized entry, remove localized one:" << theKey; remove(theKey); if (k.bDefault) { theKey.bDefault = true; @@ -183,9 +181,9 @@ bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const Q } return true; } else { - //qDebug() << k << "was already set to" << e.mValue; + // qDebug() << k << "was already set to" << e.mValue; if (!(options & EntryLocalized)) { - //qDebug() << "unchanged non-localized entry, remove localized one."; + // qDebug() << "unchanged non-localized entry, remove localized one."; KEntryKey theKey(group, key, true, false); bool ret = false; Iterator cit = find(theKey); @@ -203,7 +201,7 @@ bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const Q } return ret; } - //qDebug() << "localized entry, unchanged, return false"; + // qDebug() << "localized entry, unchanged, return false"; // When we are writing a default, we know that the non- // default is the same as the default, so we can simply // use the same branch. @@ -246,7 +244,7 @@ bool KEntryMap::hasEntry(const QByteArray &group, const QByteArray &key, KEntryM return true; } -bool KEntryMap::getEntryOption(const QMap< KEntryKey, KEntry >::ConstIterator &it, KEntryMap::EntryOption option) const +bool KEntryMap::getEntryOption(const QMap::ConstIterator &it, KEntryMap::EntryOption option) const { if (it != constEnd()) { switch (option) { @@ -272,7 +270,7 @@ bool KEntryMap::getEntryOption(const QMap< KEntryKey, KEntry >::ConstIterator &i return false; } -void KEntryMap::setEntryOption(QMap< KEntryKey, KEntry >::Iterator it, KEntryMap::EntryOption option, bool bf) +void KEntryMap::setEntryOption(QMap::Iterator it, KEntryMap::EntryOption option, bool bf) { if (it != end()) { switch (option) { @@ -305,18 +303,18 @@ bool KEntryMap::revertEntry(const QByteArray &group, const QByteArray &key, KEnt Q_ASSERT((flags & KEntryMap::SearchDefaults) == 0); Iterator entry = findEntry(group, key, flags); if (entry != end()) { - //qDebug() << "reverting" << entry.key() << " = " << entry->mValue; + // qDebug() << "reverting" << entry.key() << " = " << entry->mValue; if (entry->bReverted) { // already done before return false; } KEntryKey defaultKey(entry.key()); defaultKey.bDefault = true; - //qDebug() << "looking up default entry with key=" << defaultKey; + // qDebug() << "looking up default entry with key=" << defaultKey; const ConstIterator defaultEntry = constFind(defaultKey); if (defaultEntry != constEnd()) { Q_ASSERT(defaultEntry.key().bDefault); - //qDebug() << "found, update entry"; + // qDebug() << "found, update entry"; *entry = *defaultEntry; // copy default value, for subsequent lookups } else { entry->mValue = QByteArray(); @@ -325,7 +323,7 @@ bool KEntryMap::revertEntry(const QByteArray &group, const QByteArray &key, KEnt entry->bDirty = true; entry->bReverted = true; // skip it when writing out to disk - //qDebug() << "Here's what we have now:" << *this; + // qDebug() << "Here's what we have now:" << *this; return true; } return false; diff --git a/src/core/kconfigdata.h b/src/core/kconfigdata.h index 36d90335..bb9ee717 100644 --- a/src/core/kconfigdata.h +++ b/src/core/kconfigdata.h @@ -11,9 +11,9 @@ #define KCONFIGDATA_H #include -#include -#include #include +#include +#include /** * map/dict/list config node entry. @@ -22,60 +22,67 @@ struct KEntry { /** Constructor. @internal */ KEntry() - : mValue(), bDirty(false), - bGlobal(false), bImmutable(false), bDeleted(false), bExpand(false), bReverted(false), - bLocalizedCountry(false), bNotify(false), bOverridesGlobal(false) {} + : mValue() + , bDirty(false) + , bGlobal(false) + , bImmutable(false) + , bDeleted(false) + , bExpand(false) + , bReverted(false) + , bLocalizedCountry(false) + , bNotify(false) + , bOverridesGlobal(false) + { + } /** @internal */ QByteArray mValue; /** * Must the entry be written back to disk? */ - bool bDirty : 1; + bool bDirty : 1; /** * Entry should be written to the global config file */ - bool bGlobal: 1; + bool bGlobal : 1; /** * Entry can not be modified. */ - bool bImmutable: 1; + bool bImmutable : 1; /** * Entry has been deleted. */ - bool bDeleted: 1; + bool bDeleted : 1; /** * Whether to apply dollar expansion or not. */ - bool bExpand: 1; + bool bExpand : 1; /** * Entry has been reverted to its default value (from a more global file). */ - bool bReverted: 1; + bool bReverted : 1; /** * Entry is for a localized key. If @c false the value references just language e.g. "de", * if @c true the value references language and country, e.g. "de_DE". **/ - bool bLocalizedCountry: 1; + bool bLocalizedCountry : 1; - bool bNotify: 1; + bool bNotify : 1; /** * Entry will need to be written on a non global file even if it matches default value */ - bool bOverridesGlobal: 1; + bool bOverridesGlobal : 1; }; // These operators are used to check whether an entry which is about // to be written equals the previous value. As such, this intentionally // omits the dirty/notify flag from the comparison. -inline bool operator ==(const KEntry &k1, const KEntry &k2) +inline bool operator==(const KEntry &k1, const KEntry &k2) { - return k1.bGlobal == k2.bGlobal && k1.bImmutable == k2.bImmutable - && k1.bDeleted == k2.bDeleted && k1.bExpand == k2.bExpand - && k1.mValue == k2.mValue; + return k1.bGlobal == k2.bGlobal && k1.bImmutable == k2.bImmutable && k1.bDeleted == k2.bDeleted && k1.bExpand == k2.bExpand && k1.mValue == k2.mValue; } -inline bool operator !=(const KEntry &k1, const KEntry &k2) +inline bool operator!=(const KEntry &k1, const KEntry &k2) { return !(k1 == k2); } @@ -87,9 +94,12 @@ inline bool operator !=(const KEntry &k1, const KEntry &k2) */ struct KEntryKey { /** Constructor. @internal */ - KEntryKey(const QByteArray &_group = QByteArray(), - const QByteArray &_key = QByteArray(), bool isLocalized = false, bool isDefault = false) - : mGroup(_group), mKey(_key), bLocal(isLocalized), bDefault(isDefault), bRaw(false) + KEntryKey(const QByteArray &_group = QByteArray(), const QByteArray &_key = QByteArray(), bool isLocalized = false, bool isDefault = false) + : mGroup(_group) + , mKey(_key) + , bLocal(isLocalized) + , bDefault(isDefault) + , bRaw(false) { ; } @@ -104,16 +114,16 @@ struct KEntryKey { /** * Entry is localised or not */ - bool bLocal : 1; + bool bLocal : 1; /** * Entry indicates if this is a default value. */ - bool bDefault: 1; + bool bDefault : 1; /** @internal * Key is a raw unprocessed key. * @warning this should only be set during merging, never for normal use. */ - bool bRaw: 1; + bool bRaw : 1; }; /** @@ -121,7 +131,7 @@ struct KEntryKey { * non-localized, non-localized-default * @internal */ -inline bool operator <(const KEntryKey &k1, const KEntryKey &k2) +inline bool operator<(const KEntryKey &k1, const KEntryKey &k2) { int result = qstrcmp(k1.mGroup, k2.mGroup); if (result != 0) { @@ -172,45 +182,38 @@ class KEntryMap : public QMap }; Q_DECLARE_FLAGS(EntryOptions, EntryOption) - Iterator findExactEntry(const QByteArray &group, const QByteArray &key = QByteArray(), - SearchFlags flags = SearchFlags()); + Iterator findExactEntry(const QByteArray &group, const QByteArray &key = QByteArray(), SearchFlags flags = SearchFlags()); - Iterator findEntry(const QByteArray &group, const QByteArray &key = QByteArray(), - SearchFlags flags = SearchFlags()); + Iterator findEntry(const QByteArray &group, const QByteArray &key = QByteArray(), SearchFlags flags = SearchFlags()); - ConstIterator findEntry(const QByteArray &group, const QByteArray &key = QByteArray(), - SearchFlags flags = SearchFlags()) const; + ConstIterator findEntry(const QByteArray &group, const QByteArray &key = QByteArray(), SearchFlags flags = SearchFlags()) const; /** * Returns true if the entry gets dirtied or false in other case */ - bool setEntry(const QByteArray &group, const QByteArray &key, - const QByteArray &value, EntryOptions options); + bool setEntry(const QByteArray &group, const QByteArray &key, const QByteArray &value, EntryOptions options); - void setEntry(const QByteArray &group, const QByteArray &key, - const QString &value, EntryOptions options) + void setEntry(const QByteArray &group, const QByteArray &key, const QString &value, EntryOptions options) { setEntry(group, key, value.toUtf8(), options); } - QString getEntry(const QByteArray &group, const QByteArray &key, + QString getEntry(const QByteArray &group, + const QByteArray &key, const QString &defaultValue = QString(), SearchFlags flags = SearchFlags(), bool *expand = nullptr) const; - bool hasEntry(const QByteArray &group, const QByteArray &key = QByteArray(), - SearchFlags flags = SearchFlags()) const; + bool hasEntry(const QByteArray &group, const QByteArray &key = QByteArray(), SearchFlags flags = SearchFlags()) const; bool getEntryOption(const ConstIterator &it, EntryOption option) const; - bool getEntryOption(const QByteArray &group, const QByteArray &key, - SearchFlags flags, EntryOption option) const + bool getEntryOption(const QByteArray &group, const QByteArray &key, SearchFlags flags, EntryOption option) const { return getEntryOption(findEntry(group, key, flags), option); } void setEntryOption(Iterator it, EntryOption option, bool bf); - void setEntryOption(const QByteArray &group, const QByteArray &key, SearchFlags flags, - EntryOption option, bool bf) + void setEntryOption(const QByteArray &group, const QByteArray &key, SearchFlags flags, EntryOption option, bool bf) { setEntryOption(findEntry(group, key, flags), option, bf); } diff --git a/src/core/kconfiggroup.cpp b/src/core/kconfiggroup.cpp index d900458f..8fcfafe7 100644 --- a/src/core/kconfiggroup.cpp +++ b/src/core/kconfiggroup.cpp @@ -11,41 +11,50 @@ #include "kconfiggroup_p.h" #include "kconfig.h" -#include "kconfig_p.h" #include "kconfig_core_log_settings.h" -#include "ksharedconfig.h" +#include "kconfig_p.h" #include "kconfigdata.h" +#include "ksharedconfig.h" #include -#include +#include #include #include #include +#include #include #include -#include #include -#include #include +#include class KConfigGroupPrivate : public QSharedData { public: KConfigGroupPrivate(KConfig *owner, bool isImmutable, bool isConst, const QByteArray &name) - : mOwner(owner), mName(name), bImmutable(isImmutable), bConst(isConst) + : mOwner(owner) + , mName(name) + , bImmutable(isImmutable) + , bConst(isConst) { } KConfigGroupPrivate(const KSharedConfigPtr &owner, const QByteArray &name) - : sOwner(owner), mOwner(sOwner.data()), mName(name), - bImmutable(name.isEmpty() ? owner->isImmutable() : owner->isGroupImmutable(name)), bConst(false) + : sOwner(owner) + , mOwner(sOwner.data()) + , mName(name) + , bImmutable(name.isEmpty() ? owner->isImmutable() : owner->isGroupImmutable(name)) + , bConst(false) { } KConfigGroupPrivate(KConfigGroup *parent, bool isImmutable, bool isConst, const QByteArray &name) - : sOwner(parent->d->sOwner), mOwner(parent->d->mOwner), mName(name), - bImmutable(isImmutable), bConst(isConst) + : sOwner(parent->d->sOwner) + , mOwner(parent->d->mOwner) + , mName(name) + , bImmutable(isImmutable) + , bConst(isConst) { if (!parent->d->mName.isEmpty()) { mParent = parent->d; @@ -53,8 +62,11 @@ class KConfigGroupPrivate : public QSharedData } KConfigGroupPrivate(const KConfigGroupPrivate *other, bool isImmutable, const QByteArray &name) - : sOwner(other->sOwner), mOwner(other->mOwner), mName(name), - bImmutable(isImmutable), bConst(other->bConst) + : sOwner(other->sOwner) + , mOwner(other->mOwner) + , mName(name) + , bImmutable(isImmutable) + , bConst(other->bConst) { if (!other->mName.isEmpty()) { mParent = const_cast(other); @@ -67,8 +79,8 @@ class KConfigGroupPrivate : public QSharedData QByteArray mName; /* bitfield */ - const bool bImmutable: 1; // is this group immutable? - const bool bConst: 1; // is this group read-only? + const bool bImmutable : 1; // is this group immutable? + const bool bConst : 1; // is this group read-only? QByteArray fullName() const { @@ -94,10 +106,7 @@ class KConfigGroupPrivate : public QSharedData return fullName() + '\x1d' + aGroup; } - static QExplicitlySharedDataPointer create(KConfigBase *master, - const QByteArray &name, - bool isImmutable, - bool isConst) + static QExplicitlySharedDataPointer create(KConfigBase *master, const QByteArray &name, bool isImmutable, bool isConst) { QExplicitlySharedDataPointer data; if (dynamic_cast(master)) { @@ -198,9 +207,7 @@ static QVector asRealList(const QByteArray &string) static QString errString(const char *pKey, const QByteArray &value, const QVariant &aDefault) { return QStringLiteral("\"%1\" - conversion of \"%3\" to %2 failed") - .arg( QString::fromLatin1(pKey), - QString::fromLatin1(QVariant::typeToName(aDefault.type())), - QString::fromLatin1(value) ); + .arg(QString::fromLatin1(pKey), QString::fromLatin1(QVariant::typeToName(aDefault.type())), QString::fromLatin1(value)); } static QString formatError(int expected, int got) @@ -249,8 +256,7 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val const auto list = asIntList(value); if (list.count() != 2) { - qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) - << formatError(2, list.count()); + qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(2, list.count()); return aDefault; } return QPoint(list.at(0), list.at(1)); @@ -259,8 +265,7 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val const auto list = asRealList(value); if (list.count() != 2) { - qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) - << formatError(2, list.count()); + qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(2, list.count()); return aDefault; } return QPointF(list.at(0), list.at(1)); @@ -269,8 +274,7 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val const auto list = asIntList(value); if (list.count() != 4) { - qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) - << formatError(4, list.count()); + qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(4, list.count()); return aDefault; } const QRect rect(list.at(0), list.at(1), list.at(2), list.at(3)); @@ -284,8 +288,7 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val const auto list = asRealList(value); if (list.count() != 4) { - qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) - << formatError(4, list.count()); + qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(4, list.count()); return aDefault; } const QRectF rect(list.at(0), list.at(1), list.at(2), list.at(3)); @@ -299,8 +302,7 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val const auto list = asIntList(value); if (list.count() != 2) { - qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) - << formatError(2, list.count()); + qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(2, list.count()); return aDefault; } const QSize size(list.at(0), list.at(1)); @@ -314,8 +316,7 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val const auto list = asRealList(value); if (list.count() != 2) { - qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) - << formatError(2, list.count()); + qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(2, list.count()); return aDefault; } const QSizeF size(list.at(0), list.at(1)); @@ -328,8 +329,7 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val case QMetaType::QDateTime: { const auto list = asRealList(value); if (list.count() < 6) { - qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) - << formatError(6, list.count()); + qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(6, list.count()); return aDefault; } const QDate date(list.at(0), list.at(1), list.at(2)); @@ -348,11 +348,10 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val case QMetaType::QDate: { auto list = asIntList(value); if (list.count() == 6) { - list = list.mid(0, 3); // don't break config files that stored QDate as QDateTime + list = list.mid(0, 3); // don't break config files that stored QDate as QDateTime } if (list.count() != 3) { - qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) - << formatError(3, list.count()); + qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(3, list.count()); return aDefault; } const QDate date(list.at(0), list.at(1), list.at(2)); @@ -364,10 +363,9 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val } case QMetaType::QColor: case QMetaType::QFont: - qCWarning(KCONFIG_CORE_LOG) << "KConfigGroup::readEntry was passed GUI type '" - << aDefault.typeName() - << "' but KConfigGui isn't linked! If it is linked to your program, " - "this is a platform bug. Please inform the KDE developers"; + qCWarning(KCONFIG_CORE_LOG) << "KConfigGroup::readEntry was passed GUI type '" << aDefault.typeName() + << "' but KConfigGui isn't linked! If it is linked to your program, " + "this is a platform bug. Please inform the KDE developers"; break; case QMetaType::QUrl: return QUrl(QString::fromUtf8(value)); @@ -381,12 +379,12 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val } #ifdef Q_OS_WIN -# include +#include #endif static bool cleanHomeDirPath(QString &path, const QString &homeDir) { -#ifdef Q_OS_WIN //safer +#ifdef Q_OS_WIN // safer if (!QDir::toNativeSeparators(path).startsWith(QDir::toNativeSeparators(homeDir))) { return false; } @@ -406,7 +404,7 @@ static bool cleanHomeDirPath(QString &path, const QString &homeDir) return false; } -static QString translatePath(QString path) // krazy:exclude=passbyvalue +static QString translatePath(QString path) // krazy:exclude=passbyvalue { if (path.isEmpty()) { return path; @@ -429,9 +427,7 @@ static QString translatePath(QString path) // krazy:exclude=passbyvalue const QString homeDir0 = QFile::decodeName(qgetenv("HOME")); const QString homeDir1 = QDir::homePath(); const QString homeDir2 = QDir(homeDir1).canonicalPath(); - if (cleanHomeDirPath(path, homeDir0) || - cleanHomeDirPath(path, homeDir1) || - cleanHomeDirPath(path, homeDir2)) { + if (cleanHomeDirPath(path, homeDir0) || cleanHomeDirPath(path, homeDir1) || cleanHomeDirPath(path, homeDir2)) { // qDebug() << "Path was replaced\n"; } @@ -442,7 +438,8 @@ static QString translatePath(QString path) // krazy:exclude=passbyvalue return path; } -KConfigGroup::KConfigGroup() : d() +KConfigGroup::KConfigGroup() + : d() { } @@ -452,8 +449,7 @@ bool KConfigGroup::isValid() const } KConfigGroupGui _kde_internal_KConfigGroupGui; -static inline bool readEntryGui(const QByteArray &data, const char *key, const QVariant &input, - QVariant &output) +static inline bool readEntryGui(const QByteArray &data, const char *key, const QVariant &input, QVariant &output) { if (_kde_internal_KConfigGroupGui.readEntryGui) { return _kde_internal_KConfigGroupGui.readEntryGui(data, key, input, output); @@ -461,8 +457,7 @@ static inline bool readEntryGui(const QByteArray &data, const char *key, const Q return false; } -static inline bool writeEntryGui(KConfigGroup *cg, const char *key, const QVariant &input, - KConfigGroup::WriteConfigFlags flags) +static inline bool writeEntryGui(KConfigGroup *cg, const char *key, const QVariant &input, KConfigGroup::WriteConfigFlags flags) { if (_kde_internal_KConfigGroupGui.writeEntryGui) { return _kde_internal_KConfigGroupGui.writeEntryGui(cg, key, input, flags); @@ -535,8 +530,7 @@ const KConfigGroup KConfigGroup::groupImpl(const QByteArray &aGroup) const KConfigGroup newGroup; - newGroup.d = new KConfigGroupPrivate(const_cast(this), isGroupImmutableImpl(aGroup), - true, aGroup); + newGroup.d = new KConfigGroupPrivate(const_cast(this), isGroupImmutableImpl(aGroup), true, aGroup); return newGroup; } @@ -634,8 +628,7 @@ bool KConfigGroup::isEntryImmutable(const char *key) const { Q_ASSERT_X(isValid(), "KConfigGroup::isEntryImmutable", "accessing an invalid group"); - return (isImmutable() || - !config()->d_func()->canWriteEntry(d->fullName(), key, config()->readDefaults())); + return (isImmutable() || !config()->d_func()->canWriteEntry(d->fullName(), key, config()->readDefaults())); } bool KConfigGroup::isEntryImmutable(const QString &key) const @@ -676,8 +669,7 @@ QString KConfigGroup::readEntry(const char *key, const QString &aDefault) const bool expand = false; // read value from the entry map - QString aValue = config()->d_func()->lookupData(d->fullName(), key, KEntryMap::SearchLocalized, - &expand); + QString aValue = config()->d_func()->lookupData(d->fullName(), key, KEntryMap::SearchLocalized, &expand); if (aValue.isNull()) { aValue = aDefault; } @@ -809,8 +801,7 @@ QString KConfigGroup::readPathEntry(const char *key, const QString &aDefault) co bool expand = false; - QString aValue = config()->d_func()->lookupData(d->fullName(), key, KEntryMap::SearchLocalized, - &expand); + QString aValue = config()->d_func()->lookupData(d->fullName(), key, KEntryMap::SearchLocalized, &expand); if (aValue.isNull()) { aValue = aDefault; } @@ -861,8 +852,7 @@ void KConfigGroup::writeEntry(const char *key, const char *value, WriteConfigFla writeEntry(key, QVariant(QString::fromLatin1(value)), pFlags); } -void KConfigGroup::writeEntry(const char *key, const QByteArray &value, - WriteConfigFlags flags) +void KConfigGroup::writeEntry(const char *key, const QByteArray &value, WriteConfigFlags flags) { Q_ASSERT_X(isValid(), "KConfigGroup::writeEntry", "accessing an invalid group"); Q_ASSERT_X(!d->bConst, "KConfigGroup::writeEntry", "writing to a read-only group"); @@ -870,8 +860,7 @@ void KConfigGroup::writeEntry(const char *key, const QByteArray &value, config()->d_func()->putData(d->fullName(), key, value.isNull() ? QByteArray("") : value, flags); } -void KConfigGroup::writeEntry(const QString &key, const QByteArray &value, - WriteConfigFlags pFlags) +void KConfigGroup::writeEntry(const QString &key, const QByteArray &value, WriteConfigFlags pFlags) { writeEntry(key.toUtf8().constData(), value, pFlags); } @@ -915,14 +904,13 @@ void KConfigGroup::writeEntry(const char *key, const QVariantList &list, WriteCo writeEntry(key, KConfigGroupPrivate::serializeList(data), flags); } -void KConfigGroup::writeEntry(const char *key, const QVariant &value, - WriteConfigFlags flags) +void KConfigGroup::writeEntry(const char *key, const QVariant &value, WriteConfigFlags flags) { Q_ASSERT_X(isValid(), "KConfigGroup::writeEntry", "accessing an invalid group"); Q_ASSERT_X(!d->bConst, "KConfigGroup::writeEntry", "writing to a read-only group"); if (writeEntryGui(this, key, value, flags)) { - return; // GUI type that was handled + return; // GUI type that was handled } QByteArray data; @@ -948,8 +936,9 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value, break; case QMetaType::QVariantList: if (!value.canConvert(QMetaType::QStringList)) - qCWarning(KCONFIG_CORE_LOG) << "not all types in \"" << key << "\" can convert to QString," - " information will be lost"; + qCWarning(KCONFIG_CORE_LOG) << "not all types in \"" << key + << "\" can convert to QString," + " information will be lost"; Q_FALLTHROUGH(); case QMetaType::QStringList: writeEntry(key, value.toList(), flags); @@ -957,10 +946,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value, case QMetaType::QPoint: { const QPoint rPoint = value.toPoint(); - const QVariantList list{ - rPoint.x(), - rPoint.y() - }; + const QVariantList list{rPoint.x(), rPoint.y()}; writeEntry(key, list, flags); return; @@ -968,10 +954,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value, case QMetaType::QPointF: { const QPointF point = value.toPointF(); - const QVariantList list{ - point.x(), - point.y() - }; + const QVariantList list{point.x(), point.y()}; writeEntry(key, list, flags); return; @@ -979,12 +962,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value, case QMetaType::QRect: { const QRect rRect = value.toRect(); - const QVariantList list{ - rRect.left(), - rRect.top(), - rRect.width(), - rRect.height() - }; + const QVariantList list{rRect.left(), rRect.top(), rRect.width(), rRect.height()}; writeEntry(key, list, flags); return; @@ -992,12 +970,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value, case QMetaType::QRectF: { const QRectF rRectF = value.toRectF(); - const QVariantList list{ - rRectF.left(), - rRectF.top(), - rRectF.width(), - rRectF.height() - }; + const QVariantList list{rRectF.left(), rRectF.top(), rRectF.width(), rRectF.height()}; writeEntry(key, list, flags); return; @@ -1005,10 +978,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value, case QMetaType::QSize: { const QSize rSize = value.toSize(); - const QVariantList list{ - rSize.width(), - rSize.height() - }; + const QVariantList list{rSize.width(), rSize.height()}; writeEntry(key, list, flags); return; @@ -1016,10 +986,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value, case QMetaType::QSizeF: { const QSizeF rSizeF = value.toSizeF(); - const QVariantList list{ - rSizeF.width(), - rSizeF.height() - }; + const QVariantList list{rSizeF.width(), rSizeF.height()}; writeEntry(key, list, flags); return; @@ -1027,11 +994,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value, case QMetaType::QDate: { const QDate date = value.toDate(); - const QVariantList list{ - date.year(), - date.month(), - date.day() - }; + const QVariantList list{date.year(), date.month(), date.day()}; writeEntry(key, list, flags); return; @@ -1049,7 +1012,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value, time.hour(), time.minute(), - time.second() + time.msec()/1000.0, + time.second() + time.msec() / 1000.0, }; writeEntry(key, list, flags); @@ -1058,10 +1021,9 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value, case QMetaType::QColor: case QMetaType::QFont: - qCWarning(KCONFIG_CORE_LOG) << "KConfigGroup::writeEntry was passed GUI type '" - << value.typeName() - << "' but KConfigGui isn't linked! If it is linked to your program, this is a platform bug. " - "Please inform the KDE developers"; + qCWarning(KCONFIG_CORE_LOG) << "KConfigGroup::writeEntry was passed GUI type '" << value.typeName() + << "' but KConfigGui isn't linked! If it is linked to your program, this is a platform bug. " + "Please inform the KDE developers"; break; case QMetaType::QUrl: data = QUrl(value.toUrl()).toString().toUtf8(); @@ -1260,7 +1222,7 @@ bool KConfigGroup::isGroupImmutableImpl(const QByteArray &b) const Q_ASSERT_X(isValid(), "KConfigGroup::isGroupImmutableImpl", "accessing an invalid group"); if (!hasGroupImpl(b)) { // group doesn't exist yet - return d->bImmutable; // child groups are immutable if the parent is immutable. + return d->bImmutable; // child groups are immutable if the parent is immutable. } return config()->isGroupImmutable(d->fullName(b)); diff --git a/src/core/kconfiggroup.h b/src/core/kconfiggroup.h index 620f04c0..5c125dd2 100644 --- a/src/core/kconfiggroup.h +++ b/src/core/kconfiggroup.h @@ -16,8 +16,8 @@ #include #include -#include #include +#include class KConfig; class KConfigGroupPrivate; @@ -246,7 +246,7 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase * * @see writeEntry(), deleteEntry(), hasKey() */ - template + template T readEntry(const QString &key, const T &aDefault) const { return readEntry(key.toUtf8().constData(), aDefault); @@ -255,7 +255,7 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase * Overload for readEntry(const QString&, const T&) const * @param key name of key, encoded in UTF-8 */ - template + template T readEntry(const char *key, const T &aDefault) const; /** @@ -414,14 +414,12 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase * @param aDefault a default value returned if the key was not found * @return the value for this key, or @p aDefault if the key does not exist */ - QString readEntryUntranslated(const QString &pKey, - const QString &aDefault = QString()) const; + QString readEntryUntranslated(const QString &pKey, const QString &aDefault = QString()) const; /** * Overload for readEntryUntranslated(const QString&, const QString&) const * @param key name of key, encoded in UTF-8 */ - QString readEntryUntranslated(const char *key, - const QString &aDefault = QString()) const; + QString readEntryUntranslated(const char *key, const QString &aDefault = QString()) const; /** * Writes a value to the configuration object. @@ -432,34 +430,28 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase * * @see readEntry(), writeXdgListEntry(), deleteEntry() */ - void writeEntry(const QString &key, const QVariant &value, - WriteConfigFlags pFlags = Normal); + void writeEntry(const QString &key, const QVariant &value, WriteConfigFlags pFlags = Normal); /** * Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) * @param key name of key, encoded in UTF-8 */ - void writeEntry(const char *key, const QVariant &value, - WriteConfigFlags pFlags = Normal); + void writeEntry(const char *key, const QVariant &value, WriteConfigFlags pFlags = Normal); /** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */ - void writeEntry(const QString &key, const QString &value, - WriteConfigFlags pFlags = Normal); + void writeEntry(const QString &key, const QString &value, WriteConfigFlags pFlags = Normal); /** * Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) * @param key name of key, encoded in UTF-8 */ - void writeEntry(const char *key, const QString &value, - WriteConfigFlags pFlags = Normal); + void writeEntry(const char *key, const QString &value, WriteConfigFlags pFlags = Normal); /** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */ - void writeEntry(const QString &key, const QByteArray &value, - WriteConfigFlags pFlags = Normal); + void writeEntry(const QString &key, const QByteArray &value, WriteConfigFlags pFlags = Normal); /** * Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) * @param key name of key, encoded in UTF-8 */ - void writeEntry(const char *key, const QByteArray &value, - WriteConfigFlags pFlags = Normal); + void writeEntry(const char *key, const QByteArray &value, WriteConfigFlags pFlags = Normal); /** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */ void writeEntry(const QString &key, const char *value, WriteConfigFlags pFlags = Normal); @@ -473,37 +465,33 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase * Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) * @param key name of key, encoded in UTF-8 */ - template + template void writeEntry(const char *key, const T &value, WriteConfigFlags pFlags = Normal); /** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */ - template + template void writeEntry(const QString &key, const T &value, WriteConfigFlags pFlags = Normal) { writeEntry(key.toUtf8().constData(), value, pFlags); } /** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */ - void writeEntry(const QString &key, const QStringList &value, - WriteConfigFlags pFlags = Normal); + void writeEntry(const QString &key, const QStringList &value, WriteConfigFlags pFlags = Normal); /** * Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) * @param key name of key, encoded in UTF-8 */ - void writeEntry(const char *key, const QStringList &value, - WriteConfigFlags pFlags = Normal); + void writeEntry(const char *key, const QStringList &value, WriteConfigFlags pFlags = Normal); /** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */ - void writeEntry(const QString &key, const QVariantList &value, - WriteConfigFlags pFlags = Normal); + void writeEntry(const QString &key, const QVariantList &value, WriteConfigFlags pFlags = Normal); /** * Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) * @param key name of key, encoded in UTF-8 */ - void writeEntry(const char *key, const QVariantList &value, - WriteConfigFlags pFlags = Normal); + void writeEntry(const char *key, const QVariantList &value, WriteConfigFlags pFlags = Normal); /** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */ - template + template void writeEntry(const QString &key, const QList &value, WriteConfigFlags pFlags = Normal) { writeEntry(key.toUtf8().constData(), value, pFlags); @@ -512,7 +500,7 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase * Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) * @param key name of key, encoded in UTF-8 */ - template + template void writeEntry(const char *key, const QList &value, WriteConfigFlags pFlags = Normal); /** @@ -525,14 +513,12 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase * * @see writeEntry(), readXdgListEntry() */ - void writeXdgListEntry(const QString &pKey, const QStringList &value, - WriteConfigFlags pFlags = Normal); + void writeXdgListEntry(const QString &pKey, const QStringList &value, WriteConfigFlags pFlags = Normal); /** * Overload for writeXdgListEntry(const QString&, const QStringList&, WriteConfigFlags) * @param key name of key, encoded in UTF-8 */ - void writeXdgListEntry(const char *key, const QStringList &value, - WriteConfigFlags pFlags = Normal); + void writeXdgListEntry(const char *key, const QStringList &value, WriteConfigFlags pFlags = Normal); /** * Writes a file path to the configuration @@ -547,14 +533,12 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase * * @see writeEntry(), readPathEntry() */ - void writePathEntry(const QString &pKey, const QString &path, - WriteConfigFlags pFlags = Normal); + void writePathEntry(const QString &pKey, const QString &path, WriteConfigFlags pFlags = Normal); /** * Overload for writePathEntry(const QString&, const QString&, WriteConfigFlags) * @param key name of key, encoded in UTF-8 */ - void writePathEntry(const char *Key, const QString &path, - WriteConfigFlags pFlags = Normal); + void writePathEntry(const char *Key, const QString &path, WriteConfigFlags pFlags = Normal); /** * Writes a list of paths to the configuration @@ -569,14 +553,12 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase * * @see writeEntry(), readPathEntry() */ - void writePathEntry(const QString &pKey, const QStringList &value, - WriteConfigFlags pFlags = Normal); + void writePathEntry(const QString &pKey, const QStringList &value, WriteConfigFlags pFlags = Normal); /** * Overload for writePathEntry(const QString&, const QStringList&, WriteConfigFlags) * @param key name of key, encoded in UTF-8 */ - void writePathEntry(const char *key, const QStringList &value, - WriteConfigFlags pFlags = Normal); + void writePathEntry(const char *key, const QStringList &value, WriteConfigFlags pFlags = Normal); /** * Deletes the entry specified by @p pKey in the current group @@ -742,9 +724,7 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase friend class KServicePrivate; // XXX yeah, ugly^5 }; -#define KCONFIGGROUP_ENUMERATOR_ERROR(ENUM) \ - "The Qt MetaObject system does not seem to know about \"" ENUM \ - "\" please use Q_ENUM or Q_FLAG to register it." +#define KCONFIGGROUP_ENUMERATOR_ERROR(ENUM) "The Qt MetaObject system does not seem to know about \"" ENUM "\" please use Q_ENUM or Q_FLAG to register it." /** * To add support for your own enums in KConfig, you can declare them with Q_ENUM() @@ -754,70 +734,88 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase * KCONFIGGROUP_DECLARE_ENUM_QOBJECT(MyClass, MyEnum) * */ -#define KCONFIGGROUP_DECLARE_ENUM_QOBJECT(Class, Enum) \ - template<> \ - Class::Enum KConfigGroup::readEntry(const char* key, const Class::Enum& def) const\ - { \ - const QMetaObject* M_obj = &Class::staticMetaObject; \ - const int M_index = M_obj->indexOfEnumerator(#Enum); \ - if(M_index == -1) qFatal(KCONFIGGROUP_ENUMERATOR_ERROR(#Enum)); \ - const QMetaEnum M_enum = M_obj->enumerator(M_index); \ - const QByteArray M_data = readEntry(key, QByteArray(M_enum.valueToKey(def)));\ - return static_cast(M_enum.keyToValue(M_data.constData())); \ - } \ - inline Class::Enum Q_DECL_DEPRECATED readEntry(const KConfigGroup& group, const char* key, const Class::Enum& def)\ - { return group.readEntry(key, def); } \ - template<> \ - void KConfigGroup::writeEntry(const char* key, const Class::Enum& value, KConfigBase::WriteConfigFlags flags)\ - { \ - const QMetaObject* M_obj = &Class::staticMetaObject; \ - const int M_index = M_obj->indexOfEnumerator(#Enum); \ - if(M_index == -1) qFatal(KCONFIGGROUP_ENUMERATOR_ERROR(#Enum)); \ - const QMetaEnum M_enum = M_obj->enumerator(M_index); \ - writeEntry(key, QByteArray(M_enum.valueToKey(value)), flags); \ - } \ - inline void Q_DECL_DEPRECATED writeEntry(KConfigGroup& group, const char* key, const Class::Enum& value, KConfigBase::WriteConfigFlags flags = KConfigBase::Normal)\ - { group.writeEntry(key, value, flags); } +#define KCONFIGGROUP_DECLARE_ENUM_QOBJECT(Class, Enum) \ + template<> \ + Class::Enum KConfigGroup::readEntry(const char *key, const Class::Enum &def) const \ + { \ + const QMetaObject *M_obj = &Class::staticMetaObject; \ + const int M_index = M_obj->indexOfEnumerator(#Enum); \ + if (M_index == -1) \ + qFatal(KCONFIGGROUP_ENUMERATOR_ERROR(#Enum)); \ + const QMetaEnum M_enum = M_obj->enumerator(M_index); \ + const QByteArray M_data = readEntry(key, QByteArray(M_enum.valueToKey(def))); \ + return static_cast(M_enum.keyToValue(M_data.constData())); \ + } \ + inline Class::Enum Q_DECL_DEPRECATED readEntry(const KConfigGroup &group, const char *key, const Class::Enum &def) \ + { \ + return group.readEntry(key, def); \ + } \ + template<> \ + void KConfigGroup::writeEntry(const char *key, const Class::Enum &value, KConfigBase::WriteConfigFlags flags) \ + { \ + const QMetaObject *M_obj = &Class::staticMetaObject; \ + const int M_index = M_obj->indexOfEnumerator(#Enum); \ + if (M_index == -1) \ + qFatal(KCONFIGGROUP_ENUMERATOR_ERROR(#Enum)); \ + const QMetaEnum M_enum = M_obj->enumerator(M_index); \ + writeEntry(key, QByteArray(M_enum.valueToKey(value)), flags); \ + } \ + inline void Q_DECL_DEPRECATED writeEntry(KConfigGroup &group, \ + const char *key, \ + const Class::Enum &value, \ + KConfigBase::WriteConfigFlags flags = KConfigBase::Normal) \ + { \ + group.writeEntry(key, value, flags); \ + } /** * Similar to KCONFIGGROUP_DECLARE_ENUM_QOBJECT but for flags declared with Q_FLAG() * (where multiple values can be set at the same time) */ -#define KCONFIGGROUP_DECLARE_FLAGS_QOBJECT(Class, Flags) \ - template<> \ - Class::Flags KConfigGroup::readEntry(const char* key, const Class::Flags& def) const\ - { \ - const QMetaObject* M_obj = &Class::staticMetaObject; \ - const int M_index = M_obj->indexOfEnumerator(#Flags); \ - if(M_index == -1) qFatal(KCONFIGGROUP_ENUMERATOR_ERROR(#Flags)); \ - const QMetaEnum M_enum = M_obj->enumerator(M_index); \ - const QByteArray M_data = readEntry(key, QByteArray(M_enum.valueToKeys(def)));\ - return static_cast(M_enum.keysToValue(M_data.constData())); \ - } \ - inline Class::Flags Q_DECL_DEPRECATED readEntry(const KConfigGroup& group, const char* key, const Class::Flags& def)\ - { return group.readEntry(key, def);} \ - template<> \ - void KConfigGroup::writeEntry(const char* key, const Class::Flags& value, KConfigBase::WriteConfigFlags flags)\ - { \ - const QMetaObject* M_obj = &Class::staticMetaObject; \ - const int M_index = M_obj->indexOfEnumerator(#Flags); \ - if(M_index == -1) qFatal(KCONFIGGROUP_ENUMERATOR_ERROR(#Flags)); \ - const QMetaEnum M_enum = M_obj->enumerator(M_index); \ - writeEntry(key, QByteArray(M_enum.valueToKeys(value)), flags); \ - } \ - inline void Q_DECL_DEPRECATED writeEntry(KConfigGroup& group, const char* key, const Class::Flags& value, KConfigBase::WriteConfigFlags flags = KConfigBase::Normal)\ - { group.writeEntry(key, value, flags); } +#define KCONFIGGROUP_DECLARE_FLAGS_QOBJECT(Class, Flags) \ + template<> \ + Class::Flags KConfigGroup::readEntry(const char *key, const Class::Flags &def) const \ + { \ + const QMetaObject *M_obj = &Class::staticMetaObject; \ + const int M_index = M_obj->indexOfEnumerator(#Flags); \ + if (M_index == -1) \ + qFatal(KCONFIGGROUP_ENUMERATOR_ERROR(#Flags)); \ + const QMetaEnum M_enum = M_obj->enumerator(M_index); \ + const QByteArray M_data = readEntry(key, QByteArray(M_enum.valueToKeys(def))); \ + return static_cast(M_enum.keysToValue(M_data.constData())); \ + } \ + inline Class::Flags Q_DECL_DEPRECATED readEntry(const KConfigGroup &group, const char *key, const Class::Flags &def) \ + { \ + return group.readEntry(key, def); \ + } \ + template<> \ + void KConfigGroup::writeEntry(const char *key, const Class::Flags &value, KConfigBase::WriteConfigFlags flags) \ + { \ + const QMetaObject *M_obj = &Class::staticMetaObject; \ + const int M_index = M_obj->indexOfEnumerator(#Flags); \ + if (M_index == -1) \ + qFatal(KCONFIGGROUP_ENUMERATOR_ERROR(#Flags)); \ + const QMetaEnum M_enum = M_obj->enumerator(M_index); \ + writeEntry(key, QByteArray(M_enum.valueToKeys(value)), flags); \ + } \ + inline void Q_DECL_DEPRECATED writeEntry(KConfigGroup &group, \ + const char *key, \ + const Class::Flags &value, \ + KConfigBase::WriteConfigFlags flags = KConfigBase::Normal) \ + { \ + group.writeEntry(key, value, flags); \ + } #include "conversioncheck.h" -template +template T KConfigGroup::readEntry(const char *key, const T &defaultValue) const { ConversionCheck::to_QVariant(); return qvariant_cast(readEntry(key, QVariant::fromValue(defaultValue))); } -template +template QList KConfigGroup::readEntry(const char *key, const QList &defaultValue) const { ConversionCheck::to_QVariant(); @@ -839,14 +837,14 @@ QList KConfigGroup::readEntry(const char *key, const QList &defaultValue) return list; } -template +template void KConfigGroup::writeEntry(const char *key, const T &value, WriteConfigFlags pFlags) { ConversionCheck::to_QVariant(); writeEntry(key, QVariant::fromValue(value), pFlags); } -template +template void KConfigGroup::writeEntry(const char *key, const QList &list, WriteConfigFlags pFlags) { ConversionCheck::to_QVariant(); diff --git a/src/core/kconfiggroup_p.h b/src/core/kconfiggroup_p.h index 923387e7..2744c153 100644 --- a/src/core/kconfiggroup_p.h +++ b/src/core/kconfiggroup_p.h @@ -8,16 +8,14 @@ #ifndef KCONFIGGROUP_P_H #define KCONFIGGROUP_P_H -#include #include "kconfiggroup.h" +#include class KConfigGroup; struct KConfigGroupGui { - typedef bool (*kReadEntryGui)(const QByteArray &data, const char *key, const QVariant &input, - QVariant &output); - typedef bool (*kWriteEntryGui)(KConfigGroup *, const char *key, const QVariant &input, - KConfigGroup::WriteConfigFlags flags); + typedef bool (*kReadEntryGui)(const QByteArray &data, const char *key, const QVariant &input, QVariant &output); + typedef bool (*kWriteEntryGui)(KConfigGroup *, const char *key, const QVariant &input, KConfigGroup::WriteConfigFlags flags); kReadEntryGui readEntryGui; kWriteEntryGui writeEntryGui; diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp index 96cd3763..6271bcd5 100644 --- a/src/core/kconfigini.cpp +++ b/src/core/kconfigini.cpp @@ -9,26 +9,26 @@ #include "kconfigini_p.h" +#include "bufferfragment_p.h" #include "kconfig.h" +#include "kconfig_core_log_settings.h" #include "kconfigbackend_p.h" -#include "bufferfragment_p.h" #include "kconfigdata.h" -#include "kconfig_core_log_settings.h" -#include -#include #include +#include #include #include #include -#include +#include +#include #include #ifndef Q_OS_WIN #include // getuid, close #endif -#include // uid_t #include // open +#include // uid_t KCONFIGCORE_EXPORT bool kde_kiosk_exception = false; // flag to disable kiosk restrictions @@ -44,12 +44,12 @@ static QByteArray lookup(const KConfigIniBackend::BufferFragment fragment, QHash QString KConfigIniBackend::warningProlog(const QFile &file, int line) { - return QStringLiteral("KConfigIni: In file %2, line %1: ") - .arg(line).arg(file.fileName()); + return QStringLiteral("KConfigIni: In file %2, line %1: ").arg(line).arg(file.fileName()); } KConfigIniBackend::KConfigIniBackend() - : KConfigBackend(), lockFile(nullptr) + : KConfigBackend() + , lockFile(nullptr) { } @@ -57,18 +57,14 @@ KConfigIniBackend::~KConfigIniBackend() { } -KConfigBackend::ParseInfo -KConfigIniBackend::parseConfig(const QByteArray ¤tLocale, KEntryMap &entryMap, - ParseOptions options) +KConfigBackend::ParseInfo KConfigIniBackend::parseConfig(const QByteArray ¤tLocale, KEntryMap &entryMap, ParseOptions options) { return parseConfig(currentLocale, entryMap, options, false); } // merging==true is the merging that happens at the beginning of writeConfig: // merge changes in the on-disk file with the changes in the KConfig object. -KConfigBackend::ParseInfo -KConfigIniBackend::parseConfig(const QByteArray ¤tLocale, KEntryMap &entryMap, - ParseOptions options, bool merging) +KConfigBackend::ParseInfo KConfigIniBackend::parseConfig(const QByteArray ¤tLocale, KEntryMap &entryMap, ParseOptions options, bool merging) { if (filePath().isEmpty() || !QFile::exists(filePath())) { return ParseOk; @@ -137,8 +133,7 @@ KConfigIniBackend::parseConfig(const QByteArray ¤tLocale, KEntryMap &entry } ++end; } - if (end + 1 == line.length() && start + 2 == end && - line.at(start) == '$' && line.at(start + 1) == 'i') { + if (end + 1 == line.length() && start + 2 == end && line.at(start) == '$' && line.at(start + 1) == 'i') { if (newGroup.isEmpty()) { fileOptionImmutable = !kde_kiosk_exception; } else { @@ -162,14 +157,14 @@ KConfigIniBackend::parseConfig(const QByteArray ¤tLocale, KEntryMap &entry } if (groupOptionImmutable) - // Do not make the groups immutable until the entries from - // this file have been added. + // Do not make the groups immutable until the entries from + // this file have been added. { immutableGroups.append(currentGroup); } } else { if (groupSkip && !bDefault) { - continue; // skip entry + continue; // skip entry } BufferFragment aKey; @@ -199,8 +194,7 @@ KConfigIniBackend::parseConfig(const QByteArray ¤tLocale, KEntryMap &entry while ((start = aKey.lastIndexOf('[')) >= 0) { int end = aKey.indexOf(']', start); if (end < 0) { - qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, lineNo) - << "Invalid entry (missing ']')"; + qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, lineNo) << "Invalid entry (missing ']')"; goto next_line; } else if (end > start + 1 && aKey.at(start + 1) == '$') { // found option(s) int i = start + 2; @@ -229,8 +223,7 @@ KConfigIniBackend::parseConfig(const QByteArray ¤tLocale, KEntryMap &entry } } else { // found a locale if (!locale.isNull()) { - qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, lineNo) - << "Invalid entry (second locale!?)"; + qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, lineNo) << "Invalid entry (second locale!?)"; goto next_line; } @@ -250,7 +243,7 @@ KConfigIniBackend::parseConfig(const QByteArray ¤tLocale, KEntryMap &entry if (merging) { entryOptions |= KEntryMap::EntryRawKey; } else { - goto next_line; // skip this entry if we're not merging + goto next_line; // skip this entry if we're not merging } } } @@ -295,8 +288,7 @@ KConfigIniBackend::parseConfig(const QByteArray ¤tLocale, KEntryMap &entry return fileOptionImmutable ? ParseImmutable : ParseOk; } -void KConfigIniBackend::writeEntries(const QByteArray &locale, QIODevice &file, - const KEntryMap &map, bool defaultGroup, bool &firstEntry) +void KConfigIniBackend::writeEntries(const QByteArray &locale, QIODevice &file, const KEntryMap &map, bool defaultGroup, bool &firstEntry) { QByteArray currentGroup; bool groupIsImmutable = false; @@ -306,7 +298,7 @@ void KConfigIniBackend::writeEntries(const QByteArray &locale, QIODevice &file, // Either process the default group or all others if ((key.mGroup != "") == defaultGroup) { - continue; // skip + continue; // skip } // the only thing we care about groups is, is it immutable? @@ -366,9 +358,9 @@ void KConfigIniBackend::writeEntries(const QByteArray &locale, QIODevice &file, } if (currentEntry.bDeleted) { if (currentEntry.bImmutable) { - file.write("[$di]", 5); // Deleted + immutable + file.write("[$di]", 5); // Deleted + immutable } else { - file.write("[$d]", 4); // Deleted + file.write("[$d]", 4); // Deleted } } else { if (currentEntry.bImmutable || currentEntry.bExpand) { @@ -399,8 +391,7 @@ void KConfigIniBackend::writeEntries(const QByteArray &locale, QIODevice &file, writeEntries(locale, file, map, false, firstEntry); } -bool KConfigIniBackend::writeConfig(const QByteArray &locale, KEntryMap &entryMap, - WriteOptions options) +bool KConfigIniBackend::writeConfig(const QByteArray &locale, KEntryMap &entryMap, WriteOptions options) { Q_ASSERT(!filePath().isEmpty()); @@ -442,10 +433,10 @@ bool KConfigIniBackend::writeConfig(const QByteArray &locale, KEntryMap &entryMa defaultKey.bDefault = true; if (!entryMap.contains(defaultKey)) { writeMap.remove(key); // remove the deleted entry if there is no default - //qDebug() << "Detected as deleted=>removed:" << key.mGroup << key.mKey << "global=" << bGlobal; + // qDebug() << "Detected as deleted=>removed:" << key.mGroup << key.mKey << "global=" << bGlobal; } else { writeMap[key] = *it; // otherwise write an explicitly deleted entry - //qDebug() << "Detected as deleted=>[$d]:" << key.mGroup << key.mKey << "global=" << bGlobal; + // qDebug() << "Detected as deleted=>[$d]:" << key.mGroup << key.mKey << "global=" << bGlobal; } } it->bDirty = false; @@ -462,7 +453,7 @@ bool KConfigIniBackend::writeConfig(const QByteArray &locale, KEntryMap &entryMa QFileInfo fi(filePath()); if (fi.exists()) { #ifdef Q_OS_WIN - //TODO: getuid does not exist on windows, use GetSecurityInfo and GetTokenInformation instead + // TODO: getuid does not exist on windows, use GetSecurityInfo and GetTokenInformation instead createNew = false; #else if (fi.ownerId() == ::getuid()) { @@ -574,7 +565,7 @@ void KConfigIniBackend::createEnclosing() { const QString file = filePath(); if (file.isEmpty()) { - return; // nothing to do + return; // nothing to do } // Create the containing dir, maybe it wasn't there @@ -639,106 +630,112 @@ bool KConfigIniBackend::isLocked() const return lockFile && lockFile->isLocked(); } -namespace { - // serialize an escaped byte at the end of @param data - // @param data should have room for 4 bytes - char* escapeByte(char* data, unsigned char s) { - static const char nibbleLookup[] = { - '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' - }; - *data++ = '\\'; - *data++ = 'x'; - *data++ = nibbleLookup[s >> 4]; - *data++ = nibbleLookup[s & 0x0f]; - return data; - } +namespace +{ +// serialize an escaped byte at the end of @param data +// @param data should have room for 4 bytes +char *escapeByte(char *data, unsigned char s) +{ + static const char nibbleLookup[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; + *data++ = '\\'; + *data++ = 'x'; + *data++ = nibbleLookup[s >> 4]; + *data++ = nibbleLookup[s & 0x0f]; + return data; +} - // Struct that represents a multi-byte UTF-8 character. - // This struct is used to keep track of bytes that seem to be valid - // UTF-8. - struct Utf8Char { - public: - unsigned char bytes[4]; - unsigned char count; - unsigned char charLength; - - Utf8Char() { - clear(); - charLength = 0; - } - void clear() { - count = 0; - } - // Add a byte to the UTF8 character. - // When an additional byte leads to an invalid character, return false. - bool addByte(unsigned char b) { - if (count == 0) { - if (b > 0xc1 && (b & 0xe0) == 0xc0) { - charLength = 2; - } else if ((b & 0xf0) == 0xe0) { - charLength = 3; - } else if (b < 0xf5 && (b & 0xf8) == 0xf0) { - charLength = 4; - } else { - return false; +// Struct that represents a multi-byte UTF-8 character. +// This struct is used to keep track of bytes that seem to be valid +// UTF-8. +struct Utf8Char { +public: + unsigned char bytes[4]; + unsigned char count; + unsigned char charLength; + + Utf8Char() + { + clear(); + charLength = 0; + } + void clear() + { + count = 0; + } + // Add a byte to the UTF8 character. + // When an additional byte leads to an invalid character, return false. + bool addByte(unsigned char b) + { + if (count == 0) { + if (b > 0xc1 && (b & 0xe0) == 0xc0) { + charLength = 2; + } else if ((b & 0xf0) == 0xe0) { + charLength = 3; + } else if (b < 0xf5 && (b & 0xf8) == 0xf0) { + charLength = 4; + } else { + return false; + } + bytes[0] = b; + count = 1; + } else if (count < 4 && (b & 0xc0) == 0x80) { + if (count == 1) { + if (charLength == 3 && bytes[0] == 0xe0 && b < 0xa0) { + return false; // overlong 3 byte sequence } - bytes[0] = b; - count = 1; - } else if (count < 4 && (b & 0xc0) == 0x80) { - if (count == 1) { - if (charLength == 3 && bytes[0] == 0xe0 && b < 0xa0) { - return false; // overlong 3 byte sequence + if (charLength == 4) { + if (bytes[0] == 0xf0 && b < 0x90) { + return false; // overlong 4 byte sequence } - if (charLength == 4) { - if (bytes[0] == 0xf0 && b < 0x90) { - return false; // overlong 4 byte sequence - } - if (bytes[0] == 0xf4 && b > 0x8f) { - return false; // Unicode value larger than U+10FFFF - } + if (bytes[0] == 0xf4 && b > 0x8f) { + return false; // Unicode value larger than U+10FFFF } } - bytes[count++] = b; - } else { - return false; } - return true; - } - // Return true if Utf8Char contains one valid character. - bool isComplete() { - return count > 0 && count == charLength; + bytes[count++] = b; + } else { + return false; } - // Add the bytes in this UTF8 character in escaped form to data. - char* escapeBytes(char* data) { - for (unsigned char i = 0; i < count; ++i) { - data = escapeByte(data, bytes[i]); - } - clear(); - return data; + return true; + } + // Return true if Utf8Char contains one valid character. + bool isComplete() + { + return count > 0 && count == charLength; + } + // Add the bytes in this UTF8 character in escaped form to data. + char *escapeBytes(char *data) + { + for (unsigned char i = 0; i < count; ++i) { + data = escapeByte(data, bytes[i]); } - // Add the bytes of the UTF8 character to a buffer. - // Only call this if isComplete() returns true. - char* writeUtf8(char* data) { - for (unsigned char i = 0; i < count; ++i) { - *data++ = bytes[i]; - } - clear(); - return data; + clear(); + return data; + } + // Add the bytes of the UTF8 character to a buffer. + // Only call this if isComplete() returns true. + char *writeUtf8(char *data) + { + for (unsigned char i = 0; i < count; ++i) { + *data++ = bytes[i]; } - // Write the bytes in the UTF8 character literally, or, if the - // character is not complete, write the escaped bytes. - // This is useful to handle the state that remains after handling - // all bytes in a buffer. - char* write(char* data) { - if (isComplete()) { - data = writeUtf8(data); - } else { - data = escapeBytes(data); - } - return data; + clear(); + return data; + } + // Write the bytes in the UTF8 character literally, or, if the + // character is not complete, write the escaped bytes. + // This is useful to handle the state that remains after handling + // all bytes in a buffer. + char *write(char *data) + { + if (isComplete()) { + data = writeUtf8(data); + } else { + data = escapeBytes(data); } - }; + return data; + } +}; } QByteArray KConfigIniBackend::stringToPrintable(const QByteArray &aString, StringType type) @@ -763,7 +760,7 @@ QByteArray KConfigIniBackend::stringToPrintable(const QByteArray &aString, Strin } Utf8Char utf8; - for (; i < l; ++i/*, r++*/) { + for (; i < l; ++i /*, r++*/) { switch (s[i]) { default: if (utf8.addByte(s[i])) { @@ -847,8 +844,8 @@ char KConfigIniBackend::charFromHex(const char *str, const QFile &file, int line } else { QByteArray e(str, 2); e.prepend("\\x"); - qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, line) << "Invalid hex character " << c - << " in \\x-type escape sequence \"" << e.constData() << "\"."; + qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, line) << "Invalid hex character " << c << " in \\x-type escape sequence \"" << e.constData() + << "\"."; return 'x'; } } @@ -915,8 +912,7 @@ void KConfigIniBackend::printableToString(BufferFragment *aString, const QFile & break; default: *r = '\\'; - qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, line) - << QStringLiteral("Invalid escape sequence \"\\%1\".").arg(str[i]); + qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, line) << QStringLiteral("Invalid escape sequence \"\\%1\".").arg(str[i]); } } } diff --git a/src/core/kconfigini_p.h b/src/core/kconfigini_p.h index d760170d..3397857c 100644 --- a/src/core/kconfigini_p.h +++ b/src/core/kconfigini_p.h @@ -10,15 +10,15 @@ #ifndef KCONFIGINI_P_H #define KCONFIGINI_P_H -#include #include +#include class QLockFile; class QIODevice; class KConfigIniBackend : public KConfigBackend { -Q_OBJECT + Q_OBJECT private: QLockFile *lockFile; @@ -28,15 +28,9 @@ Q_OBJECT KConfigIniBackend(); ~KConfigIniBackend() override; - ParseInfo parseConfig(const QByteArray &locale, - KEntryMap &entryMap, - ParseOptions options) override; - ParseInfo parseConfig(const QByteArray &locale, - KEntryMap &entryMap, - ParseOptions options, - bool merging); - bool writeConfig(const QByteArray &locale, KEntryMap &entryMap, - WriteOptions options) override; + ParseInfo parseConfig(const QByteArray &locale, KEntryMap &entryMap, ParseOptions options) override; + ParseInfo parseConfig(const QByteArray &locale, KEntryMap &entryMap, ParseOptions options, bool merging); + bool writeConfig(const QByteArray &locale, KEntryMap &entryMap, WriteOptions options) override; bool isWritable() const override; QString nonWritableErrorMessage() const override; @@ -48,7 +42,6 @@ Q_OBJECT bool isLocked() const override; protected: - enum StringType { GroupString = 0, KeyString = 1, @@ -62,8 +55,7 @@ Q_OBJECT static QString warningProlog(const QFile &file, int line); void writeEntries(const QByteArray &locale, QIODevice &file, const KEntryMap &map); - void writeEntries(const QByteArray &locale, QIODevice &file, const KEntryMap &map, - bool defaultGroup, bool &firstEntry); + void writeEntries(const QByteArray &locale, QIODevice &file, const KEntryMap &map, bool defaultGroup, bool &firstEntry); }; #endif // KCONFIGINI_P_H diff --git a/src/core/kconfigwatcher.cpp b/src/core/kconfigwatcher.cpp index c5aa6205..3da2d535 100644 --- a/src/core/kconfigwatcher.cpp +++ b/src/core/kconfigwatcher.cpp @@ -16,17 +16,18 @@ #endif #include -#include #include +#include -class KConfigWatcherPrivate { +class KConfigWatcherPrivate +{ public: KSharedConfig::Ptr m_config; }; KConfigWatcher::Ptr KConfigWatcher::create(const KSharedConfig::Ptr &config) { - static QThreadStorage>> watcherList; + static QThreadStorage>> watcherList; auto c = config.data(); KConfigWatcher::Ptr watcher; @@ -43,9 +44,9 @@ KConfigWatcher::Ptr KConfigWatcher::create(const KSharedConfig::Ptr &config) return watcherList.localData().value(c).toStrongRef(); } -KConfigWatcher::KConfigWatcher(const KSharedConfig::Ptr &config): - QObject (nullptr), - d(new KConfigWatcherPrivate) +KConfigWatcher::KConfigWatcher(const KSharedConfig::Ptr &config) + : QObject(nullptr) + , d(new KConfigWatcherPrivate) { Q_ASSERT(config); #if KCONFIG_USE_DBUS @@ -65,13 +66,13 @@ KConfigWatcher::KConfigWatcher(const KSharedConfig::Ptr &config): watchedPaths << QStringLiteral("/kdeglobals"); } - for(const QString &path: qAsConst(watchedPaths)) { + for (const QString &path : qAsConst(watchedPaths)) { QDBusConnection::sessionBus().connect(QString(), path, QStringLiteral("org.kde.kconfig.notify"), QStringLiteral("ConfigChanged"), this, - SLOT(onConfigChangeNotification(QHash))); + SLOT(onConfigChangeNotification(QHash))); } #else qCWarning(KCONFIG_CORE_LOG) << "Use of KConfigWatcher without DBus support. You will not receive updates"; @@ -87,17 +88,16 @@ KSharedConfig::Ptr KConfigWatcher::config() const void KConfigWatcher::onConfigChangeNotification(const QHash &changes) { - //should we ever need it we can determine the file changed with QDbusContext::message().path(), but it doesn't seem too useful + // should we ever need it we can determine the file changed with QDbusContext::message().path(), but it doesn't seem too useful d->m_config->reparseConfiguration(); - for(auto it = changes.constBegin(); it != changes.constEnd(); it++) { - KConfigGroup group = d->m_config->group(QString());//top level group - const auto parts = it.key().split(QLatin1Char('\x1d')); //magic char, see KConfig - for(const QString &groupName: parts) { + for (auto it = changes.constBegin(); it != changes.constEnd(); it++) { + KConfigGroup group = d->m_config->group(QString()); // top level group + const auto parts = it.key().split(QLatin1Char('\x1d')); // magic char, see KConfig + for (const QString &groupName : parts) { group = group.group(groupName); } Q_EMIT configChanged(group, it.value()); } } - diff --git a/src/core/kconfigwatcher.h b/src/core/kconfigwatcher.h index 28576bb4..76418c9b 100644 --- a/src/core/kconfigwatcher.h +++ b/src/core/kconfigwatcher.h @@ -10,8 +10,8 @@ #include #include -#include #include +#include #include @@ -23,7 +23,7 @@ class KConfigWatcherPrivate; * Notifies when another client has updated this config file with the Notify flag set. * @since 5.51 */ -class KCONFIGCORE_EXPORT KConfigWatcher: public QObject +class KCONFIGCORE_EXPORT KConfigWatcher : public QObject { Q_OBJECT public: diff --git a/src/core/kcoreconfigskeleton.cpp b/src/core/kcoreconfigskeleton.cpp index d5af41e4..669e0ce5 100644 --- a/src/core/kcoreconfigskeleton.cpp +++ b/src/core/kcoreconfigskeleton.cpp @@ -18,16 +18,14 @@ static QString obscuredString(const QString &str) for (int i = 0; i < str.length(); ++i) // yes, no typo. can't encode ' ' or '!' because // they're the unicode BOM. stupid scrambling. stupid. - result += (unicode[ i ].unicode() <= 0x21) ? unicode[ i ] - : QChar(0x1001F - unicode[ i ].unicode()); + result += (unicode[i].unicode() <= 0x21) ? unicode[i] : QChar(0x1001F - unicode[i].unicode()); return result; } KConfigSkeletonItemPrivate::~KConfigSkeletonItemPrivate() = default; -KConfigSkeletonItem::KConfigSkeletonItem(const QString &_group, - const QString &_key) +KConfigSkeletonItem::KConfigSkeletonItem(const QString &_group, const QString &_key) : mGroup(_group) , mKey(_key) , d_ptr(new KConfigSkeletonItemPrivate) @@ -179,19 +177,19 @@ void KConfigSkeletonItem::readImmutability(const KConfigGroup &group) d->mIsImmutable = group.isEntryImmutable(mKey); } -void KConfigSkeletonItem::setIsDefaultImpl(const std::function &impl) +void KConfigSkeletonItem::setIsDefaultImpl(const std::function &impl) { Q_D(KConfigSkeletonItem); d->mIsDefaultImpl = impl; } -void KConfigSkeletonItem::setIsSaveNeededImpl(const std::function &impl) +void KConfigSkeletonItem::setIsSaveNeededImpl(const std::function &impl) { Q_D(KConfigSkeletonItem); d->mIsSaveNeededImpl = impl; } -void KConfigSkeletonItem::setGetDefaultImpl(const std::function &impl) +void KConfigSkeletonItem::setGetDefaultImpl(const std::function &impl) { Q_D(KConfigSkeletonItem); d->mGetDefaultImpl = impl; @@ -276,18 +274,15 @@ void KPropertySkeletonItem::swapDefault() } } -void KPropertySkeletonItem::setNotifyFunction(const std::function &impl) +void KPropertySkeletonItem::setNotifyFunction(const std::function &impl) { Q_D(KPropertySkeletonItem); d->mNotifyFunction = impl; } -KCoreConfigSkeleton::ItemString::ItemString(const QString &_group, const QString &_key, - QString &reference, - const QString &defaultValue, - Type type) - : KConfigSkeletonGenericItem(_group, _key, reference, defaultValue), - mType(type) +KCoreConfigSkeleton::ItemString::ItemString(const QString &_group, const QString &_key, QString &reference, const QString &defaultValue, Type type) + : KConfigSkeletonGenericItem(_group, _key, reference, defaultValue) + , mType(type) { } @@ -341,23 +336,17 @@ QVariant KCoreConfigSkeleton::ItemString::property() const return QVariant(mReference); } -KCoreConfigSkeleton::ItemPassword::ItemPassword(const QString &_group, const QString &_key, - QString &reference, - const QString &defaultValue) +KCoreConfigSkeleton::ItemPassword::ItemPassword(const QString &_group, const QString &_key, QString &reference, const QString &defaultValue) : ItemString(_group, _key, reference, defaultValue, Password) { } -KCoreConfigSkeleton::ItemPath::ItemPath(const QString &_group, const QString &_key, - QString &reference, - const QString &defaultValue) +KCoreConfigSkeleton::ItemPath::ItemPath(const QString &_group, const QString &_key, QString &reference, const QString &defaultValue) : ItemString(_group, _key, reference, defaultValue, Path) { } -KCoreConfigSkeleton::ItemUrl::ItemUrl(const QString &_group, const QString &_key, - QUrl &reference, - const QUrl &defaultValue) +KCoreConfigSkeleton::ItemUrl::ItemUrl(const QString &_group, const QString &_key, QUrl &reference, const QUrl &defaultValue) : KConfigSkeletonGenericItem(_group, _key, reference, defaultValue) { } @@ -400,10 +389,7 @@ QVariant KCoreConfigSkeleton::ItemUrl::property() const return QVariant::fromValue(mReference); } -KCoreConfigSkeleton::ItemProperty::ItemProperty(const QString &_group, - const QString &_key, - QVariant &reference, - const QVariant &defaultValue) +KCoreConfigSkeleton::ItemProperty::ItemProperty(const QString &_group, const QString &_key, QVariant &reference, const QVariant &defaultValue) : KConfigSkeletonGenericItem(_group, _key, reference, defaultValue) { } @@ -424,7 +410,7 @@ void KCoreConfigSkeleton::ItemProperty::setProperty(const QVariant &p) bool KCoreConfigSkeleton::ItemProperty::isEqual(const QVariant &v) const { - //this might cause problems if the QVariants are not of default types + // this might cause problems if the QVariants are not of default types return mReference == v; } @@ -433,8 +419,7 @@ QVariant KCoreConfigSkeleton::ItemProperty::property() const return mReference; } -KCoreConfigSkeleton::ItemBool::ItemBool(const QString &_group, const QString &_key, - bool &reference, bool defaultValue) +KCoreConfigSkeleton::ItemBool::ItemBool(const QString &_group, const QString &_key, bool &reference, bool defaultValue) : KConfigSkeletonGenericItem(_group, _key, reference, defaultValue) { } @@ -463,10 +448,10 @@ QVariant KCoreConfigSkeleton::ItemBool::property() const return QVariant(mReference); } -KCoreConfigSkeleton::ItemInt::ItemInt(const QString &_group, const QString &_key, - qint32 &reference, qint32 defaultValue) +KCoreConfigSkeleton::ItemInt::ItemInt(const QString &_group, const QString &_key, qint32 &reference, qint32 defaultValue) : KConfigSkeletonGenericItem(_group, _key, reference, defaultValue) - , mHasMin(false), mHasMax(false) + , mHasMin(false) + , mHasMax(false) { } @@ -528,10 +513,10 @@ void KCoreConfigSkeleton::ItemInt::setMaxValue(qint32 v) mMax = v; } -KCoreConfigSkeleton::ItemLongLong::ItemLongLong(const QString &_group, const QString &_key, - qint64 &reference, qint64 defaultValue) +KCoreConfigSkeleton::ItemLongLong::ItemLongLong(const QString &_group, const QString &_key, qint64 &reference, qint64 defaultValue) : KConfigSkeletonGenericItem(_group, _key, reference, defaultValue) - , mHasMin(false), mHasMax(false) + , mHasMin(false) + , mHasMax(false) { } @@ -606,11 +591,9 @@ void KCoreConfigSkeleton::ItemEnum::setValueForChoice(const QString &name, const d_ptr->mValues.insert(name, value); } -KCoreConfigSkeleton::ItemEnum::ItemEnum(const QString &_group, const QString &_key, - qint32 &reference, - const QList &choices, - qint32 defaultValue) - : ItemInt(_group, _key, reference, defaultValue), mChoices(choices) +KCoreConfigSkeleton::ItemEnum::ItemEnum(const QString &_group, const QString &_key, qint32 &reference, const QList &choices, qint32 defaultValue) + : ItemInt(_group, _key, reference, defaultValue) + , mChoices(choices) { } @@ -623,8 +606,7 @@ void KCoreConfigSkeleton::ItemEnum::readConfig(KConfig *config) int i = 0; mReference = -1; QString tmp = cg.readEntry(mKey, QString()).toLower(); - for (QList::ConstIterator it = mChoices.constBegin(); - it != mChoices.constEnd(); ++it, ++i) { + for (QList::ConstIterator it = mChoices.constBegin(); it != mChoices.constEnd(); ++it, ++i) { QString choiceName = (*it).name; if (valueForChoice(choiceName).toLower() == tmp) { mReference = i; @@ -665,11 +647,10 @@ QList KCoreConfigSkeleton::ItemEnum::choi return mChoices; } -KCoreConfigSkeleton::ItemUInt::ItemUInt(const QString &_group, const QString &_key, - quint32 &reference, - quint32 defaultValue) +KCoreConfigSkeleton::ItemUInt::ItemUInt(const QString &_group, const QString &_key, quint32 &reference, quint32 defaultValue) : KConfigSkeletonGenericItem(_group, _key, reference, defaultValue) - , mHasMin(false), mHasMax(false) + , mHasMin(false) + , mHasMax(false) { } @@ -731,10 +712,10 @@ void KCoreConfigSkeleton::ItemUInt::setMaxValue(quint32 v) mMax = v; } -KCoreConfigSkeleton::ItemULongLong::ItemULongLong(const QString &_group, const QString &_key, - quint64 &reference, quint64 defaultValue) +KCoreConfigSkeleton::ItemULongLong::ItemULongLong(const QString &_group, const QString &_key, quint64 &reference, quint64 defaultValue) : KConfigSkeletonGenericItem(_group, _key, reference, defaultValue) - , mHasMin(false), mHasMax(false) + , mHasMin(false) + , mHasMax(false) { } @@ -796,10 +777,10 @@ void KCoreConfigSkeleton::ItemULongLong::setMaxValue(quint64 v) mMax = v; } -KCoreConfigSkeleton::ItemDouble::ItemDouble(const QString &_group, const QString &_key, - double &reference, double defaultValue) +KCoreConfigSkeleton::ItemDouble::ItemDouble(const QString &_group, const QString &_key, double &reference, double defaultValue) : KConfigSkeletonGenericItem(_group, _key, reference, defaultValue) - , mHasMin(false), mHasMax(false) + , mHasMin(false) + , mHasMax(false) { } @@ -861,9 +842,7 @@ void KCoreConfigSkeleton::ItemDouble::setMaxValue(double v) mMax = v; } -KCoreConfigSkeleton::ItemRect::ItemRect(const QString &_group, const QString &_key, - QRect &reference, - const QRect &defaultValue) +KCoreConfigSkeleton::ItemRect::ItemRect(const QString &_group, const QString &_key, QRect &reference, const QRect &defaultValue) : KConfigSkeletonGenericItem(_group, _key, reference, defaultValue) { } @@ -892,9 +871,7 @@ QVariant KCoreConfigSkeleton::ItemRect::property() const return QVariant(mReference); } -KCoreConfigSkeleton::ItemPoint::ItemPoint(const QString &_group, const QString &_key, - QPoint &reference, - const QPoint &defaultValue) +KCoreConfigSkeleton::ItemPoint::ItemPoint(const QString &_group, const QString &_key, QPoint &reference, const QPoint &defaultValue) : KConfigSkeletonGenericItem(_group, _key, reference, defaultValue) { } @@ -923,9 +900,7 @@ QVariant KCoreConfigSkeleton::ItemPoint::property() const return QVariant(mReference); } -KCoreConfigSkeleton::ItemSize::ItemSize(const QString &_group, const QString &_key, - QSize &reference, - const QSize &defaultValue) +KCoreConfigSkeleton::ItemSize::ItemSize(const QString &_group, const QString &_key, QSize &reference, const QSize &defaultValue) : KConfigSkeletonGenericItem(_group, _key, reference, defaultValue) { } @@ -954,9 +929,7 @@ QVariant KCoreConfigSkeleton::ItemSize::property() const return QVariant(mReference); } -KCoreConfigSkeleton::ItemDateTime::ItemDateTime(const QString &_group, const QString &_key, - QDateTime &reference, - const QDateTime &defaultValue) +KCoreConfigSkeleton::ItemDateTime::ItemDateTime(const QString &_group, const QString &_key, QDateTime &reference, const QDateTime &defaultValue) : KConfigSkeletonGenericItem(_group, _key, reference, defaultValue) { } @@ -985,9 +958,7 @@ QVariant KCoreConfigSkeleton::ItemDateTime::property() const return QVariant(mReference); } -KCoreConfigSkeleton::ItemStringList::ItemStringList(const QString &_group, const QString &_key, - QStringList &reference, - const QStringList &defaultValue) +KCoreConfigSkeleton::ItemStringList::ItemStringList(const QString &_group, const QString &_key, QStringList &reference, const QStringList &defaultValue) : KConfigSkeletonGenericItem(_group, _key, reference, defaultValue) { } @@ -1020,9 +991,7 @@ QVariant KCoreConfigSkeleton::ItemStringList::property() const return QVariant(mReference); } -KCoreConfigSkeleton::ItemPathList::ItemPathList(const QString &_group, const QString &_key, - QStringList &reference, - const QStringList &defaultValue) +KCoreConfigSkeleton::ItemPathList::ItemPathList(const QString &_group, const QString &_key, QStringList &reference, const QStringList &defaultValue) : ItemStringList(_group, _key, reference, defaultValue) { } @@ -1054,10 +1023,8 @@ void KCoreConfigSkeleton::ItemPathList::writeConfig(KConfig *config) } } -KCoreConfigSkeleton::ItemUrlList::ItemUrlList(const QString &_group, const QString &_key, - QList &reference, - const QList &defaultValue) - : KConfigSkeletonGenericItem >(_group, _key, reference, defaultValue) +KCoreConfigSkeleton::ItemUrlList::ItemUrlList(const QString &_group, const QString &_key, QList &reference, const QList &defaultValue) + : KConfigSkeletonGenericItem>(_group, _key, reference, defaultValue) { } @@ -1101,23 +1068,21 @@ void KCoreConfigSkeleton::ItemUrlList::writeConfig(KConfig *config) void KCoreConfigSkeleton::ItemUrlList::setProperty(const QVariant &p) { - mReference = qvariant_cast >(p); + mReference = qvariant_cast>(p); } bool KCoreConfigSkeleton::ItemUrlList::isEqual(const QVariant &v) const { - return mReference == qvariant_cast >(v); + return mReference == qvariant_cast>(v); } QVariant KCoreConfigSkeleton::ItemUrlList::property() const { - return QVariant::fromValue >(mReference); + return QVariant::fromValue>(mReference); } -KCoreConfigSkeleton::ItemIntList::ItemIntList(const QString &_group, const QString &_key, - QList &reference, - const QList &defaultValue) - : KConfigSkeletonGenericItem >(_group, _key, reference, defaultValue) +KCoreConfigSkeleton::ItemIntList::ItemIntList(const QString &_group, const QString &_key, QList &reference, const QList &defaultValue) + : KConfigSkeletonGenericItem>(_group, _key, reference, defaultValue) { } @@ -1136,35 +1101,35 @@ void KCoreConfigSkeleton::ItemIntList::readConfig(KConfig *config) void KCoreConfigSkeleton::ItemIntList::setProperty(const QVariant &p) { - mReference = qvariant_cast< QList >(p); + mReference = qvariant_cast>(p); } bool KCoreConfigSkeleton::ItemIntList::isEqual(const QVariant &v) const { - return mReference == qvariant_cast< QList >(v); + return mReference == qvariant_cast>(v); } QVariant KCoreConfigSkeleton::ItemIntList::property() const { - return QVariant::fromValue< QList >(mReference); + return QVariant::fromValue>(mReference); } -//static int kCoreConfigSkeletionDebugArea() { static int s_area = KDebug::registerArea("kdecore (KConfigSkeleton)"); return s_area; } +// static int kCoreConfigSkeletionDebugArea() { static int s_area = KDebug::registerArea("kdecore (KConfigSkeleton)"); return s_area; } KCoreConfigSkeleton::KCoreConfigSkeleton(const QString &configname, QObject *parent) - : QObject(parent), - d(new KCoreConfigSkeletonPrivate) + : QObject(parent) + , d(new KCoreConfigSkeletonPrivate) { - //qDebug() << "Creating KCoreConfigSkeleton (" << (void *)this << ")"; + // qDebug() << "Creating KCoreConfigSkeleton (" << (void *)this << ")"; d->mConfig = KSharedConfig::openConfig(configname, KConfig::FullConfig); } KCoreConfigSkeleton::KCoreConfigSkeleton(KSharedConfig::Ptr pConfig, QObject *parent) - : QObject(parent), - d(new KCoreConfigSkeletonPrivate) + : QObject(parent) + , d(new KCoreConfigSkeletonPrivate) { - //qDebug() << "Creating KCoreConfigSkeleton (" << (void *)this << ")"; + // qDebug() << "Creating KCoreConfigSkeleton (" << (void *)this << ")"; d->mConfig = std::move(pConfig); } @@ -1271,7 +1236,7 @@ bool KCoreConfigSkeleton::isSaveNeeded() const bool KCoreConfigSkeleton::save() { - //qDebug(); + // qDebug(); KConfigSkeletonItem::List::ConstIterator it; for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) { (*it)->writeConfig(d->mConfig.data()); @@ -1330,8 +1295,7 @@ bool KCoreConfigSkeleton::usrWriteConfig() void KCoreConfigSkeleton::addItem(KConfigSkeletonItem *item, const QString &name) { if (d->mItems.contains(item)) { - if (item->name() == name || - (name.isEmpty() && item->name() == item->key())) { + if (item->name() == name || (name.isEmpty() && item->name() == item->key())) { // nothing to do -> it is already in our collection // and the name isn't changing return; @@ -1366,185 +1330,149 @@ void KCoreConfigSkeleton::clearItems() qDeleteAll(items); } -KCoreConfigSkeleton::ItemString *KCoreConfigSkeleton::addItemString(const QString &name, QString &reference, - const QString &defaultValue, const QString &key) +KCoreConfigSkeleton::ItemString *KCoreConfigSkeleton::addItemString(const QString &name, QString &reference, const QString &defaultValue, const QString &key) { KCoreConfigSkeleton::ItemString *item; - item = new KCoreConfigSkeleton::ItemString(d->mCurrentGroup, key.isEmpty() ? name : key, - reference, defaultValue, - KCoreConfigSkeleton::ItemString::Normal); + item = new KCoreConfigSkeleton::ItemString(d->mCurrentGroup, key.isEmpty() ? name : key, reference, defaultValue, KCoreConfigSkeleton::ItemString::Normal); addItem(item, name); return item; } -KCoreConfigSkeleton::ItemPassword *KCoreConfigSkeleton::addItemPassword(const QString &name, QString &reference, - const QString &defaultValue, const QString &key) +KCoreConfigSkeleton::ItemPassword * +KCoreConfigSkeleton::addItemPassword(const QString &name, QString &reference, const QString &defaultValue, const QString &key) { KCoreConfigSkeleton::ItemPassword *item; - item = new KCoreConfigSkeleton::ItemPassword(d->mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue); + item = new KCoreConfigSkeleton::ItemPassword(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue); addItem(item, name); return item; } -KCoreConfigSkeleton::ItemPath *KCoreConfigSkeleton::addItemPath(const QString &name, QString &reference, - const QString &defaultValue, const QString &key) +KCoreConfigSkeleton::ItemPath *KCoreConfigSkeleton::addItemPath(const QString &name, QString &reference, const QString &defaultValue, const QString &key) { KCoreConfigSkeleton::ItemPath *item; - item = new KCoreConfigSkeleton::ItemPath(d->mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue); + item = new KCoreConfigSkeleton::ItemPath(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue); addItem(item, name); return item; } -KCoreConfigSkeleton::ItemProperty *KCoreConfigSkeleton::addItemProperty(const QString &name, QVariant &reference, - const QVariant &defaultValue, const QString &key) +KCoreConfigSkeleton::ItemProperty * +KCoreConfigSkeleton::addItemProperty(const QString &name, QVariant &reference, const QVariant &defaultValue, const QString &key) { KCoreConfigSkeleton::ItemProperty *item; - item = new KCoreConfigSkeleton::ItemProperty(d->mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue); + item = new KCoreConfigSkeleton::ItemProperty(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue); addItem(item, name); return item; } -KCoreConfigSkeleton::ItemBool *KCoreConfigSkeleton::addItemBool(const QString &name, bool &reference, - bool defaultValue, const QString &key) +KCoreConfigSkeleton::ItemBool *KCoreConfigSkeleton::addItemBool(const QString &name, bool &reference, bool defaultValue, const QString &key) { KCoreConfigSkeleton::ItemBool *item; - item = new KCoreConfigSkeleton::ItemBool(d->mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue); + item = new KCoreConfigSkeleton::ItemBool(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue); addItem(item, name); return item; } -KCoreConfigSkeleton::ItemInt *KCoreConfigSkeleton::addItemInt(const QString &name, qint32 &reference, - qint32 defaultValue, const QString &key) +KCoreConfigSkeleton::ItemInt *KCoreConfigSkeleton::addItemInt(const QString &name, qint32 &reference, qint32 defaultValue, const QString &key) { KCoreConfigSkeleton::ItemInt *item; - item = new KCoreConfigSkeleton::ItemInt(d->mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue); + item = new KCoreConfigSkeleton::ItemInt(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue); addItem(item, name); return item; } -KCoreConfigSkeleton::ItemUInt *KCoreConfigSkeleton::addItemUInt(const QString &name, quint32 &reference, - quint32 defaultValue, const QString &key) +KCoreConfigSkeleton::ItemUInt *KCoreConfigSkeleton::addItemUInt(const QString &name, quint32 &reference, quint32 defaultValue, const QString &key) { KCoreConfigSkeleton::ItemUInt *item; - item = new KCoreConfigSkeleton::ItemUInt(d->mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue); + item = new KCoreConfigSkeleton::ItemUInt(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue); addItem(item, name); return item; } -KCoreConfigSkeleton::ItemLongLong *KCoreConfigSkeleton::addItemLongLong(const QString &name, qint64 &reference, - qint64 defaultValue, const QString &key) +KCoreConfigSkeleton::ItemLongLong *KCoreConfigSkeleton::addItemLongLong(const QString &name, qint64 &reference, qint64 defaultValue, const QString &key) { KCoreConfigSkeleton::ItemLongLong *item; - item = new KCoreConfigSkeleton::ItemLongLong(d->mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue); + item = new KCoreConfigSkeleton::ItemLongLong(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue); addItem(item, name); return item; } #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 0) -KCoreConfigSkeleton::ItemLongLong *KCoreConfigSkeleton::addItemInt64( - const QString &name, - qint64 &reference, - qint64 defaultValue, - const QString &key) +KCoreConfigSkeleton::ItemLongLong *KCoreConfigSkeleton::addItemInt64(const QString &name, qint64 &reference, qint64 defaultValue, const QString &key) { return addItemLongLong(name, reference, defaultValue, key); } #endif -KCoreConfigSkeleton::ItemULongLong *KCoreConfigSkeleton::addItemULongLong(const QString &name, quint64 &reference, - quint64 defaultValue, const QString &key) +KCoreConfigSkeleton::ItemULongLong *KCoreConfigSkeleton::addItemULongLong(const QString &name, quint64 &reference, quint64 defaultValue, const QString &key) { KCoreConfigSkeleton::ItemULongLong *item; - item = new KCoreConfigSkeleton::ItemULongLong(d->mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue); + item = new KCoreConfigSkeleton::ItemULongLong(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue); addItem(item, name); return item; } #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 0) -KCoreConfigSkeleton::ItemULongLong *KCoreConfigSkeleton::addItemUInt64( - const QString &name, - quint64 &reference, - quint64 defaultValue, - const QString &key) +KCoreConfigSkeleton::ItemULongLong *KCoreConfigSkeleton::addItemUInt64(const QString &name, quint64 &reference, quint64 defaultValue, const QString &key) { return addItemULongLong(name, reference, defaultValue, key); } #endif -KCoreConfigSkeleton::ItemDouble *KCoreConfigSkeleton::addItemDouble(const QString &name, double &reference, - double defaultValue, const QString &key) +KCoreConfigSkeleton::ItemDouble *KCoreConfigSkeleton::addItemDouble(const QString &name, double &reference, double defaultValue, const QString &key) { KCoreConfigSkeleton::ItemDouble *item; - item = new KCoreConfigSkeleton::ItemDouble(d->mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue); + item = new KCoreConfigSkeleton::ItemDouble(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue); addItem(item, name); return item; } -KCoreConfigSkeleton::ItemRect *KCoreConfigSkeleton::addItemRect(const QString &name, QRect &reference, - const QRect &defaultValue, const QString &key) +KCoreConfigSkeleton::ItemRect *KCoreConfigSkeleton::addItemRect(const QString &name, QRect &reference, const QRect &defaultValue, const QString &key) { KCoreConfigSkeleton::ItemRect *item; - item = new KCoreConfigSkeleton::ItemRect(d->mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue); + item = new KCoreConfigSkeleton::ItemRect(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue); addItem(item, name); return item; } -KCoreConfigSkeleton::ItemPoint *KCoreConfigSkeleton::addItemPoint(const QString &name, QPoint &reference, - const QPoint &defaultValue, const QString &key) +KCoreConfigSkeleton::ItemPoint *KCoreConfigSkeleton::addItemPoint(const QString &name, QPoint &reference, const QPoint &defaultValue, const QString &key) { KCoreConfigSkeleton::ItemPoint *item; - item = new KCoreConfigSkeleton::ItemPoint(d->mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue); + item = new KCoreConfigSkeleton::ItemPoint(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue); addItem(item, name); return item; } -KCoreConfigSkeleton::ItemSize *KCoreConfigSkeleton::addItemSize(const QString &name, QSize &reference, - const QSize &defaultValue, const QString &key) +KCoreConfigSkeleton::ItemSize *KCoreConfigSkeleton::addItemSize(const QString &name, QSize &reference, const QSize &defaultValue, const QString &key) { KCoreConfigSkeleton::ItemSize *item; - item = new KCoreConfigSkeleton::ItemSize(d->mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue); + item = new KCoreConfigSkeleton::ItemSize(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue); addItem(item, name); return item; } -KCoreConfigSkeleton::ItemDateTime *KCoreConfigSkeleton::addItemDateTime(const QString &name, QDateTime &reference, - const QDateTime &defaultValue, const QString &key) +KCoreConfigSkeleton::ItemDateTime * +KCoreConfigSkeleton::addItemDateTime(const QString &name, QDateTime &reference, const QDateTime &defaultValue, const QString &key) { KCoreConfigSkeleton::ItemDateTime *item; - item = new KCoreConfigSkeleton::ItemDateTime(d->mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue); + item = new KCoreConfigSkeleton::ItemDateTime(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue); addItem(item, name); return item; } -KCoreConfigSkeleton::ItemStringList *KCoreConfigSkeleton::addItemStringList(const QString &name, QStringList &reference, - const QStringList &defaultValue, const QString &key) +KCoreConfigSkeleton::ItemStringList * +KCoreConfigSkeleton::addItemStringList(const QString &name, QStringList &reference, const QStringList &defaultValue, const QString &key) { KCoreConfigSkeleton::ItemStringList *item; - item = new KCoreConfigSkeleton::ItemStringList(d->mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue); + item = new KCoreConfigSkeleton::ItemStringList(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue); addItem(item, name); return item; } -KCoreConfigSkeleton::ItemIntList *KCoreConfigSkeleton::addItemIntList(const QString &name, QList &reference, - const QList &defaultValue, const QString &key) +KCoreConfigSkeleton::ItemIntList * +KCoreConfigSkeleton::addItemIntList(const QString &name, QList &reference, const QList &defaultValue, const QString &key) { KCoreConfigSkeleton::ItemIntList *item; - item = new KCoreConfigSkeleton::ItemIntList(d->mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue); + item = new KCoreConfigSkeleton::ItemIntList(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue); addItem(item, name); return item; } @@ -1560,25 +1488,36 @@ KConfigSkeletonItem *KCoreConfigSkeleton::findItem(const QString &name) const return d->mItemDict.value(name); } -KConfigCompilerSignallingItem::KConfigCompilerSignallingItem(KConfigSkeletonItem* item, QObject* object, - KConfigCompilerSignallingItem::NotifyFunction targetFunction, quint64 userData) - : KConfigSkeletonItem(item->group(), item->key()), mItem(item), mTargetFunction(targetFunction), - mObject(object), mUserData(userData) +KConfigCompilerSignallingItem::KConfigCompilerSignallingItem(KConfigSkeletonItem *item, + QObject *object, + KConfigCompilerSignallingItem::NotifyFunction targetFunction, + quint64 userData) + : KConfigSkeletonItem(item->group(), item->key()) + , mItem(item) + , mTargetFunction(targetFunction) + , mObject(object) + , mUserData(userData) { Q_ASSERT(mTargetFunction); Q_ASSERT(mItem); Q_ASSERT(mObject); - setIsDefaultImpl([this] { return mItem->isDefault(); }); - setIsSaveNeededImpl([this] { return mItem->isSaveNeeded(); }); - setGetDefaultImpl([this] {return mItem->getDefault(); }); + setIsDefaultImpl([this] { + return mItem->isDefault(); + }); + setIsSaveNeededImpl([this] { + return mItem->isSaveNeeded(); + }); + setGetDefaultImpl([this] { + return mItem->getDefault(); + }); } KConfigCompilerSignallingItem::~KConfigCompilerSignallingItem() { } -bool KConfigCompilerSignallingItem::isEqual(const QVariant& p) const +bool KConfigCompilerSignallingItem::isEqual(const QVariant &p) const { return mItem->isEqual(p); } @@ -1588,11 +1527,11 @@ QVariant KConfigCompilerSignallingItem::property() const return mItem->property(); } -void KConfigCompilerSignallingItem::readConfig(KConfig* c) +void KConfigCompilerSignallingItem::readConfig(KConfig *c) { QVariant oldValue = mItem->property(); mItem->readConfig(c); - //readConfig() changes mIsImmutable, update it here as well + // readConfig() changes mIsImmutable, update it here as well KConfigGroup cg = configGroup(c); readImmutability(cg); if (!mItem->isEqual(oldValue)) { @@ -1600,15 +1539,15 @@ void KConfigCompilerSignallingItem::readConfig(KConfig* c) } } -void KConfigCompilerSignallingItem::readDefault(KConfig* c) +void KConfigCompilerSignallingItem::readDefault(KConfig *c) { mItem->readDefault(c); - //readDefault() changes mIsImmutable, update it here as well + // readDefault() changes mIsImmutable, update it here as well KConfigGroup cg = configGroup(c); readImmutability(cg); } -void KConfigCompilerSignallingItem::writeConfig(KConfig* c) +void KConfigCompilerSignallingItem::writeConfig(KConfig *c) { mItem->writeConfig(c); } @@ -1622,7 +1561,7 @@ void KConfigCompilerSignallingItem::setDefault() } } -void KConfigCompilerSignallingItem::setProperty(const QVariant& p) +void KConfigCompilerSignallingItem::setProperty(const QVariant &p) { if (!mItem->isEqual(p)) { mItem->setProperty(p); diff --git a/src/core/kcoreconfigskeleton.h b/src/core/kcoreconfigskeleton.h index e7b814e8..aafc417c 100644 --- a/src/core/kcoreconfigskeleton.h +++ b/src/core/kcoreconfigskeleton.h @@ -12,15 +12,15 @@ #include -#include #include +#include #include #include #include #include -#include #include +#include class KCoreConfigSkeletonPrivate; @@ -42,9 +42,9 @@ class KCONFIGCORE_EXPORT KConfigSkeletonItem { Q_DECLARE_PRIVATE(KConfigSkeletonItem) public: - typedef QList < KConfigSkeletonItem * >List; - typedef QHash < QString, KConfigSkeletonItem * > Dict; - typedef QHash < QString, KConfigSkeletonItem * >::Iterator DictIterator; + typedef QList List; + typedef QHash Dict; + typedef QHash::Iterator DictIterator; /** * Constructor. @@ -310,29 +310,35 @@ class KCONFIGCORE_EXPORT KPropertySkeletonItem : public KConfigSkeletonItem * Set a notify function, it will be invoked when the value of the property changes. * @since 5.68 */ - void setNotifyFunction(const std::function &impl); + void setNotifyFunction(const std::function &impl); }; - /** * \class KConfigSkeletonGenericItem kcoreconfigskeleton.h */ -template < typename T > class KConfigSkeletonGenericItem: public KConfigSkeletonItem +template +class KConfigSkeletonGenericItem : public KConfigSkeletonItem { public: /** @copydoc KConfigSkeletonItem(const QString&, const QString&) @param reference The initial value to hold in the item @param defaultValue The default value for the item */ - KConfigSkeletonGenericItem(const QString &_group, const QString &_key, T &reference, - T defaultValue) - : KConfigSkeletonItem(_group, _key), mReference(reference), - mDefault(defaultValue), mLoadedValue(defaultValue) + KConfigSkeletonGenericItem(const QString &_group, const QString &_key, T &reference, T defaultValue) + : KConfigSkeletonItem(_group, _key) + , mReference(reference) + , mDefault(defaultValue) + , mLoadedValue(defaultValue) { - setIsDefaultImpl([this] { return mReference == mDefault; }); - setIsSaveNeededImpl([this] { return mReference != mLoadedValue; }); - setGetDefaultImpl([this] { return QVariant::fromValue(mDefault); }); - + setIsDefaultImpl([this] { + return mReference == mDefault; + }); + setIsSaveNeededImpl([this] { + return mReference != mLoadedValue; + }); + setGetDefaultImpl([this] { + return QVariant::fromValue(mDefault); + }); } /** @@ -407,7 +413,7 @@ template < typename T > class KConfigSkeletonGenericItem: public KConfigSkeleton } protected: - T &mReference; ///< Stores the value for this item + T &mReference; ///< Stores the value for this item T mDefault; ///< The default value for this item T mLoadedValue; }; @@ -428,17 +434,16 @@ template < typename T > class KConfigSkeletonGenericItem: public KConfigSkeleton class KCONFIGCORE_EXPORT KConfigCompilerSignallingItem : public KConfigSkeletonItem { public: - typedef void (QObject::* NotifyFunction)(quint64 arg); - /** - * Constructor. - * - * @param item the KConfigSkeletonItem to wrap - * @param targetFunction the method to invoke whenever the value of @p item changes - * @param object The object on which the method is invoked. - * @param userData This data will be passed to @p targetFunction on every property change - */ - KConfigCompilerSignallingItem(KConfigSkeletonItem *item, QObject* object, - NotifyFunction targetFunction, quint64 userData); + typedef void (QObject::*NotifyFunction)(quint64 arg); + /** + * Constructor. + * + * @param item the KConfigSkeletonItem to wrap + * @param targetFunction the method to invoke whenever the value of @p item changes + * @param object The object on which the method is invoked. + * @param userData This data will be passed to @p targetFunction on every property change + */ + KConfigCompilerSignallingItem(KConfigSkeletonItem *item, QObject *object, NotifyFunction targetFunction, quint64 userData); ~KConfigCompilerSignallingItem() override; void readConfig(KConfig *) override; @@ -466,14 +471,14 @@ class KCONFIGCORE_EXPORT KConfigCompilerSignallingItem : public KConfigSkeletonI // call the pointer to member function using the strange ->* operator (mObject->*mTargetFunction)(mUserData); } + private: QScopedPointer mItem; NotifyFunction mTargetFunction; - QObject* mObject; + QObject *mObject; quint64 mUserData; }; - /** * \class KCoreConfigSkeleton kcoreconfigskeleton.h * @@ -540,7 +545,7 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject /** * Class for handling a string preferences item. */ - class KCONFIGCORE_EXPORT ItemString: public KConfigSkeletonGenericItem < QString > + class KCONFIGCORE_EXPORT ItemString : public KConfigSkeletonGenericItem { public: enum Type { @@ -565,9 +570,10 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem @param type The type of string held by the item */ - ItemString(const QString &_group, const QString &_key, + ItemString(const QString &_group, + const QString &_key, QString &reference, - const QString &defaultValue = QLatin1String(""), // NOT QString() !! + const QString &defaultValue = QLatin1String(""), // NOT QString() !! Type type = Normal); /** @copydoc KConfigSkeletonItem::writeConfig(KConfig*) */ @@ -592,39 +598,33 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject /** * Class for handling a password preferences item. */ - class KCONFIGCORE_EXPORT ItemPassword: public ItemString + class KCONFIGCORE_EXPORT ItemPassword : public ItemString { public: /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ - ItemPassword(const QString &_group, const QString &_key, - QString &reference, - const QString &defaultValue = QLatin1String("")); // NOT QString() !! + ItemPassword(const QString &_group, const QString &_key, QString &reference, + const QString &defaultValue = QLatin1String("")); // NOT QString() !! }; /** * Class for handling a path preferences item. */ - class KCONFIGCORE_EXPORT ItemPath: public ItemString + class KCONFIGCORE_EXPORT ItemPath : public ItemString { public: /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ - ItemPath(const QString &_group, const QString &_key, - QString &reference, - const QString &defaultValue = QString()); + ItemPath(const QString &_group, const QString &_key, QString &reference, const QString &defaultValue = QString()); }; /** * Class for handling a url preferences item. */ - class KCONFIGCORE_EXPORT ItemUrl: public KConfigSkeletonGenericItem < QUrl > + class KCONFIGCORE_EXPORT ItemUrl : public KConfigSkeletonGenericItem { public: - /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ - ItemUrl(const QString &_group, const QString &_key, - QUrl &reference, - const QUrl &defaultValue = QUrl()); + ItemUrl(const QString &_group, const QString &_key, QUrl &reference, const QUrl &defaultValue = QUrl()); /** @copydoc KConfigSkeletonItem::writeConfig(KConfig*) */ void writeConfig(KConfig *config) override; @@ -645,12 +645,11 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject /** * Class for handling a QVariant preferences item. */ - class KCONFIGCORE_EXPORT ItemProperty: public KConfigSkeletonGenericItem < QVariant > + class KCONFIGCORE_EXPORT ItemProperty : public KConfigSkeletonGenericItem { public: /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ - ItemProperty(const QString &_group, const QString &_key, - QVariant &reference, const QVariant &defaultValue = QVariant()); + ItemProperty(const QString &_group, const QString &_key, QVariant &reference, const QVariant &defaultValue = QVariant()); void readConfig(KConfig *config) override; void setProperty(const QVariant &p) override; @@ -665,12 +664,11 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject /** * Class for handling a bool preferences item. */ - class KCONFIGCORE_EXPORT ItemBool: public KConfigSkeletonGenericItem < bool > + class KCONFIGCORE_EXPORT ItemBool : public KConfigSkeletonGenericItem { public: /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ - ItemBool(const QString &_group, const QString &_key, bool &reference, - bool defaultValue = true); + ItemBool(const QString &_group, const QString &_key, bool &reference, bool defaultValue = true); /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */ void readConfig(KConfig *config) override; @@ -688,12 +686,11 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject /** * Class for handling a 32-bit integer preferences item. */ - class KCONFIGCORE_EXPORT ItemInt: public KConfigSkeletonGenericItem < qint32 > + class KCONFIGCORE_EXPORT ItemInt : public KConfigSkeletonGenericItem { public: /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ - ItemInt(const QString &_group, const QString &_key, qint32 &reference, - qint32 defaultValue = 0); + ItemInt(const QString &_group, const QString &_key, qint32 &reference, qint32 defaultValue = 0); /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */ void readConfig(KConfig *config) override; @@ -733,12 +730,11 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject /** * Class for handling a 64-bit integer preferences item. */ - class KCONFIGCORE_EXPORT ItemLongLong: public KConfigSkeletonGenericItem < qint64 > + class KCONFIGCORE_EXPORT ItemLongLong : public KConfigSkeletonGenericItem { public: /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ - ItemLongLong(const QString &_group, const QString &_key, qint64 &reference, - qint64 defaultValue = 0); + ItemLongLong(const QString &_group, const QString &_key, qint64 &reference, qint64 defaultValue = 0); /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */ void readConfig(KConfig *config) override; @@ -777,7 +773,7 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject /** * Class for handling enums. */ - class KCONFIGCORE_EXPORT ItemEnum: public ItemInt + class KCONFIGCORE_EXPORT ItemEnum : public ItemInt { public: struct Choice { @@ -790,8 +786,7 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem @param choices The list of enums that can be stored in this item */ - ItemEnum(const QString &_group, const QString &_key, qint32 &reference, - const QList &choices, qint32 defaultValue = 0); + ItemEnum(const QString &_group, const QString &_key, qint32 &reference, const QList &choices, qint32 defaultValue = 0); QList choices() const; @@ -823,12 +818,11 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject /** * Class for handling an unsigned 32-bit integer preferences item. */ - class KCONFIGCORE_EXPORT ItemUInt: public KConfigSkeletonGenericItem < quint32 > + class KCONFIGCORE_EXPORT ItemUInt : public KConfigSkeletonGenericItem { public: /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ - ItemUInt(const QString &_group, const QString &_key, - quint32 &reference, quint32 defaultValue = 0); + ItemUInt(const QString &_group, const QString &_key, quint32 &reference, quint32 defaultValue = 0); /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */ void readConfig(KConfig *config) override; @@ -864,12 +858,11 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject /** * Class for handling unsigned 64-bit integer preferences item. */ - class KCONFIGCORE_EXPORT ItemULongLong: public KConfigSkeletonGenericItem < quint64 > + class KCONFIGCORE_EXPORT ItemULongLong : public KConfigSkeletonGenericItem { public: /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ - ItemULongLong(const QString &_group, const QString &_key, quint64 &reference, - quint64 defaultValue = 0); + ItemULongLong(const QString &_group, const QString &_key, quint64 &reference, quint64 defaultValue = 0); /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */ void readConfig(KConfig *config) override; @@ -908,12 +901,11 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject /** * Class for handling a floating point preference item. */ - class KCONFIGCORE_EXPORT ItemDouble: public KConfigSkeletonGenericItem < double > + class KCONFIGCORE_EXPORT ItemDouble : public KConfigSkeletonGenericItem { public: /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ - ItemDouble(const QString &_group, const QString &_key, - double &reference, double defaultValue = 0); + ItemDouble(const QString &_group, const QString &_key, double &reference, double defaultValue = 0); /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */ void readConfig(KConfig *config) override; @@ -949,12 +941,11 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject /** * Class for handling a QRect preferences item. */ - class KCONFIGCORE_EXPORT ItemRect: public KConfigSkeletonGenericItem < QRect > + class KCONFIGCORE_EXPORT ItemRect : public KConfigSkeletonGenericItem { public: /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ - ItemRect(const QString &_group, const QString &_key, QRect &reference, - const QRect &defaultValue = QRect()); + ItemRect(const QString &_group, const QString &_key, QRect &reference, const QRect &defaultValue = QRect()); /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */ void readConfig(KConfig *config) override; @@ -972,12 +963,11 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject /** * Class for handling a QPoint preferences item. */ - class KCONFIGCORE_EXPORT ItemPoint: public KConfigSkeletonGenericItem < QPoint > + class KCONFIGCORE_EXPORT ItemPoint : public KConfigSkeletonGenericItem { public: /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ - ItemPoint(const QString &_group, const QString &_key, QPoint &reference, - const QPoint &defaultValue = QPoint()); + ItemPoint(const QString &_group, const QString &_key, QPoint &reference, const QPoint &defaultValue = QPoint()); /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */ void readConfig(KConfig *config) override; @@ -995,12 +985,11 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject /** * Class for handling a QSize preferences item. */ - class KCONFIGCORE_EXPORT ItemSize: public KConfigSkeletonGenericItem < QSize > + class KCONFIGCORE_EXPORT ItemSize : public KConfigSkeletonGenericItem { public: /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ - ItemSize(const QString &_group, const QString &_key, QSize &reference, - const QSize &defaultValue = QSize()); + ItemSize(const QString &_group, const QString &_key, QSize &reference, const QSize &defaultValue = QSize()); /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */ void readConfig(KConfig *config) override; @@ -1018,13 +1007,11 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject /** * Class for handling a QDateTime preferences item. */ - class KCONFIGCORE_EXPORT ItemDateTime: public KConfigSkeletonGenericItem < QDateTime > + class KCONFIGCORE_EXPORT ItemDateTime : public KConfigSkeletonGenericItem { public: /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ - ItemDateTime(const QString &_group, const QString &_key, - QDateTime &reference, - const QDateTime &defaultValue = QDateTime()); + ItemDateTime(const QString &_group, const QString &_key, QDateTime &reference, const QDateTime &defaultValue = QDateTime()); /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */ void readConfig(KConfig *config) override; @@ -1042,13 +1029,11 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject /** * Class for handling a string list preferences item. */ - class KCONFIGCORE_EXPORT ItemStringList: public KConfigSkeletonGenericItem < QStringList > + class KCONFIGCORE_EXPORT ItemStringList : public KConfigSkeletonGenericItem { public: /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ - ItemStringList(const QString &_group, const QString &_key, - QStringList &reference, - const QStringList &defaultValue = QStringList()); + ItemStringList(const QString &_group, const QString &_key, QStringList &reference, const QStringList &defaultValue = QStringList()); /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */ void readConfig(KConfig *config) override; @@ -1066,13 +1051,11 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject /** * Class for handling a path list preferences item. */ - class KCONFIGCORE_EXPORT ItemPathList: public ItemStringList + class KCONFIGCORE_EXPORT ItemPathList : public ItemStringList { public: /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ - ItemPathList(const QString &_group, const QString &_key, - QStringList &reference, - const QStringList &defaultValue = QStringList()); + ItemPathList(const QString &_group, const QString &_key, QStringList &reference, const QStringList &defaultValue = QStringList()); /** @copydoc KConfigSkeletonItem::readConfig */ void readConfig(KConfig *config) override; @@ -1083,13 +1066,11 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject /** * Class for handling a url list preferences item. */ - class KCONFIGCORE_EXPORT ItemUrlList: public KConfigSkeletonGenericItem < QList > + class KCONFIGCORE_EXPORT ItemUrlList : public KConfigSkeletonGenericItem> { public: /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ - ItemUrlList(const QString &_group, const QString &_key, - QList &reference, - const QList &defaultValue = QList()); + ItemUrlList(const QString &_group, const QString &_key, QList &reference, const QList &defaultValue = QList()); /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */ void readConfig(KConfig *config) override; @@ -1110,13 +1091,11 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject /** * Class for handling an integer list preferences item. */ - class KCONFIGCORE_EXPORT ItemIntList: public KConfigSkeletonGenericItem < QList < int > > + class KCONFIGCORE_EXPORT ItemIntList : public KConfigSkeletonGenericItem> { public: /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ - ItemIntList(const QString &_group, const QString &_key, - QList < int > &reference, - const QList < int > &defaultValue = QList < int >()); + ItemIntList(const QString &_group, const QString &_key, QList &reference, const QList &defaultValue = QList()); /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */ void readConfig(KConfig *config) override; @@ -1246,8 +1225,9 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject * @param key Key used in config file. If key is null, name is used as key. * @return The created item */ - ItemString *addItemString(const QString &name, QString &reference, - const QString &defaultValue = QLatin1String(""), // NOT QString() !! + ItemString *addItemString(const QString &name, + QString &reference, + const QString &defaultValue = QLatin1String(""), // NOT QString() !! const QString &key = QString()); /** @@ -1263,9 +1243,7 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject * @param key Key used in config file. If key is null, name is used as key. * @return The created item */ - ItemPassword *addItemPassword(const QString &name, QString &reference, - const QString &defaultValue = QLatin1String(""), - const QString &key = QString()); + ItemPassword *addItemPassword(const QString &name, QString &reference, const QString &defaultValue = QLatin1String(""), const QString &key = QString()); /** * Register a path item of type QString. The string value is interpreted @@ -1280,9 +1258,7 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject * @param key Key used in config file. If key is null, name is used as key. * @return The created item */ - ItemPath *addItemPath(const QString &name, QString &reference, - const QString &defaultValue = QLatin1String(""), - const QString &key = QString()); + ItemPath *addItemPath(const QString &name, QString &reference, const QString &defaultValue = QLatin1String(""), const QString &key = QString()); /** * Register a property item of type QVariant. Note that only the following @@ -1297,9 +1273,7 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject * @param key Key used in config file. If key is null, name is used as key. * @return The created item */ - ItemProperty *addItemProperty(const QString &name, QVariant &reference, - const QVariant &defaultValue = QVariant(), - const QString &key = QString()); + ItemProperty *addItemProperty(const QString &name, QVariant &reference, const QVariant &defaultValue = QVariant(), const QString &key = QString()); /** * Register an item of type bool. * @@ -1311,9 +1285,7 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject * @param key Key used in config file. If key is null, name is used as key. * @return The created item */ - ItemBool *addItemBool(const QString &name, bool &reference, - bool defaultValue = false, - const QString &key = QString()); + ItemBool *addItemBool(const QString &name, bool &reference, bool defaultValue = false, const QString &key = QString()); /** * Register an item of type qint32. @@ -1326,8 +1298,7 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject * @param key Key used in config file. If key is null, name is used as key. * @return The created item */ - ItemInt *addItemInt(const QString &name, qint32 &reference, qint32 defaultValue = 0, - const QString &key = QString()); + ItemInt *addItemInt(const QString &name, qint32 &reference, qint32 defaultValue = 0, const QString &key = QString()); /** * Register an item of type quint32. @@ -1340,9 +1311,7 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject * @param key Key used in config file. If key is null, name is used as key. * @return The created item */ - ItemUInt *addItemUInt(const QString &name, quint32 &reference, - quint32 defaultValue = 0, - const QString &key = QString()); + ItemUInt *addItemUInt(const QString &name, quint32 &reference, quint32 defaultValue = 0, const QString &key = QString()); /** * Register an item of type qint64. @@ -1355,18 +1324,14 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject * @param key Key used in config file. If key is null, name is used as key. * @return The created item */ - ItemLongLong *addItemLongLong(const QString &name, qint64 &reference, - qint64 defaultValue = 0, - const QString &key = QString()); + ItemLongLong *addItemLongLong(const QString &name, qint64 &reference, qint64 defaultValue = 0, const QString &key = QString()); #if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(5, 0) /** * @deprecated Since 5.0, use addItemLongLong(). */ KCONFIGCORE_DEPRECATED_VERSION(5, 0, "Use KCoreConfigSkeleton::addItemLongLong(...)") - ItemLongLong *addItemInt64(const QString &name, qint64 &reference, - qint64 defaultValue = 0, - const QString &key = QString()); + ItemLongLong *addItemInt64(const QString &name, qint64 &reference, qint64 defaultValue = 0, const QString &key = QString()); #endif /** @@ -1380,18 +1345,14 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject * @param key Key used in config file. If key is null, name is used as key. * @return The created item */ - ItemULongLong *addItemULongLong(const QString &name, quint64 &reference, - quint64 defaultValue = 0, - const QString &key = QString()); + ItemULongLong *addItemULongLong(const QString &name, quint64 &reference, quint64 defaultValue = 0, const QString &key = QString()); #if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(5, 0) /** * @deprecated Since 5.0, use addItemULongLong(). */ KCONFIGCORE_DEPRECATED_VERSION(5, 0, "Use KCoreConfigSkeleton::addItemULongLong(...)") - ItemULongLong *addItemUInt64(const QString &name, quint64 &reference, - quint64 defaultValue = 0, - const QString &key = QString()); + ItemULongLong *addItemUInt64(const QString &name, quint64 &reference, quint64 defaultValue = 0, const QString &key = QString()); #endif /** @@ -1405,9 +1366,7 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject * @param key Key used in config file. If key is null, name is used as key. * @return The created item */ - ItemDouble *addItemDouble(const QString &name, double &reference, - double defaultValue = 0.0, - const QString &key = QString()); + ItemDouble *addItemDouble(const QString &name, double &reference, double defaultValue = 0.0, const QString &key = QString()); /** * Register an item of type QRect. @@ -1420,9 +1379,7 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject * @param key Key used in config file. If key is null, name is used as key. * @return The created item */ - ItemRect *addItemRect(const QString &name, QRect &reference, - const QRect &defaultValue = QRect(), - const QString &key = QString()); + ItemRect *addItemRect(const QString &name, QRect &reference, const QRect &defaultValue = QRect(), const QString &key = QString()); /** * Register an item of type QPoint. @@ -1435,9 +1392,7 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject * @param key Key used in config file. If key is null, name is used as key. * @return The created item */ - ItemPoint *addItemPoint(const QString &name, QPoint &reference, - const QPoint &defaultValue = QPoint(), - const QString &key = QString()); + ItemPoint *addItemPoint(const QString &name, QPoint &reference, const QPoint &defaultValue = QPoint(), const QString &key = QString()); /** * Register an item of type QSize. @@ -1450,9 +1405,7 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject * @param key Key used in config file. If key is null, name is used as key. * @return The created item */ - ItemSize *addItemSize(const QString &name, QSize &reference, - const QSize &defaultValue = QSize(), - const QString &key = QString()); + ItemSize *addItemSize(const QString &name, QSize &reference, const QSize &defaultValue = QSize(), const QString &key = QString()); /** * Register an item of type QDateTime. @@ -1465,9 +1418,7 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject * @param key Key used in config file. If key is null, name is used as key. * @return The created item */ - ItemDateTime *addItemDateTime(const QString &name, QDateTime &reference, - const QDateTime &defaultValue = QDateTime(), - const QString &key = QString()); + ItemDateTime *addItemDateTime(const QString &name, QDateTime &reference, const QDateTime &defaultValue = QDateTime(), const QString &key = QString()); /** * Register an item of type QStringList. @@ -1480,9 +1431,8 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject * @param key Key used in config file. If key is null, name is used as key. * @return The created item */ - ItemStringList *addItemStringList(const QString &name, QStringList &reference, - const QStringList &defaultValue = QStringList(), - const QString &key = QString()); + ItemStringList * + addItemStringList(const QString &name, QStringList &reference, const QStringList &defaultValue = QStringList(), const QString &key = QString()); /** * Register an item of type QList. @@ -1495,10 +1445,7 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject * @param key Key used in config file. If key is null, name is used as key. * @return The created item */ - ItemIntList *addItemIntList(const QString &name, QList < int > &reference, - const QList < int > &defaultValue = - QList < int >(), - const QString &key = QString()); + ItemIntList *addItemIntList(const QString &name, QList &reference, const QList &defaultValue = QList(), const QString &key = QString()); /** * Return the @ref KConfig object used for reading and writing the settings. @@ -1623,7 +1570,7 @@ public Q_SLOTS: virtual bool usrSave(); #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 0) - /** + /** * @deprecated since 5.0, override usrRead instead. This method is still called from usrRead * for compatibility. */ @@ -1632,7 +1579,7 @@ public Q_SLOTS: #endif #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 0) - /** + /** * @deprecated since 5.0, override usrSave instead. This method is still called from usrSave * for compatibility. */ @@ -1643,7 +1590,6 @@ public Q_SLOTS: private: KCoreConfigSkeletonPrivate *const d; friend class KConfigSkeleton; - }; #endif diff --git a/src/core/kcoreconfigskeleton_p.h b/src/core/kcoreconfigskeleton_p.h index 006bd45f..d854cc43 100644 --- a/src/core/kcoreconfigskeleton_p.h +++ b/src/core/kcoreconfigskeleton_p.h @@ -15,8 +15,10 @@ class KCoreConfigSkeletonPrivate { public: KCoreConfigSkeletonPrivate() - : mCurrentGroup(QStringLiteral("No Group")), mUseDefaults(false) - {} + : mCurrentGroup(QStringLiteral("No Group")) + , mUseDefaults(false) + { + } ~KCoreConfigSkeletonPrivate() { KConfigSkeletonItem::List::ConstIterator it; @@ -40,7 +42,8 @@ class KConfigSkeletonItemPrivate KConfigSkeletonItemPrivate() : mIsImmutable(true) , mWriteFlags(KConfigBase::Normal) - {} + { + } virtual ~KConfigSkeletonItemPrivate(); bool mIsImmutable; ///< Indicates this item is immutable KConfigBase::WriteConfigFlags mWriteFlags; ///< The flags to pass to calls of writeEntry() and revertToDefault() @@ -79,5 +82,4 @@ class KPropertySkeletonItemPrivate : public KConfigSkeletonItemPrivate std::function mNotifyFunction; }; - #endif diff --git a/src/core/kdesktopfile.cpp b/src/core/kdesktopfile.cpp index 0dccd2d2..d5029ffe 100644 --- a/src/core/kdesktopfile.cpp +++ b/src/core/kdesktopfile.cpp @@ -14,14 +14,14 @@ #include #include -#include #include +#include #include "kauthorized.h" +#include "kconfig_core_log_settings.h" #include "kconfig_p.h" #include "kconfiggroup.h" #include "kconfigini_p.h" -#include "kconfig_core_log_settings.h" class KDesktopFilePrivate : public KConfigPrivate { @@ -71,9 +71,8 @@ QString KDesktopFile::locateLocal(const QString &path) // Relative to config? (e.g. for autostart) const QStringList lstGenericConfigLocation = QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation); // Iterate from the last item since some items may be subfolders of others. - for (QStringList::const_reverse_iterator constIterator = lstGenericConfigLocation.crbegin(); - constIterator != lstGenericConfigLocation.crend(); - ++constIterator) { + for (QStringList::const_reverse_iterator constIterator = lstGenericConfigLocation.crbegin(); constIterator != lstGenericConfigLocation.crend(); + ++constIterator) { const QString &dir = (*constIterator); if (path.startsWith(dir + plus)) { relativePath = path.mid(dir.length() + 1); @@ -102,16 +101,16 @@ bool KDesktopFile::isDesktopFile(const QString &path) bool KDesktopFile::isAuthorizedDesktopFile(const QString &path) { if (path.isEmpty()) { - return false; // Empty paths are not ok. + return false; // Empty paths are not ok. } if (QDir::isRelativePath(path)) { - return true; // Relative paths are ok. + return true; // Relative paths are ok. } const QString realPath = QFileInfo(path).canonicalFilePath(); if (realPath.isEmpty()) { - return false; // File doesn't exist. + return false; // File doesn't exist. } #ifndef Q_OS_WIN @@ -284,9 +283,7 @@ bool KDesktopFile::tryExec() const const QStringList list = d->desktopGroup.readEntry("X-KDE-AuthorizeAction", QStringList()); if (!list.isEmpty()) { - for (QStringList::ConstIterator it = list.begin(); - it != list.end(); - ++it) { + for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it) { if (!KAuthorized::authorize((*it).trimmed())) { return false; } @@ -314,24 +311,23 @@ bool KDesktopFile::tryExec() const /** * @return the filename as passed to the constructor. */ -//QString KDesktopFile::fileName() const { return backEnd->fileName(); } +// QString KDesktopFile::fileName() const { return backEnd->fileName(); } /** * @return the resource type as passed to the constructor. */ -//QString -//KDesktopFile::resource() const { return backEnd->resource(); } +// QString +// KDesktopFile::resource() const { return backEnd->resource(); } #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 42) -QStringList -KDesktopFile::sortOrder() const +QStringList KDesktopFile::sortOrder() const { Q_D(const KDesktopFile); return d->desktopGroup.readXdgListEntry("SortOrder"); } #endif -//void KDesktopFile::virtual_hook( int id, void* data ) +// void KDesktopFile::virtual_hook( int id, void* data ) //{ KConfig::virtual_hook( id, data ); } QString KDesktopFile::readDocPath() const @@ -344,7 +340,7 @@ KDesktopFile *KDesktopFile::copyTo(const QString &file) const { KDesktopFile *config = new KDesktopFile(QString()); this->KConfig::copyTo(file, config); -// config->setDesktopGroup(); + // config->setDesktopGroup(); return config; } diff --git a/src/core/kdesktopfile.h b/src/core/kdesktopfile.h index 4d817181..c98bf1bb 100644 --- a/src/core/kdesktopfile.h +++ b/src/core/kdesktopfile.h @@ -241,9 +241,8 @@ class KCONFIGCORE_EXPORT KDesktopFile : public KConfig /** Virtual hook, used to add new "virtual" functions while maintaining binary compatibility. Unused in this class. */ -// virtual void virtual_hook( int id, void* data ); + // virtual void virtual_hook( int id, void* data ); private: - Q_DISABLE_COPY(KDesktopFile) Q_DECLARE_PRIVATE(KDesktopFile) diff --git a/src/core/kemailsettings.cpp b/src/core/kemailsettings.cpp index ed4255b5..cfebe2a8 100644 --- a/src/core/kemailsettings.cpp +++ b/src/core/kemailsettings.cpp @@ -12,7 +12,10 @@ class KEMailSettingsPrivate { public: - KEMailSettingsPrivate() : m_pConfig(nullptr) {} + KEMailSettingsPrivate() + : m_pConfig(nullptr) + { + } ~KEMailSettingsPrivate() { delete m_pConfig; @@ -97,7 +100,7 @@ QString KEMailSettings::getSetting(KEMailSettings::Setting s) const }; return QString(); } -void KEMailSettings::setSetting(KEMailSettings::Setting s, const QString &v) +void KEMailSettings::setSetting(KEMailSettings::Setting s, const QString &v) { KConfigGroup cg(p->m_pConfig, QLatin1String("PROFILE_") + p->m_sCurrentProfile); switch (s) { @@ -191,7 +194,6 @@ void KEMailSettings::setDefault(const QString &s) p->m_pConfig->group("Defaults").writeEntry("Profile", s); p->m_pConfig->sync(); p->m_sDefaultProfile = s; - } void KEMailSettings::setProfile(const QString &s) diff --git a/src/core/kemailsettings.h b/src/core/kemailsettings.h index 30f9942c..eb701f8c 100644 --- a/src/core/kemailsettings.h +++ b/src/core/kemailsettings.h @@ -15,29 +15,29 @@ class KEMailSettingsPrivate; /** - * \class KEMailSettings kemailsettings.h - * - * This is just a small class to facilitate accessing e-mail settings in - * a sane way, and allowing any program to manage multiple e-mail - * profiles effortlessly - * - * The default profile is automatically selected in the constructor. - * - * @author Alex Zepeda zipzippy@sonic.net - **/ + * \class KEMailSettings kemailsettings.h + * + * This is just a small class to facilitate accessing e-mail settings in + * a sane way, and allowing any program to manage multiple e-mail + * profiles effortlessly + * + * The default profile is automatically selected in the constructor. + * + * @author Alex Zepeda zipzippy@sonic.net + **/ class KCONFIGCORE_EXPORT KEMailSettings { Q_DECLARE_TR_FUNCTIONS(KEMailSettings) public: /** - * The list of settings that I thought of when I wrote this - * class. Any extra settings thought of later can be accessed - * easily with getExtendedSetting and setExtendedSetting. - * @see getSetting() - * @see setSetting() - * @see getExtendedSetting() - * @see setExtendedSetting() - **/ + * The list of settings that I thought of when I wrote this + * class. Any extra settings thought of later can be accessed + * easily with getExtendedSetting and setExtendedSetting. + * @see getSetting() + * @see setSetting() + * @see getExtendedSetting() + * @see setExtendedSetting() + **/ enum Setting { ClientProgram, ClientTerminal, @@ -86,8 +86,8 @@ class KCONFIGCORE_EXPORT KEMailSettings }; /** - * The various extensions allowed. - **/ + * The various extensions allowed. + **/ enum Extension { POP3, SMTP, @@ -95,40 +95,40 @@ class KCONFIGCORE_EXPORT KEMailSettings }; /** - * Default constructor, just sets things up and sets the default profile - * as the current profile - **/ + * Default constructor, just sets things up and sets the default profile + * as the current profile + **/ KEMailSettings(); KEMailSettings(const KEMailSettings &) = delete; - KEMailSettings& operator=(const KEMailSettings &) = delete; + KEMailSettings &operator=(const KEMailSettings &) = delete; /** - * Default destructor, nothing to see here. - **/ + * Default destructor, nothing to see here. + **/ ~KEMailSettings(); /** - * List of profiles available. - * @return the list of profiles - **/ + * List of profiles available. + * @return the list of profiles + **/ QStringList profiles() const; #if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(5, 0) /** - * Returns the name of the current profile. - * @returns what profile we're currently using - * @deprecated Since 5.0 - **/ + * Returns the name of the current profile. + * @returns what profile we're currently using + * @deprecated Since 5.0 + **/ KCONFIGCORE_DEPRECATED_VERSION(5, 0, "API planned to be changed") QString currentProfileName() const; // see https://git.reviewboard.kde.org/r/111910/ #endif /** - * Change the current profile. - * @param s the name of the new profile - **/ + * Change the current profile. + * @param s the name of the new profile + **/ void setProfile(const QString &s); /** @@ -138,25 +138,25 @@ class KCONFIGCORE_EXPORT KEMailSettings QString defaultProfileName() const; /** - * Sets a new default. - * @param def the new default - **/ + * Sets a new default. + * @param def the new default + **/ void setDefault(const QString &def); /** - * Get one of the predefined "basic" settings. - * @param s the setting to get - * @return the value of the setting, or QString() if not - * set - **/ + * Get one of the predefined "basic" settings. + * @param s the setting to get + * @return the value of the setting, or QString() if not + * set + **/ QString getSetting(KEMailSettings::Setting s) const; /** - * Set one of the predefined "basic" settings. - * @param s the setting to set - * @param v the new value of the setting, or QString() to - * unset - **/ + * Set one of the predefined "basic" settings. + * @param s the setting to set + * @param v the new value of the setting, or QString() to + * unset + **/ void setSetting(KEMailSettings::Setting s, const QString &v); private: diff --git a/src/core/ksharedconfig.cpp b/src/core/ksharedconfig.cpp index cc6adeb9..98aa4c5e 100644 --- a/src/core/ksharedconfig.cpp +++ b/src/core/ksharedconfig.cpp @@ -7,9 +7,9 @@ */ #include "ksharedconfig.h" +#include "kconfig_p.h" #include "kconfigbackend_p.h" #include "kconfiggroup.h" -#include "kconfig_p.h" #include #include #include @@ -40,8 +40,8 @@ class GlobalSharedConfigList : public QList }; static QThreadStorage s_storage; -template -T * perThreadGlobalStatic() +template +T *perThreadGlobalStatic() { if (!s_storage.hasLocalData()) { s_storage.setLocalData(new T); @@ -50,7 +50,10 @@ T * perThreadGlobalStatic() } // Q_GLOBAL_STATIC(GlobalSharedConfigList, globalSharedConfigList), but per thread: -static GlobalSharedConfigList *globalSharedConfigList() { return perThreadGlobalStatic(); } +static GlobalSharedConfigList *globalSharedConfigList() +{ + return perThreadGlobalStatic(); +} void _k_globalMainConfigSync() { @@ -60,9 +63,7 @@ void _k_globalMainConfigSync() } } -KSharedConfigPtr KSharedConfig::openConfig(const QString &_fileName, - OpenFlags flags, - QStandardPaths::StandardLocation resType) +KSharedConfigPtr KSharedConfig::openConfig(const QString &_fileName, OpenFlags flags, QStandardPaths::StandardLocation resType) { QString fileName(_fileName); GlobalSharedConfigList *list = globalSharedConfigList(); @@ -78,11 +79,9 @@ KSharedConfigPtr KSharedConfig::openConfig(const QString &_fileName, } for (auto *cfg : qAsConst(*list)) { - if (cfg->name() == fileName && - cfg->d_ptr->openFlags == flags && - cfg->locationType() == resType -// cfg->backend()->type() == backend - ) { + if (cfg->name() == fileName && cfg->d_ptr->openFlags == flags && cfg->locationType() == resType + // cfg->backend()->type() == backend + ) { return KSharedConfigPtr(cfg); } } @@ -121,9 +120,7 @@ KSharedConfig::Ptr KSharedConfig::openStateConfig(const QString &_fileName) return openConfig(fileName, SimpleConfig, QStandardPaths::AppDataLocation); } -KSharedConfig::KSharedConfig(const QString &fileName, - OpenFlags flags, - QStandardPaths::StandardLocation resType) +KSharedConfig::KSharedConfig(const QString &fileName, OpenFlags flags, QStandardPaths::StandardLocation resType) : KConfig(fileName, flags, resType) { globalSharedConfigList()->append(this); diff --git a/src/core/ksharedconfig.h b/src/core/ksharedconfig.h index be01401c..e23d17c6 100644 --- a/src/core/ksharedconfig.h +++ b/src/core/ksharedconfig.h @@ -9,8 +9,8 @@ #ifndef KSHAREDCONFIG_H #define KSHAREDCONFIG_H -#include #include +#include /** * \class KSharedConfig ksharedconfig.h @@ -28,7 +28,7 @@ * using reparseConfiguration after a manual change notification, just like you have * to do between processes. */ -class KCONFIGCORE_EXPORT KSharedConfig : public KConfig, public QSharedData //krazy:exclude=dpointer (only for refcounting) +class KCONFIGCORE_EXPORT KSharedConfig : public KConfig, public QSharedData // krazy:exclude=dpointer (only for refcounting) { public: typedef QExplicitlySharedDataPointer Ptr; @@ -58,9 +58,8 @@ class KCONFIGCORE_EXPORT KSharedConfig : public KConfig, public QSharedData //kr * * @sa KConfig */ - static KSharedConfig::Ptr openConfig(const QString &fileName = QString(), - OpenFlags mode = FullConfig, - QStandardPaths::StandardLocation type = QStandardPaths::GenericConfigLocation); + static KSharedConfig::Ptr + openConfig(const QString &fileName = QString(), OpenFlags mode = FullConfig, QStandardPaths::StandardLocation type = QStandardPaths::GenericConfigLocation); /** * Creates a KSharedConfig object to manipulate a configuration file suitable @@ -91,9 +90,7 @@ class KCONFIGCORE_EXPORT KSharedConfig : public KConfig, public QSharedData //kr KConfigGroup groupImpl(const QByteArray &aGroup) override; const KConfigGroup groupImpl(const QByteArray &aGroup) const override; - KSharedConfig(const QString &file, OpenFlags mode, - QStandardPaths::StandardLocation resourceType); - + KSharedConfig(const QString &file, OpenFlags mode, QStandardPaths::StandardLocation resourceType); }; typedef KSharedConfig::Ptr KSharedConfigPtr; diff --git a/src/gui/kconfiggroupgui.cpp b/src/gui/kconfiggroupgui.cpp index 96b042af..5fbdbfad 100644 --- a/src/gui/kconfiggroupgui.cpp +++ b/src/gui/kconfiggroupgui.cpp @@ -21,14 +21,11 @@ * @returns true if something was handled (even if output was set to clear or default) * or false if nothing was handled (e.g., Core type) */ -static bool readEntryGui(const QByteArray &data, const char *key, const QVariant &input, - QVariant &output) +static bool readEntryGui(const QByteArray &data, const char *key, const QVariant &input, QVariant &output) { const auto errString = [&]() { return QStringLiteral("\"%1\" - conversion from \"%3\" to %2 failed") - .arg(QLatin1String(key), - QLatin1String(QVariant::typeToName(input.type())), - QLatin1String(data.constData()) ); + .arg(QLatin1String(key), QLatin1String(QVariant::typeToName(input.type())), QLatin1String(data.constData())); }; // set in case of failure @@ -37,7 +34,7 @@ static bool readEntryGui(const QByteArray &data, const char *key, const QVariant switch (static_cast(input.type())) { case QMetaType::QColor: { if (data.isEmpty() || data == "invalid") { - output = QColor(); // return what was stored + output = QColor(); // return what was stored return true; } else if (data.at(0) == '#') { QColor col; @@ -59,7 +56,7 @@ static bool readEntryGui(const QByteArray &data, const char *key, const QVariant if (count != 3 && count != 4) { const QString formatError = QStringLiteral(" (wrong format: expected '%1' items, read '%2')"); qCritical() << qPrintable(errString()) << qPrintable(formatError.arg(QStringLiteral("3' or '4")).arg(count)); - return true; // return default + return true; // return default } int temp[4]; @@ -72,9 +69,7 @@ static bool readEntryGui(const QByteArray &data, const char *key, const QVariant return true; // return default } if (j < 0 || j > 255) { - static const char *const components[] = { - "red", "green", "blue", "alpha" - }; + static const char *const components[] = {"red", "green", "blue", "alpha"}; const QString boundsError = QStringLiteral(" (bounds error: %1 component %2)"); qCritical() << qPrintable(errString()) << qPrintable(boundsError.arg(QLatin1String(components[i])).arg(j < 0 ? QStringLiteral("< 0") : QStringLiteral("> 255"))); @@ -114,13 +109,13 @@ static bool readEntryGui(const QByteArray &data, const char *key, const QVariant case QMetaType::QCursor: case QMetaType::QSizePolicy: case QMetaType::QPen: - // we may want to handle these in the future + // we may want to handle these in the future default: break; } - return false; // not handled + return false; // not handled } /** @@ -129,8 +124,7 @@ static bool readEntryGui(const QByteArray &data, const char *key, const QVariant * @returns true if something was handled (even if an empty value was written) * or false if nothing was handled (e.g., Core type) */ -static bool writeEntryGui(KConfigGroup *cg, const char *key, const QVariant &prop, - KConfigGroup::WriteConfigFlags pFlags) +static bool writeEntryGui(KConfigGroup *cg, const char *key, const QVariant &prop, KConfigGroup::WriteConfigFlags pFlags) { switch (static_cast(prop.type())) { case QMetaType::QColor: { @@ -161,10 +155,8 @@ static bool writeEntryGui(KConfigGroup *cg, const char *key, const QVariant &pro // https://bugreports.qt.io/browse/QTBUG-63792 // https://bugs.kde.org/show_bug.cgi?id=378523 if (f.weight() == QFont::Normal - && (f.styleName() == QLatin1String("Regular") - || f.styleName() == QLatin1String("Normal") - || f.styleName() == QLatin1String("Book") - || f.styleName() == QLatin1String("Roman"))) { + && (f.styleName() == QLatin1String("Regular") || f.styleName() == QLatin1String("Normal") || f.styleName() == QLatin1String("Book") + || f.styleName() == QLatin1String("Roman"))) { f.setStyleName(QString()); } cg->writeEntry(key, f.toString().toUtf8(), pFlags); @@ -194,7 +186,7 @@ static int initKConfigGroupGui() { _kde_internal_KConfigGroupGui.readEntryGui = readEntryGui; _kde_internal_KConfigGroupGui.writeEntryGui = writeEntryGui; - return 42; // because 42 is nicer than 1 or 0 + return 42; // because 42 is nicer than 1 or 0 } #ifdef Q_CONSTRUCTOR_FUNCTION diff --git a/src/gui/kconfiggui.cpp b/src/gui/kconfiggui.cpp index 1daeec45..938fbd93 100644 --- a/src/gui/kconfiggui.cpp +++ b/src/gui/kconfiggui.cpp @@ -13,9 +13,7 @@ static QString configName(const QString &id, const QString &key) { - return(QLatin1String("session/") + QGuiApplication::applicationName() + - QLatin1Char('_') + id + - QLatin1Char('_') + key); + return (QLatin1String("session/") + QGuiApplication::applicationName() + QLatin1Char('_') + id + QLatin1Char('_') + key); } static KConfig *s_sessionConfig = nullptr; @@ -28,9 +26,7 @@ KConfig *KConfigGui::sessionConfig() if (!hasSessionConfig() && qApp->isSessionRestored()) { // create the default instance specific config object // from applications' -session command line parameter - s_sessionConfig = new KConfig(configName(qApp->sessionId(), - qApp->sessionKey()), - KConfig::SimpleConfig); + s_sessionConfig = new KConfig(configName(qApp->sessionId(), qApp->sessionKey()), KConfig::SimpleConfig); } return s_sessionConfig; @@ -44,8 +40,7 @@ void KConfigGui::setSessionConfig(const QString &id, const QString &key) } // create a new instance specific config object from supplied id & key - s_sessionConfig = new KConfig(configName(id, key), - KConfig::SimpleConfig); + s_sessionConfig = new KConfig(configName(id, key), KConfig::SimpleConfig); } bool KConfigGui::hasSessionConfig() diff --git a/src/gui/kconfigloader.cpp b/src/gui/kconfigloader.cpp index 538a38ff..bc1751f4 100644 --- a/src/gui/kconfigloader.cpp +++ b/src/gui/kconfigloader.cpp @@ -27,8 +27,8 @@ void ConfigLoaderPrivate::parse(KConfigLoader *loader, QIODevice *xml) } ConfigLoaderHandler::ConfigLoaderHandler(KConfigLoader *config, ConfigLoaderPrivate *d) - : m_config(config), - d(d) + : m_config(config) + , d(d) { resetState(); } @@ -86,7 +86,7 @@ bool ConfigLoaderHandler::startElement(const QStringRef &localName, const QXmlSt for (const auto &attr : attrs) { const QStringRef name = attr.name(); if (name.compare(QLatin1String("name"), Qt::CaseInsensitive) == 0) { - //qDebug() << "set group to" << attrs.value(i); + // qDebug() << "set group to" << attrs.value(i); group = attr.value().toString(); } } @@ -137,7 +137,7 @@ bool ConfigLoaderHandler::characters(const QStringRef &ch) bool ConfigLoaderHandler::endElement(const QStringRef &localName) { -// qDebug() << "ConfigLoaderHandler::endElement(" << localName << qName; + // qDebug() << "ConfigLoaderHandler::endElement(" << localName << qName; const QStringRef tag = localName; if (tag.compare(QLatin1String("entry"), Qt::CaseInsensitive) == 0) { addItem(); @@ -189,22 +189,16 @@ void ConfigLoaderHandler::addItem() } else if (m_type == QLatin1String("color")) { item = m_config->addItemColor(m_name, *d->newColor(), QColor(m_default), m_key); } else if (m_type == QLatin1String("datetime")) { - item = m_config->addItemDateTime(m_name, *d->newDateTime(), - QDateTime::fromString(m_default), m_key); + item = m_config->addItemDateTime(m_name, *d->newDateTime(), QDateTime::fromString(m_default), m_key); } else if (m_type == QLatin1String("enum")) { m_key = (m_key.isEmpty()) ? m_name : m_key; - KConfigSkeleton::ItemEnum *enumItem = - new KConfigSkeleton::ItemEnum(m_config->currentGroup(), - m_key, *d->newInt(), - m_enumChoices, - m_default.toUInt()); + KConfigSkeleton::ItemEnum *enumItem = new KConfigSkeleton::ItemEnum(m_config->currentGroup(), m_key, *d->newInt(), m_enumChoices, m_default.toUInt()); m_config->addItem(enumItem, m_name); item = enumItem; } else if (m_type == QLatin1String("font")) { item = m_config->addItemFont(m_name, *d->newFont(), QFont(m_default), m_key); } else if (m_type == QLatin1String("int")) { - KConfigSkeleton::ItemInt *intItem = m_config->addItemInt(m_name, *d->newInt(), - m_default.toInt(), m_key); + KConfigSkeleton::ItemInt *intItem = m_config->addItemInt(m_name, *d->newInt(), m_default.toInt(), m_key); if (m_haveMin) { intItem->setMinValue(m_min); @@ -222,13 +216,11 @@ void ConfigLoaderHandler::addItem() } else if (m_type == QLatin1String("string")) { item = m_config->addItemString(m_name, *d->newString(), m_default, m_key); } else if (m_type == QLatin1String("stringlist")) { - //FIXME: the split() is naive and will break on lists with ,'s in them - //empty parts are not wanted in this case - item = m_config->addItemStringList(m_name, *d->newStringList(), - m_default.split(QLatin1Char(','), Qt::SkipEmptyParts), m_key); + // FIXME: the split() is naive and will break on lists with ,'s in them + // empty parts are not wanted in this case + item = m_config->addItemStringList(m_name, *d->newStringList(), m_default.split(QLatin1Char(','), Qt::SkipEmptyParts), m_key); } else if (m_type == QLatin1String("uint")) { - KConfigSkeleton::ItemUInt *uintItem = - m_config->addItemUInt(m_name, *d->newUint(), m_default.toUInt(), m_key); + KConfigSkeleton::ItemUInt *uintItem = m_config->addItemUInt(m_name, *d->newUint(), m_default.toUInt(), m_key); if (m_haveMin) { uintItem->setMinValue(m_min); } @@ -238,15 +230,11 @@ void ConfigLoaderHandler::addItem() item = uintItem; } else if (m_type == QLatin1String("url")) { m_key = (m_key.isEmpty()) ? m_name : m_key; - KConfigSkeleton::ItemUrl *urlItem = - new KConfigSkeleton::ItemUrl(m_config->currentGroup(), - m_key, *d->newUrl(), - QUrl::fromUserInput(m_default)); + KConfigSkeleton::ItemUrl *urlItem = new KConfigSkeleton::ItemUrl(m_config->currentGroup(), m_key, *d->newUrl(), QUrl::fromUserInput(m_default)); m_config->addItem(urlItem, m_name); item = urlItem; } else if (m_type == QLatin1String("double")) { - KConfigSkeleton::ItemDouble *doubleItem = m_config->addItemDouble(m_name, - *d->newDouble(), m_default.toDouble(), m_key); + KConfigSkeleton::ItemDouble *doubleItem = m_config->addItemDouble(m_name, *d->newDouble(), m_default.toDouble(), m_key); if (m_haveMin) { doubleItem->setMinValue(m_min); } @@ -262,8 +250,7 @@ void ConfigLoaderHandler::addItem() } item = m_config->addItemIntList(m_name, *d->newIntList(), defaultList, m_key); } else if (m_type == QLatin1String("longlong")) { - KConfigSkeleton::ItemLongLong *longlongItem = m_config->addItemLongLong(m_name, - *d->newLongLong(), m_default.toLongLong(), m_key); + KConfigSkeleton::ItemLongLong *longlongItem = m_config->addItemLongLong(m_name, *d->newLongLong(), m_default.toLongLong(), m_key); if (m_haveMin) { longlongItem->setMinValue(m_min); } @@ -288,8 +275,7 @@ void ConfigLoaderHandler::addItem() QRect defaultRect; const QStringList tmpList = m_default.split(QLatin1Char(',')); if (tmpList.size() >= 4) { - defaultRect.setCoords(tmpList[0].toInt(), tmpList[1].toInt(), - tmpList[2].toInt(), tmpList[3].toInt()); + defaultRect.setCoords(tmpList[0].toInt(), tmpList[1].toInt(), tmpList[2].toInt(), tmpList[3].toInt()); } item = m_config->addItemRect(m_name, *d->newRect(), defaultRect, m_key); } else if (m_type == QLatin1String("size")) { @@ -301,8 +287,7 @@ void ConfigLoaderHandler::addItem() } item = m_config->addItemSize(m_name, *d->newSize(), defaultSize, m_key); } else if (m_type == QLatin1String("ulonglong")) { - KConfigSkeleton::ItemULongLong *ulonglongItem = - m_config->addItemULongLong(m_name, *d->newULongLong(), m_default.toULongLong(), m_key); + KConfigSkeleton::ItemULongLong *ulonglongItem = m_config->addItemULongLong(m_name, *d->newULongLong(), m_default.toULongLong(), m_key); if (m_haveMin) { ulonglongItem->setMinValue(m_min); } @@ -345,25 +330,25 @@ void ConfigLoaderHandler::resetState() } KConfigLoader::KConfigLoader(const QString &configFile, QIODevice *xml, QObject *parent) - : KConfigSkeleton(configFile, parent), - d(new ConfigLoaderPrivate) + : KConfigSkeleton(configFile, parent) + , d(new ConfigLoaderPrivate) { d->parse(this, xml); } KConfigLoader::KConfigLoader(KSharedConfigPtr config, QIODevice *xml, QObject *parent) - : KConfigSkeleton(std::move(config), parent), - d(new ConfigLoaderPrivate) + : KConfigSkeleton(std::move(config), parent) + , d(new ConfigLoaderPrivate) { d->parse(this, xml); } -//FIXME: obviously this is broken and should be using the group as the root, +// FIXME: obviously this is broken and should be using the group as the root, // but KConfigSkeleton does not currently support this. it will eventually though, // at which point this can be addressed properly KConfigLoader::KConfigLoader(const KConfigGroup &config, QIODevice *xml, QObject *parent) - : KConfigSkeleton(KSharedConfig::openConfig(config.config()->name(), config.config()->openFlags(), config.config()->locationType()), parent), - d(new ConfigLoaderPrivate) + : KConfigSkeleton(KSharedConfig::openConfig(config.config()->name(), config.config()->openFlags(), config.config()->locationType()), parent) + , d(new ConfigLoaderPrivate) { KConfigGroup group = config.parent(); d->baseGroup = config.name(); @@ -418,7 +403,7 @@ bool KConfigLoader::usrSave() { if (d->saveDefaults) { const auto listItems = items(); - for (const auto& item : listItems) { + for (const auto &item : listItems) { config()->group(item->group()).writeEntry(item->key(), ""); } } diff --git a/src/gui/kconfigloader.h b/src/gui/kconfigloader.h index 2e97ccd8..e40b68cb 100644 --- a/src/gui/kconfigloader.h +++ b/src/gui/kconfigloader.h @@ -166,4 +166,4 @@ class KCONFIGGUI_EXPORT KConfigLoader : public KConfigSkeleton ConfigLoaderPrivate *const d; }; -#endif //multiple inclusion guard +#endif // multiple inclusion guard diff --git a/src/gui/kconfigloaderhandler_p.h b/src/gui/kconfigloaderhandler_p.h index cf9b7081..bc199e0e 100644 --- a/src/gui/kconfigloaderhandler_p.h +++ b/src/gui/kconfigloaderhandler_p.h @@ -44,4 +44,3 @@ class ConfigLoaderHandler }; #endif - diff --git a/src/gui/kconfigskeleton.cpp b/src/gui/kconfigskeleton.cpp index 031c7fbb..c3881c3b 100644 --- a/src/gui/kconfigskeleton.cpp +++ b/src/gui/kconfigskeleton.cpp @@ -20,9 +20,7 @@ KConfigSkeleton::KConfigSkeleton(KSharedConfig::Ptr pConfig, QObject *parent) { } -KConfigSkeleton::ItemColor::ItemColor(const QString &_group, const QString &_key, - QColor &reference, - const QColor &defaultValue) +KConfigSkeleton::ItemColor::ItemColor(const QString &_group, const QString &_key, QColor &reference, const QColor &defaultValue) : KConfigSkeletonGenericItem(_group, _key, reference, defaultValue) { } @@ -51,9 +49,7 @@ QVariant KConfigSkeleton::ItemColor::property() const return QVariant(mReference); } -KConfigSkeleton::ItemFont::ItemFont(const QString &_group, const QString &_key, - QFont &reference, - const QFont &defaultValue) +KConfigSkeleton::ItemFont::ItemFont(const QString &_group, const QString &_key, QFont &reference, const QFont &defaultValue) : KConfigSkeletonGenericItem(_group, _key, reference, defaultValue) { } @@ -82,23 +78,18 @@ QVariant KConfigSkeleton::ItemFont::property() const return QVariant(mReference); } -KConfigSkeleton::ItemColor *KConfigSkeleton::addItemColor(const QString &name, QColor &reference, - const QColor &defaultValue, const QString &key) +KConfigSkeleton::ItemColor *KConfigSkeleton::addItemColor(const QString &name, QColor &reference, const QColor &defaultValue, const QString &key) { KConfigSkeleton::ItemColor *item; - item = new KConfigSkeleton::ItemColor(d->mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue); + item = new KConfigSkeleton::ItemColor(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue); addItem(item, name); return item; } -KConfigSkeleton::ItemFont *KConfigSkeleton::addItemFont(const QString &name, QFont &reference, - const QFont &defaultValue, const QString &key) +KConfigSkeleton::ItemFont *KConfigSkeleton::addItemFont(const QString &name, QFont &reference, const QFont &defaultValue, const QString &key) { KConfigSkeleton::ItemFont *item; - item = new KConfigSkeleton::ItemFont(d->mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue); + item = new KConfigSkeleton::ItemFont(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue); addItem(item, name); return item; } - diff --git a/src/gui/kconfigskeleton.h b/src/gui/kconfigskeleton.h index 8e88e8d8..3f0aec87 100644 --- a/src/gui/kconfigskeleton.h +++ b/src/gui/kconfigskeleton.h @@ -32,13 +32,11 @@ class KCONFIGGUI_EXPORT KConfigSkeleton : public KCoreConfigSkeleton /** * Class for handling a color preferences item. */ - class KCONFIGGUI_EXPORT ItemColor: public KConfigSkeletonGenericItem < QColor > + class KCONFIGGUI_EXPORT ItemColor : public KConfigSkeletonGenericItem { public: /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ - ItemColor(const QString &_group, const QString &_key, - QColor &reference, - const QColor &defaultValue = QColor(128, 128, 128)); + ItemColor(const QString &_group, const QString &_key, QColor &reference, const QColor &defaultValue = QColor(128, 128, 128)); /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */ void readConfig(KConfig *config) override; @@ -56,12 +54,11 @@ class KCONFIGGUI_EXPORT KConfigSkeleton : public KCoreConfigSkeleton /** * Class for handling a font preferences item. */ - class KCONFIGGUI_EXPORT ItemFont: public KConfigSkeletonGenericItem < QFont > + class KCONFIGGUI_EXPORT ItemFont : public KConfigSkeletonGenericItem { public: /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ - ItemFont(const QString &_group, const QString &_key, QFont &reference, - const QFont &defaultValue = QFont()); + ItemFont(const QString &_group, const QString &_key, QFont &reference, const QFont &defaultValue = QFont()); /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */ void readConfig(KConfig *config) override; @@ -103,9 +100,7 @@ class KCONFIGGUI_EXPORT KConfigSkeleton : public KCoreConfigSkeleton * @param key Key used in config file. If key is null, name is used as key. * @return The created item */ - ItemColor *addItemColor(const QString &name, QColor &reference, - const QColor &defaultValue = QColor(128, 128, 128), - const QString &key = QString()); + ItemColor *addItemColor(const QString &name, QColor &reference, const QColor &defaultValue = QColor(128, 128, 128), const QString &key = QString()); /** * Register an item of type QFont. @@ -118,10 +113,7 @@ class KCONFIGGUI_EXPORT KConfigSkeleton : public KCoreConfigSkeleton * @param key Key used in config file. If key is null, name is used as key. * @return The created item */ - ItemFont *addItemFont(const QString &name, QFont &reference, - const QFont &defaultValue = QFont(), - const QString &key = QString()); - + ItemFont *addItemFont(const QString &name, QFont &reference, const QFont &defaultValue = QFont(), const QString &key = QString()); }; #endif diff --git a/src/gui/kstandardshortcut.cpp b/src/gui/kstandardshortcut.cpp index c55d71c3..ac8431df 100644 --- a/src/gui/kstandardshortcut.cpp +++ b/src/gui/kstandardshortcut.cpp @@ -19,7 +19,6 @@ namespace KStandardShortcut { - struct KStandardShortcutInfo { //! The standard shortcut id. @see StandardShortcut StandardShortcut id; @@ -32,7 +31,10 @@ struct KStandardShortcutInfo { const char *name; //! Localized label for user-visible display, including translation context. - struct { const char *text; const char *context; } description; + struct { + const char *text; + const char *context; + } description; //! The keys for this shortcut int cutDefault, cutDefault2; @@ -47,11 +49,11 @@ struct KStandardShortcutInfo { Category category; }; -#define CTRL(x) Qt::CTRL|Qt::Key_##x -#define SHIFT(x) Qt::SHIFT|Qt::Key_##x -#define CTRLSHIFT(x) Qt::CTRL|Qt::SHIFT|Qt::Key_##x -#define ALT(x) Qt::ALT|Qt::Key_##x -#define ALTSHIFT(x) Qt::ALT|Qt::SHIFT|Qt::Key_##x +#define CTRL(x) Qt::CTRL | Qt::Key_##x +#define SHIFT(x) Qt::SHIFT | Qt::Key_##x +#define CTRLSHIFT(x) Qt::CTRL | Qt::SHIFT | Qt::Key_##x +#define ALT(x) Qt::ALT | Qt::Key_##x +#define ALTSHIFT(x) Qt::ALT | Qt::SHIFT | Qt::Key_##x /** Array of predefined KStandardShortcutInfo objects, which cover all the "standard" accelerators. Each enum value from StandardShortcut @@ -60,129 +62,351 @@ struct KStandardShortcutInfo { // STUFF WILL BREAK IF YOU DON'T READ THIS!!! // Read the comments of the big enum in kstandardshortcut.h before you change anything! static KStandardShortcutInfo g_infoStandardShortcut[] = { -//Group File, - { AccelNone, nullptr, {nullptr, nullptr}, 0, 0, QList(), false, Category::InvalidCategory }, - { Open, "Open", QT_TRANSLATE_NOOP3("KStandardShortcut", "Open", "@action"), CTRL(O), 0, QList(), false, Category::File }, - { New, "New", QT_TRANSLATE_NOOP3("KStandardShortcut", "New", "@action"), CTRL(N), 0, QList(), false, Category::File }, - { Close, "Close", QT_TRANSLATE_NOOP3("KStandardShortcut", "Close", "@action"), CTRL(W), CTRL(Escape), QList(), false, Category::File }, - { Save, "Save", QT_TRANSLATE_NOOP3("KStandardShortcut", "Save", "@action"), CTRL(S), 0, QList(), false, Category::File }, - { Print, "Print", QT_TRANSLATE_NOOP3("KStandardShortcut", "Print", "@action"), CTRL(P), 0, QList(), false, Category::File }, - { Quit, "Quit", QT_TRANSLATE_NOOP3("KStandardShortcut", "Quit", "@action"), CTRL(Q), 0, QList(), false, Category::Navigation }, - -//Group Edit - { Undo, "Undo", QT_TRANSLATE_NOOP3("KStandardShortcut", "Undo", "@action"), CTRL(Z), 0, QList(), false, Category::Edit }, - { Redo, "Redo", QT_TRANSLATE_NOOP3("KStandardShortcut", "Redo", "@action"), CTRLSHIFT(Z), 0, QList(), false, Category::Edit }, + // Group File, + {AccelNone, nullptr, {nullptr, nullptr}, 0, 0, QList(), false, Category::InvalidCategory}, + {Open, "Open", QT_TRANSLATE_NOOP3("KStandardShortcut", "Open", "@action"), CTRL(O), 0, QList(), false, Category::File}, + {New, "New", QT_TRANSLATE_NOOP3("KStandardShortcut", "New", "@action"), CTRL(N), 0, QList(), false, Category::File}, + {Close, "Close", QT_TRANSLATE_NOOP3("KStandardShortcut", "Close", "@action"), CTRL(W), CTRL(Escape), QList(), false, Category::File}, + {Save, "Save", QT_TRANSLATE_NOOP3("KStandardShortcut", "Save", "@action"), CTRL(S), 0, QList(), false, Category::File}, + {Print, "Print", QT_TRANSLATE_NOOP3("KStandardShortcut", "Print", "@action"), CTRL(P), 0, QList(), false, Category::File}, + {Quit, "Quit", QT_TRANSLATE_NOOP3("KStandardShortcut", "Quit", "@action"), CTRL(Q), 0, QList(), false, Category::Navigation}, + + // Group Edit + {Undo, "Undo", QT_TRANSLATE_NOOP3("KStandardShortcut", "Undo", "@action"), CTRL(Z), 0, QList(), false, Category::Edit}, + {Redo, "Redo", QT_TRANSLATE_NOOP3("KStandardShortcut", "Redo", "@action"), CTRLSHIFT(Z), 0, QList(), false, Category::Edit}, // Both "Cut" and "Delete" use Shift+Delete, but this is okay; see // https://commits.kde.org/kxmlgui/8eabbf6725386e716b7536c71a9181dfe5d959f0 - { Cut, "Cut", QT_TRANSLATE_NOOP3("KStandardShortcut", "Cut", "@action"), CTRL(X), SHIFT(Delete), QList(), false, Category::Edit }, - { Copy, "Copy", QT_TRANSLATE_NOOP3("KStandardShortcut", "Copy", "@action"), CTRL(C), CTRL(Insert), QList(), false, Category::Edit}, - { Paste, "Paste", QT_TRANSLATE_NOOP3("KStandardShortcut", "Paste", "@action"), CTRL(V), SHIFT(Insert), QList(), false, Category::Edit }, - { PasteSelection, "Paste Selection", QT_TRANSLATE_NOOP3("KStandardShortcut", "Paste Selection", "@action"), CTRLSHIFT(Insert), 0, QList(), false, Category::Edit }, - - { SelectAll, "SelectAll", QT_TRANSLATE_NOOP3("KStandardShortcut", "Select All", "@action"), CTRL(A), 0, QList(), false, Category::Edit }, - { Deselect, "Deselect", QT_TRANSLATE_NOOP3("KStandardShortcut", "Deselect", "@action"), CTRLSHIFT(A), 0, QList(), false, Category::Edit }, - { DeleteWordBack, "DeleteWordBack", QT_TRANSLATE_NOOP3("KStandardShortcut", "Delete Word Backwards", "@action"), CTRL(Backspace), 0, QList(), false, Category::Edit }, - { DeleteWordForward, "DeleteWordForward", QT_TRANSLATE_NOOP3("KStandardShortcut", "Delete Word Forward", "@action"), CTRL(Delete), 0, QList(), false, Category::Edit }, - - { Find, "Find", QT_TRANSLATE_NOOP3("KStandardShortcut", "Find", "@action"), CTRL(F), 0, QList(), false, Category::Edit }, - { FindNext, "FindNext", QT_TRANSLATE_NOOP3("KStandardShortcut", "Find Next", "@action"), Qt::Key_F3, 0, QList(), false, Category::Edit }, - { FindPrev, "FindPrev", QT_TRANSLATE_NOOP3("KStandardShortcut", "Find Prev", "@action"), SHIFT(F3), 0, QList(), false, Category::Edit }, - { Replace, "Replace", QT_TRANSLATE_NOOP3("KStandardShortcut", "Replace", "@action"), CTRL(R), 0, QList(), false, Category::Edit }, - -//Group Navigation - { Home, "Home", QT_TRANSLATE_NOOP3("KStandardShortcut", "Home", "@action Go to main page"), ALT(Home), Qt::Key_HomePage, QList(), false, Category::Navigation }, - { Begin, "Begin", QT_TRANSLATE_NOOP3("KStandardShortcut", "Begin", "@action Beginning of document"), CTRL(Home), 0, QList(), false, Category::Navigation }, - { End, "End", QT_TRANSLATE_NOOP3("KStandardShortcut", "End", "@action End of document"), CTRL(End), 0, QList(), false, Category::Navigation }, - { Prior, "Prior", QT_TRANSLATE_NOOP3("KStandardShortcut", "Prior", "@action"), Qt::Key_PageUp, 0, QList(), false, Category::Navigation }, - { Next, "Next", QT_TRANSLATE_NOOP3("KStandardShortcut", "Next", "@action Opposite to Prior"), Qt::Key_PageDown, 0, QList(), false, Category::Navigation }, - - { Up, "Up", QT_TRANSLATE_NOOP3("KStandardShortcut", "Up", "@action"), ALT(Up), 0, QList(), false, Category::Navigation }, - { Back, "Back", QT_TRANSLATE_NOOP3("KStandardShortcut", "Back", "@action"), ALT(Left), Qt::Key_Back, QList(), false, Category::Navigation }, - { Forward, "Forward", QT_TRANSLATE_NOOP3("KStandardShortcut", "Forward", "@action"), ALT(Right), Qt::Key_Forward, QList(), false, Category::Navigation }, - { Reload, "Reload", QT_TRANSLATE_NOOP3("KStandardShortcut", "Reload", "@action"), Qt::Key_F5, Qt::Key_Refresh, QList(), false, Category::Navigation }, - - { BeginningOfLine, "BeginningOfLine", QT_TRANSLATE_NOOP3("KStandardShortcut", "Beginning of Line", "@action"), Qt::Key_Home, 0, QList(), false, Category::Navigation }, - { EndOfLine, "EndOfLine", QT_TRANSLATE_NOOP3("KStandardShortcut", "End of Line", "@action"), Qt::Key_End, 0, QList(), false, Category::Navigation }, - { GotoLine, "GotoLine", QT_TRANSLATE_NOOP3("KStandardShortcut", "Go to Line", "@action"), CTRL(G), 0, QList(), false, Category::Navigation }, - { BackwardWord, "BackwardWord", QT_TRANSLATE_NOOP3("KStandardShortcut", "Backward Word", "@action"), CTRL(Left), 0, QList(), false, Category::Navigation }, - { ForwardWord, "ForwardWord", QT_TRANSLATE_NOOP3("KStandardShortcut", "Forward Word", "@action"), CTRL(Right), 0, QList(), false, Category::Navigation }, - - { AddBookmark, "AddBookmark", QT_TRANSLATE_NOOP3("KStandardShortcut", "Add Bookmark", "@action"), CTRL(B), 0, QList(), false, Category::Navigation }, - { ZoomIn, "ZoomIn", QT_TRANSLATE_NOOP3("KStandardShortcut", "Zoom In", "@action"), CTRL(Plus), CTRL(Equal), QList(), false, Category::View }, - { ZoomOut, "ZoomOut", QT_TRANSLATE_NOOP3("KStandardShortcut", "Zoom Out", "@action"), CTRL(Minus), 0, QList(), false, Category::View }, - { FullScreen, "FullScreen", QT_TRANSLATE_NOOP3("KStandardShortcut", "Full Screen Mode", "@action"), CTRLSHIFT(F), 0, QList(), false, Category::View }, - - { ShowMenubar, "ShowMenubar", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show Menu Bar", "@action"), CTRL(M), 0, QList(), false, Category::View }, - { TabNext, "Activate Next Tab", QT_TRANSLATE_NOOP3("KStandardShortcut", "Activate Next Tab", "@action"), CTRL(PageDown), CTRL(BracketRight), QList(), false, Category::Navigation }, - { TabPrev, "Activate Previous Tab", QT_TRANSLATE_NOOP3("KStandardShortcut", "Activate Previous Tab", "@action"), CTRL(PageUp), CTRL(BracketLeft), QList(), false, Category::Navigation }, - - //Group Help - { Help, "Help", QT_TRANSLATE_NOOP3("KStandardShortcut", "Help", "@action"), Qt::Key_F1, 0, QList(), false, Category::Help }, - { WhatsThis, "WhatsThis", QT_TRANSLATE_NOOP3("KStandardShortcut", "What's This", "@action"), SHIFT(F1), 0, QList(), false, Category::Help }, - -//Group TextCompletion - { TextCompletion, "TextCompletion", QT_TRANSLATE_NOOP3("KStandardShortcut", "Text Completion", "@action"), CTRL(E), 0, QList(), false, Category::Edit }, - { PrevCompletion, "PrevCompletion", QT_TRANSLATE_NOOP3("KStandardShortcut", "Previous Completion Match", "@action"), CTRL(Up), 0, QList(), false, Category::Edit }, - { NextCompletion, "NextCompletion", QT_TRANSLATE_NOOP3("KStandardShortcut", "Next Completion Match", "@action"), CTRL(Down), 0, QList(), false, Category::Edit }, - { SubstringCompletion, "SubstringCompletion", QT_TRANSLATE_NOOP3("KStandardShortcut", "Substring Completion", "@action"), CTRL(T), 0, QList(), false, Category::Edit }, - - { RotateUp, "RotateUp", QT_TRANSLATE_NOOP3("KStandardShortcut", "Previous Item in List", "@action"), Qt::Key_Up, 0, QList(), false, Category::Navigation }, - { RotateDown, "RotateDown", QT_TRANSLATE_NOOP3("KStandardShortcut", "Next Item in List", "@action"), Qt::Key_Down, 0, QList(), false, Category::Navigation }, - - { OpenRecent, "OpenRecent", QT_TRANSLATE_NOOP3("KStandardShortcut", "Open Recent", "@action"), 0, 0, QList(), false, Category::File }, - { SaveAs, "SaveAs", QT_TRANSLATE_NOOP3("KStandardShortcut", "Save As", "@action"), CTRLSHIFT(S), 0, QList(), false, Category::File }, - { Revert, "Revert", QT_TRANSLATE_NOOP3("KStandardShortcut", "Revert", "@action"), 0, 0, QList(), false, Category::Edit }, - { PrintPreview, "PrintPreview", QT_TRANSLATE_NOOP3("KStandardShortcut", "Print Preview", "@action"), 0, 0, QList(), false, Category::File }, - { Mail, "Mail", QT_TRANSLATE_NOOP3("KStandardShortcut", "Mail", "@action"), 0, 0, QList(), false, Category::Help }, - { Clear, "Clear", QT_TRANSLATE_NOOP3("KStandardShortcut", "Clear", "@action"), 0, 0, QList(), false, Category::Edit }, - { ActualSize, "ActualSize", QT_TRANSLATE_NOOP3("KStandardShortcut", "Actual Size", "@action"), CTRL(0), 0, QList(), false, Category::View }, - { FitToPage, "FitToPage", QT_TRANSLATE_NOOP3("KStandardShortcut", "Fit To Page", "@action"), 0, 0, QList(), false, Category::View }, - { FitToWidth, "FitToWidth", QT_TRANSLATE_NOOP3("KStandardShortcut", "Fit To Width", "@action"), 0, 0, QList(), false, Category::View }, - { FitToHeight, "FitToHeight", QT_TRANSLATE_NOOP3("KStandardShortcut", "Fit To Height", "@action"), 0, 0, QList(), false, Category::View }, - { Zoom, "Zoom", QT_TRANSLATE_NOOP3("KStandardShortcut", "Zoom", "@action"), 0, 0, QList(), false, Category::View }, - { Goto, "Goto", QT_TRANSLATE_NOOP3("KStandardShortcut", "Goto", "@action"), 0, 0, QList(), false, Category::Navigation }, - { GotoPage, "GotoPage", QT_TRANSLATE_NOOP3("KStandardShortcut", "Goto Page", "@action"), 0, 0, QList(), false, Category::Navigation }, - { DocumentBack, "DocumentBack", QT_TRANSLATE_NOOP3("KStandardShortcut", "Document Back", "@action"), ALTSHIFT(Left), 0, QList(), false, Category::Navigation }, - { DocumentForward, "DocumentForward", QT_TRANSLATE_NOOP3("KStandardShortcut", "Document Forward", "@action"), ALTSHIFT(Right), 0, QList(), false, Category::Navigation }, - { EditBookmarks, "EditBookmarks", QT_TRANSLATE_NOOP3("KStandardShortcut", "Edit Bookmarks", "@action"), 0, 0, QList(), false, Category::Navigation }, - { Spelling, "Spelling", QT_TRANSLATE_NOOP3("KStandardShortcut", "Spelling", "@action"), 0, 0, QList(), false, Category::Edit }, - { ShowToolbar, "ShowToolbar", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show Toolbar", "@action"), 0, 0, QList(), false, Category::View }, - { ShowStatusbar, "ShowStatusbar", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show Statusbar", "@action"), 0, 0, QList(), false, Category::View }, + {Cut, "Cut", QT_TRANSLATE_NOOP3("KStandardShortcut", "Cut", "@action"), CTRL(X), SHIFT(Delete), QList(), false, Category::Edit}, + {Copy, "Copy", QT_TRANSLATE_NOOP3("KStandardShortcut", "Copy", "@action"), CTRL(C), CTRL(Insert), QList(), false, Category::Edit}, + {Paste, "Paste", QT_TRANSLATE_NOOP3("KStandardShortcut", "Paste", "@action"), CTRL(V), SHIFT(Insert), QList(), false, Category::Edit}, + {PasteSelection, + "Paste Selection", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Paste Selection", "@action"), + CTRLSHIFT(Insert), + 0, + QList(), + false, + Category::Edit}, + + {SelectAll, "SelectAll", QT_TRANSLATE_NOOP3("KStandardShortcut", "Select All", "@action"), CTRL(A), 0, QList(), false, Category::Edit}, + {Deselect, "Deselect", QT_TRANSLATE_NOOP3("KStandardShortcut", "Deselect", "@action"), CTRLSHIFT(A), 0, QList(), false, Category::Edit}, + {DeleteWordBack, + "DeleteWordBack", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Delete Word Backwards", "@action"), + CTRL(Backspace), + 0, + QList(), + false, + Category::Edit}, + {DeleteWordForward, + "DeleteWordForward", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Delete Word Forward", "@action"), + CTRL(Delete), + 0, + QList(), + false, + Category::Edit}, + + {Find, "Find", QT_TRANSLATE_NOOP3("KStandardShortcut", "Find", "@action"), CTRL(F), 0, QList(), false, Category::Edit}, + {FindNext, "FindNext", QT_TRANSLATE_NOOP3("KStandardShortcut", "Find Next", "@action"), Qt::Key_F3, 0, QList(), false, Category::Edit}, + {FindPrev, "FindPrev", QT_TRANSLATE_NOOP3("KStandardShortcut", "Find Prev", "@action"), SHIFT(F3), 0, QList(), false, Category::Edit}, + {Replace, "Replace", QT_TRANSLATE_NOOP3("KStandardShortcut", "Replace", "@action"), CTRL(R), 0, QList(), false, Category::Edit}, + + // Group Navigation + {Home, + "Home", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Home", "@action Go to main page"), + ALT(Home), + Qt::Key_HomePage, + QList(), + false, + Category::Navigation}, + {Begin, + "Begin", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Begin", "@action Beginning of document"), + CTRL(Home), + 0, + QList(), + false, + Category::Navigation}, + {End, "End", QT_TRANSLATE_NOOP3("KStandardShortcut", "End", "@action End of document"), CTRL(End), 0, QList(), false, Category::Navigation}, + {Prior, "Prior", QT_TRANSLATE_NOOP3("KStandardShortcut", "Prior", "@action"), Qt::Key_PageUp, 0, QList(), false, Category::Navigation}, + {Next, + "Next", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Next", "@action Opposite to Prior"), + Qt::Key_PageDown, + 0, + QList(), + false, + Category::Navigation}, + + {Up, "Up", QT_TRANSLATE_NOOP3("KStandardShortcut", "Up", "@action"), ALT(Up), 0, QList(), false, Category::Navigation}, + {Back, "Back", QT_TRANSLATE_NOOP3("KStandardShortcut", "Back", "@action"), ALT(Left), Qt::Key_Back, QList(), false, Category::Navigation}, + {Forward, + "Forward", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Forward", "@action"), + ALT(Right), + Qt::Key_Forward, + QList(), + false, + Category::Navigation}, + {Reload, + "Reload", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Reload", "@action"), + Qt::Key_F5, + Qt::Key_Refresh, + QList(), + false, + Category::Navigation}, + + {BeginningOfLine, + "BeginningOfLine", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Beginning of Line", "@action"), + Qt::Key_Home, + 0, + QList(), + false, + Category::Navigation}, + {EndOfLine, + "EndOfLine", + QT_TRANSLATE_NOOP3("KStandardShortcut", "End of Line", "@action"), + Qt::Key_End, + 0, + QList(), + false, + Category::Navigation}, + {GotoLine, "GotoLine", QT_TRANSLATE_NOOP3("KStandardShortcut", "Go to Line", "@action"), CTRL(G), 0, QList(), false, Category::Navigation}, + {BackwardWord, + "BackwardWord", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Backward Word", "@action"), + CTRL(Left), + 0, + QList(), + false, + Category::Navigation}, + {ForwardWord, + "ForwardWord", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Forward Word", "@action"), + CTRL(Right), + 0, + QList(), + false, + Category::Navigation}, + + {AddBookmark, + "AddBookmark", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Add Bookmark", "@action"), + CTRL(B), + 0, + QList(), + false, + Category::Navigation}, + {ZoomIn, "ZoomIn", QT_TRANSLATE_NOOP3("KStandardShortcut", "Zoom In", "@action"), CTRL(Plus), CTRL(Equal), QList(), false, Category::View}, + {ZoomOut, "ZoomOut", QT_TRANSLATE_NOOP3("KStandardShortcut", "Zoom Out", "@action"), CTRL(Minus), 0, QList(), false, Category::View}, + {FullScreen, + "FullScreen", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Full Screen Mode", "@action"), + CTRLSHIFT(F), + 0, + QList(), + false, + Category::View}, + + {ShowMenubar, "ShowMenubar", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show Menu Bar", "@action"), CTRL(M), 0, QList(), false, Category::View}, + {TabNext, + "Activate Next Tab", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Activate Next Tab", "@action"), + CTRL(PageDown), + CTRL(BracketRight), + QList(), + false, + Category::Navigation}, + {TabPrev, + "Activate Previous Tab", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Activate Previous Tab", "@action"), + CTRL(PageUp), + CTRL(BracketLeft), + QList(), + false, + Category::Navigation}, + + // Group Help + {Help, "Help", QT_TRANSLATE_NOOP3("KStandardShortcut", "Help", "@action"), Qt::Key_F1, 0, QList(), false, Category::Help}, + {WhatsThis, "WhatsThis", QT_TRANSLATE_NOOP3("KStandardShortcut", "What's This", "@action"), SHIFT(F1), 0, QList(), false, Category::Help}, + + // Group TextCompletion + {TextCompletion, + "TextCompletion", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Text Completion", "@action"), + CTRL(E), + 0, + QList(), + false, + Category::Edit}, + {PrevCompletion, + "PrevCompletion", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Previous Completion Match", "@action"), + CTRL(Up), + 0, + QList(), + false, + Category::Edit}, + {NextCompletion, + "NextCompletion", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Next Completion Match", "@action"), + CTRL(Down), + 0, + QList(), + false, + Category::Edit}, + {SubstringCompletion, + "SubstringCompletion", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Substring Completion", "@action"), + CTRL(T), + 0, + QList(), + false, + Category::Edit}, + + {RotateUp, + "RotateUp", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Previous Item in List", "@action"), + Qt::Key_Up, + 0, + QList(), + false, + Category::Navigation}, + {RotateDown, + "RotateDown", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Next Item in List", "@action"), + Qt::Key_Down, + 0, + QList(), + false, + Category::Navigation}, + + {OpenRecent, "OpenRecent", QT_TRANSLATE_NOOP3("KStandardShortcut", "Open Recent", "@action"), 0, 0, QList(), false, Category::File}, + {SaveAs, "SaveAs", QT_TRANSLATE_NOOP3("KStandardShortcut", "Save As", "@action"), CTRLSHIFT(S), 0, QList(), false, Category::File}, + {Revert, "Revert", QT_TRANSLATE_NOOP3("KStandardShortcut", "Revert", "@action"), 0, 0, QList(), false, Category::Edit}, + {PrintPreview, "PrintPreview", QT_TRANSLATE_NOOP3("KStandardShortcut", "Print Preview", "@action"), 0, 0, QList(), false, Category::File}, + {Mail, "Mail", QT_TRANSLATE_NOOP3("KStandardShortcut", "Mail", "@action"), 0, 0, QList(), false, Category::Help}, + {Clear, "Clear", QT_TRANSLATE_NOOP3("KStandardShortcut", "Clear", "@action"), 0, 0, QList(), false, Category::Edit}, + {ActualSize, "ActualSize", QT_TRANSLATE_NOOP3("KStandardShortcut", "Actual Size", "@action"), CTRL(0), 0, QList(), false, Category::View}, + {FitToPage, "FitToPage", QT_TRANSLATE_NOOP3("KStandardShortcut", "Fit To Page", "@action"), 0, 0, QList(), false, Category::View}, + {FitToWidth, "FitToWidth", QT_TRANSLATE_NOOP3("KStandardShortcut", "Fit To Width", "@action"), 0, 0, QList(), false, Category::View}, + {FitToHeight, "FitToHeight", QT_TRANSLATE_NOOP3("KStandardShortcut", "Fit To Height", "@action"), 0, 0, QList(), false, Category::View}, + {Zoom, "Zoom", QT_TRANSLATE_NOOP3("KStandardShortcut", "Zoom", "@action"), 0, 0, QList(), false, Category::View}, + {Goto, "Goto", QT_TRANSLATE_NOOP3("KStandardShortcut", "Goto", "@action"), 0, 0, QList(), false, Category::Navigation}, + {GotoPage, "GotoPage", QT_TRANSLATE_NOOP3("KStandardShortcut", "Goto Page", "@action"), 0, 0, QList(), false, Category::Navigation}, + {DocumentBack, + "DocumentBack", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Document Back", "@action"), + ALTSHIFT(Left), + 0, + QList(), + false, + Category::Navigation}, + {DocumentForward, + "DocumentForward", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Document Forward", "@action"), + ALTSHIFT(Right), + 0, + QList(), + false, + Category::Navigation}, + {EditBookmarks, + "EditBookmarks", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Edit Bookmarks", "@action"), + 0, + 0, + QList(), + false, + Category::Navigation}, + {Spelling, "Spelling", QT_TRANSLATE_NOOP3("KStandardShortcut", "Spelling", "@action"), 0, 0, QList(), false, Category::Edit}, + {ShowToolbar, "ShowToolbar", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show Toolbar", "@action"), 0, 0, QList(), false, Category::View}, + {ShowStatusbar, "ShowStatusbar", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show Statusbar", "@action"), 0, 0, QList(), false, Category::View}, #if KCONFIGGUI_BUILD_DEPRECATED_SINCE(5, 39) - { SaveOptions, "SaveOptions", QT_TRANSLATE_NOOP3("KStandardShortcut", "Save Options", "@action"), 0, 0, QList(), false, Category::Settings }, + {SaveOptions, "SaveOptions", QT_TRANSLATE_NOOP3("KStandardShortcut", "Save Options", "@action"), 0, 0, QList(), false, Category::Settings}, #else // dummy entry - { SaveOptions_DEPRECATED_DO_NOT_USE, nullptr, {nullptr, nullptr}, 0, 0, QList(), false, Category::InvalidCategory }, + {SaveOptions_DEPRECATED_DO_NOT_USE, nullptr, {nullptr, nullptr}, 0, 0, QList(), false, Category::InvalidCategory}, #endif - { KeyBindings, "KeyBindings", QT_TRANSLATE_NOOP3("KStandardShortcut", "Key Bindings", "@action"), 0, 0, QList(), false, Category::Settings }, - { Preferences, "Preferences", QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Application", "@action"), CTRLSHIFT(Comma), 0, QList(), false, Category::Settings }, - { ConfigureToolbars, "ConfigureToolbars", QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Toolbars", "@action"), 0, 0, QList(), false, Category::Settings }, - { ConfigureNotifications, "ConfigureNotifications", QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Notifications", "@action"), 0, 0, QList(), false, Category::Settings }, - { TipofDay, "TipofDay", QT_TRANSLATE_NOOP3("KStandardShortcut", "Tip Of Day", "@action"), 0, 0, QList(), false, Category::Help }, - { ReportBug, "ReportBug", QT_TRANSLATE_NOOP3("KStandardShortcut", "Report Bug", "@action"), 0, 0, QList(), false, Category::Help }, - { SwitchApplicationLanguage, "SwitchApplicationLanguage", QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Language...", "@action"), 0, 0, QList(), false, Category::Settings }, - { AboutApp, "AboutApp", QT_TRANSLATE_NOOP3("KStandardShortcut", "About Application", "@action"), 0, 0, QList(), false, Category::Help }, - { AboutKDE, "AboutKDE", QT_TRANSLATE_NOOP3("KStandardShortcut", "About KDE", "@action"), 0, 0, QList(), false, Category::Help }, + {KeyBindings, "KeyBindings", QT_TRANSLATE_NOOP3("KStandardShortcut", "Key Bindings", "@action"), 0, 0, QList(), false, Category::Settings}, + {Preferences, + "Preferences", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Application", "@action"), + CTRLSHIFT(Comma), + 0, + QList(), + false, + Category::Settings}, + {ConfigureToolbars, + "ConfigureToolbars", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Toolbars", "@action"), + 0, + 0, + QList(), + false, + Category::Settings}, + {ConfigureNotifications, + "ConfigureNotifications", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Notifications", "@action"), + 0, + 0, + QList(), + false, + Category::Settings}, + {TipofDay, "TipofDay", QT_TRANSLATE_NOOP3("KStandardShortcut", "Tip Of Day", "@action"), 0, 0, QList(), false, Category::Help}, + {ReportBug, "ReportBug", QT_TRANSLATE_NOOP3("KStandardShortcut", "Report Bug", "@action"), 0, 0, QList(), false, Category::Help}, + {SwitchApplicationLanguage, + "SwitchApplicationLanguage", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Language...", "@action"), + 0, + 0, + QList(), + false, + Category::Settings}, + {AboutApp, "AboutApp", QT_TRANSLATE_NOOP3("KStandardShortcut", "About Application", "@action"), 0, 0, QList(), false, Category::Help}, + {AboutKDE, "AboutKDE", QT_TRANSLATE_NOOP3("KStandardShortcut", "About KDE", "@action"), 0, 0, QList(), false, Category::Help}, // Both "Cut" and "Delete" use Shift+Delete, but this is okay; see // https://commits.kde.org/kxmlgui/8eabbf6725386e716b7536c71a9181dfe5d959f0 - { DeleteFile, "DeleteFile", QT_TRANSLATE_NOOP3("KStandardShortcut", "Delete", "@action"), SHIFT(Delete), 0, QList(), false, Category::File }, - { RenameFile, "RenameFile", QT_TRANSLATE_NOOP3("KStandardShortcut", "Rename", "@action"), Qt::Key_F2, 0, QList(), false, Category::File }, - { MoveToTrash, "MoveToTrash", QT_TRANSLATE_NOOP3("KStandardShortcut", "Move to Trash", "@action"), Qt::Key_Delete, 0, QList(), false, Category::File }, - { Donate, "Donate", QT_TRANSLATE_NOOP3("KStandardShortcut", "Donate", "@action"), 0, 0, QList(), false, Category::Help }, - { ShowHideHiddenFiles, "ShowHideHiddenFiles", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show/Hide Hidden Files", "@action"), CTRL(H), ALT(Period), QList(), false, Category::View }, - { CreateFolder, "CreateFolder", QT_TRANSLATE_NOOP3("KStandardShortcut", "Create Folder", "@action"), Qt::Key_F10, 0, QList(), false, Category::File }, - - //dummy entry to catch simple off-by-one errors. Insert new entries before this line. - { AccelNone, nullptr, {nullptr, nullptr}, 0, 0, QList(), false, Category::InvalidCategory } -}; + {DeleteFile, "DeleteFile", QT_TRANSLATE_NOOP3("KStandardShortcut", "Delete", "@action"), SHIFT(Delete), 0, QList(), false, Category::File}, + {RenameFile, "RenameFile", QT_TRANSLATE_NOOP3("KStandardShortcut", "Rename", "@action"), Qt::Key_F2, 0, QList(), false, Category::File}, + {MoveToTrash, + "MoveToTrash", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Move to Trash", "@action"), + Qt::Key_Delete, + 0, + QList(), + false, + Category::File}, + {Donate, "Donate", QT_TRANSLATE_NOOP3("KStandardShortcut", "Donate", "@action"), 0, 0, QList(), false, Category::Help}, + {ShowHideHiddenFiles, + "ShowHideHiddenFiles", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Show/Hide Hidden Files", "@action"), + CTRL(H), + ALT(Period), + QList(), + false, + Category::View}, + {CreateFolder, + "CreateFolder", + QT_TRANSLATE_NOOP3("KStandardShortcut", "Create Folder", "@action"), + Qt::Key_F10, + 0, + QList(), + false, + Category::File}, + + // dummy entry to catch simple off-by-one errors. Insert new entries before this line. + {AccelNone, nullptr, {nullptr, nullptr}, 0, 0, QList(), false, Category::InvalidCategory}}; /** Search for the KStandardShortcutInfo object associated with the given @p id. Return a dummy entry with no name and an empty shortcut if @p id is invalid. */ static KStandardShortcutInfo *guardedStandardShortcutInfo(StandardShortcut id) { - if (id >= static_cast(sizeof(g_infoStandardShortcut) / sizeof(KStandardShortcutInfo)) || - id < 0) { + if (id >= static_cast(sizeof(g_infoStandardShortcut) / sizeof(KStandardShortcutInfo)) || id < 0) { qWarning() << "KStandardShortcut: id not found!"; return &g_infoStandardShortcut[AccelNone]; } else { @@ -190,7 +414,6 @@ static KStandardShortcutInfo *guardedStandardShortcutInfo(StandardShortcut id) } } - // Sanitize the list for duplicates. For some reason some // people have kdeglobals entries like // Close=Ctrl+W; Ctrl+Esc; Ctrl+W; Ctrl+Esc; @@ -278,18 +501,16 @@ QString name(StandardShortcut id) QString label(StandardShortcut id) { KStandardShortcutInfo *info = guardedStandardShortcutInfo(id); - return QCoreApplication::translate("KStandardShortcut", - info->description.text, - info->description.context); + return QCoreApplication::translate("KStandardShortcut", info->description.text, info->description.context); } // TODO: Add psWhatsThis entry to KStandardShortcutInfo QString whatsThis(StandardShortcut /*id*/) { -// KStandardShortcutInfo* info = guardedStandardShortcutInfo( id ); -// if( info && info->whatsThis ) -// return i18n(info->whatsThis); -// else + // KStandardShortcutInfo* info = guardedStandardShortcutInfo( id ); + // if( info && info->whatsThis ) + // return i18n(info->whatsThis); + // else return QString(); } @@ -326,7 +547,6 @@ StandardShortcut find(const QKeySequence &seq) return AccelNone; } - #if KCONFIGGUI_BUILD_DEPRECATED_SINCE(5, 71) StandardShortcut find(const char *keyName) { @@ -342,7 +562,6 @@ StandardShortcut find(const char *keyName) StandardShortcut findByName(const QString &name) { - for (const KStandardShortcutInfo &shortcutInfo : g_infoStandardShortcut) { if (QString::fromLatin1(shortcutInfo.name) == name) { return shortcutInfo.id; diff --git a/src/gui/kstandardshortcut.h b/src/gui/kstandardshortcut.h index 3757a593..6ffbeed6 100644 --- a/src/gui/kstandardshortcut.h +++ b/src/gui/kstandardshortcut.h @@ -9,8 +9,8 @@ #ifndef KSTANDARDSHORTCUT_H #define KSTANDARDSHORTCUT_H -#include #include +#include #include @@ -42,8 +42,8 @@ namespace KStandardShortcut * Defines the identifier of all standard accelerators. */ enum StandardShortcut { - //C++ requires that the value of an enum symbol be one more than the previous one. - //This means that everything will be well-ordered from here on. + // C++ requires that the value of an enum symbol be one more than the previous one. + // This means that everything will be well-ordered from here on. AccelNone = 0, // File menu Open, ///< Open file. diff --git a/src/gui/kwindowconfig.cpp b/src/gui/kwindowconfig.cpp index 4f3ac73a..a7697782 100644 --- a/src/gui/kwindowconfig.cpp +++ b/src/gui/kwindowconfig.cpp @@ -37,7 +37,7 @@ static QString allConnectedScreens() static QString configFileString(const QRect &desk, const QString &key) { // We include resolution data to also save data on a per-resolution basis - const QString returnString = QStringLiteral("%1 %2 %3x%4").arg(allConnectedScreens()).arg(key).arg(desk.width()).arg(desk.height()); + const QString returnString = QStringLiteral("%1 %2 %3x%4").arg(allConnectedScreens()).arg(key).arg(desk.width()).arg(desk.height()); return returnString; } @@ -67,7 +67,6 @@ static QString windowYPositionString(const QRect &desk) return configFileString(desk, QStringLiteral("YPosition")); } - void KWindowConfig::saveWindowSize(const QWindow *window, KConfigGroup &config, KConfigGroup::WriteConfigFlags options) { // QWindow::screen() shouldn't return null, but it sometimes does due to bugs. @@ -97,7 +96,6 @@ void KWindowConfig::saveWindowSize(const QWindow *window, KConfigGroup &config, } else { config.writeEntry(screenMaximizedString(desk), isMaximized, options); } - } void KWindowConfig::restoreWindowSize(QWindow *window, const KConfigGroup &config) diff --git a/src/gui/kwindowconfig.h b/src/gui/kwindowconfig.h index 4bb56e12..3c18c0a7 100644 --- a/src/gui/kwindowconfig.h +++ b/src/gui/kwindowconfig.h @@ -54,7 +54,7 @@ KCONFIGGUI_EXPORT void saveWindowSize(const QWindow *window, KConfigGroup &confi * @param config The config group to read from. * @since 5.0. */ -KCONFIGGUI_EXPORT void restoreWindowSize(QWindow *window, const KConfigGroup &config); +KCONFIGGUI_EXPORT void restoreWindowSize(QWindow *window, const KConfigGroup &config); /** * Saves the window's position either to the global or application config file. @@ -81,6 +81,6 @@ KCONFIGGUI_EXPORT void saveWindowPosition(const QWindow *window, KConfigGroup &c * @param config The config group to read from. * @since 5.74 */ -KCONFIGGUI_EXPORT void restoreWindowPosition(QWindow *window, const KConfigGroup &config); +KCONFIGGUI_EXPORT void restoreWindowPosition(QWindow *window, const KConfigGroup &config); } #endif // KWINDOWCONFIG_H diff --git a/src/kconf_update/kconf_update.cpp b/src/kconf_update/kconf_update.cpp index c2552c23..defe0b80 100644 --- a/src/kconf_update/kconf_update.cpp +++ b/src/kconf_update/kconf_update.cpp @@ -7,15 +7,15 @@ #include // CMAKE_INSTALL_PREFIX +#include #include +#include +#include #include +#include +#include #include #include -#include -#include -#include -#include -#include #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #include @@ -24,17 +24,16 @@ #include #include -#include -#include #include +#include +#include #include "kconf_update_debug.h" #include "kconfigutils.h" // Convenience wrapper around qCDebug to prefix the output with metadata of // the file. -#define qCDebugFile(CATEGORY) \ - qCDebug(CATEGORY) << m_currentFilename << ':' << m_lineCount << ":'" << m_line << "': " +#define qCDebugFile(CATEGORY) qCDebug(CATEGORY) << m_currentFilename << ':' << m_lineCount << ":'" << m_line << "': " class KonfUpdate { @@ -43,7 +42,7 @@ class KonfUpdate ~KonfUpdate(); KonfUpdate(const KonfUpdate &) = delete; - KonfUpdate& operator=(const KonfUpdate &) = delete; + KonfUpdate &operator=(const KonfUpdate &) = delete; QStringList findUpdateFiles(bool dirtyOnly); @@ -65,8 +64,7 @@ class KonfUpdate void gotScriptArguments(const QString &_arguments); void resetOptions(); - void copyGroup(const KConfigBase *cfg1, const QString &group1, - KConfigBase *cfg2, const QString &group2); + void copyGroup(const KConfigBase *cfg1, const QString &group1, KConfigBase *cfg2, const QString &group2); void copyGroup(const KConfigGroup &cg1, KConfigGroup &cg2); void copyOrMoveKey(const QStringList &srcGroupPath, const QString &srcKey, const QStringList &dstGroupPath, const QString &dstKey); void copyOrMoveGroup(const QStringList &srcGroupPath, const QStringList &dstGroupPath); @@ -104,9 +102,14 @@ class KonfUpdate }; KonfUpdate::KonfUpdate(QCommandLineParser *parser) - : m_oldConfig1(nullptr), m_oldConfig2(nullptr), m_newConfig(nullptr), - m_bCopy(false), m_bOverwrite(false), m_textStream(nullptr), - m_file(nullptr), m_lineCount(-1) + : m_oldConfig1(nullptr) + , m_oldConfig2(nullptr) + , m_newConfig(nullptr) + , m_bCopy(false) + , m_bOverwrite(false) + , m_textStream(nullptr) + , m_file(nullptr) + , m_lineCount(-1) { bool updateAll = false; @@ -125,8 +128,7 @@ KonfUpdate::KonfUpdate(QCommandLineParser *parser) QLoggingCategory::setFilterRules(QLatin1String("%1.debug=true").arg(QLatin1String{KCONF_UPDATE_LOG().categoryName()})); qDebug() << "Automatically enabled the debug logging category" << KCONF_UPDATE_LOG().categoryName(); if (!KCONF_UPDATE_LOG().isDebugEnabled()) { - qWarning("The debug logging category %s needs to be enabled manually to get debug output", - KCONF_UPDATE_LOG().categoryName()); + qWarning("The debug logging category %s needs to be enabled manually to get debug output", KCONF_UPDATE_LOG().categoryName()); } } @@ -159,7 +161,7 @@ KonfUpdate::KonfUpdate(QCommandLineParser *parser) updateAll = true; } - for (const QString& file : qAsConst(updateFiles)) { + for (const QString &file : qAsConst(updateFiles)) { updateFile(file); } @@ -167,9 +169,7 @@ KonfUpdate::KonfUpdate(QCommandLineParser *parser) cg.writeEntry("updateInfoAdded", true); updateFiles = findUpdateFiles(false); - for (QStringList::ConstIterator it = updateFiles.constBegin(); - it != updateFiles.constEnd(); - ++it) { + for (QStringList::ConstIterator it = updateFiles.constBegin(); it != updateFiles.constEnd(); ++it) { checkFile(*it); } updateFiles.clear(); @@ -199,9 +199,7 @@ QStringList KonfUpdate::findUpdateFiles(bool dirtyOnly) KConfigGroup cg(m_config, fileName); const QDateTime ctime = QDateTime::fromSecsSinceEpoch(cg.readEntry("ctime", 0u)); const QDateTime mtime = QDateTime::fromSecsSinceEpoch(cg.readEntry("mtime", 0u)); - if (!dirtyOnly || - (ctime.isValid() && ctime != info.birthTime()) || - mtime != info.lastModified()) { + if (!dirtyOnly || (ctime.isValid() && ctime != info.birthTime()) || mtime != info.lastModified()) { result.append(file); } } @@ -243,9 +241,7 @@ bool KonfUpdate::checkFile(const QString &filename) } if (line.startsWith(QLatin1String("Id="))) { if (!foundVersion) { - qCDebug(KCONF_UPDATE_LOG, - "Missing 'Version=5', file '%s' will be skipped.", - qUtf8Printable(filename)); + qCDebug(KCONF_UPDATE_LOG, "Missing 'Version=5', file '%s' will be skipped.", qUtf8Printable(filename)); return true; } id = m_currentFilename + QLatin1Char{':'} + line.mid(3); @@ -267,7 +263,7 @@ void KonfUpdate::checkGotFile(const QString &_file, const QString &id) file = _file.mid(i + 1).trimmed(); } -// qDebug("File %s, id %s", file.toLatin1().constData(), id.toLatin1().constData()); + // qDebug("File %s, id %s", file.toLatin1().constData(), id.toLatin1().constData()); KConfig cfg(file, KConfig::SimpleConfig); KConfigGroup cg = cfg.group("$Version"); @@ -334,9 +330,7 @@ bool KonfUpdate::updateFile(const QString &filename) } if (m_line.startsWith(QLatin1String("Id="))) { if (!foundVersion) { - qCDebug(KCONF_UPDATE_LOG, - "Missing 'Version=5', file '%s' will be skipped.", - qUtf8Printable(filename)); + qCDebug(KCONF_UPDATE_LOG, "Missing 'Version=5', file '%s' will be skipped.", qUtf8Printable(filename)); break; } gotId(m_line.mid(3)); @@ -416,7 +410,7 @@ void KonfUpdate::gotId(const QString &_id) KConfigGroup cg(m_config, m_currentFilename); QStringList ids = cg.readEntry("done", QStringList()); if (ids.contains(_id) && !m_bUseConfigInfo) { - //qDebug("Id '%s' was already in done-list", _id.toLatin1().constData()); + // qDebug("Id '%s' was already in done-list", _id.toLatin1().constData()); m_skip = true; return; } @@ -523,8 +517,8 @@ void KonfUpdate::gotFile(const QString &_file) m_skipFile = false; if (!m_oldFile.isEmpty()) { // if File= is specified, it doesn't exist, is empty or contains only kconf_update's [$Version] group, skip if (m_oldConfig1 != nullptr - && (m_oldConfig1->groupList().isEmpty() - || (m_oldConfig1->groupList().count() == 1 && m_oldConfig1->groupList().at(0) == QLatin1String("$Version")))) { + && (m_oldConfig1->groupList().isEmpty() + || (m_oldConfig1->groupList().count() == 1 && m_oldConfig1->groupList().at(0) == QLatin1String("$Version")))) { qCDebug(KCONF_UPDATE_LOG) << m_currentFilename << ": File" << m_oldFile << "does not exist or empty, skipping"; m_skipFile = true; } @@ -621,9 +615,7 @@ void KonfUpdate::copyOrMoveKey(const QStringList &srcGroupPath, const QString &s } // Delete old entry - if (m_oldConfig2 == m_newConfig - && srcGroupPath == dstGroupPath - && srcKey == dstKey) { + if (m_oldConfig2 == m_newConfig && srcGroupPath == dstGroupPath && srcKey == dstKey) { return; // Don't delete! } KConfigGroup srcCg2 = KConfigUtils::openGroup(m_oldConfig2, srcGroupPath); @@ -695,8 +687,7 @@ void KonfUpdate::gotAllGroups() } const QStringList allGroups = m_oldConfig1->groupList(); - for (QStringList::ConstIterator it = allGroups.begin(); - it != allGroups.end(); ++it) { + for (QStringList::ConstIterator it = allGroups.begin(); it != allGroups.end(); ++it) { m_oldGroup = QStringList() << *it; m_newGroup = m_oldGroup; gotAllKeys(); @@ -706,9 +697,7 @@ void KonfUpdate::gotAllGroups() void KonfUpdate::gotOptions(const QString &_options) { const QStringList options = _options.split(QLatin1Char{','}); - for (QStringList::ConstIterator it = options.begin(); - it != options.end(); - ++it) { + for (QStringList::ConstIterator it = options.begin(); it != options.end(); ++it) { if ((*it).toLower().trimmed() == QLatin1String("copy")) { m_bCopy = true; } @@ -719,8 +708,7 @@ void KonfUpdate::gotOptions(const QString &_options) } } -void KonfUpdate::copyGroup(const KConfigBase *cfg1, const QString &group1, - KConfigBase *cfg2, const QString &group2) +void KonfUpdate::copyGroup(const KConfigBase *cfg1, const QString &group1, KConfigBase *cfg2, const QString &group2) { KConfigGroup cg2 = cfg2->group(group2); copyGroup(cfg1->group(group1), cg2); @@ -730,8 +718,7 @@ void KonfUpdate::copyGroup(const KConfigGroup &cg1, KConfigGroup &cg2) { // Copy keys QMap list = cg1.entryMap(); - for (QMap::ConstIterator it = list.constBegin(); - it != list.constEnd(); ++it) { + for (QMap::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it) { if (m_bOverwrite || !cg2.hasKey(it.key())) { cg2.writeEntry(it.key(), it.value()); } @@ -822,7 +809,7 @@ void KonfUpdate::gotScript(const QString &_script) proc.setStandardOutputFile(scriptOut.fileName()); if (m_oldConfig1) { if (m_bDebugOutput) { - //scriptIn.setAutoRemove(false); + // scriptIn.setAutoRemove(false); qCDebug(KCONF_UPDATE_LOG) << "Script input stored in" << scriptIn.fileName(); } KConfig cfg(scriptIn.fileName(), KConfig::SimpleConfig); @@ -830,9 +817,7 @@ void KonfUpdate::gotScript(const QString &_script) if (m_oldGroup.isEmpty()) { // Write all entries to tmpFile; const QStringList grpList = m_oldConfig1->groupList(); - for (QStringList::ConstIterator it = grpList.begin(); - it != grpList.end(); - ++it) { + for (QStringList::ConstIterator it = grpList.begin(); it != grpList.end(); ++it) { copyGroup(m_oldConfig1, *it, &cfg, *it); } } else { @@ -883,7 +868,7 @@ void KonfUpdate::gotScript(const QString &_script) } if (m_bDebugOutput) { - //scriptOut.setAutoRemove(false); + // scriptOut.setAutoRemove(false); qCDebug(KCONF_UPDATE_LOG) << "Script output stored in" << scriptOut.fileName(); QFile output(scriptOut.fileName()); if (output.open(QIODevice::ReadOnly)) { @@ -966,9 +951,15 @@ int main(int argc, char **argv) parser.setApplicationDescription(QCoreApplication::translate("main", "KDE Tool for updating user configuration files")); parser.addHelpOption(); parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("debug"), QCoreApplication::translate("main", "Keep output results from scripts"))); - parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("testmode"), QCoreApplication::translate("main", "For unit tests only: use test directories to stay away from the user's real files"))); - parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("check"), QCoreApplication::translate("main", "Check whether config file itself requires updating"), QStringLiteral("update-file"))); - parser.addPositionalArgument(QStringLiteral("files"), QCoreApplication::translate("main", "File(s) to read update instructions from"), QStringLiteral("[files...]")); + parser.addOption( + QCommandLineOption(QStringList() << QStringLiteral("testmode"), + QCoreApplication::translate("main", "For unit tests only: use test directories to stay away from the user's real files"))); + parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("check"), + QCoreApplication::translate("main", "Check whether config file itself requires updating"), + QStringLiteral("update-file"))); + parser.addPositionalArgument(QStringLiteral("files"), + QCoreApplication::translate("main", "File(s) to read update instructions from"), + QStringLiteral("[files...]")); // TODO aboutData.addAuthor(ki18n("Waldo Bastian"), KLocalizedString(), "bastian@kde.org"); diff --git a/src/kconf_update/kconfigutils.cpp b/src/kconf_update/kconfigutils.cpp index 56e5cba7..49d5ac3c 100644 --- a/src/kconf_update/kconfigutils.cpp +++ b/src/kconf_update/kconfigutils.cpp @@ -13,7 +13,6 @@ namespace KConfigUtils { - bool hasGroup(KConfig *config, const QStringList &lst) { KConfigGroup group = openGroup(config, lst); diff --git a/src/kconf_update/kconfigutils.h b/src/kconf_update/kconfigutils.h index 5b07c4fe..9a74d412 100644 --- a/src/kconf_update/kconfigutils.h +++ b/src/kconf_update/kconfigutils.h @@ -18,7 +18,6 @@ class KConfigGroup; namespace KConfigUtils { - bool hasGroup(KConfig *, const QStringList &); KConfigGroup openGroup(KConfig *, const QStringList &); diff --git a/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp b/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp index 3f308cbb..27a96488 100644 --- a/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp +++ b/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp @@ -13,21 +13,24 @@ #include "KConfigCodeGeneratorBase.h" -#include #include +#include -#include #include +#include #include -KConfigCodeGeneratorBase::KConfigCodeGeneratorBase( - const QString &inputFile, - const QString &baseDir, - const QString &fileName, - const KConfigParameters ¶meters, - ParseResult &parseResult) - : parseResult(parseResult), m_inputFile(inputFile), m_baseDir(baseDir), m_fileName(fileName), m_cfg(parameters) +KConfigCodeGeneratorBase::KConfigCodeGeneratorBase(const QString &inputFile, + const QString &baseDir, + const QString &fileName, + const KConfigParameters ¶meters, + ParseResult &parseResult) + : parseResult(parseResult) + , m_inputFile(inputFile) + , m_baseDir(baseDir) + , m_fileName(fileName) + , m_cfg(parameters) { m_file.setFileName(m_fileName); if (!m_file.open(QIODevice::WriteOnly)) { @@ -54,7 +57,7 @@ void KConfigCodeGeneratorBase::save() m_file.close(); } -//TODO: Remove this weird logic and adapt the testcases +// TODO: Remove this weird logic and adapt the testcases void KConfigCodeGeneratorBase::indent() { if (m_indentLevel >= 4) { @@ -102,7 +105,8 @@ void KConfigCodeGeneratorBase::endScope(ScopeFinalizer finalizer) void KConfigCodeGeneratorBase::start() { const QString m_fileName = QFileInfo(m_inputFile).fileName(); - m_stream << "// This file is generated by kconfig_compiler_kf5 from " << m_fileName << ".kcfg" << ".\n"; + m_stream << "// This file is generated by kconfig_compiler_kf5 from " << m_fileName << ".kcfg" + << ".\n"; m_stream << "// All changes you do to this file will be lost.\n"; } @@ -214,7 +218,6 @@ void KConfigCodeGeneratorBase::createIfSetLogic(const CfgEntry *e, const QString void KConfigCodeGeneratorBase::memberMutatorBody(const CfgEntry *e) { - // HACK: Don't open '{' manually, use startScope / endScope to automatically handle whitespace indentation. if (!e->min.isEmpty()) { if (e->min != QLatin1String("0") || !isUnsigned(e->type)) { // skip writing "if uint<0" (#187579) @@ -254,8 +257,7 @@ void KConfigCodeGeneratorBase::memberMutatorBody(const CfgEntry *e) if (signal.modify) { m_stream << whitespace() << " Q_EMIT " << m_this << signal.name << "();\n"; } else { - m_stream << whitespace() << " " << m_this << varPath(QStringLiteral("settingsChanged"), m_cfg) - << " |= " << signalEnumName(signal.name) << ";\n"; + m_stream << whitespace() << " " << m_this << varPath(QStringLiteral("settingsChanged"), m_cfg) << " |= " << signalEnumName(signal.name) << ";\n"; } } if (hasBody) { diff --git a/src/kconfig_compiler/KConfigCodeGeneratorBase.h b/src/kconfig_compiler/KConfigCodeGeneratorBase.h index e9d2a955..4a100518 100644 --- a/src/kconfig_compiler/KConfigCodeGeneratorBase.h +++ b/src/kconfig_compiler/KConfigCodeGeneratorBase.h @@ -14,28 +14,31 @@ #ifndef KCONFIGCODEGENERATORBASE_H #define KCONFIGCODEGENERATORBASE_H +#include #include #include -#include #include -#include "KConfigParameters.h" #include "KConfigCommonStructs.h" +#include "KConfigParameters.h" class CfgEntry; struct ParseResult; /* This class manages the base of writing a C - Based code */ -class KConfigCodeGeneratorBase { +class KConfigCodeGeneratorBase +{ public: - enum ScopeFinalizer {None, Semicolon,}; - - KConfigCodeGeneratorBase( - const QString &inputFileName, // The kcfg file - const QString &baseDir, // where we should store the generated file - const QString &fileName, // the name of the generated file - const KConfigParameters ¶meters, // parameters passed to the generator - ParseResult &parseResult // The pre processed configuration entries + enum ScopeFinalizer { + None, + Semicolon, + }; + + KConfigCodeGeneratorBase(const QString &inputFileName, // The kcfg file + const QString &baseDir, // where we should store the generated file + const QString &fileName, // the name of the generated file + const KConfigParameters ¶meters, // parameters passed to the generator + ParseResult &parseResult // The pre processed configuration entries ); virtual ~KConfigCodeGeneratorBase(); @@ -87,32 +90,53 @@ class KConfigCodeGeneratorBase { /* reduce the number of spaces for the indentation level */ void unindent(); - QString inputFile() const { return m_inputFile; } - QString fileName() const { return m_fileName; } - QString baseDir() const { return m_baseDir; } - QString This() const { return m_this; } - QString Const() const { return m_const; } - KConfigParameters cfg() const { return m_cfg; } + QString inputFile() const + { + return m_inputFile; + } + QString fileName() const + { + return m_fileName; + } + QString baseDir() const + { + return m_baseDir; + } + QString This() const + { + return m_this; + } + QString Const() const + { + return m_const; + } + KConfigParameters cfg() const + { + return m_cfg; + } // Can't be const. - QTextStream& stream() { return m_stream; } + QTextStream &stream() + { + return m_stream; + } // HACK: This needs to be accesible because the HeaderGenerator actually modifies // it while running. Considering that this is a the result of the xml Parse, and not // the result of generating code, I consider this to be quite wrong - but moving the // changes away from the header generator only created more problems and I have to // investigate more. - ParseResult &parseResult; // the result of the parsed kcfg file + ParseResult &parseResult; // the result of the parsed kcfg file private: QString m_inputFile; // the base file name, input file is based on this. - QString m_baseDir; // Where we are going to save the file - QString m_fileName; // The file name + QString m_baseDir; // Where we are going to save the file + QString m_fileName; // The file name KConfigParameters m_cfg; // The parameters passed via the kcfgc file - QTextStream m_stream; // the stream that operates in the file to write data. - QFile m_file; // The file handler. + QTextStream m_stream; // the stream that operates in the file to write data. + QFile m_file; // The file handler. // Special access to `this->` and `const` thru the code. QString m_this; diff --git a/src/kconfig_compiler/KConfigCommonStructs.h b/src/kconfig_compiler/KConfigCommonStructs.h index 8ed1d22f..43e981cb 100644 --- a/src/kconfig_compiler/KConfigCommonStructs.h +++ b/src/kconfig_compiler/KConfigCommonStructs.h @@ -14,20 +14,18 @@ #ifndef KCONFIGCOMMONSTRUCTS_H #define KCONFIGCOMMONSTRUCTS_H +#include #include #include -#include #include "KConfigParameters.h" -struct Param -{ +struct Param { QString name; QString type; }; -struct Signal -{ +struct Signal { QString name; QString label; QList arguments; @@ -53,9 +51,13 @@ class CfgEntry class Choices { public: - Choices() {} + Choices() + { + } Choices(const QList &d, const QString &n, const QString &p) - : prefix(p), choices(d), mName(n) + : prefix(p) + , choices(d) + , mName(n) { int i = n.indexOf(QLatin1String("::")); if (i >= 0) { @@ -76,6 +78,7 @@ class CfgEntry { return !mExternalQual.isEmpty(); } + private: QString mName; QString mExternalQual; @@ -161,33 +164,18 @@ QString filenameOnly(const QString &path); QString itemDeclaration(const CfgEntry *e, const KConfigParameters &cfg); -QString translatedString( - const KConfigParameters &cfg, - const QString &string, - const QString &context = QString(), - const QString ¶m = QString(), - const QString ¶mValue = QString()); +QString translatedString(const KConfigParameters &cfg, + const QString &string, + const QString &context = QString(), + const QString ¶m = QString(), + const QString ¶mValue = QString()); // TODO: Sanitize those functions. -QString newItem( - const CfgEntry *entry, - const QString &key, - const QString &defaultValue, - const KConfigParameters &cfg, - const QString ¶m = QString()); - -QString newInnerItem( - const CfgEntry *entry, - const QString &key, - const QString &defaultValue, - const KConfigParameters &cfg, - const QString ¶m = QString()); - -QString userTextsFunctions( - const CfgEntry *e, - const KConfigParameters &cfg, - QString itemVarStr = QString(), - const QString &i = QString()); +QString newItem(const CfgEntry *entry, const QString &key, const QString &defaultValue, const KConfigParameters &cfg, const QString ¶m = QString()); + +QString newInnerItem(const CfgEntry *entry, const QString &key, const QString &defaultValue, const KConfigParameters &cfg, const QString ¶m = QString()); + +QString userTextsFunctions(const CfgEntry *e, const KConfigParameters &cfg, QString itemVarStr = QString(), const QString &i = QString()); QString paramString(const QString &s, const CfgEntry *e, int i); QString paramString(const QString &group, const QList ¶meters); diff --git a/src/kconfig_compiler/KConfigHeaderGenerator.cpp b/src/kconfig_compiler/KConfigHeaderGenerator.cpp index 7829ab67..d2c7e6cf 100644 --- a/src/kconfig_compiler/KConfigHeaderGenerator.cpp +++ b/src/kconfig_compiler/KConfigHeaderGenerator.cpp @@ -13,15 +13,11 @@ #include "KConfigHeaderGenerator.h" -#include #include +#include #include -KConfigHeaderGenerator::KConfigHeaderGenerator( - const QString &inputFile, - const QString &baseDir, - const KConfigParameters &cfg, - ParseResult &result) +KConfigHeaderGenerator::KConfigHeaderGenerator(const QString &inputFile, const QString &baseDir, const KConfigParameters &cfg, ParseResult &result) : KConfigCodeGeneratorBase(inputFile, baseDir, baseDir + cfg.baseName + QLatin1Char('.') + cfg.headerExtension, cfg, result) { } @@ -78,9 +74,7 @@ void KConfigHeaderGenerator::doClassDefinition() } // Member variables - if (!cfg().memberVariables.isEmpty() - && cfg().memberVariables != QLatin1String("private") - && cfg().memberVariables != QLatin1String("dpointer")) { + if (!cfg().memberVariables.isEmpty() && cfg().memberVariables != QLatin1String("private") && cfg().memberVariables != QLatin1String("dpointer")) { stream() << " " << cfg().memberVariables << ":\n"; } @@ -212,7 +206,7 @@ void KConfigHeaderGenerator::implementEnums() implementChoiceEnums(entry, choices); implementValueEnums(entry, values); } - stream() << '\n'; + stream() << '\n'; } void KConfigHeaderGenerator::createSignals() @@ -239,19 +233,15 @@ void KConfigHeaderGenerator::createSignals() // a last comma, as it's valid c++. for (int i = 0, end = parseResult.signalList.size(); i < end; i++) { auto signal = parseResult.signalList.at(i); - stream() << whitespace() << " " << signalEnumName(signal.name) << " = 0x" - << Qt::hex - << val; - if (i != end-1) { + stream() << whitespace() << " " << signalEnumName(signal.name) << " = 0x" << Qt::hex << val; + if (i != end - 1) { stream() << ",\n"; } val <<= 1; } stream() << '\n'; - stream() << whitespace() << "};" - << Qt::dec - << "\n\n"; + stream() << whitespace() << "};" << Qt::dec << "\n\n"; stream() << " Q_SIGNALS:"; for (const Signal &signal : qAsConst(parseResult.signalList)) { @@ -364,7 +354,7 @@ void KConfigHeaderGenerator::createForwardDeclarations() } } -void KConfigHeaderGenerator::createProperties(const CfgEntry *entry, const QString& returnType) +void KConfigHeaderGenerator::createProperties(const CfgEntry *entry, const QString &returnType) { if (!cfg().generateProperties) { return; @@ -377,8 +367,8 @@ void KConfigHeaderGenerator::createProperties(const CfgEntry *entry, const QStri stream() << " WRITE " << setFunction(entry->name); stream() << " NOTIFY " << signal; - //If we have the modified signal, we'll also need - //the changed signal as well + // If we have the modified signal, we'll also need + // the changed signal as well Signal s; s.name = signal; s.modify = true; @@ -417,12 +407,10 @@ void KConfigHeaderGenerator::createSetters(const CfgEntry *entry) stream() << whitespace() << "void " << setFunction(entry->name) << "( "; if (!entry->param.isEmpty()) { - stream() <paramType) << " i, "; + stream() << cppType(entry->paramType) << " i, "; } - stream() << (cfg().useEnumTypes && entry->type == QLatin1String("Enum") - ? enumType(entry, cfg().globalEnums) - : param(entry->type)); + stream() << (cfg().useEnumTypes && entry->type == QLatin1String("Enum") ? enumType(entry, cfg().globalEnums) : param(entry->type)); stream() << " v )"; @@ -481,7 +469,7 @@ void KConfigHeaderGenerator::createImmutableGetters(const CfgEntry *entry) stream() << whitespace() << ""; stream() << "bool " << immutableFunction(entry->name) << "("; if (!entry->param.isEmpty()) { - stream() << " " << cppType(entry->paramType)<< " i "; + stream() << " " << cppType(entry->paramType) << " i "; } stream() << ")" << Const(); // function body inline only if not using dpointer @@ -506,11 +494,9 @@ void KConfigHeaderGenerator::createItemAcessors(const CfgEntry *entry, const QSt return; } stream() << whitespace() << "/**\n"; - stream() << whitespace() << " Get Item object corresponding to " << entry->name << "()" - << '\n'; + stream() << whitespace() << " Get Item object corresponding to " << entry->name << "()" << '\n'; stream() << whitespace() << "*/\n"; - stream() << whitespace() << "Item" << itemType(entry->type) << " *" - << getFunction(entry->name) << "Item("; + stream() << whitespace() << "Item" << itemType(entry->type) << " *" << getFunction(entry->name) << "Item("; if (!entry->param.isEmpty()) { stream() << " " << cppType(entry->paramType) << " i "; } @@ -530,7 +516,7 @@ void KConfigHeaderGenerator::createItemAcessors(const CfgEntry *entry, const QSt void KConfigHeaderGenerator::createDefaultValueMember(const CfgEntry *entry) { // Default value Accessor - if (! ((cfg().allDefaultGetters || cfg().defaultGetters.contains(entry->name)) && !entry->defaultValue.isEmpty())) { + if (!((cfg().allDefaultGetters || cfg().defaultGetters.contains(entry->name)) && !entry->defaultValue.isEmpty())) { return; } stream() << whitespace() << "/**\n"; diff --git a/src/kconfig_compiler/KConfigHeaderGenerator.h b/src/kconfig_compiler/KConfigHeaderGenerator.h index b93a47db..4c2e4561 100644 --- a/src/kconfig_compiler/KConfigHeaderGenerator.h +++ b/src/kconfig_compiler/KConfigHeaderGenerator.h @@ -17,23 +17,20 @@ #include "KConfigCodeGeneratorBase.h" #include "KConfigCommonStructs.h" -#include #include +#include class KConfigParameters; class CfgEntry; class QTextStream; struct ParseResult; -class KConfigHeaderGenerator : public KConfigCodeGeneratorBase { +class KConfigHeaderGenerator : public KConfigCodeGeneratorBase +{ public: - KConfigHeaderGenerator( - const QString &inputFile, - const QString &baseDir, - const KConfigParameters ¶meters, - ParseResult &parseResult); + KConfigHeaderGenerator(const QString &inputFile, const QString &baseDir, const KConfigParameters ¶meters, ParseResult &parseResult); - void start() override; + void start() override; private: void startHeaderGuards(); diff --git a/src/kconfig_compiler/KConfigParameters.h b/src/kconfig_compiler/KConfigParameters.h index f8619b2a..153b68dd 100644 --- a/src/kconfig_compiler/KConfigParameters.h +++ b/src/kconfig_compiler/KConfigParameters.h @@ -33,14 +33,14 @@ class KConfigParameters }; // These are read from the .kcfgc configuration file - QString nameSpace; // The namespace for the class to be generated - QString className; // The class name to be generated - QString inherits; // The class the generated class inherits (if empty, from KConfigSkeleton) + QString nameSpace; // The namespace for the class to be generated + QString className; // The class name to be generated + QString inherits; // The class the generated class inherits (if empty, from KConfigSkeleton) QString visibility; bool parentInConstructor; // The class has the optional parent parameter in its constructor bool forceStringFilename; - bool singleton; // The class will be a singleton - bool staticAccessors; // provide or not static accessors + bool singleton; // The class will be a singleton + bool staticAccessors; // provide or not static accessors bool customAddons; QString memberVariables; QStringList headerIncludes; diff --git a/src/kconfig_compiler/KConfigSourceGenerator.cpp b/src/kconfig_compiler/KConfigSourceGenerator.cpp index 663a138f..ce6378cd 100644 --- a/src/kconfig_compiler/KConfigSourceGenerator.cpp +++ b/src/kconfig_compiler/KConfigSourceGenerator.cpp @@ -50,7 +50,7 @@ void KConfigSourceGenerator::createHeaders() // TODO: Make addQuotes return a string instead of replacing it inplace. addQuotes(headerName); - addHeaders({ headerName }); + addHeaders({headerName}); stream() << '\n'; addHeaders(cfg().sourceIncludes); @@ -108,11 +108,10 @@ void KConfigSourceGenerator::createPrivateDPointerImplementation() // Create Items. for (const auto *entry : qAsConst(parseResult.entries)) { - const QString declType = entry->signalList.isEmpty() - ? QString(cfg().inherits + QStringLiteral("::Item") + itemType(entry->type)) - : QStringLiteral("KConfigCompilerSignallingItem"); + const QString declType = entry->signalList.isEmpty() ? QString(cfg().inherits + QStringLiteral("::Item") + itemType(entry->type)) + : QStringLiteral("KConfigCompilerSignallingItem"); - stream() << " " << declType << " *" << itemVar( entry, cfg() ); + stream() << " " << declType << " *" << itemVar(entry, cfg()); if (!entry->param.isEmpty()) { stream() << QStringLiteral("[%1]").arg(entry->paramMax + 1); } @@ -163,7 +162,7 @@ void KConfigSourceGenerator::createSingletonImplementation() stream() << "}\n\n"; if (parseResult.cfgFileNameArg) { - auto instance = [this] (const QString &type, const QString &arg, bool isString) { + auto instance = [this](const QString &type, const QString &arg, bool isString) { stream() << "void " << cfg().className << "::instance(" << type << " " << arg << ")\n"; stream() << "{\n"; stream() << " if (s_global" << cfg().className << "()->q) {\n"; @@ -215,8 +214,7 @@ void KConfigSourceGenerator::createConstructorParameterList() stream() << (parseResult.parameters.isEmpty() ? "" : ","); } - for (QList::ConstIterator it = parseResult.parameters.constBegin(); - it != parseResult.parameters.constEnd(); ++it) { + for (QList::ConstIterator it = parseResult.parameters.constBegin(); it != parseResult.parameters.constEnd(); ++it) { if (it != parseResult.parameters.constBegin()) { stream() << ","; } @@ -229,7 +227,6 @@ void KConfigSourceGenerator::createConstructorParameterList() } stream() << " QObject *parent"; } - } void KConfigSourceGenerator::createParentConstructorCall() @@ -239,7 +236,7 @@ void KConfigSourceGenerator::createParentConstructorCall() stream() << " QStringLiteral( \"" << parseResult.cfgFileName << "\" "; } if (parseResult.cfgFileNameArg) { - if (! cfg().forceStringFilename) { + if (!cfg().forceStringFilename) { stream() << " std::move( config ) "; } else { stream() << " config "; @@ -275,19 +272,13 @@ void KConfigSourceGenerator::createEnums(const CfgEntry *entry) stream() << " choice.name = QStringLiteral(\"" << choice.name << "\");\n"; if (cfg().setUserTexts) { if (!choice.label.isEmpty()) { - stream() << " choice.label = " - << translatedString(cfg(), choice.label, choice.context) - << ";\n"; + stream() << " choice.label = " << translatedString(cfg(), choice.label, choice.context) << ";\n"; } if (!choice.toolTip.isEmpty()) { - stream() << " choice.toolTip = " - << translatedString(cfg(), choice.toolTip, choice.context) - << ";\n"; + stream() << " choice.toolTip = " << translatedString(cfg(), choice.toolTip, choice.context) << ";\n"; } if (!choice.whatsThis.isEmpty()) { - stream() << " choice.whatsThis = " - << translatedString(cfg(), choice.whatsThis, choice.context) - << ";\n"; + stream() << " choice.whatsThis = " << translatedString(cfg(), choice.whatsThis, choice.context) << ";\n"; } } stream() << " values" << entry->name << ".append( choice );\n"; @@ -300,12 +291,10 @@ void KConfigSourceGenerator::createNormalEntry(const CfgEntry *entry, const QStr const QString itemVarStr = itemPath(entry, cfg()); const QString innerItemVarStr = innerItemVar(entry, cfg()); if (!entry->signalList.isEmpty()) { - stream() << " " << innerItemVarStr << " = " - << newInnerItem(entry, key, entry->defaultValue, cfg()) << '\n'; + stream() << " " << innerItemVarStr << " = " << newInnerItem(entry, key, entry->defaultValue, cfg()) << '\n'; } - stream() << " " << itemVarStr << " = " - << newItem(entry, key, entry->defaultValue, cfg()) << '\n'; + stream() << " " << itemVarStr << " = " << newItem(entry, key, entry->defaultValue, cfg()) << '\n'; if (!entry->min.isEmpty()) { stream() << " " << innerItemVarStr << "->setMinValue(" << entry->min << ");\n"; @@ -353,19 +342,17 @@ void KConfigSourceGenerator::createIndexedEntry(const CfgEntry *entry, const QSt const QString argBracket = QStringLiteral("[%1]").arg(i); const QString innerItemVarStr = innerItemVar(entry, cfg()) + argBracket; - const QString defaultStr = !entry->paramDefaultValues[i].isEmpty() - ? entry->paramDefaultValues[i] - : !entry->defaultValue.isEmpty() ? paramString(entry->defaultValue, entry, i) : defaultValue(entry->type); + const QString defaultStr = !entry->paramDefaultValues[i].isEmpty() ? entry->paramDefaultValues[i] + : !entry->defaultValue.isEmpty() ? paramString(entry->defaultValue, entry, i) + : defaultValue(entry->type); if (!entry->signalList.isEmpty()) { - stream() << " " << innerItemVarStr << " = " - << newInnerItem(entry, paramString(key, entry, i), defaultStr, cfg(), argBracket) << '\n'; + stream() << " " << innerItemVarStr << " = " << newInnerItem(entry, paramString(key, entry, i), defaultStr, cfg(), argBracket) << '\n'; } const QString itemVarStr = itemPath(entry, cfg()) + argBracket; - stream() << " " << itemVarStr << " = " - << newItem(entry, paramString(key, entry, i), defaultStr, cfg(), argBracket) << '\n'; + stream() << " " << itemVarStr << " = " << newItem(entry, paramString(key, entry, i), defaultStr, cfg(), argBracket) << '\n'; if (!entry->min.isEmpty()) { stream() << " " << innerItemVarStr << "->setMinValue(" << entry->min << ");\n"; @@ -376,7 +363,8 @@ void KConfigSourceGenerator::createIndexedEntry(const CfgEntry *entry, const QSt for (const CfgEntry::Choice &choice : qAsConst(entry->choices.choices)) { if (!choice.val.isEmpty()) { - stream() << " " << itemVarStr << "->setValueForChoice(QStringLiteral( \"" << choice.name << "\" ), QStringLiteral( \"" << choice.val << "\" ));\n"; + stream() << " " << itemVarStr << "->setValueForChoice(QStringLiteral( \"" << choice.name << "\" ), QStringLiteral( \"" << choice.val + << "\" ));\n"; } } @@ -419,14 +407,12 @@ void KConfigSourceGenerator::handleCurrentGroupChange(const CfgEntry *entry) if (!entry->parentGroup.isEmpty()) { QString parentGroup = QString(entry->parentGroup).remove(QRegularExpression(QStringLiteral("\\W"))); if (!mConfigGroupList.contains(parentGroup)) { - stream() << " KConfigGroup cg" << parentGroup - << "(this->config(), " << paramString(entry->parentGroup, parseResult.parameters) << ");\n"; + stream() << " KConfigGroup cg" << parentGroup << "(this->config(), " << paramString(entry->parentGroup, parseResult.parameters) << ");\n"; mConfigGroupList << parentGroup; } QString currentGroup = QString(mCurrentGroup).remove(QRegularExpression(QStringLiteral("\\W"))); if (!mConfigGroupList.contains(currentGroup)) { - stream() << " KConfigGroup cg" << currentGroup - << " = cg" << QString(entry->parentGroup).remove(QRegularExpression(QStringLiteral("\\W"))) + stream() << " KConfigGroup cg" << currentGroup << " = cg" << QString(entry->parentGroup).remove(QRegularExpression(QStringLiteral("\\W"))) << ".group(" << paramString(mCurrentGroup, parseResult.parameters) << ");\n"; mConfigGroupList << currentGroup; } @@ -470,8 +456,7 @@ void KConfigSourceGenerator::doConstructor() // this cast to base-class pointer-to-member is valid C++ // https://stackoverflow.com/questions/4272909/is-it-safe-to-upcast-a-method-pointer-and-use-it-with-base-class-pointer/ stream() << " KConfigCompilerSignallingItem::NotifyFunction notifyFunction =" - << " static_cast(&" - << cfg().className << "::itemChanged);\n"; + << " static_cast(&" << cfg().className << "::itemChanged);\n"; stream() << '\n'; } @@ -524,7 +509,8 @@ void KConfigSourceGenerator::createGetterDPointerMode(const CfgEntry *entry) void KConfigSourceGenerator::createImmutableGetterDPointerMode(const CfgEntry *entry) { stream() << whitespace() << ""; - stream() << "bool " << " " << immutableFunction(entry->name, cfg().className) << "("; + stream() << "bool " + << " " << immutableFunction(entry->name, cfg().className) << "("; if (!entry->param.isEmpty()) { stream() << " " << cppType(entry->paramType) << " i "; } @@ -569,8 +555,7 @@ void KConfigSourceGenerator::createItemGetterDPointerMode(const CfgEntry *entry) return; } stream() << '\n'; - stream() << cfg().inherits << "::Item" << itemType(entry->type) << " *" - << getFunction(entry->name, cfg().className) << "Item("; + stream() << cfg().inherits << "::Item" << itemType(entry->type) << " *" << getFunction(entry->name, cfg().className) << "Item("; if (!entry->param.isEmpty()) { stream() << " " << cppType(entry->paramType) << " i "; } @@ -637,7 +622,8 @@ void KConfigSourceGenerator::createNonModifyingSignalsHelper() if (!parseResult.hasNonModifySignals) { return; } - stream() << "bool " << cfg().className << "::" << "usrSave()\n"; + stream() << "bool " << cfg().className << "::" + << "usrSave()\n"; startScope(); stream() << " const bool res = " << cfg().inherits << "::usrSave();\n"; stream() << " if (!res) return false;\n\n"; @@ -685,7 +671,8 @@ void KConfigSourceGenerator::createSignalFlagsHandler() } stream() << '\n'; - stream() << "void " << cfg().className << "::" << "itemChanged(quint64 flags) {\n"; + stream() << "void " << cfg().className << "::" + << "itemChanged(quint64 flags) {\n"; if (parseResult.hasNonModifySignals) stream() << " " << varPath(QStringLiteral("settingsChanged"), cfg()) << " |= flags;\n"; @@ -703,7 +690,8 @@ void KConfigSourceGenerator::createSignalFlagsHandler() stream() << "}\n"; } -void KConfigSourceGenerator::includeMoc() { +void KConfigSourceGenerator::includeMoc() +{ const QString mocFileName = cfg().baseName + QStringLiteral(".moc"); if (parseResult.signalList.count() || cfg().generateProperties) { diff --git a/src/kconfig_compiler/KConfigSourceGenerator.h b/src/kconfig_compiler/KConfigSourceGenerator.h index db2c8e72..4b3ef96c 100644 --- a/src/kconfig_compiler/KConfigSourceGenerator.h +++ b/src/kconfig_compiler/KConfigSourceGenerator.h @@ -17,21 +17,18 @@ #include "KConfigCodeGeneratorBase.h" #include "KConfigCommonStructs.h" -#include #include +#include class KConfigParameters; class CfgEntry; class QTextStream; struct ParseResult; -class KConfigSourceGenerator : public KConfigCodeGeneratorBase { +class KConfigSourceGenerator : public KConfigCodeGeneratorBase +{ public: - KConfigSourceGenerator( - const QString &inputFile, - const QString &baseDir, - const KConfigParameters ¶meters, - ParseResult &parseResult); + KConfigSourceGenerator(const QString &inputFile, const QString &baseDir, const KConfigParameters ¶meters, ParseResult &parseResult); void start() override; diff --git a/src/kconfig_compiler/KConfigXmlParser.cpp b/src/kconfig_compiler/KConfigXmlParser.cpp index e1010564..97d61342 100644 --- a/src/kconfig_compiler/KConfigXmlParser.cpp +++ b/src/kconfig_compiler/KConfigXmlParser.cpp @@ -21,13 +21,15 @@ #include #include #include -//TODO: Move preprocessDefault to Header / CPP implementation. +// TODO: Move preprocessDefault to Header / CPP implementation. // it makes no sense for a parser to process those values and generate code. -static void preProcessDefault(QString &defaultValue, const QString &name, +static void preProcessDefault(QString &defaultValue, + const QString &name, const QString &type, const CfgEntry::Choices &choices, - QString &code, const KConfigParameters &cfg) + QString &code, + const KConfigParameters &cfg) { if (type == QLatin1String("String") && !defaultValue.isEmpty()) { defaultValue = literalString(defaultValue); @@ -64,8 +66,7 @@ static void preProcessDefault(QString &defaultValue, const QString &name, defaultValue = QLatin1String("default") + name; } else if (type == QLatin1String("Color") && !defaultValue.isEmpty()) { - const QRegularExpression colorRe(QRegularExpression::anchoredPattern( - QStringLiteral("\\d+,\\s*\\d+,\\s*\\d+(,\\s*\\d+)?"))); + const QRegularExpression colorRe(QRegularExpression::anchoredPattern(QStringLiteral("\\d+,\\s*\\d+,\\s*\\d+(,\\s*\\d+)?"))); if (colorRe.match(defaultValue).hasMatch()) { defaultValue = QLatin1String("QColor( ") + defaultValue + QLatin1String(" )"); @@ -124,7 +125,7 @@ void KConfigXmlParser::readParameterFromEntry(CfgEntry &readEntry, const QDomEle if (readEntry.param.isEmpty()) { std::cerr << "Parameter must have a name: " << qPrintable(dumpNode(e)) << std::endl; - exit (1); + exit(1); } if (readEntry.paramType.isEmpty()) { @@ -157,7 +158,7 @@ void KConfigXmlParser::readParameterFromEntry(CfgEntry &readEntry, const QDomEle readEntry.paramMax = readEntry.paramValues.count() - 1; } else { std::cerr << "Parameter '" << qPrintable(readEntry.param) << "' has type " << qPrintable(readEntry.paramType) - << " but must be of type int, uint or Enum." << std::endl; + << " but must be of type int, uint or Enum." << std::endl; exit(1); } } @@ -190,7 +191,8 @@ void KConfigXmlParser::readChoicesFromEntry(CfgEntry &readEntry, const QDomEleme if (choice.name.isEmpty()) { std::cerr << "Tag requires attribute 'name'." << std::endl; } else if (!choiceNameRegex.match(choice.name).hasMatch()) { - std::cerr << "Tag attribute 'name' must be compatible with Enum naming. name was '" << qPrintable(choice.name) << "'. You can use attribute 'value' to pass any string as the choice value." << std::endl; + std::cerr << "Tag attribute 'name' must be compatible with Enum naming. name was '" << qPrintable(choice.name) + << "'. You can use attribute 'value' to pass any string as the choice value." << std::endl; } choice.val = e2.attribute(QStringLiteral("value")); for (QDomElement e3 = e2.firstChildElement(); !e3.isNull(); e3 = e3.nextSiblingElement()) { @@ -266,7 +268,7 @@ void KConfigXmlParser::validateNameAndKey(CfgEntry &readEntry, const QDomElement bool nameIsEmpty = readEntry.name.isEmpty(); if (nameIsEmpty && readEntry.key.isEmpty()) { std::cerr << "Entry must have a name or a key: " << qPrintable(dumpNode(element)) << std::endl; - exit (1); + exit(1); } if (readEntry.key.isEmpty()) { @@ -284,12 +286,12 @@ void KConfigXmlParser::validateNameAndKey(CfgEntry &readEntry, const QDomElement if (readEntry.name.contains(QStringLiteral("$("))) { if (readEntry.param.isEmpty()) { std::cerr << "Name may not be parameterized: " << qPrintable(readEntry.name) << std::endl; - exit (1); + exit(1); } } else { if (!readEntry.param.isEmpty()) { std::cerr << "Name must contain '$(" << qPrintable(readEntry.param) << ")': " << qPrintable(readEntry.name) << std::endl; - exit (1); + exit(1); } } } @@ -324,13 +326,13 @@ void KConfigXmlParser::readParamDefaultValues(CfgEntry &readEntry, const QDomEle i = readEntry.paramValues.indexOf(index); if (i == -1) { std::cerr << "Index '" << qPrintable(index) << "' for default value is unknown." << std::endl; - exit (1); + exit(1); } } if ((i < 0) || (i > readEntry.paramMax)) { std::cerr << "Index '" << i << "' for default value is out of range [0, " << readEntry.paramMax << "]." << std::endl; - exit (1); + exit(1); } QString tmpDefaultValue = e.text(); @@ -349,7 +351,8 @@ CfgEntry *KConfigXmlParser::parseEntry(const QString &group, const QString &pare readEntry.type = element.attribute(QStringLiteral("type")); readEntry.name = element.attribute(QStringLiteral("name")); readEntry.key = element.attribute(QStringLiteral("key")); - readEntry.hidden = element.attribute(QStringLiteral("hidden")) == QLatin1String("true");; + readEntry.hidden = element.attribute(QStringLiteral("hidden")) == QLatin1String("true"); + ; readEntry.group = group; readEntry.parentGroup = parentGroup; @@ -364,29 +367,33 @@ CfgEntry *KConfigXmlParser::parseEntry(const QString &group, const QString &pare } if (readEntry.type.isEmpty()) { - readEntry.type = QStringLiteral("String"); // XXX : implicit type might be bad + readEntry.type = QStringLiteral("String"); // XXX : implicit type might be bad } readParamDefaultValues(readEntry, element); if (!mValidNameRegexp.match(readEntry.name).hasMatch()) { if (nameIsEmpty) - std::cerr << "The key '" << qPrintable(readEntry.key) << "' can not be used as name for the entry because " - "it is not a valid name. You need to specify a valid name for this entry." << std::endl; + std::cerr << "The key '" << qPrintable(readEntry.key) + << "' can not be used as name for the entry because " + "it is not a valid name. You need to specify a valid name for this entry." + << std::endl; else { std::cerr << "The name '" << qPrintable(readEntry.name) << "' is not a valid name for an entry." << std::endl; } - exit (1); + exit(1); } if (mAllNames.contains(readEntry.name)) { if (nameIsEmpty) - std::cerr << "The key '" << qPrintable(readEntry.key) << "' can not be used as name for the entry because " - "it does not result in a unique name. You need to specify a unique name for this entry." << std::endl; + std::cerr << "The key '" << qPrintable(readEntry.key) + << "' can not be used as name for the entry because " + "it does not result in a unique name. You need to specify a unique name for this entry." + << std::endl; else { std::cerr << "The name '" << qPrintable(readEntry.name) << "' is not unique." << std::endl; } - exit (1); + exit(1); } mAllNames.append(readEntry.name); @@ -433,7 +440,8 @@ CfgEntry *KConfigXmlParser::parseEntry(const QString &group, const QString &pare // TODO: Change the name of the config variable. KConfigXmlParser::KConfigXmlParser(const KConfigParameters &cfg, const QString &inputFileName) - : cfg(cfg), mInputFileName(inputFileName) + : cfg(cfg) + , mInputFileName(inputFileName) { mValidNameRegexp.setPattern(QRegularExpression::anchoredPattern(QStringLiteral("[a-zA-Z_][a-zA-Z0-9_]*"))); } @@ -447,14 +455,15 @@ void KConfigXmlParser::start() int errorCol; if (!doc.setContent(&input, &errorMsg, &errorRow, &errorCol)) { std::cerr << "Unable to load document." << std::endl; - std::cerr << "Parse error in " << qPrintable(mInputFileName) << ", line " << errorRow << ", col " << errorCol << ": " << qPrintable(errorMsg) << std::endl; - exit (1); + std::cerr << "Parse error in " << qPrintable(mInputFileName) << ", line " << errorRow << ", col " << errorCol << ": " << qPrintable(errorMsg) + << std::endl; + exit(1); } QDomElement cfgElement = doc.documentElement(); if (cfgElement.isNull()) { std::cerr << "No document in kcfg file" << std::endl; - exit (1); + exit(1); } for (QDomElement element = cfgElement.firstChildElement(); !element.isNull(); element = element.nextSiblingElement()) { @@ -490,7 +499,7 @@ void KConfigXmlParser::readGroupTag(const QDomElement &e) QString group = e.attribute(QStringLiteral("name")); if (group.isEmpty()) { std::cerr << "Group without name" << std::endl; - exit (1); + exit(1); } const QString parentGroup = e.attribute(QStringLiteral("parentGroupName")); @@ -504,7 +513,7 @@ void KConfigXmlParser::readGroupTag(const QDomElement &e) mParseResult.entries.append(entry); } else { std::cerr << "Can not parse entry." << std::endl; - exit (1); + exit(1); } } } @@ -531,7 +540,7 @@ void KConfigXmlParser::readSignalTag(const QDomElement &e) QString signalName = e.attribute(QStringLiteral("name")); if (signalName.isEmpty()) { std::cerr << "Signal without name." << std::endl; - exit (1); + exit(1); } Signal theSignal; theSignal.name = signalName; @@ -542,9 +551,9 @@ void KConfigXmlParser::readSignalTag(const QDomElement &e) argument.type = e2.attribute(QStringLiteral("type")); if (argument.type.isEmpty()) { std::cerr << "Signal argument without type." << std::endl; - exit (1); + exit(1); } - argument.name= e2.text(); + argument.name = e2.text(); theSignal.arguments.append(argument); } else if (e2.tagName() == QLatin1String("label")) { theSignal.label = e2.text(); diff --git a/src/kconfig_compiler/KConfigXmlParser.h b/src/kconfig_compiler/KConfigXmlParser.h index 742cb496..58c2ed58 100644 --- a/src/kconfig_compiler/KConfigXmlParser.h +++ b/src/kconfig_compiler/KConfigXmlParser.h @@ -15,8 +15,8 @@ #define KCONFIGXMLPARSER_H #include -#include #include +#include #include "KConfigCommonStructs.h" #include "KConfigParameters.h" diff --git a/src/kconfig_compiler/kconfig_compiler.cpp b/src/kconfig_compiler/kconfig_compiler.cpp index dd7b793c..449d437a 100644 --- a/src/kconfig_compiler/kconfig_compiler.cpp +++ b/src/kconfig_compiler/kconfig_compiler.cpp @@ -10,26 +10,26 @@ SPDX-License-Identifier: LGPL-2.0-or-later */ +#include +#include #include +#include #include #include -#include -#include -#include #include +#include #include -#include -#include +#include -#include +#include #include +#include #include -#include #include "../../kconfig_version.h" -#include "KConfigParameters.h" #include "KConfigCommonStructs.h" #include "KConfigHeaderGenerator.h" +#include "KConfigParameters.h" #include "KConfigSourceGenerator.h" #include "KConfigXmlParser.h" @@ -114,12 +114,12 @@ QString setFunction(const QString &n, const QString &className) QString changeSignalName(const QString &n) { - return n+QStringLiteral("Changed"); + return n + QStringLiteral("Changed"); } QString getDefaultFunction(const QString &n, const QString &className) { - QString result = QLatin1String("default") + n + QLatin1String("Value"); + QString result = QLatin1String("default") + n + QLatin1String("Value"); result[7] = result.at(7).toUpper(); if (!className.isEmpty()) { @@ -173,7 +173,9 @@ static QString quoteString(const QString &s) QString literalString(const QString &str) { - const bool isAscii = std::none_of(str.cbegin(), str.cend(), [](const QChar ch) { return ch.unicode() > 127; }); + const bool isAscii = std::none_of(str.cbegin(), str.cend(), [](const QChar ch) { + return ch.unicode() > 127; + }); if (isAscii) { return QLatin1String{"QStringLiteral( "} + quoteString(str) + QLatin1String{" )"}; @@ -246,7 +248,7 @@ QString param(const QString &t) return QStringLiteral("const QList &"); } else { std::cerr << "kconfig_compiler_kf5 does not support type \"" << qPrintable(type) << "\"" << std::endl; - return QStringLiteral("QString"); //For now, but an assert would be better + return QStringLiteral("QString"); // For now, but an assert would be better } } @@ -300,7 +302,7 @@ QString cppType(const QString &t) return QStringLiteral("QList"); } else { std::cerr << "kconfig_compiler_kf5 does not support type \"" << qPrintable(type) << "\"" << std::endl; - return QStringLiteral("QString"); //For now, but an assert would be better + return QStringLiteral("QString"); // For now, but an assert would be better } } @@ -308,7 +310,7 @@ QString defaultValue(const QString &t) { const QString type = t.toLower(); if (type == QLatin1String("string")) { - return QStringLiteral("\"\""); // Use empty string, not null string! + return QStringLiteral("\"\""); // Use empty string, not null string! } else if (type == QLatin1String("stringlist")) { return QStringLiteral("QStringList()"); } else if (type == QLatin1String("font")) { @@ -340,18 +342,18 @@ QString defaultValue(const QString &t) } else if (type == QLatin1String("enum")) { return QStringLiteral("0"); } else if (type == QLatin1String("path")) { - return QStringLiteral("\"\""); // Use empty string, not null string! + return QStringLiteral("\"\""); // Use empty string, not null string! } else if (type == QLatin1String("pathlist")) { return QStringLiteral("QStringList()"); } else if (type == QLatin1String("password")) { - return QStringLiteral("\"\""); // Use empty string, not null string! + return QStringLiteral("\"\""); // Use empty string, not null string! } else if (type == QLatin1String("url")) { return QStringLiteral("QUrl()"); } else if (type == QLatin1String("urllist")) { return QStringLiteral("QList()"); } else { std::cerr << "Error, kconfig_compiler_kf5 does not support the \"" << qPrintable(type) << "\" type!" << std::endl; - return QStringLiteral("QString"); //For now, but an assert would be better + return QStringLiteral("QString"); // For now, but an assert would be better } } @@ -381,8 +383,8 @@ QString itemDeclaration(const CfgEntry *e, const KConfigParameters &cfg) QString result; if (!cfg.itemAccessors && !cfg.dpointer) { - result += QLatin1String{" "} + (!e->signalList.isEmpty() ? QStringLiteral("KConfigCompilerSignallingItem") : type) - + QLatin1String{" *item"} + fCap + argSuffix + QLatin1String{";\n"}; + result += QLatin1String{" "} + (!e->signalList.isEmpty() ? QStringLiteral("KConfigCompilerSignallingItem") : type) + QLatin1String{" *item"} + fCap + + argSuffix + QLatin1String{";\n"}; } if (!e->signalList.isEmpty()) { @@ -434,8 +436,8 @@ QString itemPath(const CfgEntry *e, const KConfigParameters &cfg) QString newInnerItem(const CfgEntry *entry, const QString &key, const QString &defaultValue, const KConfigParameters &cfg, const QString ¶m) { - QString t = QLatin1String{"new "} + cfg.inherits + QLatin1String{"::Item"} + itemType(entry->type) - + QLatin1String{"( currentGroup(), "} + key + QLatin1String{", "} + varPath( entry->name, cfg ) + param; + QString t = QLatin1String{"new "} + cfg.inherits + QLatin1String{"::Item"} + itemType(entry->type) + QLatin1String{"( currentGroup(), "} + key + + QLatin1String{", "} + varPath(entry->name, cfg) + param; if (entry->type == QLatin1String("Enum")) { t += QLatin1String{", values"} + entry->name; @@ -523,8 +525,7 @@ QString translatedString(const KConfigParameters &cfg, const QString &string, co case KConfigParameters::KdeTranslation: if (!cfg.translationDomain.isEmpty() && !context.isEmpty()) { - result += QLatin1String{"i18ndc("} + quoteString(cfg.translationDomain) + QLatin1String{", "} - + quoteString(context) + QLatin1String{", "}; + result += QLatin1String{"i18ndc("} + quoteString(cfg.translationDomain) + QLatin1String{", "} + quoteString(context) + QLatin1String{", "}; } else if (!cfg.translationDomain.isEmpty()) { result += QLatin1String{"i18nd("} + quoteString(cfg.translationDomain) + QLatin1String{", "}; } else if (!context.isEmpty()) { @@ -573,21 +574,19 @@ QString userTextsFunctions(const CfgEntry *e, const KConfigParameters &cfg, QStr return txt; } - // returns the member mutator implementation // which should go in the h file if inline // or the cpp file if not inline -//TODO: Fix add Debug Method, it should also take the debug string. +// TODO: Fix add Debug Method, it should also take the debug string. void addDebugMethod(QTextStream &out, const KConfigParameters &cfg, const QString &n) { if (cfg.qCategoryLoggingName.isEmpty()) { - out << " qDebug() << \"" << setFunction(n); + out << " qDebug() << \"" << setFunction(n); } else { - out << " qCDebug(" << cfg.qCategoryLoggingName << ") << \"" << setFunction(n); + out << " qCDebug(" << cfg.qCategoryLoggingName << ") << \"" << setFunction(n); } } - // returns the member get default implementation // which should go in the h file if inline // or the cpp file if not inline @@ -633,7 +632,7 @@ QString itemAccessorBody(const CfgEntry *e, const KConfigParameters &cfg) return result; } -//indents text adding X spaces per line +// indents text adding X spaces per line QString indent(QString text, int spaces) { QString result; @@ -651,7 +650,7 @@ QString indent(QString text, int spaces) return result; } -bool hasErrors(KConfigXmlParser &parser, const ParseResult& parseResult, const KConfigParameters &cfg) +bool hasErrors(KConfigXmlParser &parser, const ParseResult &parseResult, const KConfigParameters &cfg) { Q_UNUSED(parser) @@ -671,18 +670,18 @@ bool hasErrors(KConfigXmlParser &parser, const ParseResult& parseResult, const K } /* TODO: For some reason some configuration files prefer to have *no* entries - * at all in it, and the generated code is mostly bogus as KConfigXT will not - * handle save / load / properties, etc, nothing. - * - * The first of those files that I came across are qmakebuilderconfig.kcfg from the KDevelop - * project. - * I think we should remove the possibility of creating configuration classes from configuration - * files that don't really have configuration in it. but I'm changing this right now to allow - * kdevelop files to pass. - * - * Remove for KDE 6 - * (to make things more interesting, it failed in a code that's never used within KDevelop... ) - */ + * at all in it, and the generated code is mostly bogus as KConfigXT will not + * handle save / load / properties, etc, nothing. + * + * The first of those files that I came across are qmakebuilderconfig.kcfg from the KDevelop + * project. + * I think we should remove the possibility of creating configuration classes from configuration + * files that don't really have configuration in it. but I'm changing this right now to allow + * kdevelop files to pass. + * + * Remove for KDE 6 + * (to make things more interesting, it failed in a code that's never used within KDevelop... ) + */ if (parseResult.entries.isEmpty()) { std::cerr << "No entries." << std::endl; return false; @@ -699,13 +698,13 @@ int main(int argc, char **argv) QString inputFilename, codegenFilename; - QCommandLineOption targetDirectoryOption(QStringList { QStringLiteral("d"), QStringLiteral("directory") }, - QCoreApplication::translate("main", "Directory to generate files in [.]"), - QCoreApplication::translate("main", "directory"), QStringLiteral(".")); + QCommandLineOption targetDirectoryOption(QStringList{QStringLiteral("d"), QStringLiteral("directory")}, + QCoreApplication::translate("main", "Directory to generate files in [.]"), + QCoreApplication::translate("main", "directory"), + QStringLiteral(".")); - QCommandLineOption licenseOption ( - QStringList { QStringLiteral("l"), QStringLiteral("license") }, - QCoreApplication::translate("main", "Display software license.")); + QCommandLineOption licenseOption(QStringList{QStringLiteral("l"), QStringLiteral("license")}, + QCoreApplication::translate("main", "Display software license.")); QCommandLineParser parser; @@ -713,7 +712,7 @@ int main(int argc, char **argv) parser.addPositionalArgument(QStringLiteral("file.kcfgc"), QStringLiteral("Code generation options file")); parser.addOption(targetDirectoryOption); - parser.addOption (licenseOption); + parser.addOption(licenseOption); parser.addVersionOption(); parser.addHelpOption(); @@ -732,7 +731,7 @@ int main(int argc, char **argv) const QStringList args = parser.positionalArguments(); if (args.count() < 2) { std::cerr << "Too few arguments." << std::endl; - return 1; + return 1; } if (args.count() > 2) { diff --git a/src/kreadconfig/kreadconfig.cpp b/src/kreadconfig/kreadconfig.cpp index 3d26c3b8..444f3bde 100644 --- a/src/kreadconfig/kreadconfig.cpp +++ b/src/kreadconfig/kreadconfig.cpp @@ -38,64 +38,66 @@ int main(int argc, char **argv) { - QCoreApplication app(argc, argv); + QCoreApplication app(argc, argv); - QCommandLineParser parser; - parser.addOption(QCommandLineOption(QStringLiteral("file"), QCoreApplication::translate("main", "Use instead of global config"), QStringLiteral("file"))); - parser.addOption(QCommandLineOption(QStringLiteral("group"), QCoreApplication::translate("main", "Group to look in. Use repeatedly for nested groups."), QStringLiteral("group"), QStringLiteral("KDE"))); + QCommandLineParser parser; + parser.addOption( + QCommandLineOption(QStringLiteral("file"), QCoreApplication::translate("main", "Use instead of global config"), QStringLiteral("file"))); + parser.addOption(QCommandLineOption(QStringLiteral("group"), + QCoreApplication::translate("main", "Group to look in. Use repeatedly for nested groups."), + QStringLiteral("group"), + QStringLiteral("KDE"))); parser.addOption(QCommandLineOption(QStringLiteral("key"), QCoreApplication::translate("main", "Key to look for"), QStringLiteral("key"))); parser.addOption(QCommandLineOption(QStringLiteral("default"), QCoreApplication::translate("main", "Default value"), QStringLiteral("value"))); parser.addOption(QCommandLineOption(QStringLiteral("type"), QCoreApplication::translate("main", "Type of variable"), QStringLiteral("type"))); - parser.process(app); + parser.process(app); - const QStringList groups=parser.values(QStringLiteral("group")); - QString key=parser.value(QStringLiteral("key")); - QString file=parser.value(QStringLiteral("file")); - QString dflt=parser.value(QStringLiteral("default")); - QString type=parser.value(QStringLiteral("type")).toLower(); + const QStringList groups = parser.values(QStringLiteral("group")); + QString key = parser.value(QStringLiteral("key")); + QString file = parser.value(QStringLiteral("file")); + QString dflt = parser.value(QStringLiteral("default")); + QString type = parser.value(QStringLiteral("type")).toLower(); if (key.isNull() || !parser.positionalArguments().isEmpty()) { - parser.showHelp(1); - } + parser.showHelp(1); + } - KSharedConfig::openConfig(); + KSharedConfig::openConfig(); - KConfig *konfig; - bool configMustDeleted = false; - if (file.isEmpty()) - konfig = KSharedConfig::openConfig().data(); - else - { - konfig = new KConfig( file, KConfig::NoGlobals ); - configMustDeleted=true; - } - KConfigGroup cfgGroup = konfig->group(QString()); + KConfig *konfig; + bool configMustDeleted = false; + if (file.isEmpty()) + konfig = KSharedConfig::openConfig().data(); + else { + konfig = new KConfig(file, KConfig::NoGlobals); + configMustDeleted = true; + } + KConfigGroup cfgGroup = konfig->group(QString()); for (const QString &grp : groups) - cfgGroup = cfgGroup.group(grp); - if(type==QStringLiteral("bool")) { - dflt=dflt.toLower(); - bool def=(dflt==QStringLiteral("true") || dflt==QStringLiteral("on") || dflt==QStringLiteral("yes") || dflt==QStringLiteral("1")); - bool retValue = !cfgGroup.readEntry(key, def); - if ( configMustDeleted ) - delete konfig; - return retValue; - } else if((type==QStringLiteral("num")) || (type==QStringLiteral("int"))) { - int retValue = cfgGroup.readEntry(key, dflt.toInt()); - if ( configMustDeleted ) - delete konfig; - return retValue; - } else if (type==QStringLiteral("path")){ - fprintf(stdout, "%s\n", cfgGroup.readPathEntry(key, dflt).toLocal8Bit().data()); - if ( configMustDeleted ) - delete konfig; - return 0; - } else { - /* Assume it's a string... */ - fprintf(stdout, "%s\n", cfgGroup.readEntry(key, dflt).toLocal8Bit().data()); - if ( configMustDeleted ) - delete konfig; - return 0; - } + cfgGroup = cfgGroup.group(grp); + if (type == QStringLiteral("bool")) { + dflt = dflt.toLower(); + bool def = (dflt == QStringLiteral("true") || dflt == QStringLiteral("on") || dflt == QStringLiteral("yes") || dflt == QStringLiteral("1")); + bool retValue = !cfgGroup.readEntry(key, def); + if (configMustDeleted) + delete konfig; + return retValue; + } else if ((type == QStringLiteral("num")) || (type == QStringLiteral("int"))) { + int retValue = cfgGroup.readEntry(key, dflt.toInt()); + if (configMustDeleted) + delete konfig; + return retValue; + } else if (type == QStringLiteral("path")) { + fprintf(stdout, "%s\n", cfgGroup.readPathEntry(key, dflt).toLocal8Bit().data()); + if (configMustDeleted) + delete konfig; + return 0; + } else { + /* Assume it's a string... */ + fprintf(stdout, "%s\n", cfgGroup.readEntry(key, dflt).toLocal8Bit().data()); + if (configMustDeleted) + delete konfig; + return 0; + } } - diff --git a/src/kreadconfig/kwriteconfig.cpp b/src/kreadconfig/kwriteconfig.cpp index 8befa56d..ba16ec68 100644 --- a/src/kreadconfig/kwriteconfig.cpp +++ b/src/kreadconfig/kwriteconfig.cpp @@ -11,9 +11,9 @@ #include #include -#include -#include #include +#include +#include int main(int argc, char **argv) { @@ -21,20 +21,27 @@ int main(int argc, char **argv) QCommandLineParser parser; parser.addHelpOption(); - parser.addOption(QCommandLineOption(QStringLiteral("file"), QCoreApplication::translate("main", "Use instead of global config"), QStringLiteral("file"))); - parser.addOption(QCommandLineOption(QStringLiteral("group"), QCoreApplication::translate("main", "Group to look in. Use repeatedly for nested groups."), QStringLiteral("group"), QStringLiteral("KDE"))); + parser.addOption( + QCommandLineOption(QStringLiteral("file"), QCoreApplication::translate("main", "Use instead of global config"), QStringLiteral("file"))); + parser.addOption(QCommandLineOption(QStringLiteral("group"), + QCoreApplication::translate("main", "Group to look in. Use repeatedly for nested groups."), + QStringLiteral("group"), + QStringLiteral("KDE"))); parser.addOption(QCommandLineOption(QStringLiteral("key"), QCoreApplication::translate("main", "Key to look for"), QStringLiteral("key"))); - parser.addOption(QCommandLineOption(QStringLiteral("type"), QCoreApplication::translate("main", "Type of variable. Use \"bool\" for a boolean, otherwise it is treated as a string"), QStringLiteral("type"))); + parser.addOption( + QCommandLineOption(QStringLiteral("type"), + QCoreApplication::translate("main", "Type of variable. Use \"bool\" for a boolean, otherwise it is treated as a string"), + QStringLiteral("type"))); parser.addOption(QCommandLineOption(QStringLiteral("delete"), QCoreApplication::translate("main", "Delete the designated key if enabled"))); - parser.addPositionalArgument(QStringLiteral("value"), QCoreApplication::translate("main", "The value to write. Mandatory, on a shell use '' for empty" )); + parser.addPositionalArgument(QStringLiteral("value"), QCoreApplication::translate("main", "The value to write. Mandatory, on a shell use '' for empty")); parser.process(app); - const QStringList groups=parser.values(QStringLiteral("group")); - QString key=parser.value(QStringLiteral("key")); - QString file=parser.value(QStringLiteral("file")); - QString type=parser.value(QStringLiteral("type")).toLower(); - bool del=parser.isSet(QStringLiteral("delete")); + const QStringList groups = parser.values(QStringLiteral("group")); + QString key = parser.value(QStringLiteral("key")); + QString file = parser.value(QStringLiteral("file")); + QString type = parser.value(QStringLiteral("type")).toLower(); + bool del = parser.isSet(QStringLiteral("delete")); QString value; if (del) { @@ -47,28 +54,28 @@ int main(int argc, char **argv) KConfig *konfig; if (file.isEmpty()) - konfig = new KConfig(QStringLiteral( "kdeglobals"), KConfig::NoGlobals ); + konfig = new KConfig(QStringLiteral("kdeglobals"), KConfig::NoGlobals); else - konfig = new KConfig( file, KConfig::NoGlobals ); + konfig = new KConfig(file, KConfig::NoGlobals); KConfigGroup cfgGroup = konfig->group(QString()); for (const QString &grp : groups) cfgGroup = cfgGroup.group(grp); - if ( konfig->accessMode() != KConfig::ReadWrite || cfgGroup.isEntryImmutable( key ) ) return 2; + if (konfig->accessMode() != KConfig::ReadWrite || cfgGroup.isEntryImmutable(key)) + return 2; if (del) { - cfgGroup.deleteEntry( key ); - } else if (type==QStringLiteral("bool")) { + cfgGroup.deleteEntry(key); + } else if (type == QStringLiteral("bool")) { // For symmetry with kreadconfig we accept a wider range of values as true than Qt - bool boolvalue=(value==QStringLiteral("true") || value==QStringLiteral("on") || value==QStringLiteral("yes") || value==QStringLiteral("1")); - cfgGroup.writeEntry( key, boolvalue ); - } else if (type==QStringLiteral("path")) { - cfgGroup.writePathEntry( key, value ); + bool boolvalue = (value == QStringLiteral("true") || value == QStringLiteral("on") || value == QStringLiteral("yes") || value == QStringLiteral("1")); + cfgGroup.writeEntry(key, boolvalue); + } else if (type == QStringLiteral("path")) { + cfgGroup.writePathEntry(key, value); } else { - cfgGroup.writeEntry( key, value ); + cfgGroup.writeEntry(key, value); } konfig->sync(); delete konfig; return 0; } - From 48c132be8aa983165126b0641a083848dd5c6620 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Mon, 22 Feb 2021 19:25:40 +0200 Subject: [PATCH 116/259] Fix formatting in a couple of places after running clang-format NO_CHANGELOG --- src/core/kauthorized.cpp | 17 ++++++++++++----- src/core/kconfig.cpp | 7 +++---- src/core/kconfigdata.h | 8 +++++++- src/core/kconfigini.cpp | 6 +++++- src/gui/kconfiggroupgui.cpp | 7 +++++-- src/kconf_update/kconf_update.cpp | 4 +++- src/kconfig_compiler/KConfigHeaderGenerator.cpp | 4 +++- src/kconfig_compiler/kconfig_compiler.cpp | 8 ++++---- src/kreadconfig/kwriteconfig.cpp | 13 ++++++++++--- 9 files changed, 52 insertions(+), 22 deletions(-) diff --git a/src/core/kauthorized.cpp b/src/core/kauthorized.cpp index a08586c5..46b33ab2 100644 --- a/src/core/kauthorized.cpp +++ b/src/core/kauthorized.cpp @@ -77,11 +77,14 @@ class URLActionRule bool baseMatch(const QUrl &url, const QString &protClass) const { if (baseProtWildCard) { - if (!baseProt.isEmpty() && !url.scheme().startsWith(baseProt) && (protClass.isEmpty() || (protClass != baseProt))) { + if (!baseProt.isEmpty() // + && !url.scheme().startsWith(baseProt) // + && (protClass.isEmpty() || (protClass != baseProt))) { return false; } } else { - if ((url.scheme() != baseProt) && (protClass.isEmpty() || (protClass != baseProt))) { + if (url.scheme() != baseProt // + && (protClass.isEmpty() || (protClass != baseProt))) { return false; } } @@ -109,15 +112,19 @@ class URLActionRule bool destMatch(const QUrl &url, const QString &protClass, const QUrl &base, const QString &baseClass) const { if (destProtEqual) { - if ((url.scheme() != base.scheme()) && (protClass.isEmpty() || baseClass.isEmpty() || protClass != baseClass)) { + if (url.scheme() != base.scheme() // + && (protClass.isEmpty() || baseClass.isEmpty() || protClass != baseClass)) { return false; } } else if (destProtWildCard) { - if (!destProt.isEmpty() && !url.scheme().startsWith(destProt) && (protClass.isEmpty() || (protClass != destProt))) { + if (!destProt.isEmpty() // + && !url.scheme().startsWith(destProt) // + && (protClass.isEmpty() || (protClass != destProt))) { return false; } } else { - if ((url.scheme() != destProt) && (protClass.isEmpty() || (protClass != destProt))) { + if (url.scheme() != destProt // + && (protClass.isEmpty() || (protClass != destProt))) { return false; } } diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index 2da1dd48..ab6ac5c5 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -756,8 +756,8 @@ void KConfigPrivate::parseConfigFiles() } } else { QExplicitlySharedDataPointer backend = KConfigBackend::create(file); - bFileImmutable = (backend->parseConfig(utf8Locale, entryMap, KConfigBackend::ParseDefaults | KConfigBackend::ParseExpansions) - == KConfigBackend::ParseImmutable); + constexpr auto parseOpts = KConfigBackend::ParseDefaults | KConfigBackend::ParseExpansions; + bFileImmutable = backend->parseConfig(utf8Locale, entryMap, parseOpts) == KConfigBackend::ParseImmutable; } if (bFileImmutable) { @@ -918,8 +918,7 @@ bool KConfig::isConfigWritable(bool warnUser) errorMsg += QCoreApplication::translate("KConfig", "Please contact your system administrator."); QString cmdToExec = QStandardPaths::findExecutable(QStringLiteral("kdialog")); if (!cmdToExec.isEmpty()) { - QProcess::execute(cmdToExec, - QStringList() << QStringLiteral("--title") << QCoreApplication::applicationName() << QStringLiteral("--msgbox") << errorMsg); + QProcess::execute(cmdToExec, QStringList{QStringLiteral("--title"), QCoreApplication::applicationName(), QStringLiteral("--msgbox"), errorMsg}); } } diff --git a/src/core/kconfigdata.h b/src/core/kconfigdata.h index bb9ee717..afa18877 100644 --- a/src/core/kconfigdata.h +++ b/src/core/kconfigdata.h @@ -79,7 +79,13 @@ struct KEntry { // omits the dirty/notify flag from the comparison. inline bool operator==(const KEntry &k1, const KEntry &k2) { - return k1.bGlobal == k2.bGlobal && k1.bImmutable == k2.bImmutable && k1.bDeleted == k2.bDeleted && k1.bExpand == k2.bExpand && k1.mValue == k2.mValue; + /* clang-format off */ + return k1.bGlobal == k2.bGlobal + && k1.bImmutable == k2.bImmutable + && k1.bDeleted == k2.bDeleted + && k1.bExpand == k2.bExpand + && k1.mValue == k2.mValue; + /* clang-format on */ } inline bool operator!=(const KEntry &k1, const KEntry &k2) diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp index 6271bcd5..f47310d0 100644 --- a/src/core/kconfigini.cpp +++ b/src/core/kconfigini.cpp @@ -133,7 +133,11 @@ KConfigBackend::ParseInfo KConfigIniBackend::parseConfig(const QByteArray &curre } ++end; } - if (end + 1 == line.length() && start + 2 == end && line.at(start) == '$' && line.at(start + 1) == 'i') { + /* clang-format off */ + if (end + 1 == line.length() + && start + 2 == end + && line.at(start) == '$' + && line.at(start + 1) == 'i') { /* clang-format on */ if (newGroup.isEmpty()) { fileOptionImmutable = !kde_kiosk_exception; } else { diff --git a/src/gui/kconfiggroupgui.cpp b/src/gui/kconfiggroupgui.cpp index 5fbdbfad..09c31590 100644 --- a/src/gui/kconfiggroupgui.cpp +++ b/src/gui/kconfiggroupgui.cpp @@ -154,9 +154,12 @@ static bool writeEntryGui(KConfigGroup *cg, const char *key, const QVariant &pro // than the former. For more details see: // https://bugreports.qt.io/browse/QTBUG-63792 // https://bugs.kde.org/show_bug.cgi?id=378523 + /* clang-format off */ if (f.weight() == QFont::Normal - && (f.styleName() == QLatin1String("Regular") || f.styleName() == QLatin1String("Normal") || f.styleName() == QLatin1String("Book") - || f.styleName() == QLatin1String("Roman"))) { + && (f.styleName() == QLatin1String("Regular") + || f.styleName() == QLatin1String("Normal") + || f.styleName() == QLatin1String("Book") + || f.styleName() == QLatin1String("Roman"))) { /* clang-format on */ f.setStyleName(QString()); } cg->writeEntry(key, f.toString().toUtf8(), pFlags); diff --git a/src/kconf_update/kconf_update.cpp b/src/kconf_update/kconf_update.cpp index defe0b80..a08ecaae 100644 --- a/src/kconf_update/kconf_update.cpp +++ b/src/kconf_update/kconf_update.cpp @@ -199,7 +199,9 @@ QStringList KonfUpdate::findUpdateFiles(bool dirtyOnly) KConfigGroup cg(m_config, fileName); const QDateTime ctime = QDateTime::fromSecsSinceEpoch(cg.readEntry("ctime", 0u)); const QDateTime mtime = QDateTime::fromSecsSinceEpoch(cg.readEntry("mtime", 0u)); - if (!dirtyOnly || (ctime.isValid() && ctime != info.birthTime()) || mtime != info.lastModified()) { + if (!dirtyOnly // + || (ctime.isValid() && ctime != info.birthTime()) // + || mtime != info.lastModified()) { result.append(file); } } diff --git a/src/kconfig_compiler/KConfigHeaderGenerator.cpp b/src/kconfig_compiler/KConfigHeaderGenerator.cpp index d2c7e6cf..21eb51a5 100644 --- a/src/kconfig_compiler/KConfigHeaderGenerator.cpp +++ b/src/kconfig_compiler/KConfigHeaderGenerator.cpp @@ -74,7 +74,9 @@ void KConfigHeaderGenerator::doClassDefinition() } // Member variables - if (!cfg().memberVariables.isEmpty() && cfg().memberVariables != QLatin1String("private") && cfg().memberVariables != QLatin1String("dpointer")) { + if (!cfg().memberVariables.isEmpty() // + && cfg().memberVariables != QLatin1String("private") // + && cfg().memberVariables != QLatin1String("dpointer")) { stream() << " " << cfg().memberVariables << ":\n"; } diff --git a/src/kconfig_compiler/kconfig_compiler.cpp b/src/kconfig_compiler/kconfig_compiler.cpp index 449d437a..3c226d5f 100644 --- a/src/kconfig_compiler/kconfig_compiler.cpp +++ b/src/kconfig_compiler/kconfig_compiler.cpp @@ -383,8 +383,8 @@ QString itemDeclaration(const CfgEntry *e, const KConfigParameters &cfg) QString result; if (!cfg.itemAccessors && !cfg.dpointer) { - result += QLatin1String{" "} + (!e->signalList.isEmpty() ? QStringLiteral("KConfigCompilerSignallingItem") : type) + QLatin1String{" *item"} + fCap - + argSuffix + QLatin1String{";\n"}; + result += QLatin1String{" "} + (!e->signalList.isEmpty() ? QStringLiteral("KConfigCompilerSignallingItem") : type); + result += QLatin1String{" *item"} + fCap + argSuffix + QLatin1String{";\n"}; } if (!e->signalList.isEmpty()) { @@ -436,8 +436,8 @@ QString itemPath(const CfgEntry *e, const KConfigParameters &cfg) QString newInnerItem(const CfgEntry *entry, const QString &key, const QString &defaultValue, const KConfigParameters &cfg, const QString ¶m) { - QString t = QLatin1String{"new "} + cfg.inherits + QLatin1String{"::Item"} + itemType(entry->type) + QLatin1String{"( currentGroup(), "} + key - + QLatin1String{", "} + varPath(entry->name, cfg) + param; + QString t = QLatin1String{"new "} + cfg.inherits + QLatin1String{"::Item"} + itemType(entry->type); + t += QLatin1String{"( currentGroup(), "} + key + QLatin1String{", "} + varPath(entry->name, cfg) + param; if (entry->type == QLatin1String("Enum")) { t += QLatin1String{", values"} + entry->name; diff --git a/src/kreadconfig/kwriteconfig.cpp b/src/kreadconfig/kwriteconfig.cpp index ba16ec68..a8a1ee4e 100644 --- a/src/kreadconfig/kwriteconfig.cpp +++ b/src/kreadconfig/kwriteconfig.cpp @@ -59,16 +59,23 @@ int main(int argc, char **argv) konfig = new KConfig(file, KConfig::NoGlobals); KConfigGroup cfgGroup = konfig->group(QString()); - for (const QString &grp : groups) + for (const QString &grp : groups) { cfgGroup = cfgGroup.group(grp); - if (konfig->accessMode() != KConfig::ReadWrite || cfgGroup.isEntryImmutable(key)) + } + + if (konfig->accessMode() != KConfig::ReadWrite || cfgGroup.isEntryImmutable(key)) { return 2; + } if (del) { cfgGroup.deleteEntry(key); } else if (type == QStringLiteral("bool")) { // For symmetry with kreadconfig we accept a wider range of values as true than Qt - bool boolvalue = (value == QStringLiteral("true") || value == QStringLiteral("on") || value == QStringLiteral("yes") || value == QStringLiteral("1")); + /* clang-format off */ + bool boolvalue = value == QStringLiteral("true") + || value == QStringLiteral("on") + || value == QStringLiteral("yes") + || value == QStringLiteral("1"); /* clang-format on */ cfgGroup.writeEntry(key, boolvalue); } else if (type == QStringLiteral("path")) { cfgGroup.writePathEntry(key, value); From cae1e9b6d2ec957f8bc4643b898308a404d00a5f Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Tue, 23 Feb 2021 13:08:15 +0200 Subject: [PATCH 117/259] Add KEntryMap::constFindEntry() method - This has the same logic as QMap::constFind(); less detaching and now we can use auto keyword when creating iterators and always get a const_iterator even when calling constFindEntry() on a non-const map. - Use QCOMPARE() where appropriate in the unit tests. --- autotests/kentrymaptest.cpp | 56 ++++++++++++++++++------------------- src/core/kconfig.cpp | 10 +++---- src/core/kconfigdata.cpp | 15 +++++----- src/core/kconfigdata.h | 7 ++++- 4 files changed, 47 insertions(+), 41 deletions(-) diff --git a/autotests/kentrymaptest.cpp b/autotests/kentrymaptest.cpp index d571f761..899fcac1 100644 --- a/autotests/kentrymaptest.cpp +++ b/autotests/kentrymaptest.cpp @@ -54,21 +54,21 @@ void KEntryMapTest::testSimple() map.setEntry(group1, key2, value2, EntryOptions()); QCOMPARE(map.size(), 3); // the group marker & 2 keys - QVERIFY(map.findEntry(group1) != map.end()); - QVERIFY(map.findEntry(group1.toLower()) == map.end()); + QVERIFY(map.constFindEntry(group1) != map.cend()); + QCOMPARE(map.constFindEntry(group1.toLower()), map.cend()); - QVERIFY(map.findEntry(group1, key1) != map.end()); - QVERIFY(map.findEntry(group1, key1.toLower()) == map.end()); - QVERIFY(map.findEntry(group1, key2) != map.end()); - QVERIFY(map.findEntry(group1, key2.toUpper()) == map.end()); + QVERIFY(map.constFindEntry(group1, key1) != map.cend()); + QCOMPARE(map.constFindEntry(group1, key1.toLower()), map.cend()); + QVERIFY(map.constFindEntry(group1, key2) != map.cend()); + QCOMPARE(map.constFindEntry(group1, key2.toUpper()), map.cend()); - QByteArray found = map.findEntry(group1, key1)->mValue; - QVERIFY(found == value1); + QByteArray found = map.constFindEntry(group1, key1)->mValue; + QCOMPARE(found, value1); QVERIFY(found != value2); - found = map.findEntry(group1, key2)->mValue; + found = map.constFindEntry(group1, key2)->mValue; QVERIFY(found != value1); - QVERIFY(found == value2); + QCOMPARE(found, value2); } void KEntryMapTest::testDirty() @@ -93,16 +93,16 @@ void KEntryMapTest::testDefault() map.setEntry(group1, key2, value2, EntryOptions()); QCOMPARE(map.size(), 4); // group marker, default1, entry1, entry2 - const KEntryMap::ConstIterator defaultEntry(map.findEntry(group1, key1, SearchDefaults)); - const KEntryMap::ConstIterator entry1(map.findEntry(group1, key1)); - const KEntryMap::ConstIterator entry2(map.findEntry(group1, key2)); + const auto defaultEntry(map.constFindEntry(group1, key1, SearchDefaults)); + const auto entry1(map.constFindEntry(group1, key1)); + const auto entry2(map.constFindEntry(group1, key2)); // default set for entry1 QVERIFY(defaultEntry != map.constEnd()); QCOMPARE(defaultEntry->mValue, entry1->mValue); // no default set for entry2 - QVERIFY(map.findEntry(group1, key2, SearchDefaults) == map.end()); + QCOMPARE(map.constFindEntry(group1, key2, SearchDefaults), map.cend()); // change from default map.setEntry(group1, key1, value2, EntryOptions()); @@ -131,7 +131,7 @@ void KEntryMapTest::testDelete() map.setEntry(group1, key2, QByteArray(), EntryDeleted | EntryDirty); QCOMPARE(map.size(), 5); // entry should still be in map, so it can override merged entries later - QCOMPARE(map.findEntry(group1, key2)->mValue, QByteArray()); + QCOMPARE(map.constFindEntry(group1, key2)->mValue, QByteArray()); } void KEntryMapTest::testGlobal() @@ -139,11 +139,11 @@ void KEntryMapTest::testGlobal() KEntryMap map; map.setEntry(group1, key1, value1, EntryGlobal); - QCOMPARE(map.findEntry(group1, key1)->bGlobal, true); + QCOMPARE(map.constFindEntry(group1, key1)->bGlobal, true); // this should create a new key that is not "global" map.setEntry(group1, key1, value2, EntryOptions()); - QVERIFY(!map.findEntry(group1, key1)->bGlobal); + QCOMPARE(map.constFindEntry(group1, key1)->bGlobal, false); } void KEntryMapTest::testImmutable() @@ -151,18 +151,18 @@ void KEntryMapTest::testImmutable() KEntryMap map; map.setEntry(group1, key1, value1, EntryImmutable); - QCOMPARE(map.findEntry(group1, key1)->bImmutable, true); // verify the immutable bit was set + QCOMPARE(map.constFindEntry(group1, key1)->bImmutable, true); // verify the immutable bit was set map.setEntry(group1, key1, value2, EntryOptions()); - QCOMPARE(map.findEntry(group1, key1)->mValue, value1); // verify the value didn't change + QCOMPARE(map.constFindEntry(group1, key1)->mValue, value1); // verify the value didn't change map.clear(); map.setEntry(group1, QByteArray(), QByteArray(), EntryImmutable); - QCOMPARE(map.findEntry(group1)->bImmutable, true); // verify the group is immutable + QCOMPARE(map.constFindEntry(group1)->bImmutable, true); // verify the group is immutable map.setEntry(group1, key1, value1, EntryOptions()); // should be ignored since the group is immutable - QVERIFY(map.findEntry(group1, key1) == map.end()); + QCOMPARE(map.constFindEntry(group1, key1), map.cend()); } void KEntryMapTest::testLocale() @@ -173,17 +173,17 @@ void KEntryMapTest::testLocale() KEntryMap map; map.setEntry(group1, key1, untranslated, EntryDefault); - QCOMPARE(map.findEntry(group1, key1)->mValue, untranslated); - QCOMPARE(map.findEntry(group1, key1, SearchLocalized)->mValue, untranslated); // no localized value yet + QCOMPARE(map.constFindEntry(group1, key1)->mValue, untranslated); + QCOMPARE(map.constFindEntry(group1, key1, SearchLocalized)->mValue, untranslated); // no localized value yet map.setEntry(group1, key1, translated, EntryLocalized); - QCOMPARE(map.findEntry(group1, key1, SearchLocalized)->mValue, translated); // has localized value now - QVERIFY(map.findEntry(group1, key1, SearchLocalized)->mValue != map.findEntry(group1, key1)->mValue); - QCOMPARE(map.findEntry(group1, key1, SearchDefaults | SearchLocalized)->mValue, untranslated); // default should still be untranslated + QCOMPARE(map.constFindEntry(group1, key1, SearchLocalized)->mValue, translated); // has localized value now + QVERIFY(map.constFindEntry(group1, key1, SearchLocalized)->mValue != map.constFindEntry(group1, key1)->mValue); + QCOMPARE(map.constFindEntry(group1, key1, SearchDefaults | SearchLocalized)->mValue, untranslated); // default should still be untranslated map.setEntry(group1, key1, translatedDefault, EntryDefault | EntryLocalized); - QCOMPARE(map.findEntry(group1, key1, SearchLocalized)->mValue, translatedDefault); + QCOMPARE(map.constFindEntry(group1, key1, SearchLocalized)->mValue, translatedDefault); map.setEntry(group1, key1, translated, EntryLocalized); // set the translated entry to a different locale - QCOMPARE(map.findEntry(group1, key1, SearchLocalized)->mValue, translated); + QCOMPARE(map.constFindEntry(group1, key1, SearchLocalized)->mValue, translated); } diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index ab6ac5c5..7f53847f 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -332,8 +332,8 @@ QStringList KConfigPrivate::keyListImpl(const QByteArray &theGroup) const { QStringList keys; - const KEntryMapConstIterator theEnd = entryMap.constEnd(); - KEntryMapConstIterator it = entryMap.findEntry(theGroup); + const auto theEnd = entryMap.constEnd(); + auto it = entryMap.constFindEntry(theGroup); if (it != theEnd) { ++it; // advance past the special group entry marker @@ -363,8 +363,8 @@ QMap KConfig::entryMap(const QString &aGroup) const QMap theMap; const QByteArray theGroup(aGroup.isEmpty() ? "" : aGroup.toUtf8()); - const KEntryMapConstIterator theEnd = d->entryMap.constEnd(); - KEntryMapConstIterator it = d->entryMap.findEntry(theGroup, {}, {}); + const auto theEnd = d->entryMap.constEnd(); + auto it = d->entryMap.constFindEntry(theGroup, {}, {}); if (it != theEnd) { ++it; // advance past the special group entry marker @@ -981,7 +981,7 @@ QByteArray KConfigPrivate::lookupData(const QByteArray &group, const char *key, if (bReadDefaults) { flags |= KEntryMap::SearchDefaults; } - const KEntryMapConstIterator it = entryMap.findEntry(group, key, flags); + const auto it = entryMap.constFindEntry(group, key, flags); if (it == entryMap.constEnd()) { return QByteArray(); } diff --git a/src/core/kconfigdata.cpp b/src/core/kconfigdata.cpp index accf869b..5a785c45 100644 --- a/src/core/kconfigdata.cpp +++ b/src/core/kconfigdata.cpp @@ -48,7 +48,7 @@ QMap::Iterator KEntryMap::findEntry(const QByteArray &group, return find(theKey); } -QMap::ConstIterator KEntryMap::findEntry(const QByteArray &group, const QByteArray &key, KEntryMap::SearchFlags flags) const +QMap::ConstIterator KEntryMap::constFindEntry(const QByteArray &group, const QByteArray &key, SearchFlags flags) const { KEntryKey theKey(group, key, false, bool(flags & SearchDefaults)); @@ -56,14 +56,15 @@ QMap::ConstIterator KEntryMap::findEntry(const QByteArray &gr if (flags & SearchLocalized) { theKey.bLocal = true; - ConstIterator it = find(theKey); - if (it != constEnd()) { + auto it = constFind(theKey); + if (it != cend()) { return it; } theKey.bLocal = false; } - return find(theKey); + + return constFind(theKey); } bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const QByteArray &value, KEntryMap::EntryOptions options) @@ -105,7 +106,7 @@ bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const Q } else { // make sure the group marker is in the map KEntryMap const *that = this; - ConstIterator cit = that->findEntry(group); + auto cit = that->constFindEntry(group); if (cit == constEnd()) { insert(KEntryKey(group), KEntry()); } else if (cit->bImmutable) { @@ -212,7 +213,7 @@ bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const Q QString KEntryMap::getEntry(const QByteArray &group, const QByteArray &key, const QString &defaultValue, KEntryMap::SearchFlags flags, bool *expand) const { - const ConstIterator it = findEntry(group, key, flags); + const auto it = constFindEntry(group, key, flags); QString theValue = defaultValue; if (it != constEnd() && !it->bDeleted) { @@ -230,7 +231,7 @@ QString KEntryMap::getEntry(const QByteArray &group, const QByteArray &key, cons bool KEntryMap::hasEntry(const QByteArray &group, const QByteArray &key, KEntryMap::SearchFlags flags) const { - const ConstIterator it = findEntry(group, key, flags); + const auto it = constFindEntry(group, key, flags); if (it == constEnd()) { return false; } diff --git a/src/core/kconfigdata.h b/src/core/kconfigdata.h index afa18877..dd396fc8 100644 --- a/src/core/kconfigdata.h +++ b/src/core/kconfigdata.h @@ -192,7 +192,12 @@ class KEntryMap : public QMap Iterator findEntry(const QByteArray &group, const QByteArray &key = QByteArray(), SearchFlags flags = SearchFlags()); - ConstIterator findEntry(const QByteArray &group, const QByteArray &key = QByteArray(), SearchFlags flags = SearchFlags()) const; + ConstIterator findEntry(const QByteArray &group, const QByteArray &key = QByteArray(), SearchFlags flags = SearchFlags()) const + { + return constFindEntry(group, key, flags); + } + + ConstIterator constFindEntry(const QByteArray &group, const QByteArray &key = QByteArray(), SearchFlags flags = SearchFlags()) const; /** * Returns true if the entry gets dirtied or false in other case From 505909e5d6c5a5b44a4972f1aee8156da6d61c79 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Tue, 23 Feb 2021 13:25:26 +0200 Subject: [PATCH 118/259] Use KEntryMapIterator/KEntryMapConstIterator typedef's everywhere NO_CHANGELOG --- src/core/kconfigdata.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/kconfigdata.cpp b/src/core/kconfigdata.cpp index 5a785c45..8ceea7ee 100644 --- a/src/core/kconfigdata.cpp +++ b/src/core/kconfigdata.cpp @@ -24,13 +24,13 @@ QDebug operator<<(QDebug dbg, const KEntry &entry) return dbg.space(); } -QMap::Iterator KEntryMap::findExactEntry(const QByteArray &group, const QByteArray &key, KEntryMap::SearchFlags flags) +KEntryMapIterator KEntryMap::findExactEntry(const QByteArray &group, const QByteArray &key, KEntryMap::SearchFlags flags) { KEntryKey theKey(group, key, bool(flags & SearchLocalized), bool(flags & SearchDefaults)); return find(theKey); } -QMap::Iterator KEntryMap::findEntry(const QByteArray &group, const QByteArray &key, KEntryMap::SearchFlags flags) +KEntryMapIterator KEntryMap::findEntry(const QByteArray &group, const QByteArray &key, KEntryMap::SearchFlags flags) { KEntryKey theKey(group, key, false, bool(flags & SearchDefaults)); @@ -48,7 +48,7 @@ QMap::Iterator KEntryMap::findEntry(const QByteArray &group, return find(theKey); } -QMap::ConstIterator KEntryMap::constFindEntry(const QByteArray &group, const QByteArray &key, SearchFlags flags) const +KEntryMapConstIterator KEntryMap::constFindEntry(const QByteArray &group, const QByteArray &key, SearchFlags flags) const { KEntryKey theKey(group, key, false, bool(flags & SearchDefaults)); @@ -245,7 +245,7 @@ bool KEntryMap::hasEntry(const QByteArray &group, const QByteArray &key, KEntryM return true; } -bool KEntryMap::getEntryOption(const QMap::ConstIterator &it, KEntryMap::EntryOption option) const +bool KEntryMap::getEntryOption(const KEntryMapConstIterator &it, KEntryMap::EntryOption option) const { if (it != constEnd()) { switch (option) { @@ -271,7 +271,7 @@ bool KEntryMap::getEntryOption(const QMap::ConstIterator &it, return false; } -void KEntryMap::setEntryOption(QMap::Iterator it, KEntryMap::EntryOption option, bool bf) +void KEntryMap::setEntryOption(KEntryMapIterator it, KEntryMap::EntryOption option, bool bf) { if (it != end()) { switch (option) { From 124668a0be01f5a65f120072c34ddddabdd627e7 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Sat, 27 Feb 2021 15:32:28 +0200 Subject: [PATCH 119/259] Add .git-blame-ignore-revs GIT_SILENT --- .git-blame-ignore-revs | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .git-blame-ignore-revs diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 00000000..a64f7abc --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,3 @@ +#clang-format +8bed00ab34e31f2b9c70026d418d923913325798 +48c132be8aa983165126b0641a083848dd5c6620 From 5a048f1c911fad293ea98a979273db22cf1034a7 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sun, 28 Feb 2021 11:13:40 +0000 Subject: [PATCH 120/259] GIT_SILENT Upgrade ECM and KF version requirements for 5.80.0 release. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dba7a7ef..68ffa483 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ set(KF_VERSION "5.80.0") # handled by release scripts project(KConfig VERSION ${KF_VERSION}) include(FeatureSummary) -find_package(ECM 5.79.0 NO_MODULE) +find_package(ECM 5.80.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) From 63c26290d25bc8ace158de94bcb764c764c476a9 Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Sun, 31 Jan 2021 18:11:46 +0100 Subject: [PATCH 121/259] Make QByteArray -> char* conversion explicit The implicit conversion fails in Qt6 --- src/core/kconfigdata.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/kconfigdata.h b/src/core/kconfigdata.h index dd396fc8..0ca228fe 100644 --- a/src/core/kconfigdata.h +++ b/src/core/kconfigdata.h @@ -139,12 +139,12 @@ struct KEntryKey { */ inline bool operator<(const KEntryKey &k1, const KEntryKey &k2) { - int result = qstrcmp(k1.mGroup, k2.mGroup); + int result = qstrcmp(k1.mGroup.data(), k2.mGroup.data()); if (result != 0) { return result < 0; } - result = qstrcmp(k1.mKey, k2.mKey); + result = qstrcmp(k1.mKey.data(), k2.mKey.data()); if (result != 0) { return result < 0; } From 24dab65f44b0352cfa410162c1099c3f22f7e873 Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Mon, 1 Mar 2021 11:13:04 +0100 Subject: [PATCH 122/259] Add missing QTextStream::setCodec ifdef This was missed in https://invent.kde.org/frameworks/kconfig/-/merge_requests/41 --- src/kconfig_compiler/KConfigCodeGeneratorBase.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp b/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp index 27a96488..5d7f57be 100644 --- a/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp +++ b/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp @@ -38,7 +38,9 @@ KConfigCodeGeneratorBase::KConfigCodeGeneratorBase(const QString &inputFile, exit(1); } m_stream.setDevice(&m_file); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) m_stream.setCodec("utf-8"); +#endif if (m_cfg.staticAccessors) { m_this = QStringLiteral("self()->"); From 36f12b207f6a08f6d5fda7d53246a8abe70edf63 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Mon, 1 Mar 2021 14:28:46 +0200 Subject: [PATCH 123/259] KDEFrameworkCompilerSettings in ECM 5.80 includes KDEClangFormat by default GIT_SILENT --- CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 68ffa483..9cc3f6e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,7 +106,3 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kconfig_version.h feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT) -# Remove these 3 lines when the ECM version is bumped to 5.80 -include(KDEClangFormat) -file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h) -kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES}) From ee35bdce8f6b08922b4c9e0c0c838e5f2c4a79ad Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Mon, 22 Feb 2021 22:38:43 +0200 Subject: [PATCH 124/259] Optimise string operations a bit - Use QString::arg(Args...) instead of .arg().arg() - Use QLatin1String for string comparisons, should be faster - Use QLatin1String::arg() for better readability - Add the comment dfaure suggested in the MR, to explain why it's '2%' then '%1' in a QString().arg().arg() NO_CHANGELOG --- src/core/kconfigini.cpp | 2 ++ src/gui/kconfiggroupgui.cpp | 10 ++++++---- src/gui/kconfiggui.cpp | 2 +- src/gui/kwindowconfig.cpp | 10 +++++----- src/kconfig_compiler/kconfig_compiler.cpp | 2 +- src/kreadconfig/kreadconfig.cpp | 12 +++++++----- src/kreadconfig/kwriteconfig.cpp | 12 ++++++------ 7 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp index f47310d0..dd24a959 100644 --- a/src/core/kconfigini.cpp +++ b/src/core/kconfigini.cpp @@ -44,6 +44,8 @@ static QByteArray lookup(const KConfigIniBackend::BufferFragment fragment, QHash QString KConfigIniBackend::warningProlog(const QFile &file, int line) { + // %2 then %1 i.e. int before QString, so that the QString is last + // This avoids a wrong substitution if the fileName itself contains %1 return QStringLiteral("KConfigIni: In file %2, line %1: ").arg(line).arg(file.fileName()); } diff --git a/src/gui/kconfiggroupgui.cpp b/src/gui/kconfiggroupgui.cpp index 09c31590..ab0c268f 100644 --- a/src/gui/kconfiggroupgui.cpp +++ b/src/gui/kconfiggroupgui.cpp @@ -54,8 +54,9 @@ static bool readEntryGui(const QByteArray &data, const char *key, const QVariant const int count = list.count(); if (count != 3 && count != 4) { - const QString formatError = QStringLiteral(" (wrong format: expected '%1' items, read '%2')"); - qCritical() << qPrintable(errString()) << qPrintable(formatError.arg(QStringLiteral("3' or '4")).arg(count)); + qCritical() // + << qPrintable(errString()) // + << qPrintable(QStringLiteral(" (wrong format: expected '%1' items, read '%2')").arg(QStringLiteral("3' or '4")).arg(count)); return true; // return default } @@ -70,9 +71,10 @@ static bool readEntryGui(const QByteArray &data, const char *key, const QVariant } if (j < 0 || j > 255) { static const char *const components[] = {"red", "green", "blue", "alpha"}; - const QString boundsError = QStringLiteral(" (bounds error: %1 component %2)"); qCritical() << qPrintable(errString()) - << qPrintable(boundsError.arg(QLatin1String(components[i])).arg(j < 0 ? QStringLiteral("< 0") : QStringLiteral("> 255"))); + << qPrintable(QStringLiteral(" (bounds error: %1 component %2)") + .arg(QLatin1String(components[i]), // + j < 0 ? QStringLiteral("< 0") : QStringLiteral("> 255"))); return true; // return default } } diff --git a/src/gui/kconfiggui.cpp b/src/gui/kconfiggui.cpp index 938fbd93..cafe061d 100644 --- a/src/gui/kconfiggui.cpp +++ b/src/gui/kconfiggui.cpp @@ -13,7 +13,7 @@ static QString configName(const QString &id, const QString &key) { - return (QLatin1String("session/") + QGuiApplication::applicationName() + QLatin1Char('_') + id + QLatin1Char('_') + key); + return QLatin1String("session/%1_%2_%3").arg(QGuiApplication::applicationName(), id, key); } static KConfig *s_sessionConfig = nullptr; diff --git a/src/gui/kwindowconfig.cpp b/src/gui/kwindowconfig.cpp index a7697782..019e1aa2 100644 --- a/src/gui/kwindowconfig.cpp +++ b/src/gui/kwindowconfig.cpp @@ -37,7 +37,7 @@ static QString allConnectedScreens() static QString configFileString(const QRect &desk, const QString &key) { // We include resolution data to also save data on a per-resolution basis - const QString returnString = QStringLiteral("%1 %2 %3x%4").arg(allConnectedScreens()).arg(key).arg(desk.width()).arg(desk.height()); + const QString returnString = QStringLiteral("%1 %2 %3x%4").arg(allConnectedScreens(), key, QString::number(desk.width()), QString::number(desk.height())); return returnString; } @@ -136,7 +136,7 @@ void KWindowConfig::saveWindowPosition(const QWindow *window, KConfigGroup &conf { // On Wayland, the compositor is solely responsible for window positioning, // So this needs to be a no-op - if (!window || QGuiApplication::platformName() == QStringLiteral("wayland")) { + if (!window || QGuiApplication::platformName() == QLatin1String{"wayland"}) { return; } @@ -149,7 +149,7 @@ void KWindowConfig::restoreWindowPosition(QWindow *window, const KConfigGroup &c { // On Wayland, the compositor is solely responsible for window positioning, // So this needs to be a no-op - if (!window || QGuiApplication::platformName() == QStringLiteral("wayland")) { + if (!window || QGuiApplication::platformName() == QLatin1String{"wayland"}) { return; } @@ -166,8 +166,8 @@ void KWindowConfig::restoreWindowPosition(QWindow *window, const KConfigGroup &c // per-resolution information is not // TODO: Remove in KF6 or maybe even KF5.85 or something. It really only needs // to be here to transition existing users once they upgrade from 5.78 -> 5.79 - const int fallbackXPosition = config.readEntry(QStringLiteral("%1 XPosition %2").arg(allConnectedScreens()).arg(desk.width()), -1); - const int fallbackYPosition = config.readEntry(QStringLiteral("%1 YPosition %2").arg(allConnectedScreens()).arg(desk.height()), -1); + const int fallbackXPosition = config.readEntry(QStringLiteral("%1 XPosition %2").arg(allConnectedScreens(), QString::number(desk.width())), -1); + const int fallbackYPosition = config.readEntry(QStringLiteral("%1 YPosition %2").arg(allConnectedScreens(), QString::number(desk.height())), -1); const int xPos = config.readEntry(windowXPositionString(desk), fallbackXPosition); const int yPos = config.readEntry(windowYPositionString(desk), fallbackYPosition); diff --git a/src/kconfig_compiler/kconfig_compiler.cpp b/src/kconfig_compiler/kconfig_compiler.cpp index 3c226d5f..50c54f8f 100644 --- a/src/kconfig_compiler/kconfig_compiler.cpp +++ b/src/kconfig_compiler/kconfig_compiler.cpp @@ -114,7 +114,7 @@ QString setFunction(const QString &n, const QString &className) QString changeSignalName(const QString &n) { - return n + QStringLiteral("Changed"); + return n + QLatin1String{"Changed"}; } QString getDefaultFunction(const QString &n, const QString &className) diff --git a/src/kreadconfig/kreadconfig.cpp b/src/kreadconfig/kreadconfig.cpp index 444f3bde..f0fb3518 100644 --- a/src/kreadconfig/kreadconfig.cpp +++ b/src/kreadconfig/kreadconfig.cpp @@ -74,21 +74,23 @@ int main(int argc, char **argv) configMustDeleted = true; } KConfigGroup cfgGroup = konfig->group(QString()); - for (const QString &grp : groups) + for (const QString &grp : groups) { cfgGroup = cfgGroup.group(grp); - if (type == QStringLiteral("bool")) { + } + + if (type == QLatin1String{"bool"}) { dflt = dflt.toLower(); - bool def = (dflt == QStringLiteral("true") || dflt == QStringLiteral("on") || dflt == QStringLiteral("yes") || dflt == QStringLiteral("1")); + bool def = (dflt == QLatin1String{"true"} || dflt == QLatin1String{"on"} || dflt == QLatin1String{"yes"} || dflt == QLatin1String{"1"}); bool retValue = !cfgGroup.readEntry(key, def); if (configMustDeleted) delete konfig; return retValue; - } else if ((type == QStringLiteral("num")) || (type == QStringLiteral("int"))) { + } else if (type == QLatin1String{"num"} || type == QLatin1String{"int"}) { int retValue = cfgGroup.readEntry(key, dflt.toInt()); if (configMustDeleted) delete konfig; return retValue; - } else if (type == QStringLiteral("path")) { + } else if (type == QLatin1String{"path"}) { fprintf(stdout, "%s\n", cfgGroup.readPathEntry(key, dflt).toLocal8Bit().data()); if (configMustDeleted) delete konfig; diff --git a/src/kreadconfig/kwriteconfig.cpp b/src/kreadconfig/kwriteconfig.cpp index a8a1ee4e..67d9637e 100644 --- a/src/kreadconfig/kwriteconfig.cpp +++ b/src/kreadconfig/kwriteconfig.cpp @@ -69,15 +69,15 @@ int main(int argc, char **argv) if (del) { cfgGroup.deleteEntry(key); - } else if (type == QStringLiteral("bool")) { + } else if (type == QLatin1String{"bool"}) { // For symmetry with kreadconfig we accept a wider range of values as true than Qt /* clang-format off */ - bool boolvalue = value == QStringLiteral("true") - || value == QStringLiteral("on") - || value == QStringLiteral("yes") - || value == QStringLiteral("1"); /* clang-format on */ + bool boolvalue = value == QLatin1String{"true"} + || value == QLatin1String{"on"} + || value == QLatin1String{"yes"} + || value == QLatin1String{"1"}; /* clang-format on */ cfgGroup.writeEntry(key, boolvalue); - } else if (type == QStringLiteral("path")) { + } else if (type == QLatin1String{"path"}) { cfgGroup.writePathEntry(key, value); } else { cfgGroup.writeEntry(key, value); From 9d87348260316af729892c58bc29f159a173abf1 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Tue, 23 Feb 2021 00:37:11 +0200 Subject: [PATCH 125/259] Minor code optimisation - Use more range-for loops where appropriate - Use auto instead of the usually-long iterator type names - Use cbegin/cend(), to match the std:: containers, less confusion - Use qDeleteAll instead of a for loop - Make a QRE with a long-ish pattern static NO_CHANGELOG --- src/core/kauthorized.cpp | 6 +-- src/core/kconfig.cpp | 6 +-- src/core/kconfigdata.cpp | 2 +- src/core/kconfiggroup.cpp | 4 +- src/core/kconfigini.cpp | 14 +++--- src/core/kcoreconfigskeleton.cpp | 46 ++++++++----------- src/core/kcoreconfigskeleton_p.h | 5 +- src/core/kdesktopfile.cpp | 32 ++++++------- src/core/kemailsettings.cpp | 6 +-- src/kconf_update/kconf_update.cpp | 26 +++++------ .../KConfigHeaderGenerator.cpp | 6 ++- .../KConfigSourceGenerator.cpp | 9 ++-- src/kconfig_compiler/KConfigXmlParser.cpp | 25 +++++----- 13 files changed, 88 insertions(+), 99 deletions(-) diff --git a/src/core/kauthorized.cpp b/src/core/kauthorized.cpp index 46b33ab2..a8784a1c 100644 --- a/src/core/kauthorized.cpp +++ b/src/core/kauthorized.cpp @@ -251,9 +251,9 @@ QStringList KAuthorized::authorizeControlModules(const QStringList &menuIds) { KConfigGroup cg(KSharedConfig::openConfig(), "KDE Control Module Restrictions"); QStringList result; - for (QStringList::ConstIterator it = menuIds.begin(); it != menuIds.end(); ++it) { - if (cg.readEntry(*it, true)) { - result.append(*it); + for (const auto &id : menuIds) { + if (cg.readEntry(id, true)) { + result.append(id); } } return result; diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index 7f53847f..cc3700e1 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -125,7 +125,7 @@ void KConfigPrivate::copyGroup(const QByteArray &source, const QByteArray &desti // as dirty erroneously bool dirtied = false; - for (KEntryMap::ConstIterator entryMapIt(entryMap.constBegin()); entryMapIt != entryMap.constEnd(); ++entryMapIt) { + for (auto entryMapIt = entryMap.cbegin(); entryMapIt != entryMap.cend(); ++entryMapIt) { const QByteArray &group = entryMapIt.key().mGroup; if (!group.startsWith(source)) { // nothing to do @@ -266,7 +266,7 @@ QStringList KConfig::groupList() const Q_D(const KConfig); QSet groups; - for (KEntryMap::ConstIterator entryMapIt(d->entryMap.constBegin()); entryMapIt != d->entryMap.constEnd(); ++entryMapIt) { + for (auto entryMapIt = d->entryMap.cbegin(); entryMapIt != d->entryMap.cend(); ++entryMapIt) { const KEntryKey &key = entryMapIt.key(); const QByteArray group = key.mGroup; if (key.mKey.isNull() && !group.isEmpty() && group != "" && group != "$Version") { @@ -283,7 +283,7 @@ QStringList KConfigPrivate::groupList(const QByteArray &group) const QByteArray theGroup = group + '\x1d'; QSet groups; - for (KEntryMap::ConstIterator entryMapIt(entryMap.constBegin()); entryMapIt != entryMap.constEnd(); ++entryMapIt) { + for (auto entryMapIt = entryMap.cbegin(); entryMapIt != entryMap.cend(); ++entryMapIt) { const KEntryKey &key = entryMapIt.key(); if (key.mKey.isNull() && key.mGroup.startsWith(theGroup)) { const QString groupname = QString::fromUtf8(key.mGroup.mid(theGroup.length())); diff --git a/src/core/kconfigdata.cpp b/src/core/kconfigdata.cpp index 8ceea7ee..ada7125f 100644 --- a/src/core/kconfigdata.cpp +++ b/src/core/kconfigdata.cpp @@ -312,7 +312,7 @@ bool KEntryMap::revertEntry(const QByteArray &group, const QByteArray &key, KEnt KEntryKey defaultKey(entry.key()); defaultKey.bDefault = true; // qDebug() << "looking up default entry with key=" << defaultKey; - const ConstIterator defaultEntry = constFind(defaultKey); + const auto defaultEntry = constFind(defaultKey); if (defaultEntry != constEnd()) { Q_ASSERT(defaultEntry.key().bDefault); // qDebug() << "found, update entry"; diff --git a/src/core/kconfiggroup.cpp b/src/core/kconfiggroup.cpp index 8fcfafe7..c065be81 100644 --- a/src/core/kconfiggroup.cpp +++ b/src/core/kconfiggroup.cpp @@ -126,8 +126,8 @@ QByteArray KConfigGroupPrivate::serializeList(const QList &list) QByteArray value; if (!list.isEmpty()) { - QList::ConstIterator it = list.constBegin(); - const QList::ConstIterator end = list.constEnd(); + auto it = list.cbegin(); + const auto end = list.cend(); value = QByteArray(*it).replace('\\', QByteArrayLiteral("\\\\")).replace(',', QByteArrayLiteral("\\,")); diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp index dd24a959..8c81db8f 100644 --- a/src/core/kconfigini.cpp +++ b/src/core/kconfigini.cpp @@ -298,8 +298,8 @@ void KConfigIniBackend::writeEntries(const QByteArray &locale, QIODevice &file, { QByteArray currentGroup; bool groupIsImmutable = false; - const KEntryMapConstIterator end = map.constEnd(); - for (KEntryMapConstIterator it = map.constBegin(); it != end; ++it) { + const auto end = map.cend(); + for (auto it = map.cbegin(); it != end; ++it) { const KEntryKey &key = it.key(); // Either process the default group or all others @@ -746,13 +746,13 @@ struct Utf8Char { QByteArray KConfigIniBackend::stringToPrintable(const QByteArray &aString, StringType type) { - if (aString.isEmpty()) { + const int len = aString.size(); + if (len == 0) { return aString; } - const int l = aString.length(); - QByteArray result; // Guesstimated that it's good to avoid data() initialization for a length of l*4 - result.resize(l * 4); // Maximum 4x as long as source string due to \x escape sequences + QByteArray result; // Guesstimated that it's good to avoid data() initialization for a length of len*4 + result.resize(len * 4); // Maximum 4x as long as source string due to \x escape sequences const char *s = aString.constData(); int i = 0; char *data = result.data(); @@ -766,7 +766,7 @@ QByteArray KConfigIniBackend::stringToPrintable(const QByteArray &aString, Strin } Utf8Char utf8; - for (; i < l; ++i /*, r++*/) { + for (; i < len; ++i) { switch (s[i]) { default: if (utf8.addByte(s[i])) { diff --git a/src/core/kcoreconfigskeleton.cpp b/src/core/kcoreconfigskeleton.cpp index 669e0ce5..ab968023 100644 --- a/src/core/kcoreconfigskeleton.cpp +++ b/src/core/kcoreconfigskeleton.cpp @@ -11,6 +11,8 @@ #include +#include + static QString obscuredString(const QString &str) { QString result; @@ -606,7 +608,7 @@ void KCoreConfigSkeleton::ItemEnum::readConfig(KConfig *config) int i = 0; mReference = -1; QString tmp = cg.readEntry(mKey, QString()).toLower(); - for (QList::ConstIterator it = mChoices.constBegin(); it != mChoices.constEnd(); ++it, ++i) { + for (auto it = mChoices.cbegin(); it != mChoices.cend(); ++it, ++i) { QString choiceName = (*it).name; if (valueForChoice(choiceName).toLower() == tmp) { mReference = i; @@ -1180,19 +1182,18 @@ bool KCoreConfigSkeleton::useDefaults(bool b) } d->mUseDefaults = b; - KConfigSkeletonItem::List::ConstIterator it; - for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) { - (*it)->swapDefault(); + for (auto *skelItem : qAsConst(d->mItems)) { + skelItem->swapDefault(); } + usrUseDefaults(b); return !d->mUseDefaults; } void KCoreConfigSkeleton::setDefaults() { - KConfigSkeletonItem::List::ConstIterator it; - for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) { - (*it)->setDefault(); + for (auto *skelItem : qAsConst(d->mItems)) { + skelItem->setDefault(); } usrSetDefaults(); } @@ -1205,42 +1206,33 @@ void KCoreConfigSkeleton::load() void KCoreConfigSkeleton::read() { - KConfigSkeletonItem::List::ConstIterator it; - for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) { - (*it)->readConfig(d->mConfig.data()); + for (auto *skelItem : qAsConst(d->mItems)) { + skelItem->readConfig(d->mConfig.data()); } usrRead(); } bool KCoreConfigSkeleton::isDefaults() const { - KConfigSkeletonItem::List::ConstIterator it; - for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) { - if (!(*it)->isDefault()) { - return false; - } - } - return true; + return std::all_of(d->mItems.cbegin(), d->mItems.cend(), [](KConfigSkeletonItem *skelItem) { + return skelItem->isDefault(); + }); } bool KCoreConfigSkeleton::isSaveNeeded() const { - KConfigSkeletonItem::List::ConstIterator it; - for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) { - if ((*it)->isSaveNeeded()) { - return true; - } - } - return false; + return std::any_of(d->mItems.cbegin(), d->mItems.cend(), [](KConfigSkeletonItem *skelItem) { + return skelItem->isSaveNeeded(); + }); } bool KCoreConfigSkeleton::save() { // qDebug(); - KConfigSkeletonItem::List::ConstIterator it; - for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) { - (*it)->writeConfig(d->mConfig.data()); + for (auto *skelItem : qAsConst(d->mItems)) { + skelItem->writeConfig(d->mConfig.data()); } + if (!usrSave()) { return false; } diff --git a/src/core/kcoreconfigskeleton_p.h b/src/core/kcoreconfigskeleton_p.h index d854cc43..a7417430 100644 --- a/src/core/kcoreconfigskeleton_p.h +++ b/src/core/kcoreconfigskeleton_p.h @@ -21,10 +21,7 @@ class KCoreConfigSkeletonPrivate } ~KCoreConfigSkeletonPrivate() { - KConfigSkeletonItem::List::ConstIterator it; - for (it = mItems.constBegin(); it != mItems.constEnd(); ++it) { - delete *it; - } + qDeleteAll(mItems); } QString mCurrentGroup; diff --git a/src/core/kdesktopfile.cpp b/src/core/kdesktopfile.cpp index d5029ffe..cae8b98d 100644 --- a/src/core/kdesktopfile.cpp +++ b/src/core/kdesktopfile.cpp @@ -8,20 +8,22 @@ #include "kdesktopfile.h" -#ifndef Q_OS_WIN -#include -#endif +#include "kauthorized.h" +#include "kconfig_core_log_settings.h" +#include "kconfig_p.h" +#include "kconfiggroup.h" +#include "kconfigini_p.h" #include #include #include #include -#include "kauthorized.h" -#include "kconfig_core_log_settings.h" -#include "kconfig_p.h" -#include "kconfiggroup.h" -#include "kconfigini_p.h" +#ifndef Q_OS_WIN +#include +#endif + +#include class KDesktopFilePrivate : public KConfigPrivate { @@ -281,17 +283,15 @@ bool KDesktopFile::tryExec() const } } const QStringList list = d->desktopGroup.readEntry("X-KDE-AuthorizeAction", QStringList()); - - if (!list.isEmpty()) { - for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it) { - if (!KAuthorized::authorize((*it).trimmed())) { - return false; - } - } + const auto isNotAuthorized = std::any_of(list.cbegin(), list.cend(), [](const QString &action) { + return !KAuthorized::authorize(action.trimmed()); + }); + if (isNotAuthorized) { + return false; } // See also KService::username() - bool su = d->desktopGroup.readEntry("X-KDE-SubstituteUID", false); + const bool su = d->desktopGroup.readEntry("X-KDE-SubstituteUID", false); if (su) { QString user = d->desktopGroup.readEntry("X-KDE-Username", QString()); if (user.isEmpty()) { diff --git a/src/core/kemailsettings.cpp b/src/core/kemailsettings.cpp index cfebe2a8..9074a0a2 100644 --- a/src/core/kemailsettings.cpp +++ b/src/core/kemailsettings.cpp @@ -227,9 +227,9 @@ KEMailSettings::KEMailSettings() p->m_pConfig = new KConfig(QStringLiteral("emaildefaults")); const QStringList groups = p->m_pConfig->groupList(); - for (QStringList::ConstIterator it = groups.begin(); it != groups.end(); ++it) { - if ((*it).startsWith(QLatin1String("PROFILE_"))) { - p->profiles += (*it).mid(8, (*it).length()); + for (const auto &grp : groups) { + if (grp.startsWith(QLatin1String("PROFILE_"))) { + p->profiles += grp.mid(8 /* length of "PROFILE_" */); } } diff --git a/src/kconf_update/kconf_update.cpp b/src/kconf_update/kconf_update.cpp index a08ecaae..d4f7e15e 100644 --- a/src/kconf_update/kconf_update.cpp +++ b/src/kconf_update/kconf_update.cpp @@ -169,8 +169,8 @@ KonfUpdate::KonfUpdate(QCommandLineParser *parser) cg.writeEntry("updateInfoAdded", true); updateFiles = findUpdateFiles(false); - for (QStringList::ConstIterator it = updateFiles.constBegin(); it != updateFiles.constEnd(); ++it) { - checkFile(*it); + for (const auto &file : qAsConst(updateFiles)) { + checkFile(file); } updateFiles.clear(); } @@ -689,8 +689,8 @@ void KonfUpdate::gotAllGroups() } const QStringList allGroups = m_oldConfig1->groupList(); - for (QStringList::ConstIterator it = allGroups.begin(); it != allGroups.end(); ++it) { - m_oldGroup = QStringList() << *it; + for (const auto &grp : allGroups) { + m_oldGroup = QStringList{grp}; m_newGroup = m_oldGroup; gotAllKeys(); } @@ -699,12 +699,12 @@ void KonfUpdate::gotAllGroups() void KonfUpdate::gotOptions(const QString &_options) { const QStringList options = _options.split(QLatin1Char{','}); - for (QStringList::ConstIterator it = options.begin(); it != options.end(); ++it) { - if ((*it).toLower().trimmed() == QLatin1String("copy")) { - m_bCopy = true; - } + for (const auto &opt : options) { + const auto normalizedOpt = opt.toLower().trimmed(); - if ((*it).toLower().trimmed() == QLatin1String("overwrite")) { + if (normalizedOpt == QLatin1String("copy")) { + m_bCopy = true; + } else if (normalizedOpt == QLatin1String("overwrite")) { m_bOverwrite = true; } } @@ -719,8 +719,8 @@ void KonfUpdate::copyGroup(const KConfigBase *cfg1, const QString &group1, KConf void KonfUpdate::copyGroup(const KConfigGroup &cg1, KConfigGroup &cg2) { // Copy keys - QMap list = cg1.entryMap(); - for (QMap::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it) { + const auto map = cg1.entryMap(); + for (auto it = map.cbegin(); it != map.cend(); ++it) { if (m_bOverwrite || !cg2.hasKey(it.key())) { cg2.writeEntry(it.key(), it.value()); } @@ -819,8 +819,8 @@ void KonfUpdate::gotScript(const QString &_script) if (m_oldGroup.isEmpty()) { // Write all entries to tmpFile; const QStringList grpList = m_oldConfig1->groupList(); - for (QStringList::ConstIterator it = grpList.begin(); it != grpList.end(); ++it) { - copyGroup(m_oldConfig1, *it, &cfg, *it); + for (const auto &grp : grpList) { + copyGroup(m_oldConfig1, grp, &cfg, grp); } } else { KConfigGroup cg1 = KConfigUtils::openGroup(m_oldConfig1, m_oldGroup); diff --git a/src/kconfig_compiler/KConfigHeaderGenerator.cpp b/src/kconfig_compiler/KConfigHeaderGenerator.cpp index 21eb51a5..08d383d8 100644 --- a/src/kconfig_compiler/KConfigHeaderGenerator.cpp +++ b/src/kconfig_compiler/KConfigHeaderGenerator.cpp @@ -254,8 +254,10 @@ void KConfigHeaderGenerator::createSignals() stream() << whitespace() << "*/\n"; } stream() << whitespace() << "void " << signal.name << "("; - QList::ConstIterator it, itEnd = signal.arguments.constEnd(); - for (it = signal.arguments.constBegin(); it != itEnd;) { + + auto it = signal.arguments.cbegin(); + const auto itEnd = signal.arguments.cend(); + while (it != itEnd) { Param argument = *it; QString type = param(argument.type); if (cfg().useEnumTypes && argument.type == QLatin1String("Enum")) { diff --git a/src/kconfig_compiler/KConfigSourceGenerator.cpp b/src/kconfig_compiler/KConfigSourceGenerator.cpp index ce6378cd..d308ffcd 100644 --- a/src/kconfig_compiler/KConfigSourceGenerator.cpp +++ b/src/kconfig_compiler/KConfigSourceGenerator.cpp @@ -214,8 +214,8 @@ void KConfigSourceGenerator::createConstructorParameterList() stream() << (parseResult.parameters.isEmpty() ? "" : ","); } - for (QList::ConstIterator it = parseResult.parameters.constBegin(); it != parseResult.parameters.constEnd(); ++it) { - if (it != parseResult.parameters.constBegin()) { + for (auto it = parseResult.parameters.cbegin(); it != parseResult.parameters.cend(); ++it) { + if (it != parseResult.parameters.cbegin()) { stream() << ","; } stream() << " " << param((*it).type) << " " << (*it).name; @@ -634,8 +634,9 @@ void KConfigSourceGenerator::createNonModifyingSignalsHelper() stream() << " if ( " << varPath(QStringLiteral("settingsChanged"), cfg()) << " & " << signalEnumName(signal.name) << " )\n"; stream() << " Q_EMIT " << signal.name << "("; - QList::ConstIterator it, itEnd = signal.arguments.constEnd(); - for (it = signal.arguments.constBegin(); it != itEnd;) { + auto it = signal.arguments.cbegin(); + const auto itEnd = signal.arguments.cend(); + while (it != itEnd) { Param argument = *it; bool cast = false; if (cfg().useEnumTypes && argument.type == QLatin1String("Enum")) { diff --git a/src/kconfig_compiler/KConfigXmlParser.cpp b/src/kconfig_compiler/KConfigXmlParser.cpp index 97d61342..7dc1d9f0 100644 --- a/src/kconfig_compiler/KConfigXmlParser.cpp +++ b/src/kconfig_compiler/KConfigXmlParser.cpp @@ -27,7 +27,7 @@ static void preProcessDefault(QString &defaultValue, const QString &name, const QString &type, - const CfgEntry::Choices &choices, + const CfgEntry::Choices &cfgChoices, QString &code, const KConfigParameters &cfg) { @@ -51,13 +51,12 @@ static void preProcessDefault(QString &defaultValue, cpp << " QStringList default" << name << ";\n"; } const QStringList defaults = defaultValue.split(QLatin1Char(',')); - QStringList::ConstIterator it; - for (it = defaults.constBegin(); it != defaults.constEnd(); ++it) { + for (const auto &val : defaults) { cpp << " default" << name << ".append( "; if (type == QLatin1String("UrlList")) { cpp << "QUrl::fromUserInput("; } - cpp << "QString::fromUtf8( \"" << *it << "\" ) "; + cpp << "QString::fromUtf8( \"" << val << "\" ) "; if (type == QLatin1String("UrlList")) { cpp << ") "; } @@ -66,7 +65,7 @@ static void preProcessDefault(QString &defaultValue, defaultValue = QLatin1String("default") + name; } else if (type == QLatin1String("Color") && !defaultValue.isEmpty()) { - const QRegularExpression colorRe(QRegularExpression::anchoredPattern(QStringLiteral("\\d+,\\s*\\d+,\\s*\\d+(,\\s*\\d+)?"))); + static const QRegularExpression colorRe(QRegularExpression::anchoredPattern(QStringLiteral("\\d+,\\s*\\d+,\\s*\\d+(,\\s*\\d+)?"))); if (colorRe.match(defaultValue).hasMatch()) { defaultValue = QLatin1String("QColor( ") + defaultValue + QLatin1String(" )"); @@ -75,13 +74,12 @@ static void preProcessDefault(QString &defaultValue, } } else if (type == QLatin1String("Enum")) { - QList::ConstIterator it; - for (it = choices.choices.constBegin(); it != choices.choices.constEnd(); ++it) { - if ((*it).name == defaultValue) { - if (cfg.globalEnums && choices.name().isEmpty()) { - defaultValue.prepend(choices.prefix); + for (const auto &choice : cfgChoices.choices) { + if (choice.name == defaultValue) { + if (cfg.globalEnums && cfgChoices.name().isEmpty()) { + defaultValue.prepend(cfgChoices.prefix); } else { - defaultValue.prepend(enumTypeQualifier(name, choices) + choices.prefix); + defaultValue.prepend(enumTypeQualifier(name, cfgChoices) + cfgChoices.prefix); } break; } @@ -96,9 +94,8 @@ static void preProcessDefault(QString &defaultValue, cpp << " QList default" << name << ";\n"; if (!defaultValue.isEmpty()) { const QStringList defaults = defaultValue.split(QLatin1Char(',')); - QStringList::ConstIterator it; - for (it = defaults.constBegin(); it != defaults.constEnd(); ++it) { - cpp << " default" << name << ".append( " << *it << " );\n"; + for (const auto &defaultVal : defaults) { + cpp << " default" << name << ".append( " << defaultVal << " );\n"; } } defaultValue = QLatin1String("default") + name; From 23f55a865bdc1b5f7f462b35e8788ea3e2cbc121 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Tue, 23 Feb 2021 16:23:22 +0200 Subject: [PATCH 126/259] kconfig_compiler: change how paramString() creates strings Now it creates C++ code that uses QString::arg(Args...) instead of arg().arg(). AFAICS, the type of the "Args" is QString, so this should work. --- autotests/kconfig_compiler/test1.cpp.ref | 2 +- src/kconfig_compiler/kconfig_compiler.cpp | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/autotests/kconfig_compiler/test1.cpp.ref b/autotests/kconfig_compiler/test1.cpp.ref index c0d94eef..16b1833b 100644 --- a/autotests/kconfig_compiler/test1.cpp.ref +++ b/autotests/kconfig_compiler/test1.cpp.ref @@ -63,7 +63,7 @@ Test1::Test1( const QString & transport, const QString & folder, QObject *parent itemMyStringListHidden = new KConfigSkeleton::ItemStringList( currentGroup(), QStringLiteral( "MyStringListHidden" ), mMyStringListHidden, defaultMyStringListHidden ); addItem( itemMyStringListHidden, QStringLiteral( "MyStringListHidden" ) ); KConfigSkeleton::ItemInt *itemMyNumber; - itemMyNumber = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "List-%1-%2" ).arg( mParamtransport ).arg( mParamfolder ), mMyNumber, 1 ); + itemMyNumber = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "List-%1-%2" ).arg( mParamtransport, mParamfolder ), mMyNumber, 1 ); addItem( itemMyNumber, QStringLiteral( "MyNumber" ) ); } diff --git a/src/kconfig_compiler/kconfig_compiler.cpp b/src/kconfig_compiler/kconfig_compiler.cpp index 50c54f8f..d278414e 100644 --- a/src/kconfig_compiler/kconfig_compiler.cpp +++ b/src/kconfig_compiler/kconfig_compiler.cpp @@ -490,19 +490,30 @@ QString paramString(const QString &group, const QList ¶meters) QString paramString = group; QString arguments; int i = 1; + bool firstArg = true; for (const auto ¶m : parameters) { const QString paramName = param.name; const QString str = QLatin1String{"$("} + paramName + QLatin1Char{')'}; if (paramString.contains(str)) { const QString tmp = QStringLiteral("%%1").arg(i++); paramString.replace(str, tmp); - // TODO: change the code here to get C++ code generated by KConfig to use - // QString::arg(QString, QString, QString) instead of QString().arg().arg() - arguments += QLatin1String{".arg( mParam"} + paramName + QLatin1String{" )"}; + + if (firstArg) { + arguments += QLatin1String{".arg( "}; + firstArg = false; + } + + arguments += QLatin1String{"mParam"} + paramName + QLatin1String{", "}; } } - if (arguments.isEmpty()) { + if (!arguments.isEmpty()) { + // Remove the last ", " + arguments.chop(2); + + // Close the ".arg( " + arguments += QLatin1String{" )"}; + } else { return QLatin1String{"QStringLiteral( \""} + group + QLatin1String{"\" )"}; } From d5ca63b954407b36c18c70e2ecace7b30694558d Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Tue, 23 Feb 2021 17:09:33 +0200 Subject: [PATCH 127/259] Improve code readability by using QLatin1String::arg() NO_CHANGELOG --- .../KConfigCodeGeneratorBase.cpp | 2 +- src/kconfig_compiler/KConfigXmlParser.cpp | 6 +- src/kconfig_compiler/kconfig_compiler.cpp | 69 +++++++++---------- 3 files changed, 35 insertions(+), 42 deletions(-) diff --git a/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp b/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp index 5d7f57be..f1ff06b3 100644 --- a/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp +++ b/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp @@ -180,7 +180,7 @@ void KConfigCodeGeneratorBase::memberImmutableBody(const CfgEntry *e, bool globa { stream() << whitespace() << "return " << m_this << "isImmutable( QStringLiteral( \""; if (!e->param.isEmpty()) { - stream() << QString(e->paramName).replace(QLatin1String("$(") + e->param + QLatin1Char(')'), QLatin1String("%1")) << "\" ).arg( "; + stream() << QString(e->paramName).replace(QLatin1String("$(%1)").arg(e->param), QLatin1String("%1")) << "\" ).arg( "; if (e->paramType == QLatin1String("Enum")) { stream() << "QLatin1String( "; diff --git a/src/kconfig_compiler/KConfigXmlParser.cpp b/src/kconfig_compiler/KConfigXmlParser.cpp index 7dc1d9f0..9815d1cd 100644 --- a/src/kconfig_compiler/KConfigXmlParser.cpp +++ b/src/kconfig_compiler/KConfigXmlParser.cpp @@ -38,7 +38,7 @@ static void preProcessDefault(QString &defaultValue, defaultValue = literalString(defaultValue); } else if (type == QLatin1String("Url") && !defaultValue.isEmpty()) { // Use fromUserInput in order to support absolute paths and absolute urls, like KDE4's KUrl(QString) did. - defaultValue = QLatin1String("QUrl::fromUserInput( ") + literalString(defaultValue) + QLatin1Char(')'); + defaultValue = QLatin1String("QUrl::fromUserInput( %1)").arg(literalString(defaultValue)); } else if ((type == QLatin1String("UrlList") || type == QLatin1String("StringList") || type == QLatin1String("PathList")) && !defaultValue.isEmpty()) { QTextStream cpp(&code, QIODevice::WriteOnly | QIODevice::Append); if (!code.isEmpty()) { @@ -68,9 +68,9 @@ static void preProcessDefault(QString &defaultValue, static const QRegularExpression colorRe(QRegularExpression::anchoredPattern(QStringLiteral("\\d+,\\s*\\d+,\\s*\\d+(,\\s*\\d+)?"))); if (colorRe.match(defaultValue).hasMatch()) { - defaultValue = QLatin1String("QColor( ") + defaultValue + QLatin1String(" )"); + defaultValue = QLatin1String("QColor( %1 )").arg(defaultValue); } else { - defaultValue = QLatin1String("QColor( \"") + defaultValue + QLatin1String("\" )"); + defaultValue = QLatin1String("QColor( \"%1\" )").arg(defaultValue); } } else if (type == QLatin1String("Enum")) { diff --git a/src/kconfig_compiler/kconfig_compiler.cpp b/src/kconfig_compiler/kconfig_compiler.cpp index d278414e..e997eac9 100644 --- a/src/kconfig_compiler/kconfig_compiler.cpp +++ b/src/kconfig_compiler/kconfig_compiler.cpp @@ -119,11 +119,11 @@ QString changeSignalName(const QString &n) QString getDefaultFunction(const QString &n, const QString &className) { - QString result = QLatin1String("default") + n + QLatin1String("Value"); + QString result = QLatin1String("default%1Value").arg(n); result[7] = result.at(7).toUpper(); if (!className.isEmpty()) { - result = className + QLatin1String("::") + result; + result.prepend(className + QLatin1String("::")); } return result; } @@ -134,7 +134,7 @@ QString getFunction(const QString &n, const QString &className) result[0] = result.at(0).toLower(); if (!className.isEmpty()) { - result = className + QLatin1String("::") + result; + result.prepend(className + QLatin1String("::")); } return result; } @@ -146,7 +146,7 @@ QString immutableFunction(const QString &n, const QString &className) result += QLatin1String{"Immutable"}; if (!className.isEmpty()) { - result = className + QLatin1String("::") + result; + result.prepend(className + QLatin1String("::")); } return result; } @@ -178,9 +178,9 @@ QString literalString(const QString &str) }); if (isAscii) { - return QLatin1String{"QStringLiteral( "} + quoteString(str) + QLatin1String{" )"}; + return QLatin1String("QStringLiteral( %1 )").arg(quoteString(str)); } else { - return QLatin1String{"QString::fromUtf8( "} + quoteString(str) + QLatin1String{" )"}; + return QLatin1String("QString::fromUtf8( %1 )").arg(quoteString(str)); } } @@ -384,11 +384,11 @@ QString itemDeclaration(const CfgEntry *e, const KConfigParameters &cfg) if (!cfg.itemAccessors && !cfg.dpointer) { result += QLatin1String{" "} + (!e->signalList.isEmpty() ? QStringLiteral("KConfigCompilerSignallingItem") : type); - result += QLatin1String{" *item"} + fCap + argSuffix + QLatin1String{";\n"}; + result += QLatin1String(" *item%1;\n").arg(fCap + argSuffix); } if (!e->signalList.isEmpty()) { - result += QLatin1String{" "} + type + QLatin1String{" *"} + innerItemVar(e, cfg) + argSuffix + QLatin1String{";\n"}; + result += QLatin1String(" %1 *%2;\n").arg(type, innerItemVar(e, cfg) + argSuffix); } return result; @@ -402,7 +402,7 @@ QString itemVar(const CfgEntry *e, const KConfigParameters &cfg) QString result; if (cfg.itemAccessors) { if (!cfg.dpointer) { - result = QLatin1Char{'m'} + e->name + QLatin1String{"Item"}; + result = QLatin1String("m%1Item").arg(e->name); result[1] = result.at(1).toUpper(); } else { result = e->name + QLatin1String{"Item"}; @@ -436,18 +436,18 @@ QString itemPath(const CfgEntry *e, const KConfigParameters &cfg) QString newInnerItem(const CfgEntry *entry, const QString &key, const QString &defaultValue, const KConfigParameters &cfg, const QString ¶m) { - QString t = QLatin1String{"new "} + cfg.inherits + QLatin1String{"::Item"} + itemType(entry->type); - t += QLatin1String{"( currentGroup(), "} + key + QLatin1String{", "} + varPath(entry->name, cfg) + param; + QString str = QLatin1String("new %1::Item%2").arg(cfg.inherits, itemType(entry->type)); + str += QLatin1String("( currentGroup(), %1, %2").arg(key, varPath(entry->name, cfg) + param); if (entry->type == QLatin1String("Enum")) { - t += QLatin1String{", values"} + entry->name; + str += QLatin1String{", values"} + entry->name; } if (!defaultValue.isEmpty()) { - t += QLatin1String(", ") + defaultValue; + str += QLatin1String(", ") + defaultValue; } - t += QLatin1String(" );"); + str += QLatin1String(" );"); - return t; + return str; } QString newItem(const CfgEntry *entry, const QString &key, const QString &defaultValue, const KConfigParameters &cfg, const QString ¶m) @@ -458,8 +458,7 @@ QString newItem(const CfgEntry *entry, const QString &key, const QString &defaul } QString str; - str += QLatin1String("new KConfigCompilerSignallingItem(") + innerItemVar(entry, cfg) + param; - str += QLatin1String(", this, notifyFunction, "); + str += QLatin1String("new KConfigCompilerSignallingItem(%1, this, notifyFunction, ").arg(innerItemVar(entry, cfg) + param); // Append the signal flags const int listSize = sigs.size(); for (int i = 0; i < listSize; ++i) { @@ -476,7 +475,7 @@ QString newItem(const CfgEntry *entry, const QString &key, const QString &defaul QString paramString(const QString &s, const CfgEntry *e, int i) { QString result = s; - const QString needle = QLatin1String{"$("} + e->param + QLatin1Char{')'}; + const QString needle = QLatin1String("$(%1)").arg(e->param); if (result.contains(needle)) { const QString tmp = e->paramType == QLatin1String{"Enum"} ? e->paramValues.at(i) : QString::number(i); @@ -493,7 +492,7 @@ QString paramString(const QString &group, const QList ¶meters) bool firstArg = true; for (const auto ¶m : parameters) { const QString paramName = param.name; - const QString str = QLatin1String{"$("} + paramName + QLatin1Char{')'}; + const QString str = QLatin1String("$(%1)").arg(paramName); if (paramString.contains(str)) { const QString tmp = QStringLiteral("%%1").arg(i++); paramString.replace(str, tmp); @@ -503,7 +502,7 @@ QString paramString(const QString &group, const QList ¶meters) firstArg = false; } - arguments += QLatin1String{"mParam"} + paramName + QLatin1String{", "}; + arguments += QLatin1String("mParam%1, ").arg(paramName); } } @@ -514,10 +513,10 @@ QString paramString(const QString &group, const QList ¶meters) // Close the ".arg( " arguments += QLatin1String{" )"}; } else { - return QLatin1String{"QStringLiteral( \""} + group + QLatin1String{"\" )"}; + return QLatin1String("QStringLiteral( \"%1\" )").arg(group); } - return QLatin1String{"QStringLiteral( \""} + paramString + QLatin1String{"\" )"} + arguments; + return QLatin1String("QStringLiteral( \"%1\" )%2").arg(paramString, arguments); } QString translatedString(const KConfigParameters &cfg, const QString &string, const QString &context, const QString ¶m, const QString ¶mValue) @@ -527,20 +526,20 @@ QString translatedString(const KConfigParameters &cfg, const QString &string, co switch (cfg.translationSystem) { case KConfigParameters::QtTranslation: if (!context.isEmpty()) { - result += QLatin1String{"/*: "} + context + QLatin1String{" */ QCoreApplication::translate(\""}; + result += QLatin1String("/*: %1 */ QCoreApplication::translate(\"").arg(context); } else { result += QLatin1String{"QCoreApplication::translate(\""}; } - result += cfg.className + QLatin1String{"\", "}; + result += QLatin1String("%1\", ").arg(cfg.className); break; case KConfigParameters::KdeTranslation: if (!cfg.translationDomain.isEmpty() && !context.isEmpty()) { - result += QLatin1String{"i18ndc("} + quoteString(cfg.translationDomain) + QLatin1String{", "} + quoteString(context) + QLatin1String{", "}; + result += QLatin1String("i18ndc(%1, %2, ").arg(quoteString(cfg.translationDomain), quoteString(context)); } else if (!cfg.translationDomain.isEmpty()) { - result += QLatin1String{"i18nd("} + quoteString(cfg.translationDomain) + QLatin1String{", "}; + result += QLatin1String("i18nd(%1, ").arg(quoteString(cfg.translationDomain)); } else if (!context.isEmpty()) { - result += QLatin1String{"i18nc("} + quoteString(context) + QLatin1String{", "}; + result += QLatin1String("i18nc(%1, ").arg(quoteString(context)); } else { result += QLatin1String{"i18n("}; } @@ -549,7 +548,7 @@ QString translatedString(const KConfigParameters &cfg, const QString &string, co if (!param.isEmpty()) { QString resolvedString = string; - resolvedString.replace(QLatin1String{"$("} + param + QLatin1Char{')'}, paramValue); + resolvedString.replace(QLatin1String("$(%1)").arg(param), paramValue); result += quoteString(resolvedString); } else { result += quoteString(string); @@ -568,19 +567,13 @@ QString userTextsFunctions(const CfgEntry *e, const KConfigParameters &cfg, QStr itemVarStr = itemPath(e, cfg); } if (!e->label.isEmpty()) { - txt += QLatin1String{" "} + itemVarStr + QLatin1String{"->setLabel( "}; - txt += translatedString(cfg, e->label, e->labelContext, e->param, i); - txt += QLatin1String(" );\n"); + txt += QLatin1String(" %1->setLabel( %2 );\n").arg(itemVarStr, translatedString(cfg, e->label, e->labelContext, e->param, i)); } if (!e->toolTip.isEmpty()) { - txt += QLatin1String{" "} + itemVarStr + QLatin1String{"->setToolTip( "}; - txt += translatedString(cfg, e->toolTip, e->toolTipContext, e->param, i); - txt += QLatin1String(" );\n"); + txt += QLatin1String(" %1->setToolTip( %2 );\n").arg(itemVarStr, translatedString(cfg, e->toolTip, e->toolTipContext, e->param, i)); } if (!e->whatsThis.isEmpty()) { - txt += QLatin1String{" "} + itemVarStr + QLatin1String{"->setWhatsThis( "}; - txt += translatedString(cfg, e->whatsThis, e->whatsThisContext, e->param, i); - txt += QLatin1String(" );\n"); + txt += QLatin1String(" %1->setWhatsThis( %2 );\n").arg(itemVarStr, translatedString(cfg, e->whatsThis, e->whatsThisContext, e->param, i)); } return txt; } @@ -617,7 +610,7 @@ QString memberGetDefaultBody(const CfgEntry *e) QString defaultValue = e->defaultValue; out << " default:\n"; - out << " return " << defaultValue.replace(QLatin1String{"$("} + e->param + QLatin1Char{')'}, QLatin1String("i")) << ";\n"; + out << " return " << defaultValue.replace(QLatin1String("$(%1)").arg(e->param), QLatin1String("i")) << ";\n"; out << " }\n"; } else { out << " return " << e->defaultValue << ';'; From 0c1df8be22339319ee4921d2b89c44504ea3b3b6 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Mon, 15 Mar 2021 14:33:12 +0000 Subject: [PATCH 128/259] GIT_SILENT Upgrade KF version to 5.81.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9cc3f6e9..1ab61932 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.5) -set(KF_VERSION "5.80.0") # handled by release scripts +set(KF_VERSION "5.81.0") # handled by release scripts project(KConfig VERSION ${KF_VERSION}) include(FeatureSummary) From fee82b7f093cfdcfd217582df18ff41721e6e120 Mon Sep 17 00:00:00 2001 From: David Hurka Date: Tue, 16 Mar 2021 18:37:50 +0100 Subject: [PATCH 129/259] Remove old contact data from src/kconfig_compiler_README.dox --- src/kconfig_compiler/README.dox | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/kconfig_compiler/README.dox b/src/kconfig_compiler/README.dox index 90dd4597..89b29520 100644 --- a/src/kconfig_compiler/README.dox +++ b/src/kconfig_compiler/README.dox @@ -512,7 +512,4 @@ for a signal, the signal name will suffice. You can also use the generic configChanged() signal from KConfigSkeleton to notify your application about configuration changes. - -If you have questions or comments please contact Cornelius Schumacher - or Waldo Bastian */ From ce350dfdd9d32849346c5b89fffa4f553b94188b Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Wed, 17 Mar 2021 01:09:33 +0100 Subject: [PATCH 130/259] [kconfig_compiler] Explicitly open input file for reading In Qt6 QDomDocument does not open the file itself any more --- src/kconfig_compiler/KConfigXmlParser.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/kconfig_compiler/KConfigXmlParser.cpp b/src/kconfig_compiler/KConfigXmlParser.cpp index 9815d1cd..5b2fb775 100644 --- a/src/kconfig_compiler/KConfigXmlParser.cpp +++ b/src/kconfig_compiler/KConfigXmlParser.cpp @@ -13,6 +13,7 @@ #include "KConfigXmlParser.h" +#include #include #include #include @@ -446,6 +447,9 @@ KConfigXmlParser::KConfigXmlParser(const KConfigParameters &cfg, const QString & void KConfigXmlParser::start() { QFile input(mInputFileName); + if (!input.open(QIODevice::ReadOnly)) { + qFatal("Could not open input file: %s", qUtf8Printable(mInputFileName)); + } QDomDocument doc; QString errorMsg; int errorRow; From ecf02500cf822c7fb026059778de4f58c24baa66 Mon Sep 17 00:00:00 2001 From: Andreas Cord-Landwehr Date: Sun, 28 Mar 2021 09:53:31 +0200 Subject: [PATCH 131/259] Relicense file to LGPL-2.0-or-later Relicense approved by relicensecheck except: - lgplv2+: a.volkov@rusbitech.ru a.volkov@rusbitech.ru ( 1 LOC): d328dd6 Which is a non-copyrightible trivial change. --- autotests/kdesktopfiletest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autotests/kdesktopfiletest.h b/autotests/kdesktopfiletest.h index 6bf97bf8..04403794 100644 --- a/autotests/kdesktopfiletest.h +++ b/autotests/kdesktopfiletest.h @@ -1,7 +1,7 @@ /* SPDX-FileCopyrightText: 2006 David Faure - SPDX-License-Identifier: LGPL-2.0-only + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KDESKTOPFILETEST_H From e5aa388ede0750d78b0e70bef4ef86fd5514687c Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 3 Apr 2021 09:29:42 +0000 Subject: [PATCH 132/259] GIT_SILENT Upgrade ECM and KF version requirements for 5.81.0 release. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ab61932..10578ebd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ set(KF_VERSION "5.81.0") # handled by release scripts project(KConfig VERSION ${KF_VERSION}) include(FeatureSummary) -find_package(ECM 5.80.0 NO_MODULE) +find_package(ECM 5.81.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) From 6b99fccf95382d887ad9695ed4972a82cd31cebc Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 4 Apr 2021 14:41:01 +0200 Subject: [PATCH 133/259] GIT_SILENT Upgrade Qt5 version requirement to 5.15.0. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 10578ebd..c83d2e6d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKA set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) -set(REQUIRED_QT_VERSION 5.14.0) +set(REQUIRED_QT_VERSION 5.15.0) find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Xml) option(KCONFIG_USE_GUI "Build components using Qt5Gui" ON) @@ -52,7 +52,7 @@ ecm_setup_version(PROJECT VARIABLE_PREFIX KCONFIG SOVERSION 5) add_definitions(-DQT_NO_FOREACH) -add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050e00) +add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050f00) add_subdirectory(src) if (BUILD_TESTING) From 05bf9bd074ab254e42400e7d42db6e06dd977953 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 4 Apr 2021 19:17:34 +0200 Subject: [PATCH 134/259] autotests: look for cmd, not bash, on Windows --- autotests/kdesktopfiletest.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/autotests/kdesktopfiletest.cpp b/autotests/kdesktopfiletest.cpp index cadc3b3d..b8235606 100644 --- a/autotests/kdesktopfiletest.cpp +++ b/autotests/kdesktopfiletest.cpp @@ -227,8 +227,13 @@ void KDesktopFileTest::testTryExecWithAuthorizeAction() "Type=Application\n" "Name=My Application\n" "Exec=kfoo\n" - "TryExec=bash\n" - "X-KDE-AuthorizeAction=someAction" + "TryExec="; +#ifdef Q_OS_WIN + ts << "cmd\n"; +#else + ts << "bash\n"; +#endif + ts << "X-KDE-AuthorizeAction=someAction" "\n"; file.close(); From 27f1d268d9f960b72081b74b0688fdc5fc212ff5 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 4 Apr 2021 13:52:53 +0200 Subject: [PATCH 135/259] kconfig_compiler: add override to generated destructors This fixes the clang warning globalsettings_kmail.h:58:5: warning: '~GlobalSettingsBase' overrides a destructor but is not marked 'override' [-Wsuggest-destructor-override] --- autotests/kconfig_compiler/test1.h.ref | 2 +- autotests/kconfig_compiler/test10.h.ref | 2 +- autotests/kconfig_compiler/test11.h.ref | 2 +- autotests/kconfig_compiler/test11a.h.ref | 2 +- autotests/kconfig_compiler/test12.h.ref | 2 +- autotests/kconfig_compiler/test13.h.ref | 2 +- autotests/kconfig_compiler/test2.h.ref | 2 +- autotests/kconfig_compiler/test3.h.ref | 2 +- autotests/kconfig_compiler/test3a.h.ref | 2 +- autotests/kconfig_compiler/test4.h.ref | 2 +- autotests/kconfig_compiler/test5.h.ref | 2 +- autotests/kconfig_compiler/test6.h.ref | 2 +- autotests/kconfig_compiler/test7.h.ref | 2 +- autotests/kconfig_compiler/test8a.h.ref | 2 +- autotests/kconfig_compiler/test8b.h.ref | 2 +- autotests/kconfig_compiler/test8c.h.ref | 2 +- autotests/kconfig_compiler/test9.h.ref | 2 +- autotests/kconfig_compiler/test_dpointer.h.ref | 2 +- autotests/kconfig_compiler/test_emptyentries.h.ref | 2 +- autotests/kconfig_compiler/test_notifiers.h.ref | 2 +- autotests/kconfig_compiler/test_param_minmax.h.ref | 2 +- autotests/kconfig_compiler/test_properties_minmax.h.ref | 2 +- autotests/kconfig_compiler/test_qdebugcategory.h.ref | 2 +- autotests/kconfig_compiler/test_signal.h.ref | 2 +- autotests/kconfig_compiler/test_subgroups.h.ref | 2 +- autotests/kconfig_compiler/test_translation_kde.h.ref | 2 +- autotests/kconfig_compiler/test_translation_kde_domain.h.ref | 2 +- autotests/kconfig_compiler/test_translation_qt.h.ref | 2 +- src/kconfig_compiler/KConfigHeaderGenerator.cpp | 2 +- 29 files changed, 29 insertions(+), 29 deletions(-) diff --git a/autotests/kconfig_compiler/test1.h.ref b/autotests/kconfig_compiler/test1.h.ref index 24500176..b8c5df0d 100644 --- a/autotests/kconfig_compiler/test1.h.ref +++ b/autotests/kconfig_compiler/test1.h.ref @@ -19,7 +19,7 @@ class Test1 : public KConfigSkeleton }; Test1( const QString & transport, const QString & folder, QObject *parent = nullptr ); - ~Test1(); + ~Test1() override; /** Set One option diff --git a/autotests/kconfig_compiler/test10.h.ref b/autotests/kconfig_compiler/test10.h.ref index a06bd162..4a2c8f69 100644 --- a/autotests/kconfig_compiler/test10.h.ref +++ b/autotests/kconfig_compiler/test10.h.ref @@ -12,7 +12,7 @@ class Test10 : public KConfigSkeleton public: static Test10 *self(); - ~Test10(); + ~Test10() override; /** Get foo bar diff --git a/autotests/kconfig_compiler/test11.h.ref b/autotests/kconfig_compiler/test11.h.ref index 786858dc..ab68dab6 100644 --- a/autotests/kconfig_compiler/test11.h.ref +++ b/autotests/kconfig_compiler/test11.h.ref @@ -23,7 +23,7 @@ class Test11 : public MyPrefs enum MailClient { sendmail, kmail }; Test11( QObject *parent = nullptr ); - ~Test11(); + ~Test11() override; /** Set Enable automatic saving of calendar diff --git a/autotests/kconfig_compiler/test11a.h.ref b/autotests/kconfig_compiler/test11a.h.ref index 014501cd..1f36c52d 100644 --- a/autotests/kconfig_compiler/test11a.h.ref +++ b/autotests/kconfig_compiler/test11a.h.ref @@ -23,7 +23,7 @@ class Test11a : public MyPrefs enum MailClient { sendmail, kmail }; Test11a( ); - ~Test11a(); + ~Test11a() override; /** Set Enable automatic saving of calendar diff --git a/autotests/kconfig_compiler/test12.h.ref b/autotests/kconfig_compiler/test12.h.ref index cd4c188e..16eba805 100644 --- a/autotests/kconfig_compiler/test12.h.ref +++ b/autotests/kconfig_compiler/test12.h.ref @@ -13,7 +13,7 @@ class Test12 : public KConfigSkeleton public: Test12( ); - ~Test12(); + ~Test12() override; /** Get RnRSource diff --git a/autotests/kconfig_compiler/test13.h.ref b/autotests/kconfig_compiler/test13.h.ref index 45863900..34e97f7c 100644 --- a/autotests/kconfig_compiler/test13.h.ref +++ b/autotests/kconfig_compiler/test13.h.ref @@ -14,7 +14,7 @@ class Test13 : public KConfigSkeleton public: Test13( ); - ~Test13(); + ~Test13() override; Q_PROPERTY(QUrl picturesDir READ picturesDir CONSTANT) Q_PROPERTY(bool isPicturesDirImmutable READ isPicturesDirImmutable CONSTANT) diff --git a/autotests/kconfig_compiler/test2.h.ref b/autotests/kconfig_compiler/test2.h.ref index 75d850d7..26b6568e 100644 --- a/autotests/kconfig_compiler/test2.h.ref +++ b/autotests/kconfig_compiler/test2.h.ref @@ -16,7 +16,7 @@ class Test2 : public MyPrefs enum EnumDestination { standardDestination, askDestination, argl1, argl2, argl3 }; Test2( ); - ~Test2(); + ~Test2() override; /** Set Enable automatic saving of calendar diff --git a/autotests/kconfig_compiler/test3.h.ref b/autotests/kconfig_compiler/test3.h.ref index 7dde3de0..ed449fdf 100644 --- a/autotests/kconfig_compiler/test3.h.ref +++ b/autotests/kconfig_compiler/test3.h.ref @@ -15,7 +15,7 @@ class Test3 : public KConfigSkeleton public: Test3( ); - ~Test3(); + ~Test3() override; /** Set Enable automatic saving of calendar diff --git a/autotests/kconfig_compiler/test3a.h.ref b/autotests/kconfig_compiler/test3a.h.ref index 3cdf1677..ef0d1c78 100644 --- a/autotests/kconfig_compiler/test3a.h.ref +++ b/autotests/kconfig_compiler/test3a.h.ref @@ -16,7 +16,7 @@ class Test3a : public KConfigSkeleton public: Test3a( ); - ~Test3a(); + ~Test3a() override; /** Set Enable automatic saving of calendar diff --git a/autotests/kconfig_compiler/test4.h.ref b/autotests/kconfig_compiler/test4.h.ref index 32e351ca..6439ac35 100644 --- a/autotests/kconfig_compiler/test4.h.ref +++ b/autotests/kconfig_compiler/test4.h.ref @@ -23,7 +23,7 @@ class Test4 : public KConfigSkeleton }; static Test4 *self(); - ~Test4(); + ~Test4() override; /** Set Block colors. diff --git a/autotests/kconfig_compiler/test5.h.ref b/autotests/kconfig_compiler/test5.h.ref index 96e5c143..a0938584 100644 --- a/autotests/kconfig_compiler/test5.h.ref +++ b/autotests/kconfig_compiler/test5.h.ref @@ -15,7 +15,7 @@ class Test5 : public KConfigSkeleton static const char* const EnumButtonToString[]; static Test5 *self(); - ~Test5(); + ~Test5() override; /** Set Block colors. diff --git a/autotests/kconfig_compiler/test6.h.ref b/autotests/kconfig_compiler/test6.h.ref index 6084e7dc..e21b33a9 100644 --- a/autotests/kconfig_compiler/test6.h.ref +++ b/autotests/kconfig_compiler/test6.h.ref @@ -12,7 +12,7 @@ class Test6 : public KConfigSkeleton public: Test6( const QString & Number ); - ~Test6(); + ~Test6() override; /** Set Block colors. diff --git a/autotests/kconfig_compiler/test7.h.ref b/autotests/kconfig_compiler/test7.h.ref index c2dccf90..7b339b5c 100644 --- a/autotests/kconfig_compiler/test7.h.ref +++ b/autotests/kconfig_compiler/test7.h.ref @@ -12,7 +12,7 @@ class Test7 : public KConfigSkeleton public: Test7( int Number ); - ~Test7(); + ~Test7() override; /** Set Block colors. diff --git a/autotests/kconfig_compiler/test8a.h.ref b/autotests/kconfig_compiler/test8a.h.ref index 9e9c0f4e..0334e8cd 100644 --- a/autotests/kconfig_compiler/test8a.h.ref +++ b/autotests/kconfig_compiler/test8a.h.ref @@ -13,7 +13,7 @@ class Test8a : public KConfigSkeleton public: Test8a( KSharedConfig::Ptr config = KSharedConfig::openConfig(), QObject *parent = nullptr ); - ~Test8a(); + ~Test8a() override; /** Set Font diff --git a/autotests/kconfig_compiler/test8b.h.ref b/autotests/kconfig_compiler/test8b.h.ref index 793c6851..7c671be3 100644 --- a/autotests/kconfig_compiler/test8b.h.ref +++ b/autotests/kconfig_compiler/test8b.h.ref @@ -14,7 +14,7 @@ class Test8b : public Test8a public: static Test8b *self(); - ~Test8b(); + ~Test8b() override; /** Set Something diff --git a/autotests/kconfig_compiler/test8c.h.ref b/autotests/kconfig_compiler/test8c.h.ref index 7e96da0b..44528747 100644 --- a/autotests/kconfig_compiler/test8c.h.ref +++ b/autotests/kconfig_compiler/test8c.h.ref @@ -14,7 +14,7 @@ class Test8c : public KConfigSkeleton static Test8c *self(); static void instance(const QString& cfgfilename); static void instance(KSharedConfig::Ptr config); - ~Test8c(); + ~Test8c() override; /** Set Font diff --git a/autotests/kconfig_compiler/test9.h.ref b/autotests/kconfig_compiler/test9.h.ref index 7c95b1d1..84fbbf30 100644 --- a/autotests/kconfig_compiler/test9.h.ref +++ b/autotests/kconfig_compiler/test9.h.ref @@ -14,7 +14,7 @@ class Test9 : public KConfigSkeleton public: Test9( const QString & transport, const QString & folder ); - ~Test9(); + ~Test9() override; /** Set MyStringList diff --git a/autotests/kconfig_compiler/test_dpointer.h.ref b/autotests/kconfig_compiler/test_dpointer.h.ref index a0886a07..4b7c86ea 100644 --- a/autotests/kconfig_compiler/test_dpointer.h.ref +++ b/autotests/kconfig_compiler/test_dpointer.h.ref @@ -19,7 +19,7 @@ class TestDPointer : public KConfigSkeleton }; static TestDPointer *self(); - ~TestDPointer(); + ~TestDPointer() override; /** Set Enable automatic saving of calendar diff --git a/autotests/kconfig_compiler/test_emptyentries.h.ref b/autotests/kconfig_compiler/test_emptyentries.h.ref index c2481e2d..65d5c7da 100644 --- a/autotests/kconfig_compiler/test_emptyentries.h.ref +++ b/autotests/kconfig_compiler/test_emptyentries.h.ref @@ -15,7 +15,7 @@ class QMakeBuilderSettings : public KConfigSkeleton static QMakeBuilderSettings *self(); static void instance(const QString& cfgfilename); static void instance(KSharedConfig::Ptr config); - ~QMakeBuilderSettings(); + ~QMakeBuilderSettings() override; protected: QMakeBuilderSettings(KSharedConfig::Ptr config); diff --git a/autotests/kconfig_compiler/test_notifiers.h.ref b/autotests/kconfig_compiler/test_notifiers.h.ref index 6d73b7d0..8e059d94 100644 --- a/autotests/kconfig_compiler/test_notifiers.h.ref +++ b/autotests/kconfig_compiler/test_notifiers.h.ref @@ -12,7 +12,7 @@ class TestNotifiers : public KConfigSkeleton public: TestNotifiers( int Number ); - ~TestNotifiers(); + ~TestNotifiers() override; /** Set Block colors. diff --git a/autotests/kconfig_compiler/test_param_minmax.h.ref b/autotests/kconfig_compiler/test_param_minmax.h.ref index 3cc8717c..a0f93ba7 100644 --- a/autotests/kconfig_compiler/test_param_minmax.h.ref +++ b/autotests/kconfig_compiler/test_param_minmax.h.ref @@ -13,7 +13,7 @@ class TestParamMinMax : public KConfigSkeleton public: TestParamMinMax( KSharedConfig::Ptr config = KSharedConfig::openConfig() ); - ~TestParamMinMax(); + ~TestParamMinMax() override; /** Set foo_#$(myparam) diff --git a/autotests/kconfig_compiler/test_properties_minmax.h.ref b/autotests/kconfig_compiler/test_properties_minmax.h.ref index 5f222320..e8be4382 100644 --- a/autotests/kconfig_compiler/test_properties_minmax.h.ref +++ b/autotests/kconfig_compiler/test_properties_minmax.h.ref @@ -14,7 +14,7 @@ class TestPropertiesMinMax : public KConfigSkeleton public: TestPropertiesMinMax( KSharedConfig::Ptr config = KSharedConfig::openConfig() ); - ~TestPropertiesMinMax(); + ~TestPropertiesMinMax() override; /** Set bar diff --git a/autotests/kconfig_compiler/test_qdebugcategory.h.ref b/autotests/kconfig_compiler/test_qdebugcategory.h.ref index cf7e3dbf..9a979fb9 100644 --- a/autotests/kconfig_compiler/test_qdebugcategory.h.ref +++ b/autotests/kconfig_compiler/test_qdebugcategory.h.ref @@ -14,7 +14,7 @@ class TestQCategory : public KConfigSkeleton public: TestQCategory( int Number ); - ~TestQCategory(); + ~TestQCategory() override; /** Set Block colors. diff --git a/autotests/kconfig_compiler/test_signal.h.ref b/autotests/kconfig_compiler/test_signal.h.ref index ef106a8d..fe2e1732 100644 --- a/autotests/kconfig_compiler/test_signal.h.ref +++ b/autotests/kconfig_compiler/test_signal.h.ref @@ -13,7 +13,7 @@ class TestSignal : public KConfigSkeleton public: static TestSignal *self(); - ~TestSignal(); + ~TestSignal() override; /** Set Current emoticon theme. diff --git a/autotests/kconfig_compiler/test_subgroups.h.ref b/autotests/kconfig_compiler/test_subgroups.h.ref index 11665710..c8a1c253 100644 --- a/autotests/kconfig_compiler/test_subgroups.h.ref +++ b/autotests/kconfig_compiler/test_subgroups.h.ref @@ -12,7 +12,7 @@ class TestSubgroups : public KConfigSkeleton public: TestSubgroups( const QString & GeneralGroup, const QString & SubGroup, const QString & AnotherSubGroup ); - ~TestSubgroups(); + ~TestSubgroups() override; /** Get Foo diff --git a/autotests/kconfig_compiler/test_translation_kde.h.ref b/autotests/kconfig_compiler/test_translation_kde.h.ref index 781cdcea..623ba6a6 100644 --- a/autotests/kconfig_compiler/test_translation_kde.h.ref +++ b/autotests/kconfig_compiler/test_translation_kde.h.ref @@ -15,7 +15,7 @@ class TestTranslationKde : public KConfigSkeleton public: TestTranslationKde( ); - ~TestTranslationKde(); + ~TestTranslationKde() override; /** Get Enable automatic saving of calendar diff --git a/autotests/kconfig_compiler/test_translation_kde_domain.h.ref b/autotests/kconfig_compiler/test_translation_kde_domain.h.ref index 38634817..dd98915b 100644 --- a/autotests/kconfig_compiler/test_translation_kde_domain.h.ref +++ b/autotests/kconfig_compiler/test_translation_kde_domain.h.ref @@ -15,7 +15,7 @@ class TestTranslationKdeDomain : public KConfigSkeleton public: TestTranslationKdeDomain( ); - ~TestTranslationKdeDomain(); + ~TestTranslationKdeDomain() override; /** Get Enable automatic saving of calendar diff --git a/autotests/kconfig_compiler/test_translation_qt.h.ref b/autotests/kconfig_compiler/test_translation_qt.h.ref index 11590509..dd134537 100644 --- a/autotests/kconfig_compiler/test_translation_qt.h.ref +++ b/autotests/kconfig_compiler/test_translation_qt.h.ref @@ -15,7 +15,7 @@ class TestTranslationQt : public KConfigSkeleton public: TestTranslationQt( ); - ~TestTranslationQt(); + ~TestTranslationQt() override; /** Get Enable automatic saving of calendar diff --git a/src/kconfig_compiler/KConfigHeaderGenerator.cpp b/src/kconfig_compiler/KConfigHeaderGenerator.cpp index 08d383d8..bf29da05 100644 --- a/src/kconfig_compiler/KConfigHeaderGenerator.cpp +++ b/src/kconfig_compiler/KConfigHeaderGenerator.cpp @@ -347,7 +347,7 @@ void KConfigHeaderGenerator::createConstructor() void KConfigHeaderGenerator::createDestructor() { - stream() << whitespace() << "~" << cfg().className << "();\n\n"; + stream() << whitespace() << "~" << cfg().className << "() override;\n\n"; } void KConfigHeaderGenerator::createForwardDeclarations() From ecfc43a9c1f93a266be2cd0e05b8d09dda90494b Mon Sep 17 00:00:00 2001 From: Alexander Lohnau Date: Wed, 7 Apr 2021 20:18:00 +0200 Subject: [PATCH 136/259] GIT_SILENT Add auto generated files to .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 6e9efad9..748c9a8a 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,6 @@ CMakeLists.txt.user* .cmake/ /.clang-format /compile_commands.json +.clangd +.idea +/cmake-build* From 5210b3349e47e128674b6a4426035ccba27404cd Mon Sep 17 00:00:00 2001 From: Andreas Cord-Landwehr Date: Sat, 10 Apr 2021 12:05:37 +0200 Subject: [PATCH 137/259] Relicense to LGPL-2.0-or-later All named authors from copyright statements confirmed this change (confirmations at sysadmins' longterm archive). From the git history check, relicensecheck tells: - lgplv2+: pandom79@gmail.com pandom79@gmail.com ( 7 LOC): eeb2bbe Whereas pandom79 does not posses a KDE contributor account but also confirmed via private mail (confirmation mail also in sysadmins' archive). --- src/gui/kstandardshortcut.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kstandardshortcut.h b/src/gui/kstandardshortcut.h index 6ffbeed6..9dad7ffb 100644 --- a/src/gui/kstandardshortcut.h +++ b/src/gui/kstandardshortcut.h @@ -4,7 +4,7 @@ SPDX-FileCopyrightText: 2000 Nicolas Hadacek SPDX-FileCopyrightText: 2001, 2002 Ellis Whitehead - SPDX-License-Identifier: LGPL-2.0-only + SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KSTANDARDSHORTCUT_H #define KSTANDARDSHORTCUT_H From 48fd62f88073d268108b681aff53bc36b07d7523 Mon Sep 17 00:00:00 2001 From: Andreas Cord-Landwehr Date: Sat, 10 Apr 2021 12:09:57 +0200 Subject: [PATCH 138/259] Relicense to LGPL-2.0-or-later All named authors from copyright statements confirmed this change (confirmations at sysadmins' longterm archive). From the git history check, relicensecheck tells: - lgplv2+: mdawson pandom79@gmail.com mdawson ( 6 LOC): 0005ba7 pandom79@gmail.com ( 4 LOC): eeb2bbe Whereas pandom79 does not posses a KDE contributor account but also confirmed via private mail (confirmation mail also in sysadmins' archive). Change 0005ba7 is a syntactical replacement of QT_TRANSLATE_NOOP with QT_TRANSLATE_NOOP3 and thus can be assumed to not by copyrightable. --- src/gui/kstandardshortcut.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kstandardshortcut.cpp b/src/gui/kstandardshortcut.cpp index ac8431df..6afd4a9f 100644 --- a/src/gui/kstandardshortcut.cpp +++ b/src/gui/kstandardshortcut.cpp @@ -4,7 +4,7 @@ SPDX-FileCopyrightText: 2000 Nicolas Hadacek SPDX-FileCopyrightText: 2001, 2002 Ellis Whitehead - SPDX-License-Identifier: LGPL-2.0-only + SPDX-License-Identifier: LGPL-2.0-or-later */ #include "kstandardshortcut.h" From f8a547152685f1702445dda734cbf7dcd1f8629b Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 10 Apr 2021 11:27:27 +0000 Subject: [PATCH 139/259] GIT_SILENT Upgrade KF version to 5.82.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c83d2e6d..cf453525 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.5) -set(KF_VERSION "5.81.0") # handled by release scripts +set(KF_VERSION "5.82.0") # handled by release scripts project(KConfig VERSION ${KF_VERSION}) include(FeatureSummary) From ff9baa8f4a9b910862618dac54d0bdb537af29d1 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 11 Apr 2021 12:21:00 +0200 Subject: [PATCH 140/259] Remove check for po subdir. These function check for the po directory presence themselves, and can also handle it being in the build directory with KDE_L10N_AUTO_TRANSLATIONS NO_CHANGELOG --- CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf453525..89d977f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,9 +60,7 @@ if (BUILD_TESTING) endif() include (ECMPoQmTools) -if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po") - ecm_install_po_files_as_qm(po) -endif() +ecm_install_po_files_as_qm(po) # create a Config.cmake and a ConfigVersion.cmake file and install them From 163cebc7065cd85650f45e93203b3ea8dd82f652 Mon Sep 17 00:00:00 2001 From: David Faure Date: Thu, 15 Apr 2021 12:02:09 +0200 Subject: [PATCH 141/259] KConfig: rename kconfigdata.h to kconfigdata_p.h It's internal, the symbols are not exported, the header is not installed. The _p.h naming makes this more obvious, when grepping for stuff in public API. --- DESIGN | 2 +- autotests/kentrymaptest.h | 2 +- docs/DESIGN.kconfig | 2 +- src/core/kconfig_p.h | 2 +- src/core/kconfigbackend.cpp | 2 +- src/core/kconfigdata.cpp | 2 +- src/core/{kconfigdata.h => kconfigdata_p.h} | 4 ++-- src/core/kconfiggroup.cpp | 2 +- src/core/kconfigini.cpp | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) rename src/core/{kconfigdata.h => kconfigdata_p.h} (99%) diff --git a/DESIGN b/DESIGN index 3cccc1ca..a5fbd2b5 100644 --- a/DESIGN +++ b/DESIGN @@ -1,7 +1,7 @@ If you add a major new feature, suggest using it in http://techbase.kde.org/Development/Tutorials/KConfig -kconfigdata.h contains definitions of the data formats used by kconfig. +kconfigdata_p.h contains definitions of the data formats used by kconfig. Configuration entries are stored as "KEntry". They are indexed with "KEntryKey". The primary store is a "KEntryMap" which is defined as a QMap from "KEntryKey" diff --git a/autotests/kentrymaptest.h b/autotests/kentrymaptest.h index faf3ad6d..8ad36a31 100644 --- a/autotests/kentrymaptest.h +++ b/autotests/kentrymaptest.h @@ -7,7 +7,7 @@ #ifndef KENTRYMAPTEST_H #define KENTRYMAPTEST_H -#include "kconfigdata.h" +#include "kconfigdata_p.h" #include class KEntryMapTest : public QObject diff --git a/docs/DESIGN.kconfig b/docs/DESIGN.kconfig index 1aa0a3f8..68994aed 100644 --- a/docs/DESIGN.kconfig +++ b/docs/DESIGN.kconfig @@ -1,4 +1,4 @@ -kconfigdata.h contains definitions of the data formats used by kconfig. +kconfigdata_p.h contains definitions of the data formats used by kconfig. Configuration entries are stored as "KEntry". They are indexed with "KEntryKey". The primary store is a "KEntryMap" which is defined as a QMap from "KEntryKey" diff --git a/src/core/kconfig_p.h b/src/core/kconfig_p.h index b201df17..e5c9d869 100644 --- a/src/core/kconfig_p.h +++ b/src/core/kconfig_p.h @@ -12,7 +12,7 @@ #define KCONFIG_P_H #include "kconfigbackend_p.h" -#include "kconfigdata.h" +#include "kconfigdata_p.h" #include "kconfiggroup.h" #include diff --git a/src/core/kconfigbackend.cpp b/src/core/kconfigbackend.cpp index 13455dbd..6a5984a3 100644 --- a/src/core/kconfigbackend.cpp +++ b/src/core/kconfigbackend.cpp @@ -16,7 +16,7 @@ #include #include -#include "kconfigdata.h" +#include "kconfigdata_p.h" #include "kconfigini_p.h" typedef QExplicitlySharedDataPointer BackendPtr; diff --git a/src/core/kconfigdata.cpp b/src/core/kconfigdata.cpp index ada7125f..b479a598 100644 --- a/src/core/kconfigdata.cpp +++ b/src/core/kconfigdata.cpp @@ -7,7 +7,7 @@ SPDX-License-Identifier: LGPL-2.0-or-later */ -#include +#include "kconfigdata_p.h" QDebug operator<<(QDebug dbg, const KEntryKey &key) { diff --git a/src/core/kconfigdata.h b/src/core/kconfigdata_p.h similarity index 99% rename from src/core/kconfigdata.h rename to src/core/kconfigdata_p.h index 0ca228fe..3554568e 100644 --- a/src/core/kconfigdata.h +++ b/src/core/kconfigdata_p.h @@ -7,8 +7,8 @@ SPDX-License-Identifier: LGPL-2.0-or-later */ -#ifndef KCONFIGDATA_H -#define KCONFIGDATA_H +#ifndef KCONFIGDATA_P_H +#define KCONFIGDATA_P_H #include #include diff --git a/src/core/kconfiggroup.cpp b/src/core/kconfiggroup.cpp index c065be81..5ee9f6ab 100644 --- a/src/core/kconfiggroup.cpp +++ b/src/core/kconfiggroup.cpp @@ -13,7 +13,7 @@ #include "kconfig.h" #include "kconfig_core_log_settings.h" #include "kconfig_p.h" -#include "kconfigdata.h" +#include "kconfigdata_p.h" #include "ksharedconfig.h" #include diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp index 8c81db8f..c7861f66 100644 --- a/src/core/kconfigini.cpp +++ b/src/core/kconfigini.cpp @@ -13,7 +13,7 @@ #include "kconfig.h" #include "kconfig_core_log_settings.h" #include "kconfigbackend_p.h" -#include "kconfigdata.h" +#include "kconfigdata_p.h" #include #include From 6a4b1b412bb4f02b509902b5a273f83303f79fcb Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Fri, 16 Apr 2021 14:43:44 +0200 Subject: [PATCH 142/259] Remove stray tick from readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 941c63ea..e1d1cc6f 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ KConfigCore and KConfigGui. KConfigCore provides access to the configuration files themselves. It features: - Code generation: describe your configuration in an XML file, and use - `kconfig_compiler to generate classes that read and write configuration + kconfig_compiler to generate classes that read and write configuration entries. - Cascading configuration files (global settings overridden by local settings). - Optional shell expansion support (see [docs/options.md](@ref options)). From 533ff88a5430655f3b969b3e1a86ac71064c57ef Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Sun, 18 Apr 2021 21:46:56 +0200 Subject: [PATCH 143/259] Deprecate KDesktopFile::readDevice() Since the FSDevice .desktop template hasn't been installed for a long time, this method in KDesktopFile hasn't been useful. The whole FSDesktop concept seems to be redundant nowadays, since CDRom and Floppy drives have been replaced by USB sticks. See this KF6 taks for more details: https://phabricator.kde.org/T14295#253759 --- src/core/CMakeLists.txt | 2 +- src/core/kdesktopfile.cpp | 2 ++ src/core/kdesktopfile.h | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index eb16d039..0c0aa72c 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -31,7 +31,7 @@ ecm_generate_export_header(KF5ConfigCore GROUP_BASE_NAME KF VERSION ${KF_VERSION} DEPRECATED_BASE_VERSION 0 - DEPRECATION_VERSIONS 4.0 5.0 5.24 5.42 + DEPRECATION_VERSIONS 4.0 5.0 5.24 5.42 5.82 EXCLUDE_DEPRECATED_BEFORE_AND_AT ${EXCLUDE_DEPRECATED_BEFORE_AND_AT} ) diff --git a/src/core/kdesktopfile.cpp b/src/core/kdesktopfile.cpp index cae8b98d..338692e6 100644 --- a/src/core/kdesktopfile.cpp +++ b/src/core/kdesktopfile.cpp @@ -206,11 +206,13 @@ QString KDesktopFile::readPath() const return d->desktopGroup.readEntry("Path", QString()); } +#if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 82) QString KDesktopFile::readDevice() const { Q_D(const KDesktopFile); return d->desktopGroup.readEntry("Dev", QString()); } +#endif QString KDesktopFile::readUrl() const { diff --git a/src/core/kdesktopfile.h b/src/core/kdesktopfile.h index c98bf1bb..25420083 100644 --- a/src/core/kdesktopfile.h +++ b/src/core/kdesktopfile.h @@ -129,11 +129,16 @@ class KCONFIGCORE_EXPORT KDesktopFile : public KConfig */ QString readPath() const; +#if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(5, 82) /** * Returns the value of the "Dev=" entry. * @return the device or QString() if not specified + * @deprecated since 5.82, for lack of usage, the FSDevice .desktop template + * hadn't been installed for a long time. */ + KCONFIGCORE_DEPRECATED_VERSION(5, 82, "For lack of usage.") QString readDevice() const; +#endif /** * Returns the value of the "URL=" entry. From 17ce440211de8d72b683b25dae89ee6b7c9dc69d Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Mon, 26 Apr 2021 19:21:43 +0200 Subject: [PATCH 144/259] Use new version-controlled enumerator deprecation warning macros --- docs/Doxyfile.local | 8 +++++++- src/CMakeLists.txt | 6 ++++++ src/core/kemailsettings.h | 12 ++++++------ src/gui/CMakeLists.txt | 2 +- src/gui/kstandardshortcut.h | 3 ++- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/docs/Doxyfile.local b/docs/Doxyfile.local index 6fff4f58..37895c76 100644 --- a/docs/Doxyfile.local +++ b/docs/Doxyfile.local @@ -5,6 +5,12 @@ PREDEFINED += \ "KCONFIGCORE_ENABLE_DEPRECATED_SINCE(x, y)=1" \ "KCONFIGCORE_BUILD_DEPRECATED_SINCE(x, y)=1" \ "KCONFIGCORE_DEPRECATED_VERSION(x, y, t)=" \ + "KCONFIGCORE_DEPRECATED_VERSION_BELATED(x, y, xt, yt, t)=" \ + "KCONFIGCORE_ENUMERATOR_DEPRECATED_VERSION(x, y, t)=" \ + "KCONFIGCORE_ENUMERATOR_DEPRECATED_VERSION_BELATED(x, y, xt, yt, t)=" \ "KCONFIGGUI_ENABLE_DEPRECATED_SINCE(x, y)=1" \ "KCONFIGGUI_BUILD_DEPRECATED_SINCE(x, y)=1" \ - "KCONFIGGUI_DEPRECATED_VERSION(x, y, t)=" + "KCONFIGGUI_DEPRECATED_VERSION(x, y, t)=" \ + "KCONFIGGUI_DEPRECATED_VERSION_BELATED(x, y, xt, yt, t)=" \ + "KCONFIGGUI_ENUMERATOR_DEPRECATED_VERSION(x, y, t)=" \ + "KCONFIGGUI_ENUMERATOR_DEPRECATED_VERSION_BELATED(x, y, xt, yt, t)=" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 151c3249..e6bac82a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -37,10 +37,16 @@ if (BUILD_QCH) KCONFIGCORE_DEPRECATED_EXPORT KCONFIGCORE_DEPRECATED "KCONFIGCORE_DEPRECATED_VERSION(x, y, t)" + "KCONFIGCORE_DEPRECATED_VERSION_BELATED(x, y, xt, yt, t)" + "KCONFIGCORE_ENUMERATOR_DEPRECATED_VERSION(x, y, t)" + "KCONFIGCORE_ENUMERATOR_DEPRECATED_VERSION_BELATED(x, y, xt, yt, t)" KCONFIGGUI_EXPORT KCONFIGGUI_DEPRECATED_EXPORT KCONFIGGUI_DEPRECATED "KCONFIGGUI_DEPRECATED_VERSION(x, y, t)" + "KCONFIGGUI_DEPRECATED_VERSION_BELATED(x, y, xt, yt, t)" + "KCONFIGGUI_ENUMERATOR_DEPRECATED_VERSION(x, y, t)" + "KCONFIGGUI_ENUMERATOR_DEPRECATED_VERSION_BELATED(x, y, xt, yt, t)" TAGFILE_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR} QCH_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR} COMPONENT Devel diff --git a/src/core/kemailsettings.h b/src/core/kemailsettings.h index eb701f8c..7ced45aa 100644 --- a/src/core/kemailsettings.h +++ b/src/core/kemailsettings.h @@ -52,15 +52,15 @@ class KCONFIGCORE_EXPORT KEMailSettings /** * @deprecated since 5.0 */ - OutServerType, + OutServerType KCONFIGCORE_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 0, "No known users"), /** * @deprecated since 5.0 */ - OutServerCommand, + OutServerCommand KCONFIGCORE_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 0, "No known users"), /** * @deprecated since 5.0 */ - OutServerTLS, + OutServerTLS KCONFIGCORE_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 0, "No known users"), #else OutServerType_DEPRECATED_DO_NOT_USE, OutServerCommand_DEPRECATED_DO_NOT_USE, @@ -73,15 +73,15 @@ class KCONFIGCORE_EXPORT KEMailSettings /** * @deprecated since 5.0 */ - InServerType, + InServerType KCONFIGCORE_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 0, "No known users"), /** * @deprecated since 5.0 */ - InServerMBXType, + InServerMBXType KCONFIGCORE_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 0, "No known users"), /** * @deprecated since 5.0 */ - InServerTLS + InServerTLS KCONFIGCORE_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 0, "No known users") #endif }; diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 2de87570..b6d4d34f 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -15,7 +15,7 @@ ecm_generate_export_header(KF5ConfigGui GROUP_BASE_NAME KF VERSION ${KF_VERSION} DEPRECATED_BASE_VERSION 0 - DEPRECATION_VERSIONS 5.11 5.39 5.71 + DEPRECATION_VERSIONS 5.11 5.39 5.71 5.82 EXCLUDE_DEPRECATED_BEFORE_AND_AT ${EXCLUDE_DEPRECATED_BEFORE_AND_AT} ) diff --git a/src/gui/kstandardshortcut.h b/src/gui/kstandardshortcut.h index 9dad7ffb..305cf8ed 100644 --- a/src/gui/kstandardshortcut.h +++ b/src/gui/kstandardshortcut.h @@ -123,7 +123,8 @@ enum StandardShortcut { ShowToolbar, ///< Show/Hide the toolbar. ShowStatusbar, ///< Show/Hide the statusbar. #if KCONFIGGUI_ENABLE_DEPRECATED_SINCE(5, 39) - SaveOptions, ///< @deprecated since 5.39 + SaveOptions ///< @deprecated since 5.39 + KCONFIGGUI_ENUMERATOR_DEPRECATED_VERSION_BELATED(5, 82, 5, 39, "No known users"), #else SaveOptions_DEPRECATED_DO_NOT_USE, #endif From 50ae3700dc57e53c3583b3afc9661fdb8932ad03 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Wed, 28 Apr 2021 15:26:02 +0200 Subject: [PATCH 145/259] Make the docs state that KConfig::reparseConfiguration() calls sync() if needed This matches the method actually does, and makes it clearer that you don't need to do config->sync() followed by config()->reparseConfiguration(), the latter should suffice. --- src/core/kconfig.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/kconfig.h b/src/core/kconfig.h index 792a9a6b..6fee5ff5 100644 --- a/src/core/kconfig.h +++ b/src/core/kconfig.h @@ -233,6 +233,8 @@ class KCONFIGCORE_EXPORT KConfig : public KConfigBase /** * Updates the state of this object to match the persistent storage. + * Note that if this object has pending changes, this method will + * call sync() first so as not to lose those changes. */ void reparseConfiguration(); From 2b969608f2444066a7f400e7bd41c9485e7a3df2 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 1 May 2021 09:38:21 +0000 Subject: [PATCH 146/259] GIT_SILENT Upgrade ECM and KF version requirements for 5.82.0 release. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 89d977f8..40beb702 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ set(KF_VERSION "5.82.0") # handled by release scripts project(KConfig VERSION ${KF_VERSION}) include(FeatureSummary) -find_package(ECM 5.81.0 NO_MODULE) +find_package(ECM 5.82.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) From 1164ef55e93b4171306899ab786bfd0acaa00847 Mon Sep 17 00:00:00 2001 From: Alexander Lohnau Date: Sun, 2 May 2021 10:39:24 +0200 Subject: [PATCH 147/259] GIT_SILENT Add auto generated files to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 748c9a8a..d84c8172 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ CMakeLists.txt.user* .clangd .idea /cmake-build* +.cache From 1780fb2a237af80ddc1f9cfb70cb892b53b91990 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Sun, 2 May 2021 17:50:05 +0200 Subject: [PATCH 148/259] Minor code refactoring Some methods in ConfigLoaderHandler always returned true, change them to return void instead. Also port them to take a QStringView instead of QStringRef, this doesn't require a lot of changes because a QStringView can be constructed from a QStringRef. QXmlStreamAttribute methods like value() and name() return QStringRef in Qt5 and QStringView in Qt6, "fix" the issue by using auto keyword, which works in both cases. QStringView::toInt() isn't efficient in Qt5 so make the build conditional. NO_CHANGELOG --- src/core/kconfig.cpp | 10 ++--- src/gui/kconfigloader.cpp | 68 +++++++++++++------------------ src/gui/kconfigloaderhandler_p.h | 5 +-- src/kconf_update/kconfigutils.cpp | 4 ++ 4 files changed, 39 insertions(+), 48 deletions(-) diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index cc3700e1..8118ea51 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -174,21 +174,21 @@ QString KConfigPrivate::expandString(const QString &value) int nDollarPos = aValue.indexOf(QLatin1Char('$')); while (nDollarPos != -1 && nDollarPos + 1 < aValue.length()) { // there is at least one $ - if (aValue[nDollarPos + 1] != QLatin1Char('$')) { + if (aValue.at(nDollarPos + 1) != QLatin1Char('$')) { int nEndPos = nDollarPos + 1; // the next character is not $ - QStringRef aVarName; - if (aValue[nEndPos] == QLatin1Char('{')) { + QStringView aVarName; + if (aValue.at(nEndPos) == QLatin1Char('{')) { while ((nEndPos <= aValue.length()) && (aValue[nEndPos] != QLatin1Char('}'))) { ++nEndPos; } ++nEndPos; - aVarName = aValue.midRef(nDollarPos + 2, nEndPos - nDollarPos - 3); + aVarName = QStringView(aValue).mid(nDollarPos + 2, nEndPos - nDollarPos - 3); } else { while (nEndPos < aValue.length() && (aValue[nEndPos].isNumber() || aValue[nEndPos].isLetter() || aValue[nEndPos] == QLatin1Char('_'))) { ++nEndPos; } - aVarName = aValue.midRef(nDollarPos + 1, nEndPos - nDollarPos - 1); + aVarName = QStringView(aValue).mid(nDollarPos + 1, nEndPos - nDollarPos - 1); } QString env; if (!aVarName.isEmpty()) { diff --git a/src/gui/kconfigloader.cpp b/src/gui/kconfigloader.cpp index bc1751f4..940613b8 100644 --- a/src/gui/kconfigloader.cpp +++ b/src/gui/kconfigloader.cpp @@ -49,20 +49,14 @@ bool ConfigLoaderHandler::parse(QIODevice *input) switch (reader.tokenType()) { case QXmlStreamReader::StartElement: - if (!startElement(reader.name(), reader.attributes())) { - return false; - } + startElement(reader.name(), reader.attributes()); break; case QXmlStreamReader::EndElement: - if (!endElement(reader.name())) { - return false; - } + endElement(reader.name()); break; case QXmlStreamReader::Characters: if (!reader.isWhitespace() && !reader.text().trimmed().isEmpty()) { - if (!characters(reader.text())) { - return false; - } + m_cdata.append(reader.text()); } break; default: @@ -77,15 +71,19 @@ bool ConfigLoaderHandler::parse(QIODevice *input) return true; } -bool ConfigLoaderHandler::startElement(const QStringRef &localName, const QXmlStreamAttributes &attrs) +static bool caseInsensitiveCompare(const QStringView a, const QLatin1String b) +{ + return a.compare(b, Qt::CaseInsensitive) == 0; +} + +void ConfigLoaderHandler::startElement(const QStringView localName, const QXmlStreamAttributes &attrs) { // qDebug() << "ConfigLoaderHandler::startElement(" << localName << qName; - const QString tag = localName.toString().toLower(); - if (tag == QLatin1String("group")) { + if (caseInsensitiveCompare(localName, QLatin1String("group"))) { QString group; for (const auto &attr : attrs) { - const QStringRef name = attr.name(); - if (name.compare(QLatin1String("name"), Qt::CaseInsensitive) == 0) { + const auto name = attr.name(); + if (caseInsensitiveCompare(name, QLatin1String("name"))) { // qDebug() << "set group to" << attrs.value(i); group = attr.value().toString(); } @@ -102,71 +100,61 @@ bool ConfigLoaderHandler::startElement(const QStringRef &localName, const QXmlSt if (m_config) { m_config->setCurrentGroup(group); } - } else if (tag == QLatin1String("entry")) { + } else if (caseInsensitiveCompare(localName, QLatin1String("entry"))) { for (const auto &attr : attrs) { - const QStringRef name = attr.name(); - if (name.compare(QLatin1String("name"), Qt::CaseInsensitive) == 0) { + const auto name = attr.name(); + if (caseInsensitiveCompare(name, QLatin1String("name"))) { m_name = attr.value().trimmed().toString(); - } else if (name.compare(QLatin1String("type"), Qt::CaseInsensitive) == 0) { + } else if (caseInsensitiveCompare(name, QLatin1String("type"))) { m_type = attr.value().toString().toLower(); - } else if (name.compare(QLatin1String("key"), Qt::CaseInsensitive) == 0) { + } else if (caseInsensitiveCompare(name, QLatin1String("key"))) { m_key = attr.value().trimmed().toString(); } } - } else if (tag == QLatin1String("choice")) { + } else if (caseInsensitiveCompare(localName, QLatin1String("choice"))) { m_choice.name.clear(); m_choice.label.clear(); m_choice.whatsThis.clear(); for (const auto &attr : attrs) { - const QStringRef name = attr.name(); - if (name.compare(QLatin1String("name"), Qt::CaseInsensitive) == 0) { + const auto name = attr.name(); + if (caseInsensitiveCompare(name, QLatin1String("name"))) { m_choice.name = attr.value().toString(); } } m_inChoice = true; } - - return true; -} - -bool ConfigLoaderHandler::characters(const QStringRef &ch) -{ - m_cdata.append(ch.toString()); - return true; } -bool ConfigLoaderHandler::endElement(const QStringRef &localName) +void ConfigLoaderHandler::endElement(const QStringView localName) { // qDebug() << "ConfigLoaderHandler::endElement(" << localName << qName; - const QStringRef tag = localName; - if (tag.compare(QLatin1String("entry"), Qt::CaseInsensitive) == 0) { + if (caseInsensitiveCompare(localName, QLatin1String("entry"))) { addItem(); resetState(); - } else if (tag.compare(QLatin1String("label"), Qt::CaseInsensitive) == 0) { + } else if (caseInsensitiveCompare(localName, QLatin1String("label"))) { if (m_inChoice) { m_choice.label = m_cdata.trimmed(); } else { m_label = m_cdata.trimmed(); } - } else if (tag.compare(QLatin1String("whatsthis"), Qt::CaseInsensitive) == 0) { + } else if (caseInsensitiveCompare(localName, QLatin1String("whatsthis"))) { if (m_inChoice) { m_choice.whatsThis = m_cdata.trimmed(); } else { m_whatsThis = m_cdata.trimmed(); } - } else if (tag.compare(QLatin1String("default"), Qt::CaseInsensitive) == 0) { + } else if (caseInsensitiveCompare(localName, QLatin1String("default"))) { m_default = m_cdata.trimmed(); - } else if (tag.compare(QLatin1String("min"), Qt::CaseInsensitive) == 0) { + } else if (caseInsensitiveCompare(localName, QLatin1String("min"))) { m_min = m_cdata.toInt(&m_haveMin); - } else if (tag.compare(QLatin1String("max"), Qt::CaseInsensitive) == 0) { + } else if (caseInsensitiveCompare(localName, QLatin1String("max"))) { m_max = m_cdata.toInt(&m_haveMax); - } else if (tag.compare(QLatin1String("choice"), Qt::CaseInsensitive) == 0) { + } else if (caseInsensitiveCompare(localName, QLatin1String("choice"))) { m_enumChoices.append(m_choice); m_inChoice = false; } m_cdata.clear(); - return true; } void ConfigLoaderHandler::addItem() diff --git a/src/gui/kconfigloaderhandler_p.h b/src/gui/kconfigloaderhandler_p.h index bc199e0e..297e5462 100644 --- a/src/gui/kconfigloaderhandler_p.h +++ b/src/gui/kconfigloaderhandler_p.h @@ -17,9 +17,8 @@ class ConfigLoaderHandler bool parse(QIODevice *input); - bool startElement(const QStringRef &localName, const QXmlStreamAttributes &attrs); - bool endElement(const QStringRef &localName); - bool characters(const QStringRef &ch); + void startElement(const QStringView localName, const QXmlStreamAttributes &attrs); + void endElement(const QStringView localName); private: void addItem(); diff --git a/src/kconf_update/kconfigutils.cpp b/src/kconf_update/kconfigutils.cpp index 49d5ac3c..9608f21c 100644 --- a/src/kconf_update/kconfigutils.cpp +++ b/src/kconf_update/kconfigutils.cpp @@ -89,7 +89,11 @@ QString unescapeString(const QString &src, bool *ok, QString *error) break; case L'x': { if (pos + 2 < length) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + char value = QStringView(src).mid(pos + 1, 2).toInt(ok, 16); +#else char value = src.midRef(pos + 1, 2).toInt(ok, 16); +#endif if (*ok) { dst += QLatin1Char{value}; pos += 2; From 122125452775fd67a59c0a34e1c9941bc15a8f8d Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Sun, 2 May 2021 22:17:42 +0200 Subject: [PATCH 149/259] Port away from ECMSetupVersion's deprecated *_VERSION_STRING CMake variable NO_CHANGELOG --- src/core/CMakeLists.txt | 2 +- src/gui/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 0c0aa72c..82800972 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -48,7 +48,7 @@ if(KCONFIG_USE_DBUS) target_link_libraries(KF5ConfigCore PRIVATE Qt5::DBus) endif() -set_target_properties(KF5ConfigCore PROPERTIES VERSION ${KCONFIG_VERSION_STRING} +set_target_properties(KF5ConfigCore PROPERTIES VERSION ${KCONFIG_VERSION} SOVERSION ${KCONFIG_SOVERSION} EXPORT_NAME ConfigCore ) diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index b6d4d34f..8f37b6e1 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -23,7 +23,7 @@ target_include_directories(KF5ConfigGui INTERFACE "$ Date: Tue, 4 May 2021 06:50:23 +0200 Subject: [PATCH 150/259] Fix cmake warning "Policy CMP0115 is not set: Source file extensions must be explicit. Run "cmake --help-policy CMP0115" for policy details. Use the cmake_policy command to set the policy and suppress this warning. " We need to add file extension --- autotests/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt index f07bf557..121b530a 100644 --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -22,7 +22,7 @@ ecm_add_test(${kentrymaptest_SRCS} target_include_directories(kentrymaptest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../src/core) # compile KConfigUtils into the test since it's not exported -set(test_kconfigutils_SRCS test_kconfigutils ../src/kconf_update/kconfigutils.cpp) +set(test_kconfigutils_SRCS test_kconfigutils.cpp ../src/kconf_update/kconfigutils.cpp) ecm_add_test(${test_kconfigutils_SRCS} TEST_NAME test_kconfigutils LINK_LIBRARIES KF5::ConfigCore Qt5::Test @@ -31,18 +31,18 @@ target_include_directories(test_kconfigutils PRIVATE ../src/kconf_update) qt5_add_resources(sharedconfigresources sharedconfigresources.qrc) -ecm_add_test(ksharedconfigtest ${sharedconfigresources} TEST_NAME kconfigcore-ksharedconfigtest LINK_LIBRARIES KF5::ConfigCore Qt5::Test Qt5::Concurrent) +ecm_add_test(ksharedconfigtest.cpp ${sharedconfigresources} TEST_NAME kconfigcore-ksharedconfigtest LINK_LIBRARIES KF5::ConfigCore Qt5::Test Qt5::Concurrent) # test for fallback to :/kconfig/xxxx config resource qt5_add_resources(fallbackconfigresources fallbackconfigresources.qrc) -ecm_add_test(fallbackconfigresourcestest ${fallbackconfigresources} TEST_NAME kconfigcore-fallbackconfigresourcestest LINK_LIBRARIES KF5::ConfigCore Qt5::Test Qt5::Concurrent) +ecm_add_test(fallbackconfigresourcestest.cpp ${fallbackconfigresources} TEST_NAME kconfigcore-fallbackconfigresourcestest LINK_LIBRARIES KF5::ConfigCore Qt5::Test Qt5::Concurrent) ecm_add_tests( kconfignokdehometest.cpp kconfigtest.cpp kdesktopfiletest.cpp test_kconf_update.cpp - ksharedconfig_in_global_object + ksharedconfig_in_global_object.cpp NAME_PREFIX kconfigcore- LINK_LIBRARIES KF5::ConfigCore Qt5::Test Qt5::Concurrent ) From f5f12926b1ead2f36b2f7e8fc34ff864b5b6d60e Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Tue, 4 May 2021 21:59:43 -0600 Subject: [PATCH 151/259] Don't write position data for maximized windows A window that is maximized does not really have a position on screen other then the fact that it's maximized, and writing out position data in this case anyway will only serve to mis-position the window once da-maximized, should KWin ever stop remembering de-maximized window positions internally. CCBUG: 434116 --- src/gui/kwindowconfig.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gui/kwindowconfig.cpp b/src/gui/kwindowconfig.cpp index 019e1aa2..38b4b929 100644 --- a/src/gui/kwindowconfig.cpp +++ b/src/gui/kwindowconfig.cpp @@ -140,6 +140,12 @@ void KWindowConfig::saveWindowPosition(const QWindow *window, KConfigGroup &conf return; } + // If the window is maximized, saving the position will only serve to mis-position + // it once de-maximized, so let's not do that + if (window->windowState() & Qt::WindowMaximized) { + return; + } + const QRect desk = window->screen()->geometry(); config.writeEntry(windowXPositionString(desk), window->x(), options); config.writeEntry(windowYPositionString(desk), window->y(), options); From 728c44c81c23401056484b7ab39a33821aa7e2f5 Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Fri, 7 May 2021 03:43:32 +0200 Subject: [PATCH 152/259] Order macro for attribute for symbol export before that for deprecated The symbol export/visibility attribute is not standardized so far and needs to be set by language extension attribute declaration at least with clang & MSVC, who both support that when it appears before the standard attribute declaration. NO_CHANGELOG --- src/core/kauthorized.h | 3 ++- src/gui/kconfiggui.h | 3 ++- src/gui/kstandardshortcut.h | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/core/kauthorized.h b/src/core/kauthorized.h index ac3cfa7e..a61e0927 100644 --- a/src/core/kauthorized.h +++ b/src/core/kauthorized.h @@ -110,8 +110,9 @@ KCONFIGCORE_EXPORT bool authorizeAction(const QString &action); * @see authorize() * @deprecated since 5.24, use authorizeAction() instead. */ +KCONFIGCORE_EXPORT KCONFIGCORE_DEPRECATED_VERSION(5, 24, "Use KAuthorized::authorizeAction(const QString&)") -KCONFIGCORE_EXPORT bool authorizeKAction(const QString &action); +bool authorizeKAction(const QString &action); #endif /** diff --git a/src/gui/kconfiggui.h b/src/gui/kconfiggui.h index c32e108f..8f4b739a 100644 --- a/src/gui/kconfiggui.h +++ b/src/gui/kconfiggui.h @@ -53,8 +53,9 @@ KCONFIGGUI_EXPORT bool hasSessionConfig(); * @return the application session name * @deprecated since 5.11, use sessionConfig()->name() */ +KCONFIGGUI_EXPORT KCONFIGGUI_DEPRECATED_VERSION(5, 11, "Use KConfigGui::sessionConfig()->name()") -KCONFIGGUI_EXPORT QString sessionConfigName(); +QString sessionConfigName(); #endif } diff --git a/src/gui/kstandardshortcut.h b/src/gui/kstandardshortcut.h index 305cf8ed..7986486a 100644 --- a/src/gui/kstandardshortcut.h +++ b/src/gui/kstandardshortcut.h @@ -211,8 +211,9 @@ KCONFIGGUI_EXPORT StandardShortcut find(const QKeySequence &keySeq); * is none * @deprecated since 5.71, use findByName(const QString &name) instead */ +KCONFIGGUI_EXPORT KCONFIGGUI_DEPRECATED_VERSION(5, 71, "Use findByName(const QString &name) instead") -KCONFIGGUI_EXPORT StandardShortcut find(const char *keyName); +StandardShortcut find(const char *keyName); #endif /** From f3e8853abf53a80cbe7d7a0de21070505b1ee5fb Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 8 May 2021 12:34:47 +0000 Subject: [PATCH 153/259] GIT_SILENT Upgrade KF version to 5.83.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 40beb702..0bb765a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.5) -set(KF_VERSION "5.82.0") # handled by release scripts +set(KF_VERSION "5.83.0") # handled by release scripts project(KConfig VERSION ${KF_VERSION}) include(FeatureSummary) From 2e8742e64fc02477296335c39b0485895321855b Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Mon, 3 May 2021 01:49:43 +0200 Subject: [PATCH 154/259] Revert QStringView port QStringView has some bits of API that were only added in 5.15.2, whereas KF requires 5.15.0. This reverts commit 1780fb2a237af80ddc1f9cfb70cb892b53b91990. --- src/core/kconfig.cpp | 10 ++--- src/gui/kconfigloader.cpp | 68 ++++++++++++++++++------------- src/gui/kconfigloaderhandler_p.h | 5 ++- src/kconf_update/kconfigutils.cpp | 4 -- 4 files changed, 48 insertions(+), 39 deletions(-) diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index 8118ea51..cc3700e1 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -174,21 +174,21 @@ QString KConfigPrivate::expandString(const QString &value) int nDollarPos = aValue.indexOf(QLatin1Char('$')); while (nDollarPos != -1 && nDollarPos + 1 < aValue.length()) { // there is at least one $ - if (aValue.at(nDollarPos + 1) != QLatin1Char('$')) { + if (aValue[nDollarPos + 1] != QLatin1Char('$')) { int nEndPos = nDollarPos + 1; // the next character is not $ - QStringView aVarName; - if (aValue.at(nEndPos) == QLatin1Char('{')) { + QStringRef aVarName; + if (aValue[nEndPos] == QLatin1Char('{')) { while ((nEndPos <= aValue.length()) && (aValue[nEndPos] != QLatin1Char('}'))) { ++nEndPos; } ++nEndPos; - aVarName = QStringView(aValue).mid(nDollarPos + 2, nEndPos - nDollarPos - 3); + aVarName = aValue.midRef(nDollarPos + 2, nEndPos - nDollarPos - 3); } else { while (nEndPos < aValue.length() && (aValue[nEndPos].isNumber() || aValue[nEndPos].isLetter() || aValue[nEndPos] == QLatin1Char('_'))) { ++nEndPos; } - aVarName = QStringView(aValue).mid(nDollarPos + 1, nEndPos - nDollarPos - 1); + aVarName = aValue.midRef(nDollarPos + 1, nEndPos - nDollarPos - 1); } QString env; if (!aVarName.isEmpty()) { diff --git a/src/gui/kconfigloader.cpp b/src/gui/kconfigloader.cpp index 940613b8..bc1751f4 100644 --- a/src/gui/kconfigloader.cpp +++ b/src/gui/kconfigloader.cpp @@ -49,14 +49,20 @@ bool ConfigLoaderHandler::parse(QIODevice *input) switch (reader.tokenType()) { case QXmlStreamReader::StartElement: - startElement(reader.name(), reader.attributes()); + if (!startElement(reader.name(), reader.attributes())) { + return false; + } break; case QXmlStreamReader::EndElement: - endElement(reader.name()); + if (!endElement(reader.name())) { + return false; + } break; case QXmlStreamReader::Characters: if (!reader.isWhitespace() && !reader.text().trimmed().isEmpty()) { - m_cdata.append(reader.text()); + if (!characters(reader.text())) { + return false; + } } break; default: @@ -71,19 +77,15 @@ bool ConfigLoaderHandler::parse(QIODevice *input) return true; } -static bool caseInsensitiveCompare(const QStringView a, const QLatin1String b) -{ - return a.compare(b, Qt::CaseInsensitive) == 0; -} - -void ConfigLoaderHandler::startElement(const QStringView localName, const QXmlStreamAttributes &attrs) +bool ConfigLoaderHandler::startElement(const QStringRef &localName, const QXmlStreamAttributes &attrs) { // qDebug() << "ConfigLoaderHandler::startElement(" << localName << qName; - if (caseInsensitiveCompare(localName, QLatin1String("group"))) { + const QString tag = localName.toString().toLower(); + if (tag == QLatin1String("group")) { QString group; for (const auto &attr : attrs) { - const auto name = attr.name(); - if (caseInsensitiveCompare(name, QLatin1String("name"))) { + const QStringRef name = attr.name(); + if (name.compare(QLatin1String("name"), Qt::CaseInsensitive) == 0) { // qDebug() << "set group to" << attrs.value(i); group = attr.value().toString(); } @@ -100,61 +102,71 @@ void ConfigLoaderHandler::startElement(const QStringView localName, const QXmlSt if (m_config) { m_config->setCurrentGroup(group); } - } else if (caseInsensitiveCompare(localName, QLatin1String("entry"))) { + } else if (tag == QLatin1String("entry")) { for (const auto &attr : attrs) { - const auto name = attr.name(); - if (caseInsensitiveCompare(name, QLatin1String("name"))) { + const QStringRef name = attr.name(); + if (name.compare(QLatin1String("name"), Qt::CaseInsensitive) == 0) { m_name = attr.value().trimmed().toString(); - } else if (caseInsensitiveCompare(name, QLatin1String("type"))) { + } else if (name.compare(QLatin1String("type"), Qt::CaseInsensitive) == 0) { m_type = attr.value().toString().toLower(); - } else if (caseInsensitiveCompare(name, QLatin1String("key"))) { + } else if (name.compare(QLatin1String("key"), Qt::CaseInsensitive) == 0) { m_key = attr.value().trimmed().toString(); } } - } else if (caseInsensitiveCompare(localName, QLatin1String("choice"))) { + } else if (tag == QLatin1String("choice")) { m_choice.name.clear(); m_choice.label.clear(); m_choice.whatsThis.clear(); for (const auto &attr : attrs) { - const auto name = attr.name(); - if (caseInsensitiveCompare(name, QLatin1String("name"))) { + const QStringRef name = attr.name(); + if (name.compare(QLatin1String("name"), Qt::CaseInsensitive) == 0) { m_choice.name = attr.value().toString(); } } m_inChoice = true; } + + return true; +} + +bool ConfigLoaderHandler::characters(const QStringRef &ch) +{ + m_cdata.append(ch.toString()); + return true; } -void ConfigLoaderHandler::endElement(const QStringView localName) +bool ConfigLoaderHandler::endElement(const QStringRef &localName) { // qDebug() << "ConfigLoaderHandler::endElement(" << localName << qName; - if (caseInsensitiveCompare(localName, QLatin1String("entry"))) { + const QStringRef tag = localName; + if (tag.compare(QLatin1String("entry"), Qt::CaseInsensitive) == 0) { addItem(); resetState(); - } else if (caseInsensitiveCompare(localName, QLatin1String("label"))) { + } else if (tag.compare(QLatin1String("label"), Qt::CaseInsensitive) == 0) { if (m_inChoice) { m_choice.label = m_cdata.trimmed(); } else { m_label = m_cdata.trimmed(); } - } else if (caseInsensitiveCompare(localName, QLatin1String("whatsthis"))) { + } else if (tag.compare(QLatin1String("whatsthis"), Qt::CaseInsensitive) == 0) { if (m_inChoice) { m_choice.whatsThis = m_cdata.trimmed(); } else { m_whatsThis = m_cdata.trimmed(); } - } else if (caseInsensitiveCompare(localName, QLatin1String("default"))) { + } else if (tag.compare(QLatin1String("default"), Qt::CaseInsensitive) == 0) { m_default = m_cdata.trimmed(); - } else if (caseInsensitiveCompare(localName, QLatin1String("min"))) { + } else if (tag.compare(QLatin1String("min"), Qt::CaseInsensitive) == 0) { m_min = m_cdata.toInt(&m_haveMin); - } else if (caseInsensitiveCompare(localName, QLatin1String("max"))) { + } else if (tag.compare(QLatin1String("max"), Qt::CaseInsensitive) == 0) { m_max = m_cdata.toInt(&m_haveMax); - } else if (caseInsensitiveCompare(localName, QLatin1String("choice"))) { + } else if (tag.compare(QLatin1String("choice"), Qt::CaseInsensitive) == 0) { m_enumChoices.append(m_choice); m_inChoice = false; } m_cdata.clear(); + return true; } void ConfigLoaderHandler::addItem() diff --git a/src/gui/kconfigloaderhandler_p.h b/src/gui/kconfigloaderhandler_p.h index 297e5462..bc199e0e 100644 --- a/src/gui/kconfigloaderhandler_p.h +++ b/src/gui/kconfigloaderhandler_p.h @@ -17,8 +17,9 @@ class ConfigLoaderHandler bool parse(QIODevice *input); - void startElement(const QStringView localName, const QXmlStreamAttributes &attrs); - void endElement(const QStringView localName); + bool startElement(const QStringRef &localName, const QXmlStreamAttributes &attrs); + bool endElement(const QStringRef &localName); + bool characters(const QStringRef &ch); private: void addItem(); diff --git a/src/kconf_update/kconfigutils.cpp b/src/kconf_update/kconfigutils.cpp index 9608f21c..49d5ac3c 100644 --- a/src/kconf_update/kconfigutils.cpp +++ b/src/kconf_update/kconfigutils.cpp @@ -89,11 +89,7 @@ QString unescapeString(const QString &src, bool *ok, QString *error) break; case L'x': { if (pos + 2 < length) { -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - char value = QStringView(src).mid(pos + 1, 2).toInt(ok, 16); -#else char value = src.midRef(pos + 1, 2).toInt(ok, 16); -#endif if (*ok) { dst += QLatin1Char{value}; pos += 2; From 40f2371fbbcf7456df41b6afa791c8ae935409fa Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 11 May 2021 12:13:38 +0200 Subject: [PATCH 155/259] Docs: make a complete reference to reparseConfiguration() from KSharedConfig NO_CHANGELOG --- src/core/ksharedconfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/ksharedconfig.h b/src/core/ksharedconfig.h index e23d17c6..1add155e 100644 --- a/src/core/ksharedconfig.h +++ b/src/core/ksharedconfig.h @@ -25,7 +25,7 @@ * The openConfig() method is threadsafe: every thread gets a separate repository * of shared KConfig objects. This means, however, that you'll be responsible for * synchronizing the instances of KConfig for the same filename between threads, - * using reparseConfiguration after a manual change notification, just like you have + * using KConfig::reparseConfiguration() after a manual change notification, just like you have * to do between processes. */ class KCONFIGCORE_EXPORT KSharedConfig : public KConfig, public QSharedData // krazy:exclude=dpointer (only for refcounting) From 5bc56ee99d41076dc36543d493d57157d31fa59e Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Sun, 16 May 2021 11:47:27 +0200 Subject: [PATCH 156/259] GIT_SILENT: use qt_ macro --- autotests/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt index 121b530a..eb48a134 100644 --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -29,12 +29,12 @@ ecm_add_test(${test_kconfigutils_SRCS} ) target_include_directories(test_kconfigutils PRIVATE ../src/kconf_update) -qt5_add_resources(sharedconfigresources sharedconfigresources.qrc) +qt_add_resources(sharedconfigresources sharedconfigresources.qrc) ecm_add_test(ksharedconfigtest.cpp ${sharedconfigresources} TEST_NAME kconfigcore-ksharedconfigtest LINK_LIBRARIES KF5::ConfigCore Qt5::Test Qt5::Concurrent) # test for fallback to :/kconfig/xxxx config resource -qt5_add_resources(fallbackconfigresources fallbackconfigresources.qrc) +qt_add_resources(fallbackconfigresources fallbackconfigresources.qrc) ecm_add_test(fallbackconfigresourcestest.cpp ${fallbackconfigresources} TEST_NAME kconfigcore-fallbackconfigresourcestest LINK_LIBRARIES KF5::ConfigCore Qt5::Test Qt5::Concurrent) ecm_add_tests( From 725c2cc5f0d71198b50382af52e3595afc8428a4 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Sun, 16 May 2021 13:50:34 +0200 Subject: [PATCH 157/259] Bump required CMake version to 3.16 KF6 task: https://phabricator.kde.org/T14467 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0bb765a4..2d29e181 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.16) set(KF_VERSION "5.83.0") # handled by release scripts project(KConfig VERSION ${KF_VERSION}) From af6982ba361b7b5b11c732d2f7286801e0391d51 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Sun, 23 May 2021 17:17:43 +0200 Subject: [PATCH 158/259] Remove compiler flags already defined in extra-cmake-modules -DQT_NO_FOREACH GIT_SILENT --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d29e181..4babe0b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,7 +51,6 @@ ecm_setup_version(PROJECT VARIABLE_PREFIX KCONFIG PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5ConfigConfigVersion.cmake" SOVERSION 5) -add_definitions(-DQT_NO_FOREACH) add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050f00) add_subdirectory(src) From b3dc879e8b108c26c929bfbe551bcdf77f140e94 Mon Sep 17 00:00:00 2001 From: Lieven Hey Date: Thu, 20 May 2021 12:29:04 +0200 Subject: [PATCH 159/259] fix deleted group is in listGroups calling deleteGroup only deletes all entries but the group does still exists in listGroups this is somewhat irritating since calling exists on that group will return false with this patch the group does no longer exists in listGroup --- autotests/kconfigtest.cpp | 2 +- src/core/kconfig.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index bf7882f0..e6a3e645 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -802,7 +802,7 @@ void KConfigTest::testDelete() delgr.deleteGroup(); QVERIFY(!delgr.exists()); QVERIFY(!ct.hasGroup("Nested Group 3")); - QVERIFY(ct.groupList().contains(QStringLiteral("Nested Group 3"))); + QVERIFY(!ct.groupList().contains(QStringLiteral("Nested Group 3"))); KConfigGroup ng(&ct, "Nested Group 2"); QVERIFY(sc.hasGroup("Complex Types")); diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index cc3700e1..49a66d14 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -269,7 +269,7 @@ QStringList KConfig::groupList() const for (auto entryMapIt = d->entryMap.cbegin(); entryMapIt != d->entryMap.cend(); ++entryMapIt) { const KEntryKey &key = entryMapIt.key(); const QByteArray group = key.mGroup; - if (key.mKey.isNull() && !group.isEmpty() && group != "" && group != "$Version") { + if (key.mKey.isNull() && !group.isEmpty() && group != "" && group != "$Version" && !d->hasNonDeletedEntries(group)) { const QString groupname = QString::fromUtf8(group); groups << groupname.left(groupname.indexOf(QLatin1Char('\x1d'))); } @@ -285,7 +285,7 @@ QStringList KConfigPrivate::groupList(const QByteArray &group) const for (auto entryMapIt = entryMap.cbegin(); entryMapIt != entryMap.cend(); ++entryMapIt) { const KEntryKey &key = entryMapIt.key(); - if (key.mKey.isNull() && key.mGroup.startsWith(theGroup)) { + if (key.mKey.isNull() && key.mGroup.startsWith(theGroup) && !hasNonDeletedEntries(group)) { const QString groupname = QString::fromUtf8(key.mGroup.mid(theGroup.length())); groups << groupname.left(groupname.indexOf(QLatin1Char('\x1d'))); } From 4c590ede2cef74342aaf25eea9a32ee96c78b1aa Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Tue, 25 May 2021 07:59:30 -0600 Subject: [PATCH 160/259] Revert "fix deleted group is in listGroups" This reverts commit b3dc879e8b108c26c929bfbe551bcdf77f140e94. This change breaks plasmashell startup and possible other apps as well. Reverting so the root cause can be investigated without time pressure. --- autotests/kconfigtest.cpp | 2 +- src/core/kconfig.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index e6a3e645..bf7882f0 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -802,7 +802,7 @@ void KConfigTest::testDelete() delgr.deleteGroup(); QVERIFY(!delgr.exists()); QVERIFY(!ct.hasGroup("Nested Group 3")); - QVERIFY(!ct.groupList().contains(QStringLiteral("Nested Group 3"))); + QVERIFY(ct.groupList().contains(QStringLiteral("Nested Group 3"))); KConfigGroup ng(&ct, "Nested Group 2"); QVERIFY(sc.hasGroup("Complex Types")); diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index 49a66d14..cc3700e1 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -269,7 +269,7 @@ QStringList KConfig::groupList() const for (auto entryMapIt = d->entryMap.cbegin(); entryMapIt != d->entryMap.cend(); ++entryMapIt) { const KEntryKey &key = entryMapIt.key(); const QByteArray group = key.mGroup; - if (key.mKey.isNull() && !group.isEmpty() && group != "" && group != "$Version" && !d->hasNonDeletedEntries(group)) { + if (key.mKey.isNull() && !group.isEmpty() && group != "" && group != "$Version") { const QString groupname = QString::fromUtf8(group); groups << groupname.left(groupname.indexOf(QLatin1Char('\x1d'))); } @@ -285,7 +285,7 @@ QStringList KConfigPrivate::groupList(const QByteArray &group) const for (auto entryMapIt = entryMap.cbegin(); entryMapIt != entryMap.cend(); ++entryMapIt) { const KEntryKey &key = entryMapIt.key(); - if (key.mKey.isNull() && key.mGroup.startsWith(theGroup) && !hasNonDeletedEntries(group)) { + if (key.mKey.isNull() && key.mGroup.startsWith(theGroup)) { const QString groupname = QString::fromUtf8(key.mGroup.mid(theGroup.length())); groups << groupname.left(groupname.indexOf(QLatin1Char('\x1d'))); } From 9fe58ac80574ca668c23ba662e73de5e5b054c1f Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Thu, 27 May 2021 03:50:11 +0200 Subject: [PATCH 161/259] Avoid cmake variables and pass sources directly to macro NO_CHANGELOG --- autotests/CMakeLists.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt index eb48a134..cae4c0b1 100644 --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -14,16 +14,18 @@ if(NOT Qt5Concurrent_FOUND) endif() # compile KEntryMap into the test since it's not exported -set(kentrymaptest_SRCS kentrymaptest.cpp ../src/core/kconfigdata.cpp) -ecm_add_test(${kentrymaptest_SRCS} +ecm_add_test( + kentrymaptest.cpp + ../src/core/kconfigdata.cpp TEST_NAME kentrymaptest LINK_LIBRARIES Qt5::Test ) target_include_directories(kentrymaptest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../src/core) # compile KConfigUtils into the test since it's not exported -set(test_kconfigutils_SRCS test_kconfigutils.cpp ../src/kconf_update/kconfigutils.cpp) -ecm_add_test(${test_kconfigutils_SRCS} +ecm_add_test( + test_kconfigutils.cpp + ../src/kconf_update/kconfigutils.cpp TEST_NAME test_kconfigutils LINK_LIBRARIES KF5::ConfigCore Qt5::Test ) From e4a9b977d47cc1ec01282212039ed58241eafcf4 Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Thu, 27 May 2021 03:54:31 +0200 Subject: [PATCH 162/259] Use more target-centric cmake code NO_CHANGELOG --- src/core/CMakeLists.txt | 9 +++++---- src/gui/CMakeLists.txt | 22 ++++++++++++---------- src/kconf_update/CMakeLists.txt | 11 +++++------ src/kconfig_compiler/CMakeLists.txt | 20 +++++++++----------- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 82800972..4e85142e 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -1,4 +1,7 @@ -set(libkconfigcore_SRCS +add_library(KF5ConfigCore) +add_library(KF5::ConfigCore ALIAS KF5ConfigCore) + +target_sources(KF5ConfigCore PRIVATE kconfig.cpp kconfigbase.cpp kconfigdata.cpp @@ -13,7 +16,7 @@ set(libkconfigcore_SRCS kconfigwatcher.cpp ) -ecm_qt_declare_logging_category(libkconfigcore_SRCS +ecm_qt_declare_logging_category(KF5ConfigCore HEADER kconfig_core_log_settings.h IDENTIFIER KCONFIG_CORE_LOG CATEGORY_NAME kf.config.core @@ -24,8 +27,6 @@ ecm_qt_declare_logging_category(libkconfigcore_SRCS configure_file(config-kconfig.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kconfig.h ) -add_library(KF5ConfigCore ${libkconfigcore_SRCS}) -add_library(KF5::ConfigCore ALIAS KF5ConfigCore) ecm_generate_export_header(KF5ConfigCore BASE_NAME KConfigCore GROUP_BASE_NAME KF diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 8f37b6e1..9dad629a 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -1,15 +1,17 @@ -set(libkconfiggui_SRCS - kconfiggui.cpp - kconfiggroupgui.cpp - kconfigloader.cpp - kconfigskeleton.cpp - kstandardshortcut.cpp - kwindowconfig.cpp +add_library(KF5ConfigGui) +add_library(KF5::ConfigGui ALIAS KF5ConfigGui) + +ecm_create_qm_loader(KF5ConfigGui kconfig5_qt) + +target_sources(KF5ConfigGui PRIVATE + kconfiggui.cpp + kconfiggroupgui.cpp + kconfigloader.cpp + kconfigskeleton.cpp + kstandardshortcut.cpp + kwindowconfig.cpp ) -ecm_create_qm_loader(libkconfiggui_SRCS kconfig5_qt) -add_library(KF5ConfigGui ${libkconfiggui_SRCS}) -add_library(KF5::ConfigGui ALIAS KF5ConfigGui) ecm_generate_export_header(KF5ConfigGui BASE_NAME KConfigGui GROUP_BASE_NAME KF diff --git a/src/kconf_update/CMakeLists.txt b/src/kconf_update/CMakeLists.txt index 917a471b..40fb4ccb 100644 --- a/src/kconf_update/CMakeLists.txt +++ b/src/kconf_update/CMakeLists.txt @@ -1,11 +1,12 @@ -########### next target ############### +add_executable(kconf_update) +add_executable(KF5::kconf_update ALIAS kconf_update) -set(kconf_update_SRCS +target_sources(kconf_update PRIVATE kconf_update.cpp kconfigutils.cpp - ) +) -ecm_qt_declare_logging_category(kconf_update_SRCS +ecm_qt_declare_logging_category(kconf_update HEADER kconf_update_debug.h IDENTIFIER KCONF_UPDATE_LOG CATEGORY_NAME kf.config.kconf_update @@ -14,8 +15,6 @@ ecm_qt_declare_logging_category(kconf_update_SRCS EXPORT KCONFIG ) -add_executable(kconf_update ${kconf_update_SRCS}) -add_executable(KF5::kconf_update ALIAS kconf_update) target_link_libraries(kconf_update Qt5::Core KF5::ConfigCore) include(ECMMarkNonGuiExecutable) ecm_mark_nongui_executable(kconf_update) diff --git a/src/kconfig_compiler/CMakeLists.txt b/src/kconfig_compiler/CMakeLists.txt index 2bd41cec..0e11ee58 100644 --- a/src/kconfig_compiler/CMakeLists.txt +++ b/src/kconfig_compiler/CMakeLists.txt @@ -1,6 +1,14 @@ +add_executable(kconfig_compiler) +if(CMAKE_TOOLCHAIN_FILE) + if(BUILD_TESTING) + message(WARNING "Testing should be disabled on cross-compilation") + endif() +else() + add_executable(KF5::kconfig_compiler ALIAS kconfig_compiler) +endif() -set(kconfig_compiler_SRCS +target_sources(kconfig_compiler PRIVATE KConfigParameters.cpp KConfigCodeGeneratorBase.cpp KConfigHeaderGenerator.cpp @@ -9,20 +17,10 @@ set(kconfig_compiler_SRCS kconfig_compiler.cpp ) - -add_executable(kconfig_compiler ${kconfig_compiler_SRCS}) set_target_properties(kconfig_compiler PROPERTIES OUTPUT_NAME "kconfig_compiler_kf5" ) -if(CMAKE_TOOLCHAIN_FILE) - if(BUILD_TESTING) - message(WARNING "Testing should be disabled on cross-compilation") - endif() -else() - add_executable(KF5::kconfig_compiler ALIAS kconfig_compiler) -endif() - target_link_libraries(kconfig_compiler Qt5::Xml) ecm_mark_nongui_executable(kconfig_compiler) From 0d6cdae8f9869dbedc7396b5cfac39f43e76ca51 Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Sat, 29 May 2021 01:24:27 +0200 Subject: [PATCH 163/259] kconfig_add_kcfg_files: catch alias targets before failing internally target_sources() as used internally does not take alias targets. --- KF5ConfigMacros.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/KF5ConfigMacros.cmake b/KF5ConfigMacros.cmake index 7938e4cf..3ceaf17c 100644 --- a/KF5ConfigMacros.cmake +++ b/KF5ConfigMacros.cmake @@ -4,6 +4,7 @@ # Use optional GENERATE_MOC to generate moc if you use signals in your kcfg files. # Use optional USE_RELATIVE_PATH to generate the classes in the build following the given # relative path to the file. +# must not be an alias. # # SPDX-FileCopyrightText: 2006-2009 Alexander Neundorf # SPDX-FileCopyrightText: 2006, 2007, Laurent Montel @@ -17,6 +18,13 @@ function (KCONFIG_ADD_KCFG_FILES _target_or_source_var) set(options GENERATE_MOC USE_RELATIVE_PATH) cmake_parse_arguments(ARG "${options}" "" "" ${ARGN}) + if (TARGET ${_target_or_source_var}) + get_target_property(aliased_target ${_target_or_source_var} ALIASED_TARGET) + if(aliased_target) + message(FATAL_ERROR "Target argument passed to kconfig_add_kcfg_files must not be an alias: ${_target_or_source_var}") + endif() + endif() + set(sources) foreach (_current_FILE ${ARG_UNPARSED_ARGUMENTS}) get_filename_component(_tmp_FILE ${_current_FILE} ABSOLUTE) From ad2c9eb819114b04a263469e99e7afe3f229554e Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 5 Jun 2021 08:51:30 +0000 Subject: [PATCH 164/259] GIT_SILENT Upgrade ECM and KF version requirements for 5.83.0 release. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4babe0b7..30e0ce2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ set(KF_VERSION "5.83.0") # handled by release scripts project(KConfig VERSION ${KF_VERSION}) include(FeatureSummary) -find_package(ECM 5.82.0 NO_MODULE) +find_package(ECM 5.83.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) From c5a81579058fab61cbed22eacf95c71e049c6bf5 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 12 Jun 2021 19:28:17 +0000 Subject: [PATCH 165/259] GIT_SILENT Upgrade KF version to 5.84.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 30e0ce2e..c8c372ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.16) -set(KF_VERSION "5.83.0") # handled by release scripts +set(KF_VERSION "5.84.0") # handled by release scripts project(KConfig VERSION ${KF_VERSION}) include(FeatureSummary) From 6da4db6634560c13a0614c290f92d2dd5192e15e Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 19 Jun 2021 15:54:09 +0000 Subject: [PATCH 166/259] GIT_SILENT Upgrade ECM and KF version requirements for 5.84.0 release. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c8c372ae..046c3989 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ set(KF_VERSION "5.84.0") # handled by release scripts project(KConfig VERSION ${KF_VERSION}) include(FeatureSummary) -find_package(ECM 5.83.0 NO_MODULE) +find_package(ECM 5.84.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) From 74a861c5617621663b1d5d8a1cd79c7a0eef9d8a Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 21 Jun 2021 14:16:23 +0200 Subject: [PATCH 167/259] kconfigtest: save/restore XDG_CONFIG_DIRS No impact on the rest of the test, but I was wondering if it might break anything, better restore it just in case. --- autotests/kconfigtest.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index bf7882f0..d8cc417d 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -960,6 +960,7 @@ void KConfigTest::testCascadingWithLocale() #ifdef Q_XDG_PLATFORM QTemporaryDir middleDir; QTemporaryDir globalDir; + const QByteArray oldConfigDirs = qgetenv("XDG_CONFIG_DIRS"); qputenv("XDG_CONFIG_DIRS", qPrintable(middleDir.path() + QLatin1Char(':') + globalDir.path())); const QString globalConfigDir = globalDir.path() + QLatin1Char('/') + s_test_subdir; @@ -999,6 +1000,7 @@ void KConfigTest::testCascadingWithLocale() QCOMPARE(group.readEntry("FromLocal"), QStringLiteral("vrai")); QCOMPARE(group.readEntry("Name"), QStringLiteral("FR")); QCOMPARE(group.readEntry("Other"), QStringLiteral("English Only")); // Global_FR is locally overriden + qputenv("XDG_CONFIG_DIRS", oldConfigDirs); #endif } From 93c9398cdcf147c5c5e1a89662ffd047e36927ac Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Thu, 1 Jul 2021 02:50:55 +0200 Subject: [PATCH 168/259] Cache global config files Whenever we read a config file, we are first parsing kdeglobalsrc. This caches the parsed entries so that they can be reused as long as it hasn't changed. This reduces the parseConfig calls (which is mostly prominent at early process startup) from 18 to 12 (33%) ksmserver-logout-greeter. This also means there's better cache locality as well as less memory allocated as a lot of objects are shared but I have not measured this. --- src/core/kconfig.cpp | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index cc3700e1..9b8d2e62 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -28,6 +29,7 @@ #include #include #include +#include #if KCONFIG_USE_DBUS #include @@ -44,6 +46,14 @@ Q_GLOBAL_STATIC(QStringList, s_globalFiles) // For caching purposes. static QBasicMutex s_globalFilesMutex; Q_GLOBAL_STATIC_WITH_ARGS(QString, sGlobalFileName, (QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1String("/kdeglobals"))) +using ParseCacheKey = std::pair; +struct ParseCacheValue { + KEntryMap entries; + QDateTime parseTime; +}; +using ParseCache = QThreadStorage>; +Q_GLOBAL_STATIC(ParseCache, sGlobalParse) + #ifndef Q_OS_WIN static const Qt::CaseSensitivity sPathCaseSensitivity = Qt::CaseSensitive; #else @@ -687,8 +697,25 @@ void KConfigPrivate::parseGlobalFiles() const QStringList globalFiles = getGlobalFiles(); // qDebug() << "parsing global files" << globalFiles; - // TODO: can we cache the values in etc_kderc / other global files - // on a per-application basis? + Q_ASSERT(entryMap.isEmpty()); + const ParseCacheKey key = {globalFiles, locale}; + auto data = sGlobalParse->localData().object(key); + QDateTime newest; + for (const auto &file : globalFiles) { + const auto fileDate = QFileInfo(file).lastModified(); + if (fileDate > newest) { + newest = fileDate; + } + } + if (data) { + if (data->parseTime < newest) { + data = nullptr; + } else { + entryMap = data->entries; + return; + } + } + const QByteArray utf8Locale = locale.toUtf8(); for (const QString &file : globalFiles) { KConfigBackend::ParseOptions parseOpts = KConfigBackend::ParseGlobal | KConfigBackend::ParseExpansions; @@ -701,6 +728,7 @@ void KConfigPrivate::parseGlobalFiles() break; } } + sGlobalParse->localData().insert(key, new ParseCacheValue({entryMap, newest})); } void KConfigPrivate::parseConfigFiles() From 57296d5c85a426918a634b15f814a7435b899d32 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Mon, 5 Jul 2021 00:33:27 +0200 Subject: [PATCH 169/259] Use specific API to compare QByteArrays At the moment we are taking a bit of a detour by converting to char*. Not a bit deal but reads better and ends up being less calls. --- src/core/kconfigdata_p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/kconfigdata_p.h b/src/core/kconfigdata_p.h index 3554568e..5e5246f3 100644 --- a/src/core/kconfigdata_p.h +++ b/src/core/kconfigdata_p.h @@ -139,12 +139,12 @@ struct KEntryKey { */ inline bool operator<(const KEntryKey &k1, const KEntryKey &k2) { - int result = qstrcmp(k1.mGroup.data(), k2.mGroup.data()); + int result = k1.mGroup.compare(k2.mGroup); if (result != 0) { return result < 0; } - result = qstrcmp(k1.mKey.data(), k2.mKey.data()); + result = k1.mKey.compare(k2.mKey); if (result != 0) { return result < 0; } From e74f28482253890d1c7e74fa51f087cc3310ce60 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Mon, 5 Jul 2021 00:37:28 +0200 Subject: [PATCH 170/259] Only query for existing config file when it's necessary We are only interested in whether the file doesn't exist when it fails to open. This saves a stat on every successful config file parse. --- src/core/kconfigini.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp index c7861f66..fc6f34ec 100644 --- a/src/core/kconfigini.cpp +++ b/src/core/kconfigini.cpp @@ -68,20 +68,13 @@ KConfigBackend::ParseInfo KConfigIniBackend::parseConfig(const QByteArray &curre // merge changes in the on-disk file with the changes in the KConfig object. KConfigBackend::ParseInfo KConfigIniBackend::parseConfig(const QByteArray ¤tLocale, KEntryMap &entryMap, ParseOptions options, bool merging) { - if (filePath().isEmpty() || !QFile::exists(filePath())) { + if (filePath().isEmpty()) { return ParseOk; } - const QByteArray currentLanguage = currentLocale.split('_').first(); - - bool bDefault = options & ParseDefaults; - bool allowExecutableValues = options & ParseExpansions; - - QByteArray currentGroup(""); - QFile file(filePath()); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - return ParseOpenError; + return file.exists() ? ParseOpenError : ParseOk; } QList immutableGroups; @@ -97,6 +90,11 @@ KConfigBackend::ParseInfo KConfigIniBackend::parseConfig(const QByteArray &curre BufferFragment contents(buffer.data(), buffer.size()); unsigned int len = contents.length(); unsigned int startOfLine = 0; + const QByteArray currentLanguage = currentLocale.split('_').first(); + + QByteArray currentGroup(""); + bool bDefault = options & ParseDefaults; + bool allowExecutableValues = options & ParseExpansions; // Reduce memory overhead by making use of implicit sharing // This assumes that config files contain only a small amount of From 3c78617ac60dd8da2434fcbb7f61bd62d19492a7 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Mon, 5 Jul 2021 00:41:51 +0200 Subject: [PATCH 171/259] Do not create a vector and a QByteArray just to discard it immediately --- src/core/kconfigini.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp index fc6f34ec..a67e490f 100644 --- a/src/core/kconfigini.cpp +++ b/src/core/kconfigini.cpp @@ -90,7 +90,9 @@ KConfigBackend::ParseInfo KConfigIniBackend::parseConfig(const QByteArray &curre BufferFragment contents(buffer.data(), buffer.size()); unsigned int len = contents.length(); unsigned int startOfLine = 0; - const QByteArray currentLanguage = currentLocale.split('_').first(); + + const int langIdx = currentLocale.indexOf('_'); + const QByteArray currentLanguage = langIdx >= 0 ? currentLocale.left(langIdx) : currentLocale; QByteArray currentGroup(""); bool bDefault = options & ParseDefaults; From bd53bb3eb4d88c1b9919a3073df8914de01acf1a Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 10 Jul 2021 19:23:06 +0000 Subject: [PATCH 172/259] GIT_SILENT Upgrade KF version to 5.85.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 046c3989..4aa300f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.16) -set(KF_VERSION "5.84.0") # handled by release scripts +set(KF_VERSION "5.85.0") # handled by release scripts project(KConfig VERSION ${KF_VERSION}) include(FeatureSummary) From 530f9490749505221d137343f1bd556821b820da Mon Sep 17 00:00:00 2001 From: Cyril Rossi Date: Wed, 7 Jul 2021 15:05:44 +0200 Subject: [PATCH 173/259] Update kconfig_compiler documentation with translation options --- src/kconfig_compiler/README.dox | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/kconfig_compiler/README.dox b/src/kconfig_compiler/README.dox index 89b29520..671e9c5b 100644 --- a/src/kconfig_compiler/README.dox +++ b/src/kconfig_compiler/README.dox @@ -272,6 +272,19 @@ The following options are read from the kcfgc file: settings discovery and handle the deallocation. Note this parameter is incompatible with Singleton set to true. + +
TranslationSystem=\
+
+ Default: qt \n + Set the translation system for label, tooltip and whatsthis text in generated KConfigSkeleton. + Set the value to kde to use the KDE Framework translation system, see KI18n. +
+ +
TranslationDomain=\
+
+ When TranslationSystem=kde is set, allow to specify the domain in which to look for translations. +
+ @@ -512,4 +525,20 @@ for a signal, the signal name will suffice. You can also use the generic configChanged() signal from KConfigSkeleton to notify your application about configuration changes. + +\subsection translation_context Translation context + +In the kcfg file you can specify the translation's context for \, \ and \ element for an entry. + +\code{.xml} + + + Enable automatic saving of calendars to have calendars saved automatically. + false + +\endcode + +For more information on translation context and how to write good translatable text, +please refer to https://api.kde.org/frameworks/ki18n/html/prg_guide.html + */ From 3471f19fc56e41b2ee6236ea3016dfa30a76c0ff Mon Sep 17 00:00:00 2001 From: Christophe Giboudeaux Date: Tue, 13 Jul 2021 23:20:57 +0200 Subject: [PATCH 174/259] Fix typos found by codespell GIT_SILENT --- DESIGN | 8 ++++---- TODO | 8 ++++---- autotests/kconfigtest.cpp | 4 ++-- docs/DESIGN.kconfig | 8 ++++---- docs/options.md | 4 ++-- src/core/kconfiggroup.h | 2 +- src/kconfig_compiler/KConfigCodeGeneratorBase.cpp | 2 +- src/kconfig_compiler/KConfigCodeGeneratorBase.h | 2 +- src/kconfig_compiler/kcfg.xsd | 2 +- src/kconfig_compiler/kconfig_compiler.cpp | 2 +- 10 files changed, 21 insertions(+), 21 deletions(-) diff --git a/DESIGN b/DESIGN index a5fbd2b5..0f4a590a 100644 --- a/DESIGN +++ b/DESIGN @@ -33,8 +33,8 @@ current config object's entry map and then written back. Note that there is a subtle difference between revertToDefault() and deleteEntry(). revertToDefault() will change the entry to the default value set by the system administrator (Via e.g. $KDEDIR/share/config) or, if no such default was set, -non-existant. -deleteEntry() will make the entry non-existant. If if the system administrator +non-existent. +deleteEntry() will make the entry non-existent. If if the system administrator has specified a default value, the local entry is marked with [$d]. Entries are marked "immutable" if the key is followed by [$i]. This means @@ -47,7 +47,7 @@ KConfig XT ========== My buzzword picker offered KConfig XT ("eXtended Technology") and KConfig NG -("Next Generation"). Since the planned changes are ment to be evolutionary +("Next Generation"). Since the planned changes are meant to be evolutionary rather than revolutionary, KConfig NG was dropped. Goals @@ -96,7 +96,7 @@ myconfig.kcfgc: Implementation specific code generation instructions choses the actual name. KConfigDialogManager: Class that links widgets in a dialog up with their - corresponding confguration options in a configuration + corresponding configuration options in a configuration object derived from KConfigSkeleton. MyConfigWidget: Dialog generated from a .ui description file. Widget names diff --git a/TODO b/TODO index 4346ee13..4f86d878 100644 --- a/TODO +++ b/TODO @@ -14,7 +14,7 @@ wishes ====== - use lazy loading - - load as soon as the first KConfigGroup is instanciated + - load as soon as the first KConfigGroup is instantiated - lazy parsing of values is interesting, too - see kconfig_take2 branch - add $\\VAR and $\\(cmd) escapes to list-quote expanded string - possibly: @@ -75,18 +75,18 @@ create a submap). however, keeping that consistent with deletions would be a nightmare, and with the rescan changing the groups underneath impossible without each map having a list of referring configgroups. therefore it might make more sense to always create a corresponding tree -of empty maps when a configroup for a non-existing group is instanciated +of empty maps when a configroup for a non-existing group is instantiated - these groups won't be written out (they have no entries and cannot be immutable) and access to non-existing groups (esp. without an subsequent write that would actually create it) is rare, so the performance and memory overhead of this "eager" approach is likely to be negligible. as a middle way one could use a pointer and lazily populate it on first -access whithout putting semantics into the pointer being already set, +access without putting semantics into the pointer being already set, but i don't think the added complexity will pay off. 4) > > > > hmm, wait. maybe it would be better if the map did not do actual -> > > > permission checking. the frontent is peppered with asserts already +> > > > permission checking. the frontend is peppered with asserts already > > > > > > that's the group doing permission checking, if this group is immutable > > > then the entry can't be changed. plus, now that KEntryKey doesn't know diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index d8cc417d..49f22d1b 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -822,7 +822,7 @@ void KConfigTest::testDelete() QVERIFY(sc.entryMap(QStringLiteral("Complex Types")).isEmpty()); QVERIFY(sc.entryMap(QStringLiteral("AAA")).isEmpty()); QVERIFY(!sc.entryMap(QStringLiteral("Hello")).isEmpty()); // not deleted group - QVERIFY(sc.entryMap(QStringLiteral("FooBar")).isEmpty()); // inexistant group + QVERIFY(sc.entryMap(QStringLiteral("FooBar")).isEmpty()); // inexistent group QVERIFY(cg.sync()); // Check what happens on disk @@ -999,7 +999,7 @@ void KConfigTest::testCascadingWithLocale() QCOMPARE(group.readEntry("FromGlobal"), QStringLiteral("vrai")); QCOMPARE(group.readEntry("FromLocal"), QStringLiteral("vrai")); QCOMPARE(group.readEntry("Name"), QStringLiteral("FR")); - QCOMPARE(group.readEntry("Other"), QStringLiteral("English Only")); // Global_FR is locally overriden + QCOMPARE(group.readEntry("Other"), QStringLiteral("English Only")); // Global_FR is locally overridden qputenv("XDG_CONFIG_DIRS", oldConfigDirs); #endif } diff --git a/docs/DESIGN.kconfig b/docs/DESIGN.kconfig index 68994aed..d2f2056a 100644 --- a/docs/DESIGN.kconfig +++ b/docs/DESIGN.kconfig @@ -53,8 +53,8 @@ void deleteEntry(key); // Remove entry Note that there is a subtle difference between revertToDefault() and deleteEntry(). revertToDefault() will change the entry to the default value set by the system administrator (Via e.g. $KDEDIR/share/config) or, if no such default was set, -non-existant. -deleteEntry() will make the entry non-existant. +non-existent. +deleteEntry() will make the entry non-existent. Entries are marked "immutable" if the key is followed by [$i]. This means that a user can not override these entries. @@ -103,7 +103,7 @@ KConfig XT ========== My buzzword picker offered KConfig XT ("eXtended Technology") and KConfig NG -("Next Generation"). Since the planned changes are ment to be evolutionary +("Next Generation"). Since the planned changes are meant to be evolutionary rather than revolutionary, KConfig NG was dropped. Goals @@ -216,7 +216,7 @@ myconfig.kcfg-codegen: Implementation specific code generation instructions choses the actual name. KConfigDialogManager: Class that links widgets in a dialog up with their - corresponding confguration options in a configuration + corresponding configuration options in a configuration object derived from KConfigSkeleton. MyConfigWidget: Dialog generated from a .ui description file. Widget names diff --git a/docs/options.md b/docs/options.md index 4a6e9bc1..b57713de 100644 --- a/docs/options.md +++ b/docs/options.md @@ -48,11 +48,11 @@ Once this is done, the immutable entries or groups cannot be overridden by later files of the same name (and, if the file is immutable, later files will be ignored entirely). -Note that a similar effect to file immutability can be acheived by using file +Note that a similar effect to file immutability can be achieved by using file system permissions to prevent the user from writing to their local versions of the configuration file, although (since this is normally a setup error), the user will be warned that the configuration file is not writable. This warning -can be supressed by adding the following setting to either the relevant +can be suppressed by adding the following setting to either the relevant configuration file or the `kdeglobals` file: [General] diff --git a/src/core/kconfiggroup.h b/src/core/kconfiggroup.h index 5c125dd2..2584cb85 100644 --- a/src/core/kconfiggroup.h +++ b/src/core/kconfiggroup.h @@ -113,7 +113,7 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase QString name() const; /** - * Check whether the containing KConfig object acutally contains a + * Check whether the containing KConfig object actually contains a * group with this name. */ bool exists() const; diff --git a/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp b/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp index f1ff06b3..0effd7e5 100644 --- a/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp +++ b/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp @@ -149,7 +149,7 @@ void KConfigCodeGeneratorBase::endNamespaces() } } -// returns the member accesor implementation +// returns the member accessor implementation // which should go in the h file if inline // or the cpp file if not inline QString KConfigCodeGeneratorBase::memberAccessorBody(const CfgEntry *e, bool globalEnums) const diff --git a/src/kconfig_compiler/KConfigCodeGeneratorBase.h b/src/kconfig_compiler/KConfigCodeGeneratorBase.h index 4a100518..7a8c8502 100644 --- a/src/kconfig_compiler/KConfigCodeGeneratorBase.h +++ b/src/kconfig_compiler/KConfigCodeGeneratorBase.h @@ -121,7 +121,7 @@ class KConfigCodeGeneratorBase return m_stream; } - // HACK: This needs to be accesible because the HeaderGenerator actually modifies + // HACK: This needs to be accessible because the HeaderGenerator actually modifies // it while running. Considering that this is a the result of the xml Parse, and not // the result of generating code, I consider this to be quite wrong - but moving the // changes away from the header generator only created more problems and I have to diff --git a/src/kconfig_compiler/kcfg.xsd b/src/kconfig_compiler/kcfg.xsd index 1ec1dc81..f9175a1d 100644 --- a/src/kconfig_compiler/kcfg.xsd +++ b/src/kconfig_compiler/kcfg.xsd @@ -65,7 +65,7 @@ - + diff --git a/src/kconfig_compiler/kconfig_compiler.cpp b/src/kconfig_compiler/kconfig_compiler.cpp index e997eac9..28b10e4f 100644 --- a/src/kconfig_compiler/kconfig_compiler.cpp +++ b/src/kconfig_compiler/kconfig_compiler.cpp @@ -619,7 +619,7 @@ QString memberGetDefaultBody(const CfgEntry *e) return result; } -// returns the item accesor implementation +// returns the item accessor implementation // which should go in the h file if inline // or the cpp file if not inline QString itemAccessorBody(const CfgEntry *e, const KConfigParameters &cfg) From dcc5f6529d3008f2cf3a678a4c42d5092b406690 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Wed, 14 Jul 2021 22:28:23 +0000 Subject: [PATCH 175/259] GIT_SILENT Upgrade ECM and KF version requirements for 5.85.0 release. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4aa300f3..91ab39ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ set(KF_VERSION "5.85.0") # handled by release scripts project(KConfig VERSION ${KF_VERSION}) include(FeatureSummary) -find_package(ECM 5.84.0 NO_MODULE) +find_package(ECM 5.85.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) From ed28682265bd95416a98d5ccc6a72e96563f84f3 Mon Sep 17 00:00:00 2001 From: David Faure Date: Wed, 23 Jun 2021 12:05:33 +0200 Subject: [PATCH 176/259] KConfig: fix deletion of an entry that is also in kdeglobals This is the case where we expected to see Key[$d] in the config file, and it was somehow broken. When saving, the key was omitted, so when reloading the kdeglobals key was present again. Detected when trying to write a unittest for a different patch... I had to reshuffle the unittest a bit because testThreads calls testSimple which didn't expect that the "[AAA]" group would actually be deleted now. --- autotests/kconfigtest.cpp | 80 +++++++++++++++++++++++++++++++++------ autotests/kconfigtest.h | 1 + src/core/kconfigdata.cpp | 7 ++-- src/core/kconfigini.cpp | 2 +- 4 files changed, 75 insertions(+), 15 deletions(-) diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index 49f22d1b..af62b14d 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -116,9 +116,15 @@ void KConfigTest::initTestCase() KConfig sc(s_kconfig_test_subdir); - KConfigGroup cg(&sc, "AAA"); + KConfigGroup cg(&sc, "AAA"); // deleted later by testDelete cg.writeEntry("stringEntry1", s_string_entry1, KConfig::Persistent | KConfig::Global); - cg.deleteEntry("stringEntry2", KConfig::Global); + + cg = KConfigGroup(&sc, "GlobalGroup"); + cg.writeEntry("globalEntry", s_string_entry1, KConfig::Persistent | KConfig::Global); + cg.deleteEntry("globalEntry2", KConfig::Global); + + cg = KConfigGroup(&sc, "LocalGroupToBeDeleted"); // deleted later by testDelete + cg.writeEntry("stringEntry1", s_string_entry1); cg = KConfigGroup(&sc, "Hello"); cg.writeEntry("boolEntry1", s_bool_entry1); @@ -339,16 +345,16 @@ void KConfigTest::testSimple() QVERIFY(!group.contains(QChar(0x1d))); } - KConfigGroup sc3(&sc2, "AAA"); + KConfigGroup sc3(&sc2, "GlobalGroup"); - QVERIFY(sc3.hasKey("stringEntry1")); // from kdeglobals - QVERIFY(!sc3.isEntryImmutable("stringEntry1")); - QCOMPARE(sc3.readEntry("stringEntry1"), s_string_entry1); + QVERIFY(sc3.hasKey("globalEntry")); // from kdeglobals + QVERIFY(!sc3.isEntryImmutable("globalEntry")); + QCOMPARE(sc3.readEntry("globalEntry"), s_string_entry1); - QVERIFY(!sc3.hasKey("stringEntry2")); - QCOMPARE(sc3.readEntry("stringEntry2", QStringLiteral("bla")), QStringLiteral("bla")); + QVERIFY(!sc3.hasKey("globalEntry2")); + QCOMPARE(sc3.readEntry("globalEntry2", QStringLiteral("bla")), QStringLiteral("bla")); - QVERIFY(!sc3.hasDefault("stringEntry1")); + QVERIFY(!sc3.hasDefault("globalEntry")); sc3 = KConfigGroup(&sc2, "Hello"); QCOMPARE(sc3.readEntry("Test", QByteArray()), QByteArray(s_utf8bit_entry)); @@ -824,6 +830,8 @@ void KConfigTest::testDelete() QVERIFY(!sc.entryMap(QStringLiteral("Hello")).isEmpty()); // not deleted group QVERIFY(sc.entryMap(QStringLiteral("FooBar")).isEmpty()); // inexistent group + KConfigGroup(&sc, "LocalGroupToBeDeleted").deleteGroup(); + QVERIFY(cg.sync()); // Check what happens on disk const QList lines = readLines(); @@ -832,7 +840,8 @@ void KConfigTest::testDelete() QVERIFY(!lines.contains("[Complex Types][Nested Group 1]\n")); QVERIFY(!lines.contains("[Complex Types][Nested Group 2]\n")); QVERIFY(!lines.contains("[Complex Types][Nested Group 2.1]\n")); - QVERIFY(!lines.contains("[AAA]\n")); + QVERIFY(!lines.contains("[LocalGroupToBeDeleted]\n")); + QVERIFY(lines.contains("[AAA]\n")); // deleted from kconfigtest, but present in kdeglobals, so [$d] QVERIFY(lines.contains("[Hello]\n")); // a group that was not deleted // test for entries that are marked as deleted when there is no default @@ -1712,8 +1721,57 @@ void KConfigTest::testKdeGlobals() const KConfigGroup generalNoGlob(&globReadNoGlob, "General"); QCOMPARE(generalNoGlob.readEntry("testKG"), QStringLiteral("2")); } +} + +void KConfigTest::testLocalDeletion() +{ + // Prepare kdeglobals + { + KConfig glob(QStringLiteral("kdeglobals")); + KConfigGroup general(&glob, "OwnTestGroup"); + general.writeEntry("GlobalKey", "DontTouchMe"); + QVERIFY(glob.sync()); + } - // TODO now use kconfigtest and writeEntry(,Global) -> should go into kdeglobals + QStringList expectedKeys{QStringLiteral("LocalKey")}; + expectedKeys.prepend(QStringLiteral("GlobalWrite")); + + // Write into kconfigtest, including deleting GlobalKey + { + KConfig mainConfig(s_kconfig_test_subdir); + KConfigGroup mainGroup(&mainConfig, "OwnTestGroup"); + mainGroup.writeEntry("LocalKey", QStringLiteral("LocalValue")); + mainGroup.writeEntry("GlobalWrite", QStringLiteral("GlobalValue"), KConfig::Persistent | KConfig::Global); // goes to kdeglobals + QCOMPARE(mainGroup.readEntry("GlobalKey"), QStringLiteral("DontTouchMe")); + mainGroup.deleteEntry("GlobalKey"); // local deletion ([$d]), kdeglobals is unchanged + QCOMPARE(mainGroup.readEntry("GlobalKey", "Default"), QStringLiteral("Default")); // key is gone + QCOMPARE(mainGroup.keyList(), expectedKeys); + } + + // Check what ended up in kconfigtest + const QList lines = readLines(); + QVERIFY(lines.contains("[OwnTestGroup]\n")); + QVERIFY(lines.contains("GlobalKey[$d]\n")); + + // Check what ended up in kdeglobals + { + KConfig globReadNoGlob(QStringLiteral("kdeglobals"), KConfig::NoGlobals); + const KConfigGroup generalNoGlob(&globReadNoGlob, "OwnTestGroup"); + QCOMPARE(generalNoGlob.readEntry("GlobalKey"), QStringLiteral("DontTouchMe")); + QCOMPARE(generalNoGlob.readEntry("GlobalWrite"), QStringLiteral("GlobalValue")); + QVERIFY(!generalNoGlob.hasKey("LocalValue")); + QStringList expectedGlobalKeys{QStringLiteral("GlobalKey")}; + expectedGlobalKeys.append(QStringLiteral("GlobalWrite")); + QCOMPARE(generalNoGlob.keyList(), expectedGlobalKeys); + } + + // Check what we see when re-reading the config file + { + KConfig mainConfig(s_kconfig_test_subdir); + KConfigGroup mainGroup(&mainConfig, "OwnTestGroup"); + QCOMPARE(mainGroup.readEntry("GlobalKey", "Default"), QStringLiteral("Default")); // key is gone + QCOMPARE(mainGroup.keyList(), expectedKeys); + } } void KConfigTest::testAnonymousConfig() diff --git a/autotests/kconfigtest.h b/autotests/kconfigtest.h index d6502331..9d519eda 100644 --- a/autotests/kconfigtest.h +++ b/autotests/kconfigtest.h @@ -76,6 +76,7 @@ private Q_SLOTS: void testLocaleConfig(); void testDirtyAfterRevert(); void testKdeGlobals(); + void testLocalDeletion(); void testNewlines(); void testXdgListEntry(); void testNotify(); diff --git a/src/core/kconfigdata.cpp b/src/core/kconfigdata.cpp index b479a598..0d6a7bb9 100644 --- a/src/core/kconfigdata.cpp +++ b/src/core/kconfigdata.cpp @@ -18,8 +18,9 @@ QDebug operator<<(QDebug dbg, const KEntryKey &key) QDebug operator<<(QDebug dbg, const KEntry &entry) { - dbg.nospace() << "[" << entry.mValue << (entry.bDirty ? " dirty" : "") << (entry.bGlobal ? " global" : "") << (entry.bImmutable ? " immutable" : "") - << (entry.bDeleted ? " deleted" : "") << (entry.bReverted ? " reverted" : "") << (entry.bExpand ? " expand" : "") << "]"; + dbg.nospace() << "[" << entry.mValue << (entry.bDirty ? " dirty" : "") << (entry.bGlobal ? " global" : "") + << (entry.bOverridesGlobal ? " overrides global" : "") << (entry.bImmutable ? " immutable" : "") << (entry.bDeleted ? " deleted" : "") + << (entry.bReverted ? " reverted" : "") << (entry.bExpand ? " expand" : "") << "]"; return dbg.space(); } @@ -164,7 +165,7 @@ bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const Q } } if (it.value() != e) { - // qDebug() << "changing" << k << "from" << e.mValue << "to" << value; + // qDebug() << "changing" << k << "from" << it.value().mValue << "to" << value << e; it.value() = e; if (k.bDefault) { KEntryKey nonDefaultKey(k); diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp index a67e490f..2792cb4f 100644 --- a/src/core/kconfigini.cpp +++ b/src/core/kconfigini.cpp @@ -437,7 +437,7 @@ bool KConfigIniBackend::writeConfig(const QByteArray &locale, KEntryMap &entryMa } else { KEntryKey defaultKey = key; defaultKey.bDefault = true; - if (!entryMap.contains(defaultKey)) { + if (!entryMap.contains(defaultKey) && !it->bOverridesGlobal) { writeMap.remove(key); // remove the deleted entry if there is no default // qDebug() << "Detected as deleted=>removed:" << key.mGroup << key.mKey << "global=" << bGlobal; } else { From 17c179566d764d9a55b6ae98006495133bcffdbf Mon Sep 17 00:00:00 2001 From: David Faure Date: Wed, 23 Jun 2021 12:34:53 +0200 Subject: [PATCH 177/259] KConfig: sort keys in keyListImpl() so unittests can rely on it The code was using a QSet (hash-based), use a std::set instead for unicity, it gives us sorting for free. We probably want to do the same in groupList(), but that's separate. --- src/core/kconfig.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index 9b8d2e62..b4777575 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -31,6 +31,8 @@ #include #include +#include + #if KCONFIG_USE_DBUS #include #include @@ -347,14 +349,14 @@ QStringList KConfigPrivate::keyListImpl(const QByteArray &theGroup) const if (it != theEnd) { ++it; // advance past the special group entry marker - QSet tmp; + std::set tmp; // unique set, sorted for unittests for (; it != theEnd && it.key().mGroup == theGroup; ++it) { const KEntryKey &key = it.key(); if (!key.mKey.isNull() && !it->bDeleted) { - tmp << QString::fromUtf8(key.mKey); + tmp.insert(QString::fromUtf8(key.mKey)); } } - keys = tmp.values(); + keys = QList(tmp.begin(), tmp.end()); } return keys; From 783d1c28c88229f81715f6ecd1cf3866855252a2 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Fri, 13 Aug 2021 02:10:47 +0200 Subject: [PATCH 178/259] clang-tidy: one declaration per line; braces around statements clang-tidy checks: readability-isolate-declaration and readability-braces-around-statements KF task: https://phabricator.kde.org/T14729 GIT_SILENT --- .git-blame-ignore-revs | 3 ++- autotests/kconfigtest.cpp | 12 ++++++++---- src/core/kconfig.cpp | 6 ++++-- src/core/kconfiggroup.cpp | 3 ++- src/core/kconfigini.cpp | 5 +++-- src/core/kcoreconfigskeleton.cpp | 3 ++- src/kconf_update/kconf_update.cpp | 3 ++- src/kconfig_compiler/KConfigHeaderGenerator.cpp | 5 +++-- src/kconfig_compiler/KConfigSourceGenerator.cpp | 6 ++++-- src/kconfig_compiler/KConfigXmlParser.cpp | 8 ++++---- src/kconfig_compiler/kconfig_compiler.cpp | 6 ++++-- src/kreadconfig/kreadconfig.cpp | 16 ++++++++++------ src/kreadconfig/kwriteconfig.cpp | 5 +++-- 13 files changed, 51 insertions(+), 30 deletions(-) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index a64f7abc..d7c1427a 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -1,3 +1,4 @@ -#clang-format +#clang-format/tidy 8bed00ab34e31f2b9c70026d418d923913325798 48c132be8aa983165126b0641a083848dd5c6620 +06ca3b8c62989f59ca348606dfd4eda9e3ee3ec0 diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index af62b14d..256acb36 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -853,10 +853,11 @@ void KConfigTest::testDelete() int count = 0; const QList listLines = readLines(); - for (const QByteArray &item : listLines) + for (const QByteArray &item : listLines) { if (item.startsWith("devices|")) { // krazy:exclude=strings ++count; } + } QCOMPARE(count, 2); cg.deleteEntry("devices|manual|/mnt/ipod"); QVERIFY(cf.sync()); @@ -1364,7 +1365,8 @@ static void ageTimeStamp(const QString &path, int nsec) void KConfigTest::testWriteOnSync() { - QDateTime oldStamp, newStamp; + QDateTime oldStamp; + QDateTime newStamp; KConfig sc(s_kconfig_test_subdir, KConfig::IncludeGlobals); // Age the timestamp of global config file a few sec, and collect it. @@ -1411,8 +1413,9 @@ void KConfigTest::testFailOnReadOnlyFileSync() QVERIFY(f.setPermissions(QFileDevice::ReadOwner)); #ifndef Q_OS_WIN - if (::getuid() == 0) + if (::getuid() == 0) { QSKIP("Root can write to read-only files"); + } #endif cgLocal.writeEntry("someLocalString", "whatever2"); QVERIFY(!cgLocal.sync()); @@ -1423,7 +1426,8 @@ void KConfigTest::testFailOnReadOnlyFileSync() void KConfigTest::testDirtyOnEqual() { - QDateTime oldStamp, newStamp; + QDateTime oldStamp; + QDateTime newStamp; KConfig sc(s_kconfig_test_subdir); // Initialize value diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index b4777575..b5fd9d63 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -580,8 +580,9 @@ void KConfig::setMainConfigName(const QString &str) QString KConfig::mainConfigName() { KConfigStaticData *data = globalData(); - if (data->appArgs.isEmpty()) + if (data->appArgs.isEmpty()) { data->appArgs = QCoreApplication::arguments(); + } // --config on the command line overrides everything else const QStringList args = data->appArgs; @@ -722,8 +723,9 @@ void KConfigPrivate::parseGlobalFiles() for (const QString &file : globalFiles) { KConfigBackend::ParseOptions parseOpts = KConfigBackend::ParseGlobal | KConfigBackend::ParseExpansions; - if (file.compare(*sGlobalFileName, sPathCaseSensitivity) != 0) + if (file.compare(*sGlobalFileName, sPathCaseSensitivity) != 0) { parseOpts |= KConfigBackend::ParseDefaults; + } QExplicitlySharedDataPointer backend = KConfigBackend::create(file); if (backend->parseConfig(utf8Locale, entryMap, parseOpts) == KConfigBackend::ParseImmutable) { diff --git a/src/core/kconfiggroup.cpp b/src/core/kconfiggroup.cpp index 5ee9f6ab..a15c45eb 100644 --- a/src/core/kconfiggroup.cpp +++ b/src/core/kconfiggroup.cpp @@ -935,10 +935,11 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value, WriteConfi data = value.toString().toUtf8(); break; case QMetaType::QVariantList: - if (!value.canConvert(QMetaType::QStringList)) + if (!value.canConvert(QMetaType::QStringList)) { qCWarning(KCONFIG_CORE_LOG) << "not all types in \"" << key << "\" can convert to QString," " information will be lost"; + } Q_FALLTHROUGH(); case QMetaType::QStringList: writeEntry(key, value.toList(), flags); diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp index 2792cb4f..5bc8743c 100644 --- a/src/core/kconfigini.cpp +++ b/src/core/kconfigini.cpp @@ -592,10 +592,11 @@ void KConfigIniBackend::setFilePath(const QString &file) setLocalFilePath(info.canonicalFilePath()); } else { const QString dir = info.dir().canonicalPath(); - if (!dir.isEmpty()) + if (!dir.isEmpty()) { setLocalFilePath(dir + QLatin1Char('/') + info.fileName()); - else + } else { setLocalFilePath(file); + } } } diff --git a/src/core/kcoreconfigskeleton.cpp b/src/core/kcoreconfigskeleton.cpp index ab968023..e1c5c1dd 100644 --- a/src/core/kcoreconfigskeleton.cpp +++ b/src/core/kcoreconfigskeleton.cpp @@ -17,10 +17,11 @@ static QString obscuredString(const QString &str) { QString result; const QChar *unicode = str.unicode(); - for (int i = 0; i < str.length(); ++i) + for (int i = 0; i < str.length(); ++i) { // yes, no typo. can't encode ' ' or '!' because // they're the unicode BOM. stupid scrambling. stupid. result += (unicode[i].unicode() <= 0x21) ? unicode[i] : QChar(0x1001F - unicode[i].unicode()); + } return result; } diff --git a/src/kconf_update/kconf_update.cpp b/src/kconf_update/kconf_update.cpp index d4f7e15e..bfb115dd 100644 --- a/src/kconf_update/kconf_update.cpp +++ b/src/kconf_update/kconf_update.cpp @@ -575,7 +575,8 @@ void KonfUpdate::gotRemoveGroup(const QString &_group) void KonfUpdate::gotKey(const QString &_key) { - QString oldKey, newKey; + QString oldKey; + QString newKey; const int i = _key.indexOf(QLatin1Char{','}); if (i == -1) { oldKey = _key.trimmed(); diff --git a/src/kconfig_compiler/KConfigHeaderGenerator.cpp b/src/kconfig_compiler/KConfigHeaderGenerator.cpp index bf29da05..24829ff5 100644 --- a/src/kconfig_compiler/KConfigHeaderGenerator.cpp +++ b/src/kconfig_compiler/KConfigHeaderGenerator.cpp @@ -319,10 +319,11 @@ void KConfigHeaderGenerator::createConstructor() stream() << whitespace() << "" << cfg().className << "("; if (parseResult.cfgFileNameArg) { - if (cfg().forceStringFilename) + if (cfg().forceStringFilename) { stream() << " const QString &cfgfilename" << (parseResult.parameters.isEmpty() ? " = QString()" : ", "); - else + } else { stream() << " KSharedConfig::Ptr config" << (parseResult.parameters.isEmpty() ? " = KSharedConfig::openConfig()" : ", "); + } } bool first = true; diff --git a/src/kconfig_compiler/KConfigSourceGenerator.cpp b/src/kconfig_compiler/KConfigSourceGenerator.cpp index d308ffcd..e221d1ab 100644 --- a/src/kconfig_compiler/KConfigSourceGenerator.cpp +++ b/src/kconfig_compiler/KConfigSourceGenerator.cpp @@ -674,11 +674,13 @@ void KConfigSourceGenerator::createSignalFlagsHandler() stream() << '\n'; stream() << "void " << cfg().className << "::" << "itemChanged(quint64 flags) {\n"; - if (parseResult.hasNonModifySignals) + if (parseResult.hasNonModifySignals) { stream() << " " << varPath(QStringLiteral("settingsChanged"), cfg()) << " |= flags;\n"; + } - if (!parseResult.signalList.isEmpty()) + if (!parseResult.signalList.isEmpty()) { stream() << '\n'; + } for (const Signal &signal : qAsConst(parseResult.signalList)) { if (signal.modify) { diff --git a/src/kconfig_compiler/KConfigXmlParser.cpp b/src/kconfig_compiler/KConfigXmlParser.cpp index 5b2fb775..3d054522 100644 --- a/src/kconfig_compiler/KConfigXmlParser.cpp +++ b/src/kconfig_compiler/KConfigXmlParser.cpp @@ -371,24 +371,24 @@ CfgEntry *KConfigXmlParser::parseEntry(const QString &group, const QString &pare readParamDefaultValues(readEntry, element); if (!mValidNameRegexp.match(readEntry.name).hasMatch()) { - if (nameIsEmpty) + if (nameIsEmpty) { std::cerr << "The key '" << qPrintable(readEntry.key) << "' can not be used as name for the entry because " "it is not a valid name. You need to specify a valid name for this entry." << std::endl; - else { + } else { std::cerr << "The name '" << qPrintable(readEntry.name) << "' is not a valid name for an entry." << std::endl; } exit(1); } if (mAllNames.contains(readEntry.name)) { - if (nameIsEmpty) + if (nameIsEmpty) { std::cerr << "The key '" << qPrintable(readEntry.key) << "' can not be used as name for the entry because " "it does not result in a unique name. You need to specify a unique name for this entry." << std::endl; - else { + } else { std::cerr << "The name '" << qPrintable(readEntry.name) << "' is not unique." << std::endl; } exit(1); diff --git a/src/kconfig_compiler/kconfig_compiler.cpp b/src/kconfig_compiler/kconfig_compiler.cpp index 28b10e4f..761e64fc 100644 --- a/src/kconfig_compiler/kconfig_compiler.cpp +++ b/src/kconfig_compiler/kconfig_compiler.cpp @@ -645,10 +645,11 @@ QString indent(QString text, int spaces) QString currLine; while (!in.atEnd()) { currLine = in.readLine(); - if (!currLine.isEmpty()) + if (!currLine.isEmpty()) { for (int i = 0; i < spaces; ++i) { out << " "; } + } out << currLine << '\n'; } return result; @@ -700,7 +701,8 @@ int main(int argc, char **argv) app.setApplicationName(QStringLiteral("kconfig_compiler")); app.setApplicationVersion(QStringLiteral(KCONFIG_VERSION_STRING)); - QString inputFilename, codegenFilename; + QString inputFilename; + QString codegenFilename; QCommandLineOption targetDirectoryOption(QStringList{QStringLiteral("d"), QStringLiteral("directory")}, QCoreApplication::translate("main", "Directory to generate files in [.]"), diff --git a/src/kreadconfig/kreadconfig.cpp b/src/kreadconfig/kreadconfig.cpp index f0fb3518..01d44326 100644 --- a/src/kreadconfig/kreadconfig.cpp +++ b/src/kreadconfig/kreadconfig.cpp @@ -67,9 +67,9 @@ int main(int argc, char **argv) KConfig *konfig; bool configMustDeleted = false; - if (file.isEmpty()) + if (file.isEmpty()) { konfig = KSharedConfig::openConfig().data(); - else { + } else { konfig = new KConfig(file, KConfig::NoGlobals); configMustDeleted = true; } @@ -82,24 +82,28 @@ int main(int argc, char **argv) dflt = dflt.toLower(); bool def = (dflt == QLatin1String{"true"} || dflt == QLatin1String{"on"} || dflt == QLatin1String{"yes"} || dflt == QLatin1String{"1"}); bool retValue = !cfgGroup.readEntry(key, def); - if (configMustDeleted) + if (configMustDeleted) { delete konfig; + } return retValue; } else if (type == QLatin1String{"num"} || type == QLatin1String{"int"}) { int retValue = cfgGroup.readEntry(key, dflt.toInt()); - if (configMustDeleted) + if (configMustDeleted) { delete konfig; + } return retValue; } else if (type == QLatin1String{"path"}) { fprintf(stdout, "%s\n", cfgGroup.readPathEntry(key, dflt).toLocal8Bit().data()); - if (configMustDeleted) + if (configMustDeleted) { delete konfig; + } return 0; } else { /* Assume it's a string... */ fprintf(stdout, "%s\n", cfgGroup.readEntry(key, dflt).toLocal8Bit().data()); - if (configMustDeleted) + if (configMustDeleted) { delete konfig; + } return 0; } } diff --git a/src/kreadconfig/kwriteconfig.cpp b/src/kreadconfig/kwriteconfig.cpp index 67d9637e..20036331 100644 --- a/src/kreadconfig/kwriteconfig.cpp +++ b/src/kreadconfig/kwriteconfig.cpp @@ -53,10 +53,11 @@ int main(int argc, char **argv) } KConfig *konfig; - if (file.isEmpty()) + if (file.isEmpty()) { konfig = new KConfig(QStringLiteral("kdeglobals"), KConfig::NoGlobals); - else + } else { konfig = new KConfig(file, KConfig::NoGlobals); + } KConfigGroup cfgGroup = konfig->group(QString()); for (const QString &grp : groups) { From f74498d0439943b69795321a3712e6d1d7419bbe Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 14 Aug 2021 11:18:40 +0000 Subject: [PATCH 179/259] GIT_SILENT Upgrade KF version to 5.86.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 91ab39ed..fce079a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.16) -set(KF_VERSION "5.85.0") # handled by release scripts +set(KF_VERSION "5.86.0") # handled by release scripts project(KConfig VERSION ${KF_VERSION}) include(FeatureSummary) From 98e74c201c760c17fd6b7143f649ae42d3e0667f Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sun, 15 Aug 2021 08:53:39 +0000 Subject: [PATCH 180/259] GIT_SILENT Upgrade Qt5 version requirement to 5.15.2. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fce079a5..79356ad3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKA set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) -set(REQUIRED_QT_VERSION 5.15.0) +set(REQUIRED_QT_VERSION 5.15.2) find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Xml) option(KCONFIG_USE_GUI "Build components using Qt5Gui" ON) @@ -51,7 +51,7 @@ ecm_setup_version(PROJECT VARIABLE_PREFIX KCONFIG PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5ConfigConfigVersion.cmake" SOVERSION 5) -add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050f00) +add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050f02) add_subdirectory(src) if (BUILD_TESTING) From 4f8ed9b7815584afc59a9ea73bb401d9b4006d68 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Wed, 18 Aug 2021 15:26:07 +0200 Subject: [PATCH 181/259] Port to QStrinView Now that KF requires Qt 5.15.2; this basically reverts commit 2e8742e64fc0 with some trivial changes. NO_CHANGELOG --- src/core/kconfig.cpp | 10 ++--- src/gui/kconfigloader.cpp | 68 +++++++++++++------------------ src/gui/kconfigloaderhandler_p.h | 5 +-- src/kconf_update/kconfigutils.cpp | 4 ++ 4 files changed, 39 insertions(+), 48 deletions(-) diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index b5fd9d63..0bf6cccd 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -186,21 +186,21 @@ QString KConfigPrivate::expandString(const QString &value) int nDollarPos = aValue.indexOf(QLatin1Char('$')); while (nDollarPos != -1 && nDollarPos + 1 < aValue.length()) { // there is at least one $ - if (aValue[nDollarPos + 1] != QLatin1Char('$')) { + if (aValue.at(nDollarPos + 1) != QLatin1Char('$')) { int nEndPos = nDollarPos + 1; // the next character is not $ - QStringRef aVarName; - if (aValue[nEndPos] == QLatin1Char('{')) { + QStringView aVarName; + if (aValue.at(nEndPos) == QLatin1Char('{')) { while ((nEndPos <= aValue.length()) && (aValue[nEndPos] != QLatin1Char('}'))) { ++nEndPos; } ++nEndPos; - aVarName = aValue.midRef(nDollarPos + 2, nEndPos - nDollarPos - 3); + aVarName = QStringView(aValue).mid(nDollarPos + 2, nEndPos - nDollarPos - 3); } else { while (nEndPos < aValue.length() && (aValue[nEndPos].isNumber() || aValue[nEndPos].isLetter() || aValue[nEndPos] == QLatin1Char('_'))) { ++nEndPos; } - aVarName = aValue.midRef(nDollarPos + 1, nEndPos - nDollarPos - 1); + aVarName = QStringView(aValue).mid(nDollarPos + 1, nEndPos - nDollarPos - 1); } QString env; if (!aVarName.isEmpty()) { diff --git a/src/gui/kconfigloader.cpp b/src/gui/kconfigloader.cpp index bc1751f4..ac39a12f 100644 --- a/src/gui/kconfigloader.cpp +++ b/src/gui/kconfigloader.cpp @@ -49,20 +49,14 @@ bool ConfigLoaderHandler::parse(QIODevice *input) switch (reader.tokenType()) { case QXmlStreamReader::StartElement: - if (!startElement(reader.name(), reader.attributes())) { - return false; - } + startElement(reader.name(), reader.attributes()); break; case QXmlStreamReader::EndElement: - if (!endElement(reader.name())) { - return false; - } + endElement(reader.name()); break; case QXmlStreamReader::Characters: if (!reader.isWhitespace() && !reader.text().trimmed().isEmpty()) { - if (!characters(reader.text())) { - return false; - } + m_cdata.append(reader.text()); } break; default: @@ -77,15 +71,19 @@ bool ConfigLoaderHandler::parse(QIODevice *input) return true; } -bool ConfigLoaderHandler::startElement(const QStringRef &localName, const QXmlStreamAttributes &attrs) +static bool caseInsensitiveCompare(const QStringView a, const QLatin1String b) +{ + return a.compare(b, Qt::CaseInsensitive) == 0; +} + +void ConfigLoaderHandler::startElement(const QStringView localName, const QXmlStreamAttributes &attrs) { // qDebug() << "ConfigLoaderHandler::startElement(" << localName << qName; - const QString tag = localName.toString().toLower(); - if (tag == QLatin1String("group")) { + if (caseInsensitiveCompare(localName, QLatin1String("group"))) { QString group; for (const auto &attr : attrs) { - const QStringRef name = attr.name(); - if (name.compare(QLatin1String("name"), Qt::CaseInsensitive) == 0) { + const auto attrName = attr.name(); + if (caseInsensitiveCompare(attrName, QLatin1String("name"))) { // qDebug() << "set group to" << attrs.value(i); group = attr.value().toString(); } @@ -102,71 +100,61 @@ bool ConfigLoaderHandler::startElement(const QStringRef &localName, const QXmlSt if (m_config) { m_config->setCurrentGroup(group); } - } else if (tag == QLatin1String("entry")) { + } else if (caseInsensitiveCompare(localName, QLatin1String("entry"))) { for (const auto &attr : attrs) { - const QStringRef name = attr.name(); - if (name.compare(QLatin1String("name"), Qt::CaseInsensitive) == 0) { + const auto attrName = attr.name(); + if (caseInsensitiveCompare(attrName, QLatin1String("name"))) { m_name = attr.value().trimmed().toString(); - } else if (name.compare(QLatin1String("type"), Qt::CaseInsensitive) == 0) { + } else if (caseInsensitiveCompare(attrName, QLatin1String("type"))) { m_type = attr.value().toString().toLower(); - } else if (name.compare(QLatin1String("key"), Qt::CaseInsensitive) == 0) { + } else if (caseInsensitiveCompare(attrName, QLatin1String("key"))) { m_key = attr.value().trimmed().toString(); } } - } else if (tag == QLatin1String("choice")) { + } else if (caseInsensitiveCompare(localName, QLatin1String("choice"))) { m_choice.name.clear(); m_choice.label.clear(); m_choice.whatsThis.clear(); for (const auto &attr : attrs) { - const QStringRef name = attr.name(); - if (name.compare(QLatin1String("name"), Qt::CaseInsensitive) == 0) { + const auto attrName = attr.name(); + if (caseInsensitiveCompare(attrName, QLatin1String("name"))) { m_choice.name = attr.value().toString(); } } m_inChoice = true; } - - return true; -} - -bool ConfigLoaderHandler::characters(const QStringRef &ch) -{ - m_cdata.append(ch.toString()); - return true; } -bool ConfigLoaderHandler::endElement(const QStringRef &localName) +void ConfigLoaderHandler::endElement(const QStringView localName) { // qDebug() << "ConfigLoaderHandler::endElement(" << localName << qName; - const QStringRef tag = localName; - if (tag.compare(QLatin1String("entry"), Qt::CaseInsensitive) == 0) { + if (caseInsensitiveCompare(localName, QLatin1String("entry"))) { addItem(); resetState(); - } else if (tag.compare(QLatin1String("label"), Qt::CaseInsensitive) == 0) { + } else if (caseInsensitiveCompare(localName, QLatin1String("label"))) { if (m_inChoice) { m_choice.label = m_cdata.trimmed(); } else { m_label = m_cdata.trimmed(); } - } else if (tag.compare(QLatin1String("whatsthis"), Qt::CaseInsensitive) == 0) { + } else if (caseInsensitiveCompare(localName, QLatin1String("whatsthis"))) { if (m_inChoice) { m_choice.whatsThis = m_cdata.trimmed(); } else { m_whatsThis = m_cdata.trimmed(); } - } else if (tag.compare(QLatin1String("default"), Qt::CaseInsensitive) == 0) { + } else if (caseInsensitiveCompare(localName, QLatin1String("default"))) { m_default = m_cdata.trimmed(); - } else if (tag.compare(QLatin1String("min"), Qt::CaseInsensitive) == 0) { + } else if (caseInsensitiveCompare(localName, QLatin1String("min"))) { m_min = m_cdata.toInt(&m_haveMin); - } else if (tag.compare(QLatin1String("max"), Qt::CaseInsensitive) == 0) { + } else if (caseInsensitiveCompare(localName, QLatin1String("max"))) { m_max = m_cdata.toInt(&m_haveMax); - } else if (tag.compare(QLatin1String("choice"), Qt::CaseInsensitive) == 0) { + } else if (caseInsensitiveCompare(localName, QLatin1String("choice"))) { m_enumChoices.append(m_choice); m_inChoice = false; } m_cdata.clear(); - return true; } void ConfigLoaderHandler::addItem() diff --git a/src/gui/kconfigloaderhandler_p.h b/src/gui/kconfigloaderhandler_p.h index bc199e0e..297e5462 100644 --- a/src/gui/kconfigloaderhandler_p.h +++ b/src/gui/kconfigloaderhandler_p.h @@ -17,9 +17,8 @@ class ConfigLoaderHandler bool parse(QIODevice *input); - bool startElement(const QStringRef &localName, const QXmlStreamAttributes &attrs); - bool endElement(const QStringRef &localName); - bool characters(const QStringRef &ch); + void startElement(const QStringView localName, const QXmlStreamAttributes &attrs); + void endElement(const QStringView localName); private: void addItem(); diff --git a/src/kconf_update/kconfigutils.cpp b/src/kconf_update/kconfigutils.cpp index 49d5ac3c..9608f21c 100644 --- a/src/kconf_update/kconfigutils.cpp +++ b/src/kconf_update/kconfigutils.cpp @@ -89,7 +89,11 @@ QString unescapeString(const QString &src, bool *ok, QString *error) break; case L'x': { if (pos + 2 < length) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + char value = QStringView(src).mid(pos + 1, 2).toInt(ok, 16); +#else char value = src.midRef(pos + 1, 2).toInt(ok, 16); +#endif if (*ok) { dst += QLatin1Char{value}; pos += 2; From e65ecb48521038c20573901acb38f3d8346a6636 Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Wed, 25 Aug 2021 14:55:27 +0200 Subject: [PATCH 182/259] GIT_SILENT: replace MacOSX with macOS --- metainfo.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metainfo.yaml b/metainfo.yaml index a57e936a..e8a544a1 100644 --- a/metainfo.yaml +++ b/metainfo.yaml @@ -6,7 +6,7 @@ platforms: - name: Linux - name: FreeBSD - name: Windows - - name: MacOSX + - name: macOS - name: Android portingAid: false deprecated: false From 3259a6e6530cb0526bf71733ba28015f481f056e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9ven=20Car?= Date: Wed, 25 Aug 2021 10:56:41 +0200 Subject: [PATCH 183/259] KDesktopFile::isAuthorizedDesktopFile: reduce warning to info a log --- src/core/kdesktopfile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/kdesktopfile.cpp b/src/core/kdesktopfile.cpp index 338692e6..408da286 100644 --- a/src/core/kdesktopfile.cpp +++ b/src/core/kdesktopfile.cpp @@ -162,7 +162,7 @@ bool KDesktopFile::isAuthorizedDesktopFile(const QString &path) return true; } - qCWarning(KCONFIG_CORE_LOG) << "Access to '" << path << "' denied, not owned by root, executable flag not set."; + qCInfo(KCONFIG_CORE_LOG) << "Access to '" << path << "' denied, not owned by root and executable flag not set."; return false; } From dffdff73fa98a4fdebca38fb4a41938541ffb1c1 Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Sat, 28 Aug 2021 18:05:30 +0200 Subject: [PATCH 184/259] GIT_SILENT: we can use std::as_const directly --- autotests/kconfigtest.cpp | 6 ++--- src/core/kauthorized.cpp | 2 +- src/core/kconfig.cpp | 2 +- src/core/kconfigini.cpp | 2 +- src/core/kconfigwatcher.cpp | 2 +- src/core/kcoreconfigskeleton.cpp | 12 +++++----- src/core/ksharedconfig.cpp | 2 +- src/kconf_update/kconf_update.cpp | 4 ++-- .../KConfigCodeGeneratorBase.cpp | 2 +- .../KConfigHeaderGenerator.cpp | 20 ++++++++-------- .../KConfigSourceGenerator.cpp | 24 +++++++++---------- src/kconfig_compiler/kconfig_compiler.cpp | 2 +- 12 files changed, 40 insertions(+), 40 deletions(-) diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index 256acb36..c3a68e42 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -1057,7 +1057,7 @@ void KConfigTest::testMerge() << "entry[fr]=French\n"; QFile file(m_testConfigDir + QLatin1String("/mergetest")); file.open(QIODevice::ReadOnly | QIODevice::Text); - for (const QByteArray &line : qAsConst(lines)) { + for (const QByteArray &line : std::as_const(lines)) { QCOMPARE(line, file.readLine()); } } @@ -1124,7 +1124,7 @@ void KConfigTest::testOptionOrder() QFile file(m_testConfigDir + QLatin1String("/doubleattrtest")); file.open(QIODevice::ReadOnly | QIODevice::Text); - for (const QByteArray &line : qAsConst(lines)) { + for (const QByteArray &line : std::as_const(lines)) { QCOMPARE(line, file.readLine()); } } @@ -1943,7 +1943,7 @@ void KConfigTest::testThreads() // QEXPECT_FAIL triggers race conditions, it should be fixed to use QThreadStorage... // futures << QtConcurrent::run(this, &KConfigTest::testDeleteWhenLocalized); // futures << QtConcurrent::run(this, &KConfigTest::testEntryMap); - for (QFuture f : qAsConst(futures)) { + for (QFuture f : std::as_const(futures)) { f.waitForFinished(); } } diff --git a/src/core/kauthorized.cpp b/src/core/kauthorized.cpp index a8784a1c..3c0941d5 100644 --- a/src/core/kauthorized.cpp +++ b/src/core/kauthorized.cpp @@ -378,7 +378,7 @@ authorizeUrlActionInternal(const QString &action, const QUrl &_baseURL, const QU QUrl destURL(_destURL); destURL.setPath(QDir::cleanPath(destURL.path())); - for (const URLActionRule &rule : qAsConst(d->urlActionRestrictions)) { + for (const URLActionRule &rule : std::as_const(d->urlActionRestrictions)) { if ((result != rule.permission) && // No need to check if it doesn't make a difference (action == QLatin1String(rule.action.constData())) && rule.baseMatch(baseURL, baseClass) && rule.destMatch(destURL, destClass, baseURL, baseClass)) { diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index 0bf6cccd..506e3f90 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -774,7 +774,7 @@ void KConfigPrivate::parseConfigFiles() // qDebug() << "parsing local files" << files; const QByteArray utf8Locale = locale.toUtf8(); - for (const QString &file : qAsConst(files)) { + for (const QString &file : std::as_const(files)) { if (file.compare(mBackend->filePath(), sPathCaseSensitivity) == 0) { switch (mBackend->parseConfig(utf8Locale, entryMap, KConfigBackend::ParseExpansions)) { case KConfigBackend::ParseOk: diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp index 5bc8743c..7c1e15f0 100644 --- a/src/core/kconfigini.cpp +++ b/src/core/kconfigini.cpp @@ -287,7 +287,7 @@ KConfigBackend::ParseInfo KConfigIniBackend::parseConfig(const QByteArray &curre } // now make sure immutable groups are marked immutable - for (const QByteArray &group : qAsConst(immutableGroups)) { + for (const QByteArray &group : std::as_const(immutableGroups)) { entryMap.setEntry(group, QByteArray(), QByteArray(), KEntryMap::EntryImmutable); } diff --git a/src/core/kconfigwatcher.cpp b/src/core/kconfigwatcher.cpp index 3da2d535..ec3cb541 100644 --- a/src/core/kconfigwatcher.cpp +++ b/src/core/kconfigwatcher.cpp @@ -66,7 +66,7 @@ KConfigWatcher::KConfigWatcher(const KSharedConfig::Ptr &config) watchedPaths << QStringLiteral("/kdeglobals"); } - for (const QString &path : qAsConst(watchedPaths)) { + for (const QString &path : std::as_const(watchedPaths)) { QDBusConnection::sessionBus().connect(QString(), path, QStringLiteral("org.kde.kconfig.notify"), diff --git a/src/core/kcoreconfigskeleton.cpp b/src/core/kcoreconfigskeleton.cpp index e1c5c1dd..f8097055 100644 --- a/src/core/kcoreconfigskeleton.cpp +++ b/src/core/kcoreconfigskeleton.cpp @@ -1038,7 +1038,7 @@ void KCoreConfigSkeleton::ItemUrlList::readConfig(KConfig *config) mReference = mDefault; } else { QStringList strList; - for (const QUrl &url : qAsConst(mDefault)) { + for (const QUrl &url : std::as_const(mDefault)) { strList.append(url.toString()); } mReference.clear(); @@ -1060,7 +1060,7 @@ void KCoreConfigSkeleton::ItemUrlList::writeConfig(KConfig *config) cg.revertToDefault(mKey, writeFlags()); } else { QStringList strList; - for (const QUrl &url : qAsConst(mReference)) { + for (const QUrl &url : std::as_const(mReference)) { strList.append(url.toString()); } cg.writeEntry(mKey, strList, writeFlags()); @@ -1183,7 +1183,7 @@ bool KCoreConfigSkeleton::useDefaults(bool b) } d->mUseDefaults = b; - for (auto *skelItem : qAsConst(d->mItems)) { + for (auto *skelItem : std::as_const(d->mItems)) { skelItem->swapDefault(); } @@ -1193,7 +1193,7 @@ bool KCoreConfigSkeleton::useDefaults(bool b) void KCoreConfigSkeleton::setDefaults() { - for (auto *skelItem : qAsConst(d->mItems)) { + for (auto *skelItem : std::as_const(d->mItems)) { skelItem->setDefault(); } usrSetDefaults(); @@ -1207,7 +1207,7 @@ void KCoreConfigSkeleton::load() void KCoreConfigSkeleton::read() { - for (auto *skelItem : qAsConst(d->mItems)) { + for (auto *skelItem : std::as_const(d->mItems)) { skelItem->readConfig(d->mConfig.data()); } usrRead(); @@ -1230,7 +1230,7 @@ bool KCoreConfigSkeleton::isSaveNeeded() const bool KCoreConfigSkeleton::save() { // qDebug(); - for (auto *skelItem : qAsConst(d->mItems)) { + for (auto *skelItem : std::as_const(d->mItems)) { skelItem->writeConfig(d->mConfig.data()); } diff --git a/src/core/ksharedconfig.cpp b/src/core/ksharedconfig.cpp index 98aa4c5e..09cd35f1 100644 --- a/src/core/ksharedconfig.cpp +++ b/src/core/ksharedconfig.cpp @@ -78,7 +78,7 @@ KSharedConfigPtr KSharedConfig::openConfig(const QString &_fileName, OpenFlags f list->mainConfig = nullptr; } - for (auto *cfg : qAsConst(*list)) { + for (auto *cfg : std::as_const(*list)) { if (cfg->name() == fileName && cfg->d_ptr->openFlags == flags && cfg->locationType() == resType // cfg->backend()->type() == backend ) { diff --git a/src/kconf_update/kconf_update.cpp b/src/kconf_update/kconf_update.cpp index bfb115dd..eec97d66 100644 --- a/src/kconf_update/kconf_update.cpp +++ b/src/kconf_update/kconf_update.cpp @@ -161,7 +161,7 @@ KonfUpdate::KonfUpdate(QCommandLineParser *parser) updateAll = true; } - for (const QString &file : qAsConst(updateFiles)) { + for (const QString &file : std::as_const(updateFiles)) { updateFile(file); } @@ -169,7 +169,7 @@ KonfUpdate::KonfUpdate(QCommandLineParser *parser) cg.writeEntry("updateInfoAdded", true); updateFiles = findUpdateFiles(false); - for (const auto &file : qAsConst(updateFiles)) { + for (const auto &file : std::as_const(updateFiles)) { checkFile(file); } updateFiles.clear(); diff --git a/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp b/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp index 0effd7e5..78a5fa0a 100644 --- a/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp +++ b/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp @@ -255,7 +255,7 @@ void KConfigCodeGeneratorBase::memberMutatorBody(const CfgEntry *e) m_stream << whitespace() << " " << varExpression << " = v;\n"; const auto listSignal = e->signalList; - for (const Signal &signal : qAsConst(listSignal)) { + for (const Signal &signal : std::as_const(listSignal)) { if (signal.modify) { m_stream << whitespace() << " Q_EMIT " << m_this << signal.name << "();\n"; } else { diff --git a/src/kconfig_compiler/KConfigHeaderGenerator.cpp b/src/kconfig_compiler/KConfigHeaderGenerator.cpp index 24829ff5..2c5126d5 100644 --- a/src/kconfig_compiler/KConfigHeaderGenerator.cpp +++ b/src/kconfig_compiler/KConfigHeaderGenerator.cpp @@ -52,7 +52,7 @@ void KConfigHeaderGenerator::doClassDefinition() createConstructor(); createDestructor(); - for (const auto *entry : qAsConst(parseResult.entries)) { + for (const auto *entry : std::as_const(parseResult.entries)) { const QString returnType = (cfg().useEnumTypes && entry->type == QLatin1String("Enum")) ? enumType(entry, cfg().globalEnums) : cppType(entry->type); createSetters(entry); @@ -81,7 +81,7 @@ void KConfigHeaderGenerator::doClassDefinition() } // Class Parameters - for (const auto ¶meter : qAsConst(parseResult.parameters)) { + for (const auto ¶meter : std::as_const(parseResult.parameters)) { stream() << whitespace() << "" << cppType(parameter.type) << " mParam" << parameter.name << ";\n"; } @@ -152,7 +152,7 @@ void KConfigHeaderGenerator::implementChoiceEnums(const CfgEntry *entry, const C } QStringList values; - for (const auto &choice : qAsConst(chlist)) { + for (const auto &choice : std::as_const(chlist)) { values.append(choices.prefix + choice.name); } @@ -201,7 +201,7 @@ void KConfigHeaderGenerator::implementEnums() return; } - for (const auto *entry : qAsConst(parseResult.entries)) { + for (const auto *entry : std::as_const(parseResult.entries)) { const CfgEntry::Choices &choices = entry->choices; const QStringList values = entry->paramValues; @@ -246,7 +246,7 @@ void KConfigHeaderGenerator::createSignals() stream() << whitespace() << "};" << Qt::dec << "\n\n"; stream() << " Q_SIGNALS:"; - for (const Signal &signal : qAsConst(parseResult.signalList)) { + for (const Signal &signal : std::as_const(parseResult.signalList)) { stream() << '\n'; if (!signal.label.isEmpty()) { stream() << whitespace() << "/**\n"; @@ -261,7 +261,7 @@ void KConfigHeaderGenerator::createSignals() Param argument = *it; QString type = param(argument.type); if (cfg().useEnumTypes && argument.type == QLatin1String("Enum")) { - for (const auto *entry : qAsConst(parseResult.entries)) { + for (const auto *entry : std::as_const(parseResult.entries)) { if (entry->name == argument.name) { type = enumType(entry, cfg().globalEnums); break; @@ -290,7 +290,7 @@ void KConfigHeaderGenerator::createDPointer() // use a private class for both member variables and items stream() << " private:\n"; - for (const auto *entry : qAsConst(parseResult.entries)) { + for (const auto *entry : std::as_const(parseResult.entries)) { if (cfg().allDefaultGetters || cfg().defaultGetters.contains(entry->name)) { stream() << whitespace() << ""; if (cfg().staticAccessors) { @@ -327,7 +327,7 @@ void KConfigHeaderGenerator::createConstructor() } bool first = true; - for (const auto ¶meter : qAsConst(parseResult.parameters)) { + for (const auto ¶meter : std::as_const(parseResult.parameters)) { if (first) { first = false; } else { @@ -587,7 +587,7 @@ void KConfigHeaderGenerator::createNonDPointerHelpers() } QString group; - for (const auto *entry : qAsConst(parseResult.entries)) { + for (const auto *entry : std::as_const(parseResult.entries)) { if (entry->group != group) { group = entry->group; stream() << '\n'; @@ -614,7 +614,7 @@ void KConfigHeaderGenerator::createNonDPointerHelpers() stream() << "\n private:\n"; if (cfg().itemAccessors) { - for (const auto *entry : qAsConst(parseResult.entries)) { + for (const auto *entry : std::as_const(parseResult.entries)) { stream() << whitespace() << "Item" << itemType(entry->type) << " *" << itemVar(entry, cfg()); if (!entry->param.isEmpty()) { stream() << QStringLiteral("[%1]").arg(entry->paramMax + 1); diff --git a/src/kconfig_compiler/KConfigSourceGenerator.cpp b/src/kconfig_compiler/KConfigSourceGenerator.cpp index e221d1ab..a8a05f4b 100644 --- a/src/kconfig_compiler/KConfigSourceGenerator.cpp +++ b/src/kconfig_compiler/KConfigSourceGenerator.cpp @@ -92,7 +92,7 @@ void KConfigSourceGenerator::createPrivateDPointerImplementation() stream() << " public:\n"; // Create Members - for (const auto *entry : qAsConst(parseResult.entries)) { + for (const auto *entry : std::as_const(parseResult.entries)) { if (entry->group != group) { group = entry->group; stream() << '\n'; @@ -107,7 +107,7 @@ void KConfigSourceGenerator::createPrivateDPointerImplementation() stream() << "\n // items\n"; // Create Items. - for (const auto *entry : qAsConst(parseResult.entries)) { + for (const auto *entry : std::as_const(parseResult.entries)) { const QString declType = entry->signalList.isEmpty() ? QString(cfg().inherits + QStringLiteral("::Item") + itemType(entry->type)) : QStringLiteral("KConfigCompilerSignallingItem"); @@ -187,7 +187,7 @@ void KConfigSourceGenerator::createSingletonImplementation() void KConfigSourceGenerator::createPreamble() { QString cppPreamble; - for (const auto *entry : qAsConst(parseResult.entries)) { + for (const auto *entry : std::as_const(parseResult.entries)) { if (entry->paramValues.isEmpty()) { continue; } @@ -250,7 +250,7 @@ void KConfigSourceGenerator::createParentConstructorCall() void KConfigSourceGenerator::createInitializerList() { - for (const auto ¶meter : qAsConst(parseResult.parameters)) { + for (const auto ¶meter : std::as_const(parseResult.parameters)) { stream() << " , mParam" << parameter.name << "(" << parameter.name << ")\n"; } @@ -266,7 +266,7 @@ void KConfigSourceGenerator::createEnums(const CfgEntry *entry) } stream() << " QList<" << cfg().inherits << "::ItemEnum::Choice> values" << entry->name << ";\n"; - for (const auto &choice : qAsConst(entry->choices.choices)) { + for (const auto &choice : std::as_const(entry->choices.choices)) { stream() << " {\n"; stream() << " " << cfg().inherits << "::ItemEnum::Choice choice;\n"; stream() << " choice.name = QStringLiteral(\"" << choice.name << "\");\n"; @@ -312,7 +312,7 @@ void KConfigSourceGenerator::createNormalEntry(const CfgEntry *entry, const QStr stream() << " " << itemVarStr << "->setWriteFlags(KConfigBase::Notify);\n"; } - for (const CfgEntry::Choice &choice : qAsConst(entry->choices.choices)) { + for (const CfgEntry::Choice &choice : std::as_const(entry->choices.choices)) { if (!choice.val.isEmpty()) { stream() << " " << itemVarStr << "->setValueForChoice(QStringLiteral( \"" << choice.name << "\" ), QStringLiteral( \"" << choice.val << "\" ));\n"; } @@ -361,7 +361,7 @@ void KConfigSourceGenerator::createIndexedEntry(const CfgEntry *entry, const QSt stream() << " " << innerItemVarStr << "->setMaxValue(" << entry->max << ");\n"; } - for (const CfgEntry::Choice &choice : qAsConst(entry->choices.choices)) { + for (const CfgEntry::Choice &choice : std::as_const(entry->choices.choices)) { if (!choice.val.isEmpty()) { stream() << " " << itemVarStr << "->setValueForChoice(QStringLiteral( \"" << choice.name << "\" ), QStringLiteral( \"" << choice.val << "\" ));\n"; @@ -461,7 +461,7 @@ void KConfigSourceGenerator::doConstructor() stream() << '\n'; } - for (const auto *entry : qAsConst(parseResult.entries)) { + for (const auto *entry : std::as_const(parseResult.entries)) { handleCurrentGroupChange(entry); const QString key = paramString(entry->key, parseResult.parameters); @@ -572,7 +572,7 @@ void KConfigSourceGenerator::doGetterSetterDPointerMode() } // setters and getters go in Cpp if in dpointer mode - for (const auto *entry : qAsConst(parseResult.entries)) { + for (const auto *entry : std::as_const(parseResult.entries)) { createSetterDPointerMode(entry); createGetterDPointerMode(entry); createImmutableGetterDPointerMode(entry); @@ -584,7 +584,7 @@ void KConfigSourceGenerator::doGetterSetterDPointerMode() void KConfigSourceGenerator::createDefaultValueGetterSetter() { // default value getters always go in Cpp - for (const auto *entry : qAsConst(parseResult.entries)) { + for (const auto *entry : std::as_const(parseResult.entries)) { QString n = entry->name; QString t = entry->type; @@ -627,7 +627,7 @@ void KConfigSourceGenerator::createNonModifyingSignalsHelper() startScope(); stream() << " const bool res = " << cfg().inherits << "::usrSave();\n"; stream() << " if (!res) return false;\n\n"; - for (const Signal &signal : qAsConst(parseResult.signalList)) { + for (const Signal &signal : std::as_const(parseResult.signalList)) { if (signal.modify) { continue; } @@ -682,7 +682,7 @@ void KConfigSourceGenerator::createSignalFlagsHandler() stream() << '\n'; } - for (const Signal &signal : qAsConst(parseResult.signalList)) { + for (const Signal &signal : std::as_const(parseResult.signalList)) { if (signal.modify) { stream() << " if ( flags & " << signalEnumName(signal.name) << " ) {\n"; stream() << " Q_EMIT " << signal.name << "();\n"; diff --git a/src/kconfig_compiler/kconfig_compiler.cpp b/src/kconfig_compiler/kconfig_compiler.cpp index 761e64fc..fb7e7a68 100644 --- a/src/kconfig_compiler/kconfig_compiler.cpp +++ b/src/kconfig_compiler/kconfig_compiler.cpp @@ -773,7 +773,7 @@ int main(int argc, char **argv) } // TODO: Move this to somewhere saner. - for (const auto &signal : qAsConst(parseResult.signalList)) { + for (const auto &signal : std::as_const(parseResult.signalList)) { parseResult.hasNonModifySignals |= !signal.modify; } From dab919f1c2c255535874e8f47ad1eba2b5d347f2 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Sat, 14 Aug 2021 21:56:54 +0200 Subject: [PATCH 185/259] Make enum value visible to QML when using GlobalEnum mode Now generate Q_ENUM() --- src/kconfig_compiler/KConfigHeaderGenerator.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/kconfig_compiler/KConfigHeaderGenerator.cpp b/src/kconfig_compiler/KConfigHeaderGenerator.cpp index 2c5126d5..9938599c 100644 --- a/src/kconfig_compiler/KConfigHeaderGenerator.cpp +++ b/src/kconfig_compiler/KConfigHeaderGenerator.cpp @@ -159,6 +159,9 @@ void KConfigHeaderGenerator::implementChoiceEnums(const CfgEntry *entry, const C if (choices.name().isEmpty()) { if (cfg().globalEnums) { stream() << whitespace() << "enum " << enumName(entry->name, entry->choices) << " { " << values.join(QStringLiteral(", ")) << " };\n"; + if (cfg().generateProperties) { + stream() << whitespace() << "Q_ENUM(" << enumName(entry->name, entry->choices) << ")\n"; + } } else { // Create an automatically named enum stream() << whitespace() << "class " << enumName(entry->name, entry->choices) << '\n'; From 7ad396a0448abc7b6861c0a9ca80b9902d365bc9 Mon Sep 17 00:00:00 2001 From: empyreal one Date: Sun, 29 Aug 2021 18:12:22 +0000 Subject: [PATCH 186/259] Add Ctrl+Alt+Comma shortcut for "Configure Keyboard Shortcuts" BUG: 441537 FIXED-IN: 5.86 --- src/gui/kstandardshortcut.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/kstandardshortcut.cpp b/src/gui/kstandardshortcut.cpp index 6afd4a9f..1f67901f 100644 --- a/src/gui/kstandardshortcut.cpp +++ b/src/gui/kstandardshortcut.cpp @@ -51,6 +51,7 @@ struct KStandardShortcutInfo { #define CTRL(x) Qt::CTRL | Qt::Key_##x #define SHIFT(x) Qt::SHIFT | Qt::Key_##x +#define CTRLALT(x) Qt::CTRL | Qt::ALT | Qt::Key_##x #define CTRLSHIFT(x) Qt::CTRL | Qt::SHIFT | Qt::Key_##x #define ALT(x) Qt::ALT | Qt::Key_##x #define ALTSHIFT(x) Qt::ALT | Qt::SHIFT | Qt::Key_##x @@ -331,7 +332,7 @@ static KStandardShortcutInfo g_infoStandardShortcut[] = { // dummy entry {SaveOptions_DEPRECATED_DO_NOT_USE, nullptr, {nullptr, nullptr}, 0, 0, QList(), false, Category::InvalidCategory}, #endif - {KeyBindings, "KeyBindings", QT_TRANSLATE_NOOP3("KStandardShortcut", "Key Bindings", "@action"), 0, 0, QList(), false, Category::Settings}, + {KeyBindings, "KeyBindings", QT_TRANSLATE_NOOP3("KStandardShortcut", "Key Bindings", "@action"), CTRLALT(Comma), 0, QList(), false, Category::Settings}, {Preferences, "Preferences", QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Application", "@action"), From e88b043db2642fb1cc8d30451042e37c7f2b690f Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 4 Sep 2021 15:42:10 +0000 Subject: [PATCH 187/259] GIT_SILENT Upgrade ECM and KF version requirements for 5.86.0 release. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 79356ad3..f267fca0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ set(KF_VERSION "5.86.0") # handled by release scripts project(KConfig VERSION ${KF_VERSION}) include(FeatureSummary) -find_package(ECM 5.85.0 NO_MODULE) +find_package(ECM 5.86.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) From 3691e4fe2d218d49002be80b66b766c21454c242 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 5 Sep 2021 13:06:23 +0200 Subject: [PATCH 188/259] GIT_SILENT Add CI configuration file --- .kde-ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .kde-ci.yml diff --git a/.kde-ci.yml b/.kde-ci.yml new file mode 100644 index 00000000..cf1d3363 --- /dev/null +++ b/.kde-ci.yml @@ -0,0 +1,7 @@ +Dependencies: +- 'on': ['@all'] + 'require': + 'frameworks/extra-cmake-modules': '@same' + +Options: + test-before-installing: True From 782750149a0819053d47960fb144f17b7c719d13 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 11 Sep 2021 10:06:24 +0000 Subject: [PATCH 189/259] GIT_SILENT Upgrade KF version to 5.87.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f267fca0..83599192 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.16) -set(KF_VERSION "5.86.0") # handled by release scripts +set(KF_VERSION "5.87.0") # handled by release scripts project(KConfig VERSION ${KF_VERSION}) include(FeatureSummary) From 0b0a4464fb3d1145eb612b1ab7edacfa9581c8c9 Mon Sep 17 00:00:00 2001 From: Alexander Lohnau Date: Tue, 14 Sep 2021 07:30:32 +0200 Subject: [PATCH 190/259] Allow KConfigXT to use KSharedConfig::openStateConfig Otherwise we force consumers to use the config location for state data, which is what we are trying to avoid. Task: https://phabricator.kde.org/T12549 --- autotests/kconfig_compiler/CMakeLists.txt | 9 ++++ .../kconfig_compiler/test_state_config.kcfg | 14 +++++++ .../kconfig_compiler/test_state_config.kcfgc | 6 +++ .../test_state_config_main.cpp | 41 +++++++++++++++++++ src/kconfig_compiler/KConfigCommonStructs.h | 1 + .../KConfigHeaderGenerator.cpp | 7 ++++ .../KConfigSourceGenerator.cpp | 8 +++- src/kconfig_compiler/KConfigXmlParser.cpp | 1 + src/kconfig_compiler/README.dox | 5 +++ src/kconfig_compiler/kcfg.xsd | 1 + 10 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 autotests/kconfig_compiler/test_state_config.kcfg create mode 100644 autotests/kconfig_compiler/test_state_config.kcfgc create mode 100644 autotests/kconfig_compiler/test_state_config_main.cpp diff --git a/autotests/kconfig_compiler/CMakeLists.txt b/autotests/kconfig_compiler/CMakeLists.txt index 2a4b343b..4641c0e0 100644 --- a/autotests/kconfig_compiler/CMakeLists.txt +++ b/autotests/kconfig_compiler/CMakeLists.txt @@ -172,6 +172,15 @@ target_link_libraries(test13 KF5::ConfigGui) ########### next target ############### +set(test_state_config_SRCS test_state_config_main.cpp) + +gen_kcfg_test_source(test_state_config test_state_config_SRCS GENERATE_MOC) + +ecm_add_test(TEST_NAME test_state_config ${test_state_config_SRCS}) +target_link_libraries(test_state_config KF5::ConfigGui Qt5::Test) + +########### next target ############### + set(test_emptyentries_SRCS test_emptyentries_main.cpp ) gen_kcfg_test_source(test_emptyentries test_emptyentries_SRCS GENERATE_MOC) diff --git a/autotests/kconfig_compiler/test_state_config.kcfg b/autotests/kconfig_compiler/test_state_config.kcfg new file mode 100644 index 00000000..9c9e96c3 --- /dev/null +++ b/autotests/kconfig_compiler/test_state_config.kcfg @@ -0,0 +1,14 @@ + + + + + + + 0 + + + + diff --git a/autotests/kconfig_compiler/test_state_config.kcfgc b/autotests/kconfig_compiler/test_state_config.kcfgc new file mode 100644 index 00000000..35e2de7d --- /dev/null +++ b/autotests/kconfig_compiler/test_state_config.kcfgc @@ -0,0 +1,6 @@ +# Code generation options for kconfig_compiler_kf5 +File=test_state_config.kcfg +ClassName=MyStateConfig +Singleton=false +Mutators=true +ItemAccessors=true diff --git a/autotests/kconfig_compiler/test_state_config_main.cpp b/autotests/kconfig_compiler/test_state_config_main.cpp new file mode 100644 index 00000000..07044bb5 --- /dev/null +++ b/autotests/kconfig_compiler/test_state_config_main.cpp @@ -0,0 +1,41 @@ +/* + SPDX-FileCopyrightText: 2021 Alexander Lohnau + + SPDX-License-Identifier: MIT +*/ + +#include "test_state_config.h" +#include + +class TestStateConfig : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void testStateConfig() + { + auto stateConfig = KSharedConfig::openStateConfig(QStringLiteral("test_statedatarc")); + + // Clean the group at every start + stateConfig->deleteGroup("General"); + stateConfig->sync(); + + // It should have the default value + QCOMPARE(MyStateConfig().someStateData(), 0); + + // the updated value should be read from the generated config class + stateConfig->group("General").writeEntry("SomeStateData", 1); + QCOMPARE(MyStateConfig().someStateData(), 1); + + // Make sure writing the value works as expected + MyStateConfig cfg; + cfg.setSomeStateData(2); + QVERIFY(cfg.isSaveNeeded()); + cfg.save(); + stateConfig->reparseConfiguration(); + QCOMPARE(stateConfig->group("General").readEntry("SomeStateData", -1), 2); + } +}; +QTEST_MAIN(TestStateConfig) + +#include "test_state_config_main.moc" diff --git a/src/kconfig_compiler/KConfigCommonStructs.h b/src/kconfig_compiler/KConfigCommonStructs.h index 43e981cb..bac10c70 100644 --- a/src/kconfig_compiler/KConfigCommonStructs.h +++ b/src/kconfig_compiler/KConfigCommonStructs.h @@ -114,6 +114,7 @@ class CfgEntry struct ParseResult { QString cfgFileName; bool cfgFileNameArg = false; + bool cfgStateConfig = false; QList parameters; QList signalList; QStringList includes; diff --git a/src/kconfig_compiler/KConfigHeaderGenerator.cpp b/src/kconfig_compiler/KConfigHeaderGenerator.cpp index 9938599c..ea5a2c75 100644 --- a/src/kconfig_compiler/KConfigHeaderGenerator.cpp +++ b/src/kconfig_compiler/KConfigHeaderGenerator.cpp @@ -324,10 +324,17 @@ void KConfigHeaderGenerator::createConstructor() if (parseResult.cfgFileNameArg) { if (cfg().forceStringFilename) { stream() << " const QString &cfgfilename" << (parseResult.parameters.isEmpty() ? " = QString()" : ", "); + } else if (parseResult.cfgStateConfig) { + stream() << " KSharedConfig::Ptr config" << (parseResult.parameters.isEmpty() ? " = KSharedConfig::openStateConfig()" : ", "); } else { stream() << " KSharedConfig::Ptr config" << (parseResult.parameters.isEmpty() ? " = KSharedConfig::openConfig()" : ", "); } } + if (cfg().forceStringFilename && parseResult.cfgStateConfig) { + std::cerr << "One can not use ForceStringFilename and use the stateConfig attribute, consider " + "removing the ForceStringFilename kcfgc option if you want to use state data" + << std::endl; + } bool first = true; for (const auto ¶meter : std::as_const(parseResult.parameters)) { diff --git a/src/kconfig_compiler/KConfigSourceGenerator.cpp b/src/kconfig_compiler/KConfigSourceGenerator.cpp index a8a05f4b..45299a4f 100644 --- a/src/kconfig_compiler/KConfigSourceGenerator.cpp +++ b/src/kconfig_compiler/KConfigSourceGenerator.cpp @@ -170,7 +170,9 @@ void KConfigSourceGenerator::createSingletonImplementation() stream() << " return;\n"; stream() << " }\n"; stream() << " new " << cfg().className << "("; - if (isString) { + if (parseResult.cfgStateConfig) { + stream() << "KSharedConfig::openStateConfig(" << arg << ")"; + } else if (isString) { stream() << "KSharedConfig::openConfig(" << arg << ")"; } else { stream() << "std::move(" << arg << ")"; @@ -232,7 +234,9 @@ void KConfigSourceGenerator::createConstructorParameterList() void KConfigSourceGenerator::createParentConstructorCall() { stream() << cfg().inherits << "("; - if (!parseResult.cfgFileName.isEmpty()) { + if (parseResult.cfgStateConfig) { + stream() << " KSharedConfig::openStateConfig(QStringLiteral( \"" << parseResult.cfgFileName << "\") "; + } else if (!parseResult.cfgFileName.isEmpty()) { stream() << " QStringLiteral( \"" << parseResult.cfgFileName << "\" "; } if (parseResult.cfgFileNameArg) { diff --git a/src/kconfig_compiler/KConfigXmlParser.cpp b/src/kconfig_compiler/KConfigXmlParser.cpp index 3d054522..fbcd4b92 100644 --- a/src/kconfig_compiler/KConfigXmlParser.cpp +++ b/src/kconfig_compiler/KConfigXmlParser.cpp @@ -522,6 +522,7 @@ void KConfigXmlParser::readGroupTag(const QDomElement &e) void KConfigXmlParser::readKcfgfileTag(const QDomElement &e) { mParseResult.cfgFileName = e.attribute(QStringLiteral("name")); + mParseResult.cfgStateConfig = e.attribute(QStringLiteral("stateConfig")).toLower() == QLatin1String("true"); mParseResult.cfgFileNameArg = e.attribute(QStringLiteral("arg")).toLower() == QLatin1String("true"); for (QDomElement e2 = e.firstChildElement(); !e2.isNull(); e2 = e2.nextSiblingElement()) { if (e2.tagName() == QLatin1String("parameter")) { diff --git a/src/kconfig_compiler/README.dox b/src/kconfig_compiler/README.dox index 671e9c5b..4c22a452 100644 --- a/src/kconfig_compiler/README.dox +++ b/src/kconfig_compiler/README.dox @@ -385,6 +385,11 @@ Example 1: In this case passing "Group2" as the 'groupname' parameter to the generated class will make it use group "Group2" for the entry "Text". +By setting the stateConfig attribute of kcfgfile to "true", KSharedConfig::openStateConfig is used. +This should be used when one stores volatile data, like window sizes or autocompletion texts. +It is recommended to have at least two separate kcfg files for the different kinds of data. +NOTE: This option is ignored when ForceStringFilename is set. + \subsection enums Enums By default, if GlobalEnums is set to false, a separate named enum will be generated diff --git a/src/kconfig_compiler/kcfg.xsd b/src/kconfig_compiler/kcfg.xsd index f9175a1d..6825819b 100644 --- a/src/kconfig_compiler/kcfg.xsd +++ b/src/kconfig_compiler/kcfg.xsd @@ -68,6 +68,7 @@ + From 3090534d92d598c4f6a1d758cc4392aa086a4c0a Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Tue, 7 Sep 2021 03:57:06 +0200 Subject: [PATCH 191/259] kconfigini: Only open the file once to write We were calling open(), then fopen(), then QFile::open(). This patch removes the fopen() call that does not seem to do anything. --- src/core/kconfigini.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp index 7c1e15f0..0e85cda7 100644 --- a/src/core/kconfigini.cpp +++ b/src/core/kconfigini.cpp @@ -510,19 +510,14 @@ bool KConfigIniBackend::writeConfig(const QByteArray &locale, KEntryMap &entryMa if (fd < 0) { return false; } - FILE *fp = ::fdopen(fd, "w"); - if (!fp) { - QT_CLOSE(fd); - return false; - } QFile f; - if (!f.open(fp, QIODevice::WriteOnly)) { - fclose(fp); + if (!f.open(fd, QIODevice::WriteOnly)) { + QT_CLOSE(fd); return false; } writeEntries(locale, f, writeMap); f.close(); - fclose(fp); + QT_CLOSE(fd); #else QFile f(filePath()); // XXX This is broken - it DOES create the file if it is suddenly gone. From 5617e6d214eaa9c910c4e466b383dece9917b6d9 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Sat, 25 Sep 2021 22:48:32 +0200 Subject: [PATCH 192/259] Fix one typo in API docs GIT_SILENT --- src/core/ksharedconfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/ksharedconfig.h b/src/core/ksharedconfig.h index 1add155e..56522f48 100644 --- a/src/core/ksharedconfig.h +++ b/src/core/ksharedconfig.h @@ -18,7 +18,7 @@ * KConfig variant using shared memory * * KSharedConfig provides a shared (reference counted) variant - * of KConfig. This allows you to use manipulate the same configuration + * of KConfig. This allows you to use/manipulate the same configuration * files from different places in your code without worrying about * accidentally overwriting changes. * From 064f1b11cf93f2b8dad0b0576921da2ff68259ed Mon Sep 17 00:00:00 2001 From: Ben Cooksley Date: Wed, 29 Sep 2021 21:40:13 +1300 Subject: [PATCH 193/259] Add Gitlab CI configuration --- .gitlab-ci.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..8950fb6d --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,5 @@ +# SPDX-FileCopyrightText: 2020 Volker Krause +# SPDX-License-Identifier: CC0-1.0 + +include: + - https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/linux.yml From 0c61fb56725a2cc042a03c21c7bee63a16a5e7fe Mon Sep 17 00:00:00 2001 From: Sharaf Zaman Date: Wed, 29 Sep 2021 09:19:54 +0000 Subject: [PATCH 194/259] Android: Fix writing to config if path is a content:// Uri KConfigIniBackend relies on QLockFile which changes the content Uri and this is bound to fail because we don't have permission. So, for these Uris we use Android's Internal cache directory to save the .lock files. --- src/core/kconfigini.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp index 0e85cda7..290c3354 100644 --- a/src/core/kconfigini.cpp +++ b/src/core/kconfigini.cpp @@ -505,7 +505,7 @@ bool KConfigIniBackend::writeConfig(const QByteArray &locale, KEntryMap &entryMa } } else { // Open existing file. *DON'T* create it if it suddenly does not exist! -#ifdef Q_OS_UNIX +#if defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID) int fd = QT_OPEN(QFile::encodeName(filePath()).constData(), O_WRONLY | O_TRUNC); if (fd < 0) { return false; @@ -613,7 +613,20 @@ bool KConfigIniBackend::lock() Q_ASSERT(!filePath().isEmpty()); if (!lockFile) { - lockFile = new QLockFile(filePath() + QLatin1String(".lock")); +#ifdef Q_OS_ANDROID + // handle content Uris properly + if (filePath().startsWith(QLatin1String("content://"))) { + // we can't create file at an arbitrary location, so use internal storage to create one + + // NOTE: filename can be the same, but because this lock is short lived we may never have a collision + lockFile = new QLockFile(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + + QLatin1String("/") + QFileInfo(filePath()).fileName() + QLatin1String(".lock")); + } else { +#endif + lockFile = new QLockFile(filePath() + QLatin1String(".lock")); +#ifdef Q_OS_ANDROID + } +#endif } lockFile->lock(); From 1e42d79728f57197a8c70618ef48cc38b8c27ac7 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Fri, 1 Oct 2021 01:21:46 +0000 Subject: [PATCH 195/259] SVN_SILENT made messages (.desktop file) - always resolve ours In case of conflict in i18n, keep the version of the branch "ours" To resolve a particular conflict, "git checkout --ours path/to/file.desktop" --- src/core/kconfigbackend.desktop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/kconfigbackend.desktop b/src/core/kconfigbackend.desktop index 39e35cd5..c3533986 100644 --- a/src/core/kconfigbackend.desktop +++ b/src/core/kconfigbackend.desktop @@ -74,7 +74,7 @@ Comment[sr@ijekavian]=Складишна позадина за К‑конфиг Comment[sr@ijekavianlatin]=Skladišna pozadina za KConfig Comment[sr@latin]=Skladišna pozadina za KConfig Comment[sv]=Lagringsgränssnitt för KConfig -Comment[ta]=கேவடிவமைப்பிற்கான பின்னணி சேமிப்பகம் +Comment[ta]=KConfig-க்கான சேமிப்பக பின்நிலை Comment[tg]=Коркардкунандаи захирагоҳ барои KConfig Comment[th]=โปรแกรมเบื้องหลังพื้นที่จัดเก็บข้อมูลสำหรับ KConfig Comment[tr]=KConfig için Depolama Arka Ucu From 4fceed00bd4a93bb9f0620627e90ed4909a5a9c1 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 2 Oct 2021 12:15:25 +0000 Subject: [PATCH 196/259] GIT_SILENT Upgrade ECM and KF version requirements for 5.87.0 release. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 83599192..bb34d379 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ set(KF_VERSION "5.87.0") # handled by release scripts project(KConfig VERSION ${KF_VERSION}) include(FeatureSummary) -find_package(ECM 5.86.0 NO_MODULE) +find_package(ECM 5.87.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) From 07c9b76f9790dd524b9a85aef8121de1b749860a Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Thu, 7 Oct 2021 00:04:08 +0200 Subject: [PATCH 197/259] Add Android CI --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8950fb6d..aeb8916c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,3 +3,4 @@ include: - https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/linux.yml + - https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/android.yml From 14bab9269f9c8b84cc9f8a2f70203c6925e8e7d6 Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Thu, 7 Oct 2021 00:28:35 +0200 Subject: [PATCH 198/259] Add FreeBSD CI --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index aeb8916c..95f47074 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,3 +4,4 @@ include: - https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/linux.yml - https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/android.yml + - https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/freebsd.yml From 13b79463dd80c84c7cf1c817c363e7747e4da034 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 9 Oct 2021 13:25:58 +0000 Subject: [PATCH 199/259] GIT_SILENT Upgrade KF version to 5.88.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb34d379..f804a586 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.16) -set(KF_VERSION "5.87.0") # handled by release scripts +set(KF_VERSION "5.88.0") # handled by release scripts project(KConfig VERSION ${KF_VERSION}) include(FeatureSummary) From f7754f2bb3db666e4bfb2b82af079828e0086b84 Mon Sep 17 00:00:00 2001 From: Alexander Lohnau Date: Sun, 19 Sep 2021 20:02:50 +0200 Subject: [PATCH 200/259] Create utility method for moving entries from one group to another This will become especially useful when moving state data from the config file to a dedicated state data file. Task: https://phabricator.kde.org/T12549 --- autotests/kconfigtest.cpp | 41 +++++++++++++++++++++++++++++++++++++++ autotests/kconfigtest.h | 2 ++ src/core/kconfig.cpp | 9 +++++++-- src/core/kconfig_p.h | 7 +++++++ src/core/kconfiggroup.cpp | 26 +++++++++++++++++++++++++ src/core/kconfiggroup.h | 8 ++++++++ 6 files changed, 91 insertions(+), 2 deletions(-) diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index c3a68e42..00e7bbf0 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -1898,6 +1898,47 @@ void KConfigTest::testNewlines() #endif } +void KConfigTest::testMoveValuesTo() +{ + QTemporaryFile file; + QVERIFY(file.open()); + // Prepare kdeglobals + { + KConfig glob(QStringLiteral("kdeglobals")); + KConfigGroup general(&glob, "TestGroup"); + general.writeEntry("GlobalKey", "PlsDeleteMe"); + QVERIFY(glob.sync()); + } + + KConfigGroup grp = KSharedConfig::openConfig(file.fileName())->group("TestGroup"); + + grp.writeEntry("test1", "first_value"); + grp.writeEntry("test_empty", ""); + grp.writeEntry("other", "other_value"); + grp.writePathEntry("my_path", QStringLiteral("~/somepath")); + // because this key is from the global file it should be explicitly deleted + grp.deleteEntry("GlobalKey"); + + QTemporaryFile targetFile; + QVERIFY(targetFile.open()); + targetFile.close(); + KConfigGroup targetGroup = KSharedConfig::openConfig(targetFile.fileName(), KConfig::SimpleConfig)->group("MoveToGroup"); + + grp.moveValuesTo({"test1", "test_empty", "does_not_exist", "my_path", "GlobalKey"}, targetGroup); + QVERIFY(grp.config()->isDirty()); + QVERIFY(targetGroup.config()->isDirty()); + + QCOMPARE(grp.keyList(), QStringList{QStringLiteral("other")}); + QStringList expectedKeyList{QStringLiteral("my_path"), QStringLiteral("test1"), QStringLiteral("test_empty")}; + QCOMPARE(targetGroup.keyList(), expectedKeyList); + QCOMPARE(targetGroup.readEntry("test1"), QStringLiteral("first_value")); + + targetGroup.sync(); + QFile targetReadFile(targetFile.fileName()); + targetReadFile.open(QFile::ReadOnly); + QVERIFY(targetReadFile.readAll().contains(QByteArray("my_path[$e]=~/somepath"))); +} + void KConfigTest::testXdgListEntry() { QTemporaryFile file; diff --git a/autotests/kconfigtest.h b/autotests/kconfigtest.h index 9d519eda..f716bd70 100644 --- a/autotests/kconfigtest.h +++ b/autotests/kconfigtest.h @@ -64,6 +64,8 @@ private Q_SLOTS: void testQStringUtf8_data(); void testQStringUtf8(); + void testMoveValuesTo(); + void testSubGroup(); void testAddConfigSources(); void testWriteOnSync(); diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index 506e3f90..03ab67d3 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -1009,15 +1009,20 @@ void KConfigPrivate::revertEntry(const QByteArray &group, const char *key, KConf } QByteArray KConfigPrivate::lookupData(const QByteArray &group, const char *key, KEntryMap::SearchFlags flags) const +{ + return lookupInternalEntry(group, key, flags).mValue; +} + +KEntry KConfigPrivate::lookupInternalEntry(const QByteArray &group, const char *key, KEntryMap::SearchFlags flags) const { if (bReadDefaults) { flags |= KEntryMap::SearchDefaults; } const auto it = entryMap.constFindEntry(group, key, flags); if (it == entryMap.constEnd()) { - return QByteArray(); + return {}; } - return it->mValue; + return it.value(); } QString KConfigPrivate::lookupData(const QByteArray &group, const char *key, KEntryMap::SearchFlags flags, bool *expand) const diff --git a/src/core/kconfig_p.h b/src/core/kconfig_p.h index e5c9d869..60604477 100644 --- a/src/core/kconfig_p.h +++ b/src/core/kconfig_p.h @@ -34,8 +34,15 @@ class KConfigPrivate bool canWriteEntry(const QByteArray &group, const char *key, bool isDefault = false) const; QString lookupData(const QByteArray &group, const char *key, KEntryMap::SearchFlags flags, bool *expand) const; QByteArray lookupData(const QByteArray &group, const char *key, KEntryMap::SearchFlags flags) const; + KEntry lookupInternalEntry(const QByteArray &group, const char *key, KEntryMap::SearchFlags flags) const; void putData(const QByteArray &group, const char *key, const QByteArray &value, KConfigBase::WriteConfigFlags flags, bool expand = false); + void setEntryData(const QByteArray &group, const char *key, const QByteArray &value, KEntryMap::EntryOptions flags) + { + if (entryMap.setEntry(group, key, value, flags)) { + bDirty = true; + } + } void revertEntry(const QByteArray &group, const char *key, KConfigBase::WriteConfigFlags flags); QStringList groupList(const QByteArray &group) const; // copies the entries from @p source to @p otherGroup changing all occurrences diff --git a/src/core/kconfiggroup.cpp b/src/core/kconfiggroup.cpp index a15c45eb..be1f2b0e 100644 --- a/src/core/kconfiggroup.cpp +++ b/src/core/kconfiggroup.cpp @@ -1257,3 +1257,29 @@ void KConfigGroup::reparent(KConfigBase *parent, WriteConfigFlags pFlags) oldGroup.copyTo(this, pFlags); oldGroup.deleteGroup(); // so that the entries with the old group name are deleted on sync } + +void KConfigGroup::moveValuesTo(const QList &keys, KConfigGroup &other, WriteConfigFlags pFlags) +{ + Q_ASSERT(isValid()); + Q_ASSERT(other.isValid()); + + for (const auto key : keys) { + const QByteArray groupName = name().toLocal8Bit(); + const auto entry = config()->d_ptr->lookupInternalEntry(groupName, key, KEntryMap::SearchLocalized); + + // Only write the entry if it is not null, if it is a global enry there is no point in moving it + if (!entry.mValue.isNull() && !entry.bGlobal) { + deleteEntry(key, pFlags); + KEntryMap::EntryOptions options = KEntryMap::EntryOption::EntryDirty; + if (entry.bDeleted) { + options |= KEntryMap::EntryDeleted; + } + + if (entry.bExpand) { + options |= KEntryMap::EntryExpansion; + } + + other.config()->d_ptr->setEntryData(other.name().toLocal8Bit(), key, entry.mValue, options); + } + } +} diff --git a/src/core/kconfiggroup.h b/src/core/kconfiggroup.h index 2584cb85..8a6243af 100644 --- a/src/core/kconfiggroup.h +++ b/src/core/kconfiggroup.h @@ -194,6 +194,14 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase */ void reparent(KConfigBase *parent, WriteConfigFlags pFlags = Normal); + /** + * Moves the key-value pairs from one config group to the other. + * In case the entries do not exist the key is ignored. + * + * @since 5.88 + */ + void moveValuesTo(const QList &keys, KConfigGroup &other, WriteConfigFlags pFlags = Normal); + /** * Returns the group that this group belongs to * From 9b44f490c8f5136571da34fcf28eb15e0f3bea6a Mon Sep 17 00:00:00 2001 From: Alexander Lohnau Date: Mon, 11 Oct 2021 19:50:57 +0200 Subject: [PATCH 201/259] Do not try to generate python bindings for KConfigGroup::moveValuesTo --- cmake/rules_PyKF5.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/rules_PyKF5.py b/cmake/rules_PyKF5.py index e510340e..1238aea8 100644 --- a/cmake/rules_PyKF5.py +++ b/cmake/rules_PyKF5.py @@ -74,6 +74,7 @@ def local_function_rules(): ["KConfigGroup", "KConfigGroup", ".*", ".*", ".*KConfigBase.*", rules_engine.function_discard], ["KConfigGroup", "config", ".*", "const KConfig.*", ".*", rules_engine.function_discard], + ["KConfigGroup", "moveValuesTo", ".*", ".*", ".*", rules_engine.function_discard], ["KConfigWatcher", "config", ".*", "KSharedConfig::Ptr", ".*", rules_engine.function_discard], From b0a3e4276e8318475c39c2b7b4b5bc4040dcd19e Mon Sep 17 00:00:00 2001 From: Alexander Lohnau Date: Sun, 26 Sep 2021 18:47:44 +0200 Subject: [PATCH 202/259] Create enum to to authorize common keys By using an enum we have a central place to provide docs for the most common actions/restrictions. Also consumers can pass in type-safe enum values instead of potentially undocumented strings that might contain typos. Also it is better documents is a value is supposed to be authorized using KAuthorized::authorize or KAuthorized::authorizeAction, in the case of "shell_access" this was mixed up from time to time. Considering that we do not want the parameter for the methods to become too long I have deliberately decided against using `enum class`. Also we don't have and usecases for the binary operators in combination with the newly added enums. Task: https://phabricator.kde.org/T11948 --- autotests/kconfigtest.cpp | 13 ++++++++++ autotests/kconfigtest.h | 1 + src/core/kauthorized.cpp | 18 +++++++++++++ src/core/kauthorized.h | 54 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+) diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index 00e7bbf0..9f88e67b 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -2071,6 +2072,18 @@ void KConfigTest::testNotify() QCOMPARE(otherWatcherSpy[0][1].value(), QByteArrayList({"someGlobalEntry"})); } +void KConfigTest::testKAuthorizeEnums() +{ + KSharedConfig::Ptr config = KSharedConfig::openConfig(); + KConfigGroup actionRestrictions = config->group("KDE Action Restrictions"); + actionRestrictions.writeEntry("shell_access", false); + actionRestrictions.writeEntry("action/open_with", false); + + QVERIFY(!KAuthorized::authorize(KAuthorized::SHELL_ACCESS)); + QVERIFY(!KAuthorized::authorizeAction(KAuthorized::OPEN_WITH)); + actionRestrictions.deleteGroup(); +} + void KConfigTest::testKdeglobalsVsDefault() { // Add testRestore key with global value in kdeglobals diff --git a/autotests/kconfigtest.h b/autotests/kconfigtest.h index f716bd70..cdc94366 100644 --- a/autotests/kconfigtest.h +++ b/autotests/kconfigtest.h @@ -82,6 +82,7 @@ private Q_SLOTS: void testNewlines(); void testXdgListEntry(); void testNotify(); + void testKAuthorizeEnums(); void testThreads(); diff --git a/src/core/kauthorized.cpp b/src/core/kauthorized.cpp index 3c0941d5..0c8beef9 100644 --- a/src/core/kauthorized.cpp +++ b/src/core/kauthorized.cpp @@ -218,6 +218,15 @@ bool KAuthorized::authorize(const QString &genericAction) return cg.readEntry(genericAction, true); } +bool KAuthorized::authorize(KAuthorized::GenericRestriction action) +{ + const QMetaEnum metaEnum = QMetaEnum::fromType(); + if (metaEnum.isValid()) { + return KAuthorized::authorize(QString::fromLatin1(metaEnum.valueToKey(action)).toLower()); + } + return false; +} + bool KAuthorized::authorizeAction(const QString &action) { MY_D if (d->blockEverything) @@ -231,6 +240,15 @@ bool KAuthorized::authorizeAction(const QString &action) return authorize(QLatin1String("action/") + action); } +bool KAuthorized::authorizeAction(KAuthorized::GenericAction action) +{ + const QMetaEnum metaEnum = QMetaEnum::fromType(); + if (metaEnum.isValid()) { + return KAuthorized::authorizeAction(QString::fromLatin1(metaEnum.valueToKey(action)).toLower()); + } + return false; +} + #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 24) bool KAuthorized::authorizeKAction(const QString &action) { diff --git a/src/core/kauthorized.h b/src/core/kauthorized.h index a61e0927..b7fa4c97 100644 --- a/src/core/kauthorized.h +++ b/src/core/kauthorized.h @@ -10,7 +10,10 @@ #include +#include +#include #include +#include class QUrl; class QString; @@ -25,6 +28,39 @@ class QString; */ namespace KAuthorized { +Q_NAMESPACE_EXPORT(KCONFIGCORE_EXPORT); + +/** + * The enum values lower cased represent the action that is authorized + * For example the SHELL_ACCESS value is converted to the "shell_access" string. + * + * @since 5.88 + */ +enum GenericRestriction { + SHELL_ACCESS, // if the user is authorized to open a shell or execute shell commands + GHNS, /// if the collaborative data sharing framework KNewStuff is authorized + // GUI behavior + LINEEDIT_REVEAL_PASSWORD, /// if typed characters in password fields can be made visible + LINEEDIT_TEXT_COMPLETION, /// if line edits should be allowed to display completions + MOVABLE_TOOLBARS, /// if toolbars of of apps should be movable + RUN_DESKTOP_FILES, /// if .desktop files should be run as executables when clicked +}; +Q_ENUM_NS(GenericRestriction) + +/** + * + * @since 5.88 + */ +enum GenericAction { + OPEN_WITH, /// if the open-with menu should be shown for files etc. + EDITFILETYPE, /// if mime-type accociations are allowed to be configured + + OPTIONS_SHOW_TOOLBAR, /// if the toolbar should be displayed in apps + SWITCH_APPLICATION_LANGUAGE, /// if an action to switch the app language should be shown + BOOKMARKS, /// saving bookmarks is allowed +}; +Q_ENUM_NS(GenericAction) + /** * Returns whether the user is permitted to perform a certain action. * @@ -57,6 +93,16 @@ namespace KAuthorized */ KCONFIGCORE_EXPORT bool authorize(const QString &action); +/** + * Returns whether the user is permitted to perform a common action. + * The enum values lower cased represent the action that is + * passed in to @p authorize(QString) + * + * @overload + * @since 5.88 + */ +KCONFIGCORE_EXPORT bool authorize(GenericRestriction action); + /** * Returns whether the user is permitted to perform a certain action. * @@ -84,6 +130,14 @@ KCONFIGCORE_EXPORT bool authorize(const QString &action); */ KCONFIGCORE_EXPORT bool authorizeAction(const QString &action); +/** + * Overload to authorize common actions. + * + * @overload + * @since 5.88 + */ +KCONFIGCORE_EXPORT bool authorizeAction(GenericAction action); + #if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(5, 24) /** * Returns whether the user is permitted to perform a certain action. From 9b134d6354089920d22c8de783093120c44cfb36 Mon Sep 17 00:00:00 2001 From: Alexander Lohnau Date: Sat, 9 Oct 2021 15:09:57 +0200 Subject: [PATCH 203/259] Enforce KAuthorized enums being not 0 This will output a warning if an invalid value is requested. The goal is to avoid implicit conversion which might result in a zero-int value. --- autotests/kconfigtest.cpp | 3 +++ src/core/kauthorized.cpp | 9 +++++++-- src/core/kauthorized.h | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index 9f88e67b..4657ea8d 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -2082,6 +2082,9 @@ void KConfigTest::testKAuthorizeEnums() QVERIFY(!KAuthorized::authorize(KAuthorized::SHELL_ACCESS)); QVERIFY(!KAuthorized::authorizeAction(KAuthorized::OPEN_WITH)); actionRestrictions.deleteGroup(); + + QVERIFY(!KAuthorized::authorize((KAuthorized::GenericRestriction)0)); + QVERIFY(!KAuthorized::authorizeAction((KAuthorized::GenericAction)0)); } void KConfigTest::testKdeglobalsVsDefault() diff --git a/src/core/kauthorized.cpp b/src/core/kauthorized.cpp index 0c8beef9..aad23949 100644 --- a/src/core/kauthorized.cpp +++ b/src/core/kauthorized.cpp @@ -7,10 +7,12 @@ #include "kauthorized.h" +#include #include #include #include +#include "kconfig_core_log_settings.h" #include #include #include // srand(), rand() @@ -221,9 +223,11 @@ bool KAuthorized::authorize(const QString &genericAction) bool KAuthorized::authorize(KAuthorized::GenericRestriction action) { const QMetaEnum metaEnum = QMetaEnum::fromType(); - if (metaEnum.isValid()) { + + if (metaEnum.isValid() && action != 0) { return KAuthorized::authorize(QString::fromLatin1(metaEnum.valueToKey(action)).toLower()); } + qCWarning(KCONFIG_CORE_LOG) << "Invalid GenericRestriction requested" << action; return false; } @@ -243,9 +247,10 @@ bool KAuthorized::authorizeAction(const QString &action) bool KAuthorized::authorizeAction(KAuthorized::GenericAction action) { const QMetaEnum metaEnum = QMetaEnum::fromType(); - if (metaEnum.isValid()) { + if (metaEnum.isValid() && action != 0) { return KAuthorized::authorizeAction(QString::fromLatin1(metaEnum.valueToKey(action)).toLower()); } + qCWarning(KCONFIG_CORE_LOG) << "Invalid GenericAction requested" << action; return false; } diff --git a/src/core/kauthorized.h b/src/core/kauthorized.h index b7fa4c97..071e0cb2 100644 --- a/src/core/kauthorized.h +++ b/src/core/kauthorized.h @@ -37,7 +37,7 @@ Q_NAMESPACE_EXPORT(KCONFIGCORE_EXPORT); * @since 5.88 */ enum GenericRestriction { - SHELL_ACCESS, // if the user is authorized to open a shell or execute shell commands + SHELL_ACCESS = 1, // if the user is authorized to open a shell or execute shell commands GHNS, /// if the collaborative data sharing framework KNewStuff is authorized // GUI behavior LINEEDIT_REVEAL_PASSWORD, /// if typed characters in password fields can be made visible @@ -52,7 +52,7 @@ Q_ENUM_NS(GenericRestriction) * @since 5.88 */ enum GenericAction { - OPEN_WITH, /// if the open-with menu should be shown for files etc. + OPEN_WITH = 1, /// if the open-with menu should be shown for files etc. EDITFILETYPE, /// if mime-type accociations are allowed to be configured OPTIONS_SHOW_TOOLBAR, /// if the toolbar should be displayed in apps From 5bc393b0615020d8e04ebed13364d3ab7a21d856 Mon Sep 17 00:00:00 2001 From: Alexander Lohnau Date: Wed, 13 Oct 2021 15:43:32 +0200 Subject: [PATCH 204/259] Exclude new enum-overload from python bindings build --- src/core/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 4e85142e..6c242253 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -81,7 +81,6 @@ if (PythonModuleGeneration_FOUND) SIP_DEPENDS QtCore/QtCoremod.sip HEADERS - kauthorized.h kconfig.h kconfigbase.h kconfiggroup.h From 605383b1a299ea69444b10a5cf2eb9cb61009f86 Mon Sep 17 00:00:00 2001 From: Alexander Lohnau Date: Wed, 20 Oct 2021 11:12:49 +0200 Subject: [PATCH 205/259] GIT_SILENT Remove a bit of dead code --- src/core/kdesktopfile.cpp | 14 -------------- src/core/kdesktopfile.h | 5 ----- src/kconf_update/kconf_update.cpp | 2 -- 3 files changed, 21 deletions(-) diff --git a/src/core/kdesktopfile.cpp b/src/core/kdesktopfile.cpp index 408da286..d26ed59d 100644 --- a/src/core/kdesktopfile.cpp +++ b/src/core/kdesktopfile.cpp @@ -310,17 +310,6 @@ bool KDesktopFile::tryExec() const return true; } -/** - * @return the filename as passed to the constructor. - */ -// QString KDesktopFile::fileName() const { return backEnd->fileName(); } - -/** - * @return the resource type as passed to the constructor. - */ -// QString -// KDesktopFile::resource() const { return backEnd->resource(); } - #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 42) QStringList KDesktopFile::sortOrder() const { @@ -329,9 +318,6 @@ QStringList KDesktopFile::sortOrder() const } #endif -// void KDesktopFile::virtual_hook( int id, void* data ) -//{ KConfig::virtual_hook( id, data ); } - QString KDesktopFile::readDocPath() const { Q_D(const KDesktopFile); diff --git a/src/core/kdesktopfile.h b/src/core/kdesktopfile.h index 25420083..da0f39b4 100644 --- a/src/core/kdesktopfile.h +++ b/src/core/kdesktopfile.h @@ -242,11 +242,6 @@ class KCONFIGCORE_EXPORT KDesktopFile : public KConfig QStandardPaths::StandardLocation resource() const; -protected: - /** Virtual hook, used to add new "virtual" functions while maintaining - binary compatibility. Unused in this class. - */ - // virtual void virtual_hook( int id, void* data ); private: Q_DISABLE_COPY(KDesktopFile) diff --git a/src/kconf_update/kconf_update.cpp b/src/kconf_update/kconf_update.cpp index eec97d66..8cbbc3c3 100644 --- a/src/kconf_update/kconf_update.cpp +++ b/src/kconf_update/kconf_update.cpp @@ -812,7 +812,6 @@ void KonfUpdate::gotScript(const QString &_script) proc.setStandardOutputFile(scriptOut.fileName()); if (m_oldConfig1) { if (m_bDebugOutput) { - // scriptIn.setAutoRemove(false); qCDebug(KCONF_UPDATE_LOG) << "Script input stored in" << scriptIn.fileName(); } KConfig cfg(scriptIn.fileName(), KConfig::SimpleConfig); @@ -871,7 +870,6 @@ void KonfUpdate::gotScript(const QString &_script) } if (m_bDebugOutput) { - // scriptOut.setAutoRemove(false); qCDebug(KCONF_UPDATE_LOG) << "Script output stored in" << scriptOut.fileName(); QFile output(scriptOut.fileName()); if (output.open(QIODevice::ReadOnly)) { From c64a73a4c4f3c3fc31720c6004c217cd44b7de0b Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Tue, 2 Nov 2021 07:50:11 +0100 Subject: [PATCH 206/259] GIT_SILENT: add missing override --- src/core/kconfig.h | 2 +- src/core/kconfigbackend_p.h | 2 +- src/core/kconfiggroup.h | 2 +- src/core/kcoreconfigskeleton.h | 2 +- src/core/kdesktopfile.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/kconfig.h b/src/core/kconfig.h index 6fee5ff5..0835c951 100644 --- a/src/core/kconfig.h +++ b/src/core/kconfig.h @@ -139,7 +139,7 @@ class KCONFIGCORE_EXPORT KConfig : public KConfigBase */ KConfig(const QString &file, const QString &backend, QStandardPaths::StandardLocation type = QStandardPaths::GenericConfigLocation); - virtual ~KConfig(); + ~KConfig() override; /** * Returns the standard location enum passed to the constructor. diff --git a/src/core/kconfigbackend_p.h b/src/core/kconfigbackend_p.h index 5b38634f..1884643f 100644 --- a/src/core/kconfigbackend_p.h +++ b/src/core/kconfigbackend_p.h @@ -63,7 +63,7 @@ class KConfigBackend : public QObject, public QSharedData static void registerMappings(const KEntryMap &entryMap); /** Destroys the backend */ - virtual ~KConfigBackend(); + ~KConfigBackend() override; /** Allows the behaviour of parseConfig() to be tuned */ enum ParseOption { diff --git a/src/core/kconfiggroup.h b/src/core/kconfiggroup.h index 8a6243af..6a6a74da 100644 --- a/src/core/kconfiggroup.h +++ b/src/core/kconfiggroup.h @@ -92,7 +92,7 @@ class KCONFIGCORE_EXPORT KConfigGroup : public KConfigBase KConfigGroup(const KConfigGroup &); KConfigGroup &operator=(const KConfigGroup &); - ~KConfigGroup(); + ~KConfigGroup() override; /** * Whether the group is valid. diff --git a/src/core/kcoreconfigskeleton.h b/src/core/kcoreconfigskeleton.h index aafc417c..d32de14a 100644 --- a/src/core/kcoreconfigskeleton.h +++ b/src/core/kcoreconfigskeleton.h @@ -1131,7 +1131,7 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject /** * Destructor */ - virtual ~KCoreConfigSkeleton(); + ~KCoreConfigSkeleton() override; /** * Set all registered items to their default values. diff --git a/src/core/kdesktopfile.h b/src/core/kdesktopfile.h index da0f39b4..5cd739f1 100644 --- a/src/core/kdesktopfile.h +++ b/src/core/kdesktopfile.h @@ -56,7 +56,7 @@ class KCONFIGCORE_EXPORT KDesktopFile : public KConfig * * Writes back any dirty configuration entries. */ - virtual ~KDesktopFile(); + ~KDesktopFile() override; /** * Checks whether this is really a desktop file. From 473a9137db305ea69cb4b40f23ed679c90c4b475 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 13 Nov 2021 11:28:48 +0000 Subject: [PATCH 207/259] GIT_SILENT Upgrade KF version to 5.89.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f804a586..326912b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.16) -set(KF_VERSION "5.88.0") # handled by release scripts +set(KF_VERSION "5.89.0") # handled by release scripts project(KConfig VERSION ${KF_VERSION}) include(FeatureSummary) From c3be6d02f6c061707c6d93e06889a2e56b994d87 Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Sun, 14 Nov 2021 19:26:34 +0100 Subject: [PATCH 208/259] Avoid some allocations by QString/QByteArray's toLower() NO_CHANGELOG --- src/core/kauthorized.cpp | 2 +- src/core/kconfiggroup.cpp | 12 +++++++----- src/core/kcoreconfigskeleton.cpp | 4 ++-- src/gui/kconfigloader.cpp | 2 +- src/kconf_update/kconf_update.cpp | 11 ++++++++--- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/core/kauthorized.cpp b/src/core/kauthorized.cpp index aad23949..66a2be23 100644 --- a/src/core/kauthorized.cpp +++ b/src/core/kauthorized.cpp @@ -332,7 +332,7 @@ KCONFIGCORE_EXPORT void loadUrlActionRestrictions(const KConfigGroup &cg) const QString urlProt = rule[4]; const QString urlHost = rule[5]; QString urlPath = rule[6]; - const bool bEnabled = (rule[7].toLower() == QLatin1String("true")); + const bool bEnabled = (rule[7].compare(QLatin1String("true"), Qt::CaseInsensitive) == 0); if (refPath.startsWith(QLatin1String("$HOME"))) { refPath.replace(0, 5, QDir::homePath()); diff --git a/src/core/kconfiggroup.cpp b/src/core/kconfiggroup.cpp index be1f2b0e..24a8ccfd 100644 --- a/src/core/kconfiggroup.cpp +++ b/src/core/kconfiggroup.cpp @@ -26,6 +26,8 @@ #include #include +#include +#include #include #include @@ -234,11 +236,11 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val case QMetaType::QByteArray: return value; case QMetaType::Bool: { - const QByteArray lower(value.toLower()); - if (lower == "false" || lower == "no" || lower == "off" || lower == "0") { - return false; - } - return true; + static const std::array negatives = {"false", "no", "off", "0"}; + + return std::all_of(negatives.begin(), negatives.end(), [value](const char *negativeString) { + return value.compare(negativeString, Qt::CaseInsensitive) != 0; + }); } case QMetaType::Double: case QMetaType::Float: diff --git a/src/core/kcoreconfigskeleton.cpp b/src/core/kcoreconfigskeleton.cpp index f8097055..030039fc 100644 --- a/src/core/kcoreconfigskeleton.cpp +++ b/src/core/kcoreconfigskeleton.cpp @@ -608,10 +608,10 @@ void KCoreConfigSkeleton::ItemEnum::readConfig(KConfig *config) } else { int i = 0; mReference = -1; - QString tmp = cg.readEntry(mKey, QString()).toLower(); + const QString entryString = cg.readEntry(mKey, QString()); for (auto it = mChoices.cbegin(); it != mChoices.cend(); ++it, ++i) { QString choiceName = (*it).name; - if (valueForChoice(choiceName).toLower() == tmp) { + if (valueForChoice(choiceName).compare(entryString, Qt::CaseInsensitive) == 0) { mReference = i; break; } diff --git a/src/gui/kconfigloader.cpp b/src/gui/kconfigloader.cpp index ac39a12f..08365f17 100644 --- a/src/gui/kconfigloader.cpp +++ b/src/gui/kconfigloader.cpp @@ -172,7 +172,7 @@ void ConfigLoaderHandler::addItem() KConfigSkeletonItem *item = nullptr; if (m_type == QLatin1String("bool")) { - bool defaultValue = m_default.toLower() == QLatin1String("true"); + const bool defaultValue = caseInsensitiveCompare(m_default, QLatin1String("true")); item = m_config->addItemBool(m_name, *d->newBool(), defaultValue, m_key); } else if (m_type == QLatin1String("color")) { item = m_config->addItemColor(m_name, *d->newColor(), QColor(m_default), m_key); diff --git a/src/kconf_update/kconf_update.cpp b/src/kconf_update/kconf_update.cpp index 8cbbc3c3..0e9744a0 100644 --- a/src/kconf_update/kconf_update.cpp +++ b/src/kconf_update/kconf_update.cpp @@ -35,6 +35,11 @@ // the file. #define qCDebugFile(CATEGORY) qCDebug(CATEGORY) << m_currentFilename << ':' << m_lineCount << ":'" << m_line << "': " +static bool caseInsensitiveCompare(const QStringView &a, const QLatin1String &b) +{ + return a.compare(b, Qt::CaseInsensitive) == 0; +} + class KonfUpdate { public: @@ -701,11 +706,11 @@ void KonfUpdate::gotOptions(const QString &_options) { const QStringList options = _options.split(QLatin1Char{','}); for (const auto &opt : options) { - const auto normalizedOpt = opt.toLower().trimmed(); + const auto normalizedOpt = QStringView(opt).trimmed(); - if (normalizedOpt == QLatin1String("copy")) { + if (caseInsensitiveCompare(normalizedOpt, QLatin1String("copy"))) { m_bCopy = true; - } else if (normalizedOpt == QLatin1String("overwrite")) { + } else if (caseInsensitiveCompare(normalizedOpt, QLatin1String("overwrite"))) { m_bOverwrite = true; } } From 3f29f3d6452f735757cb8f84dfc20cdcba791613 Mon Sep 17 00:00:00 2001 From: Alexander Lohnau Date: Sun, 7 Nov 2021 21:34:18 +0100 Subject: [PATCH 209/259] Copy ConfigPropertyMap from KDeclarative to new KConfig QML module This way consumers which want to use the ConfigPropertyMap don't have to pull in KDeclarative's entire dependency tree. Also we can remove the automatic saving of the config, previously this was opt-out - which makes is difficult to deprecate anything. This way the API design is also more clear, since the object only takes care of exposing the data to QML. The writing has to be done manually, which makes more sense anyways when we have the notify opt-in. As discussed on the KF6 weekly thread, an optional QML submodule is seen as the best way to handle the QML dependency. Task: https://phabricator.kde.org/T12131 Relates to https://phabricator.kde.org/T12126, after his change the KDeclarative stuff can be deprecated. Because we don't register the property map in any QML plugin, there is no conflict in duplicating and modifying it now. --- CMakeLists.txt | 1 + src/CMakeLists.txt | 3 + src/qml/CMakeLists.txt | 39 +++++++++ src/qml/kconfigpropertymap.cpp | 148 +++++++++++++++++++++++++++++++++ src/qml/kconfigpropertymap.h | 69 +++++++++++++++ 5 files changed, 260 insertions(+) create mode 100644 src/qml/CMakeLists.txt create mode 100644 src/qml/kconfigpropertymap.cpp create mode 100644 src/qml/kconfigpropertymap.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 326912b7..64e24647 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ option(KCONFIG_USE_GUI "Build components using Qt5Gui" ON) if(KCONFIG_USE_GUI) find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Gui) endif() +find_package(Qt5 ${REQUIRED_QT_VERSION} OPTIONAL_COMPONENTS Qml) if (NOT ANDROID) option(KCONFIG_USE_DBUS "Build components using Qt5DBus" ON) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e6bac82a..89fe7284 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,6 +2,9 @@ add_subdirectory(core) if(TARGET Qt5::Gui) add_subdirectory(gui) endif() +if(TARGET Qt5::Qml) + add_subdirectory(qml) +endif() add_subdirectory(kconfig_compiler) add_subdirectory(kconf_update) add_subdirectory(kreadconfig) diff --git a/src/qml/CMakeLists.txt b/src/qml/CMakeLists.txt new file mode 100644 index 00000000..1cdae88a --- /dev/null +++ b/src/qml/CMakeLists.txt @@ -0,0 +1,39 @@ +add_library(KF5ConfigQml) +add_library(KF5::ConfigQml ALIAS KF5ConfigQml) + +target_sources(KF5ConfigQml PRIVATE + kconfigpropertymap.cpp +) + +ecm_generate_export_header(KF5ConfigQml + BASE_NAME KConfigQml + GROUP_BASE_NAME KF + VERSION ${KF_VERSION} + DEPRECATED_BASE_VERSION 0 + EXCLUDE_DEPRECATED_BEFORE_AND_AT ${EXCLUDE_DEPRECATED_BEFORE_AND_AT} +) + +target_link_libraries(KF5ConfigQml + PUBLIC + KF5::ConfigCore # KCoreConfigSkeleton, in ConfigPropertyMap + Qt5::Qml +) +set_target_properties(KF5ConfigQml PROPERTIES VERSION ${KCONFIG_VERSION} + SOVERSION ${KCONFIG_SOVERSION} + EXPORT_NAME ConfigQml +) + +ecm_generate_headers(KConfigQml_HEADERS + HEADER_NAMES + KConfigPropertyMap + + REQUIRED_HEADERS KConfigQml_HEADERS +) +target_include_directories(KF5ConfigQml INTERFACE "$") + +install(TARGETS KF5ConfigQml EXPORT KF5ConfigTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/kconfigqml_export.h + ${KConfigQml_HEADERS} + DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/KConfigQml COMPONENT Devel +) diff --git a/src/qml/kconfigpropertymap.cpp b/src/qml/kconfigpropertymap.cpp new file mode 100644 index 00000000..55b2991d --- /dev/null +++ b/src/qml/kconfigpropertymap.cpp @@ -0,0 +1,148 @@ +/* + SPDX-FileCopyrightText: 2013 Marco Martin + SPDX-FileCopyrightText: 2020 David Edmundson + SPDX-FileCopyrightText: 2021 Alexander Lohnau + + SPDX-License-Identifier: LGPL-2.0-or-later +*/ + +#include "kconfigpropertymap.h" + +#include +#include +#include + +#include + +class KConfigPropertyMapPrivate +{ +public: + KConfigPropertyMapPrivate(KConfigPropertyMap *map) + : q(map) + { + } + + enum LoadConfigOption { + DontEmitValueChanged, + EmitValueChanged, + }; + + void loadConfig(LoadConfigOption option); + void writeConfig(); + void writeConfigValue(const QString &key, const QVariant &value); + + KConfigPropertyMap *q; + QPointer config; + bool updatingConfigValue = false; + bool autosave = true; + bool notify = false; +}; + +KConfigPropertyMap::KConfigPropertyMap(KCoreConfigSkeleton *config, QObject *parent) + : QQmlPropertyMap(this, parent) + , d(new KConfigPropertyMapPrivate(this)) +{ + Q_ASSERT(config); + d->config = config; + + // Reload the config only if the change signal has *not* been emitted by ourselves updating the config + connect(config, &KCoreConfigSkeleton::configChanged, this, [this]() { + if (!d->updatingConfigValue) { + d->loadConfig(KConfigPropertyMapPrivate::EmitValueChanged); + } + }); + connect(this, &KConfigPropertyMap::valueChanged, this, [this](const QString &key, const QVariant &value) { + d->writeConfigValue(key, value); + }); + + d->loadConfig(KConfigPropertyMapPrivate::DontEmitValueChanged); +} + +KConfigPropertyMap::~KConfigPropertyMap() = default; + +bool KConfigPropertyMap::isNotify() const +{ + return d->notify; +} + +void KConfigPropertyMap::setNotify(bool notify) +{ + d->notify = notify; +} + +void KConfigPropertyMap::writeConfig() +{ + d->writeConfig(); +} + +QVariant KConfigPropertyMap::updateValue(const QString &key, const QVariant &input) +{ + Q_UNUSED(key); + if (input.userType() == qMetaTypeId()) { + return input.value().toVariant(); + } + return input; +} + +bool KConfigPropertyMap::isImmutable(const QString &key) const +{ + KConfigSkeletonItem *item = d->config.data()->findItem(key); + if (item) { + return item->isImmutable(); + } + + return false; +} + +void KConfigPropertyMapPrivate::loadConfig(KConfigPropertyMapPrivate::LoadConfigOption option) +{ + if (!config) { + return; + } + + const auto &items = config.data()->items(); + for (KConfigSkeletonItem *item : items) { + q->insert(item->key() + QStringLiteral("Default"), item->getDefault()); + q->insert(item->key(), item->property()); + if (option == EmitValueChanged) { + Q_EMIT q->valueChanged(item->key(), item->property()); + } + } +} + +void KConfigPropertyMapPrivate::writeConfig() +{ + if (!config) { + return; + } + + const auto lstItems = config.data()->items(); + for (KConfigSkeletonItem *item : lstItems) { + item->setWriteFlags(notify ? KConfigBase::Notify : KConfigBase::Normal); + item->setProperty(q->value(item->key())); + } + + if (autosave) { + updatingConfigValue = true; + config.data()->save(); + updatingConfigValue = false; + } +} + +void KConfigPropertyMapPrivate::writeConfigValue(const QString &key, const QVariant &value) +{ + KConfigSkeletonItem *item = config.data()->findItem(key); + if (item) { + updatingConfigValue = true; + item->setWriteFlags(notify ? KConfigBase::Notify : KConfigBase::Normal); + item->setProperty(value); + if (autosave) { + config.data()->save(); + // why read? read will update KConfigSkeletonItem::mLoadedValue, + // allowing a write operation to be performed next time + config.data()->read(); + } + updatingConfigValue = false; + } +} + diff --git a/src/qml/kconfigpropertymap.h b/src/qml/kconfigpropertymap.h new file mode 100644 index 00000000..3795e099 --- /dev/null +++ b/src/qml/kconfigpropertymap.h @@ -0,0 +1,69 @@ +/* + SPDX-FileCopyrightText: 2013 Marco Martin + SPDX-FileCopyrightText: 2020 David Edmundson + SPDX-FileCopyrightText: 2021 Alexander Lohnau + + SPDX-License-Identifier: LGPL-2.0-or-later +*/ + +#ifndef KCONFIGPROPERTYMAP_H +#define KCONFIGPROPERTYMAP_H + +#include +#include + +class KCoreConfigSkeleton; + +#include + +class KConfigPropertyMapPrivate; + +/** + * @class KConfigPropertyMap configpropertymap.h ConfigPropertyMap + * + * An object that (optionally) automatically saves changes in a + * property map to a configuration object (e.g. a KConfig file). + * @since 5.89 + */ +class KCONFIGQML_EXPORT KConfigPropertyMap : public QQmlPropertyMap +{ + Q_OBJECT + +public: + KConfigPropertyMap(KCoreConfigSkeleton *config, QObject *parent = nullptr); + ~KConfigPropertyMap() override; + + /** + * Whether notifications on config changes are enabled. Disabled by default. + * @see KConfigBase::Notify + * @return true if writes send (dbus) notifications + */ + bool isNotify() const; + + /** + * Enable or disable notifications on config changes. + * @see KConfigBase::Notify + * @param notify whether to send notifications + */ + void setNotify(bool notify); + + /** + * @brief Whether the value at the given key is immutable + * + * @return true if the value is immutable, false if it isn't or it doesn't exist + */ + Q_INVOKABLE bool isImmutable(const QString &key) const; + + /** + * Saves the state of the property map on disk. + */ + void writeConfig(); + +protected: + QVariant updateValue(const QString &key, const QVariant &input) override; + +private: + std::unique_ptr const d; +}; + +#endif From 10dee5131d940316cf0136516013e2ed3aeee012 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Sun, 17 Oct 2021 12:10:36 +0200 Subject: [PATCH 210/259] Demonstrate build failure with kconfig generated code --- autotests/kconfig_compiler/CMakeLists.txt | 8 ++++++ .../test_enums_and_properties.kcfg | 25 +++++++++++++++++++ .../test_enums_and_properties.kcfgc | 4 +++ 3 files changed, 37 insertions(+) create mode 100644 autotests/kconfig_compiler/test_enums_and_properties.kcfg create mode 100644 autotests/kconfig_compiler/test_enums_and_properties.kcfgc diff --git a/autotests/kconfig_compiler/CMakeLists.txt b/autotests/kconfig_compiler/CMakeLists.txt index 4641c0e0..4778de48 100644 --- a/autotests/kconfig_compiler/CMakeLists.txt +++ b/autotests/kconfig_compiler/CMakeLists.txt @@ -303,3 +303,11 @@ gen_kcfg_test_source(test_fileextensions test_fileextensions_SRCS) ecm_add_test(TEST_NAME test_fileextensions ${test_fileextensions_SRCS}) target_link_libraries(test_fileextensions KF5::ConfigGui) + + +####### next target ########## +## This test fails the compilation - to showcase that the generated code is broken. +set(test_enums_and_properties_SRCS test10main.cpp) +gen_kcfg_test_source(test_enums_and_properties test_enums_and_properties_SRCS GENERATE_MOC) +add_library(test_enums_and_properties ${test_enums_and_properties_SRCS}) +target_link_libraries(test_enums_and_properties KF5::ConfigGui) diff --git a/autotests/kconfig_compiler/test_enums_and_properties.kcfg b/autotests/kconfig_compiler/test_enums_and_properties.kcfg new file mode 100644 index 00000000..8ce6a41b --- /dev/null +++ b/autotests/kconfig_compiler/test_enums_and_properties.kcfg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + 0 + + + diff --git a/autotests/kconfig_compiler/test_enums_and_properties.kcfgc b/autotests/kconfig_compiler/test_enums_and_properties.kcfgc new file mode 100644 index 00000000..7df2cf27 --- /dev/null +++ b/autotests/kconfig_compiler/test_enums_and_properties.kcfgc @@ -0,0 +1,4 @@ +File=test_enums_and_properties.kcfg +ClassName=TestEnumsAndProperties +GenerateProperties=true +Mutators=true From e16ab18ed8e588ea14b219d5738e9dc9f5fc5cf6 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 21 Oct 2021 10:30:49 +0200 Subject: [PATCH 211/259] unbreak kconfig with enums, mutators and properties. --- autotests/kconfig_compiler/empty_main.cpp | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 autotests/kconfig_compiler/empty_main.cpp diff --git a/autotests/kconfig_compiler/empty_main.cpp b/autotests/kconfig_compiler/empty_main.cpp new file mode 100644 index 00000000..b6343e89 --- /dev/null +++ b/autotests/kconfig_compiler/empty_main.cpp @@ -0,0 +1,2 @@ +int main() {return 0;} + From 829cc003ee4f21e91d806a2e2a353ae709ab999f Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 21 Oct 2021 10:51:16 +0200 Subject: [PATCH 212/259] Add missing changes --- autotests/kconfig_compiler/CMakeLists.txt | 4 ++-- autotests/kconfig_compiler/empty_main.cpp | 6 ++++-- src/kconfig_compiler/KConfigSourceGenerator.cpp | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/autotests/kconfig_compiler/CMakeLists.txt b/autotests/kconfig_compiler/CMakeLists.txt index 4778de48..6ca8d923 100644 --- a/autotests/kconfig_compiler/CMakeLists.txt +++ b/autotests/kconfig_compiler/CMakeLists.txt @@ -306,8 +306,8 @@ target_link_libraries(test_fileextensions KF5::ConfigGui) ####### next target ########## -## This test fails the compilation - to showcase that the generated code is broken. -set(test_enums_and_properties_SRCS test10main.cpp) +## If this to compiles, we are sure that the generation is correct. +set(test_enums_and_properties_SRCS empty_main.cpp) gen_kcfg_test_source(test_enums_and_properties test_enums_and_properties_SRCS GENERATE_MOC) add_library(test_enums_and_properties ${test_enums_and_properties_SRCS}) target_link_libraries(test_enums_and_properties KF5::ConfigGui) diff --git a/autotests/kconfig_compiler/empty_main.cpp b/autotests/kconfig_compiler/empty_main.cpp index b6343e89..905869df 100644 --- a/autotests/kconfig_compiler/empty_main.cpp +++ b/autotests/kconfig_compiler/empty_main.cpp @@ -1,2 +1,4 @@ -int main() {return 0;} - +int main() +{ + return 0; +} diff --git a/src/kconfig_compiler/KConfigSourceGenerator.cpp b/src/kconfig_compiler/KConfigSourceGenerator.cpp index 45299a4f..9953a15d 100644 --- a/src/kconfig_compiler/KConfigSourceGenerator.cpp +++ b/src/kconfig_compiler/KConfigSourceGenerator.cpp @@ -318,7 +318,8 @@ void KConfigSourceGenerator::createNormalEntry(const CfgEntry *entry, const QStr for (const CfgEntry::Choice &choice : std::as_const(entry->choices.choices)) { if (!choice.val.isEmpty()) { - stream() << " " << itemVarStr << "->setValueForChoice(QStringLiteral( \"" << choice.name << "\" ), QStringLiteral( \"" << choice.val << "\" ));\n"; + stream() << " " << innerItemVarStr << "->setValueForChoice(QStringLiteral( \"" << choice.name << "\" ), QStringLiteral( \"" << choice.val + << "\" ));\n"; } } From 148ea287a0a7b9de96dc299db56254c65aec3385 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 17 Nov 2021 13:16:21 -0300 Subject: [PATCH 213/259] Add a proper test for the enumms within groups --- autotests/kconfig_compiler/CMakeLists.txt | 2 +- autotests/kconfig_compiler/enum_group_main.cpp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 autotests/kconfig_compiler/enum_group_main.cpp diff --git a/autotests/kconfig_compiler/CMakeLists.txt b/autotests/kconfig_compiler/CMakeLists.txt index 6ca8d923..74d09e96 100644 --- a/autotests/kconfig_compiler/CMakeLists.txt +++ b/autotests/kconfig_compiler/CMakeLists.txt @@ -307,7 +307,7 @@ target_link_libraries(test_fileextensions KF5::ConfigGui) ####### next target ########## ## If this to compiles, we are sure that the generation is correct. -set(test_enums_and_properties_SRCS empty_main.cpp) +set(test_enums_and_properties_SRCS enum_group_main.cpp) gen_kcfg_test_source(test_enums_and_properties test_enums_and_properties_SRCS GENERATE_MOC) add_library(test_enums_and_properties ${test_enums_and_properties_SRCS}) target_link_libraries(test_enums_and_properties KF5::ConfigGui) diff --git a/autotests/kconfig_compiler/enum_group_main.cpp b/autotests/kconfig_compiler/enum_group_main.cpp new file mode 100644 index 00000000..fc93d275 --- /dev/null +++ b/autotests/kconfig_compiler/enum_group_main.cpp @@ -0,0 +1,18 @@ +/* + SPDX-FileCopyrightText: 2009 Pino Toscano + + SPDX-License-Identifier: MIT +*/ +#include "test_enums_and_properties.h" +#include + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + + auto *t = new TestEnumsAndProperties(); + delete t; + + Q_UNUSED(app); + return 0; +} From 0d742a8daf55311f048a6959d6641a9a95a2eb04 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 17 Nov 2021 13:29:50 -0300 Subject: [PATCH 214/259] Add the enum group test to the kconfigcompiler_test Making sure that it runs and not segfaults --- autotests/kconfig_compiler/CMakeLists.txt | 2 +- autotests/kconfig_compiler/kconfigcompiler_test.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/autotests/kconfig_compiler/CMakeLists.txt b/autotests/kconfig_compiler/CMakeLists.txt index 74d09e96..4caa17af 100644 --- a/autotests/kconfig_compiler/CMakeLists.txt +++ b/autotests/kconfig_compiler/CMakeLists.txt @@ -309,5 +309,5 @@ target_link_libraries(test_fileextensions KF5::ConfigGui) ## If this to compiles, we are sure that the generation is correct. set(test_enums_and_properties_SRCS enum_group_main.cpp) gen_kcfg_test_source(test_enums_and_properties test_enums_and_properties_SRCS GENERATE_MOC) -add_library(test_enums_and_properties ${test_enums_and_properties_SRCS}) +ecm_add_test(TEST_NAME test_enums_and_properties ${test_enums_and_properties_SRCS}) target_link_libraries(test_enums_and_properties KF5::ConfigGui) diff --git a/autotests/kconfig_compiler/kconfigcompiler_test.cpp b/autotests/kconfig_compiler/kconfigcompiler_test.cpp index 090fe01d..61666939 100644 --- a/autotests/kconfig_compiler/kconfigcompiler_test.cpp +++ b/autotests/kconfig_compiler/kconfigcompiler_test.cpp @@ -91,6 +91,7 @@ static CompilerTestSet testCasesToRun = {"test1", "test11", "test12", "test13", + "test_enums_and_properties", "test_dpointer", "test_qdebugcategory", "test_signal", From e40531e29e2ff52d67156aa8ae7691488ca1c29b Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 17 Nov 2021 13:43:48 -0300 Subject: [PATCH 215/259] Use innerVarStr instead of varStr for choices --- src/kconfig_compiler/KConfigSourceGenerator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kconfig_compiler/KConfigSourceGenerator.cpp b/src/kconfig_compiler/KConfigSourceGenerator.cpp index 9953a15d..d83c1bb4 100644 --- a/src/kconfig_compiler/KConfigSourceGenerator.cpp +++ b/src/kconfig_compiler/KConfigSourceGenerator.cpp @@ -368,7 +368,7 @@ void KConfigSourceGenerator::createIndexedEntry(const CfgEntry *entry, const QSt for (const CfgEntry::Choice &choice : std::as_const(entry->choices.choices)) { if (!choice.val.isEmpty()) { - stream() << " " << itemVarStr << "->setValueForChoice(QStringLiteral( \"" << choice.name << "\" ), QStringLiteral( \"" << choice.val + stream() << " " << innerItemVarStr << "->setValueForChoice(QStringLiteral( \"" << choice.name << "\" ), QStringLiteral( \"" << choice.val << "\" ));\n"; } } From 4c62867b4a38db28c29a063219b9d0f5c7f1cac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Wr=C3=B3bel?= Date: Fri, 26 Nov 2021 11:32:53 +0000 Subject: [PATCH 216/259] README.dox: GENERATE_MOC is required for signals --- src/kconfig_compiler/README.dox | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/kconfig_compiler/README.dox b/src/kconfig_compiler/README.dox index 4c22a452..0ead5939 100644 --- a/src/kconfig_compiler/README.dox +++ b/src/kconfig_compiler/README.dox @@ -531,6 +531,8 @@ for a signal, the signal name will suffice. You can also use the generic configChanged() signal from KConfigSkeleton to notify your application about configuration changes. +Note that you will also need to pass the GENERATE_MOC option to the kconfig_add_kcfg_files macro. + \subsection translation_context Translation context In the kcfg file you can specify the translation's context for \, \ and \ element for an entry. From 2cd5cdfa4a36c5fbeed715297a89bacfa8753ddb Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Wed, 17 Jun 2020 13:45:54 +0200 Subject: [PATCH 217/259] KDesktopFile: deprecate resource() It is redundant since the parent class, KConfig, has locationType(). Add some API docs for fileName(), even though one could use KConfig::name() from the parent class, I think this would be confusing given a .desktop file has a Name= entry, so fileName() is less ambiguous. These seem to be leftovers from a previous refactor that happened a long time ago. --- src/core/CMakeLists.txt | 2 +- src/core/kdesktopfile.cpp | 2 ++ src/core/kdesktopfile.h | 9 +++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 6c242253..c91dd040 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -32,7 +32,7 @@ ecm_generate_export_header(KF5ConfigCore GROUP_BASE_NAME KF VERSION ${KF_VERSION} DEPRECATED_BASE_VERSION 0 - DEPRECATION_VERSIONS 4.0 5.0 5.24 5.42 5.82 + DEPRECATION_VERSIONS 4.0 5.0 5.24 5.42 5.82 5.89 EXCLUDE_DEPRECATED_BEFORE_AND_AT ${EXCLUDE_DEPRECATED_BEFORE_AND_AT} ) diff --git a/src/core/kdesktopfile.cpp b/src/core/kdesktopfile.cpp index d26ed59d..d2823c15 100644 --- a/src/core/kdesktopfile.cpp +++ b/src/core/kdesktopfile.cpp @@ -332,11 +332,13 @@ KDesktopFile *KDesktopFile::copyTo(const QString &file) const return config; } +#if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 89) QStandardPaths::StandardLocation KDesktopFile::resource() const { Q_D(const KDesktopFile); return d->resourceType; } +#endif QString KDesktopFile::fileName() const { diff --git a/src/core/kdesktopfile.h b/src/core/kdesktopfile.h index 5cd739f1..445d98f6 100644 --- a/src/core/kdesktopfile.h +++ b/src/core/kdesktopfile.h @@ -238,9 +238,18 @@ class KCONFIGCORE_EXPORT KDesktopFile : public KConfig */ KDesktopFile *copyTo(const QString &file) const; + /** + * Returns the name of the .desktop file that was used to construct this KDesktopFile. + */ QString fileName() const; +#if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(5, 89) + /** + * @deprecated Since 5.89, use locationType() instead. + */ + KCONFIGCORE_DEPRECATED_VERSION(5, 89, "Use locationType() instead.") QStandardPaths::StandardLocation resource() const; +#endif private: Q_DISABLE_COPY(KDesktopFile) From 973dfd484024f7248cff51ded0efc13e4d554f59 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sun, 28 Nov 2021 01:24:43 +0000 Subject: [PATCH 218/259] SVN_SILENT made messages (.desktop file) - always resolve ours In case of conflict in i18n, keep the version of the branch "ours" To resolve a particular conflict, "git checkout --ours path/to/file.desktop" --- src/core/kconfigbackend.desktop | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/kconfigbackend.desktop b/src/core/kconfigbackend.desktop index c3533986..e66e9105 100644 --- a/src/core/kconfigbackend.desktop +++ b/src/core/kconfigbackend.desktop @@ -34,7 +34,6 @@ Comment[he]=מנוע שמירה עבור KConfig Comment[hi]=के-कोन्फिग के लिए संचयन बैकएंड Comment[hne]=के-कानफिग बर भंडार बैकएण्ड Comment[hr]=Skladišna pozadina za KConfig -Comment[hsb]=składowanski backend za KConfig Comment[hu]=Tároló a KConfighoz Comment[hy]=Բահեստի հետևի մասը KConfig-ի համար Comment[ia]=Retro-administration de immagazinage (storage) pro Kconfig From 594e62461f2f3b22dffda7470124de32125b6ed6 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Mon, 29 Nov 2021 01:30:30 +0000 Subject: [PATCH 219/259] SVN_SILENT made messages (.desktop file) - always resolve ours In case of conflict in i18n, keep the version of the branch "ours" To resolve a particular conflict, "git checkout --ours path/to/file.desktop" --- src/core/kconfigbackend.desktop | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/kconfigbackend.desktop b/src/core/kconfigbackend.desktop index e66e9105..c3533986 100644 --- a/src/core/kconfigbackend.desktop +++ b/src/core/kconfigbackend.desktop @@ -34,6 +34,7 @@ Comment[he]=מנוע שמירה עבור KConfig Comment[hi]=के-कोन्फिग के लिए संचयन बैकएंड Comment[hne]=के-कानफिग बर भंडार बैकएण्ड Comment[hr]=Skladišna pozadina za KConfig +Comment[hsb]=składowanski backend za KConfig Comment[hu]=Tároló a KConfighoz Comment[hy]=Բահեստի հետևի մասը KConfig-ի համար Comment[ia]=Retro-administration de immagazinage (storage) pro Kconfig From 202b23cdbfba2bacd8dde7ffb5b8ca26274df58a Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Thu, 2 Dec 2021 07:14:53 +0100 Subject: [PATCH 220/259] GIT_SILENT: add missing licences --- LICENSES/CC0-1.0.txt | 121 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 LICENSES/CC0-1.0.txt diff --git a/LICENSES/CC0-1.0.txt b/LICENSES/CC0-1.0.txt new file mode 100644 index 00000000..0e259d42 --- /dev/null +++ b/LICENSES/CC0-1.0.txt @@ -0,0 +1,121 @@ +Creative Commons Legal Code + +CC0 1.0 Universal + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. From dcc6e03840d0c80068cd5e838c62f60a83abcc9d Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Mon, 29 Nov 2021 14:38:17 +0100 Subject: [PATCH 221/259] Fix KDesktopFileTest::testIsAuthorizedDesktopFile running on gitlab CI --- autotests/kdesktopfiletest.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/autotests/kdesktopfiletest.cpp b/autotests/kdesktopfiletest.cpp index b8235606..efbbb244 100644 --- a/autotests/kdesktopfiletest.cpp +++ b/autotests/kdesktopfiletest.cpp @@ -13,6 +13,10 @@ #include +#if defined(Q_OS_UNIX) +#include +#endif + QTEST_MAIN(KDesktopFileTest) void KDesktopFileTest::initTestCase() @@ -199,6 +203,24 @@ void KDesktopFileTest::testIsAuthorizedDesktopFile() "\n"; file.close(); QVERIFY(QFile::exists(fileName)); + +#if defined(Q_OS_UNIX) + // Try to fix test failing in docker running as root + const QFileInfo entryInfo(fileName); + if (entryInfo.ownerId() == 0) { + // try to find a valid user/group combination + for (int i = 1; i < 100; ++i) { + if (chown(fileName.toLocal8Bit().constData(), i, i) == 0) { + break; + } + } + const QFileInfo entryInfo1(fileName); + if (entryInfo1.ownerId() == 0) { + QEXPECT_FAIL("", "Running test as root and could not find a non root user to change the ownership of the file too", Continue); + } + } +#endif + QVERIFY(!KDesktopFile::isAuthorizedDesktopFile(fileName)); const QString installedFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("/kservices5/http_cache_cleaner.desktop")); From 19fac5ec66ce32a3c8c8caa0492b95b4bc7c6ab3 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 4 Dec 2021 16:57:08 +0000 Subject: [PATCH 222/259] GIT_SILENT Upgrade ECM and KF version requirements for 5.89.0 release. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 64e24647..bb9ccecb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ set(KF_VERSION "5.89.0") # handled by release scripts project(KConfig VERSION ${KF_VERSION}) include(FeatureSummary) -find_package(ECM 5.87.0 NO_MODULE) +find_package(ECM 5.89.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) From 574508b9b6496400388aec420c6abf3ef9911868 Mon Sep 17 00:00:00 2001 From: Jonathan Marten Date: Mon, 6 Dec 2021 11:33:59 +0000 Subject: [PATCH 223/259] Allow kreadconfig/kwriteconfig to access the root group The default group if "--group" is not specified is "KDE". Trying to specify a null group name causes an assert in KConfigGroup::groupImpl(). Explicitly detect and give an error message for a null group name. Mention in the help text that "" can be used to specify the root group - this string comes from KConfigGroupPrivate::name(). Add the missing parser.addHelpOption() for kreadconfig. Update the help strings. Apply clang-format changes. I18N: --- src/kreadconfig/kreadconfig.cpp | 20 ++++++++++++++++---- src/kreadconfig/kwriteconfig.cpp | 16 ++++++++++++---- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/kreadconfig/kreadconfig.cpp b/src/kreadconfig/kreadconfig.cpp index 01d44326..7e96a17a 100644 --- a/src/kreadconfig/kreadconfig.cpp +++ b/src/kreadconfig/kreadconfig.cpp @@ -41,12 +41,14 @@ int main(int argc, char **argv) QCoreApplication app(argc, argv); QCommandLineParser parser; + parser.addHelpOption(); parser.addOption( QCommandLineOption(QStringLiteral("file"), QCoreApplication::translate("main", "Use instead of global config"), QStringLiteral("file"))); - parser.addOption(QCommandLineOption(QStringLiteral("group"), - QCoreApplication::translate("main", "Group to look in. Use repeatedly for nested groups."), - QStringLiteral("group"), - QStringLiteral("KDE"))); + parser.addOption( + QCommandLineOption(QStringLiteral("group"), + QCoreApplication::translate("main", "Group to look in. Use \"\" for the root group, or use repeatedly for nested groups."), + QStringLiteral("group"), + QStringLiteral("KDE"))); parser.addOption(QCommandLineOption(QStringLiteral("key"), QCoreApplication::translate("main", "Key to look for"), QStringLiteral("key"))); parser.addOption(QCommandLineOption(QStringLiteral("default"), QCoreApplication::translate("main", "Default value"), QStringLiteral("value"))); parser.addOption(QCommandLineOption(QStringLiteral("type"), QCoreApplication::translate("main", "Type of variable"), QStringLiteral("type"))); @@ -75,6 +77,16 @@ int main(int argc, char **argv) } KConfigGroup cfgGroup = konfig->group(QString()); for (const QString &grp : groups) { + if (grp.isEmpty()) { + fprintf(stderr, + "%s: %s\n", + qPrintable(QCoreApplication::applicationName()), + qPrintable(QCoreApplication::translate("main", "Group name cannot be empty, use \"\" for the root group"))); + if (configMustDeleted) { + delete konfig; + } + return 2; + } cfgGroup = cfgGroup.group(grp); } diff --git a/src/kreadconfig/kwriteconfig.cpp b/src/kreadconfig/kwriteconfig.cpp index 20036331..af39325e 100644 --- a/src/kreadconfig/kwriteconfig.cpp +++ b/src/kreadconfig/kwriteconfig.cpp @@ -23,10 +23,11 @@ int main(int argc, char **argv) parser.addHelpOption(); parser.addOption( QCommandLineOption(QStringLiteral("file"), QCoreApplication::translate("main", "Use instead of global config"), QStringLiteral("file"))); - parser.addOption(QCommandLineOption(QStringLiteral("group"), - QCoreApplication::translate("main", "Group to look in. Use repeatedly for nested groups."), - QStringLiteral("group"), - QStringLiteral("KDE"))); + parser.addOption( + QCommandLineOption(QStringLiteral("group"), + QCoreApplication::translate("main", "Group to look in. Use \"\" for the root group, or use repeatedly for nested groups."), + QStringLiteral("group"), + QStringLiteral("KDE"))); parser.addOption(QCommandLineOption(QStringLiteral("key"), QCoreApplication::translate("main", "Key to look for"), QStringLiteral("key"))); parser.addOption( QCommandLineOption(QStringLiteral("type"), @@ -61,6 +62,13 @@ int main(int argc, char **argv) KConfigGroup cfgGroup = konfig->group(QString()); for (const QString &grp : groups) { + if (grp.isEmpty()) { + fprintf(stderr, + "%s: %s\n", + qPrintable(QCoreApplication::applicationName()), + qPrintable(QCoreApplication::translate("main", "Group name cannot be empty, use \"\" for the root group"))); + return 2; + } cfgGroup = cfgGroup.group(grp); } From 9c81af25b184476e3945073415c0844d09a9e696 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Mon, 13 Dec 2021 11:36:44 +0000 Subject: [PATCH 224/259] GIT_SILENT Upgrade KF version to 5.90.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb9ccecb..9fe55a63 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.16) -set(KF_VERSION "5.89.0") # handled by release scripts +set(KF_VERSION "5.90.0") # handled by release scripts project(KConfig VERSION ${KF_VERSION}) include(FeatureSummary) From eeefdf8aeabd875829ae6beee0e301a88c7da7c8 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Wed, 15 Dec 2021 01:48:33 +0000 Subject: [PATCH 225/259] SVN_SILENT made messages (.desktop file) - always resolve ours In case of conflict in i18n, keep the version of the branch "ours" To resolve a particular conflict, "git checkout --ours path/to/file.desktop" --- src/core/kconfigbackend.desktop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/kconfigbackend.desktop b/src/core/kconfigbackend.desktop index c3533986..e8dbb6f0 100644 --- a/src/core/kconfigbackend.desktop +++ b/src/core/kconfigbackend.desktop @@ -12,7 +12,7 @@ Comment[bn]=KConfig-এর স্টোরেজ ব্যাকেন্ড Comment[bn_IN]=KConfig-র জন্য ব্যবহৃত ব্যাক-এন্ড সংগ্রহস্থল Comment[bs]=Skladišna pozadina za K‑konfig Comment[ca]=Dorsal de l'emmagatzematge per al KConfig -Comment[ca@valencia]=Dorsal d'emmagatzematge pel KConfig +Comment[ca@valencia]=Dorsal de l'emmagatzematge per al KConfig Comment[cs]=Úložiště pro KConfig Comment[csb]=Zôpisownô zbiérnica dlô KConfig Comment[da]=Lagringsmotor til KConfig From bdb7f8bbd2d283fa87386a0fa2a505cb93b4a35c Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Sat, 30 Oct 2021 10:49:59 +0200 Subject: [PATCH 226/259] Minor code clean up NO_CHANGELOG --- src/core/kdesktopfile.cpp | 70 ++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/src/core/kdesktopfile.cpp b/src/core/kdesktopfile.cpp index d2823c15..644646df 100644 --- a/src/core/kdesktopfile.cpp +++ b/src/core/kdesktopfile.cpp @@ -68,31 +68,31 @@ KConfigGroup KDesktopFile::desktopGroup() const QString KDesktopFile::locateLocal(const QString &path) { - QString relativePath; - QChar plus(QLatin1Char('/')); + static const QLatin1Char slash('/'); + // Relative to config? (e.g. for autostart) - const QStringList lstGenericConfigLocation = QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation); + const QStringList genericConfig = QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation); // Iterate from the last item since some items may be subfolders of others. - for (QStringList::const_reverse_iterator constIterator = lstGenericConfigLocation.crbegin(); constIterator != lstGenericConfigLocation.crend(); - ++constIterator) { - const QString &dir = (*constIterator); - if (path.startsWith(dir + plus)) { - relativePath = path.mid(dir.length() + 1); - return QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1Char('/') + relativePath; - } + auto it = std::find_if(genericConfig.crbegin(), genericConfig.crend(), [&path](const QString &dir) { + return path.startsWith(dir + slash); + }); + if (it != genericConfig.crend()) { + return QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + slash + QStringView(path).mid(it->size() + 1); } + + QString relativePath; // Relative to xdg data dir? (much more common) const QStringList lstGenericDataLocation = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); for (const QString &dir : lstGenericDataLocation) { - if (path.startsWith(dir + plus)) { + if (path.startsWith(dir + slash)) { relativePath = path.mid(dir.length() + 1); } } if (relativePath.isEmpty()) { // What now? The desktop file doesn't come from XDG_DATA_DIRS. Use filename only and hope for the best. - relativePath = path.mid(path.lastIndexOf(QLatin1Char('/')) + 1); + relativePath = path.mid(path.lastIndexOf(slash) + 1); } - return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + relativePath; + return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + slash + relativePath; } bool KDesktopFile::isDesktopFile(const QString &path) @@ -123,30 +123,40 @@ bool KDesktopFile::isAuthorizedDesktopFile(const QString &path) // Check if the .desktop file is installed as part of KDE or XDG. const QStringList appsDirs = QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation); - for (const QString &prefix : appsDirs) { - if (QDir(prefix).exists() && realPath.startsWith(QFileInfo(prefix).canonicalFilePath(), sensitivity)) { - return true; - } + auto it = std::find_if(appsDirs.cbegin(), appsDirs.cend(), [&realPath](const QString &prefix) { + QFileInfo info(prefix); + return info.exists() && info.isDir() && realPath.startsWith(info.canonicalFilePath(), sensitivity); + }); + if (it != appsDirs.cend()) { + return true; } + const QString servicesDir = QStringLiteral("kservices5/"); // KGlobal::dirs()->xdgDataRelativePath("services") - const QStringList lstGenericDataLocation = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); - for (const QString &xdgDataPrefix : lstGenericDataLocation) { - if (QDir(xdgDataPrefix).exists()) { - const QString prefix = QFileInfo(xdgDataPrefix).canonicalFilePath(); - if (realPath.startsWith(prefix + QLatin1Char('/') + servicesDir, sensitivity)) { - return true; - } + const QStringList genericData = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); + auto genericIt = std::find_if(genericData.cbegin(), genericData.cend(), [&realPath, &servicesDir](const QString &xdgDataPrefix) { + QFileInfo info(xdgDataPrefix); + if (info.exists() && info.isDir()) { + const QString prefix = info.canonicalFilePath(); + return realPath.startsWith(prefix + QLatin1Char('/') + servicesDir, sensitivity); } + return false; + }); + if (genericIt != genericData.cend()) { + return true; } + const QString autostartDir = QStringLiteral("autostart/"); const QStringList lstConfigPath = QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation); - for (const QString &xdgDataPrefix : lstConfigPath) { - if (QDir(xdgDataPrefix).exists()) { - const QString prefix = QFileInfo(xdgDataPrefix).canonicalFilePath(); - if (realPath.startsWith(prefix + QLatin1Char('/') + autostartDir, sensitivity)) { - return true; - } + auto configIt = std::find_if(lstConfigPath.cbegin(), lstConfigPath.cend(), [&realPath, &autostartDir](const QString &xdgDataPrefix) { + QFileInfo info(xdgDataPrefix); + if (info.exists() && info.isDir()) { + const QString prefix = info.canonicalFilePath(); + return realPath.startsWith(prefix + QLatin1Char('/') + autostartDir, sensitivity); } + return false; + }); + if (configIt != lstConfigPath.cend()) { + return true; } // Forbid desktop files outside of standard locations if kiosk is set so From 10c4a4b4bdfdd468e52ae0fbbf84c77b64df2f8f Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Fri, 3 Dec 2021 22:33:28 +0200 Subject: [PATCH 227/259] WIP: Change the build system to enable building with Qt 6 This was built with: -DQT_MAJOR_VERSION=6 \ -DEXCLUDE_DEPRECATED_BEFORE_AND_AT=5.90.0 \ -DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x055a00 Move the include(KDEInstallDirs) call before the first find_package(Qt*, the former is what auto-detects the Qt version, and defaults to 5. This is needed to be able to build against Qt5 by default. All unit tests still pass. --- CMakeLists.txt | 39 +++++++++++------------ KF5ConfigConfig.cmake.in | 4 +-- KF5ConfigMacros.cmake | 2 +- autotests/CMakeLists.txt | 22 ++++++------- autotests/kconfig_compiler/CMakeLists.txt | 6 ++-- autotests/kconfigtest.cpp | 26 +++++++++++---- src/CMakeLists.txt | 4 +-- src/core/CMakeLists.txt | 10 +++--- src/gui/CMakeLists.txt | 8 ++--- src/kconf_update/CMakeLists.txt | 2 +- src/kconfig_compiler/CMakeLists.txt | 2 +- src/qml/CMakeLists.txt | 6 ++-- 12 files changed, 71 insertions(+), 60 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fe55a63..d880c52a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,25 +10,6 @@ feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKA set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) -set(REQUIRED_QT_VERSION 5.15.2) - -find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Xml) -option(KCONFIG_USE_GUI "Build components using Qt5Gui" ON) -if(KCONFIG_USE_GUI) - find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Gui) -endif() -find_package(Qt5 ${REQUIRED_QT_VERSION} OPTIONAL_COMPONENTS Qml) - -if (NOT ANDROID) - option(KCONFIG_USE_DBUS "Build components using Qt5DBus" ON) - if(KCONFIG_USE_DBUS) - find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED DBus) - endif() -else() - set(KCONFIG_USE_DBUS Off) -endif() - - include(KDEInstallDirs) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(KDECMakeSettings) @@ -42,6 +23,24 @@ include(ECMPoQmTools) include(ECMAddQch) include(ECMQtDeclareLoggingCategory) +set(REQUIRED_QT_VERSION 5.15.2) + +find_package(Qt${QT_MAJOR_VERSION} ${REQUIRED_QT_VERSION} CONFIG REQUIRED Xml) +option(KCONFIG_USE_GUI "Build components using Qt${QT_MAJOR_VERSION}Gui" ON) +if(KCONFIG_USE_GUI) + find_package(Qt${QT_MAJOR_VERSION} ${REQUIRED_QT_VERSION} CONFIG REQUIRED Gui) +endif() +find_package(Qt${QT_MAJOR_VERSION} ${REQUIRED_QT_VERSION} OPTIONAL_COMPONENTS Qml) + +if (NOT ANDROID) + option(KCONFIG_USE_DBUS "Build components using Qt${QT_MAJOR_VERSION}DBus" ON) + if(KCONFIG_USE_DBUS) + find_package(Qt${QT_MAJOR_VERSION} ${REQUIRED_QT_VERSION} CONFIG REQUIRED DBus) + endif() +else() + set(KCONFIG_USE_DBUS Off) +endif() + set(EXCLUDE_DEPRECATED_BEFORE_AND_AT 0 CACHE STRING "Control the range of deprecated API excluded from the build [default=0].") option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" OFF) @@ -98,7 +97,7 @@ install(EXPORT KF5ConfigCompilerTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5ConfigCompilerTargets.cmake NAMESPACE KF5:: COMPONENT Devel) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kconfig_version.h - DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5} COMPONENT Devel ) + DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF} COMPONENT Devel ) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/KF5ConfigConfig.cmake.in b/KF5ConfigConfig.cmake.in index d24ae2ba..9b696ceb 100644 --- a/KF5ConfigConfig.cmake.in +++ b/KF5ConfigConfig.cmake.in @@ -6,10 +6,10 @@ include("${CMAKE_CURRENT_LIST_DIR}/KF5ConfigTargets.cmake") @PACKAGE_INCLUDE_QCHTARGETS@ include(CMakeFindDependencyMacro) -find_dependency(Qt5Xml "@REQUIRED_QT_VERSION@") +find_dependency(Qt@QT_MAJOR_VERSION@Xml @REQUIRED_QT_VERSION@) if(@KCONFIG_USE_DBUS@) - find_dependency(Qt5DBus "@REQUIRED_QT_VERSION@") + find_dependency(Qt@QT_MAJOR_VERSION@DBus "@REQUIRED_QT_VERSION@") endif() if(CMAKE_CROSSCOMPILING AND KF5_HOST_TOOLING) diff --git a/KF5ConfigMacros.cmake b/KF5ConfigMacros.cmake index 3ceaf17c..80c947d8 100644 --- a/KF5ConfigMacros.cmake +++ b/KF5ConfigMacros.cmake @@ -111,7 +111,7 @@ function (KCONFIG_ADD_KCFG_FILES _target_or_source_var) if(ARG_GENERATE_MOC) list(APPEND sources ${_moc_FILE}) - qt5_generate_moc(${_header_FILE} ${_moc_FILE}) + qt_generate_moc(${_header_FILE} ${_moc_FILE}) set_property(SOURCE ${_src_FILE} APPEND PROPERTY OBJECT_DEPENDS ${_moc_FILE} ) endif() diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt index cae4c0b1..a7e37e5a 100644 --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -1,14 +1,14 @@ include(ECMAddTests) -find_package(Qt5Test ${REQUIRED_QT_VERSION} CONFIG QUIET) -find_package(Qt5Concurrent ${REQUIRED_QT_VERSION} CONFIG QUIET) +find_package(Qt${QT_MAJOR_VERSION}Test ${REQUIRED_QT_VERSION} CONFIG QUIET) +find_package(Qt${QT_MAJOR_VERSION}Concurrent ${REQUIRED_QT_VERSION} CONFIG QUIET) -if(NOT Qt5Test_FOUND) +if(NOT Qt${QT_MAJOR_VERSION}Test_FOUND) message(STATUS "Qt5Test not found, autotests will not be built.") return() endif() -if(NOT Qt5Concurrent_FOUND) +if(NOT Qt${QT_MAJOR_VERSION}Concurrent_FOUND) message(STATUS "Qt5Concurrent not found, autotests will not be built.") return() endif() @@ -18,7 +18,7 @@ ecm_add_test( kentrymaptest.cpp ../src/core/kconfigdata.cpp TEST_NAME kentrymaptest - LINK_LIBRARIES Qt5::Test + LINK_LIBRARIES Qt${QT_MAJOR_VERSION}::Test ) target_include_directories(kentrymaptest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../src/core) @@ -27,17 +27,17 @@ ecm_add_test( test_kconfigutils.cpp ../src/kconf_update/kconfigutils.cpp TEST_NAME test_kconfigutils - LINK_LIBRARIES KF5::ConfigCore Qt5::Test + LINK_LIBRARIES KF5::ConfigCore Qt${QT_MAJOR_VERSION}::Test ) target_include_directories(test_kconfigutils PRIVATE ../src/kconf_update) qt_add_resources(sharedconfigresources sharedconfigresources.qrc) -ecm_add_test(ksharedconfigtest.cpp ${sharedconfigresources} TEST_NAME kconfigcore-ksharedconfigtest LINK_LIBRARIES KF5::ConfigCore Qt5::Test Qt5::Concurrent) +ecm_add_test(ksharedconfigtest.cpp ${sharedconfigresources} TEST_NAME kconfigcore-ksharedconfigtest LINK_LIBRARIES KF5::ConfigCore Qt${QT_MAJOR_VERSION}::Test Qt${QT_MAJOR_VERSION}::Concurrent) # test for fallback to :/kconfig/xxxx config resource qt_add_resources(fallbackconfigresources fallbackconfigresources.qrc) -ecm_add_test(fallbackconfigresourcestest.cpp ${fallbackconfigresources} TEST_NAME kconfigcore-fallbackconfigresourcestest LINK_LIBRARIES KF5::ConfigCore Qt5::Test Qt5::Concurrent) +ecm_add_test(fallbackconfigresourcestest.cpp ${fallbackconfigresources} TEST_NAME kconfigcore-fallbackconfigresourcestest LINK_LIBRARIES KF5::ConfigCore Qt${QT_MAJOR_VERSION}::Test Qt${QT_MAJOR_VERSION}::Concurrent) ecm_add_tests( kconfignokdehometest.cpp @@ -46,19 +46,19 @@ ecm_add_tests( test_kconf_update.cpp ksharedconfig_in_global_object.cpp NAME_PREFIX kconfigcore- - LINK_LIBRARIES KF5::ConfigCore Qt5::Test Qt5::Concurrent + LINK_LIBRARIES KF5::ConfigCore Qt${QT_MAJOR_VERSION}::Test Qt${QT_MAJOR_VERSION}::Concurrent ) target_include_directories(test_kconf_update PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/../src/kconf_update) -if(TARGET Qt5::Gui) +if(TARGET Qt${QT_MAJOR_VERSION}::Gui) ecm_add_tests( kconfigguitest.cpp kconfigloadertest.cpp kconfigskeletontest.cpp kstandardshortcuttest.cpp NAME_PREFIX kconfiggui- - LINK_LIBRARIES KF5::ConfigGui Qt5::Test + LINK_LIBRARIES KF5::ConfigGui Qt${QT_MAJOR_VERSION}::Test ) # These tests do a global cleanup of ~/.qttest, so they can't run in parallel diff --git a/autotests/kconfig_compiler/CMakeLists.txt b/autotests/kconfig_compiler/CMakeLists.txt index 4caa17af..5cbf2e44 100644 --- a/autotests/kconfig_compiler/CMakeLists.txt +++ b/autotests/kconfig_compiler/CMakeLists.txt @@ -177,7 +177,7 @@ set(test_state_config_SRCS test_state_config_main.cpp) gen_kcfg_test_source(test_state_config test_state_config_SRCS GENERATE_MOC) ecm_add_test(TEST_NAME test_state_config ${test_state_config_SRCS}) -target_link_libraries(test_state_config KF5::ConfigGui Qt5::Test) +target_link_libraries(test_state_config KF5::ConfigGui Qt${QT_MAJOR_VERSION}::Test) ########### next target ############### @@ -234,7 +234,7 @@ gen_kcfg_test_source(signals_test_no_singleton_dpointer kconfigcompiler_test_sig ecm_add_test(${kconfigcompiler_test_signals_SRCS} TEST_NAME kconfigcompiler-signals-test - LINK_LIBRARIES Qt5::Test KF5::ConfigGui + LINK_LIBRARIES Qt${QT_MAJOR_VERSION}::Test KF5::ConfigGui ) ########### next target ############### @@ -261,7 +261,7 @@ ecm_add_test(${test_param_minmax_SRCS} ecm_add_test(kconfigcompiler_test.cpp TEST_NAME kconfigcompiler-basic-test - LINK_LIBRARIES Qt5::Test + LINK_LIBRARIES Qt${QT_MAJOR_VERSION}::Test ) diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index 4657ea8d..95a87584 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -1974,18 +1974,30 @@ void KConfigTest::testXdgListEntry() void KConfigTest::testThreads() { QThreadPool::globalInstance()->setMaxThreadCount(6); - QList> futures; // Run in parallel some tests that work on different config files, // otherwise unexpected things might indeed happen. - futures << QtConcurrent::run(this, &KConfigTest::testAddConfigSources); - futures << QtConcurrent::run(this, &KConfigTest::testSimple); - futures << QtConcurrent::run(this, &KConfigTest::testDefaults); - futures << QtConcurrent::run(this, &KConfigTest::testSharedConfig); - futures << QtConcurrent::run(this, &KConfigTest::testSharedConfig); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + const QList> futures = { + QtConcurrent::run(&KConfigTest::testAddConfigSources, this), + QtConcurrent::run(&KConfigTest::testSimple, this), + QtConcurrent::run(&KConfigTest::testDefaults, this), + QtConcurrent::run(&KConfigTest::testSharedConfig, this), + QtConcurrent::run(&KConfigTest::testSharedConfig, this), + }; +#else + const QList> futures = { + QtConcurrent::run(this, &KConfigTest::testAddConfigSources), + QtConcurrent::run(this, &KConfigTest::testSimple), + QtConcurrent::run(this, &KConfigTest::testDefaults), + QtConcurrent::run(this, &KConfigTest::testSharedConfig), + QtConcurrent::run(this, &KConfigTest::testSharedConfig), + }; +#endif + // QEXPECT_FAIL triggers race conditions, it should be fixed to use QThreadStorage... // futures << QtConcurrent::run(this, &KConfigTest::testDeleteWhenLocalized); // futures << QtConcurrent::run(this, &KConfigTest::testEntryMap); - for (QFuture f : std::as_const(futures)) { + for (QFuture f : futures) { f.waitForFinished(); } } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 89fe7284..715890e0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,8 +1,8 @@ add_subdirectory(core) -if(TARGET Qt5::Gui) +if(TARGET Qt${QT_MAJOR_VERSION}::Gui) add_subdirectory(gui) endif() -if(TARGET Qt5::Qml) +if(TARGET Qt${QT_MAJOR_VERSION}::Qml) add_subdirectory(qml) endif() add_subdirectory(kconfig_compiler) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index c91dd040..2b5e949c 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -41,12 +41,12 @@ target_compile_definitions(KF5ConfigCore KCONF_UPDATE_INSTALL_LOCATION="${KDE_INSTALL_FULL_LIBEXECDIR_KF5}/$" ) -target_include_directories(KF5ConfigCore INTERFACE "$") +target_include_directories(KF5ConfigCore INTERFACE "$") -target_link_libraries(KF5ConfigCore PUBLIC Qt5::Core) +target_link_libraries(KF5ConfigCore PUBLIC Qt${QT_MAJOR_VERSION}::Core) if(KCONFIG_USE_DBUS) - target_link_libraries(KF5ConfigCore PRIVATE Qt5::DBus) + target_link_libraries(KF5ConfigCore PRIVATE Qt${QT_MAJOR_VERSION}::DBus) endif() set_target_properties(KF5ConfigCore PROPERTIES VERSION ${KCONFIG_VERSION} @@ -98,7 +98,7 @@ install(TARGETS KF5ConfigCore EXPORT KF5ConfigTargets ${KF5_INSTALL_TARGETS_DEFA install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kconfigcore_export.h ${KConfigCore_HEADERS} - DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/KConfigCore COMPONENT Devel + DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF}/KConfigCore COMPONENT Devel ) # make available to ecm_add_qch in parent folder @@ -106,5 +106,5 @@ set(KConfigCore_APIDOX_SRCS ${KConfigCore_HEADERS} PARENT_SCOPE) set(KConfigCore_APIDOX_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE) include(ECMGeneratePriFile) -ecm_generate_pri_file(BASE_NAME KConfigCore LIB_NAME KF5ConfigCore DEPS "core" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF5}/KConfigCore) +ecm_generate_pri_file(BASE_NAME KConfigCore LIB_NAME KF5ConfigCore DEPS "core" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF}/KConfigCore) install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 9dad629a..4d5512d1 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -21,9 +21,9 @@ ecm_generate_export_header(KF5ConfigGui EXCLUDE_DEPRECATED_BEFORE_AND_AT ${EXCLUDE_DEPRECATED_BEFORE_AND_AT} ) -target_include_directories(KF5ConfigGui INTERFACE "$") +target_include_directories(KF5ConfigGui INTERFACE "$") -target_link_libraries(KF5ConfigGui PUBLIC Qt5::Gui Qt5::Xml KF5::ConfigCore) +target_link_libraries(KF5ConfigGui PUBLIC Qt${QT_MAJOR_VERSION}::Gui Qt${QT_MAJOR_VERSION}::Xml KF5::ConfigCore) set_target_properties(KF5ConfigGui PROPERTIES VERSION ${KCONFIG_VERSION} SOVERSION ${KCONFIG_SOVERSION} @@ -68,7 +68,7 @@ install(TARGETS KF5ConfigGui EXPORT KF5ConfigTargets ${KF5_INSTALL_TARGETS_DEFAU install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kconfiggui_export.h ${KConfigGui_HEADERS} - DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/KConfigGui COMPONENT Devel + DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF}/KConfigGui COMPONENT Devel ) # make available to ecm_add_qch in parent folder @@ -76,5 +76,5 @@ set(KConfigGui_APIDOX_SRCS ${KConfigGui_HEADERS} PARENT_SCOPE) set(KConfigGui_APIDOX_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE) include(ECMGeneratePriFile) -ecm_generate_pri_file(BASE_NAME KConfigGui LIB_NAME KF5ConfigGui DEPS "gui xml KConfigCore" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF5}/KConfigGui) +ecm_generate_pri_file(BASE_NAME KConfigGui LIB_NAME KF5ConfigGui DEPS "gui xml KConfigCore" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF}/KConfigGui) install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) diff --git a/src/kconf_update/CMakeLists.txt b/src/kconf_update/CMakeLists.txt index 40fb4ccb..8c23b358 100644 --- a/src/kconf_update/CMakeLists.txt +++ b/src/kconf_update/CMakeLists.txt @@ -15,7 +15,7 @@ ecm_qt_declare_logging_category(kconf_update EXPORT KCONFIG ) -target_link_libraries(kconf_update Qt5::Core KF5::ConfigCore) +target_link_libraries(kconf_update Qt${QT_MAJOR_VERSION}::Core KF5::ConfigCore) include(ECMMarkNonGuiExecutable) ecm_mark_nongui_executable(kconf_update) diff --git a/src/kconfig_compiler/CMakeLists.txt b/src/kconfig_compiler/CMakeLists.txt index 0e11ee58..a475b511 100644 --- a/src/kconfig_compiler/CMakeLists.txt +++ b/src/kconfig_compiler/CMakeLists.txt @@ -21,7 +21,7 @@ set_target_properties(kconfig_compiler PROPERTIES OUTPUT_NAME "kconfig_compiler_kf5" ) -target_link_libraries(kconfig_compiler Qt5::Xml) +target_link_libraries(kconfig_compiler Qt${QT_MAJOR_VERSION}::Xml) ecm_mark_nongui_executable(kconfig_compiler) diff --git a/src/qml/CMakeLists.txt b/src/qml/CMakeLists.txt index 1cdae88a..17f90ad0 100644 --- a/src/qml/CMakeLists.txt +++ b/src/qml/CMakeLists.txt @@ -16,7 +16,7 @@ ecm_generate_export_header(KF5ConfigQml target_link_libraries(KF5ConfigQml PUBLIC KF5::ConfigCore # KCoreConfigSkeleton, in ConfigPropertyMap - Qt5::Qml + Qt${QT_MAJOR_VERSION}::Qml ) set_target_properties(KF5ConfigQml PROPERTIES VERSION ${KCONFIG_VERSION} SOVERSION ${KCONFIG_SOVERSION} @@ -29,11 +29,11 @@ ecm_generate_headers(KConfigQml_HEADERS REQUIRED_HEADERS KConfigQml_HEADERS ) -target_include_directories(KF5ConfigQml INTERFACE "$") +target_include_directories(KF5ConfigQml INTERFACE "$") install(TARGETS KF5ConfigQml EXPORT KF5ConfigTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kconfigqml_export.h ${KConfigQml_HEADERS} - DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/KConfigQml COMPONENT Devel + DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF}/KConfigQml COMPONENT Devel ) From 428261e2932e9413b1ed5322848e8df067f59ee1 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Fri, 17 Dec 2021 18:03:40 +0200 Subject: [PATCH 228/259] Fix build on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both GCC and Clang don't require a const integral value to be captured explicitly to be used in a lambda, but of course one compiler thinks otherwise... Thanks to Ömer Fadıl Usta for the heads up. GIT_SILENT --- src/core/kdesktopfile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/kdesktopfile.cpp b/src/core/kdesktopfile.cpp index 644646df..aa510dec 100644 --- a/src/core/kdesktopfile.cpp +++ b/src/core/kdesktopfile.cpp @@ -123,7 +123,7 @@ bool KDesktopFile::isAuthorizedDesktopFile(const QString &path) // Check if the .desktop file is installed as part of KDE or XDG. const QStringList appsDirs = QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation); - auto it = std::find_if(appsDirs.cbegin(), appsDirs.cend(), [&realPath](const QString &prefix) { + auto it = std::find_if(appsDirs.cbegin(), appsDirs.cend(), [&realPath, sensitivity](const QString &prefix) { QFileInfo info(prefix); return info.exists() && info.isDir() && realPath.startsWith(info.canonicalFilePath(), sensitivity); }); From eac8e43e25717fcef579a25bd40d777fc5556255 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Sat, 18 Dec 2021 20:51:03 +0200 Subject: [PATCH 229/259] Complete fixing the Windows CI --- src/core/kdesktopfile.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/kdesktopfile.cpp b/src/core/kdesktopfile.cpp index aa510dec..95645a63 100644 --- a/src/core/kdesktopfile.cpp +++ b/src/core/kdesktopfile.cpp @@ -133,7 +133,7 @@ bool KDesktopFile::isAuthorizedDesktopFile(const QString &path) const QString servicesDir = QStringLiteral("kservices5/"); // KGlobal::dirs()->xdgDataRelativePath("services") const QStringList genericData = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); - auto genericIt = std::find_if(genericData.cbegin(), genericData.cend(), [&realPath, &servicesDir](const QString &xdgDataPrefix) { + auto genericIt = std::find_if(genericData.cbegin(), genericData.cend(), [&realPath, &servicesDir, sensitivity](const QString &xdgDataPrefix) { QFileInfo info(xdgDataPrefix); if (info.exists() && info.isDir()) { const QString prefix = info.canonicalFilePath(); @@ -147,7 +147,7 @@ bool KDesktopFile::isAuthorizedDesktopFile(const QString &path) const QString autostartDir = QStringLiteral("autostart/"); const QStringList lstConfigPath = QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation); - auto configIt = std::find_if(lstConfigPath.cbegin(), lstConfigPath.cend(), [&realPath, &autostartDir](const QString &xdgDataPrefix) { + auto configIt = std::find_if(lstConfigPath.cbegin(), lstConfigPath.cend(), [&realPath, &autostartDir, sensitivity](const QString &xdgDataPrefix) { QFileInfo info(xdgDataPrefix); if (info.exists() && info.isDir()) { const QString prefix = info.canonicalFilePath(); From c5ce7c4328706018fb9b695eb5c8959aaafa4bc4 Mon Sep 17 00:00:00 2001 From: Allen Winter Date: Mon, 27 Dec 2021 10:20:12 -0500 Subject: [PATCH 230/259] kconfig_compiler/CMakeLists.txt - use CMAKE_CROSSCOMPILING use the CMake variable CMAKE_CROSSCOMPILING to detect when cross-compiling instead of CMAKE_TOOLCHAIN_FILE. CMAKE_TOOLCHAIN_FILE can be set when not cross-compiling --- src/kconfig_compiler/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kconfig_compiler/CMakeLists.txt b/src/kconfig_compiler/CMakeLists.txt index a475b511..44018401 100644 --- a/src/kconfig_compiler/CMakeLists.txt +++ b/src/kconfig_compiler/CMakeLists.txt @@ -1,6 +1,6 @@ add_executable(kconfig_compiler) -if(CMAKE_TOOLCHAIN_FILE) +if(CMAKE_CROSSCOMPILING) if(BUILD_TESTING) message(WARNING "Testing should be disabled on cross-compilation") endif() From 43e096a8838a36e6adad9d265f77170641fbfef6 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 1 Jan 2022 12:12:28 +0000 Subject: [PATCH 231/259] GIT_SILENT Upgrade ECM and KF version requirements for 5.90.0 release. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d880c52a..ba942f8a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ set(KF_VERSION "5.90.0") # handled by release scripts project(KConfig VERSION ${KF_VERSION}) include(FeatureSummary) -find_package(ECM 5.89.0 NO_MODULE) +find_package(ECM 5.90.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) From c0ad1374408c9acea8a4de6fd7d68563dcc89b2e Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Fri, 24 Dec 2021 15:25:10 +0200 Subject: [PATCH 232/259] groupList: don't copy unnecessarily; add const --- src/core/kconfig.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index 03ab67d3..ed45d1dd 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -280,7 +280,7 @@ QStringList KConfig::groupList() const for (auto entryMapIt = d->entryMap.cbegin(); entryMapIt != d->entryMap.cend(); ++entryMapIt) { const KEntryKey &key = entryMapIt.key(); - const QByteArray group = key.mGroup; + const QByteArray &group = key.mGroup; if (key.mKey.isNull() && !group.isEmpty() && group != "" && group != "$Version") { const QString groupname = QString::fromUtf8(group); groups << groupname.left(groupname.indexOf(QLatin1Char('\x1d'))); @@ -292,7 +292,7 @@ QStringList KConfig::groupList() const QStringList KConfigPrivate::groupList(const QByteArray &group) const { - QByteArray theGroup = group + '\x1d'; + const QByteArray theGroup = group + '\x1d'; QSet groups; for (auto entryMapIt = entryMap.cbegin(); entryMapIt != entryMap.cend(); ++entryMapIt) { From 295ea7632ac7cc2cc3eda79b7af8614d5ff95a41 Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Fri, 24 Dec 2021 13:22:35 +0200 Subject: [PATCH 233/259] Exclude deleted groups from groupList() This commit is an alternative to the earlier incorrect and reverted b3dc879e8b108c26c929bfbe551bcdf77f140e94. That commit contained several mistakes and an algorithmic complexity increase: 1) the added conditions were inverted: should have been `hasNonDeletedEntries` (without `!`); 2) KConfigPrivate::groupList() passed group instead of key.mGroup to hasNonDeletedEntries(); 3) The complexity of hasNonDeletedEntries() is O(entryMap.size()). Calls to this function were added into loops that iterated entryMap.size() times. So the overall complexity of groupList() increased from linear to quadratic. This fix collects `mGroup`s of non-deleted key entries instead of `mGroup`s of group entries. The number of key entries can be much greater than the number of group entries, so this fix hurts performance. But at least the algorithmic complexity of groupList() stays linear. Future commits can optimize the loops and make them almost as fast or even faster than before this fix. The `!key.mKey.isNull() && !entryMapIt->bDeleted` checks added in this commit are consistent with the check in KConfigPrivate::hasNonDeletedEntries(). KConfig::hasGroupImpl() forwards its argument to hasNonDeletedEntries() with the following comment: // No need to look for the actual group entry anymore, or for subgroups: // a group exists if it contains any non-deleted entry. BUG: 384039 FIXED-IN: 5.90 --- autotests/kconfigtest.cpp | 8 +++++++- src/core/kconfig.cpp | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index 95a87584..77d0ddde 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -806,19 +806,25 @@ void KConfigTest::testDelete() KConfigGroup delgr(&ct, "Nested Group 3"); QVERIFY(delgr.exists()); QVERIFY(ct.hasGroup("Nested Group 3")); + QVERIFY(ct.groupList().contains(QStringLiteral("Nested Group 3"))); delgr.deleteGroup(); QVERIFY(!delgr.exists()); QVERIFY(!ct.hasGroup("Nested Group 3")); - QVERIFY(ct.groupList().contains(QStringLiteral("Nested Group 3"))); + QVERIFY(!ct.groupList().contains(QStringLiteral("Nested Group 3"))); KConfigGroup ng(&ct, "Nested Group 2"); QVERIFY(sc.hasGroup("Complex Types")); + QVERIFY(sc.groupList().contains(QStringLiteral("Complex Types"))); QVERIFY(!sc.hasGroup("Does not exist")); + QVERIFY(ct.hasGroup("Nested Group 1")); + QVERIFY(ct.groupList().contains(QStringLiteral("Nested Group 1"))); sc.deleteGroup("Complex Types"); QCOMPARE(sc.group("Complex Types").keyList().count(), 0); QVERIFY(!sc.hasGroup("Complex Types")); // #192266 QVERIFY(!sc.group("Complex Types").exists()); + QVERIFY(!sc.groupList().contains(QStringLiteral("Complex Types"))); QVERIFY(!ct.hasGroup("Nested Group 1")); + QVERIFY(!ct.groupList().contains(QStringLiteral("Nested Group 1"))); QCOMPARE(ct.group("Nested Group 1").keyList().count(), 0); QCOMPARE(ct.group("Nested Group 2").keyList().count(), 0); diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index ed45d1dd..0b890132 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -281,7 +281,7 @@ QStringList KConfig::groupList() const for (auto entryMapIt = d->entryMap.cbegin(); entryMapIt != d->entryMap.cend(); ++entryMapIt) { const KEntryKey &key = entryMapIt.key(); const QByteArray &group = key.mGroup; - if (key.mKey.isNull() && !group.isEmpty() && group != "" && group != "$Version") { + if (!key.mKey.isNull() && !entryMapIt->bDeleted && !group.isEmpty() && group != "" && group != "$Version") { const QString groupname = QString::fromUtf8(group); groups << groupname.left(groupname.indexOf(QLatin1Char('\x1d'))); } @@ -297,7 +297,7 @@ QStringList KConfigPrivate::groupList(const QByteArray &group) const for (auto entryMapIt = entryMap.cbegin(); entryMapIt != entryMap.cend(); ++entryMapIt) { const KEntryKey &key = entryMapIt.key(); - if (key.mKey.isNull() && key.mGroup.startsWith(theGroup)) { + if (!key.mKey.isNull() && !entryMapIt->bDeleted && key.mGroup.startsWith(theGroup)) { const QString groupname = QString::fromUtf8(key.mGroup.mid(theGroup.length())); groups << groupname.left(groupname.indexOf(QLatin1Char('\x1d'))); } From af6b3a375d99ce5ec5ecf5a30c6bc2b1b9db6102 Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Sat, 25 Dec 2021 08:41:02 +0200 Subject: [PATCH 234/259] groupList: convert each group name from UTF-8 once Usually multiple key entries belong to each group. Before this commit every key entry's group name was converted from UTF-8 to UTF-16 and then inserted into a set. With this commit every key entry's group name is inserted as a std::string_view into a set, and only unique group names are converted to UTF-16 in the end. This should improve performance. --- src/core/kconfig.cpp | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index 0b890132..b602ce47 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -31,7 +31,11 @@ #include #include +#include +#include #include +#include +#include #if KCONFIG_USE_DBUS #include @@ -273,37 +277,57 @@ KConfig::~KConfig() delete d; } +static int findFirstGroupEndPos(const QByteArray &groupFullName, int from = 0) +{ + const auto index = groupFullName.indexOf('\x1d', from); + return index == -1 ? groupFullName.size() : index; +} + +// std::string_view is used because QByteArrayView does not exist in Qt 5. +// std::unordered_set rather than QSet is used because there is no qHash() overload for std::string_view in Qt 5. +using ByteArrayViewSet = std::unordered_set; + +static QStringList stringListFromUtf8Collection(const ByteArrayViewSet &source) +{ + QStringList list; + list.reserve(source.size()); + std::transform(source.cbegin(), source.cend(), std::back_inserter(list), [](std::string_view view) { + return QString::fromUtf8(view.data(), view.size()); + }); + return list; +} + QStringList KConfig::groupList() const { Q_D(const KConfig); - QSet groups; + ByteArrayViewSet groups; for (auto entryMapIt = d->entryMap.cbegin(); entryMapIt != d->entryMap.cend(); ++entryMapIt) { const KEntryKey &key = entryMapIt.key(); const QByteArray &group = key.mGroup; if (!key.mKey.isNull() && !entryMapIt->bDeleted && !group.isEmpty() && group != "" && group != "$Version") { - const QString groupname = QString::fromUtf8(group); - groups << groupname.left(groupname.indexOf(QLatin1Char('\x1d'))); + groups.emplace(group.constData(), findFirstGroupEndPos(group)); } } - return groups.values(); + return stringListFromUtf8Collection(groups); } QStringList KConfigPrivate::groupList(const QByteArray &group) const { const QByteArray theGroup = group + '\x1d'; - QSet groups; + ByteArrayViewSet groups; for (auto entryMapIt = entryMap.cbegin(); entryMapIt != entryMap.cend(); ++entryMapIt) { const KEntryKey &key = entryMapIt.key(); if (!key.mKey.isNull() && !entryMapIt->bDeleted && key.mGroup.startsWith(theGroup)) { - const QString groupname = QString::fromUtf8(key.mGroup.mid(theGroup.length())); - groups << groupname.left(groupname.indexOf(QLatin1Char('\x1d'))); + const auto subgroupStartPos = theGroup.size(); + const auto subgroupEndPos = findFirstGroupEndPos(key.mGroup, subgroupStartPos); + groups.emplace(key.mGroup.constData() + subgroupStartPos, subgroupEndPos - subgroupStartPos); } } - return groups.values(); + return stringListFromUtf8Collection(groups); } static bool isGroupOrSubGroupMatch(const QByteArray &potentialGroup, const QByteArray &group) From 9ca42038a09307b04a4e6be39b60f25c23105fe1 Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Sat, 25 Dec 2021 09:37:04 +0200 Subject: [PATCH 235/259] KConfigPrivate::copyGroup: remove redundant entryMap lookup --- src/core/kconfig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index b602ce47..025a8b1d 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -163,7 +163,7 @@ void KConfigPrivate::copyGroup(const QByteArray &source, const QByteArray &desti newKey.mGroup.replace(0, len, destination); } - KEntry entry = entryMap[entryMapIt.key()]; + KEntry entry = entryMapIt.value(); dirtied = entry.bDirty = flags & KConfigBase::Persistent; if (flags & KConfigBase::Global) { From 117835244a23ccc906ee0b0d462d67c38480b914 Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Mon, 27 Dec 2021 11:39:54 +0200 Subject: [PATCH 236/259] Improve the documentation of KConfigPrivate::allSubGroups() --- src/core/kconfig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index 025a8b1d..4bbceeda 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -338,7 +338,7 @@ static bool isGroupOrSubGroupMatch(const QByteArray &potentialGroup, const QByte return potentialGroup.length() == group.length() || potentialGroup[group.length()] == '\x1d'; } -// List all sub groups, including subsubgroups +/// Returns @p parentGroup itself, all its subgroups, subsubgroups, and so on, including deleted groups. QSet KConfigPrivate::allSubGroups(const QByteArray &parentGroup) const { QSet groups; From acccefbc667e7ee2c481b2fd0b45ba2f12e9237a Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Sat, 25 Dec 2021 09:46:44 +0200 Subject: [PATCH 237/259] Look for entries with common group prefix in entryMap's subrange entryMap is ordered by the group name first. So there is no need to iterate over the entire map to process entries whose group names start with some prefix. Find the group name prefix's lower bound and iterate over the proper subrange instead. This should be much faster, especially if the subrange's size is much less than the entryMap's size. Adjust isGroupOrSubGroupMatch() helper function to assert the extracted startsWith() condition instead of rechecking it. Pass KEntryMapConstIterator in place of the group name to this function in order to simplify its callers' code. Reuse this helper function in KConfigPrivate::copyGroup(). --- src/core/kconfig.cpp | 56 ++++++++++++++++------------------------ src/core/kconfigdata_p.h | 30 +++++++++++++++++++++ 2 files changed, 52 insertions(+), 34 deletions(-) diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index 4bbceeda..9e62c167 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -130,10 +130,16 @@ bool KConfigPrivate::lockLocal() return true; } +static bool isGroupOrSubGroupMatch(KEntryMapConstIterator entryMapIt, const QByteArray &group) +{ + const QByteArray &entryGroup = entryMapIt.key().mGroup; + Q_ASSERT_X(entryGroup.startsWith(group), Q_FUNC_INFO, "Precondition"); + return entryGroup.size() == group.size() || entryGroup[group.size()] == '\x1d'; +} + void KConfigPrivate::copyGroup(const QByteArray &source, const QByteArray &destination, KConfigGroup *otherGroup, KConfigBase::WriteConfigFlags flags) const { KEntryMap &otherMap = otherGroup->config()->d_ptr->entryMap; - const int len = source.length(); const bool sameName = (destination == source); // we keep this bool outside the for loop so that if @@ -141,16 +147,10 @@ void KConfigPrivate::copyGroup(const QByteArray &source, const QByteArray &desti // as dirty erroneously bool dirtied = false; - for (auto entryMapIt = entryMap.cbegin(); entryMapIt != entryMap.cend(); ++entryMapIt) { - const QByteArray &group = entryMapIt.key().mGroup; - - if (!group.startsWith(source)) { // nothing to do - continue; - } - + entryMap.forEachEntryWhoseGroupStartsWith(source, [&source, &destination, flags, &otherMap, sameName, &dirtied](KEntryMapConstIterator entryMapIt) { // don't copy groups that start with the same prefix, but are not sub-groups - if (group.length() > len && group[len] != '\x1d') { - continue; + if (!isGroupOrSubGroupMatch(entryMapIt, source)) { + return; } KEntryKey newKey = entryMapIt.key(); @@ -160,7 +160,7 @@ void KConfigPrivate::copyGroup(const QByteArray &source, const QByteArray &desti } if (!sameName) { - newKey.mGroup.replace(0, len, destination); + newKey.mGroup.replace(0, source.size(), destination); } KEntry entry = entryMapIt.value(); @@ -175,7 +175,7 @@ void KConfigPrivate::copyGroup(const QByteArray &source, const QByteArray &desti } otherMap[newKey] = entry; - } + }); if (dirtied) { otherGroup->config()->d_ptr->bDirty = true; @@ -318,50 +318,38 @@ QStringList KConfigPrivate::groupList(const QByteArray &group) const const QByteArray theGroup = group + '\x1d'; ByteArrayViewSet groups; - for (auto entryMapIt = entryMap.cbegin(); entryMapIt != entryMap.cend(); ++entryMapIt) { + entryMap.forEachEntryWhoseGroupStartsWith(theGroup, [&theGroup, &groups](KEntryMapConstIterator entryMapIt) { const KEntryKey &key = entryMapIt.key(); - if (!key.mKey.isNull() && !entryMapIt->bDeleted && key.mGroup.startsWith(theGroup)) { + if (!key.mKey.isNull() && !entryMapIt->bDeleted) { const auto subgroupStartPos = theGroup.size(); const auto subgroupEndPos = findFirstGroupEndPos(key.mGroup, subgroupStartPos); groups.emplace(key.mGroup.constData() + subgroupStartPos, subgroupEndPos - subgroupStartPos); } - } + }); return stringListFromUtf8Collection(groups); } -static bool isGroupOrSubGroupMatch(const QByteArray &potentialGroup, const QByteArray &group) -{ - if (!potentialGroup.startsWith(group)) { - return false; - } - return potentialGroup.length() == group.length() || potentialGroup[group.length()] == '\x1d'; -} - /// Returns @p parentGroup itself, all its subgroups, subsubgroups, and so on, including deleted groups. QSet KConfigPrivate::allSubGroups(const QByteArray &parentGroup) const { QSet groups; - for (KEntryMap::const_iterator entryMapIt = entryMap.begin(); entryMapIt != entryMap.end(); ++entryMapIt) { + entryMap.forEachEntryWhoseGroupStartsWith(parentGroup, [&parentGroup, &groups](KEntryMapConstIterator entryMapIt) { const KEntryKey &key = entryMapIt.key(); - if (key.mKey.isNull() && isGroupOrSubGroupMatch(key.mGroup, parentGroup)) { + if (key.mKey.isNull() && isGroupOrSubGroupMatch(entryMapIt, parentGroup)) { groups << key.mGroup; } - } + }); + return groups; } bool KConfigPrivate::hasNonDeletedEntries(const QByteArray &group) const { - for (KEntryMap::const_iterator it = entryMap.begin(); it != entryMap.end(); ++it) { - const KEntryKey &key = it.key(); - // Check for any non-deleted entry - if (isGroupOrSubGroupMatch(key.mGroup, group) && !key.mKey.isNull() && !it->bDeleted) { - return true; - } - } - return false; + return entryMap.anyEntryWhoseGroupStartsWith(group, [&group](KEntryMapConstIterator entryMapIt) { + return isGroupOrSubGroupMatch(entryMapIt, group) && !entryMapIt.key().mKey.isNull() && !entryMapIt->bDeleted; + }); } QStringList KConfigPrivate::keyListImpl(const QByteArray &theGroup) const diff --git a/src/core/kconfigdata_p.h b/src/core/kconfigdata_p.h index 5e5246f3..beb18f45 100644 --- a/src/core/kconfigdata_p.h +++ b/src/core/kconfigdata_p.h @@ -155,6 +155,17 @@ inline bool operator<(const KEntryKey &k1, const KEntryKey &k2) return (!k1.bDefault && k2.bDefault); } +/** + * Returns the minimum key that has @a mGroup == @p group. + * + * @note The returned "minimum key" is consistent with KEntryKey's operator<(). + * The return value of this function can be passed to KEntryMap::lowerBound(). + */ +inline KEntryKey minimumGroupKey(const QByteArray &group) +{ + return KEntryKey(group, QByteArray{}, true, false); +} + QDebug operator<<(QDebug dbg, const KEntryKey &key); QDebug operator<<(QDebug dbg, const KEntry &entry); @@ -230,6 +241,25 @@ class KEntryMap : public QMap } bool revertEntry(const QByteArray &group, const QByteArray &key, EntryOptions options, SearchFlags flags = SearchFlags()); + + template + void forEachEntryWhoseGroupStartsWith(const QByteArray &groupPrefix, ConstIteratorUser callback) const + { + for (auto it = lowerBound(minimumGroupKey(groupPrefix)), end = cend(); it != end && it.key().mGroup.startsWith(groupPrefix); ++it) { + callback(it); + } + } + + template + bool anyEntryWhoseGroupStartsWith(const QByteArray &groupPrefix, ConstIteratorPredicate predicate) const + { + for (auto it = lowerBound(minimumGroupKey(groupPrefix)), end = cend(); it != end && it.key().mGroup.startsWith(groupPrefix); ++it) { + if (predicate(it)) { + return true; + } + } + return false; + } }; Q_DECLARE_OPERATORS_FOR_FLAGS(KEntryMap::SearchFlags) Q_DECLARE_OPERATORS_FOR_FLAGS(KEntryMap::EntryOptions) From 9151f1dacf59d0af10b11729b53ad23824ec1693 Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Sat, 25 Dec 2021 08:29:27 +0200 Subject: [PATCH 238/259] Extract isNonDeletedKey() helper function The eliminated duplication of the composite condition was error-prone and less readable. --- src/core/kconfig.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index 9e62c167..22ae0b54 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -277,6 +277,11 @@ KConfig::~KConfig() delete d; } +static bool isNonDeletedKey(KEntryMapConstIterator entryMapIt) +{ + return !entryMapIt.key().mKey.isNull() && !entryMapIt->bDeleted; +} + static int findFirstGroupEndPos(const QByteArray &groupFullName, int from = 0) { const auto index = groupFullName.indexOf('\x1d', from); @@ -303,9 +308,8 @@ QStringList KConfig::groupList() const ByteArrayViewSet groups; for (auto entryMapIt = d->entryMap.cbegin(); entryMapIt != d->entryMap.cend(); ++entryMapIt) { - const KEntryKey &key = entryMapIt.key(); - const QByteArray &group = key.mGroup; - if (!key.mKey.isNull() && !entryMapIt->bDeleted && !group.isEmpty() && group != "" && group != "$Version") { + const QByteArray &group = entryMapIt.key().mGroup; + if (isNonDeletedKey(entryMapIt) && !group.isEmpty() && group != "" && group != "$Version") { groups.emplace(group.constData(), findFirstGroupEndPos(group)); } } @@ -319,11 +323,11 @@ QStringList KConfigPrivate::groupList(const QByteArray &group) const ByteArrayViewSet groups; entryMap.forEachEntryWhoseGroupStartsWith(theGroup, [&theGroup, &groups](KEntryMapConstIterator entryMapIt) { - const KEntryKey &key = entryMapIt.key(); - if (!key.mKey.isNull() && !entryMapIt->bDeleted) { + if (isNonDeletedKey(entryMapIt)) { + const QByteArray &entryGroup = entryMapIt.key().mGroup; const auto subgroupStartPos = theGroup.size(); - const auto subgroupEndPos = findFirstGroupEndPos(key.mGroup, subgroupStartPos); - groups.emplace(key.mGroup.constData() + subgroupStartPos, subgroupEndPos - subgroupStartPos); + const auto subgroupEndPos = findFirstGroupEndPos(entryGroup, subgroupStartPos); + groups.emplace(entryGroup.constData() + subgroupStartPos, subgroupEndPos - subgroupStartPos); } }); @@ -348,7 +352,7 @@ QSet KConfigPrivate::allSubGroups(const QByteArray &parentGroup) con bool KConfigPrivate::hasNonDeletedEntries(const QByteArray &group) const { return entryMap.anyEntryWhoseGroupStartsWith(group, [&group](KEntryMapConstIterator entryMapIt) { - return isGroupOrSubGroupMatch(entryMapIt, group) && !entryMapIt.key().mKey.isNull() && !entryMapIt->bDeleted; + return isGroupOrSubGroupMatch(entryMapIt, group) && isNonDeletedKey(entryMapIt); }); } @@ -363,9 +367,8 @@ QStringList KConfigPrivate::keyListImpl(const QByteArray &theGroup) const std::set tmp; // unique set, sorted for unittests for (; it != theEnd && it.key().mGroup == theGroup; ++it) { - const KEntryKey &key = it.key(); - if (!key.mKey.isNull() && !it->bDeleted) { - tmp.insert(QString::fromUtf8(key.mKey)); + if (isNonDeletedKey(it)) { + tmp.insert(QString::fromUtf8(it.key().mKey)); } } keys = QList(tmp.begin(), tmp.end()); From 4b440665f2e15cf9f9934fe7bcc91cac2768df1f Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Mon, 3 Jan 2022 10:09:56 +0100 Subject: [PATCH 239/259] Use KDE_INSTALL_FULL_LIBEXECDIR_KF --- src/core/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 2b5e949c..4754725b 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -38,7 +38,7 @@ ecm_generate_export_header(KF5ConfigCore target_compile_definitions(KF5ConfigCore PRIVATE - KCONF_UPDATE_INSTALL_LOCATION="${KDE_INSTALL_FULL_LIBEXECDIR_KF5}/$" + KCONF_UPDATE_INSTALL_LOCATION="${KDE_INSTALL_FULL_LIBEXECDIR_KF}/$" ) target_include_directories(KF5ConfigCore INTERFACE "$") From b0bf9e030c3a0ec38cc456c48758fce8e4398333 Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Tue, 4 Jan 2022 21:07:17 +0100 Subject: [PATCH 240/259] Add Samir variable fix too --- src/kconf_update/CMakeLists.txt | 2 +- src/kconfig_compiler/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/kconf_update/CMakeLists.txt b/src/kconf_update/CMakeLists.txt index 8c23b358..91fb92ef 100644 --- a/src/kconf_update/CMakeLists.txt +++ b/src/kconf_update/CMakeLists.txt @@ -27,4 +27,4 @@ configure_file(config-kconf.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kconf.h ) # Although this is mostly an internal binary (hence installing it in # KF5_LIBEXEC_INSTALL_DIR), it is used by kded, and so we export its location -install(TARGETS kconf_update EXPORT KF5ConfigCompilerTargets DESTINATION ${KDE_INSTALL_LIBEXECDIR_KF5}) +install(TARGETS kconf_update EXPORT KF5ConfigCompilerTargets DESTINATION ${KDE_INSTALL_LIBEXECDIR_KF}) diff --git a/src/kconfig_compiler/CMakeLists.txt b/src/kconfig_compiler/CMakeLists.txt index 44018401..84d31bf7 100644 --- a/src/kconfig_compiler/CMakeLists.txt +++ b/src/kconfig_compiler/CMakeLists.txt @@ -25,4 +25,4 @@ target_link_libraries(kconfig_compiler Qt${QT_MAJOR_VERSION}::Xml) ecm_mark_nongui_executable(kconfig_compiler) -install(TARGETS kconfig_compiler EXPORT KF5ConfigCompilerTargets DESTINATION ${KDE_INSTALL_LIBEXECDIR_KF5}) +install(TARGETS kconfig_compiler EXPORT KF5ConfigCompilerTargets DESTINATION ${KDE_INSTALL_LIBEXECDIR_KF}) From 85f1170fce0a87ad85785cf4d7e3ac5e11d2a19f Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Thu, 6 Jan 2022 08:05:58 +0100 Subject: [PATCH 241/259] Add CI qt6 support --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 95f47074..f211b66f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,3 +5,4 @@ include: - https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/linux.yml - https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/android.yml - https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/freebsd.yml + - https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/linux-qt6.yml From a05de4ec8be718a0c131a2845da12db7772290a5 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 8 Jan 2022 11:33:57 +0000 Subject: [PATCH 242/259] GIT_SILENT Upgrade KF version to 5.91.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba942f8a..2eabc5a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.16) -set(KF_VERSION "5.90.0") # handled by release scripts +set(KF_VERSION "5.91.0") # handled by release scripts project(KConfig VERSION ${KF_VERSION}) include(FeatureSummary) From 26e541b36d25069fa829e7357aabff1a780f3872 Mon Sep 17 00:00:00 2001 From: Alexander Lohnau Date: Sat, 15 Jan 2022 09:59:58 +0100 Subject: [PATCH 243/259] Utilize ECMDeprecationSettings to manage deprecate Qt/KF API Task: https://phabricator.kde.org/T15109 --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2eabc5a1..209d3491 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ include(ECMMarkNonGuiExecutable) include(ECMPoQmTools) include(ECMAddQch) include(ECMQtDeclareLoggingCategory) +include(ECMDeprecationSettings) set(REQUIRED_QT_VERSION 5.15.2) @@ -51,7 +52,9 @@ ecm_setup_version(PROJECT VARIABLE_PREFIX KCONFIG PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5ConfigConfigVersion.cmake" SOVERSION 5) -add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050f02) +ecm_set_disabled_deprecation_versions( + QT 5.15.2 +) add_subdirectory(src) if (BUILD_TESTING) From 43c0ad17c8a7f898ecfce5a7bcb14d7073541e26 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Sat, 15 Jan 2022 14:06:32 +0200 Subject: [PATCH 244/259] Install kconfig_version.h in /usr/include/KF5/KConfig/ Instead of /usr/include/KF5/kconfig_version.h. For more details see: https://invent.kde.org/frameworks/kservice/-/merge_requests/79 GIT_SILENT --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 209d3491..4b165b3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,7 +100,7 @@ install(EXPORT KF5ConfigCompilerTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5ConfigCompilerTargets.cmake NAMESPACE KF5:: COMPONENT Devel) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kconfig_version.h - DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF} COMPONENT Devel ) + DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF}/KConfig COMPONENT Devel) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) From 3bbe9de5d59a6572f3549cc3a553dd44db421b68 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Sat, 15 Jan 2022 23:56:12 +0200 Subject: [PATCH 245/259] Add KF*/KConfig to the interface include directories So that #include still works after changing its location in the previous commit. NO_CHANGELOG --- src/core/CMakeLists.txt | 4 +++- src/gui/CMakeLists.txt | 3 ++- src/qml/CMakeLists.txt | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 4754725b..61113253 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -41,7 +41,9 @@ target_compile_definitions(KF5ConfigCore KCONF_UPDATE_INSTALL_LOCATION="${KDE_INSTALL_FULL_LIBEXECDIR_KF}/$" ) -target_include_directories(KF5ConfigCore INTERFACE "$") +target_include_directories(KF5ConfigCore + INTERFACE "$" +) target_link_libraries(KF5ConfigCore PUBLIC Qt${QT_MAJOR_VERSION}::Core) diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 4d5512d1..2136ec9f 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -21,7 +21,8 @@ ecm_generate_export_header(KF5ConfigGui EXCLUDE_DEPRECATED_BEFORE_AND_AT ${EXCLUDE_DEPRECATED_BEFORE_AND_AT} ) -target_include_directories(KF5ConfigGui INTERFACE "$") +target_include_directories(KF5ConfigGui + INTERFACE "$") target_link_libraries(KF5ConfigGui PUBLIC Qt${QT_MAJOR_VERSION}::Gui Qt${QT_MAJOR_VERSION}::Xml KF5::ConfigCore) diff --git a/src/qml/CMakeLists.txt b/src/qml/CMakeLists.txt index 17f90ad0..bd71387d 100644 --- a/src/qml/CMakeLists.txt +++ b/src/qml/CMakeLists.txt @@ -29,7 +29,8 @@ ecm_generate_headers(KConfigQml_HEADERS REQUIRED_HEADERS KConfigQml_HEADERS ) -target_include_directories(KF5ConfigQml INTERFACE "$") +target_include_directories(KF5ConfigQml + INTERFACE "$") install(TARGETS KF5ConfigQml EXPORT KF5ConfigTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) install(FILES From 41d37407e80f5ccd110cf303c20a181f95fa7e73 Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Fri, 21 Jan 2022 16:01:35 +0100 Subject: [PATCH 246/259] Make singleton teardown work with Qt6 as well In Qt6 the Q_GLOBAL_STATIC will already report to be null while it is in the process of being deleted, we therefore cannot access it anymore from destruction code path as we did before. This problem is hit for example by the Breeze style, making all 6 based widgets applications crash on exit without this. --- autotests/kconfig_compiler/test10.cpp.ref | 6 ++++-- autotests/kconfig_compiler/test4.cpp.ref | 6 ++++-- autotests/kconfig_compiler/test5.cpp.ref | 6 ++++-- autotests/kconfig_compiler/test8b.cpp.ref | 6 ++++-- autotests/kconfig_compiler/test8c.cpp.ref | 6 ++++-- autotests/kconfig_compiler/test_dpointer.cpp.ref | 6 ++++-- autotests/kconfig_compiler/test_emptyentries.cpp.ref | 6 ++++-- autotests/kconfig_compiler/test_signal.cpp.ref | 6 ++++-- src/kconfig_compiler/KConfigSourceGenerator.cpp | 7 +++++-- 9 files changed, 37 insertions(+), 18 deletions(-) diff --git a/autotests/kconfig_compiler/test10.cpp.ref b/autotests/kconfig_compiler/test10.cpp.ref index 94d9f311..2369d2c3 100644 --- a/autotests/kconfig_compiler/test10.cpp.ref +++ b/autotests/kconfig_compiler/test10.cpp.ref @@ -10,7 +10,7 @@ class Test10Helper { public: Test10Helper() : q(nullptr) {} - ~Test10Helper() { delete q; } + ~Test10Helper() { delete q; q = nullptr; } Test10Helper(const Test10Helper&) = delete; Test10Helper& operator=(const Test10Helper&) = delete; Test10 *q; @@ -43,6 +43,8 @@ Test10::Test10( ) Test10::~Test10() { - s_globalTest10()->q = nullptr; + if (s_globalTest10.exists() && !s_globalTest10.isDestroyed()) { + s_globalTest10()->q = nullptr; + } } diff --git a/autotests/kconfig_compiler/test4.cpp.ref b/autotests/kconfig_compiler/test4.cpp.ref index fb4db2ff..2e7ad7d7 100644 --- a/autotests/kconfig_compiler/test4.cpp.ref +++ b/autotests/kconfig_compiler/test4.cpp.ref @@ -10,7 +10,7 @@ class Test4Helper { public: Test4Helper() : q(nullptr) {} - ~Test4Helper() { delete q; } + ~Test4Helper() { delete q; q = nullptr; } Test4Helper(const Test4Helper&) = delete; Test4Helper& operator=(const Test4Helper&) = delete; Test4 *q; @@ -178,6 +178,8 @@ QColor defaultColor[4] = { Qt::red, Qt::blue, Qt::green, Qt::black }; Test4::~Test4() { - s_globalTest4()->q = nullptr; + if (s_globalTest4.exists() && !s_globalTest4.isDestroyed()) { + s_globalTest4()->q = nullptr; + } } diff --git a/autotests/kconfig_compiler/test5.cpp.ref b/autotests/kconfig_compiler/test5.cpp.ref index 2b50222c..1272b446 100644 --- a/autotests/kconfig_compiler/test5.cpp.ref +++ b/autotests/kconfig_compiler/test5.cpp.ref @@ -10,7 +10,7 @@ class Test5Helper { public: Test5Helper() : q(nullptr) {} - ~Test5Helper() { delete q; } + ~Test5Helper() { delete q; q = nullptr; } Test5Helper(const Test5Helper&) = delete; Test5Helper& operator=(const Test5Helper&) = delete; Test5 *q; @@ -89,6 +89,8 @@ QColor defaultColor[4] = { Qt::red, Qt::blue, Qt::green, Qt::black }; Test5::~Test5() { - s_globalTest5()->q = nullptr; + if (s_globalTest5.exists() && !s_globalTest5.isDestroyed()) { + s_globalTest5()->q = nullptr; + } } diff --git a/autotests/kconfig_compiler/test8b.cpp.ref b/autotests/kconfig_compiler/test8b.cpp.ref index d2ee566b..9c81fdbd 100644 --- a/autotests/kconfig_compiler/test8b.cpp.ref +++ b/autotests/kconfig_compiler/test8b.cpp.ref @@ -10,7 +10,7 @@ class Test8bHelper { public: Test8bHelper() : q(nullptr) {} - ~Test8bHelper() { delete q; } + ~Test8bHelper() { delete q; q = nullptr; } Test8bHelper(const Test8bHelper&) = delete; Test8bHelper& operator=(const Test8bHelper&) = delete; Test8b *q; @@ -49,6 +49,8 @@ Test8b::Test8b( ) Test8b::~Test8b() { - s_globalTest8b()->q = nullptr; + if (s_globalTest8b.exists() && !s_globalTest8b.isDestroyed()) { + s_globalTest8b()->q = nullptr; + } } diff --git a/autotests/kconfig_compiler/test8c.cpp.ref b/autotests/kconfig_compiler/test8c.cpp.ref index d806ca79..a0878b86 100644 --- a/autotests/kconfig_compiler/test8c.cpp.ref +++ b/autotests/kconfig_compiler/test8c.cpp.ref @@ -12,7 +12,7 @@ class Test8cHelper { public: Test8cHelper() : q(nullptr) {} - ~Test8cHelper() { delete q; } + ~Test8cHelper() { delete q; q = nullptr; } Test8cHelper(const Test8cHelper&) = delete; Test8cHelper& operator=(const Test8cHelper&) = delete; Test8c *q; @@ -63,6 +63,8 @@ Test8c::Test8c( KSharedConfig::Ptr config, QObject *parent ) Test8c::~Test8c() { - s_globalTest8c()->q = nullptr; + if (s_globalTest8c.exists() && !s_globalTest8c.isDestroyed()) { + s_globalTest8c()->q = nullptr; + } } diff --git a/autotests/kconfig_compiler/test_dpointer.cpp.ref b/autotests/kconfig_compiler/test_dpointer.cpp.ref index 14af30b7..de533005 100644 --- a/autotests/kconfig_compiler/test_dpointer.cpp.ref +++ b/autotests/kconfig_compiler/test_dpointer.cpp.ref @@ -49,7 +49,7 @@ class TestDPointerHelper { public: TestDPointerHelper() : q(nullptr) {} - ~TestDPointerHelper() { delete q; } + ~TestDPointerHelper() { delete q; q = nullptr; } TestDPointerHelper(const TestDPointerHelper&) = delete; TestDPointerHelper& operator=(const TestDPointerHelper&) = delete; TestDPointer *q; @@ -414,6 +414,8 @@ KConfigSkeleton::ItemFont *TestDPointer::timeBarFontItem() TestDPointer::~TestDPointer() { delete d; - s_globalTestDPointer()->q = nullptr; + if (s_globalTestDPointer.exists() && !s_globalTestDPointer.isDestroyed()) { + s_globalTestDPointer()->q = nullptr; + } } diff --git a/autotests/kconfig_compiler/test_emptyentries.cpp.ref b/autotests/kconfig_compiler/test_emptyentries.cpp.ref index e23ddc3c..3634ba6c 100644 --- a/autotests/kconfig_compiler/test_emptyentries.cpp.ref +++ b/autotests/kconfig_compiler/test_emptyentries.cpp.ref @@ -12,7 +12,7 @@ class QMakeBuilderSettingsHelper { public: QMakeBuilderSettingsHelper() : q(nullptr) {} - ~QMakeBuilderSettingsHelper() { delete q; } + ~QMakeBuilderSettingsHelper() { delete q; q = nullptr; } QMakeBuilderSettingsHelper(const QMakeBuilderSettingsHelper&) = delete; QMakeBuilderSettingsHelper& operator=(const QMakeBuilderSettingsHelper&) = delete; QMakeBuilderSettings *q; @@ -54,6 +54,8 @@ QMakeBuilderSettings::QMakeBuilderSettings( KSharedConfig::Ptr config ) QMakeBuilderSettings::~QMakeBuilderSettings() { - s_globalQMakeBuilderSettings()->q = nullptr; + if (s_globalQMakeBuilderSettings.exists() && !s_globalQMakeBuilderSettings.isDestroyed()) { + s_globalQMakeBuilderSettings()->q = nullptr; + } } diff --git a/autotests/kconfig_compiler/test_signal.cpp.ref b/autotests/kconfig_compiler/test_signal.cpp.ref index 71ab7a09..378cd2c2 100644 --- a/autotests/kconfig_compiler/test_signal.cpp.ref +++ b/autotests/kconfig_compiler/test_signal.cpp.ref @@ -10,7 +10,7 @@ class TestSignalHelper { public: TestSignalHelper() : q(nullptr) {} - ~TestSignalHelper() { delete q; } + ~TestSignalHelper() { delete q; q = nullptr; } TestSignalHelper(const TestSignalHelper&) = delete; TestSignalHelper& operator=(const TestSignalHelper&) = delete; TestSignal *q; @@ -63,7 +63,9 @@ TestSignal::TestSignal( ) TestSignal::~TestSignal() { - s_globalTestSignal()->q = nullptr; + if (s_globalTestSignal.exists() && !s_globalTestSignal.isDestroyed()) { + s_globalTestSignal()->q = nullptr; + } } bool TestSignal::usrSave() diff --git a/src/kconfig_compiler/KConfigSourceGenerator.cpp b/src/kconfig_compiler/KConfigSourceGenerator.cpp index d83c1bb4..9071b9a4 100644 --- a/src/kconfig_compiler/KConfigSourceGenerator.cpp +++ b/src/kconfig_compiler/KConfigSourceGenerator.cpp @@ -138,7 +138,7 @@ void KConfigSourceGenerator::createSingletonImplementation() stream() << '{' << '\n'; stream() << " public:\n"; stream() << " " << cfg().className << "Helper() : q(nullptr) {}\n"; - stream() << " ~" << cfg().className << "Helper() { delete q; }\n"; + stream() << " ~" << cfg().className << "Helper() { delete q; q = nullptr; }\n"; stream() << " " << cfg().className << "Helper(const " << cfg().className << "Helper&) = delete;\n"; stream() << " " << cfg().className << "Helper& operator=(const " << cfg().className << "Helper&) = delete;\n"; stream() << " " << cfg().className << " *q;\n"; @@ -616,7 +616,10 @@ void KConfigSourceGenerator::createDestructor() stream() << " delete d;\n"; } if (cfg().singleton) { - stream() << " s_global" << cfg().className << "()->q = nullptr;\n"; + const QString qgs = QLatin1String("s_global") + cfg().className; + stream() << " if (" << qgs << ".exists() && !" << qgs << ".isDestroyed()) {\n"; + stream() << " " << qgs << "()->q = nullptr;\n"; + stream() << " }\n"; } endScope(); stream() << '\n'; From 820dc0a553e50cc4560733d43fca2674a61d43b3 Mon Sep 17 00:00:00 2001 From: David Redondo Date: Thu, 13 Jan 2022 10:04:13 +0100 Subject: [PATCH 247/259] Introduce StandardShortcutWatcher to watch for runtime changes Currently an application needs to be restarted before it can see any changes made to the standard shortcut configuration. To notify about changes a new class is introduced that looks for those changes using KConfigWatcher and also updates the global map. CCBUG:426656 --- autotests/CMakeLists.txt | 1 + autotests/kstandardshortcutwatchertest.cpp | 63 ++++++++++++++++++++++ src/gui/CMakeLists.txt | 3 ++ src/gui/kstandardshortcut.cpp | 10 ++-- src/gui/kstandardshortcut_p.h | 20 +++++++ src/gui/kstandardshortcutwatcher.cpp | 46 ++++++++++++++++ src/gui/kstandardshortcutwatcher.h | 54 +++++++++++++++++++ 7 files changed, 194 insertions(+), 3 deletions(-) create mode 100644 autotests/kstandardshortcutwatchertest.cpp create mode 100644 src/gui/kstandardshortcut_p.h create mode 100644 src/gui/kstandardshortcutwatcher.cpp create mode 100644 src/gui/kstandardshortcutwatcher.h diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt index a7e37e5a..725d789f 100644 --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -57,6 +57,7 @@ ecm_add_tests( kconfigloadertest.cpp kconfigskeletontest.cpp kstandardshortcuttest.cpp + kstandardshortcutwatchertest.cpp NAME_PREFIX kconfiggui- LINK_LIBRARIES KF5::ConfigGui Qt${QT_MAJOR_VERSION}::Test ) diff --git a/autotests/kstandardshortcutwatchertest.cpp b/autotests/kstandardshortcutwatchertest.cpp new file mode 100644 index 00000000..f20fc635 --- /dev/null +++ b/autotests/kstandardshortcutwatchertest.cpp @@ -0,0 +1,63 @@ +/* + SPDX-FileCopyrightText: 2022 David Redondo + + SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "kstandardshortcutwatcher.h" +#include "kconfiggroup.h" +#include "ksharedconfig.h" + +#include +#include +#include + +class KStandardShortcutWatcherTest : public QObject +{ + Q_OBJECT +private Q_SLOTS: + void initTestCase(); + void init(); + void testSignal(); + void testDataUpdated(); +}; + +Q_DECLARE_METATYPE(KStandardShortcut::StandardShortcut) + +const QList newShortcut = {Qt::CTRL + Qt::Key_Adiaeresis}; + +void KStandardShortcutWatcherTest::initTestCase() +{ + QStandardPaths::setTestModeEnabled(true); + qRegisterMetaType(); + QVERIFY(KStandardShortcut::hardcodedDefaultShortcut(KStandardShortcut::Open) != newShortcut); +} + +void KStandardShortcutWatcherTest::init() +{ + KStandardShortcut::saveShortcut(KStandardShortcut::Open, KStandardShortcut::hardcodedDefaultShortcut(KStandardShortcut::Open)); +} + +void KStandardShortcutWatcherTest::testSignal() +{ + QSignalSpy signalSpy(KStandardShortcut::shortcutWatcher(), &KStandardShortcut::StandardShortcutWatcher::shortcutChanged); + KStandardShortcut::saveShortcut(KStandardShortcut::Open, newShortcut); + QTRY_COMPARE(signalSpy.count(), 1); + const QList arguments = signalSpy.takeFirst(); + QCOMPARE(arguments[0].toInt(), KStandardShortcut::Open); + QCOMPARE(arguments[1].value>(), newShortcut); +} + +void KStandardShortcutWatcherTest::testDataUpdated() +{ + QSignalSpy signalSpy(KStandardShortcut::shortcutWatcher(), &KStandardShortcut::StandardShortcutWatcher::shortcutChanged); + // Writing manually to forego automatic update in saveShortcut() + KConfigGroup group(KSharedConfig::openConfig(), "Shortcuts"); + group.writeEntry("Open", QKeySequence::listToString(newShortcut), KConfig::Global | KConfig::Notify); + group.config()->sync(); + QTRY_COMPARE(signalSpy.count(), 1); + QCOMPARE(KStandardShortcut::open(), newShortcut); +} + +QTEST_MAIN(KStandardShortcutWatcherTest) +#include "kstandardshortcutwatchertest.moc" diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 2136ec9f..403b0367 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -9,6 +9,7 @@ target_sources(KF5ConfigGui PRIVATE kconfigloader.cpp kconfigskeleton.cpp kstandardshortcut.cpp + kstandardshortcutwatcher.cpp kwindowconfig.cpp ) @@ -37,6 +38,7 @@ ecm_generate_headers(KConfigGui_HEADERS KConfigLoader KConfigSkeleton KStandardShortcut + KStandardShortcutWatcher KWindowConfig REQUIRED_HEADERS KConfigGui_HEADERS @@ -60,6 +62,7 @@ if (PythonModuleGeneration_FOUND) kconfigloader.h kconfigskeleton.h kstandardshortcut.h + kstandardshortcutwatcher.h kwindowconfig.h ) endif() diff --git a/src/gui/kstandardshortcut.cpp b/src/gui/kstandardshortcut.cpp index 1f67901f..e7639219 100644 --- a/src/gui/kstandardshortcut.cpp +++ b/src/gui/kstandardshortcut.cpp @@ -8,8 +8,10 @@ */ #include "kstandardshortcut.h" +#include "kstandardshortcutwatcher.h" #include "kconfig.h" +#include "kconfigwatcher.h" #include "ksharedconfig.h" #include @@ -437,7 +439,7 @@ static void sanitizeShortcutList(QList *list) On X11, if QApplication was initialized with GUI disabled, the default will always be used. */ -static void initialize(StandardShortcut id) +void initialize(StandardShortcut id) { KStandardShortcutInfo *info = guardedStandardShortcutInfo(id); @@ -483,7 +485,8 @@ void saveShortcut(StandardShortcut id, const QList &newShortcut) // If the shortcut is the equal to the hardcoded one we remove it from // kdeglobal if necessary and return. if (cg.hasKey(info->name)) { - cg.deleteEntry(info->name, KConfig::Global | KConfig::Persistent); + cg.deleteEntry(info->name, KConfig::Global | KConfig::Persistent | KConfig::Notify); + cg.sync(); } return; @@ -491,7 +494,8 @@ void saveShortcut(StandardShortcut id, const QList &newShortcut) // Write the changed shortcut to kdeglobals sanitizeShortcutList(&info->cut); - cg.writeEntry(info->name, QKeySequence::listToString(info->cut), KConfig::Global | KConfig::Persistent); + cg.writeEntry(info->name, QKeySequence::listToString(info->cut), KConfig::Global | KConfig::Persistent | KConfig::Notify); + cg.sync(); } QString name(StandardShortcut id) diff --git a/src/gui/kstandardshortcut_p.h b/src/gui/kstandardshortcut_p.h new file mode 100644 index 00000000..f4b0a0fb --- /dev/null +++ b/src/gui/kstandardshortcut_p.h @@ -0,0 +1,20 @@ +/* + This file is part of the KDE libraries + SPDX-FileCopyrightText: 1997 Stefan Taferner + SPDX-FileCopyrightText: 2000 Nicolas Hadacek + SPDX-FileCopyrightText: 2001, 2002 Ellis Whitehead + + SPDX-License-Identifier: LGPL-2.0-or-later +*/ + +#ifndef KSTANDARDSHORTCUT_P_H +#define KSTANDARDSHORTCUT_P_H + +#include "kstandardshortcut.h" + +namespace KStandardShortcut +{ +void initialize(StandardShortcut id); +} + +#endif diff --git a/src/gui/kstandardshortcutwatcher.cpp b/src/gui/kstandardshortcutwatcher.cpp new file mode 100644 index 00000000..1be5e503 --- /dev/null +++ b/src/gui/kstandardshortcutwatcher.cpp @@ -0,0 +1,46 @@ +/* + SPDX-FileCopyrightText: 2022 David Redondo + + SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "kstandardshortcutwatcher.h" + +#include "kconfigwatcher.h" +#include "kstandardshortcut_p.h" + +namespace KStandardShortcut +{ +class StandardShortcutWatcherPrivate +{ +public: + KConfigWatcher::Ptr watcher = KConfigWatcher::create(KSharedConfig::openConfig()); +}; + +StandardShortcutWatcher::StandardShortcutWatcher(QObject *parent) + : QObject(parent) + , d(std::make_unique()) +{ + connect(d->watcher.get(), &KConfigWatcher::configChanged, this, [this](const KConfigGroup &group, const QByteArrayList &keys) { + if (group.name() != QStringLiteral("Shortcuts")) { + return; + } + for (const auto &key : keys) { + const StandardShortcut shortcut = KStandardShortcut::findByName(QString::fromUtf8(key)); + if (shortcut != KStandardShortcut::AccelNone) { + initialize(shortcut); + Q_EMIT shortcutChanged(shortcut, KStandardShortcut::shortcut(shortcut)); + } + } + }); +} + +StandardShortcutWatcher::~StandardShortcutWatcher() = default; + +StandardShortcutWatcher *shortcutWatcher() +{ + static StandardShortcutWatcher watcher; + return &watcher; +} + +} diff --git a/src/gui/kstandardshortcutwatcher.h b/src/gui/kstandardshortcutwatcher.h new file mode 100644 index 00000000..64c6d3d4 --- /dev/null +++ b/src/gui/kstandardshortcutwatcher.h @@ -0,0 +1,54 @@ +/* + SPDX-FileCopyrightText: 2022 David Redondo + + SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#ifndef KSTANDARDSHORTCUTWATCHER_H +#define KSTANDARDSHORTCUTWATCHER_H + +#include "kstandardshortcut.h" + +#include + +#include + +#include + +namespace KStandardShortcut +{ +class StandardShortcutWatcherPrivate; + +/** + * Watches for changes made to standard shortcuts and notifies about those changes. + * @see KStandardShortcut::shortcutWatcher + * @since 5.91 + */ +class KCONFIGGUI_EXPORT StandardShortcutWatcher : public QObject +{ + Q_OBJECT +public: + ~StandardShortcutWatcher(); +Q_SIGNALS: + /** + * The standardshortcut @p id was changed to @p shortcut + */ + void shortcutChanged(KStandardShortcut::StandardShortcut id, const QList &shortcut); + +private: + explicit StandardShortcutWatcher(QObject *parent = nullptr); + friend StandardShortcutWatcher *shortcutWatcher(); + std::unique_ptr d; +}; + +/** + * Returns the global KStandardShortcutWatcher instance of this program. + * In addition to the notifying about changes it also keeps the information returned by the + * functions in @p KStandardShortcut up to date. + * The object is created by the first call to this function. + * @since 5.91 + */ +KCONFIGGUI_EXPORT StandardShortcutWatcher *shortcutWatcher(); +} + +#endif From 724966b63f48b8b8fa8891f82924328f3f73fad0 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Mon, 24 Jan 2022 13:52:07 +0100 Subject: [PATCH 248/259] Fix build on Windows --- src/gui/kstandardshortcutwatcher.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kstandardshortcutwatcher.h b/src/gui/kstandardshortcutwatcher.h index 64c6d3d4..b6584ccf 100644 --- a/src/gui/kstandardshortcutwatcher.h +++ b/src/gui/kstandardshortcutwatcher.h @@ -37,7 +37,7 @@ class KCONFIGGUI_EXPORT StandardShortcutWatcher : public QObject private: explicit StandardShortcutWatcher(QObject *parent = nullptr); - friend StandardShortcutWatcher *shortcutWatcher(); + friend KCONFIGGUI_EXPORT StandardShortcutWatcher *shortcutWatcher(); std::unique_ptr d; }; From 4d31ec78f80d6add09dc80404470cfae7f2b13c7 Mon Sep 17 00:00:00 2001 From: David Redondo Date: Fri, 28 Jan 2022 10:58:14 +0100 Subject: [PATCH 249/259] Don't use saveShortcut for setting up tests It will trigger side effects like triggering the dbus signal which depending on the timing may be delivered only in the next test case causing an unexpected change signal emission. --- autotests/CMakeLists.txt | 12 +++++++++++- autotests/kstandardshortcutwatchertest.cpp | 8 ++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt index 725d789f..95a1200a 100644 --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -57,11 +57,21 @@ ecm_add_tests( kconfigloadertest.cpp kconfigskeletontest.cpp kstandardshortcuttest.cpp - kstandardshortcutwatchertest.cpp NAME_PREFIX kconfiggui- LINK_LIBRARIES KF5::ConfigGui Qt${QT_MAJOR_VERSION}::Test ) +ecm_add_test( + kstandardshortcutwatchertest.cpp + # add sources instead of linking so we can use the unexported initialize() + ../src/gui/kstandardshortcut.cpp + ../src/gui/kstandardshortcutwatcher.cpp + LINK_LIBRARIES KF5::ConfigCore Qt${QT_MAJOR_VERSION}::Gui Qt${QT_MAJOR_VERSION}::Test + TEST_NAME kstandardshortcutwatchertest + NAME_PREFIX kconfiggui- +) +target_include_directories(kstandardshortcutwatchertest PRIVATE "$") + # These tests do a global cleanup of ~/.qttest, so they can't run in parallel set_tests_properties(kconfigcore-kconfigtest PROPERTIES RUN_SERIAL TRUE) set_tests_properties(kconfigcore-kconfignokdehometest PROPERTIES RUN_SERIAL TRUE) diff --git a/autotests/kstandardshortcutwatchertest.cpp b/autotests/kstandardshortcutwatchertest.cpp index f20fc635..64d55d5c 100644 --- a/autotests/kstandardshortcutwatchertest.cpp +++ b/autotests/kstandardshortcutwatchertest.cpp @@ -7,6 +7,7 @@ #include "kstandardshortcutwatcher.h" #include "kconfiggroup.h" #include "ksharedconfig.h" +#include "kstandardshortcut_p.h" #include #include @@ -35,7 +36,10 @@ void KStandardShortcutWatcherTest::initTestCase() void KStandardShortcutWatcherTest::init() { - KStandardShortcut::saveShortcut(KStandardShortcut::Open, KStandardShortcut::hardcodedDefaultShortcut(KStandardShortcut::Open)); + KConfigGroup group(KSharedConfig::openConfig(), "Shortcuts"); + group.writeEntry("Open", QKeySequence::listToString(KStandardShortcut::hardcodedDefaultShortcut(KStandardShortcut::Open)), KConfig::Global); + group.sync(); + KStandardShortcut::initialize(KStandardShortcut::Open); } void KStandardShortcutWatcherTest::testSignal() @@ -54,7 +58,7 @@ void KStandardShortcutWatcherTest::testDataUpdated() // Writing manually to forego automatic update in saveShortcut() KConfigGroup group(KSharedConfig::openConfig(), "Shortcuts"); group.writeEntry("Open", QKeySequence::listToString(newShortcut), KConfig::Global | KConfig::Notify); - group.config()->sync(); + group.sync(); QTRY_COMPARE(signalSpy.count(), 1); QCOMPARE(KStandardShortcut::open(), newShortcut); } From 978d69628b1d9aec95ef97aedacd2ccd28613b7b Mon Sep 17 00:00:00 2001 From: David Redondo Date: Fri, 4 Feb 2022 13:03:22 +0100 Subject: [PATCH 250/259] Fix build on Windows Since we are not building the library but the source files we don't want the macro to expand to __declspec(dllimport). --- autotests/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt index 95a1200a..7b5a73b1 100644 --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -71,6 +71,7 @@ ecm_add_test( NAME_PREFIX kconfiggui- ) target_include_directories(kstandardshortcutwatchertest PRIVATE "$") +target_compile_definitions(kstandardshortcutwatchertest PRIVATE "-DKCONFIGGUI_STATIC_DEFINE") # These tests do a global cleanup of ~/.qttest, so they can't run in parallel set_tests_properties(kconfigcore-kconfigtest PROPERTIES RUN_SERIAL TRUE) From 4ab9e42b1041055f894f74547ecf18e378582543 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 5 Feb 2022 15:10:37 +0000 Subject: [PATCH 251/259] GIT_SILENT Upgrade ECM and KF version requirements for 5.91.0 release. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b165b3f..28c67e45 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ set(KF_VERSION "5.91.0") # handled by release scripts project(KConfig VERSION ${KF_VERSION}) include(FeatureSummary) -find_package(ECM 5.90.0 NO_MODULE) +find_package(ECM 5.91.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) From 9a35a3685d716870b8fd91fc35e0f443b1730ad4 Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Wed, 9 Feb 2022 23:56:46 +0100 Subject: [PATCH 252/259] API dox: brush over KCoreConfigSkeleton & KConfigSkeleton docs NO_CHANGELOG --- src/core/kcoreconfigskeleton.h | 218 +++++++++++++++++---------------- src/gui/kconfigskeleton.h | 5 +- 2 files changed, 112 insertions(+), 111 deletions(-) diff --git a/src/core/kcoreconfigskeleton.h b/src/core/kcoreconfigskeleton.h index d32de14a..aae57487 100644 --- a/src/core/kcoreconfigskeleton.h +++ b/src/core/kcoreconfigskeleton.h @@ -26,7 +26,7 @@ class KCoreConfigSkeletonPrivate; class KConfigSkeletonItemPrivate; /** - * \class KConfigSkeletonItem kcoreconfigskeleton.h + * \class KConfigSkeletonItem kcoreconfigskeleton.h * * @short Class for storing a preferences setting * @author Cornelius Schumacher @@ -65,7 +65,7 @@ class KCONFIGCORE_EXPORT KConfigSkeletonItem void setGroup(const QString &_group); /** - * Return config file group. + * Return name of config file group. */ QString group() const; @@ -77,10 +77,10 @@ class KCONFIGCORE_EXPORT KConfigSkeletonItem void setGroup(const KConfigGroup &cg); /** - * Return a KConfigGroup, the one provided by setGroup(KConfigGroup) if it's valid, - * or make one from @param config and item's group - * @sa setGroup(const QString &_group) - * @sa setGroup(KConfigGroup cg) + * Return a KConfigGroup, the one provided by setGroup(const KConfigGroup&) if it's valid, + * or make one from @p config and item's group. + * @see setGroup(const QString &_group) + * @see setGroup(KConfigGroup cg) * @since 5.68 */ KConfigGroup configGroup(KConfig *config) const; @@ -106,48 +106,51 @@ class KCONFIGCORE_EXPORT KConfigSkeletonItem QString name() const; /** - Set label providing a translated one-line description of the item. - */ + * Set label providing a translated one-line description of the item. + */ void setLabel(const QString &l); /** - Return label of item. See setLabel(). - */ + * Return the label of the item. + * @see setLabel() + */ QString label() const; /** - Set ToolTip description of item. - @since 4.2 - */ + * Set ToolTip description of item. + * @since 4.2 + */ void setToolTip(const QString &t); /** - Return ToolTip description of item. See setToolTip(). - @since 4.2 - */ + * Return ToolTip description of item. + * @see setToolTip() + * @since 4.2 + */ QString toolTip() const; /** - Set WhatsThis description of item. - */ + * Set WhatsThis description of item. + */ void setWhatsThis(const QString &w); /** - Return WhatsThis description of item. See setWhatsThis(). - */ + * Return WhatsThis description of item. + * @see setWhatsThis() + */ QString whatsThis() const; /** - The write flags to be used when writing configuration. - @since 5.58 - */ + * The write flags to be used when writing configuration. + * @since 5.58 + */ void setWriteFlags(KConfigBase::WriteConfigFlags flags); /** - Return write flags to be used when writing configuration. - They should be passed to every call of writeEntry() and revertToDefault(). - @since 5.58 - */ + * Return write flags to be used when writing configuration. + * They should be passed to every call of KConfigGroup::writeEntry() and KConfigGroup::revertToDefault(). + * @since 5.58 + */ KConfigBase::WriteConfigFlags writeFlags() const; /** @@ -159,7 +162,7 @@ class KCONFIGCORE_EXPORT KConfigSkeletonItem /** * This function is called by @ref KCoreConfigSkeleton to write the value of this setting * to a config file. - * Make sure to pass writeFlags() to every call of writeEntry() and revertToDefault(). + * Make sure to pass writeFlags() to every call of KConfigGroup::writeEntry() and KConfigGroup::revertToDefault(). */ virtual void writeConfig(KConfig *) = 0; @@ -174,13 +177,13 @@ class KCONFIGCORE_EXPORT KConfigSkeletonItem virtual void setProperty(const QVariant &p) = 0; /** - * Check whether the item is equal to p. + * Check whether the item is equal to @p p. * * Use this function to compare items that use custom types, * because QVariant::operator== will not work for those. * * @param p QVariant to compare to - * @return true if the item is equal to p, false otherwise + * @return @c true if the item is equal to @p p, @c false otherwise */ virtual bool isEqual(const QVariant &p) const = 0; @@ -240,7 +243,7 @@ class KCONFIGCORE_EXPORT KConfigSkeletonItem explicit KConfigSkeletonItem(KConfigSkeletonItemPrivate &dd, const QString &_group, const QString &_key); /** - * sets mIsImmutable to true if mKey in config is immutable + * Sets mIsImmutable to @c true if mKey in config is immutable. * @param group KConfigGroup to check if mKey is immutable in */ void readImmutability(const KConfigGroup &group); @@ -314,15 +317,18 @@ class KCONFIGCORE_EXPORT KPropertySkeletonItem : public KConfigSkeletonItem }; /** - * \class KConfigSkeletonGenericItem kcoreconfigskeleton.h + * \class KConfigSkeletonGenericItem kcoreconfigskeleton.h + * + * @short Base class for storing a preferences setting of type @p T. */ template class KConfigSkeletonGenericItem : public KConfigSkeletonItem { public: - /** @copydoc KConfigSkeletonItem(const QString&, const QString&) - @param reference The initial value to hold in the item - @param defaultValue The default value for the item + /** + * @copydoc KConfigSkeletonItem(const QString&, const QString&) + * @param reference The initial value to hold in the item + * @param defaultValue The default value for the item */ KConfigSkeletonGenericItem(const QString &_group, const QString &_key, T &reference, T defaultValue) : KConfigSkeletonItem(_group, _key) @@ -366,15 +372,15 @@ class KConfigSkeletonGenericItem : public KConfigSkeletonItem } /** - Set default value for this item. - */ + * Set default value for this item. + */ virtual void setDefaultValue(const T &v) { mDefault = v; } /** - Set the value for this item to the default value + * Set the value for this item to the default value */ void setDefault() override { @@ -422,14 +428,14 @@ class KConfigSkeletonGenericItem : public KConfigSkeletonItem * \class KConfigSkeletonChangeNotifyingItem kcoreconfigskeleton.h * * @author Alex Richardson - * @see KConfigSkeletonItem - * * * This class wraps a @ref KConfigSkeletonItem and invokes a function whenever the value changes. * That function must take one quint64 parameter. Whenever the property value of the wrapped KConfigSkeletonItem * changes this function will be invoked with the stored user data passed in the constructor. - * It does not call a function with the new value since this class is designed solely for the kconfig_compiler generated + * It does not call a function with the new value since this class is designed solely for the \ref kconfig_compiler generated * code and is therefore probably not suited for any other usecases. + * + * @see KConfigSkeletonItem */ class KCONFIGCORE_EXPORT KConfigCompilerSignallingItem : public KConfigSkeletonItem { @@ -484,7 +490,6 @@ class KCONFIGCORE_EXPORT KConfigCompilerSignallingItem : public KConfigSkeletonI * * @short Class for handling preferences settings for an application. * @author Cornelius Schumacher - * @see KConfigSkeletonItem * * This class provides an interface to preferences settings. Preferences items * can be registered by the addItem() function corresponding to the data type of @@ -537,6 +542,8 @@ class KCONFIGCORE_EXPORT KConfigCompilerSignallingItem : public KConfigSkeletonI * generate the C++ code from an XML description of the configuration options. * * Use KConfigSkeleton if you need GUI types as well. + * + * @see KConfigSkeletonItem */ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject { @@ -548,27 +555,16 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject class KCONFIGCORE_EXPORT ItemString : public KConfigSkeletonGenericItem { public: + /** The type of string that is held in this item */ enum Type { - Normal, - Password, - Path, + Normal, ///< A normal string + Password, ///< A password string + Path, ///< A path to a file or directory }; - /** @enum Type - The type of string that is held in this item - - @var ItemString::Type ItemString::Normal - A normal string - - @var ItemString::Type ItemString::Password - A password string - - @var ItemString::Type ItemString::Path - A path to a file or directory - */ - - /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem - @param type The type of string held by the item + /** + * @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem + * @param type The type of string held by the item */ ItemString(const QString &_group, const QString &_key, @@ -622,8 +618,7 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject class KCONFIGCORE_EXPORT ItemUrl : public KConfigSkeletonGenericItem { public: - /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem - */ + /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ ItemUrl(const QString &_group, const QString &_key, QUrl &reference, const QUrl &defaultValue = QUrl()); /** @copydoc KConfigSkeletonItem::writeConfig(KConfig*) */ @@ -710,13 +705,15 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject /** Get the maximum value this is allowed to be stored in this item */ QVariant maxValue() const override; - /** Set the minimum value for the item - @sa minValue() + /** + * Set the minimum value for the item. + * @see minValue() */ void setMinValue(qint32); - /** Set the maximum value for the item - @sa maxValue + /** + * Set the maximum value for the item. + * @see maxValue */ void setMaxValue(qint32); @@ -783,9 +780,10 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject QString whatsThis; }; - /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem - @param choices The list of enums that can be stored in this item - */ + /** + * @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem + * @param choices The list of enums that can be stored in this item + */ ItemEnum(const QString &_group, const QString &_key, qint32 &reference, const QList &choices, qint32 defaultValue = 0); QList choices() const; @@ -802,12 +800,12 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject QList choices2() const; /** - * Returns the value for for the choice with the given name + * Returns the value for for the choice with the given @p name */ QString valueForChoice(const QString &name) const; /** - * Stores a choice value for name + * Stores a choice value for @p name */ void setValueForChoice(const QString &name, const QString &valueForChoice); @@ -1204,15 +1202,16 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject QString currentGroup() const; /** - * Register a custom @ref KConfigSkeletonItem with a given name. + * Register a custom @ref KConfigSkeletonItem @p item with a given @p name. + * + * If @p name is a null string, take the name from KConfigSkeletonItem::key(). * - * If the name parameter is null, take the name from KConfigSkeletonItem::key(). - * Note that all names must be unique but that multiple entries can have + * @note All names must be unique but multiple entries can have * the same key if they reside in different groups. * - * KCoreConfigSkeleton takes ownership of the KConfigSkeletonItem. + * KCoreConfigSkeleton takes ownership of @p item. */ - void addItem(KConfigSkeletonItem *, const QString &name = QString()); + void addItem(KConfigSkeletonItem *item, const QString &name = QString()); /** * Register an item of type QString. @@ -1222,7 +1221,7 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject * calls and read by save() calls. * @param defaultValue Default value, which is used when the config file * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. + * @param key Key used in config file. If @p key is a null string, @p name is used as key. * @return The created item */ ItemString *addItemString(const QString &name, @@ -1232,37 +1231,40 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject /** * Register a password item of type QString. The string value is written - * encrypted to the config file. Note that the current encryption scheme - * is very weak. + * encrypted to the config file. + * + * @note The current encryption scheme is very weak. * * @param name Name used to identify this setting. Names must be unique. * @param reference Pointer to the variable, which is set by readConfig() * calls and read by save() calls. * @param defaultValue Default value, which is used when the config file * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. + * @param key Key used in config file. If @p key is a null string, @p name is used as key. * @return The created item */ ItemPassword *addItemPassword(const QString &name, QString &reference, const QString &defaultValue = QLatin1String(""), const QString &key = QString()); /** * Register a path item of type QString. The string value is interpreted - * as a path. This means, dollar expension is activated for this value, so - * that e.g. $HOME gets expanded. + * as a path. This means, dollar expansion is activated for this value, so + * that e.g. @c $HOME gets expanded. * * @param name Name used to identify this setting. Names must be unique. * @param reference Pointer to the variable, which is set by readConfig() * calls and read by save() calls. * @param defaultValue Default value, which is used when the config file * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. + * @param key Key used in config file. If @p key is a null string, @p name is used as key. * @return The created item */ ItemPath *addItemPath(const QString &name, QString &reference, const QString &defaultValue = QLatin1String(""), const QString &key = QString()); /** - * Register a property item of type QVariant. Note that only the following - * QVariant types are allowed: String, StringList, Font, Point, Rect, Size, + * Register a property item of type QVariant. + * + * @note The following QVariant types are allowed: + * String, StringList, Font, Point, Rect, Size, * Color, Int, UInt, Bool, Double, DateTime and Date. * * @param name Name used to identify this setting. Names must be unique. @@ -1270,58 +1272,58 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject * calls and read by save() calls. * @param defaultValue Default value, which is used when the config file * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. + * @param key Key used in config file. If @p key is a null string, @p name is used as key. * @return The created item */ ItemProperty *addItemProperty(const QString &name, QVariant &reference, const QVariant &defaultValue = QVariant(), const QString &key = QString()); /** - * Register an item of type bool. + * Register an item of type @c bool. * * @param name Name used to identify this setting. Names must be unique. * @param reference Pointer to the variable, which is set by readConfig() * calls and read by save() calls. * @param defaultValue Default value, which is used when the config file * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. + * @param key Key used in config file. If @p key is a null string, @p name is used as key. * @return The created item */ ItemBool *addItemBool(const QString &name, bool &reference, bool defaultValue = false, const QString &key = QString()); /** - * Register an item of type qint32. + * Register an item of type @c qint32. * * @param name Name used to identify this setting. Names must be unique. * @param reference Pointer to the variable, which is set by readConfig() * calls and read by save() calls. * @param defaultValue Default value, which is used when the config file * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. + * @param key Key used in config file. If @p key is a null string, @p name is used as key. * @return The created item */ ItemInt *addItemInt(const QString &name, qint32 &reference, qint32 defaultValue = 0, const QString &key = QString()); /** - * Register an item of type quint32. + * Register an item of type @c quint32. * * @param name Name used to identify this setting. Names must be unique. * @param reference Pointer to the variable, which is set by readConfig() * calls and read by save() calls. * @param defaultValue Default value, which is used when the config file * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. + * @param key Key used in config file. If @p key is a null string, @p name is used as key. * @return The created item */ ItemUInt *addItemUInt(const QString &name, quint32 &reference, quint32 defaultValue = 0, const QString &key = QString()); /** - * Register an item of type qint64. + * Register an item of type @c qint64. * * @param name Name used to identify this setting. Names must be unique. * @param reference Pointer to the variable, which is set by readConfig() * calls and read by save() calls. * @param defaultValue Default value, which is used when the config file * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. + * @param key Key used in config file. If @p key is a null string, @p name is used as key. * @return The created item */ ItemLongLong *addItemLongLong(const QString &name, qint64 &reference, qint64 defaultValue = 0, const QString &key = QString()); @@ -1335,14 +1337,14 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject #endif /** - * Register an item of type quint64 + * Register an item of type @c quint64. * * @param name Name used to identify this setting. Names must be unique. * @param reference Pointer to the variable, which is set by readConfig() * calls and read by save() calls. * @param defaultValue Default value, which is used when the config file * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. + * @param key Key used in config file. If @p key is a null string, @p name is used as key. * @return The created item */ ItemULongLong *addItemULongLong(const QString &name, quint64 &reference, quint64 defaultValue = 0, const QString &key = QString()); @@ -1356,14 +1358,14 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject #endif /** - * Register an item of type double. + * Register an item of type @c double. * * @param name Name used to identify this setting. Names must be unique. * @param reference Pointer to the variable, which is set by readConfig() * calls and read by save() calls. * @param defaultValue Default value, which is used when the config file * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. + * @param key Key used in config file. If @p key is a null string, @p name is used as key. * @return The created item */ ItemDouble *addItemDouble(const QString &name, double &reference, double defaultValue = 0.0, const QString &key = QString()); @@ -1376,7 +1378,7 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject * calls and read by save() calls. * @param defaultValue Default value, which is used when the config file * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. + * @param key Key used in config file. If @p key is a null string, @p name is used as key. * @return The created item */ ItemRect *addItemRect(const QString &name, QRect &reference, const QRect &defaultValue = QRect(), const QString &key = QString()); @@ -1389,7 +1391,7 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject * calls and read by save() calls. * @param defaultValue Default value, which is used when the config file * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. + * @param key Key used in config file. If @p key is a null string, @p name is used as key. * @return The created item */ ItemPoint *addItemPoint(const QString &name, QPoint &reference, const QPoint &defaultValue = QPoint(), const QString &key = QString()); @@ -1402,7 +1404,7 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject * calls and read by save() calls. * @param defaultValue Default value, which is used when the config file * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. + * @param key Key used in config file. If @p key is a null string, @p name is used as key. * @return The created item */ ItemSize *addItemSize(const QString &name, QSize &reference, const QSize &defaultValue = QSize(), const QString &key = QString()); @@ -1415,7 +1417,7 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject * calls and read by save() calls. * @param defaultValue Default value, which is used when the config file * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. + * @param key Key used in config file. If @p key is a null string, @p name is used as key. * @return The created item */ ItemDateTime *addItemDateTime(const QString &name, QDateTime &reference, const QDateTime &defaultValue = QDateTime(), const QString &key = QString()); @@ -1428,7 +1430,7 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject * calls and read by save() calls. * @param defaultValue Default value, which is used when the config file * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. + * @param key Key used in config file. If @p key is a null string, @p name is used as key. * @return The created item */ ItemStringList * @@ -1442,7 +1444,7 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject * calls and read by save() calls. * @param defaultValue Default value, which is used when the config file * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. + * @param key Key used in config file. If @p key is a null string, @p name is used as key. * @return The created item */ ItemIntList *addItemIntList(const QString &name, QList &reference, const QList &defaultValue = QList(), const QString &key = QString()); @@ -1504,8 +1506,8 @@ class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject * usrUseDefaults() directly. * If you don't have control whether useDefaults() or usrUseDefaults() is * called override useDefaults() directly. - * @param b true to make this object reflect the default values, - * false to make it reflect the actual values. + * @param b @c true to make this object reflect the default values, + * @c false to make it reflect the actual values. * @return The state prior to this call */ virtual bool useDefaults(bool b); @@ -1542,8 +1544,8 @@ public Q_SLOTS: * Implemented by subclasses that use special defaults. * It replaces the default values with the actual values and * vice versa. Called from @ref useDefaults() - * @param b true to make this object reflect the default values, - * false to make it reflect the actual values. + * @param b @c true to make this object reflect the default values, + * @c false to make it reflect the actual values. * @return The state prior to this call */ virtual bool usrUseDefaults(bool b); diff --git a/src/gui/kconfigskeleton.h b/src/gui/kconfigskeleton.h index 3f0aec87..fbf59bfe 100644 --- a/src/gui/kconfigskeleton.h +++ b/src/gui/kconfigskeleton.h @@ -23,7 +23,6 @@ * @author Cornelius Schumacher * * This class extends KCoreConfigSkeleton by support for GUI types. - * */ class KCONFIGGUI_EXPORT KConfigSkeleton : public KCoreConfigSkeleton { @@ -97,7 +96,7 @@ class KCONFIGGUI_EXPORT KConfigSkeleton : public KCoreConfigSkeleton * calls and read by save() calls. * @param defaultValue Default value, which is used when the config file * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. + * @param key Key used in config file. If @p key is a null string, @p name is used as key. * @return The created item */ ItemColor *addItemColor(const QString &name, QColor &reference, const QColor &defaultValue = QColor(128, 128, 128), const QString &key = QString()); @@ -110,7 +109,7 @@ class KCONFIGGUI_EXPORT KConfigSkeleton : public KCoreConfigSkeleton * calls and read by save() calls. * @param defaultValue Default value, which is used when the config file * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. + * @param key Key used in config file. If @p key is a null string, @p name is used as key. * @return The created item */ ItemFont *addItemFont(const QString &name, QFont &reference, const QFont &defaultValue = QFont(), const QString &key = QString()); From 8c3501262cb161ecb8a12e4c1fbae98ed9d11540 Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Fri, 11 Feb 2022 16:09:18 +0100 Subject: [PATCH 253/259] API dox: fix class name & CC include of KConfigCompilerSignallingItem NO_CHANGELOG --- src/core/kcoreconfigskeleton.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/kcoreconfigskeleton.h b/src/core/kcoreconfigskeleton.h index aae57487..69b5263a 100644 --- a/src/core/kcoreconfigskeleton.h +++ b/src/core/kcoreconfigskeleton.h @@ -425,7 +425,7 @@ class KConfigSkeletonGenericItem : public KConfigSkeletonItem }; /** - * \class KConfigSkeletonChangeNotifyingItem kcoreconfigskeleton.h + * \class KConfigCompilerSignallingItem kcoreconfigskeleton.h * * @author Alex Richardson * From a19011fce0012a27a22cba2de1d65baeabbfbf29 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Fri, 11 Feb 2022 13:33:38 +0100 Subject: [PATCH 254/259] Add KConfig GUI logging category Signed-off-by: Eike Hein --- src/gui/CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 403b0367..c7474893 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -13,6 +13,14 @@ target_sources(KF5ConfigGui PRIVATE kwindowconfig.cpp ) +ecm_qt_declare_logging_category(KF5ConfigGui + HEADER kconfig_gui_log_settings.h + IDENTIFIER KCONFIG_GUI_LOG + CATEGORY_NAME kf.config.gui + DESCRIPTION "KConfig Gui" + EXPORT KCONFIG +) + ecm_generate_export_header(KF5ConfigGui BASE_NAME KConfigGui GROUP_BASE_NAME KF From 7cbdd55960b36b967f2b62c6bacdcde8807c88fd Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Fri, 11 Feb 2022 13:41:37 +0100 Subject: [PATCH 255/259] Support build without Qt session manager Rather than abort the build, don't create a session config and print a warning. Signed-off-by: Eike Hein --- src/gui/kconfiggui.cpp | 6 ++++-- src/gui/kconfiggui.h | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gui/kconfiggui.cpp b/src/gui/kconfiggui.cpp index cafe061d..f8132f9e 100644 --- a/src/gui/kconfiggui.cpp +++ b/src/gui/kconfiggui.cpp @@ -6,6 +6,7 @@ */ #include "kconfiggui.h" +#include "kconfig_gui_log_settings.h" #include @@ -21,13 +22,14 @@ static KConfig *s_sessionConfig = nullptr; KConfig *KConfigGui::sessionConfig() { #ifdef QT_NO_SESSIONMANAGER -#error QT_NO_SESSIONMANAGER was set, this will not compile. Reconfigure Qt with Session management support. -#endif + qCWarning(KCONFIG_GUI_LOG) << "Qt is built without session manager support"; +#else if (!hasSessionConfig() && qApp->isSessionRestored()) { // create the default instance specific config object // from applications' -session command line parameter s_sessionConfig = new KConfig(configName(qApp->sessionId(), qApp->sessionKey()), KConfig::SimpleConfig); } +#endif return s_sessionConfig; } diff --git a/src/gui/kconfiggui.h b/src/gui/kconfiggui.h index 8f4b739a..33082d83 100644 --- a/src/gui/kconfiggui.h +++ b/src/gui/kconfiggui.h @@ -22,6 +22,10 @@ namespace KConfigGui /** * Returns the current application session config object. * + * @note If Qt is built without session manager support, + * this by default will return nullptr, unless a custom config + * has been set via @c setSessionConfig. + * * @return A pointer to the application's instance specific * KConfig object. * @see KConfig From 1a8fc4c9064f9e0a44ba37c1667e04ce0df655a8 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Fri, 11 Feb 2022 13:41:37 +0100 Subject: [PATCH 256/259] Support build without Qt session manager Rather than abort the build, don't create a session config and print a warning. Signed-off-by: Eike Hein --- src/gui/kconfiggui.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gui/kconfiggui.h b/src/gui/kconfiggui.h index 33082d83..b030c977 100644 --- a/src/gui/kconfiggui.h +++ b/src/gui/kconfiggui.h @@ -22,9 +22,10 @@ namespace KConfigGui /** * Returns the current application session config object. * - * @note If Qt is built without session manager support, - * this by default will return nullptr, unless a custom config - * has been set via @c setSessionConfig. + * @note If Qt is built without session manager support, i.e. + * QT_NO_SESSIONMANAGER is defined, this by default will return + * nullptr, unless a custom config has been set via + * @c setSessionConfig. * * @return A pointer to the application's instance specific * KConfig object. From 82a75d993b7c4ac5a48795183334045fafe8f25a Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Sun, 13 Feb 2022 19:03:53 +0100 Subject: [PATCH 257/259] QMake pri files: fix missing new path to version header --- src/core/CMakeLists.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 61113253..7bed316b 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -108,5 +108,13 @@ set(KConfigCore_APIDOX_SRCS ${KConfigCore_HEADERS} PARENT_SCOPE) set(KConfigCore_APIDOX_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE) include(ECMGeneratePriFile) -ecm_generate_pri_file(BASE_NAME KConfigCore LIB_NAME KF5ConfigCore DEPS "core" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF}/KConfigCore) +ecm_generate_pri_file( + BASE_NAME KConfigCore + LIB_NAME KF5ConfigCore + DEPS "core" + FILENAME_VAR PRI_FILENAME + INCLUDE_INSTALL_DIRS + ${KDE_INSTALL_INCLUDEDIR_KF}/KConfig + ${KDE_INSTALL_INCLUDEDIR_KF}/KConfigCore +) install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) From 17364e0942543329b8317aed79580b7840134287 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Wed, 16 Feb 2022 19:44:38 +0000 Subject: [PATCH 258/259] GIT_SILENT Upgrade KF version to 5.92.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 28c67e45..32454e1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.16) -set(KF_VERSION "5.91.0") # handled by release scripts +set(KF_VERSION "5.92.0") # handled by release scripts project(KConfig VERSION ${KF_VERSION}) include(FeatureSummary) From 828f52439fb02f224cc034e65dd82a0138a60662 Mon Sep 17 00:00:00 2001 From: Alexander Lohnau Date: Tue, 1 Feb 2022 18:17:02 +0100 Subject: [PATCH 259/259] KConfigPropertyMap: Clean up internal leftovers of autosave feature This has should be done explicitely, as the docs explain. This causes issues for the KScreenLocker KCM port. --- src/qml/kconfigpropertymap.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/qml/kconfigpropertymap.cpp b/src/qml/kconfigpropertymap.cpp index 55b2991d..f31b09c7 100644 --- a/src/qml/kconfigpropertymap.cpp +++ b/src/qml/kconfigpropertymap.cpp @@ -34,7 +34,6 @@ class KConfigPropertyMapPrivate KConfigPropertyMap *q; QPointer config; bool updatingConfigValue = false; - bool autosave = true; bool notify = false; }; @@ -122,11 +121,6 @@ void KConfigPropertyMapPrivate::writeConfig() item->setProperty(q->value(item->key())); } - if (autosave) { - updatingConfigValue = true; - config.data()->save(); - updatingConfigValue = false; - } } void KConfigPropertyMapPrivate::writeConfigValue(const QString &key, const QVariant &value) @@ -136,12 +130,6 @@ void KConfigPropertyMapPrivate::writeConfigValue(const QString &key, const QVari updatingConfigValue = true; item->setWriteFlags(notify ? KConfigBase::Notify : KConfigBase::Normal); item->setProperty(value); - if (autosave) { - config.data()->save(); - // why read? read will update KConfigSkeletonItem::mLoadedValue, - // allowing a write operation to be performed next time - config.data()->read(); - } updatingConfigValue = false; } }