Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  BrowseHomeDisplay.qml  Sprache: unbekannt

 
Spracherkennung für: .qml vermutete Sprache: SPS {SPS[56] Delphi[48] JAVA[48]} [Methode: maximale Elemente, drei Dimensionen]

/*****************************************************************************
 * Copyright (C) 2019 VLC authors and VideoLAN
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * ( at your option ) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/
import QtQuick
import QtQuick.Window
import QtQuick.Templates as T
import QtQml.Models
import QtQml


import VLC.Widgets as Widgets
import VLC.MainInterface
import VLC.Util
import VLC.Style
import VLC.Network

Widgets.PageExt {
    id: root

    // Properties

    property bool _initialized: false
    property bool _resetFocusPendingAfterInitialization: false

    property int maximumRows: {
        if (model.searchPattern !== "")
            return -1
        else if (MainCtx.gridView)
            return 2
        else
            return 5
    }

    sortModel: [
        { text: qsTr("Alphabetic"), criteria: "name"},
        { text: qsTr("Url"),        criteria: "mrl" }
    ]

    hasGridListMode: true
    isSearchable: true

    // Aliases

    property alias model: foldersSection.model

    // Signals

    signal seeAllDevices(var title, var sd_source, int reason)
    signal seeAllFolders(var title, int reason)

    signal browse(var tree, int reason)

    title: qsTr("Browse")

    focus: true

    function positionContentAtBeginning() {
        contentYBehavior.enabled = true
        flickable.contentY = -flickable.originY
        contentYBehavior.enabled = false
    }

    Component.onCompleted: {
        _initialized = true
        if (_resetFocusPendingAfterInitialization) {
            resetFocus()

            _resetFocusPendingAfterInitialization = false
        }
    }

    onActiveFocusChanged: {
        if (!_initialized) {
            _resetFocusPendingAfterInitialization = true
            return
        }

        resetFocus()
    }

    function setCurrentItemFocus(reason) {
        if (foldersSection.visible)
            foldersSection.setCurrentItemFocus(reason);
        else if (computerSection.visible)
            computerSection.setCurrentItemFocus(reason);
        else if (deviceSection.visible)
            deviceSection.setCurrentItemFocus(reason);
        else if (lanSection.visible)
            lanSection.setCurrentItemFocus(reason);
    }

    readonly property ColorContext colorContext: ColorContext {
        id: theme
        colorSet: ColorContext.View
    }

    //FIXME use the right xxxLabel class
    T.Label {
        anchors.centerIn: parent

        visible: [foldersSection, computerSection, deviceSection, lanSection]
                 .every(section => !section.model.loading && section.model.count === 0)

        font.pixelSize: VLCStyle.fontHeight_xxlarge
        color: root.activeFocus ? theme.accent : theme.fg.primary
        text: qsTr("No network shares found")
    }

    Flickable {
        id: flickable

        anchors.fill: parent

        anchors.leftMargin: root.leftPadding
        anchors.rightMargin: root.rightPadding

        T.ScrollBar.vertical: Widgets.ScrollBarExt { }

        flickableDirection: Flickable.AutoFlickIfNeeded
        boundsBehavior: Flickable.StopAtBounds

        focus: true

        pixelAligned: (MainCtx.qtVersion() >= MainCtx.qtVersionCheck(6, 2, 5)) // QTBUG-103996
                      && (Screen.pixelDensity >= VLCStyle.highPixelDensityThreshold) // no need for sub-pixel alignment with high pixel density

        contentWidth: column.width
        contentHeight: column.height

        // This behavior allows to have similar "smooth" animation
        // that Qt views have with `highlightFollowsCurrentItem`.
        Behavior on contentY {
            id: contentYBehavior

            enabled: false

            // NOTE: Usage of `SmoothedAnimation` is intentional here.
            SmoothedAnimation {
                duration: VLCStyle.duration_veryLong
                easing.type: Easing.InOutSine
            }
        }

        property Component implicitFlickableScrollHandler: DefaultFlickableScrollHandler { }

        // NOTE: This property can be set to null to prevent using a scroll handler:
        property FlickableScrollHandler scrollHandler: {
            if (interactive) {
                // JS ownership:
                return implicitFlickableScrollHandler.createObject(null, { target: flickable })
            } else {
                return null
            }
        }

        Navigation.parentItem: root

        Component.onCompleted: {
            if (!usingTouch) {
                // Flickable filters child mouse events for flicking (even when
                // the delegate is grabbed). However, this is not a useful
                // feature for non-touch cases, so disable it here and enable
                // it if touch is detected through the hover handler:
                MainCtx.setFiltersChildMouseEvents(flickable, false)
            }
        }

        readonly property bool usingTouch: MainCtx.usingTouch

        onUsingTouchChanged: {
            if (usingTouch)
                MainCtx.setFiltersChildMouseEvents(flickable, true)
            // We do not disable filtering child mouse events
            // because Qt currently has a bug that the flickable
            // jumps when it is enabled again later on.
        }

        Widgets.NavigableCol {
            id: column

            width: flickable.width
            height: implicitHeight

            spacing: 0 // relied on the generous padding of ViewHeader instead
            bottomPadding: VLCStyle.margin_normal // topPadding taken care by ViewHeader

            Navigation.parentItem: root
            Navigation.upItem: root.header

            HomeDeviceTitle {
                view: foldersSection

                text: qsTr("Folders")

                topPadding: 0

                anchors.left: parent.left
                anchors.right: parent.right
            }

            HomeDeviceView {
                id: foldersSection

                anchors.left: parent.left
                anchors.right: parent.right

                model: StandardPathModel {
                    //we only have a handfull of standard path (5 or 6)
                    //so we don't limit them

                    sortCriteria: root.sort.criteria
                    sortOrder: root.sort.order
                    searchPattern: root.search.pattern
                }
            }

            HomeDeviceTitle {
                view: computerSection

                text: qsTr("Computer")

                anchors.left: parent.left
                anchors.right: parent.right
            }

            HomeDeviceView {
                id: computerSection

                anchors.left: parent.left
                anchors.right: parent.right

                model: NetworkDeviceModel {
                    ctx: MainCtx

                    sd_source: NetworkDeviceModel.CAT_MYCOMPUTER
                    source_name: "*"

                    limit: computerSection.maximumCount

                    sortOrder: root.sort.order
                    sortCriteria: root.sort.criteria
                    searchPattern: root.search.pattern
                }
            }

            HomeDeviceTitle {
                view: deviceSection

                text: qsTr("Devices")

                anchors.left: parent.left
                anchors.right: parent.right
            }

            HomeDeviceView {
                id: deviceSection

                anchors.left: parent.left
                anchors.right: parent.right

                model: NetworkDeviceModel {
                    ctx: MainCtx

                    limit: deviceSection.maximumCount

                    sortOrder: root.sort.order
                    sortCriteria: root.sort.criteria
                    searchPattern: root.search.pattern

                    sd_source: NetworkDeviceModel.CAT_DEVICES
                    source_name: "*"
                }
            }

            HomeDeviceTitle {
                view: lanSection

                text: qsTr("Network")

                anchors.left: parent.left
                anchors.right: parent.right
            }

            HomeDeviceView {
                id: lanSection

                anchors.left: parent.left
                anchors.right: parent.right

                model: NetworkDeviceModel {
                    ctx: MainCtx

                    sd_source: NetworkDeviceModel.CAT_LAN
                    source_name: "*"

                    limit: lanSection.maximumCount

                    sortOrder: root.sort.order
                    sortCriteria: root.sort.criteria
                    searchPattern: root.search.pattern
                }
            }
        }
    }

    function resetFocus() {
        if (!activeFocus)
            return

        if (header?.activeFocus)
            return

        for (let i = 0; i < column.count; ++i) {
            const widget = column.itemAt(i)
            if (widget && widget.activeFocus && widget.visible)
                return
        }

        setCurrentItemFocus(focusReason)
    }

    component HomeDeviceTitle: Widgets.ViewHeader {

        anchors.left: parent.left
        anchors.right: parent.right

        visible: view.model.count !== 0

        seeAllButton.visible: view.model.count < view.model.maximumCount

        onSeeAllButtonClicked: (reason) => root.seeAllDevices(
            text,
            view.model.sd_source,
            reason
        )
    }

    component HomeDeviceView: BrowseDeviceView {
        id: deviceViewContent

        anchors.left: parent.left
        anchors.right: parent.right

        height: contentHeight

        visible: model.count !== 0

        focus: true

        Navigation.parentItem: column

        maximumRows: root.maximumRows

        interactive: false

        enableBeginningFade: false
        enableEndFade: false

        // FIXME: ExpandGridView makes this page completely unusable when `reuseItems` is set (#29084):
        reuseItems: !MainCtx.gridView

        onBrowse: (tree, reason) => root.browse(tree, reason)

        onActiveFocusChanged: {
            if (activeFocus) {
                const item = _currentView?.currentItem ?? _currentView?._getItem(currentIndex) // FIXME: `ExpandGridView` does not have `currentItem`.
                contentYBehavior.enabled = true
                Helpers.positionFlickableToContainItem(flickable, item ?? this)
                contentYBehavior.enabled = false
            }
        }

        onCurrentIndexChanged: {
            if (activeFocus) {
                const item = _currentView?.currentItem ?? _currentView?._getItem(currentIndex) // FIXME: `ExpandGridView` does not have `currentItem`.
                if (item) {
                    contentYBehavior.enabled = true
                    Helpers.positionFlickableToContainItem(flickable, item)
                    contentYBehavior.enabled = false
                }
            }
        }
    }
}

[Dauer der Verarbeitung: 0.3 Sekunden, vorverarbeitet 2026-10-24]

                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1104857
#Domains=418434