Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions libimageviewer/imageviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ ImageViewerPrivate::ImageViewerPrivate(imageViewerSpace::ImgViewerType imgViewer
ImageViewer *parent)
: q_ptr(parent)
{
// 初始化检测wayland环境
Libutils::base::initCheckWaylandEnv();

// 在界面前初始化授权配置
if (!qApp) {
qWarning() << qPrintable("Must init authorise config after QApplication initialized!");
Expand Down
18 changes: 14 additions & 4 deletions libimageviewer/unionimage/baseutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,22 +491,32 @@ bool checkCommandExist(const QString &command)
}
}

static bool g_IsWaylandEnv = false;
/**
@brief 判断当前是否为 wayland 环境
@brief 初始化判断当前是否为 wayland 环境,并缓存状态
*/
bool checkWayland()
bool initCheckWaylandEnv()
{
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))
if (XDG_SESSION_TYPE == QLatin1String("wayland") || WAYLAND_DISPLAY.contains(QLatin1String("wayland"), Qt::CaseInsensitive)) {
g_IsWaylandEnv = true;
return true;
else {
} else {
return false;
}
}

/**
@return 返回当前是否为 wayland 环境
*/
bool checkWayland()
{
return g_IsWaylandEnv;
}

} // namespace base

} // namespace utils
1 change: 1 addition & 0 deletions libimageviewer/unionimage/baseutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ bool mountDeviceExist(const QString &path);
bool checkCommandExist(const QString &command);
//bool isCommandExist(const QString &command);

bool initCheckWaylandEnv();
bool checkWayland();
} // namespace base

Expand Down
Loading