Warning, /plasma/plasma-systemmonitor/src/table/UserCellDelegate.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  * SPDX-FileCopyrightText: 2020 Arjen Hiemstra <ahiemstra@heimr.nl>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005  */
0006 
0007 import QtQuick 2.12
0008 import QtQuick.Controls 2.2
0009 
0010 import org.kde.kirigami 2.2 as Kirigami
0011 
0012 TextCellDelegate {
0013     id: delegate
0014 
0015     property int uidColumn
0016     property var currentUser
0017 
0018     horizontalAlignment: Text.AlignHCenter
0019 
0020     background: CellBackground {
0021         view: delegate.TableView.view
0022         row: model.row;
0023         column: model.column
0024         color: {
0025             var uid = -1
0026             var m = delegate.TableView.view.model
0027             if ("sourceModel" in m) {
0028                 var index = m.mapToSource(m.index(model.row, 0))
0029                 index = m.sourceModel.index(index.row, delegate.uidColumn)
0030                 uid = m.sourceModel.data(index)
0031             } else {
0032                 uid = m.data(m.index(model.row, delegate.uidColumn))
0033             }
0034 
0035             if (uid >= 0 && (uid < 1000 || uid >= 65534)) {
0036                 return Qt.darker(Kirigami.Theme.alternateBackgroundColor, model.row % 2 == 0 ? 1.0 : 1.1)
0037             } else if (model.display == currentUser.loginName) {
0038                 return Qt.rgba(
0039                     Kirigami.Theme.highlightColor.r,
0040                     Kirigami.Theme.highlightColor.g,
0041                     Kirigami.Theme.highlightColor.b,
0042                     model.row % 2 == 0 ? 0.4 : 0.5
0043                 )
0044             }
0045             return Kirigami.Theme.backgroundColor
0046         }
0047     }
0048 }