Skip to content

Commit

Permalink
handle flickable separately
Browse files Browse the repository at this point in the history
  • Loading branch information
CyAn84 committed Oct 1, 2024
1 parent 2eaad6a commit d12a16d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
32 changes: 17 additions & 15 deletions client/ui/controllers/focusController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<QQuickItem*>(parentObject);
if(parentItem && parentItem->inherits("QQuickFlickable")) {
return true;
qDebug() << "===>> ITEM is FLICKABLE";
} else {
return getPageOfItem(item->parentItem());
return hasFlickableParent(parentObject);
}
}

QList<QObject*> getSubChain(QObject* item)
QList<QObject*> getSubChain(QObject* object)
{
QList<QObject*> 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);
Expand Down
2 changes: 1 addition & 1 deletion client/ui/qml/Controls2/HeaderType.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Item {

property string descriptionText

focus: true
// focus: true

implicitWidth: content.implicitWidth
implicitHeight: content.implicitHeight
Expand Down
14 changes: 14 additions & 0 deletions client/ui/qml/Pages2/PageSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand All @@ -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)
}
Expand All @@ -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)
}
Expand All @@ -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)
}
Expand All @@ -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)
}
Expand All @@ -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()
}
Expand Down

0 comments on commit d12a16d

Please sign in to comment.