mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 15:03:09 +00:00
windowplugin: Use standardized way to know whether a window is showing and maximized
This commit is contained in:
parent
2653e2d816
commit
da6e17f3f4
17 changed files with 127 additions and 156 deletions
|
|
@ -80,7 +80,7 @@ Item {
|
||||||
target: MobileShellState.HomeScreenControls
|
target: MobileShellState.HomeScreenControls
|
||||||
|
|
||||||
function onOpenHomeScreen() {
|
function onOpenHomeScreen() {
|
||||||
if (!WindowPlugin.WindowUtil.allWindowsMinimized) {
|
if (WindowPlugin.WindowMaximizedTracker.showingWindow) {
|
||||||
itemContainer.zoomIn();
|
itemContainer.zoomIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
# SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
|
# SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
add_library(windowplugin)
|
set(windowplugin_SRCS
|
||||||
target_sources(windowplugin PRIVATE
|
|
||||||
windowplugin.cpp
|
windowplugin.cpp
|
||||||
windowutil.cpp
|
windowutil.cpp
|
||||||
)
|
)
|
||||||
|
qt_add_resources(RESOURCES resources.qrc)
|
||||||
|
add_library(windowplugin SHARED ${windowplugin_SRCS} ${RESOURCES})
|
||||||
|
|
||||||
target_link_libraries(windowplugin
|
target_link_libraries(windowplugin
|
||||||
Qt::Qml
|
Qt::Qml
|
||||||
|
|
|
||||||
39
components/windowplugin/qml/WindowMaximizedTracker.qml
Normal file
39
components/windowplugin/qml/WindowMaximizedTracker.qml
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
import QtQuick
|
||||||
|
|
||||||
|
import org.kde.plasma.core as PlasmaCore
|
||||||
|
import org.kde.taskmanager as TaskManager
|
||||||
|
|
||||||
|
pragma Singleton
|
||||||
|
|
||||||
|
// Helper component that uses Plasma's tasks model to provide whether a maximized window is showing on the current screen.
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
readonly property bool showingWindow: __internal.count > 0
|
||||||
|
|
||||||
|
property var __internal: PlasmaCore.SortFilterModel {
|
||||||
|
id: visibleMaximizedWindowsModel
|
||||||
|
filterRole: 'IsMinimized'
|
||||||
|
filterRegExp: 'false'
|
||||||
|
sourceModel: TaskManager.TasksModel {
|
||||||
|
id: tasksModel
|
||||||
|
filterByVirtualDesktop: true
|
||||||
|
filterByActivity: true
|
||||||
|
filterNotMaximized: true
|
||||||
|
filterByScreen: true
|
||||||
|
filterHidden: true
|
||||||
|
|
||||||
|
virtualDesktop: virtualDesktopInfo.currentDesktop
|
||||||
|
activity: activityInfo.currentActivity
|
||||||
|
|
||||||
|
groupMode: TaskManager.TasksModel.GroupDisabled
|
||||||
|
}
|
||||||
|
|
||||||
|
property var vdi: TaskManager.VirtualDesktopInfo {
|
||||||
|
id: virtualDesktopInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
property var ai: TaskManager.ActivityInfo {
|
||||||
|
id: activityInfo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
components/windowplugin/resources.qrc
Normal file
11
components/windowplugin/resources.qrc
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
<!--
|
||||||
|
- Copyright 2023 Devin Lin <devin@kde.org>
|
||||||
|
- SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
-->
|
||||||
|
<RCC>
|
||||||
|
<qresource prefix="/org/kde/plasma/private/mobileshell/windowplugin/">
|
||||||
|
<file>qml/WindowMaximizedTracker.qml</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -7,6 +7,11 @@
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
#include <QQuickItem>
|
#include <QQuickItem>
|
||||||
|
|
||||||
|
QUrl resolvePath(std::string str)
|
||||||
|
{
|
||||||
|
return QUrl("qrc:/org/kde/plasma/private/mobileshell/windowplugin/qml/" + QString::fromStdString(str));
|
||||||
|
}
|
||||||
|
|
||||||
void WindowPlugin::registerTypes(const char *uri)
|
void WindowPlugin::registerTypes(const char *uri)
|
||||||
{
|
{
|
||||||
Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.plasma.private.mobileshell.windowplugin"));
|
Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.plasma.private.mobileshell.windowplugin"));
|
||||||
|
|
@ -14,4 +19,6 @@ void WindowPlugin::registerTypes(const char *uri)
|
||||||
qmlRegisterSingletonType<WindowUtil>(uri, 1, 0, "WindowUtil", [](QQmlEngine *, QJSEngine *) -> QObject * {
|
qmlRegisterSingletonType<WindowUtil>(uri, 1, 0, "WindowUtil", [](QQmlEngine *, QJSEngine *) -> QObject * {
|
||||||
return WindowUtil::instance();
|
return WindowUtil::instance();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
qmlRegisterSingletonType(resolvePath("WindowMaximizedTracker.qml"), uri, 1, 0, "WindowMaximizedTracker");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
#include "windowutil.h"
|
#include "windowutil.h"
|
||||||
|
|
||||||
|
#include <KApplicationTrader>
|
||||||
|
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
|
|
||||||
constexpr int ACTIVE_WINDOW_UPDATE_INVERVAL = 0;
|
constexpr int ACTIVE_WINDOW_UPDATE_INVERVAL = 0;
|
||||||
|
|
@ -36,16 +38,6 @@ bool WindowUtil::isShowingDesktop() const
|
||||||
return m_showingDesktop;
|
return m_showingDesktop;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WindowUtil::allWindowsMinimized() const
|
|
||||||
{
|
|
||||||
return m_allWindowsMinimized;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WindowUtil::allWindowsMinimizedExcludingShell() const
|
|
||||||
{
|
|
||||||
return m_allWindowsMinimizedExcludingShell;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WindowUtil::activeWindowIsShell() const
|
bool WindowUtil::activeWindowIsShell() const
|
||||||
{
|
{
|
||||||
return m_activeWindowIsShell;
|
return m_activeWindowIsShell;
|
||||||
|
|
@ -83,6 +75,40 @@ void WindowUtil::initWayland()
|
||||||
m_activeWindowTimer->start();
|
m_activeWindowTimer->start();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connect(registry, &Registry::plasmaActivationFeedbackAnnounced, this, [this, registry](quint32 name, quint32 version) {
|
||||||
|
auto iface = registry->createPlasmaActivationFeedback(name, version, this);
|
||||||
|
|
||||||
|
connect(iface, &PlasmaActivationFeedback::activation, this, [this](PlasmaActivation *activation) {
|
||||||
|
connect(activation, &PlasmaActivation::applicationId, this, [this](const QString &appId) {
|
||||||
|
const auto servicesFound = KApplicationTrader::query([&appId](const KService::Ptr &service) {
|
||||||
|
if (service->exec().isEmpty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (service->desktopEntryName().compare(appId, Qt::CaseInsensitive) == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
const auto idWithoutDesktop = QString(appId).remove(QStringLiteral(".desktop"));
|
||||||
|
if (service->desktopEntryName().compare(idWithoutDesktop, Qt::CaseInsensitive) == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
const auto renamedFrom = service->property(QStringLiteral("X-Flatpak-RenamedFrom")).toStringList();
|
||||||
|
if (renamedFrom.contains(appId, Qt::CaseInsensitive) || renamedFrom.contains(idWithoutDesktop, Qt::CaseInsensitive))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!servicesFound.isEmpty()) {
|
||||||
|
Q_EMIT appActivationStarted(appId, servicesFound.constFirst()->icon());
|
||||||
|
} else {
|
||||||
|
qDebug() << "WindowUtil: Could not find service" << appId;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(activation, &PlasmaActivation::finished, this, &WindowUtil::appActivationFinished);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
registry->setup();
|
registry->setup();
|
||||||
connection->roundtrip();
|
connection->roundtrip();
|
||||||
}
|
}
|
||||||
|
|
@ -98,6 +124,7 @@ void WindowUtil::updateActiveWindow()
|
||||||
disconnect(m_activeWindow.data(), &PlasmaWindow::closeableChanged, this, &WindowUtil::hasCloseableActiveWindowChanged);
|
disconnect(m_activeWindow.data(), &PlasmaWindow::closeableChanged, this, &WindowUtil::hasCloseableActiveWindowChanged);
|
||||||
disconnect(m_activeWindow.data(), &PlasmaWindow::unmapped, this, &WindowUtil::forgetActiveWindow);
|
disconnect(m_activeWindow.data(), &PlasmaWindow::unmapped, this, &WindowUtil::forgetActiveWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_activeWindow = m_windowManagement->activeWindow();
|
m_activeWindow = m_windowManagement->activeWindow();
|
||||||
Q_EMIT activeWindowChanged();
|
Q_EMIT activeWindowChanged();
|
||||||
|
|
||||||
|
|
@ -106,29 +133,6 @@ void WindowUtil::updateActiveWindow()
|
||||||
connect(m_activeWindow.data(), &PlasmaWindow::unmapped, this, &WindowUtil::forgetActiveWindow);
|
connect(m_activeWindow.data(), &PlasmaWindow::unmapped, this, &WindowUtil::forgetActiveWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
// loop through windows
|
|
||||||
bool newAllMinimized = true;
|
|
||||||
bool newAllMinimizedExcludingShell = true;
|
|
||||||
for (auto *w : m_windowManagement->windows()) {
|
|
||||||
if (!w->isMinimized() && !w->skipTaskbar() && !w->isFullscreen()) {
|
|
||||||
newAllMinimized = false;
|
|
||||||
|
|
||||||
if (w->appId() != QStringLiteral("org.kde.plasmashell")) {
|
|
||||||
newAllMinimizedExcludingShell = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newAllMinimized != m_allWindowsMinimized) {
|
|
||||||
m_allWindowsMinimized = newAllMinimized;
|
|
||||||
Q_EMIT allWindowsMinimizedChanged();
|
|
||||||
}
|
|
||||||
if (newAllMinimizedExcludingShell != m_allWindowsMinimizedExcludingShell) {
|
|
||||||
m_allWindowsMinimizedExcludingShell = newAllMinimizedExcludingShell;
|
|
||||||
Q_EMIT allWindowsMinimizedExcludingShellChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: connect to closeableChanged, not needed right now as KWin doesn't provide this changeable
|
|
||||||
Q_EMIT hasCloseableActiveWindowChanged();
|
Q_EMIT hasCloseableActiveWindowChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -214,11 +218,12 @@ void WindowUtil::updateShowingDesktop(bool showing)
|
||||||
|
|
||||||
void WindowUtil::updateActiveWindowIsShell()
|
void WindowUtil::updateActiveWindowIsShell()
|
||||||
{
|
{
|
||||||
if (m_activeWindow) {
|
auto activeWindow = m_windowManagement->activeWindow();
|
||||||
if (m_activeWindow->appId() == QStringLiteral("org.kde.plasmashell") && !m_activeWindowIsShell) {
|
if (activeWindow) {
|
||||||
|
if (activeWindow->appId() == QStringLiteral("org.kde.plasmashell") && !m_activeWindowIsShell) {
|
||||||
m_activeWindowIsShell = true;
|
m_activeWindowIsShell = true;
|
||||||
Q_EMIT activeWindowIsShellChanged();
|
Q_EMIT activeWindowIsShellChanged();
|
||||||
} else if (m_activeWindow->appId() != QStringLiteral("org.kde.plasmashell") && m_activeWindowIsShell) {
|
} else if (activeWindow->appId() != QStringLiteral("org.kde.plasmashell") && m_activeWindowIsShell) {
|
||||||
m_activeWindowIsShell = false;
|
m_activeWindowIsShell = false;
|
||||||
Q_EMIT activeWindowIsShellChanged();
|
Q_EMIT activeWindowIsShellChanged();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,16 +24,12 @@
|
||||||
/**
|
/**
|
||||||
* Utility class that provides useful functions related to windows and KWin+KWayland.
|
* Utility class that provides useful functions related to windows and KWin+KWayland.
|
||||||
*
|
*
|
||||||
* TODO: Add per-screen support
|
|
||||||
*
|
|
||||||
* @author Devin Lin <devin@kde.org>
|
* @author Devin Lin <devin@kde.org>
|
||||||
**/
|
**/
|
||||||
class WindowUtil : public QObject
|
class WindowUtil : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool showDesktop READ isShowingDesktop WRITE requestShowingDesktop NOTIFY showingDesktopChanged)
|
Q_PROPERTY(bool isShowingDesktop READ isShowingDesktop WRITE requestShowingDesktop NOTIFY showingDesktopChanged)
|
||||||
Q_PROPERTY(bool allWindowsMinimized READ allWindowsMinimized NOTIFY allWindowsMinimizedChanged)
|
|
||||||
Q_PROPERTY(bool allWindowsMinimizedExcludingShell READ allWindowsMinimizedExcludingShell NOTIFY allWindowsMinimizedExcludingShellChanged)
|
|
||||||
Q_PROPERTY(bool hasCloseableActiveWindow READ hasCloseableActiveWindow NOTIFY hasCloseableActiveWindowChanged)
|
Q_PROPERTY(bool hasCloseableActiveWindow READ hasCloseableActiveWindow NOTIFY hasCloseableActiveWindowChanged)
|
||||||
Q_PROPERTY(bool activeWindowIsShell READ activeWindowIsShell NOTIFY activeWindowIsShellChanged)
|
Q_PROPERTY(bool activeWindowIsShell READ activeWindowIsShell NOTIFY activeWindowIsShellChanged)
|
||||||
|
|
||||||
|
|
@ -47,16 +43,6 @@ public:
|
||||||
*/
|
*/
|
||||||
bool isShowingDesktop() const;
|
bool isShowingDesktop() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether all windows are minimized, including shell windows.
|
|
||||||
*/
|
|
||||||
bool allWindowsMinimized() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether all windows are minimized, ignoring shell windows.
|
|
||||||
*/
|
|
||||||
bool allWindowsMinimizedExcludingShell() const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the active window being shown is a shell window.
|
* Whether the active window being shown is a shell window.
|
||||||
*/
|
*/
|
||||||
|
|
@ -105,14 +91,21 @@ public:
|
||||||
Q_INVOKABLE void unsetAllMinimizedGeometries(QQuickItem *parent);
|
Q_INVOKABLE void unsetAllMinimizedGeometries(QQuickItem *parent);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
// Emitted when a window has been opened
|
||||||
void windowCreated(KWayland::Client::PlasmaWindow *window);
|
void windowCreated(KWayland::Client::PlasmaWindow *window);
|
||||||
void showingDesktopChanged(bool showingDesktop);
|
void showingDesktopChanged(bool showingDesktop);
|
||||||
void allWindowsMinimizedChanged();
|
|
||||||
void allWindowsMinimizedExcludingShellChanged();
|
|
||||||
void hasCloseableActiveWindowChanged();
|
void hasCloseableActiveWindowChanged();
|
||||||
void activeWindowChanged();
|
void activeWindowChanged();
|
||||||
void activeWindowIsShellChanged();
|
void activeWindowIsShellChanged();
|
||||||
void windowChanged(QString storageId); // emitted on window open or close
|
|
||||||
|
// Emitted on window open or close
|
||||||
|
void windowChanged(QString storageId);
|
||||||
|
|
||||||
|
// Emitted when an application is launched
|
||||||
|
void appActivationStarted(const QString &appId, const QString &iconName);
|
||||||
|
|
||||||
|
// Emitted the application has finished launching
|
||||||
|
void appActivationFinished();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void updateActiveWindowIsShell();
|
void updateActiveWindowIsShell();
|
||||||
|
|
@ -129,8 +122,6 @@ private:
|
||||||
QTimer *m_activeWindowTimer;
|
QTimer *m_activeWindowTimer;
|
||||||
|
|
||||||
bool m_showingDesktop = false;
|
bool m_showingDesktop = false;
|
||||||
bool m_allWindowsMinimized = true;
|
|
||||||
bool m_allWindowsMinimizedExcludingShell = true;
|
|
||||||
bool m_activeWindowIsShell = false;
|
bool m_activeWindowIsShell = false;
|
||||||
|
|
||||||
QHash<QString, QList<KWayland::Client::PlasmaWindow *>> m_windows; // <storageId, window>
|
QHash<QString, QList<KWayland::Client::PlasmaWindow *>> m_windows; // <storageId, window>
|
||||||
|
|
|
||||||
|
|
@ -24,16 +24,6 @@ void HomeScreen::configChanged()
|
||||||
Plasma::Containment::configChanged();
|
Plasma::Containment::configChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HomeScreen::showingDesktop() const
|
|
||||||
{
|
|
||||||
return KWindowSystem::showingDesktop();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HomeScreen::setShowingDesktop(bool showingDesktop)
|
|
||||||
{
|
|
||||||
KWindowSystem::setShowingDesktop(showingDesktop);
|
|
||||||
}
|
|
||||||
|
|
||||||
K_PLUGIN_CLASS_WITH_JSON(HomeScreen, "package/metadata.json")
|
K_PLUGIN_CLASS_WITH_JSON(HomeScreen, "package/metadata.json")
|
||||||
|
|
||||||
#include "homescreen.moc"
|
#include "homescreen.moc"
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@
|
||||||
class HomeScreen : public Plasma::Containment
|
class HomeScreen : public Plasma::Containment
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool showingDesktop READ showingDesktop WRITE setShowingDesktop NOTIFY showingDesktopChanged)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HomeScreen(QObject *parent, const KPluginMetaData &data, const QVariantList &args);
|
HomeScreen(QObject *parent, const KPluginMetaData &data, const QVariantList &args);
|
||||||
|
|
@ -18,9 +17,6 @@ public:
|
||||||
|
|
||||||
void configChanged() override;
|
void configChanged() override;
|
||||||
|
|
||||||
bool showingDesktop() const;
|
|
||||||
void setShowingDesktop(bool showingDesktop);
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void showingDesktopChanged(bool showingDesktop);
|
void showingDesktopChanged(bool showingDesktop);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ MobileShell.HomeScreen {
|
||||||
// - minimize windows (only if we are in an app)
|
// - minimize windows (only if we are in an app)
|
||||||
// - open app drawer
|
// - open app drawer
|
||||||
// - close app drawer and, if necessary, restore windows
|
// - close app drawer and, if necessary, restore windows
|
||||||
if (!plasmoid.nativeInterface.showingDesktop && !WindowPlugin.WindowUtil.allWindowsMinimized
|
if (!WindowPlugin.WindowUtil.isShowingDesktop && WindowPlugin.WindowMaximizedTracker.showingWindow
|
||||||
|| MobileShellState.Shell.actionDrawerVisible
|
|| MobileShellState.Shell.actionDrawerVisible
|
||||||
|| searchWidget.isOpen
|
|| searchWidget.isOpen
|
||||||
) {
|
) {
|
||||||
|
|
@ -58,11 +58,9 @@ MobileShell.HomeScreen {
|
||||||
searchWidget.close();
|
searchWidget.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
plasmoid.nativeInterface.showingDesktop = true;
|
|
||||||
} else if (homescreen.homeScreenState.currentView === HomeScreenState.PageView) {
|
} else if (homescreen.homeScreenState.currentView === HomeScreenState.PageView) {
|
||||||
homescreen.homeScreenState.openAppDrawer();
|
homescreen.homeScreenState.openAppDrawer();
|
||||||
} else {
|
} else {
|
||||||
plasmoid.nativeInterface.showingDesktop = false;
|
|
||||||
homescreen.homeScreenState.closeAppDrawer();
|
homescreen.homeScreenState.closeAppDrawer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,16 +18,6 @@ HomeScreen::HomeScreen(QObject *parent, const KPluginMetaData &data, const QVari
|
||||||
|
|
||||||
HomeScreen::~HomeScreen() = default;
|
HomeScreen::~HomeScreen() = default;
|
||||||
|
|
||||||
bool HomeScreen::showingDesktop() const
|
|
||||||
{
|
|
||||||
return KWindowSystem::showingDesktop();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HomeScreen::setShowingDesktop(bool showingDesktop)
|
|
||||||
{
|
|
||||||
KWindowSystem::setShowingDesktop(showingDesktop);
|
|
||||||
}
|
|
||||||
|
|
||||||
K_PLUGIN_CLASS_WITH_JSON(HomeScreen, "package/metadata.json")
|
K_PLUGIN_CLASS_WITH_JSON(HomeScreen, "package/metadata.json")
|
||||||
|
|
||||||
#include "homescreen.moc"
|
#include "homescreen.moc"
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,11 @@
|
||||||
class HomeScreen : public Plasma::Containment
|
class HomeScreen : public Plasma::Containment
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool showingDesktop READ showingDesktop WRITE setShowingDesktop NOTIFY showingDesktopChanged)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HomeScreen(QObject *parent, const KPluginMetaData &data, const QVariantList &args);
|
HomeScreen(QObject *parent, const KPluginMetaData &data, const QVariantList &args);
|
||||||
~HomeScreen() override;
|
~HomeScreen() override;
|
||||||
|
|
||||||
bool showingDesktop() const;
|
|
||||||
void setShowingDesktop(bool showingDesktop);
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void showingDesktopChanged(bool showingDesktop);
|
void showingDesktopChanged(bool showingDesktop);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -43,10 +43,10 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: WindowPlugin.WindowUtil
|
target: WindowPlugin.WindowMaximizedTracker
|
||||||
|
|
||||||
function onAllWindowsMinimizedChanged(){
|
function onShowingWindowChanged(){
|
||||||
if (WindowPlugin.WindowUtil.allWindowsMinimized) {
|
if (WindowPlugin.WindowMaximizedTracker.showingWindow) {
|
||||||
swipeView.focusChild();
|
swipeView.focusChild();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ MobileShell.HomeScreen {
|
||||||
// - minimize windows (only if we are in an app)
|
// - minimize windows (only if we are in an app)
|
||||||
// - open app drawer
|
// - open app drawer
|
||||||
// - close app drawer and, if necessary, restore windows
|
// - close app drawer and, if necessary, restore windows
|
||||||
if (!WindowPlugin.WindowUtil.showDesktop && !WindowPlugin.WindowUtil.allWindowsMinimized || search.isOpen) {
|
if (!WindowPlugin.WindowUtil.isShowingDesktop && WindowPlugin.WindowMaximizedTracker.showingWindow || search.isOpen) {
|
||||||
// Always close action drawer
|
// Always close action drawer
|
||||||
if (MobileShellState.Shell.actionDrawerVisible) {
|
if (MobileShellState.Shell.actionDrawerVisible) {
|
||||||
MobileShellState.Shell.closeActionDrawer();
|
MobileShellState.Shell.closeActionDrawer();
|
||||||
|
|
@ -59,11 +59,11 @@ MobileShell.HomeScreen {
|
||||||
|
|
||||||
homescreen.page = 0;
|
homescreen.page = 0;
|
||||||
|
|
||||||
WindowPlugin.WindowUtil.showDesktop = true;
|
WindowPlugin.WindowUtil.isShowingDesktop = true;
|
||||||
} else if (homescreen.page == 0) {
|
} else if (homescreen.page == 0) {
|
||||||
homescreen.page = 1;
|
homescreen.page = 1;
|
||||||
} else {
|
} else {
|
||||||
WindowPlugin.WindowUtil.showDesktop = false;
|
WindowPlugin.WindowUtil.isShowingDesktop = false;
|
||||||
homescreen.page = 0;
|
homescreen.page = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,9 @@ import org.kde.plasma.plasmoid 2.0
|
||||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
import org.kde.plasma.components 3.0 as PlasmaComponents
|
import org.kde.plasma.components 3.0 as PlasmaComponents
|
||||||
|
|
||||||
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
|
import org.kde.plasma.private.mobileshell as MobileShell
|
||||||
import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState
|
import org.kde.plasma.private.mobileshell.state as MobileShellState
|
||||||
|
import org.kde.plasma.private.mobileshell.windowplugin as WindowPlugin
|
||||||
|
|
||||||
import org.kde.taskmanager 0.1 as TaskManager
|
import org.kde.taskmanager 0.1 as TaskManager
|
||||||
import org.kde.notificationmanager 1.0 as NotificationManager
|
import org.kde.notificationmanager 1.0 as NotificationManager
|
||||||
|
|
@ -26,7 +27,7 @@ Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
// only opaque if there are no maximized windows on this screen
|
// only opaque if there are no maximized windows on this screen
|
||||||
readonly property bool showingApp: visibleMaximizedWindowsModel.count > 0
|
readonly property bool showingApp: WindowPlugin.WindowMaximizedTracker.showingWindow
|
||||||
readonly property color backgroundColor: topPanel.colorScopeColor
|
readonly property color backgroundColor: topPanel.colorScopeColor
|
||||||
|
|
||||||
Plasmoid.backgroundHints: PlasmaCore.Types.NoBackground
|
Plasmoid.backgroundHints: PlasmaCore.Types.NoBackground
|
||||||
|
|
@ -92,33 +93,6 @@ Item {
|
||||||
MobileShellState.AudioProvider.bindShortcuts = true;
|
MobileShellState.AudioProvider.bindShortcuts = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskManager.VirtualDesktopInfo {
|
|
||||||
id: virtualDesktopInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
TaskManager.ActivityInfo {
|
|
||||||
id: activityInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaCore.SortFilterModel {
|
|
||||||
id: visibleMaximizedWindowsModel
|
|
||||||
filterRole: 'IsMinimized'
|
|
||||||
filterRegExp: 'false'
|
|
||||||
sourceModel: TaskManager.TasksModel {
|
|
||||||
id: tasksModel
|
|
||||||
filterByVirtualDesktop: true
|
|
||||||
filterByActivity: true
|
|
||||||
filterNotMaximized: true
|
|
||||||
filterByScreen: true
|
|
||||||
filterHidden: true
|
|
||||||
|
|
||||||
virtualDesktop: virtualDesktopInfo.currentDesktop
|
|
||||||
activity: activityInfo.currentActivity
|
|
||||||
|
|
||||||
groupMode: TaskManager.TasksModel.GroupDisabled
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// top panel component
|
// top panel component
|
||||||
MobileShell.StatusBar {
|
MobileShell.StatusBar {
|
||||||
id: topPanel
|
id: topPanel
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,6 @@ MobileShell.NavigationPanel {
|
||||||
|
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
MobileShellState.HomeScreenControls.openHomeScreen();
|
MobileShellState.HomeScreenControls.openHomeScreen();
|
||||||
WindowPlugin.WindowUtil.allWindowsMinimizedChanged();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@ import org.kde.kquickcontrolsaddons 2.0
|
||||||
|
|
||||||
import org.kde.plasma.private.nanoshell 2.0 as NanoShell
|
import org.kde.plasma.private.nanoshell 2.0 as NanoShell
|
||||||
import org.kde.plasma.private.mobileshell.shellsettingsplugin as ShellSettings
|
import org.kde.plasma.private.mobileshell.shellsettingsplugin as ShellSettings
|
||||||
import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState
|
import org.kde.plasma.private.mobileshell.state as MobileShellState
|
||||||
|
import org.kde.plasma.private.mobileshell.windowplugin as WindowPlugin
|
||||||
|
|
||||||
PlasmaCore.ColorScope {
|
PlasmaCore.ColorScope {
|
||||||
id: root
|
id: root
|
||||||
|
|
@ -105,35 +106,8 @@ PlasmaCore.ColorScope {
|
||||||
|
|
||||||
Component.onCompleted: setWindowProperties();
|
Component.onCompleted: setWindowProperties();
|
||||||
|
|
||||||
TaskManager.VirtualDesktopInfo {
|
|
||||||
id: virtualDesktopInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
TaskManager.ActivityInfo {
|
|
||||||
id: activityInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaCore.SortFilterModel {
|
|
||||||
id: visibleMaximizedWindowsModel
|
|
||||||
filterRole: 'IsMinimized'
|
|
||||||
filterRegExp: 'false'
|
|
||||||
sourceModel: TaskManager.TasksModel {
|
|
||||||
id: tasksModel
|
|
||||||
filterByVirtualDesktop: true
|
|
||||||
filterByActivity: true
|
|
||||||
filterNotMaximized: true
|
|
||||||
filterByScreen: true
|
|
||||||
filterHidden: true
|
|
||||||
|
|
||||||
virtualDesktop: virtualDesktopInfo.currentDesktop
|
|
||||||
activity: activityInfo.currentActivity
|
|
||||||
|
|
||||||
groupMode: TaskManager.TasksModel.GroupDisabled
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// only opaque if there are no maximized windows on this screen
|
// only opaque if there are no maximized windows on this screen
|
||||||
readonly property bool opaqueBar: visibleMaximizedWindowsModel.count > 0
|
readonly property bool opaqueBar: WindowPlugin.WindowMaximizedTracker.showingWindow
|
||||||
|
|
||||||
// contrasting colour
|
// contrasting colour
|
||||||
colorGroup: opaqueBar ? PlasmaCore.Theme.NormalColorGroup : PlasmaCore.Theme.ComplementaryColorGroup
|
colorGroup: opaqueBar ? PlasmaCore.Theme.NormalColorGroup : PlasmaCore.Theme.ComplementaryColorGroup
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue