Pimcommon

acllistview.cpp
1/*
2 SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "acllistview.h"
8#include <KLocalizedString>
9#include <QPainter>
10
11using namespace PimCommon;
12
13AclListView::AclListView(QWidget *parent)
14 : QListView(parent)
15{
16}
17
18AclListView::~AclListView() = default;
19
20void AclListView::slotCollectionCanBeAdministrated(bool b)
21{
22 if (mCanBeAdministrated != b) {
23 mCanBeAdministrated = b;
24 update();
25 }
26}
27
28void AclListView::generalPaletteChanged()
29{
30 const QPalette palette = viewport()->palette();
31 QColor color = palette.text().color();
32 color.setAlpha(128);
33 mTextColor = color;
34}
35
36void AclListView::paintEvent(QPaintEvent *event)
37{
38 if (!mCanBeAdministrated) {
39 QPainter p(viewport());
40
41 QFont font = p.font();
42 font.setItalic(true);
43 p.setFont(font);
44
45 if (!mTextColor.isValid()) {
46 generalPaletteChanged();
47 }
48 p.setPen(mTextColor);
49
50 p.drawText(QRect(0, 0, width(), height()), Qt::AlignCenter, i18n("Folder cannot be administrated."));
51 } else {
53 }
54}
55
56#include "moc_acllistview.cpp"
QString i18n(const char *text, const TYPE &arg...)
folderdialogacltab.h
QWidget * viewport() const const
bool isValid() const const
void setAlpha(int alpha)
void setItalic(bool enable)
virtual bool event(QEvent *e) override
virtual void paintEvent(QPaintEvent *e) override
AlignCenter
void update()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:39:22 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.