mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-09-19 01:22:20 +08:00
feat: support wayland
This commit is contained in:
parent
0179c2f04f
commit
89a3ab0b4c
@ -36,7 +36,7 @@ If you are using Debian11/Ubuntu 20.04, you will need extra dependency package.
|
|||||||
For Deepin V20/UOS 21/ Debian 11
|
For Deepin V20/UOS 21/ Debian 11
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
sudo apt install git qt5-default debhelper pkg-config qtchooser libqt5core5a libqt5gui5 libqt5widgets5 libqt5network5 libqt5concurrent5 libdtkcore-dev libdtkgui-dev libdtkwidget-dev qttools5-private-dev libnotify-dev qtwebengine5-dev fakeroot qtwayland5 qtwayland5-dev-tools
|
sudo apt install git qt5-default debhelper pkg-config qtchooser libqt5core5a libqt5gui5 libqt5widgets5 libqt5network5 libqt5concurrent5 libdtkcore-dev libdtkgui-dev libdtkwidget-dev qttools5-private-dev libnotify-dev qtwebengine5-dev fakeroot qtwayland5 qtwayland5-dev-tools dde-qt5wayland-plugin
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
Deepin V20/UOS 21 系统下, 安装依赖
|
Deepin V20/UOS 21 系统下, 安装依赖
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
sudo apt install git qt5-default debhelper pkg-config qtchooser libqt5core5a libqt5gui5 libqt5widgets5 libqt5network5 libqt5concurrent5 libdtkcore-dev libdtkgui-dev libdtkwidget-dev qttools5-private-dev libnotify-dev qtwebengine5-dev fakeroot qtwayland5 qtwayland5-dev-tools
|
sudo apt install git qt5-default debhelper pkg-config qtchooser libqt5core5a libqt5gui5 libqt5widgets5 libqt5network5 libqt5concurrent5 libdtkcore-dev libdtkgui-dev libdtkwidget-dev qttools5-private-dev libnotify-dev qtwebengine5-dev fakeroot qtwayland5 qtwayland5-dev-tools dde-qt5wayland-plugin
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
29
src/main.cpp
29
src/main.cpp
@ -7,6 +7,8 @@
|
|||||||
#include <DAboutDialog>
|
#include <DAboutDialog>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <DWidgetUtil>
|
#include <DWidgetUtil>
|
||||||
|
#include <DSysInfo>
|
||||||
|
|
||||||
DCORE_USE_NAMESPACE
|
DCORE_USE_NAMESPACE
|
||||||
DWIDGET_USE_NAMESPACE
|
DWIDGET_USE_NAMESPACE
|
||||||
|
|
||||||
@ -21,10 +23,28 @@ int main(int argc, char *argv[])
|
|||||||
if (!QString(qgetenv("XDG_CURRENT_DESKTOP")).toLower().startsWith("deepin")) {
|
if (!QString(qgetenv("XDG_CURRENT_DESKTOP")).toLower().startsWith("deepin")) {
|
||||||
setenv("XDG_CURRENT_DESKTOP", "Deepin", 1);
|
setenv("XDG_CURRENT_DESKTOP", "Deepin", 1);
|
||||||
}
|
}
|
||||||
|
bool isWayland = false;
|
||||||
|
auto e = QProcessEnvironment::systemEnvironment();
|
||||||
|
QString XDG_SESSION_TYPE = e.value(QStringLiteral("XDG_SESSION_TYPE"));
|
||||||
|
QString WAYLAND_DISPLAY = e.value(QStringLiteral("WAYLAND_DISPLAY"));
|
||||||
|
if (XDG_SESSION_TYPE == QLatin1String("wayland") || WAYLAND_DISPLAY.contains(QLatin1String("wayland"), Qt::CaseInsensitive)){
|
||||||
|
isWayland = true;
|
||||||
|
}
|
||||||
|
qDebug() << "Wayland enabled:" << isWayland;
|
||||||
|
|
||||||
|
if(isWayland && !Dtk::Core::DSysInfo::isDDE()){
|
||||||
|
qputenv("QT_QPA_PLATFORM", "wayland");
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (isWayland && Dtk::Core::DSysInfo::isDDE()){
|
||||||
|
qputenv("QT_QPA_PLATFORM", "dwayland");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qputenv("QT_QPA_PLATFORM", "dxcb");
|
||||||
|
}
|
||||||
DApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // 开启 Hidpi 支持
|
DApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // 开启 Hidpi 支持
|
||||||
#ifndef DSTORE_NO_DXCBs
|
|
||||||
DApplication::loadDXcbPlugin(); // 加载 DXCB 插件
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 浏览器开启 GPU 支持
|
// 浏览器开启 GPU 支持
|
||||||
qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--ignore-gpu-blocklist --enable-gpu-rasterization --enable-native-gpu-memory-buffers --enable-accelerated-video-decode");
|
qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--ignore-gpu-blocklist --enable-gpu-rasterization --enable-native-gpu-memory-buffers --enable-accelerated-video-decode");
|
||||||
@ -48,7 +68,7 @@ int main(int argc, char *argv[])
|
|||||||
a.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true);
|
a.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true);
|
||||||
}
|
}
|
||||||
a.setAttribute(Qt::AA_UseHighDpiPixmaps);
|
a.setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||||
a.loadDXcbPlugin();
|
a.setApplicationDisplayName("Spark Store");
|
||||||
|
|
||||||
a.loadTranslator(); // 载入翻译
|
a.loadTranslator(); // 载入翻译
|
||||||
|
|
||||||
@ -125,6 +145,7 @@ int main(int argc, char *argv[])
|
|||||||
w.openUrl(QUrl(argv[1]));
|
w.openUrl(QUrl(argv[1]));
|
||||||
}
|
}
|
||||||
w.show();
|
w.show();
|
||||||
|
w.setWindowTitle("Spark Store");
|
||||||
|
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user