how to access signals from diferrent qml pages of different directories
-
wrote on 30 Apr 2025, 13:43 last edited by
I have scenario like , when user selects current folder, current category , navigation buttons should be disabled greyed out and enabled only for particular UI Page ,**And I have a logic for enable and disable already but i need to link this to UI page
Document.qml contains common arrow buttons
NavlogScreen.qml is the page where i have disable and enable the buttons in ui.NavigationBar.qml where we have button Nav Log after clicking this NavLogScreen will gets opened.
so I thought using the index where for buttons defined in repeater in NavigationBar.qml
but in my case, index changes based on custo files uploading,so i can compare it through button string Nav Log,but all these qml pages are in different directories structure.
so here my doubt is how can i link my enable , disable logic to particular ui page..**
here chevron_up and chevron_down arrow buttons.
DocumentsButton.qml
import QtQuick import QtQuick.Controls import QtQuick.Layouts 1.3 import QtQml.Models 2.12 import "../../../datas" import "../../../loadables" import "../../../utils/controls" import "../../../bars/NavigationFunction.js" as NavigationFunctions import onboardplus.uilibrary 1.0 Item { id: root width: BGridSystem.unit(4.5) property real buttonSpacing: 24 property bool hasPreviousSiblingDoc: Boolean(flightsDataManager.selectedEffModel && flightsDataManager.selectedEffModel.currentFileHasPreviousSiblingItem) property bool hasNextSiblingDoc: Boolean(flightsDataManager.selectedEffModel && flightsDataManager.selectedEffModel.currentFileHasNextSiblingItem) property var linkNotam : { let topic = Data.screenSettings.getValue("NOTAM_Topic/NotamBriefingDocument") return flightsDataManager.selectedEffModel ? flightsDataManager.selectedEffModel.searchTreeFileFromTopic(topic) : undefined } // request opening of the navigation bar signal openNavigationBar() // request actions from buttons signal adjustSize() signal rotateRight() signal previousPage() signal nextPage() BActionPanel { id: mainButtonPanel palette.base: BColors.grey1 anchors.top: parent.top thickness: root.width spacing: BGridSystem.spacerS padding: BGridSystem.spacerS adaptSizeToContent: true edge: Qt.RightEdge attached: true height: computedFloatingHeight floatingMargins: 0 radius: 0 BStyle.shadowLevel: -100 model: ObjectModel { ToolBarButton { icon.source: checked ? BIcons["resize"] : BIcons["fullsize"] icon.color: checked ? BColors.blue : BColors.grey9 checkable: true checked: Data.maximised//TODO onClicked: Data.maximised = !Data.maximised enabled: DocumentControl.usedControls & Enum.DocumentControl.ButtonFullSize//TODO visible: enabled } ToolBarButton { icon.source: "qrc:/effApplication/assets/icons/icon-adjust-to-file-size.svg" onClicked: adjustSize() visible: enabled enabled: (DocumentControl.usedControls & Enum.DocumentControl.ButtonAdjustSize) && Boolean(flightsDataManager.selectedEffModel && !flightsDataManager.selectedEffModel.isLattPage(flightsDataManager.selectedEffModel.selectedItem) && !flightsDataManager.selectedEffModel.isRestPage(flightsDataManager.selectedEffModel.selectedItem)) } ToolBarButton { icon.source: BIcons["rotate_right"] onClicked: rotateRight() visible: enabled enabled: DocumentControl.usedControls & Enum.DocumentControl.ButtonRotate } ToolBarButton { icon.source: BIcons["arrow_up"] onClicked: previousPage() visible: enabled enabled: DocumentControl.usedControls & Enum.DocumentControl.ButtonsNextPreviousPage } BText { id: pageCount objectName: "pdfPageCount" anchors.horizontalCenter: parent.horizontalCenter text: (DocumentControl.currentIndex+1) + "/" + DocumentControl.pageNumber visible: enabled enabled: DocumentControl.usedControls & Enum.DocumentControl.ButtonsNextPreviousPage } ToolBarButton { icon.source: BIcons["arrow_down"] onClicked: nextPage() visible: enabled enabled: DocumentControl.usedControls & Enum.DocumentControl.ButtonsNextPreviousPage } ToolBarButton { id: allNotamBtn leftPadding: -16 rightPadding: -16 display: AbstractButton.IconOnly icon.source: BIcons["view_all"] visible: enabled enabled: DocumentControl.usedControls & Enum.DocumentControl.ButtonShowAllNotam onClicked: { if (root.linkNotam) { flightsDataManager.selectedEffModel.displayDocumentFromTreeFile(root.linkNotam) } } } BDivider { width: BGridSystem.unit(2.5) enabled: restoreBtn.enabled || deleteBtn.enabled || checkBtn.enabled visible: enabled } ToolBarButton { id: restoreBtn width: 56 leftPadding: -16 rightPadding: -16 height: 66 display: AbstractButton.TextUnderIcon icon.source: BIcons["reset"] onClicked: flightsDataManager.selectedEffModel.restoreDocument(flightsDataManager.selectedEffModel.selectedItem) text: Data.custo.getLabel("screens_DocumentScreen/squareButtonRestore") enabled: flightsDataManager.selectedEffModel ? flightsDataManager.selectedEffModel.restorable(flightsDataManager.selectedEffModel.selectedItem) : false visible: enabled } ToolBarButton { id: deleteBtn width: 56 leftPadding: -16 rightPadding: -16 height: 66 display: AbstractButton.TextUnderIcon icon.source: BIcons["delete_bin"] text: Data.custo.getLabel("screens_DocumentScreen/squareButtonDelete") onClicked: { var callOpenNavigationBar = false; if (!root.hasNextSiblingDoc && !root.hasPreviousSiblingDoc) callOpenNavigationBar = true flightsDataManager.selectedEffModel.deleteDocument(flightsDataManager.selectedEffModel.selectedItem) if (callOpenNavigationBar) openNavigationBar() } enabled: Boolean(flightsDataManager.selectedEffModel && flightsDataManager.selectedEffModel.deletable(flightsDataManager.selectedEffModel.selectedItem)) visible: enabled } ToolBarButton { id: checkBtn width: 56 leftPadding: -16 rightPadding: -16 height: 66 display: AbstractButton.TextUnderIcon icon.source: BIcons["check"] onClicked: flightsDataManager.selectedEffModel.doCheck(flightsDataManager.selectedEffModel.selectedItem) text: Data.custo.getLabel("screens_DocumentScreen/squareButtonCheck") enabled: Boolean(flightsDataManager.selectedEffModel && flightsDataManager.selectedEffModel.checkable(flightsDataManager.selectedEffModel.selectedItem)) visible: enabled } } content: Column { spacing: mainButtonPanel.spacing Repeater { model: mainButtonPanel.model delegate: mainButtonPanel.delegate } } } function checkIfEnableArrowButtons() { return flightsDataManager.selectedEffModel && !flightsDataManager.selectedEffModel.isNavigationRestricted && flightsDataManager.selectedEffModel.selectedItem !== undefined && flightsDataManager.selectedEffModel.selectedItem !== null } // property var linkNavLog: links.NavLogDocument BActionPanel { id: nextPreviousButtonPanel anchors.bottom: parent.bottom palette.base: BColors.grey1 anchors.bottomMargin: BGridSystem.spacerM thickness: BGridSystem.unit(4.5) spacing: BGridSystem.spacerS padding: BGridSystem.spacerS adaptSizeToContent: true edge: Qt.RightEdge attached: true height: computedFloatingHeight floatingMargins: 0 radius: 0 BStyle.shadowLevel: -100 model: ObjectModel { ToolBarButton { id: chevron_up icon.source: BIcons["chevron_up"] // icon.color: enabled ? (BColors.nightMode ? BColors.transparent : BColors.grey9) : BColors.transparencyLevelPoint5Of(BColors.grey6) enabled: checkIfEnableArrowButtons() // color: enabled ? BColors.grey5 : BColors.transparencyLevel2Of(BColors.grey5) onClicked: { flightsDataManager.selectedEffModel.displayPreviousSiblingDocument() if (flightsDataManager.selectedEffModel.openCurrentFolderDocsPanel) { Data.maximised = false openNavigationBar() } } } ToolBarButton { id: chevron_down icon.source: BIcons["chevron_down"] // icon.color: enabled ? (BColors.nightMode ? BColors.transparent : BColors.grey9) : BColors.transparencyLevelPoint5Of(BColors.grey6) enabled: checkIfEnableArrowButtons() // color: enabled ? BColors.grey5 : BColors.transparencyLevel2Of(BColors.grey5) onClicked: { flightsDataManager.selectedEffModel.displayNextSiblingDocument() if (flightsDataManager.selectedEffModel.openCurrentFolderDocsPanel) { Data.maximised = false openNavigationBar() } } } } }
}
EfbModel.h and EfbModel.cpp Q_PROPERTY(bool isNavigationRestricted READ isNavigationRestricted NOTIFY navigationRestrictionChanged) bool isNavigationRestricted() const; signals: void navigationRestrictionChanged(); bool EFBModel::isNavigationRestricted() const { QString style = missionplus::core::settings::AppSettings::getInstance().getValue("PAGE_NAVIGATION/pageNavigationStyleSelected").toString(); return (style == "Current Folder" || style == "Current Category"); } EffApplication.cpp // Set the defaultPageNavigationStyle in config depending on the selection made by the user missionplus::core::settings::AppSettings::getInstance().subscribe( "PAGE_NAVIGATION/pageNavigationStyleSelected", [=](const QString&, const QVariant& value) { if (value.isValid() && !value.toString().isEmpty()) { QVariant selectedStyle = defaultPageNavigationStyle; if (listOfPageNavigationStyles.contains(value.toString())) { selectedStyle = value; } missionplus::core::settings::AppSettings::getInstance().setValue( "FLIGHT_CONFIG_" + keyDefaultPageNavigationStyle, selectedStyle); if (_flightsdataManager && _flightsdataManager->flightDataInterface() && _flightsdataManager->flightDataInterface()->selectedEffModel()) { emit _flightsdataManager->flightDataInterface()->selectedEffModel()->navigationRestrictionChanged(); // emit _flightsdataManager->flightDataInterface()->selectedEffModel()->navLogScreenActiveChanged(); } } });
-
wrote on 30 Apr 2025, 16:37 last edited by
NavigationBar.qml
import QtQuick
import QtQuick.Layouts 1.3
import QtQml.Models 2.11
import onboardplus.uilibrary 1.0import "../datas"
import "../utils"
import "./NavigationFunction.js" as NavigationFunctions
import "qrc:/effApplication/utils/functions/ObjectUtils.js" as ObjectUtils
import QtQuick.ControlsRectangle {
id: root objectName: "NavigationBar" width: Data.portrait ? parent.width : BGridSystem.unit(4.7) height: Data.portrait ? BGridSystem.unit(4) : parent.height color: BColors.nightMode ? BColors.grey2 : BColors.lightNavBackground property var selectedEffModel: flightsDataManager.selectedEffModel //-- Properties to Highlight the current button of Navigation corresponding of selected Document //---------------------------------------------------------------------------------------------- property var selectedDocument: selectedEffModel?selectedEffModel.selectedItem:undefined property var selectedIndexLevel0: undefined property real navMenuHeight: 0 property bool doubleClickOnButton: false property var previousIndex signal navLogScreenActived() function openMenu(index) { if (menuNav.opened && selectedIndexLevel0 === index) { menuNav.close() } else { selectedIndexLevel0 = index //-- Check if the NavFolder have only one File, the NavMenu is not Opened //------------------------------------------------------------------------ var onlyOneFile = false if (selectedIndexLevel0 && selectedEffModel.rowCount(selectedIndexLevel0) === 1 && !selectedEffModel.isFolder(selectedEffModel.index(0, 0, selectedIndexLevel0))) { selectedEffModel.display(selectedEffModel.index(0, 0, selectedIndexLevel0)) onlyOneFile = true } if (!onlyOneFile) { menuNav.navOpened = true menuNav.open() } else { menuNav.close() } } } function openOtherMenu() { if (menuNav.opened && selectedIndexLevel0 === -1) menuNav.close() else { selectedIndexLevel0 = -1 menuNav.navOpened = false menuNav.open() } } function openNavigationBar() { updateIndex() var selectedIndex = NavigationFunctions.getCurrentSelectedItem(selectedEffModel, 0) if (selectedEffModel.isVirtualFolder(selectedIndex)) { root.openOtherMenu() } else { root.openMenu(selectedIndex) } console.debug("[NAV] Navigation bar opened") } //-- To Highlight the Selected Folder onSelectedDocumentChanged: { updateIndex() } function updateIndex() { selectedIndexLevel0 = NavigationFunctions.getCurrentSelectedItem(selectedEffModel, 0) if (selectedEffModel && selectedEffModel.isVirtualFolder(selectedIndexLevel0)) selectedIndexLevel0 = -1 } onSelectedEffModelChanged: { if (selectedEffModel) { updateIndex() if (menuNav.opened) { menuNav.close() } } } Flickable { id:flickable anchors.fill:parent contentHeight: aGrid.height contentWidth: aGrid.width boundsBehavior: Flickable.StopAtBounds Grid { id: aGrid rows: Data.portrait?1:0 columns: Data.portrait?0:1 Repeater { id: repeatItem model: DelegateModel { id: aModelDelegate model: ObjectUtils.exists(selectedEffModel) ? selectedEffModel : undefined delegate: BBarButton{ id: aBarButton height: BGridSystem.unit(4) width : BGridSystem.unit(4.7) visible: ObjectUtils.exists(selectedEffModel) ? selectedEffModel.isFolder(aModelDelegate.modelIndex(index)) && !selectedEffModel.isVirtualFolder(aModelDelegate.modelIndex(index)) : false icon.source: iconRole text: nameRole color: BColors.nightMode ? (selectedIndexLevel0 === aModelDelegate.modelIndex(index)) ? EFFColor.blue_secondary : BColors.grey2 : (selectedIndexLevel0 === aModelDelegate.modelIndex(index)) ? EFFColor.blue_secondary : BColors.lightNavBackground font.bold: true font.pointSize: BFonts.sizeTextUnderIcon subBarItemActive: false checked: selectedIndexLevel0 === aModelDelegate.modelIndex(index) iconSmallSize: true icon.color: BColors.nightMode ? EFFColor.grey9 : (selectedIndexLevel0 === aModelDelegate.modelIndex(index)) ? EFFColor.grey9 : EFFColor.grey5//Needed as binding does not work correctly palette.brightText: BColors.nightMode ? EFFColor.grey9 : (selectedIndexLevel0 === aModelDelegate.modelIndex(index)) ? EFFColor.grey9 : EFFColor.grey5//Needed as binding does not work correctly palette.buttonText: BColors.nightMode ? EFFColor.grey9 : (selectedIndexLevel0 === aModelDelegate.modelIndex(index)) ? EFFColor.grey9 : EFFColor.grey5 property string navLogLabel: Data.custo.getLabel("NavLog/Menu_NavLog", "Nav Log") onClicked: { root.openMenu(aModelDelegate.modelIndex(index)) console.info("NAV LOG LABEL =========================== "+navLogLabel) if(navLogLabel === "Nav Log") { root.navLogScreenActived() } // var selectedIndex = NavigationFunctions.getCurrentSelectedItem(selectedEffModel, 0) // console.info("NAV LOG index =============== "+selectedEffModel) // console.info("NAV LOG selected #####======================== "+selectedIndex) // if (aModelDelegate.modelIndex(index === 3)) { // console.info("NAV LOG selected") // Data.currentScreenIndex = 3 // console.info("NAV LOG selected2222") // } else { // Data.currentScreenIndex = index // console.info("NAV LOG selected333") // } // let selectedIdx = aModelDelegate.modelIndex(index) // console.info("NAV LOG selected ================= 9999 "+selectedIdx) // let selectedRow = selectedIdx.row // flightsDataManager.selectedEffModel.navLogIndexLevel0 = selectedRow // if (selectedRow === 3) { // console.info("NAV LOG selected") // flightsDataManager.selectedEffModel.navLogScreenActive = true // } else { // flightsDataManager.selectedEffModel.navLogScreenActive = false // } } Rectangle { id: pastille visible: model.statusRole === "New" radius: height/2 color: EFFColor.primary height: BGridSystem.unit(1) width: Math.max(countText.width + 4, height) x: BGridSystem.unit(3.25) y: BGridSystem.unit(1)-BGridSystem.dp(12) Text { id: countText anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter visible: pastille.visible && !(model.typeRole === 2) text: model.nbDocNew < 100 ? model.nbDocNew : "+99" font.family:BFonts.sourceSansPro font.bold: true font.pointSize: BFonts.sizeTextUnderIcon color: EFFColor.grey1 } } ColoredSvg { id: chevron anchors.verticalCenter: Data.portrait ? parent.bottom : parent.verticalCenter anchors.verticalCenterOffset: Data.portrait ? - BGridSystem.unit(0.25) : 0 anchors.horizontalCenter: Data.portrait ? parent.horizontalCenter : parent.right anchors.horizontalCenterOffset: Data.portrait ? 0: -height / 2 visible: parent.checked && menuNav.opened width: BGridSystem.unit(1) height: BGridSystem.unit(1) color: EFFColor.primary source: Data.portrait?"qrc:/effApplication/assets/icons/icon-chevron-down.svg":"qrc:/effApplication/assets/icons/icon-chevron-right.svg" } } } } BBarButton { id: otherButton visible: selectedEffModel?true:false height: BGridSystem.unit(4) width: BGridSystem.unit(4.7) icon.source: "qrc:/effApplication/assets/icons/icon-other.svg" text: Data.custo.getLabel("screens_NavigationScreen/labelOthers", "Others") color: BColors.nightMode ? (selectedIndexLevel0 === -1) ? EFFColor.blue_secondary : EFFColor.grey2 : (selectedIndexLevel0 === -1) ? EFFColor.blue_secondary : BColors.lightNavBackground subBarItemActive: false checked: selectedIndexLevel0 === -1 icon.color: BColors.nightMode ? EFFColor.grey9 : (selectedIndexLevel0 === -1) ? EFFColor.grey9 : EFFColor.grey5//Needed as binding does not work correctly palette.brightText: BColors.nightMode ? EFFColor.grey9 : (selectedIndexLevel0 === -1) ? EFFColor.grey9 : EFFColor.grey5//Needed as binding does not work correctly palette.buttonText: BColors.nightMode ? EFFColor.grey9 : (selectedIndexLevel0 === -1) ? EFFColor.grey9 : EFFColor.grey5 font.bold: true font.pointSize: BFonts.sizeTextUnderIcon onClicked: { root.openOtherMenu() } } } } //We stil need the popup for the press outside parent and use it for dimensions Popup { id: menuNav parent: root closePolicy: Popup.CloseOnPressOutsideParent background: null property int openedWidth: 288//The opened with (constant) property bool navOpened: false x: Data.portrait ? 0 : parent.width y: Data.portrait ? parent.height : 0 width: 0 height: Data.portrait ? navMenuHeight - aGrid.height : navMenuHeight padding: 0 onAboutToShow: { width = openedWidth } onClosed: { root.updateIndex() width = 0 } Behavior on width { SequentialAnimation { ScriptAction{script: if (width < menuNav.openedWidth) Data.webViewNavPopup = menuNav.openedWidth } NumberAnimation{duration: 300} ScriptAction{script: if (width == 0) Data.webViewNavPopup = 0 } } } Item { id: loader clip: true anchors.right: menuNav.right height: menuNav.height width: menuNav.width NavMenu { id: navBackground width: menuNav.openedWidth height: parent.height enabled: menuNav.navOpened visible: enabled anchors.right: parent.right popup: menuNav selectedIndexLevel0: root.selectedIndexLevel0 color: BColors.nightMode ? BColors.grey2 : BColors.lightNavBackground } OthersMenu { id: othersBackground width: menuNav.openedWidth height: parent.height enabled: !menuNav.navOpened visible: enabled anchors.right: parent.right popup: menuNav color: BColors.nightMode ? BColors.grey3 : BColors.lightNavBackground } } }
}
-
wrote on 30 Apr 2025, 17:10 last edited by
you should import modules, not directories.
Question : are those directories part of one single module ? Or different modules ?
in first case, they all just should be declared in your CMakeLists.txt in the qt_add_qml_module directive, optionnaly a qmldir file in each directory if you load from source dir instead of resources (hot reloader for example) and you shouldn't have to import anything, as it's same module.
in second case you have to import module in caller's CMakeLists.txt first via classically via target_link_directories and target_link_libraries before you can import in QML.
1/3