diff --git a/components/mobileshell/qml/taskswitcher/TaskSwitcher.qml b/components/mobileshell/qml/taskswitcher/TaskSwitcher.qml index 9955985b..344831de 100644 --- a/components/mobileshell/qml/taskswitcher/TaskSwitcher.qml +++ b/components/mobileshell/qml/taskswitcher/TaskSwitcher.qml @@ -18,6 +18,9 @@ import org.kde.plasma.private.mobileshell 1.0 as MobileShell import "../components" as Components +/** + * Component that provides a task switcher. + */ Item { id: root visible: false @@ -28,15 +31,27 @@ Item { taskSwitcher: root } - // task list model + /** + * The task manager model to use for the tasks switcher. + */ property TaskManager.TasksModel tasksModel + + /** + * The number of tasks in the given task manager model. + */ readonly property int tasksCount: tasksModel.count + /** + * The screen model to be used for moving windows between screens. + */ property var displaysModel: MobileShell.DisplaysModel {} - // if a window has popped up in front, close the task switcher + /** + * Whether the window is active. + */ property bool windowActive: Window.active onWindowActiveChanged: { + // if a window has popped up in front, close the task switcher if (visible && !windowActive) { hide(); } @@ -126,12 +141,7 @@ Item { } function minimizeAll() { - for (var i = 0 ; i < tasksModel.count; i++) { - var idx = tasksModel.makeModelIndex(i); - if (!tasksModel.data(idx, TaskManager.AbstractTasksModel.IsMinimized)) { - tasksModel.requestToggleMinimized(idx); - } - } + MobileShell.WindowUtil.minimizeAll(root); } //END functions diff --git a/components/mobileshell/windowutil.cpp b/components/mobileshell/windowutil.cpp index 077e0544..d0894071 100644 --- a/components/mobileshell/windowutil.cpp +++ b/components/mobileshell/windowutil.cpp @@ -54,6 +54,7 @@ bool WindowUtil::activeWindowIsShell() const void WindowUtil::initWayland() { if (!QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) { + qWarning() << "Plasma Mobile must use wayland! The current platform detected is:" << QGuiApplication::platformName(); return; } @@ -150,6 +151,31 @@ void WindowUtil::requestShowingDesktop(bool showingDesktop) m_windowManagement->setShowingDesktop(showingDesktop); } +void WindowUtil::minimizeAll(QQuickItem *parent) +{ + if (!m_windowManagement) { + qWarning() << "Ignoring request for minimizing all windows since window management hasn't been announced yet!"; + return; + } + + KWayland::Client::Surface *surface = nullptr; + if (parent) { + QWindow *window = parent->window(); + if (window) { + surface = KWayland::Client::Surface::fromWindow(window); + } + } + + for (auto *w : m_windowManagement->windows()) { + if (!w->isMinimized()) { + if (surface) { + w->unsetMinimizedGeometry(surface); + } + w->requestToggleMinimized(); + } + } +} + void WindowUtil::updateShowingDesktop(bool showing) { if (showing != m_showingDesktop) { diff --git a/components/mobileshell/windowutil.h b/components/mobileshell/windowutil.h index 84958168..2f7af1f1 100644 --- a/components/mobileshell/windowutil.h +++ b/components/mobileshell/windowutil.h @@ -9,6 +9,8 @@ #include #include +#include +#include #include #include @@ -77,6 +79,13 @@ public: */ Q_INVOKABLE void requestShowingDesktop(bool showingDesktop); + /** + * Minimize all windows, while also unsetting their respective minimized geometries of the window given. + * + * @param parent The parent item, which is of the same window that will have geometries unset. + */ + Q_INVOKABLE void minimizeAll(QQuickItem *parent); + Q_SIGNALS: void windowCreated(KWayland::Client::PlasmaWindow *window); void showingDesktopChanged(bool showingDesktop);