shift-shell/components/mobileshell/shellutil.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

99 lines
2.6 KiB
C
Raw Permalink Normal View History

/*
* SPDX-FileCopyrightText: 2015 Marco Martin <mart@kde.org>
* SPDX-FileCopyrightText: 2021-2022 Devin Lin <devin@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <QObject>
#include <QQuickItem>
#include <QQuickWindow>
#include <qqmlregistration.h>
#include <KConfigWatcher>
#include <KIO/ApplicationLauncherJob>
#include <KSharedConfig>
#include <LayerShellQt/Window>
/**
* Miscellaneous class to put utility functions used in the shell.
*
* @author Devin Lin <devin@kde.org>
**/
class ShellUtil : public QObject
{
Q_OBJECT
QML_ELEMENT
QML_SINGLETON
Q_PROPERTY(bool isSystem24HourFormat READ isSystem24HourFormat NOTIFY isSystem24HourFormatChanged)
public:
ShellUtil(QObject *parent = nullptr);
/**
* Change the stacking order to have the first item behind the second item.
*
* @param item1 The item to move behind.
* @param item2 The item to move in front.
*/
Q_INVOKABLE void stackItemBefore(QQuickItem *item1, QQuickItem *item2);
/**
* Change the stacking order to have the first item in front of the second item.
*
* @param item1 The item to move in front.
* @param item2 The item to move behind.
*/
Q_INVOKABLE void stackItemAfter(QQuickItem *item1, QQuickItem *item2);
/**
* Execute the command given.
*
* @param command The command to execute.
*/
Q_INVOKABLE void executeCommand(const QString &command);
/**
* Launch an application by name.
*
* @param storageId The storage id of the application to launch.
*/
Q_INVOKABLE void launchApp(const QString &storageId);
/**
* Whether the system is using 24 hour format.
*/
Q_INVOKABLE bool isSystem24HourFormat();
/**
* Set window input to be transparent.
*/
Q_INVOKABLE void setInputTransparent(QQuickWindow *window, bool transparent);
/**
* Set the window layer
*/
Q_INVOKABLE void setWindowLayer(QQuickWindow *window, LayerShellQt::Window::Layer layer);
notifications: Implement popup notifications This merge request implements a more mobile optimized solution for popup notification. - The current controls are: - Swipe up to move the notification to the notification center. - Swipe left/right to dismiss the notification entirely. - If multiple popup notifications are grouped together, tap on the bottom area to view them in a expanded view. What still needs to be done: - ~~For notification without a default action, tapping on them should probably open up the associated app.~~ Note: I think I will add this in a separate merge request as it probably should be the case regardless if the notification is a popup - ~~Swiping down on a notification currently does nothing. Maybe we should map this to a notification action?~~ Note: I have some ideas I will try later, though for now, I will leave this action blank - ~~The expanded view of notifications should be able to be dismissed by swiping up/down on the top/bottom of the list.~~ Note: Added - Investigate further into how to remove the current desktop popup notifications. - ~~Code clean up.~~ Note: The code is at least a bit better Single popup notification: ![notification_1](/uploads/63d12be6da1dd2676de17940dcadbdfa/notification_1.gif) Multiple popup notifications: ![notification_2](/uploads/907a14b772f66f46040c28342f4dcf02/notification_2.gif) Multiple popup notifications in the expanded view: ![notification_3](/uploads/9a7cd09a6bb8a0f7ee70e5bcf7c29c6b/notification_3.gif) Any feedback would be greatly appreciated.
2024-11-07 16:13:06 +00:00
/**
* Sets a region where inputs will get registered on a window.
* Inputs outside the region will pass through to the surface below.
* Set this to empty to fill the whole window again.
*/
Q_INVOKABLE void setInputRegion(QWindow *window, const QRect &region);
/**
* Converts rich text to plain text.
*/
Q_INVOKABLE QString toPlainText(QString htmlString);
Q_SIGNALS:
void isSystem24HourFormatChanged();
private:
KConfigWatcher::Ptr m_localeConfigWatcher;
KSharedConfig::Ptr m_localeConfig;
};