mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00

1. 模块可配置显示隐藏,能打开控制中心的右键菜单全屏蔽。 2. gsettings最终生效的设置在各个用户之间是互相隔离的,而且root用户读取不到普通用户的gsettings配置。 3. 集中管控版本右下解关机按钮右菜菜单的锁定功能改为调用SwitchTTYAndShow Log: 引用头文件分类规范化 Task: https://pms.uniontech.com/zentao/task-view-30817.html Change-Id: I5ae833f61864ba1874c8ceb75351d569614ab235 Reviewed-on: http://gerrit.uniontech.com/c/dde-dock/+/2377 Reviewed-by: <mailman@uniontech.com> Reviewed-by: niecheng <niecheng@uniontech.com> Reviewed-by: wangwei <wangwei@uniontech.com> Tested-by: <mailman@uniontech.com>
75 lines
2.1 KiB
C++
75 lines
2.1 KiB
C++
#include <QPixmap>
|
|
#include <QImageReader>
|
|
#include <QApplication>
|
|
#include <QScreen>
|
|
#include <QGSettings>
|
|
|
|
namespace Utils {
|
|
|
|
#define ICBC_CONF_FILE "/etc/deepin/icbc.conf"
|
|
|
|
inline QPixmap renderSVG(const QString &path, const QSize &size, const qreal devicePixelRatio) {
|
|
QImageReader reader;
|
|
QPixmap pixmap;
|
|
reader.setFileName(path);
|
|
if (reader.canRead()) {
|
|
reader.setScaledSize(size * devicePixelRatio);
|
|
pixmap = QPixmap::fromImage(reader.read());
|
|
pixmap.setDevicePixelRatio(devicePixelRatio);
|
|
}
|
|
else {
|
|
pixmap.load(path);
|
|
}
|
|
|
|
return pixmap;
|
|
}
|
|
|
|
inline QScreen * screenAt(const QPoint &point) {
|
|
for (QScreen *screen : qApp->screens()) {
|
|
const QRect r { screen->geometry() };
|
|
const QRect rect { r.topLeft(), r.size() * screen->devicePixelRatio() };
|
|
if (rect.contains(point)) {
|
|
return screen;
|
|
}
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
// 判断坐标是否位于屏幕边缘
|
|
inline bool onScreenEdge(const QPoint &point) {
|
|
for (QScreen *screen : qApp->screens()) {
|
|
const QRect r { screen->geometry() };
|
|
QRect rect { r.topLeft(), r.size() * screen->devicePixelRatio() };
|
|
if ( point.y() == screen->geometry().y()+screen->geometry().height()
|
|
|| point.x() == screen->geometry().x()+screen->geometry().width()) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
inline QScreen * screenAtByScaled(const QPoint &point) {
|
|
for (QScreen *screen : qApp->screens()) {
|
|
if (screen->geometry().contains(point)) {
|
|
return screen;
|
|
}
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
inline bool isSettingConfigured(const QString& id, const QString& path, const QString& keyName) {
|
|
if (!QGSettings::isSchemaInstalled(id.toUtf8())) {
|
|
return false;
|
|
}
|
|
QGSettings setting(id.toUtf8(), path.toUtf8());
|
|
QVariant v = setting.get(keyName);
|
|
if (!v.isValid()) {
|
|
return false;
|
|
}
|
|
return v.toBool();
|
|
}
|
|
}
|