forked from linuxdeepin/dtkgui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: move ddesktopservices to dtkgui
- move ddesktopservices from dtkwidget to dtkgui - add docs for ddesktopservice - showFileItemPropertie ==> showFileItemProperty - use dbus to check SoundEffect.Enabled instead of Gsettings Issue: linuxdeepin/dtk#134
- Loading branch information
Showing
4 changed files
with
452 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 错误信息 | ||
|
||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "ddesktopservices.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// 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: | ||
|
||
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, | ||
}; | ||
|
||
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); | ||
|
||
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); | ||
|
||
static QString errorMessage(); | ||
}; | ||
|
||
DGUI_END_NAMESPACE | ||
|
||
#ifdef Q_OS_LINUX | ||
Q_DECLARE_METATYPE(DTK_GUI_NAMESPACE::DDesktopServices::SystemSoundEffect) | ||
#endif | ||
|
Oops, something went wrong.