Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebase KConfig upstream #24

Draft
wants to merge 260 commits into
base: master
Choose a base branch
from

Conversation

mpranj
Copy link
Member

@mpranj mpranj commented Feb 17, 2022

Merged upstream (828f524).
The upstream backend seems to work (at least dolphin does).

The Elektra backend definitely needs the keyname overhaul, possibly more to work again.

croooo and others added 30 commits April 22, 2020 09:13
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
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
qstrcmp returns 0 if two strings are equal.
…const char*)

KStandardShortcut::name returns a QString, this makes the api symmetric and more
straightforward to use.
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"
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"
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"
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
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.
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"
…ames

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.
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
…tforms

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
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
l10n daemon script and others added 30 commits January 1, 2022 12:12
This commit is an alternative to the earlier incorrect and reverted
b3dc879. 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
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.
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().
The eliminated duplication of the composite condition was error-prone
and less readable.
Instead of /usr/include/KF5/kconfig_version.h.

For more details see:
https://invent.kde.org/frameworks/kservice/-/merge_requests/79

GIT_SILENT
So that #include <kconfig_version.h> still works after changing its
location in the previous commit.

NO_CHANGELOG
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.
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
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.
Since we are not building the library but the source files we
don't want the macro to expand to __declspec(dllimport).
Rather than abort the build, don't create a session config
and print a warning.

Signed-off-by: Eike Hein <[email protected]>
Rather than abort the build, don't create a session config
and print a warning.

Signed-off-by: Eike Hein <[email protected]>
This has should be done explicitely, as the docs explain.

This causes issues for the KScreenLocker KCM port.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.