https://bugs.kde.org/show_bug.cgi?id=404146

            Bug ID: 404146
           Summary: When a QML tabbox skin fails to load, fall back to
                    "Informative" like we do when the configured file does
                    not exist
           Product: kwin
           Version: unspecified
          Platform: Other
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: tabbox
          Assignee: kwin-bugs-n...@kde.org
          Reporter: zrenf...@gmail.com
  Target Milestone: ---

Issue was raised when discussing the workaround in
https://phabricator.kde.org/T10464

The relevant code is at:
*
https://github.com/KDE/kwin/blob/cfecb1e0770ca6c8fa879124e11b03081342b9ed/tabbox/tabboxhandler.cpp#L281

1. It first checks if a
"plasma/look-and-feel/%1/contents/windowswitcher/WindowSwitcher.qml" file
exists and uses that.
2. If not, it looks for a "kwin/tabbox/%1/contents/ui/main.qml"
3. Then it uses the hardcoded "informative" QML file
"kwin/tabbox/informative/contents/ui/main.qml" as a fallback (I always wondered
why it was using informative when I selected certain "look and feel" skins).

So it seems we need a new function perform the QML loading stuff which returns
a `QObject` or `nullptr`. Something like this:


        QObject *TabBoxHandlerPrivate::loadSwitcherItem(QString file)
        {
                if (file.isNull()) {
                        m_qmlComponent->loadUrl(QUrl::fromLocalFile(file));
                        if (m_qmlComponent->isError()) {
                                m_qmlComponent.reset(...) // ???
                                return nullptr;
                        } else {
                                QObject *object =
m_qmlComponent->create(m_qmlContext.data());
                                return object
                        }
                }
        }

        QObject *TabBoxHandlerPrivate::createSwitcherItem(bool desktopMode)
        {
                QString lookAndFeelFilepath = desktopMode ? ... : ...
                QString file = lookAndFeelFilepath;
                QObject *object = loadSwitcherItem(file);
                if (object != nullptr) {
                        return object;
                }

                QString tabboxFilepath = ...
                QString file = tabboxFilepath;
                QObject *object = loadSwitcherItem(file);
                if (object != nullptr) {
                        return object;
                }

                QString informativeTabboxFilepath = ...
                QString file = informativeTabboxFilepath;
                QObject *object = loadSwitcherItem(file);
                if (object != nullptr) {
                        QStringList args;
                        args << QStringLiteral("The Window Switcher failed to
load, using Informative")
                        KProcess::startDetached(QStringLiteral("kdialog"),
args);

                        return object;
                } else {
                        QStringList args;
                        args << QStringLiteral("The Window Switcher
installation is broken, resources are missing.\nContact your distribution about
this")
                        KProcess::startDetached(QStringLiteral("kdialog"),
args);

                        return nullptr;
                }
        }

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to