Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/VLC/modules/gui/qt/network/qml/   (VLC Media Plyer ©)  Datei vom 23.9.2026 mit Größe 5 kB image not shown  

Quelle  ServicesSources.qml  Sprache: unbekannt

 
Spracherkennung für: .qml vermutete Sprache: Masm {Masm[48] ABAP[44] Cobol[32]} [Methode: maximale Elemente, drei Dimensionen]

/*****************************************************************************
 * Copyright (C) 2020 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.Layouts


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

Widgets.PageExt {
    id: root

    title: qsTr("Services")

    signal browseServiceManage(int reason)
    signal browseSourceRoot(string sourceName, int reason)

    hasGridListMode: false
    isSearchable: true

    function positionContentAtBeginning() {
        grid.positionViewAtBeginningAnimated()
    }

    Widgets.ExpandGridItemView {
        //settings
        id: grid

        anchors.fill: parent

        focus: true

        basePictureWidth: VLCStyle.gridCover_network_width
        basePictureHeight: VLCStyle.gridCover_network_height
        subtitleHeight: 0

        model: sourcesModel

        delegate: Widgets.GridItem {
            property var model: ({})
            property int index: -1
            readonly property bool is_dummy: model.type === NetworkSourcesModel.TYPE_DUMMY
            readonly property bool is_podcast: !is_dummy && model.name && model.name.startsWith("podcast")

            width: grid.cellWidth;
            height: grid.cellHeight;

            pictureWidth: grid.maxPictureWidth
            pictureHeight: grid.maxPictureHeight

            title: is_dummy ? qsTr("Add a service") : model.long_name
            subtitle: ""
            playCoverShowPlay: false
            image: {
                if (is_dummy) {
                    return SVGColorImage.colorize("qrc:///placeholder/add_service.svg")
                        .color1(this.colorContext.fg.secondary)
                        .accent(this.colorContext.accent)
                        .uri()
                } else if (model.artwork && model.artwork.toString() !== "") {
                    //if the source is a qrc artwork, we should colorize it
                    if (model.artwork.toString().match(/qrc:\/\/.*svg/))
                    {
                        return SVGColorImage.colorize(model.artwork)
                            .color1(this.colorContext.fg.secondary)
                            .accent(this.colorContext.accent)
                            .uri()
                    }

                    return model.artwork
                }

                // use fallbackImage
                return ""
            }

            fallbackImage: {
                return SVGColorImage.colorize("qrc:///sd/directory.svg")
                    .color1(this.colorContext.fg.secondary)
                    .uri()
            }

            onItemDoubleClicked: {
                if (is_dummy)
                    root.browseServiceManage(Qt.MouseFocusReason)
                else
                    root.browseSourceRoot(model.name, Qt.TabFocusReason)
            }

            onItemClicked : (modifier, select) => {
                if (select)
                    grid.selectionModel.updateSelection(modifier, grid.currentIndex, index)
                grid.currentIndex = index
                grid.currentItem.forceActiveFocus(Qt.MouseFocusReason)
            }

            onContextMenuButtonClicked: (menuParent, globalMousePos) => {
                if (is_podcast) {
                    serviceContextMenu.popup(globalMousePos, [qsTr("Configure...")])
                }
            }
        }

        onActionAtIndex: (index) => {
            const itemData = sourcesModel.getDataAt(index);

            if (itemData.type === NetworkSourcesModel.TYPE_DUMMY)
                browseServiceManage(Qt.TabFocusReason)
            else
                browseSourceRoot(itemData.name, Qt.TabFocusReason)
        }

        Navigation.cancelAction: function() {
            History.previous(Qt.BacktabFocusReason)
        }

        NetworkSourcesModel {
            id: sourcesModel

            ctx: MainCtx

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

    StringListMenu {
        id: serviceContextMenu

        ctx: MainCtx

        onSelected: (index, modelData) => {
            if (index === 0) {
                DialogsProvider.podcastConfigureDialog()
            }
        }
    }
}

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