feat: set more scale envs to application
Signed-off-by: ComixHe <heyuming@deepin.org>
This commit is contained in:
parent
1a92fc1745
commit
bcb9d0c3e5
@ -23,6 +23,7 @@
|
|||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
#include <qcontainerfwd.h>
|
||||||
#include <qdbuserror.h>
|
#include <qdbuserror.h>
|
||||||
#include <qfileinfo.h>
|
#include <qfileinfo.h>
|
||||||
#include <qlogging.h>
|
#include <qlogging.h>
|
||||||
@ -166,23 +167,31 @@ bool ApplicationService::shouldBeShown(const std::unique_ptr<DesktopEntry> &entr
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ApplicationService::appendScaleFactor(QVariantMap &optionsMap) const noexcept
|
||||||
|
{
|
||||||
|
static QStringList scaleEnvs{"DEEPIN_WINE_SCALE=%1;", "GDK_DPI_SCALE=%1;", "QT_SCALE_FACTOR=%1;", "GDK_SCALE=%1;"};
|
||||||
|
QString oldEnv;
|
||||||
|
|
||||||
|
auto factor = scaleFactor();
|
||||||
|
if (auto it = optionsMap.find("env"); it != optionsMap.cend()) {
|
||||||
|
oldEnv = it->value<QString>();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto &env : scaleEnvs) {
|
||||||
|
oldEnv.append(env.arg(factor));
|
||||||
|
}
|
||||||
|
|
||||||
|
optionsMap.insert("env", oldEnv);
|
||||||
|
}
|
||||||
|
|
||||||
QDBusObjectPath
|
QDBusObjectPath
|
||||||
ApplicationService::Launch(const QString &action, const QStringList &fields, const QVariantMap &options, const QString &realExec)
|
ApplicationService::Launch(const QString &action, const QStringList &fields, const QVariantMap &options, const QString &realExec)
|
||||||
{
|
{
|
||||||
QString execStr{};
|
QString execStr{};
|
||||||
bool ok;
|
|
||||||
const auto &supportedActions = actions();
|
const auto &supportedActions = actions();
|
||||||
auto optionsMap = options;
|
auto optionsMap = options;
|
||||||
QString oldEnv;
|
|
||||||
|
|
||||||
auto factor = scaleFactor();
|
appendScaleFactor(optionsMap);
|
||||||
if (factor != 1.0) {
|
|
||||||
if (auto it = optionsMap.find("env"); it != optionsMap.cend()) {
|
|
||||||
oldEnv = it->value<QString>();
|
|
||||||
}
|
|
||||||
oldEnv.append(QString{"DEEPIN_WINE_SCALE=%1;"}.arg(factor));
|
|
||||||
optionsMap.insert("env", oldEnv);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!realExec.isNull()) { // we want to replace exec of this applications.
|
if (!realExec.isNull()) { // we want to replace exec of this applications.
|
||||||
if (realExec.isEmpty()) {
|
if (realExec.isEmpty()) {
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <qcontainerfwd.h>
|
||||||
|
#include <qvariant.h>
|
||||||
|
|
||||||
double getScaleFactor() noexcept;
|
double getScaleFactor() noexcept;
|
||||||
|
|
||||||
@ -135,6 +137,7 @@ public:
|
|||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onGlobalScaleFactorChanged() noexcept;
|
void onGlobalScaleFactorChanged() noexcept;
|
||||||
|
void appendScaleFactor(QVariantMap &optionsMap) const noexcept;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
// NOTE: 'realExec' only for internal implementation
|
// NOTE: 'realExec' only for internal implementation
|
||||||
|
Loading…
Reference in New Issue
Block a user