File indexing completed on 2024-09-08 12:14:34
0001 /* 0002 SPDX-FileCopyrightText: 2014 Nicolás Alvarez <nicolas.alvarez@gmail.com> 0003 0004 SPDX-License-Identifier: LGPL-2.0-only 0005 */ 0006 0007 #include "faceicontest.h" 0008 0009 #include <QApplication> 0010 #include <QListWidget> 0011 #include <QVBoxLayout> 0012 #include <kuser.h> 0013 0014 int main(int argc, char **argv) 0015 { 0016 QApplication app(argc, argv); 0017 0018 FaceIconTest *mainWin = new FaceIconTest(); 0019 mainWin->show(); 0020 return app.exec(); 0021 } 0022 FaceIconTest::FaceIconTest() 0023 { 0024 QVBoxLayout *layout = new QVBoxLayout(this); 0025 listWidget = new QListWidget(this); 0026 layout->addWidget(listWidget); 0027 0028 const QList<KUser> users = KUser::allUsers(); 0029 for (const KUser &u : users) { 0030 QPixmap pixmap(u.faceIconPath()); 0031 if (pixmap.isNull()) { 0032 pixmap = QPixmap(QSize(48, 48)); 0033 pixmap.fill(); 0034 } else { 0035 pixmap = pixmap.scaled(48, 48, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); 0036 } 0037 0038 QListWidgetItem *item = new QListWidgetItem(u.loginName(), listWidget); 0039 item->setData(Qt::DecorationRole, pixmap); 0040 } 0041 } 0042 0043 #include "moc_faceicontest.cpp"