阶段性完成,还差独立浏览器和几个别的需求。
parent
9ee232cead
commit
fd525fb8d1
|
@ -126,9 +126,6 @@
|
|||
<ClCompile Include="minibutton.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="addapp.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="addcategory.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
@ -138,6 +135,9 @@
|
|||
<ClCompile Include="userimprove.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="addapp.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtUic Include="navbar.ui">
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LocalDebuggerCommandArguments>79c86fb12b36dfa33d1a537c9af100b4c7928a9c</LocalDebuggerCommandArguments>
|
||||
<LocalDebuggerCommandArguments>autostart</LocalDebuggerCommandArguments>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LocalDebuggerCommandArguments>$(QmlDebug)</LocalDebuggerCommandArguments>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
|
|
|
@ -123,7 +123,7 @@ void ApplicationManager::onclick1(QString op, QString func, QString path, QStrin
|
|||
add_app.get_sort(), add_app.get_categories());
|
||||
if (!ok)
|
||||
{
|
||||
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("插入失败,全名是否重名"));
|
||||
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("插入失败,全名是否重名?"));
|
||||
}
|
||||
|
||||
emit refresh_tab();
|
||||
|
@ -153,7 +153,7 @@ void ApplicationManager::onclick1(QString op, QString func, QString path, QStrin
|
|||
{
|
||||
UserImprove user_improve;
|
||||
user_improve.exec();
|
||||
if(file.open(QIODevice::WriteOnly))
|
||||
if(file.open(QIODevice::WriteOnly|QIODevice::Text))
|
||||
{
|
||||
QJsonObject rootObj;
|
||||
rootObj.insert("agree", agree);
|
||||
|
|
|
@ -15,5 +15,6 @@ extern bool autostart;
|
|||
extern bool agree;
|
||||
extern QString background_color;
|
||||
extern QString text_color;
|
||||
extern QString text_cover_color;
|
||||
extern ApplicationManager *application_manager;
|
||||
#endif //OFFICEASSISTANT_GLOBALVARIABLES_H
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "mysettingsdialog.h"
|
||||
#include "mysettingsdialog.h"
|
||||
#include <Windows.h>
|
||||
#include <QClipBoard>
|
||||
#include "netio.h"
|
||||
|
@ -12,9 +12,9 @@ MySettingsDialog::MySettingsDialog(QWidget *parent)
|
|||
setWindowFlags(Qt::WindowCloseButtonHint);
|
||||
this->setFixedSize(width(), height());
|
||||
HKEY hRoot = HKEY_CURRENT_USER;
|
||||
wchar_t *szSubKey = (wchar_t *)"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
||||
wchar_t *szSubKey = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
||||
HKEY hKey;
|
||||
DWORD dwDisposition = REG_OPENED_EXISTING_KEY; // 如果不存在不创建
|
||||
DWORD dwDisposition = REG_OPENED_EXISTING_KEY; // 如果不存在不创建
|
||||
LONG lRet = RegCreateKeyEx(hRoot, szSubKey, 0, NULL,
|
||||
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition);
|
||||
if (lRet != ERROR_SUCCESS) {
|
||||
|
@ -22,9 +22,10 @@ MySettingsDialog::MySettingsDialog(QWidget *parent)
|
|||
}
|
||||
QString app = QApplication::applicationFilePath();
|
||||
app.replace("/", "\\");
|
||||
DWORD size=128+sizeof(wchar_t);
|
||||
char reg[128] = { 0 };
|
||||
lRet = RegQueryValueEx(hKey, L"OfficeAssistant", NULL, NULL,(LPBYTE)reg, &size);
|
||||
app += " autostart";
|
||||
DWORD size=256*sizeof(wchar_t);
|
||||
wchar_t reg[256] = { 0 };
|
||||
lRet = RegQueryValueEx(hKey, LENG_NAME, NULL, NULL,(LPBYTE)reg, &size);
|
||||
if (lRet==0) {
|
||||
ui.autostart->setChecked(true);
|
||||
}
|
||||
|
@ -47,11 +48,11 @@ void MySettingsDialog::autoStart(int state)
|
|||
HKEY hRoot = HKEY_CURRENT_USER;
|
||||
wchar_t *szSubKey = (wchar_t*)L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
||||
HKEY hKey;
|
||||
DWORD dwDisposition = REG_OPENED_EXISTING_KEY; // 如果不存在不创建
|
||||
DWORD dwDisposition = REG_OPENED_EXISTING_KEY; // 如果不存在不创建
|
||||
LONG lRet = RegCreateKeyEx(hRoot, szSubKey, 0, NULL,
|
||||
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition);
|
||||
if (lRet != ERROR_SUCCESS) {
|
||||
QMessageBox::critical(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("创建开机启动项失败"));
|
||||
QMessageBox::critical(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("创建开机启动项失败"));
|
||||
return;
|
||||
}
|
||||
QString app = QApplication::applicationFilePath();
|
||||
|
@ -61,7 +62,7 @@ void MySettingsDialog::autoStart(int state)
|
|||
lRet = RegSetValueEx(hKey, LENG_NAME, 0, REG_SZ, (BYTE*)app.toStdWString().c_str(), app.length()*sizeof(wchar_t));
|
||||
if (lRet == ERROR_SUCCESS)
|
||||
{
|
||||
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("创建开机启动项成功"));
|
||||
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("创建开机启动项成功"));
|
||||
}
|
||||
RegCloseKey(hKey);
|
||||
if(agree)
|
||||
|
@ -78,14 +79,14 @@ void MySettingsDialog::autoStart(int state)
|
|||
LONG lRet = RegCreateKeyEx(hRoot, szSubKey, 0, NULL,
|
||||
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition);
|
||||
if (lRet != ERROR_SUCCESS) {
|
||||
QMessageBox::critical(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("移除开机启动项失败。"));
|
||||
QMessageBox::critical(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("移除开机启动项失败。"));
|
||||
return;
|
||||
}
|
||||
QString app = QApplication::applicationFilePath();
|
||||
lRet = RegDeleteValue(hKey, LENG_NAME);
|
||||
if (lRet == ERROR_SUCCESS)
|
||||
{
|
||||
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("移除开机启动项成功。"));
|
||||
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("移除开机启动项成功。"));
|
||||
}
|
||||
RegCloseKey(hKey);
|
||||
if(agree)
|
||||
|
@ -116,9 +117,9 @@ void MySettingsDialog::createShortcut() {
|
|||
QString srcFile = QApplication::applicationFilePath();
|
||||
bool succeed=QFile::link(srcFile, deskTopPath);
|
||||
if (succeed) {
|
||||
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("创建快捷方式成功。"));
|
||||
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("创建快捷方式成功。"));
|
||||
}
|
||||
else {
|
||||
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("创建快捷方式失败。"));
|
||||
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("创建快捷方式失败。"));
|
||||
}
|
||||
}
|
|
@ -56,16 +56,13 @@ NavBar::NavBar(MainScreen *mainScreen,QWidget *parent) :
|
|||
config_request.sendRequest(&config_response);
|
||||
SQLiteHelper sqlite_helper;
|
||||
sqlite_helper.get_software(&buttonStructs, &config_response);
|
||||
background_color = config_response.basic.backgroud_color;
|
||||
text_color = config_response.basic.title_color;
|
||||
text_cover_color = config_response.basic.title_cover_color;
|
||||
if(!config_response.succeed)
|
||||
{
|
||||
qColor.setNamedColor(buttonStructs[0].background_color);
|
||||
qColor.setNamedColor(background_color);
|
||||
|
||||
}else
|
||||
{
|
||||
qColor.setNamedColor(config_response.basic.backgroud_color);
|
||||
qColor.setNamedColor(background_color);
|
||||
}
|
||||
layout2 = new QHBoxLayout;
|
||||
layout_right = new QHBoxLayout;
|
||||
|
@ -89,7 +86,7 @@ NavBar::NavBar(MainScreen *mainScreen,QWidget *parent) :
|
|||
MyButton *myButton = new MyButton(buttonStruct, height(), height(), &buttons,this);
|
||||
myButton->setMaximumHeight(parent->height() / 8);
|
||||
layout_right->addWidget(myButton);
|
||||
//myButton->show();
|
||||
myButton->show();
|
||||
connect(myButton, &MyButton::clicked1, mainWindowLayout, &MainWindowLayout::clickButton);
|
||||
buttons << myButton;
|
||||
}
|
||||
|
|
|
@ -51,9 +51,6 @@ private:
|
|||
int width2;
|
||||
int height2;
|
||||
QWidget* parent;
|
||||
QString background_color;
|
||||
QString text_color;
|
||||
QString text_cover_color;
|
||||
QNetworkAccessManager *manager;
|
||||
QNetworkReply *reply;
|
||||
QEventLoop eventLoop;
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#pragma comment(lib,"comsuppw.lib")
|
||||
QString background_color;
|
||||
QString text_color;
|
||||
QString text_cover_color;
|
||||
//读取注册表获取MachineUUID
|
||||
bool IsWin11AndLater()
|
||||
{
|
||||
|
@ -256,8 +257,8 @@ void ConfigRequest::sendRequest(ConfigResponse *configResponse) {
|
|||
for(auto value:array){
|
||||
QJsonObject object=value.toObject();
|
||||
Button button;
|
||||
button.img = object.value("img").toString();
|
||||
button.png = object.value("logo").toString();
|
||||
button.img = object.value("logo").toString();
|
||||
button.png = object.value("img").toString();
|
||||
button.img_name = object.value("img_name").toString();
|
||||
button.name = object.value("name").toString();
|
||||
button.type = object.value("type").toString();
|
||||
|
@ -324,8 +325,6 @@ void RequestBodyBase::sendRequest() {
|
|||
|
||||
|
||||
DeviceRequest::DeviceRequest() : RequestBodyBase() {
|
||||
//CPU
|
||||
QString cpu = QSysInfo::currentCpuArchitecture();
|
||||
//内存大小
|
||||
MEMORYSTATUSEX status;
|
||||
status.dwLength = sizeof(status);
|
||||
|
@ -334,59 +333,14 @@ DeviceRequest::DeviceRequest() : RequestBodyBase() {
|
|||
//硬盘大小
|
||||
QStorageInfo storage = QStorageInfo::root();
|
||||
int disk = storage.bytesTotal() / static_cast<qulonglong>(1024 * 1024 * 1024);
|
||||
//显卡型号
|
||||
QStringList gpus;
|
||||
BOOL success;
|
||||
DWORD deviceIndex = 0;
|
||||
DISPLAY_DEVICE displayDevice;
|
||||
displayDevice.cb = sizeof(displayDevice);
|
||||
while (EnumDisplayDevices(NULL, deviceIndex, &displayDevice, 0)) {
|
||||
WCHAR valueName[128];
|
||||
DWORD valueSize;
|
||||
DWORD valueType;
|
||||
BYTE valueData[MAX_PATH];
|
||||
HKEY hKey;
|
||||
WCHAR keyName[128];
|
||||
wsprintf(keyName, L"SYSTEM\\CurrentControlSet\\Control\\Video\\%s\\HardwareInformation",
|
||||
displayDevice.DeviceID);
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyName, 0, KEY_READ, &hKey) == ERROR_SUCCESS) {
|
||||
valueSize = sizeof(valueData);
|
||||
wsprintf(valueName, L"HardwareInformation.AdapterString");
|
||||
if (RegQueryValueEx(hKey, valueName, NULL, &valueType, valueData, &valueSize) == ERROR_SUCCESS) {
|
||||
Q_ASSERT(valueType == REG_SZ);
|
||||
QString adapterString = QString::fromWCharArray((wchar_t *) valueData, valueSize / sizeof(wchar_t) - 1);
|
||||
gpus.append(adapterString);
|
||||
}
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
deviceIndex++;
|
||||
displayDevice.cb = sizeof(displayDevice);
|
||||
}
|
||||
//主板型号
|
||||
QString motherboard = QSysInfo::prettyProductName();
|
||||
|
||||
//WMI获取网卡型号
|
||||
HRESULT hr = CoInitializeEx(0, COINIT_MULTITHREADED);
|
||||
HRESULT hr = CoInitializeEx(0, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
|
||||
if (FAILED(hr)) {
|
||||
std::cerr << "Failed to initialize COM library." << std::endl;
|
||||
return;
|
||||
}
|
||||
QStringList netCards;
|
||||
hr = CoInitializeSecurity(
|
||||
NULL,
|
||||
-1,
|
||||
NULL,
|
||||
NULL,
|
||||
RPC_C_AUTHN_LEVEL_DEFAULT,
|
||||
RPC_C_IMP_LEVEL_IMPERSONATE,
|
||||
NULL,
|
||||
EOAC_NONE,
|
||||
NULL
|
||||
);
|
||||
if (FAILED(hr)) {
|
||||
std::cerr << "Failed to initialize security." << std::endl;
|
||||
CoUninitialize();
|
||||
return;
|
||||
}
|
||||
|
||||
IWbemLocator* pLoc = NULL;
|
||||
hr = CoCreateInstance(
|
||||
|
@ -441,7 +395,7 @@ DeviceRequest::DeviceRequest() : RequestBodyBase() {
|
|||
IEnumWbemClassObject* pEnumerator = NULL;
|
||||
hr = pSvc->ExecQuery(
|
||||
_bstr_t("WQL"),
|
||||
_bstr_t("SELECT * FROM Win32_NetworkAdapter WHERE PhysicalAdapter = TRUE AND NetConnectionStatus = 3"),
|
||||
_bstr_t("SELECT * FROM Win32_NetworkAdapter WHERE PhysicalAdapter = TRUE"),
|
||||
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
|
||||
NULL,
|
||||
&pEnumerator
|
||||
|
@ -471,6 +425,78 @@ DeviceRequest::DeviceRequest() : RequestBodyBase() {
|
|||
|
||||
pClassObj->Release();
|
||||
}
|
||||
pEnumerator->Release();
|
||||
pEnumerator = nullptr;
|
||||
// 获取 CPU 信息
|
||||
hr = pSvc->ExecQuery(bstr_t("WQL"), bstr_t("SELECT * FROM Win32_Processor"), WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &pEnumerator);
|
||||
IWbemClassObject* pclsObj = NULL;
|
||||
uReturn = 0;
|
||||
QString cpu;
|
||||
while (pEnumerator) {
|
||||
HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn);
|
||||
if (0 == uReturn) break;
|
||||
|
||||
VARIANT vtProp;
|
||||
hr = pclsObj->Get(L"Name", 0, &vtProp, 0, 0);
|
||||
if (SUCCEEDED(hr)) {
|
||||
cpu=QString::fromWCharArray(vtProp.bstrVal);
|
||||
VariantClear(&vtProp);
|
||||
}
|
||||
pclsObj->Release();
|
||||
}
|
||||
|
||||
// 获取主板信息
|
||||
QString motherboard;
|
||||
hr = pSvc->ExecQuery(bstr_t("WQL"), bstr_t("SELECT * FROM Win32_BaseBoard"), WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &pEnumerator);
|
||||
while (pEnumerator) {
|
||||
HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn);
|
||||
if (0 == uReturn) break;
|
||||
|
||||
VARIANT vtProp;
|
||||
hr = pclsObj->Get(L"Product", 0, &vtProp, 0, 0);
|
||||
if (SUCCEEDED(hr)) {
|
||||
motherboard=QString::fromWCharArray(vtProp.bstrVal);
|
||||
VariantClear(&vtProp);
|
||||
}
|
||||
pclsObj->Release();
|
||||
}
|
||||
|
||||
pEnumerator->Release();
|
||||
pEnumerator=nullptr;
|
||||
//WMI获取显卡型号
|
||||
hr = pSvc->ExecQuery(
|
||||
bstr_t("WQL"),
|
||||
bstr_t("SELECT * FROM Win32_VideoController"),
|
||||
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
|
||||
NULL,
|
||||
&pEnumerator);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
std::cerr << "Query failed." << std::endl;
|
||||
pSvc->Release();
|
||||
pLoc->Release();
|
||||
CoUninitialize();
|
||||
return;
|
||||
}
|
||||
QStringList graphicsCards;
|
||||
pclsObj->Release();
|
||||
pclsObj = NULL;
|
||||
uReturn = 0;
|
||||
while (pEnumerator)
|
||||
{
|
||||
HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn);
|
||||
if (0 == uReturn) break;
|
||||
|
||||
VARIANT vtProp;
|
||||
hr = pclsObj->Get(L"Name", 0, &vtProp, 0, 0);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
graphicsCards<< QString::fromWCharArray(vtProp.bstrVal);
|
||||
VariantClear(&vtProp);
|
||||
}
|
||||
pclsObj->Release();
|
||||
}
|
||||
//WMI获取声卡型号
|
||||
hr = pSvc->ExecQuery(
|
||||
_bstr_t("WQL"),
|
||||
|
@ -531,7 +557,7 @@ DeviceRequest::DeviceRequest() : RequestBodyBase() {
|
|||
hr = pClassObj->Get(L"Manufacturer", 0, &vtProp, 0, 0);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
std::wcout << "Manufacturer: " << vtProp.bstrVal << std::endl;
|
||||
RAMModel<<QString::fromWCharArray(vtProp.bstrVal);
|
||||
VariantClear(&vtProp);
|
||||
}
|
||||
|
||||
|
@ -547,9 +573,30 @@ DeviceRequest::DeviceRequest() : RequestBodyBase() {
|
|||
pSvc->Release();
|
||||
pLoc->Release();
|
||||
CoUninitialize();
|
||||
DISPLAY_DEVICE d = { sizeof(DISPLAY_DEVICE) };
|
||||
::EnumDisplayDevices(NULL, 0, &d, 0);
|
||||
QString monitor=QString::fromWCharArray(d.DeviceString, wcslen(d.DeviceString));
|
||||
|
||||
DISPLAY_DEVICE dd;
|
||||
ZeroMemory(&dd, sizeof(dd));
|
||||
dd.cb = sizeof(dd);
|
||||
int deviceIndex = 0;
|
||||
QStringList monitors;
|
||||
// 枚举显卡设备
|
||||
while (EnumDisplayDevices(0, deviceIndex, &dd, 0))
|
||||
{
|
||||
DISPLAY_DEVICE monitor;
|
||||
ZeroMemory(&monitor, sizeof(monitor));
|
||||
monitor.cb = sizeof(monitor);
|
||||
int monitorIndex = 0;
|
||||
|
||||
// 对每个显卡枚举其连接的显示器
|
||||
while (EnumDisplayDevices(dd.DeviceName, monitorIndex, &monitor, 0))
|
||||
{
|
||||
// 打印显示器型号
|
||||
monitors<<QString::fromWCharArray(monitor.DeviceString);
|
||||
monitorIndex++;
|
||||
}
|
||||
|
||||
deviceIndex++;
|
||||
}
|
||||
//发送
|
||||
//构造JSON
|
||||
QJsonDocument *device=new QJsonDocument;
|
||||
|
@ -558,9 +605,11 @@ DeviceRequest::DeviceRequest() : RequestBodyBase() {
|
|||
object->insert("RAM",QJsonValue(ram));
|
||||
object->insert("Hard_Disk",QJsonValue(disk));
|
||||
QJsonArray *gpu_array=new QJsonArray;
|
||||
for(auto gpu:gpus) {
|
||||
gpu_array->append(gpu);
|
||||
}
|
||||
|
||||
for(auto gpu:graphicsCards)
|
||||
{
|
||||
gpu_array->append(gpu);
|
||||
}
|
||||
object->insert("GPU",*gpu_array);
|
||||
delete gpu_array;
|
||||
object->insert("Mother_Board",motherboard);
|
||||
|
@ -582,7 +631,13 @@ DeviceRequest::DeviceRequest() : RequestBodyBase() {
|
|||
}
|
||||
object->insert("Audio_Card",*audioCards_json);
|
||||
delete audioCards_json;
|
||||
object->insert("Monitor",monitor);
|
||||
QJsonArray *monitors_json=new QJsonArray;
|
||||
for(auto monitor:monitors)
|
||||
{
|
||||
monitors_json->append(monitor);
|
||||
}
|
||||
object->insert("Monitor",*monitors_json);
|
||||
delete monitors_json;
|
||||
device->setObject(*object);
|
||||
delete object;
|
||||
QJsonObject obj_root=qJsonDocument.object();
|
||||
|
@ -597,6 +652,7 @@ DeviceRequest::DeviceRequest() : RequestBodyBase() {
|
|||
requestInfo.setUrl(QUrl(DEVICE_URL));
|
||||
requestInfo.setHeader(QNetworkRequest::ContentTypeHeader,QVariant("application/json"));
|
||||
//保存响应的变量
|
||||
qDebug()<<qJsonDocument.toJson();
|
||||
reply = httpMgr->post(requestInfo,qJsonDocument.toJson());
|
||||
//开启一个循环,直到超时或者获取到数据为止
|
||||
connect(reply,&QNetworkReply::finished, &eventLoop, &QEventLoop::quit);
|
||||
|
@ -605,6 +661,8 @@ DeviceRequest::DeviceRequest() : RequestBodyBase() {
|
|||
timer->start(5000);
|
||||
//启动循环
|
||||
eventLoop.exec();
|
||||
qDebug()<<reply->error();
|
||||
qDebug()<<reply->readAll();
|
||||
delete httpMgr;
|
||||
}
|
||||
bool SoftwareRequest::sendRequest(QHash<QString,QString>&startMenu, QHash<QString, Record> *records, QJsonArray &software_exists)
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
#include <fstream>
|
||||
#include <QFile>
|
||||
#include "applicationmanager.h"
|
||||
#define MAX_KEY_LENGTH 255
|
||||
|
@ -30,6 +31,7 @@
|
|||
#pragma comment (lib,"Shell32.lib")
|
||||
|
||||
#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
|
||||
#include <iostream>
|
||||
#include <experimental/filesystem>
|
||||
namespace fs= std::experimental::filesystem;
|
||||
|
||||
|
@ -768,6 +770,7 @@ bool SQLiteHelper::get_software(QList<ButtonStruct>* button_structs, ConfigRespo
|
|||
{
|
||||
background_color = config_response->basic.backgroud_color;
|
||||
text_color = config_response->basic.title_color;
|
||||
text_cover_color = config_response->basic.title_cover_color;
|
||||
title_color = config_response->basic.title_color;
|
||||
title_cover_color = config_response->basic.title_cover_color;
|
||||
|
||||
|
@ -789,7 +792,7 @@ bool SQLiteHelper::get_software(QList<ButtonStruct>* button_structs, ConfigRespo
|
|||
array = obj_root.value("data").toObject().value("menu").toArray();
|
||||
qDebug() << array;
|
||||
QJsonObject obj_data = obj_root.value("data").toObject();
|
||||
QJsonObject obj_basic=QJsonDocument::fromJson(obj_data.value("basic").toString().toUtf8()).object();
|
||||
QJsonObject obj_basic = obj_data.value("basic").toObject();
|
||||
background_color = obj_basic.value("backgroud_color").toString();
|
||||
title_color = obj_basic.value("title_color").toString();
|
||||
text_color = obj_basic.value("title_color").toString();
|
||||
|
@ -865,7 +868,7 @@ bool SQLiteHelper::get_software(QList<ButtonStruct>* button_structs, ConfigRespo
|
|||
delete manager;
|
||||
manager = nullptr;
|
||||
QUrl url_png(menu.png);
|
||||
QNetworkRequest* request_png = new QNetworkRequest(url_logo);
|
||||
QNetworkRequest* request_png = new QNetworkRequest(url_png);
|
||||
manager = new QNetworkAccessManager;
|
||||
reply = manager->get(*request_png);
|
||||
QTimer timer_png;
|
||||
|
@ -877,15 +880,15 @@ bool SQLiteHelper::get_software(QList<ButtonStruct>* button_structs, ConfigRespo
|
|||
QByteArray buffer_png;
|
||||
buffer_png = reply->readAll();
|
||||
delete request_png;
|
||||
reply->close();
|
||||
QString png_path = QApplication::applicationDirPath() + DEFAULT_PNG_PATH + menu.img_name + ".png";;
|
||||
if ((reply->error() == QNetworkReply::NoError) && (downloadSuccess == true))
|
||||
{
|
||||
QFile file(QApplication::applicationDirPath() + DEFAULT_PNG_PATH + menu.img_name + ".png");
|
||||
if (file.open(QIODevice::WriteOnly))
|
||||
//没仔细研究QFile,貌似读写二进制文件挺麻烦,先用标准库吧
|
||||
std::ofstream out(png_path.toStdString(), std::ios::binary);
|
||||
if(out.is_open())
|
||||
{
|
||||
file.write(buffer_png);
|
||||
file.close();
|
||||
out.write(buffer_png.data(), buffer_png.size());
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -907,6 +910,7 @@ bool SQLiteHelper::get_software(QList<ButtonStruct>* button_structs, ConfigRespo
|
|||
}
|
||||
}
|
||||
}
|
||||
reply->close();
|
||||
delete manager;
|
||||
manager = nullptr;
|
||||
bool categories[CATEGORIES_NUM] = { false };
|
||||
|
@ -1044,7 +1048,7 @@ bool SQLiteHelper::get_software(QList<ButtonStruct>* button_structs,QString back
|
|||
}
|
||||
while (query.next())
|
||||
{
|
||||
QString icon = QApplication::applicationDirPath() + DEFAULT_SVG_PATH + query.value("orig_name").toString() + ".svg";
|
||||
QString icon = QApplication::applicationDirPath() + query.value("logo").toString();
|
||||
ButtonStruct button_struct;
|
||||
button_struct.path = query.value("path").toString();
|
||||
button_struct.text = query.value("name").toString();
|
||||
|
@ -1260,34 +1264,35 @@ bool SQLiteHelper::insert_software(QString name, QString orig_name, QString path
|
|||
{
|
||||
img = QApplication::applicationDirPath()+DEFAULT_PNG;
|
||||
}
|
||||
|
||||
QSqlQuery query_sel(db);
|
||||
query_sel.prepare("select id from kmd_menu where orig_name = :orig_name;");
|
||||
query_sel.bindValue(":orig_name",orig_name);
|
||||
if(query_sel.exec())
|
||||
query_sel.bindValue(":orig_name", orig_name);
|
||||
if (query_sel.exec())
|
||||
{
|
||||
if(query_sel.next())
|
||||
if (query_sel.next())
|
||||
{
|
||||
QString sql="update kmd_menu"
|
||||
QString sql = "update kmd_menu"
|
||||
" set sort=:sort,locked=:locked,type=:type,category_id=:category_id,"
|
||||
"name=:name,orig_name=:orig_name,op=:op,"
|
||||
"func=:func,path=:path,url=:url,logo=:logo,img=:img,is_navbar=:is_navbar,is_elite=:is_elite,dev=:dev where orig_name=:orig_name;";
|
||||
query.prepare(sql);
|
||||
query.bindValue(":sort",sort);
|
||||
query.bindValue(":locked",locked);
|
||||
query.bindValue(":type",type);
|
||||
query.bindValue(":category_id",categories_str);
|
||||
query.bindValue(":name",name);
|
||||
query.bindValue(":orig_name",orig_name);
|
||||
query.bindValue(":op",op);
|
||||
query.bindValue(":func",func);
|
||||
query.bindValue(":path",path);
|
||||
query.bindValue(":url",url);
|
||||
query.bindValue(":logo",logo);
|
||||
query.bindValue(":img",img);
|
||||
query.bindValue(":is_navbar",is_navbar);
|
||||
query.bindValue(":sort", sort);
|
||||
query.bindValue(":locked", locked);
|
||||
query.bindValue(":type", type);
|
||||
query.bindValue(":category_id", categories_str);
|
||||
query.bindValue(":name", name);
|
||||
query.bindValue(":orig_name", orig_name);
|
||||
query.bindValue(":op", op);
|
||||
query.bindValue(":func", func);
|
||||
query.bindValue(":path", path);
|
||||
query.bindValue(":url", url);
|
||||
query.bindValue(":logo", logo);
|
||||
query.bindValue(":img", img);
|
||||
query.bindValue(":is_navbar", is_navbar);
|
||||
query.bindValue(":is_elite", is_elite);
|
||||
query.bindValue(":dev", dev);
|
||||
if(!query.exec())
|
||||
if (!query.exec())
|
||||
{
|
||||
QSqlQuery rollback(db);
|
||||
rollback.exec("ROLLBACK;");
|
||||
|
@ -1335,7 +1340,50 @@ bool SQLiteHelper::insert_software(QString name, QString orig_name, QString path
|
|||
|
||||
return true;
|
||||
}
|
||||
bool SQLiteHelper::insert_software(QString name, QString orig_name, QString path, QString sort, bool* categories) {
|
||||
QSqlQuery begin(db);
|
||||
begin.exec("BEGIN;");
|
||||
QSqlQuery query(db);
|
||||
QString categories_str = "";
|
||||
categories[ALL - 1] = true;
|
||||
QString sql = "insert into kmd_menu "
|
||||
"(sort, app_id, locked, type, category_id, name, orig_name,"
|
||||
" create_time, op, func, path, url, "
|
||||
"initial_position,status,logo,img,is_navbar,is_elite,dev) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
|
||||
query.prepare(sql);
|
||||
query.addBindValue(sort.toInt());
|
||||
query.addBindValue("");
|
||||
query.addBindValue(false);
|
||||
query.addBindValue("app");
|
||||
query.addBindValue(categories_str);
|
||||
query.addBindValue(name);
|
||||
query.addBindValue(orig_name);
|
||||
time_t create_time;
|
||||
time(&create_time);
|
||||
query.addBindValue(create_time);
|
||||
query.addBindValue("app");
|
||||
query.addBindValue("open");
|
||||
query.addBindValue(path);
|
||||
query.addBindValue("");
|
||||
query.addBindValue("");
|
||||
query.addBindValue(true);
|
||||
query.addBindValue(QApplication::applicationDirPath() + DEFAULT_IMAGE);
|
||||
query.addBindValue(QApplication::applicationDirPath() + DEFAULT_PNG);
|
||||
query.addBindValue(false);
|
||||
query.addBindValue(false);
|
||||
query.addBindValue("");
|
||||
if (!query.exec())
|
||||
{
|
||||
QSqlQuery rollback(db);
|
||||
rollback.exec("ROLLBACK;");
|
||||
return false;
|
||||
}
|
||||
update_total();
|
||||
QSqlQuery commit(db);
|
||||
commit.exec("COMMIT;");
|
||||
|
||||
return true;
|
||||
}
|
||||
bool SQLiteHelper::set_category(QList<Categrory>& categrories)
|
||||
{
|
||||
QSqlQuery work(db);
|
||||
|
|
|
@ -51,7 +51,8 @@ class SQLiteHelper : public QObject
|
|||
public:
|
||||
SQLiteHelper(QObject *parent = nullptr);
|
||||
bool update_software();
|
||||
bool insert_software(QString name, QString orig_name, QString path, QString sort, bool* categories, QString logo="", QString img="",QString type="app",bool locked=false,QString op="soft",QString func="",QString url="",bool is_navbar=false,bool is_elite=false,QString dev="");
|
||||
bool insert_software(QString name, QString orig_name, QString path, QString sort, bool* categories, QString logo, QString img,QString type,bool locked,QString op,QString func,QString url,bool is_navbar,bool is_elite,QString dev);
|
||||
bool insert_software(QString name, QString orig_name, QString path, QString sort, bool* categories);
|
||||
bool edit_software(QString name, QString orig_name, QString path, QString sort, bool* categories,QString type="");
|
||||
bool get_software(QList<ButtonStruct>* buttons, ConfigResponse* config_response);
|
||||
bool get_software(QList<ButtonStruct>* button_structs,QString background_color , QString title_color, QString title_cover_color);
|
||||
|
|
|
@ -23,6 +23,7 @@ void UserImprove::submit()
|
|||
{
|
||||
agree = false;
|
||||
}
|
||||
close();
|
||||
}
|
||||
void UserImprove::showDetail()
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>UserImprove</string>
|
||||
<string>用户体验改善计划</string>
|
||||
</property>
|
||||
<widget class="QPushButton" name="detail">
|
||||
<property name="geometry">
|
||||
|
|
Loading…
Reference in New Issue