mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-24 18:03:53 +03:00
fix how tasks model in update for destroyed
This commit is contained in:
parent
27f34834ff
commit
546b945fff
@ -23,6 +23,7 @@
|
||||
#include <QDebug>
|
||||
|
||||
// Plasma
|
||||
#include <Plasma/Applet>
|
||||
#include <PlasmaQuick/AppletQuickItem>
|
||||
|
||||
namespace Latte {
|
||||
@ -78,22 +79,66 @@ void TasksModel::addTask(PlasmaQuick::AppletQuickItem *plasmoid)
|
||||
removeTask(plasmoid);
|
||||
});
|
||||
|
||||
connect(plasmoid->applet(), &Plasma::Applet::destroyedChanged, this, [&, plasmoid](const bool &destroyed){
|
||||
if (destroyed) {
|
||||
moveIntoWaitingTasks(plasmoid);
|
||||
} else {
|
||||
restoreFromWaitingTasks(plasmoid);
|
||||
}
|
||||
});
|
||||
|
||||
emit countChanged();
|
||||
}
|
||||
|
||||
void TasksModel::moveIntoWaitingTasks(PlasmaQuick::AppletQuickItem *plasmoid)
|
||||
{
|
||||
if (plasmoid && !m_tasks.contains(plasmoid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int tind = m_tasks.indexOf(plasmoid);
|
||||
|
||||
if (tind >= 0) {
|
||||
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
||||
m_tasksWaiting << m_tasks.takeAt(tind);
|
||||
endInsertRows();
|
||||
emit countChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void TasksModel::restoreFromWaitingTasks(PlasmaQuick::AppletQuickItem *plasmoid)
|
||||
{
|
||||
if (plasmoid && !m_tasksWaiting.contains(plasmoid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int tind = m_tasksWaiting.indexOf(plasmoid);
|
||||
|
||||
if (tind >= 0) {
|
||||
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
||||
m_tasks << m_tasksWaiting.takeAt(tind);
|
||||
endInsertRows();
|
||||
emit countChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void TasksModel::removeTask(PlasmaQuick::AppletQuickItem *plasmoid)
|
||||
{
|
||||
if (!plasmoid || (plasmoid && !m_tasks.contains(plasmoid))) {
|
||||
if (!plasmoid || (plasmoid && !m_tasks.contains(plasmoid) && !m_tasksWaiting.contains(plasmoid))) {
|
||||
return;
|
||||
}
|
||||
|
||||
int iex = m_tasks.indexOf(plasmoid);
|
||||
if (m_tasks.contains(plasmoid)) {
|
||||
int iex = m_tasks.indexOf(plasmoid);
|
||||
|
||||
beginRemoveRows(QModelIndex(), iex, iex);
|
||||
m_tasks.removeAll(plasmoid);
|
||||
endRemoveRows();
|
||||
beginRemoveRows(QModelIndex(), iex, iex);
|
||||
m_tasks.removeAll(plasmoid);
|
||||
endRemoveRows();
|
||||
|
||||
emit countChanged();
|
||||
emit countChanged();
|
||||
} else if (m_tasksWaiting.contains(plasmoid)) {
|
||||
m_tasksWaiting.removeAll(plasmoid);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -49,8 +49,13 @@ public:
|
||||
signals:
|
||||
void countChanged();
|
||||
|
||||
private slots:
|
||||
void moveIntoWaitingTasks(PlasmaQuick::AppletQuickItem *plasmoid);
|
||||
void restoreFromWaitingTasks(PlasmaQuick::AppletQuickItem *plasmoid);
|
||||
|
||||
private:
|
||||
QList<PlasmaQuick::AppletQuickItem *> m_tasks;
|
||||
QList<PlasmaQuick::AppletQuickItem *> m_tasksWaiting;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ AbilityDefinition.PositionShortcuts {
|
||||
readonly property bool isActive: bridge !== null
|
||||
|
||||
property bool isStealingGlobalPositionShortcuts: false
|
||||
readonly property bool showPositionShortcutBadges: ref.shortcuts.showPositionShortcutBadges
|
||||
readonly property bool showPositionShortcutBadges: bridge && bridge.shortcuts.host ? bridge.shortcuts.host.showPositionShortcutBadges : false
|
||||
|
||||
readonly property bool isEnabled: {
|
||||
if (bridge) {
|
||||
@ -40,11 +40,6 @@ AbilityDefinition.PositionShortcuts {
|
||||
|
||||
signal disabledIsStealingGlobalPositionShortcuts();
|
||||
|
||||
Item {
|
||||
id: ref
|
||||
readonly property Item shortcuts: bridge ? bridge.shortcuts.host : local
|
||||
}
|
||||
|
||||
onIsActiveChanged: {
|
||||
if (isActive) {
|
||||
bridge.shortcuts.client = shortcuts;
|
||||
|
Loading…
x
Reference in New Issue
Block a user