From 8e9489b7f7e93e57f4acdb0ca8d7266f3ac54073 Mon Sep 17 00:00:00 2001 From: gfdgd_xi <3025613752@qq.com> Date: Mon, 1 Jan 2024 17:33:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=86=E5=8F=B2=E8=AE=B0=E5=BD=95=E7=9A=84?= =?UTF-8?q?=E5=88=9D=E6=AD=A5=E8=AF=BB=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mainwindow.cpp | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++ mainwindow.h | 3 +++ 2 files changed, 70 insertions(+) diff --git a/mainwindow.cpp b/mainwindow.cpp index 28c032c..1c3b81f 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -12,6 +12,8 @@ #include #include #include +#include +#include using namespace std; MainWindow::MainWindow(){ @@ -180,6 +182,12 @@ MainWindow::MainWindow(){ widget->setLayout(mainLayout); window->show(); + CheckWine(); + + // 控件设置 + //if(setting.value("AutoWine") != 0) + o1->addItems(canUseWine); + // 一个 Wine 都没有却用 Wine 的功能 // 还是要处理的,至少不会闪退 if(o1->currentText() == ""){ @@ -204,6 +212,18 @@ QString MainWindow::readtxt(QString path){ return things; } +QByteArray MainWindow::readtxtByte(QString path){ + QFile file(path); + file.open(QIODevice::ReadOnly); + QByteArray things = file.readAll(); + file.close(); + return things; +} + +void MainWindow::write_txt(QString path, QString things){ + +} + /* * 检测 Wine */ @@ -254,6 +274,7 @@ void MainWindow::CheckWine(){ if(QDir("/persistent/linglong/layers/").exists()){ // 判断是否使用 linglong for(QString i : QDir("/persistent/linglong/layers/").entryList()){ try{ + break; // bug QString dire = QDir("/persistent/linglong/layers/" + i).entryList()[-1]; QString arch = QDir("/persistent/linglong/layers/" + i + "/" + dire)[-1]; if(QFile::exists("/persistent/linglong/layers/" + i + "/" + dire + "/" + arch + "/runtime/bin/deepin-wine6-stable")){ @@ -284,4 +305,50 @@ void MainWindow::CheckWine(){ } } } + QJsonParseError jsonError; + QJsonDocument jsonDocument; + QJsonObject jsonObject; + QStringList historyList[] = {shellHistory, findExeHistory, wineBottonHistory, isoPath, isoPathFound}; + QStringList historyListPath = {homePath + "/.config/deepin-wine-runner/ShellHistory.json", + homePath + "/.config/deepin-wine-runner/FindExeHistory.json", + homePath + "/.config/deepin-wine-runner/WineBottonHistory.json", + homePath + "/.config/deepin-wine-runner/ISOPath.json", + homePath + "/.config/deepin-wine-runner/ISOPathFound.json"}; + for(int i = 0; i <= historyList->size(); i++){ + QStringList *list = &historyList[i]; + jsonDocument = QJsonDocument(QJsonDocument::fromJson(readtxtByte(historyListPath[i]))); + jsonObject = jsonDocument.object(); + list->clear(); + for(QString i: jsonObject.keys()){ + list->append(jsonObject.value(i).toString()); + } + } + qDebug() << jsonError.errorString(); + jsonDocument = QJsonDocument(QJsonDocument::fromJson(readtxtByte(homePath + "/.config/deepin-wine-runner/WineSetting.json"))); + jsonObject = jsonDocument.object(); + setting.clear(); + for(QString i: jsonObject.keys()){ + setting.insert(i, jsonObject.value(i).toString()); + } + for(QString i: QDir(programPath + "/wine/").entryList()){ + if(QDir(programPath + "/wine/" + i).exists() && QFileInfo(programPath + "/wine/" + i).isDir()){ + QStringList nameValue = {{"", ""}}; + try{ + if(QFile::exists("/opt/deepin-box86/box86")){ + nameValue.append(QStringList() << "基于 UOS box86 的 " << + "WINEPREDLL='" + programPath + "/dlls-arm' WINEDLLPATH=/opt/deepin-wine6-stable/lib BOX86_NOSIGSEGV=1"\ + " /opt/deepin-box86/box86 "); + } + if(!system("which box86")){ + nameValue.append(QStringList() << "基于 box86 的 " << "box86 "); + } + if(!system("which box64")){ + nameValue.append(QStringList() << "基于 box86 的 " << "box86 "); + } + } + catch(QString msg){ + qDebug() << msg; + } + } + } } diff --git a/mainwindow.h b/mainwindow.h index a38def4..7f17177 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -14,6 +14,8 @@ public: void CheckWine(); QString get_home(); QString readtxt(QString path); + void write_txt(QString path, QString things); + QByteArray readtxtByte(QString path); private: QString homePath = QDir::homePath(); @@ -30,5 +32,6 @@ private: QStringList isoPathFound; QMap setting; + }; #endif // MAINWINDOW_H