2021-12-22 23:29:00 +00:00
|
|
|
/*
|
|
|
|
|
* SPDX-FileCopyrightText: 2015 Marco Martin <mart@kde.org>
|
2022-04-07 14:52:12 +00:00
|
|
|
* SPDX-FileCopyrightText: 2021-2022 Devin Lin <devin@kde.org>
|
2021-12-22 23:29:00 +00:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
2022-04-07 14:52:12 +00:00
|
|
|
#include <QQuickItem>
|
2021-12-22 23:29:00 +00:00
|
|
|
|
|
|
|
|
#include <KConfigWatcher>
|
2022-10-12 21:00:21 +00:00
|
|
|
#include <KIO/ApplicationLauncherJob>
|
2021-12-22 23:29:00 +00:00
|
|
|
#include <KSharedConfig>
|
|
|
|
|
|
2022-04-07 14:52:12 +00:00
|
|
|
/**
|
|
|
|
|
* Miscellaneous class to put utility functions used in the shell.
|
|
|
|
|
*
|
|
|
|
|
* @author Devin Lin <devin@kde.org>
|
|
|
|
|
**/
|
2022-03-21 14:00:03 +00:00
|
|
|
class ShellUtil : public QObject
|
2021-12-22 23:29:00 +00:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2022-10-12 16:00:12 +00:00
|
|
|
Q_PROPERTY(bool isSystem24HourFormat READ isSystem24HourFormat NOTIFY isSystem24HourFormatChanged)
|
2021-12-22 23:29:00 +00:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
ShellUtil(QObject *parent = nullptr);
|
|
|
|
|
static ShellUtil *instance();
|
|
|
|
|
|
2022-04-07 14:52:12 +00:00
|
|
|
/**
|
|
|
|
|
* 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);
|
|
|
|
|
|
|
|
|
|
/**
|
2022-10-12 21:00:21 +00:00
|
|
|
* Launch an application by name. Sets the internal "launched app" state.
|
2022-04-07 14:52:12 +00:00
|
|
|
*
|
2022-10-12 21:00:21 +00:00
|
|
|
* @param storageId The storage id of the application to launch.
|
2022-04-07 14:52:12 +00:00
|
|
|
*/
|
2022-10-12 21:00:21 +00:00
|
|
|
Q_INVOKABLE void launchApp(const QString &storageId);
|
2021-12-22 23:29:00 +00:00
|
|
|
|
2022-04-07 14:52:12 +00:00
|
|
|
/**
|
|
|
|
|
* Whether the system is using 24 hour format.
|
|
|
|
|
*/
|
|
|
|
|
Q_INVOKABLE bool isSystem24HourFormat();
|
2021-12-22 23:29:00 +00:00
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
|
void isSystem24HourFormatChanged();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
KConfigWatcher::Ptr m_localeConfigWatcher;
|
|
|
|
|
KSharedConfig::Ptr m_localeConfig;
|
|
|
|
|
};
|