Skip to content

Commit

Permalink
sync: from linuxdeepin/dtkgui
Browse files Browse the repository at this point in the history
Synchronize source files from linuxdeepin/dtkgui.

Source-pull-request: linuxdeepin/dtkgui#207
  • Loading branch information
deepin-ci-robot committed Nov 10, 2023
1 parent 0ced4cb commit 4547dcd
Show file tree
Hide file tree
Showing 10 changed files with 483 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Copyright: None
License: CC0-1.0

# gitignore
Files: .gitignore
Files: .gitignore .syncexclude
Copyright: None
License: CC0-1.0

Expand Down
11 changes: 11 additions & 0 deletions .syncexclude
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Paths that will be exclude from synchronize workflow
# Please use relative path which use project directory as root
# Notice that
# * .git
# * debian
# * archlinux
# * .obs
# * .github
# are always ignored
linglong.yaml
conanfile.py
164 changes: 164 additions & 0 deletions docs/util/ddesktopservices.h.zh_CN.dox
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
/*!
@~chinese
@file include/util/ddesktopservices.h
@ingroup DesktopServices
@brief Dtk 提供常见桌面服务的方法工具类

@namespace Dtk::Gui::DDesktopServices ddesktopservices.h
@details 用于提供一些接口,包括在文件管理器中显示目录,显示文件,显示文件属性,移入回收站,播放系统音效等。

@enum Dtk::Gui::DDesktopServices::SystemSoundEffect
@brief 系统音效的枚举
@var Dtk::Gui::DDesktopServices::SSE_Notifications
@brief 显示通知的音效
@var Dtk::Gui::DDesktopServices::SEE_Screenshot
@brief 截屏的音效
@var Dtk::Gui::DDesktopServices::SSE_EmptyTrash
@brief 清空回收站的音效
@var Dtk::Gui::DDesktopServices::SSE_SendFileComplete
@brief 完成发送文件(到桌面)的音效
@var Dtk::Gui::DDesktopServices::SSE_BootUp
@brief 开机的音效
@var Dtk::Gui::DDesktopServices::SSE_Shutdown
@brief 关机的音效
@var Dtk::Gui::DDesktopServices::SSE_Logout
@brief 注销的音效
@var Dtk::Gui::DDesktopServices::SSE_WakeUp
@brief 唤醒的音效
@var Dtk::Gui::DDesktopServices::SSE_VolumeChange
@brief 音量调节的音效
@var Dtk::Gui::DDesktopServices::SSE_LowBattery
@brief 低电量的音效
@var Dtk::Gui::DDesktopServices::SSE_PlugIn
@brief 电源接入的音效
@var Dtk::Gui::DDesktopServices::SSE_PlugOut
@brief 电源移除的音效
@var Dtk::Gui::DDesktopServices::SSE_DeviceAdded
@brief 移动设备接入的音效
@var Dtk::Gui::DDesktopServices::SSE_DeviceRemoved
@brief 移动设备移除的音效
@var Dtk::Gui::DDesktopServices::SSE_Error
@brief 错误提示的音效

@fn Dtk::Gui::DDesktopServices::showFolder(const QString &localFilePath, const QString &startupId = QString())
@details 通过文件管理器显示目录
@param[in] localFilePath 要显示的目录路径
@param[in] startupId 本次启动的id, 默认为空
@return 调用成功返回 true, 否则返回 false

@fn Dtk::Gui::DDesktopServices::showFolders(const QList<QString> &localFilePaths, const QString &startupId = QString())
@details 通过文件管理器显示多个目录
@param[in] localFilePaths 要显示的目录路径列表
@param[in] startupId 本次启动的id, 默认为空
@return 调用成功返回 true, 否则返回 false

@fn Dtk::Gui::DDesktopServices::showFolder(const QUrl &url, const QString &startupId = QString())
@details 通过文件管理器显示目录
@param[in] url 要显示的目录 QUrl 形式路径
@param[in] startupId 本次启动的id, 默认为空
@return 调用成功返回 true, 否则返回 false

@fn Dtk::Gui::DDesktopServices::showFolders(const QList<QUrl> &urls, const QString &startupId = QString())
@details 通过文件管理器显示多个目录
@param[in] urls 要显示的目录路径 url 列表
@param[in] startupId 本次启动的id, 默认为空
@return 调用成功返回 true, 否则返回 false

@fn Dtk::Gui::DDesktopServices::showFileItemProperty(const QString &localFilePath, const QString &startupId = QString())
@details 通过文件管理器显示文件的属性
@param[in] localFilePath 要显示的文件路径
@param[in] startupId 本次启动的id, 默认为空
@return 调用成功返回 true, 否则返回 false

@fn Dtk::Gui::DDesktopServices::showFileItemProperties(const QList<QString> &localFilePaths, const QString &startupId = QString())
@details 通过文件管理器显示多个文件的属性
@param[in] localFilePaths 要显示的文件路径列表
@param[in] startupId 本次启动的id, 默认为空
@return 调用成功返回 true, 否则返回 false

@fn Dtk::Gui::DDesktopServices::showFileItemProperty(const QUrl &url, const QString &startupId = QString())
@details 通过文件管理器显示文件的属性
@param[in] url 要显示的文件 QUrl 形式路径
@param[in] startupId 本次启动的id, 默认为空
@return 调用成功返回 true, 否则返回 false

@fn Dtk::Gui::DDesktopServices::showFileItemProperties(const QList<QUrl> &urls, const QString &startupId = QString())
@details 通过文件管理器显示多个文件的属性
@param[in] urls 要显示的目录路径 url 列表
@param[in] startupId 本次启动的id, 默认为空
@return 调用成功返回 true, 否则返回 false

@fn Dtk::Gui::DDesktopServices::showFileItem(const QString &localFilePath, const QString &startupId = QString())
@details 通过文件管理器在父目录中显示并选中文件(目录)
@param[in] localFilePath 要显示(选中)的文件(目录)路径
@param[in] startupId 本次启动的id, 默认为空
@return 调用成功返回 true, 否则返回 false

@fn Dtk::Gui::DDesktopServices::showFileItems(const QList<QString> &localFilePaths, const QString &startupId = QString())
@details 通过文件管理器父目录中显示并选中多个文件(目录)
@param[in] localFilePaths 要显示(选中)的文件(目录)路径列表
@param[in] startupId 本次启动的id, 默认为空
@return 调用成功返回 true, 否则返回 false

@fn Dtk::Gui::DDesktopServices::showFileItem(const QUrl &url, const QString &startupId = QString())
@details 通过文件管理器在父目录中显示并选中文件(目录)
@param[in] url 要显示(选中)的文件(目录)QUrl 形式路径
@param[in] startupId 本次启动的id, 默认为空
@return 调用成功返回 true, 否则返回 false

@fn Dtk::Gui::DDesktopServices::showFileItems(const QList<QUrl> &urls, const QString &startupId = QString())
@details 通过文件管理器父目录中显示并选中多个文件(目录)
@param[in] urls 要显示选中)的文件(目录)路径 url 列表
@param[in] startupId 本次启动的id, 默认为空
@return 调用成功返回 true, 否则返回 false

@fn Dtk::Gui::DDesktopServices::trash(const QString &localFilePath)
@details 通过文件管理器将文件移入回收站
@param[in] localFilePath 要移入回收站的文件路径
@return 调用成功返回 true, 否则返回 false

@fn Dtk::Gui::DDesktopServices::trash(const QList<QString> &localFilePaths)
@details 通过文件管理器将多个文件移入回收站
@param[in] localFilePaths 要移入回收站的文件路径列表
@return 调用成功返回 true, 否则返回 false

@fn Dtk::Gui::DDesktopServices::trash(const QUrl &url)
@details 通过文件管理器将文件移入回收站
@param[in] url 要移入回收站的文件 url 路径
@return 调用成功返回 true, 否则返回 false

@fn Dtk::Gui::DDesktopServices::trash(const QList<QUrl> &urls)
@details 通过文件管理器将多个文件移入回收站
@param[in] urls 要移入回收站的文件路径 url 列表
@return 调用成功返回 true, 否则返回 false

@fn Dtk::Gui::DDesktopServices::playSystemSoundEffect(const SystemSoundEffect &effect)
@details 播放系统音效。如果系统音效被禁用或者要播放音效被禁用将播放失败
@param[in] effect 要播放的音效,见枚举 Dtk::Gui::DDesktopServices::SystemSoundEffect
@return 调用成功返回 true, 否则返回 false

@fn Dtk::Gui::DDesktopServices::playSystemSoundEffect(const QString &name)
@details 根据音效名播放系统音效。如果系统音效被禁用或者要播放音效被禁用将播放失败
@param[in] name 要播放的音效名称,见 Dtk::Gui::DDesktopServices::getNameByEffectType
@return 调用成功返回 true, 否则返回 false

@fn Dtk::Gui::DDesktopServices::previewSystemSoundEffect(const SystemSoundEffect &effect)
@details 系统音效预览。
@param[in] effect 要播放的音效,见枚举 Dtk::Gui::DDesktopServices::SystemSoundEffect
@return 调用成功返回 true, 否则返回 false

@fn Dtk::Gui::DDesktopServices::previewSystemSoundEffect(const QString &name)
@details 根据音效名预览系统音效。
@param[in] name 要播放的音效名称,见 Dtk::Gui::DDesktopServices::getNameByEffectType
@return 调用成功返回 true, 否则返回 false

@fn Dtk::Gui::DDesktopServices::getNameByEffectType(const SystemSoundEffect &effect)
@details 根据音效名预览系统音效。
@param[in] effect 要获取名称的音效,见枚举 Dtk::Gui::DDesktopServices::SystemSoundEffect
@return QString effect 对应的音效名称

@fn Dtk::Gui::DDesktopServices::errorMessage()
@details 文件管理器相关调用出错时可以通过此接口获取错误信息
@return 错误信息

*/
1 change: 1 addition & 0 deletions include/DtkGui/DDesktopServices
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "ddesktopservices.h"
74 changes: 74 additions & 0 deletions include/util/ddesktopservices.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#pragma once

#include <dtkgui_global.h>

#include <QMetaType>
#include <QUrl>

DGUI_BEGIN_NAMESPACE

class DDesktopServices
{
public:

#ifdef Q_OS_LINUX
enum SystemSoundEffect {
SSE_Notifications,
SEE_Screenshot,
SSE_EmptyTrash,
SSE_SendFileComplete,
SSE_BootUp,
SSE_Shutdown,
SSE_Logout,
SSE_WakeUp,
SSE_VolumeChange,
SSE_LowBattery,
SSE_PlugIn,
SSE_PlugOut,
SSE_DeviceAdded,
SSE_DeviceRemoved,
SSE_Error,
};
#endif

static bool showFolder(const QString &localFilePath, const QString &startupId = QString());
static bool showFolders(const QList<QString> &localFilePaths, const QString &startupId = QString());
static bool showFolder(const QUrl &url, const QString &startupId = QString());
static bool showFolders(const QList<QUrl> &urls, const QString &startupId = QString());

static bool showFileItemProperty(const QString &localFilePath, const QString &startupId = QString());
static bool showFileItemProperties(const QList<QString> &localFilePaths, const QString &startupId = QString());
static bool showFileItemProperty(const QUrl &url, const QString &startupId = QString());
static bool showFileItemProperties(const QList<QUrl> &urls, const QString &startupId = QString());

static bool showFileItem(const QString &localFilePath, const QString &startupId = QString());
static bool showFileItems(const QList<QString> &localFilePaths, const QString &startupId = QString());
static bool showFileItem(const QUrl &url, const QString &startupId = QString());
static bool showFileItems(const QList<QUrl> &urls, const QString &startupId = QString());

static bool trash(const QString &localFilePath);
static bool trash(const QList<QString> &localFilePaths);
static bool trash(const QUrl &url);
static bool trash(const QList<QUrl> &urls);

#ifdef Q_OS_LINUX
static bool playSystemSoundEffect(const SystemSoundEffect &effect);
static bool playSystemSoundEffect(const QString &name);
static bool previewSystemSoundEffect(const SystemSoundEffect &effect);
static bool previewSystemSoundEffect(const QString &name);
static QString getNameByEffectType(const SystemSoundEffect &effect);
#endif

static QString errorMessage();
};

DGUI_END_NAMESPACE

#ifdef Q_OS_LINUX
Q_DECLARE_METATYPE(DTK_GUI_NAMESPACE::DDesktopServices::SystemSoundEffect)
#endif

Loading

0 comments on commit 4547dcd

Please sign in to comment.