mirror of
https://gitee.com/gfdgd-xi/deep-wine-runner
synced 2025-12-14 02:52:03 +08:00
历史记录的初步读取
This commit is contained in:
@@ -12,6 +12,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QIODevice>
|
#include <QIODevice>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonObject>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
MainWindow::MainWindow(){
|
MainWindow::MainWindow(){
|
||||||
@@ -180,6 +182,12 @@ MainWindow::MainWindow(){
|
|||||||
widget->setLayout(mainLayout);
|
widget->setLayout(mainLayout);
|
||||||
window->show();
|
window->show();
|
||||||
|
|
||||||
|
CheckWine();
|
||||||
|
|
||||||
|
// 控件设置
|
||||||
|
//if(setting.value("AutoWine") != 0)
|
||||||
|
o1->addItems(canUseWine);
|
||||||
|
|
||||||
// 一个 Wine 都没有却用 Wine 的功能
|
// 一个 Wine 都没有却用 Wine 的功能
|
||||||
// 还是要处理的,至少不会闪退
|
// 还是要处理的,至少不会闪退
|
||||||
if(o1->currentText() == ""){
|
if(o1->currentText() == ""){
|
||||||
@@ -204,6 +212,18 @@ QString MainWindow::readtxt(QString path){
|
|||||||
return things;
|
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
|
* 检测 Wine
|
||||||
*/
|
*/
|
||||||
@@ -254,6 +274,7 @@ void MainWindow::CheckWine(){
|
|||||||
if(QDir("/persistent/linglong/layers/").exists()){ // 判断是否使用 linglong
|
if(QDir("/persistent/linglong/layers/").exists()){ // 判断是否使用 linglong
|
||||||
for(QString i : QDir("/persistent/linglong/layers/").entryList()){
|
for(QString i : QDir("/persistent/linglong/layers/").entryList()){
|
||||||
try{
|
try{
|
||||||
|
break; // bug
|
||||||
QString dire = QDir("/persistent/linglong/layers/" + i).entryList()[-1];
|
QString dire = QDir("/persistent/linglong/layers/" + i).entryList()[-1];
|
||||||
QString arch = QDir("/persistent/linglong/layers/" + i + "/" + dire)[-1];
|
QString arch = QDir("/persistent/linglong/layers/" + i + "/" + dire)[-1];
|
||||||
if(QFile::exists("/persistent/linglong/layers/" + i + "/" + dire + "/" + arch + "/runtime/bin/deepin-wine6-stable")){
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ public:
|
|||||||
void CheckWine();
|
void CheckWine();
|
||||||
QString get_home();
|
QString get_home();
|
||||||
QString readtxt(QString path);
|
QString readtxt(QString path);
|
||||||
|
void write_txt(QString path, QString things);
|
||||||
|
QByteArray readtxtByte(QString path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString homePath = QDir::homePath();
|
QString homePath = QDir::homePath();
|
||||||
@@ -30,5 +32,6 @@ private:
|
|||||||
QStringList isoPathFound;
|
QStringList isoPathFound;
|
||||||
QMap<QString, QString> setting;
|
QMap<QString, QString> setting;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|||||||
Reference in New Issue
Block a user