10#include <QCoreApplication>
11#include <QRegularExpression>
12#include <QStandardPaths>
20template <
typename Func1>
21inline void TimerSingleShot(
int msec, Func1 slot)
23#if QT_VERSION >= 0x050500
24 QTimer::singleShot(msec, slot);
26 QTimer *timer =
new QTimer;
27 timer->setSingleShot(
true);
28 timer->setInterval(msec);
29 timer->moveToThread(qApp->thread());
30 QObject::connect(timer, &QTimer::timeout, slot);
31 QObject::connect(timer, &QTimer::timeout, timer, &QTimer::deleteLater);
32 if (QThread::currentThread() == qApp->thread()) { timer->start(); }
33 else { QMetaObject::invokeMethod(timer,
"start", Qt::QueuedConnection); }
38void SecureErase(T *p,
size_t size)
40 static_assert(std::is_standard_layout<T>::value && std::is_trivially_destructible<T>::value,
41 "try to erase content of raw pointer, but type T isn't suitable");
43 std::memset(p, 0, size);
47void SecureErase(T &obj)
49 static_assert(std::is_default_constructible<typename T::value_type>::value,
50 "container's value type must have a default constructor.");
52 for (
typename T::iterator i = obj.begin(); i != obj.end(); ++i) {
53 *i =
typename T::value_type{};
57QString escapeToObjectPath(
const QByteArray &str)
noexcept;
59QString escapeToObjectPath(
const QString &str)
noexcept;
QStringList getAbsolutePathFromAppId(const QString &appId) noexcept
从appId中获取符合条件的Desktop文件路径
QString unescapeFromObjectPath(const QString &str) noexcept
将DBus ObjectPath的部分路径转义成原来的字符串
QString getAppIdFromAbsolutePath(const QString &path) noexcept
从desktop文件的绝对路径中提取出AppId