mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-14 04:42:03 +08:00
fix: 修复非deepin的wayland环境下ui显示
This commit is contained in:
20
src/main.cpp
20
src/main.cpp
@@ -18,6 +18,8 @@ int main(int argc, char *argv[])
|
|||||||
static const QString version = "Version 4.1.1";
|
static const QString version = "Version 4.1.1";
|
||||||
static const QDate buildDate = QLocale(QLocale::English).toDate(QString(__DATE__).replace(" ", " 0"), "MMM dd yyyy");
|
static const QDate buildDate = QLocale(QLocale::English).toDate(QString(__DATE__).replace(" ", " 0"), "MMM dd yyyy");
|
||||||
static const QTime buildTime = QTime::fromString(__TIME__, "hh:mm:ss");
|
static const QTime buildTime = QTime::fromString(__TIME__, "hh:mm:ss");
|
||||||
|
QSettings readConfig(QDir::homePath() + "/.config/spark-store/config.ini", QSettings::IniFormat);
|
||||||
|
QSettings *setConfig = new QSettings(QDir::homePath() + "/.config/spark-store/config.ini", QSettings::IniFormat);
|
||||||
|
|
||||||
// 设置桌面环境环境变量
|
// 设置桌面环境环境变量
|
||||||
bool isDeepinOS = true;
|
bool isDeepinOS = true;
|
||||||
@@ -30,11 +32,22 @@ int main(int argc, char *argv[])
|
|||||||
auto e = QProcessEnvironment::systemEnvironment();
|
auto e = QProcessEnvironment::systemEnvironment();
|
||||||
QString XDG_SESSION_TYPE = e.value(QStringLiteral("XDG_SESSION_TYPE"));
|
QString XDG_SESSION_TYPE = e.value(QStringLiteral("XDG_SESSION_TYPE"));
|
||||||
QString WAYLAND_DISPLAY = e.value(QStringLiteral("WAYLAND_DISPLAY"));
|
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))
|
||||||
{
|
{
|
||||||
isWayland = true;
|
isWayland = true;
|
||||||
}
|
}
|
||||||
qDebug() << "Wayland enabled:" << isWayland;
|
setConfig->setValue("build/isWayland", isWayland);
|
||||||
|
setConfig->setValue("build/isDeepinOS", isDeepinOS);
|
||||||
|
|
||||||
|
// Check config file, if there is no wayland config, then set it to default, which means use wayland if possible.
|
||||||
|
if (!readConfig.contains("build/useWayland"))
|
||||||
|
{
|
||||||
|
setConfig->setValue("build/useWayland", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool useWayland = readConfig.value("build/useWayland").toBool();
|
||||||
|
qDebug() << "System Wayland enabled:" << isWayland << ". Spark Wayland enabled:" << useWayland;
|
||||||
|
|
||||||
// Set display backend
|
// Set display backend
|
||||||
if (isWayland && useWayland && !(Dtk::Core::DSysInfo::isDDE() || isDeepinOS))
|
if (isWayland && useWayland && !(Dtk::Core::DSysInfo::isDDE() || isDeepinOS))
|
||||||
@@ -77,16 +90,13 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
a.loadTranslator(); // 载入翻译
|
a.loadTranslator(); // 载入翻译
|
||||||
|
|
||||||
QSettings readConfig(QDir::homePath() + "/.config/spark-store/config.ini", QSettings::IniFormat);
|
|
||||||
|
|
||||||
if (readConfig.value("build/version").toString() != version)
|
if (readConfig.value("build/version").toString() != version)
|
||||||
{
|
{
|
||||||
qDebug() << "Spark Store has been updated!";
|
qDebug() << "Spark Store has been updated!";
|
||||||
QSettings *setConfig = new QSettings(QDir::homePath() + "/.config/spark-store/config.ini", QSettings::IniFormat);
|
|
||||||
setConfig->setValue("build/version", version);
|
setConfig->setValue("build/version", version);
|
||||||
setConfig->setValue("build/time", buildDate.toString("yyyy.MM.dd") + "-" + buildTime.toString());
|
setConfig->setValue("build/time", buildDate.toString("yyyy.MM.dd") + "-" + buildTime.toString());
|
||||||
setConfig->deleteLater();
|
|
||||||
}
|
}
|
||||||
|
setConfig->deleteLater();
|
||||||
|
|
||||||
// Customized DAboutDialog
|
// Customized DAboutDialog
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <DWidgetUtil>
|
#include <DWidgetUtil>
|
||||||
#include <DGuiApplicationHelper>
|
#include <DGuiApplicationHelper>
|
||||||
|
#include <DApplicationSettings>
|
||||||
#include <QSizePolicy>
|
#include <QSizePolicy>
|
||||||
|
|
||||||
#define AppPageApplist 0
|
#define AppPageApplist 0
|
||||||
@@ -63,8 +64,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
{
|
{
|
||||||
qDebug() << "投稿器不存在,跳转页面";
|
qDebug() << "投稿器不存在,跳转页面";
|
||||||
openUrl(submitterSpk);
|
openUrl(submitterSpk);
|
||||||
}
|
} });
|
||||||
});
|
|
||||||
|
|
||||||
// 主题切换
|
// 主题切换
|
||||||
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, [=](DGuiApplicationHelper::ColorType themeType)
|
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, [=](DGuiApplicationHelper::ColorType themeType)
|
||||||
@@ -153,6 +153,10 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
downloadlistwidget->hide();
|
downloadlistwidget->hide();
|
||||||
backButtom->hide();
|
backButtom->hide();
|
||||||
ui->titlebar->setIcon(QIcon::fromTheme(":/icon/logo.svg"));
|
ui->titlebar->setIcon(QIcon::fromTheme(":/icon/logo.svg"));
|
||||||
|
|
||||||
|
// Check wayland configs
|
||||||
|
QSettings readConfig(QDir::homePath() + "/.config/spark-store/config.ini", QSettings::IniFormat);
|
||||||
|
|
||||||
QWidget *w_titlebar = new QWidget(ui->titlebar);
|
QWidget *w_titlebar = new QWidget(ui->titlebar);
|
||||||
QHBoxLayout *ly_titlebar = new QHBoxLayout(w_titlebar);
|
QHBoxLayout *ly_titlebar = new QHBoxLayout(w_titlebar);
|
||||||
QLabel *title = new QLabel(this);
|
QLabel *title = new QLabel(this);
|
||||||
@@ -160,7 +164,16 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
searchEdit->setPlaceholderText(tr("Search or enter spk://"));
|
searchEdit->setPlaceholderText(tr("Search or enter spk://"));
|
||||||
ly_titlebar->addWidget(title);
|
ly_titlebar->addWidget(title);
|
||||||
ly_titlebar->addWidget(backButtom);
|
ly_titlebar->addWidget(backButtom);
|
||||||
ly_titlebar->addStretch(2.5);
|
|
||||||
|
if (!readConfig.value("build/isDeepinOS").toBool() && readConfig.value("build/useWayland").toBool())
|
||||||
|
{
|
||||||
|
ly_titlebar->addStretch(1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ly_titlebar->addStretch(2);
|
||||||
|
}
|
||||||
|
|
||||||
ly_titlebar->addWidget(searchEdit);
|
ly_titlebar->addWidget(searchEdit);
|
||||||
ly_titlebar->addWidget(downloadButton);
|
ly_titlebar->addWidget(downloadButton);
|
||||||
ly_titlebar->addStretch(1);
|
ly_titlebar->addStretch(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user