mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
startupfeedback: Fix multi-screen behaviour
Fix the model screen filtering not working properly, and account for case when opened window is already active.
This commit is contained in:
parent
3ca8e47b29
commit
5207c06a12
3 changed files with 20 additions and 50 deletions
|
|
@ -20,11 +20,18 @@ Item {
|
|||
property real leftMargin
|
||||
property real rightMargin
|
||||
|
||||
onScreenChanged: {
|
||||
repeater.model.setFilterFixedString(root.screen);
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
repeater.model.setFilterFixedString(root.screen);
|
||||
}
|
||||
|
||||
Repeater {
|
||||
id: repeater
|
||||
model: MobileShellState.StartupFeedbackFilterModel {
|
||||
startupFeedbackModel: MobileShellState.ShellDBusObject.startupFeedbackModel
|
||||
screen: root.screen
|
||||
}
|
||||
|
||||
delegate: Item {
|
||||
|
|
|
|||
|
|
@ -178,9 +178,8 @@ void StartupFeedbackModel::onWindowOpened(KWayland::Client::PlasmaWindow *window
|
|||
if (m_list.size() > indexToRemove) {
|
||||
StartupFeedback *feedbackToRemove = m_list[indexToRemove];
|
||||
|
||||
// Only delete StartupFeedback once the window becomes active
|
||||
// -> There is a gap of time between when a window is created and when it is actually visible/active
|
||||
connect(window, &KWayland::Client::PlasmaWindow::activeChanged, this, [this, window, feedbackToRemove]() {
|
||||
// Function to remove the startup feedback from the model
|
||||
auto removeFunction = [this, window, feedbackToRemove]() {
|
||||
if (!window->isActive()) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -198,7 +197,15 @@ void StartupFeedbackModel::onWindowOpened(KWayland::Client::PlasmaWindow *window
|
|||
}
|
||||
|
||||
window->disconnect(this);
|
||||
});
|
||||
};
|
||||
|
||||
// Only delete StartupFeedback once the window becomes active
|
||||
// -> There is a potential gap of time between when a window is created and when it is actually visible/active
|
||||
if (window->isActive()) {
|
||||
removeFunction();
|
||||
} else {
|
||||
connect(window, &KWayland::Client::PlasmaWindow::activeChanged, this, removeFunction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -245,7 +252,7 @@ void StartupFeedbackModel::updateActiveWindowIsStartupFeedback()
|
|||
StartupFeedbackFilterModel::StartupFeedbackFilterModel(QObject *parent)
|
||||
: QSortFilterProxyModel(parent)
|
||||
{
|
||||
setSortRole(StartupFeedbackModel::ScreenRole);
|
||||
setFilterRole(StartupFeedbackModel::ScreenRole);
|
||||
}
|
||||
|
||||
StartupFeedbackModel *StartupFeedbackFilterModel::startupFeedbackModel() const
|
||||
|
|
@ -263,38 +270,3 @@ void StartupFeedbackFilterModel::setStartupFeedbackModel(StartupFeedbackModel *s
|
|||
setSourceModel(m_startupFeedbackModel);
|
||||
Q_EMIT startupFeedbackModelChanged();
|
||||
}
|
||||
|
||||
int StartupFeedbackFilterModel::screen() const
|
||||
{
|
||||
return m_screen;
|
||||
}
|
||||
|
||||
void StartupFeedbackFilterModel::setScreen(int screen)
|
||||
{
|
||||
if (m_screen == screen) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_screen = screen;
|
||||
Q_EMIT screenChanged();
|
||||
}
|
||||
|
||||
bool StartupFeedbackFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||
{
|
||||
if (!m_startupFeedbackModel) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const QModelIndex index = m_startupFeedbackModel->index(sourceRow, 0, sourceParent);
|
||||
if (!index.isValid()) {
|
||||
return false;
|
||||
}
|
||||
const QVariant data = index.data();
|
||||
if (!data.isValid()) {
|
||||
// an invalid QVariant is valid data
|
||||
return true;
|
||||
}
|
||||
|
||||
StartupFeedback *startupFeedback = qvariant_cast<StartupFeedback *>(data);
|
||||
return startupFeedback->screen() == m_screen;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,7 +108,6 @@ class StartupFeedbackFilterModel : public QSortFilterProxyModel
|
|||
Q_OBJECT
|
||||
QML_ELEMENT
|
||||
Q_PROPERTY(StartupFeedbackModel *startupFeedbackModel READ startupFeedbackModel WRITE setStartupFeedbackModel NOTIFY startupFeedbackModelChanged)
|
||||
Q_PROPERTY(int screen READ screen WRITE setScreen NOTIFY screenChanged)
|
||||
|
||||
public:
|
||||
explicit StartupFeedbackFilterModel(QObject *parent = nullptr);
|
||||
|
|
@ -116,17 +115,9 @@ public:
|
|||
StartupFeedbackModel *startupFeedbackModel() const;
|
||||
void setStartupFeedbackModel(StartupFeedbackModel *taskModel);
|
||||
|
||||
int screen() const;
|
||||
void setScreen(int screen);
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void screenChanged();
|
||||
void startupFeedbackModelChanged();
|
||||
|
||||
private:
|
||||
StartupFeedbackModel *m_startupFeedbackModel{nullptr};
|
||||
int m_screen{0};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue