This file is indexed.

/usr/share/unity-2d/shell/dash/RatingStars.qml is in unity-2d-shell 5.10.0-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
 * This file is part of unity-2d
 *
 * Copyright 2010-2011 Canonical Ltd.
 *
 * 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; version 3.
 *
 * 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, see <http://www.gnu.org/licenses/>.
 */

import QtQuick 1.0
import "../common/utils.js" as Utils

Item {
    id: ratingStars

    property real rating
    property int size: 5 /* Number of stars */
    property alias enabled: starsMouseArea.enabled
    property alias spacing: stars.spacing
    property bool ratingVisible: true

    /* Configure icon size to use. Requires icon files named:
       - artwork/star_empty-${starIconSize}.png
       - artwork/star_full-${starIconSize}.png
    */
    property int starIconSize: 32

    width: stars.width
    height: stars.height

    function incrementRating() {
        rating = Utils.clamp(Math.floor(rating) + 1, 1, size)
    }

    function decrementRating() {
        rating = Utils.clamp(Math.ceil(rating) - 1, 1, size)
    }

    Keys.onPressed: if (handleKeyPress(event.key)) event.accepted = true
    function handleKeyPress(key) {
        switch (Utils.switchLeftRightKeys(key)) {
        case Qt.Key_Right:
            incrementRating()
            return true
        case Qt.Key_Left:
            decrementRating()
            return true
        }
        return false
    }

    Row {
        id: stars

        // Required for right-to-left mirroring
        anchors.left: parent.left

        Repeater {
            model: size
            Star {
                fill: if(!enabled){ /* If read-only, display any Star rating */
                          return Utils.clamp(rating - index, 0, size)
                      }
                      else{ /* If user selectable, restrict to integer selections */
                          return (rating - index > 0) ? 1 : 0
                      }
                iconSize: starIconSize
                selected: ( ratingStars.activeFocus )
                ratingVisible: ( ratingStars.ratingVisible )
            }
        }
    }

    MouseArea {
        id: starsMouseArea

        /* Calculating Star Rating incorporating inter-star spacing/gap.

           Consider each star+gap as a "unit". Determine what unit the mouse is over,
           and remove the width of the gaps to the left from the reported mouse position.
          */

        /* Width of each unit */
        property int unitWidth: starIconSize + stars.spacing

        function calculateRating( posX ){
            /* Mouse X coordinate over one unit, relative to that unit's left edge*/
            var posXOverUnit = posX % unitWidth

            /* What unit is the mouse over? This is the integer part of the rating (plus one)*/
            var rating = (posX - posXOverUnit) / unitWidth + 1
            if (Utils.isRightToLeft())
                rating = size + 1 - rating

            return Utils.clamp( rating, 0, size )
        }

        anchors.fill: stars

        onPressed: rating = calculateRating(mouseX)
        onPositionChanged: {
            if (pressed) rating = calculateRating(mouseX)
        }
    }
}