From d12a16da669ad0a2cd7ad12025c41d947ba2d268 Mon Sep 17 00:00:00 2001 From: Cyril Anisimov Date: Tue, 1 Oct 2024 03:41:01 +0200 Subject: [PATCH] handle flickable separately --- client/ui/controllers/focusController.cpp | 32 ++++++++++++----------- client/ui/qml/Controls2/HeaderType.qml | 2 +- client/ui/qml/Pages2/PageSettings.qml | 14 ++++++++++ 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/client/ui/controllers/focusController.cpp b/client/ui/controllers/focusController.cpp index 161333414..09aa850d2 100644 --- a/client/ui/controllers/focusController.cpp +++ b/client/ui/controllers/focusController.cpp @@ -89,34 +89,36 @@ bool isEnabled(QObject* obj) return item && item->isEnabled(); } -QQuickItem* getPageOfItem(QQuickItem* item) // TODO: remove? +bool hasFlickableParent(QObject* object) { - if(!item) { - qWarning() << "item is null"; - return {}; + if(!object) { + return false; } - const auto pagePattern = QString::fromLatin1("Page"); - QString className{item->metaObject()->className()}; - const auto isPage = className.contains(pagePattern, Qt::CaseSensitive); - if(isPage) { - return item; + + const auto parentObject = object->parent(); + const auto parentItem = qobject_cast(parentObject); + if(parentItem && parentItem->inherits("QQuickFlickable")) { + return true; + qDebug() << "===>> ITEM is FLICKABLE"; } else { - return getPageOfItem(item->parentItem()); + return hasFlickableParent(parentObject); } } -QList getSubChain(QObject* item) +QList getSubChain(QObject* object) { QList res; - if (!item) { - qDebug() << "null top item"; + if (!object) { + qDebug() << "Top object is NULL"; return res; } - const auto children = item->children(); + + const auto children = object->children(); + for(const auto child : children) { if (child && isFocusable(child) - && (isOnTheScene(child)) + && (isOnTheScene(child) || hasFlickableParent(child)) && isEnabled(child) ) { res.append(child); diff --git a/client/ui/qml/Controls2/HeaderType.qml b/client/ui/qml/Controls2/HeaderType.qml index f1cafbff7..03614067c 100644 --- a/client/ui/qml/Controls2/HeaderType.qml +++ b/client/ui/qml/Controls2/HeaderType.qml @@ -19,7 +19,7 @@ Item { property string descriptionText - focus: true + // focus: true implicitWidth: content.implicitWidth implicitHeight: content.implicitHeight diff --git a/client/ui/qml/Pages2/PageSettings.qml b/client/ui/qml/Pages2/PageSettings.qml index 65c696c73..50d104663 100644 --- a/client/ui/qml/Pages2/PageSettings.qml +++ b/client/ui/qml/Pages2/PageSettings.qml @@ -48,6 +48,8 @@ PageType { rightImageSource: "qrc:/images/controls/chevron-right.svg" leftImageSource: "qrc:/images/controls/server.svg" + parentFlickable: fl + clickedFunction: function() { PageController.goToPage(PageEnum.PageSettingsServersList) } @@ -63,6 +65,8 @@ PageType { rightImageSource: "qrc:/images/controls/chevron-right.svg" leftImageSource: "qrc:/images/controls/radio.svg" + parentFlickable: fl + clickedFunction: function() { PageController.goToPage(PageEnum.PageSettingsConnection) } @@ -78,6 +82,8 @@ PageType { rightImageSource: "qrc:/images/controls/chevron-right.svg" leftImageSource: "qrc:/images/controls/app.svg" + parentFlickable: fl + clickedFunction: function() { PageController.goToPage(PageEnum.PageSettingsApplication) } @@ -93,6 +99,8 @@ PageType { rightImageSource: "qrc:/images/controls/chevron-right.svg" leftImageSource: "qrc:/images/controls/save.svg" + parentFlickable: fl + clickedFunction: function() { PageController.goToPage(PageEnum.PageSettingsBackup) } @@ -108,6 +116,8 @@ PageType { rightImageSource: "qrc:/images/controls/chevron-right.svg" leftImageSource: "qrc:/images/controls/amnezia.svg" + parentFlickable: fl + clickedFunction: function() { PageController.goToPage(PageEnum.PageSettingsAbout) } @@ -124,6 +134,8 @@ PageType { rightImageSource: "qrc:/images/controls/chevron-right.svg" leftImageSource: "qrc:/images/controls/bug.svg" + parentFlickable: fl + clickedFunction: function() { PageController.goToPage(PageEnum.PageDevMenu) } @@ -143,6 +155,8 @@ PageType { rightImageSource: "qrc:/images/controls/chevron-right.svg" leftImageSource: "qrc:/images/controls/x-circle.svg" + parentFlickable: fl + clickedFunction: function() { PageController.closeApplication() }