File indexing completed on 2024-05-05 17:44:49
0001 /* 0002 SPDX-FileCopyrightText: 2016 Eike Hein <hein@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #include "abstractwindowtasksmodel.h" 0008 0009 #include <QGuiApplication> 0010 #include <QScreen> 0011 0012 namespace TaskManager 0013 { 0014 AbstractWindowTasksModel::AbstractWindowTasksModel(QObject *parent) 0015 : AbstractTasksModel(parent) 0016 { 0017 // TODO: The following will refresh the ScreenGeometry data role for 0018 // all rows whenever any screen is added or changes its geometry. No 0019 // attempt is made to be intelligent and exempt rows that are tech- 0020 // nically unaffected by the change. Doing so would require tracking 0021 // far more state (i.e. what screen a window is on) and be so 0022 // complicated as to invite bugs. As the trigger conditions are 0023 // expected to be rare, this would be premature optimization at this 0024 // time. That assessment may change in the future. 0025 0026 auto screenAdded = [this](const QScreen *screen) { 0027 connect(screen, &QScreen::geometryChanged, this, [this]() { 0028 Q_EMIT dataChanged(index(0, 0), index(rowCount() - 1, 0), QVector<int>{ScreenGeometry}); 0029 }); 0030 }; 0031 0032 connect(qGuiApp, &QGuiApplication::screenAdded, this, screenAdded); 0033 0034 foreach (const QScreen *screen, QGuiApplication::screens()) { 0035 screenAdded(screen); 0036 } 0037 } 0038 0039 AbstractWindowTasksModel::~AbstractWindowTasksModel() 0040 { 0041 } 0042 0043 }