应该完成了
parent
979595c8d8
commit
a7c74a20a6
|
@ -6,14 +6,11 @@
|
||||||
|
|
||||||
#include "applicationmanager.h"
|
#include "applicationmanager.h"
|
||||||
|
|
||||||
#if _MSC_VER >=1936
|
|
||||||
#include <filesystem>
|
|
||||||
namespace fs = std::filesystem;
|
|
||||||
#else
|
|
||||||
#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
|
#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
|
||||||
#include <experimental/filesystem>
|
#include <experimental/filesystem>
|
||||||
namespace fs = std::experimental::filesystem;
|
namespace fs = std::experimental::filesystem;
|
||||||
#endif
|
|
||||||
|
|
||||||
AddApp::AddApp(bool isEdit, Record2 *row , QWidget* parent)
|
AddApp::AddApp(bool isEdit, Record2 *row , QWidget* parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
|
@ -29,6 +26,10 @@ AddApp::AddApp(bool isEdit, Record2 *row , QWidget* parent)
|
||||||
{
|
{
|
||||||
name_label = new QLabel(orig_name_str);
|
name_label = new QLabel(orig_name_str);
|
||||||
form->addRow(QString::fromLocal8Bit("È«Ãû"), name_label);
|
form->addRow(QString::fromLocal8Bit("È«Ãû"), name_label);
|
||||||
|
if(row!=nullptr)
|
||||||
|
{
|
||||||
|
name_label->setText(row->orig_name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -45,14 +46,10 @@ AddApp::AddApp(bool isEdit, Record2 *row , QWidget* parent)
|
||||||
form->addRow(QString::fromLocal8Bit("ÅÅÐò"), sort);
|
form->addRow(QString::fromLocal8Bit("ÅÅÐò"), sort);
|
||||||
QList<Categrory> categrories;
|
QList<Categrory> categrories;
|
||||||
layout_inner = new QVBoxLayout;
|
layout_inner = new QVBoxLayout;
|
||||||
sqlite_helper.get_category(categrories);
|
sqlite_helper.get_category(categrories,true);
|
||||||
|
|
||||||
for (auto category : categrories)
|
for (auto category : categrories)
|
||||||
{
|
{
|
||||||
if ((category.id == 1) || (category.id == 8) || (category.id == 4) || (category.id == 5 || category.id == 3))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
QCheckBox* check_box = new QCheckBox(category.name);
|
QCheckBox* check_box = new QCheckBox(category.name);
|
||||||
layout_inner->addWidget(check_box);
|
layout_inner->addWidget(check_box);
|
||||||
categories_list.insert(category.id, check_box);
|
categories_list.insert(category.id, check_box);
|
||||||
|
@ -66,6 +63,9 @@ AddApp::AddApp(bool isEdit, Record2 *row , QWidget* parent)
|
||||||
this->isEdit = isEdit;
|
this->isEdit = isEdit;
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
|
name->setText(row->name);
|
||||||
|
name_str=row->name;
|
||||||
|
sort_str=QString::number(row->sort);
|
||||||
path = new QPushButton(QString::fromLocal8Bit("ä¯ÀÀ"));
|
path = new QPushButton(QString::fromLocal8Bit("ä¯ÀÀ"));
|
||||||
path_str = row->exe_file;
|
path_str = row->exe_file;
|
||||||
path->setText(QString::fromWCharArray(fs::path(path_str.toStdWString()).filename().c_str()));
|
path->setText(QString::fromWCharArray(fs::path(path_str.toStdWString()).filename().c_str()));
|
||||||
|
@ -77,16 +77,12 @@ AddApp::AddApp(bool isEdit, Record2 *row , QWidget* parent)
|
||||||
form->addRow(QString::fromLocal8Bit("ÅÅÐò"), sort);
|
form->addRow(QString::fromLocal8Bit("ÅÅÐò"), sort);
|
||||||
QList<Categrory> categrories;
|
QList<Categrory> categrories;
|
||||||
layout_inner = new QVBoxLayout;
|
layout_inner = new QVBoxLayout;
|
||||||
sqlite_helper.get_category(categrories);
|
sqlite_helper.get_category(categrories,true);
|
||||||
|
categories = row->categories;
|
||||||
for (auto category : categrories)
|
for (auto category : categrories)
|
||||||
{
|
{
|
||||||
if ((category.id == 1) || (category.id == 8) || (category.id == 4) || (category.id == 5 || category.id == 3))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
QCheckBox* check_box = new QCheckBox(category.name);
|
QCheckBox* check_box = new QCheckBox(category.name);
|
||||||
if(row->categories[category.id])
|
if(row->categories[category.id-1])
|
||||||
{
|
{
|
||||||
check_box->setCheckState(Qt::Checked);
|
check_box->setCheckState(Qt::Checked);
|
||||||
}
|
}
|
||||||
|
@ -122,43 +118,72 @@ AddApp::~AddApp()
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddApp::broswer_exe(){
|
void AddApp::broswer_exe(){
|
||||||
path_str = QFileDialog::getOpenFileName(this, QString::fromLocal8Bit("选择程序"),
|
QString path_str_old = path_str;
|
||||||
QApplication::applicationDirPath(), QString::fromLocal8Bit("应用程序 (*.exe)"));
|
if(path_str.isEmpty())
|
||||||
fs::path file(path_str.toStdWString());
|
|
||||||
path->setText(QString::fromStdWString(file.filename().c_str()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddApp::submit() {
|
|
||||||
if((!orig_name->text().isEmpty())&&(!path->text().isEmpty()))
|
|
||||||
{
|
{
|
||||||
orig_name_str = orig_name->text();
|
path_str = QFileDialog::getOpenFileName(this, QString::fromLocal8Bit("选择程序"),
|
||||||
name_str = orig_name_str;
|
QApplication::applicationDirPath(), QString::fromLocal8Bit("应用程序 (*.exe)"));
|
||||||
sort_str = sort->text();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("未填写名称或路径"));
|
path_str = QFileDialog::getOpenFileName(this, QString::fromLocal8Bit("选择程序"),
|
||||||
return;
|
path_str, QString::fromLocal8Bit("应用程序 (*.exe)"));
|
||||||
}
|
}
|
||||||
categories = new bool[8];
|
if (path_str.isEmpty()) {
|
||||||
categories[0] = true;
|
path_str = path_str_old;
|
||||||
categories[2] = true;
|
}
|
||||||
categories[7] = true;
|
fs::path file(path_str.toStdWString());
|
||||||
categories[3] = false;
|
path->setText(QString::fromStdWString(file.filename().c_str()));
|
||||||
categories[4] = false;
|
|
||||||
for(auto key:categories_list.keys())
|
}
|
||||||
|
|
||||||
|
void AddApp::submit() {
|
||||||
|
if(isEdit)
|
||||||
{
|
{
|
||||||
if(key==0||key==2||key==7||key==3||key==4)
|
if (!path->text().isEmpty())
|
||||||
{
|
{
|
||||||
continue;
|
QString name_str_old = name_str;
|
||||||
|
QString sort_str_old = sort_str;
|
||||||
|
name_str = name->text();
|
||||||
|
sort_str = sort->text();
|
||||||
|
|
||||||
|
if (name_str.isEmpty()) {
|
||||||
|
name_str = name_str_old;
|
||||||
|
}
|
||||||
|
if (sort_str.isEmpty()) {
|
||||||
|
sort_str = sort_str_old;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
categories[key - 1] = categories_list[key]->checkState();
|
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("未填写路径"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
if ((!orig_name->text().isEmpty()) && (!path->text().isEmpty()))
|
||||||
|
{
|
||||||
|
orig_name_str = orig_name->text();
|
||||||
|
if (name->text().isEmpty()) {
|
||||||
|
name_str = orig_name_str;
|
||||||
|
}
|
||||||
|
name_str = name->text();
|
||||||
|
sort_str = sort->text();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("未填写全名或路径"));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
categories[0] = true;
|
for(auto key:categories_list.keys())
|
||||||
categories[7] = true;
|
{
|
||||||
|
categories[key - 1] = categories_list[key]->checkState();
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
qDebug() << categories[i];
|
||||||
|
}
|
||||||
|
|
||||||
changed = true;
|
changed = true;
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ AddCategory::AddCategory(QWidget* parent)
|
||||||
ui.tableWidget->setColumnCount(3);
|
ui.tableWidget->setColumnCount(3);
|
||||||
title << QString::fromLocal8Bit("Ãû³Æ") << QString::fromLocal8Bit("ÏÔʾ") << QString::fromLocal8Bit("ÅÅÐò");
|
title << QString::fromLocal8Bit("Ãû³Æ") << QString::fromLocal8Bit("ÏÔʾ") << QString::fromLocal8Bit("ÅÅÐò");
|
||||||
ui.tableWidget->setHorizontalHeaderLabels(title);
|
ui.tableWidget->setHorizontalHeaderLabels(title);
|
||||||
sqlite_helper.get_category(categrories);
|
sqlite_helper.get_category(categrories,false);
|
||||||
ui.tableWidget->setRowCount(categrories.count());
|
ui.tableWidget->setRowCount(categrories.count());
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(auto category : categrories)
|
for(auto category : categrories)
|
||||||
|
|
|
@ -13,6 +13,7 @@ ApplicationManager::ApplicationManager(QWidget *parent)
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
resize(parent->width(), parent->height());
|
resize(parent->width(), parent->height());
|
||||||
|
this->parent = parent;
|
||||||
miniblink = new QMiniBlink(this);
|
miniblink = new QMiniBlink(this);
|
||||||
miniblink->init();
|
miniblink->init();
|
||||||
miniblink->show();
|
miniblink->show();
|
||||||
|
@ -23,7 +24,7 @@ ApplicationManager::ApplicationManager(QWidget *parent)
|
||||||
layout_top->setMargin(5);
|
layout_top->setMargin(5);
|
||||||
layout_bottom = new QHBoxLayout(this);
|
layout_bottom = new QHBoxLayout(this);
|
||||||
QList<Categrory> categrories;
|
QList<Categrory> categrories;
|
||||||
sqlite_helper.get_category(categrories);
|
sqlite_helper.get_category(categrories,false);
|
||||||
sqlite_helper.get_buttons(button_structs);
|
sqlite_helper.get_buttons(button_structs);
|
||||||
for (auto button_struct : button_structs)
|
for (auto button_struct : button_structs)
|
||||||
{
|
{
|
||||||
|
@ -243,10 +244,15 @@ void ApplicationManager::onclick1(QString op, QString func, QString path, QStrin
|
||||||
|
|
||||||
void ApplicationManager::onclick2(QString orig_name, QString op)
|
void ApplicationManager::onclick2(QString orig_name, QString op)
|
||||||
{
|
{
|
||||||
if (op == "open")
|
if (op == "app")
|
||||||
{
|
{
|
||||||
emit changeUrl(application_manager_page_all->rows[orig_name].url);
|
if (application_manager_page_all->rows[orig_name].func == "openwechat") {
|
||||||
WinExec(application_manager_page_all->rows[orig_name].exe_file.toStdString().c_str(), SW_SHOW);
|
emit application_manager_page_all->onclick3(application_manager_page_all->rows[orig_name].op, application_manager_page_all->rows[orig_name].func, application_manager_page_all->rows[orig_name].exe_file, application_manager_page_all->rows[orig_name].url);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
emit changeUrl(application_manager_page_all->rows[orig_name].url);
|
||||||
|
WinExec(application_manager_page_all->rows[orig_name].exe_file.toStdString().c_str(), SW_SHOW);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (op == "settings")
|
else if (op == "settings")
|
||||||
{
|
{
|
||||||
|
@ -261,6 +267,9 @@ void ApplicationManager::onclick2(QString orig_name, QString op)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
emit application_manager_page_all->onclick3(application_manager_page_all->rows[orig_name].op, application_manager_page_all->rows[orig_name].func,application_manager_page_all->rows[orig_name].exe_file,application_manager_page_all->rows[orig_name].url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplicationManager::tabChange(int index)
|
void ApplicationManager::tabChange(int index)
|
||||||
|
|
|
@ -27,6 +27,9 @@ struct Record2
|
||||||
QSvgWidget* icon;
|
QSvgWidget* icon;
|
||||||
MiniButton* settings;
|
MiniButton* settings;
|
||||||
MiniButton * open;
|
MiniButton * open;
|
||||||
|
QString op;
|
||||||
|
QString func;
|
||||||
|
QString name;
|
||||||
QString orig_name;
|
QString orig_name;
|
||||||
QString exe_file;
|
QString exe_file;
|
||||||
QCheckBox *check_box;
|
QCheckBox *check_box;
|
||||||
|
@ -52,6 +55,7 @@ signals:
|
||||||
public:
|
public:
|
||||||
ApplicationManager(QWidget *parent = nullptr);
|
ApplicationManager(QWidget *parent = nullptr);
|
||||||
~ApplicationManager();
|
~ApplicationManager();
|
||||||
|
QWidget* parent;
|
||||||
private:
|
private:
|
||||||
QHash<QHBoxLayout*,ApplicationManagerPage*> pages;
|
QHash<QHBoxLayout*,ApplicationManagerPage*> pages;
|
||||||
QVBoxLayout* layout;
|
QVBoxLayout* layout;
|
||||||
|
|
|
@ -2,9 +2,11 @@
|
||||||
|
|
||||||
#include <QSvgRenderer>
|
#include <QSvgRenderer>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <ctime>
|
||||||
#include "applicationmanager.h"
|
#include "applicationmanager.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "mainscreen.h"
|
||||||
|
#include "mainwindowlayout.h"
|
||||||
ApplicationManagerPage::ApplicationManagerPage(int category, ApplicationManager *application_manager,QWidget *parent)
|
ApplicationManagerPage::ApplicationManagerPage(int category, ApplicationManager *application_manager,QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
|
@ -47,8 +49,12 @@ ApplicationManagerPage::ApplicationManagerPage(int category, ApplicationManager
|
||||||
date += QString::number(1 + time->tm_mon, 10);
|
date += QString::number(1 + time->tm_mon, 10);
|
||||||
date += "/";
|
date += "/";
|
||||||
date += QString::number(time->tm_mday, 10);
|
date += QString::number(time->tm_mday, 10);
|
||||||
|
if (software.use_time == 0) {
|
||||||
|
date.clear();
|
||||||
|
}
|
||||||
table->setItem(i, 4, new QTableWidgetItem(date));
|
table->setItem(i, 4, new QTableWidgetItem(date));
|
||||||
Record2 record2;
|
Record2 record2;
|
||||||
|
record2.name = software.name;
|
||||||
record2.icon = new QSvgWidget;
|
record2.icon = new QSvgWidget;
|
||||||
QFile file(software.logo);
|
QFile file(software.logo);
|
||||||
if(file.exists())
|
if(file.exists())
|
||||||
|
@ -65,7 +71,7 @@ ApplicationManagerPage::ApplicationManagerPage(int category, ApplicationManager
|
||||||
record2.settings->setMaximumSize(60, 40);
|
record2.settings->setMaximumSize(60, 40);
|
||||||
connect(record2.settings, &MiniButton::click0, record2.settings, &MiniButton::onclick2);
|
connect(record2.settings, &MiniButton::click0, record2.settings, &MiniButton::onclick2);
|
||||||
connect(record2.settings, &MiniButton::click2, application_manager, &ApplicationManager::onclick2);
|
connect(record2.settings, &MiniButton::click2, application_manager, &ApplicationManager::onclick2);
|
||||||
record2.open = new MiniButton(software.orig_name, "open");
|
record2.open = new MiniButton(software.orig_name,software.op);
|
||||||
record2.open->setText(QString::fromLocal8Bit("打开"));
|
record2.open->setText(QString::fromLocal8Bit("打开"));
|
||||||
record2.open->setMaximumSize(60, 40);
|
record2.open->setMaximumSize(60, 40);
|
||||||
connect(record2.open, &MiniButton::click0, record2.open, &MiniButton::onclick2);
|
connect(record2.open, &MiniButton::click0, record2.open, &MiniButton::onclick2);
|
||||||
|
@ -73,13 +79,16 @@ ApplicationManagerPage::ApplicationManagerPage(int category, ApplicationManager
|
||||||
record2.exe_file = software.path;
|
record2.exe_file = software.path;
|
||||||
record2.orig_name = software.orig_name;
|
record2.orig_name = software.orig_name;
|
||||||
record2.url = software.url;
|
record2.url = software.url;
|
||||||
|
record2.op = software.op;
|
||||||
|
record2.func = software.func;
|
||||||
|
connect(this, &ApplicationManagerPage::onclick3, (MainWindowLayout*)((MainScreen*)application_manager->parent)->parent, &MainWindowLayout::clickButton);
|
||||||
for(int i=0;i<8;i++)
|
for(int i=0;i<8;i++)
|
||||||
{
|
{
|
||||||
record2.categories[i] = false;
|
record2.categories[i] = false;
|
||||||
}
|
}
|
||||||
for(int i=0;i<8;i++)
|
for(int i=0;i<8;i++)
|
||||||
{
|
{
|
||||||
if (software.category_id.contains(QString::number(i)))
|
if (software.category_id.contains(QString::number(i+1)))
|
||||||
{
|
{
|
||||||
record2.categories[i] = true;
|
record2.categories[i] = true;
|
||||||
}
|
}
|
||||||
|
@ -129,12 +138,12 @@ void ApplicationManagerPage::onclicked()
|
||||||
{
|
{
|
||||||
for(int i=0;i<table->rowCount();i++)
|
for(int i=0;i<table->rowCount();i++)
|
||||||
{
|
{
|
||||||
if(((QCheckBox *)table->cellWidget(i,4))->checkState()==Qt::Checked)
|
if(((QCheckBox *)table->cellWidget(i,5))->checkState()==Qt::Checked)
|
||||||
{
|
{
|
||||||
if(!checked[table->item(i,1)->text()])
|
if(!checked[table->item(i,2)->text()])
|
||||||
{
|
{
|
||||||
QString orig_name = table->item(i, 1)->text();
|
QString orig_name = table->item(i, 2)->text();
|
||||||
bool ok=sqlite_helper.edit_software(table->item(i, 0)->text(), orig_name, rows[orig_name].exe_file, QString::number(rows[orig_name].sort), rows[orig_name].categories,"navbar");
|
bool ok=sqlite_helper.edit_software(table->item(i, 1)->text(), orig_name, rows[orig_name].exe_file, QString::number(rows[orig_name].sort), rows[orig_name].categories,"navbar");
|
||||||
if(!ok)
|
if(!ok)
|
||||||
{
|
{
|
||||||
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("更新部分或全部失败"));
|
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("更新部分或全部失败"));
|
||||||
|
@ -143,10 +152,10 @@ void ApplicationManagerPage::onclicked()
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
if (checked[table->item(i, 1)->text()])
|
if (checked[table->item(i, 2)->text()])
|
||||||
{
|
{
|
||||||
QString orig_name = table->item(i, 1)->text();
|
QString orig_name = table->item(i, 2)->text();
|
||||||
bool ok = sqlite_helper.edit_software(table->item(i, 0)->text(), orig_name, rows[orig_name].exe_file, QString::number(rows[orig_name].sort), rows[orig_name].categories, "app");
|
bool ok = sqlite_helper.edit_software(table->item(i, 1)->text(), orig_name, rows[orig_name].exe_file, QString::number(rows[orig_name].sort), rows[orig_name].categories, "app");
|
||||||
if (!ok)
|
if (!ok)
|
||||||
{
|
{
|
||||||
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("更新部分或全部失败"));
|
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("更新部分或全部失败"));
|
||||||
|
@ -179,19 +188,35 @@ void ApplicationManagerPage::refresh()
|
||||||
for (auto software : softwares)
|
for (auto software : softwares)
|
||||||
{
|
{
|
||||||
table->insertRow(i);
|
table->insertRow(i);
|
||||||
table->setItem(i, 0, new QTableWidgetItem(software.name));
|
|
||||||
table->setItem(i, 1, new QTableWidgetItem(software.orig_name));
|
table->setItem(i, 1, new QTableWidgetItem(software.name));
|
||||||
table->setItem(i, 2, new QTableWidgetItem(software.dev));
|
table->setItem(i, 2, new QTableWidgetItem(software.orig_name));
|
||||||
|
table->setItem(i, 3, new QTableWidgetItem(software.dev));
|
||||||
QString date;
|
QString date;
|
||||||
std::tm* time;
|
std::tm* time;
|
||||||
time = std::localtime(&software.use_time);
|
if(software.use_time!=0)
|
||||||
date = QString::number(1900 + time->tm_year, 10);
|
{
|
||||||
date += "/";
|
time = std::localtime(&software.use_time);
|
||||||
date += QString::number(1 + time->tm_mon, 10);
|
date = QString::number(1900 + time->tm_year, 10);
|
||||||
date += "/";
|
date += "/";
|
||||||
date += QString::number(time->tm_mday, 10);
|
date += QString::number(1 + time->tm_mon, 10);
|
||||||
table->setItem(i, 3, new QTableWidgetItem(date));
|
date += "/";
|
||||||
|
date += QString::number(time->tm_mday, 10);
|
||||||
|
table->setItem(i, 4, new QTableWidgetItem(date));
|
||||||
|
}
|
||||||
Record2 record2;
|
Record2 record2;
|
||||||
|
record2.name = software.name;
|
||||||
|
record2.icon = new QSvgWidget;
|
||||||
|
QFile file(software.logo);
|
||||||
|
if (file.exists())
|
||||||
|
{
|
||||||
|
record2.icon->load(software.logo);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
record2.icon->load(QApplication::applicationDirPath() + DEFAULT_IMAGE);
|
||||||
|
}
|
||||||
|
record2.icon->setMaximumSize(80, 80);
|
||||||
|
table->setCellWidget(i, 0, record2.icon);
|
||||||
record2.settings = new MiniButton(software.orig_name, "settings");
|
record2.settings = new MiniButton(software.orig_name, "settings");
|
||||||
record2.settings->setText(QString::fromLocal8Bit("设置"));
|
record2.settings->setText(QString::fromLocal8Bit("设置"));
|
||||||
record2.settings->setMaximumSize(60, 40);
|
record2.settings->setMaximumSize(60, 40);
|
||||||
|
@ -199,17 +224,19 @@ void ApplicationManagerPage::refresh()
|
||||||
connect(record2.settings, &MiniButton::click2, application_manager, &ApplicationManager::onclick2);
|
connect(record2.settings, &MiniButton::click2, application_manager, &ApplicationManager::onclick2);
|
||||||
record2.open = new MiniButton(software.orig_name, "open");
|
record2.open = new MiniButton(software.orig_name, "open");
|
||||||
record2.open->setText(QString::fromLocal8Bit("打开"));
|
record2.open->setText(QString::fromLocal8Bit("打开"));
|
||||||
record2.open->setMaximumSize(60, 40); connect(record2.open, &MiniButton::click0, record2.open, &MiniButton::onclick2);
|
record2.open->setMaximumSize(60, 40);
|
||||||
|
connect(record2.open, &MiniButton::click0, record2.open, &MiniButton::onclick2);
|
||||||
connect(record2.open, &MiniButton::click2, application_manager, &ApplicationManager::onclick2);
|
connect(record2.open, &MiniButton::click2, application_manager, &ApplicationManager::onclick2);
|
||||||
record2.exe_file = software.path;
|
record2.exe_file = software.path;
|
||||||
record2.orig_name = software.orig_name;
|
record2.orig_name = software.orig_name;
|
||||||
|
record2.url = software.url;
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
record2.categories[i] = false;
|
record2.categories[i] = false;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
if (software.category_id.contains(QString::number(i)))
|
if (software.category_id.contains(QString::number(i+1)))
|
||||||
{
|
{
|
||||||
record2.categories[i] = true;
|
record2.categories[i] = true;
|
||||||
}
|
}
|
||||||
|
@ -227,12 +254,18 @@ void ApplicationManagerPage::refresh()
|
||||||
checked.insert(software.orig_name, false);
|
checked.insert(software.orig_name, false);
|
||||||
}
|
}
|
||||||
connect(record2.check_box, &QCheckBox::clicked, this, &ApplicationManagerPage::onclicked);
|
connect(record2.check_box, &QCheckBox::clicked, this, &ApplicationManagerPage::onclicked);
|
||||||
table->setCellWidget(i, 4, record2.check_box);
|
QTableWidgetItem* check_box_item = new QTableWidgetItem;
|
||||||
table->setCellWidget(i, 5, record2.settings);
|
table->setItem(i, 5, check_box_item);
|
||||||
|
table->setCellWidget(i, 5, record2.check_box);
|
||||||
|
check_box_item->setTextAlignment(Qt::AlignCenter);
|
||||||
|
table->setCellWidget(i, 6, record2.settings);
|
||||||
//table->item(i, 5)->setTextAlignment(Qt::AlignCenter);
|
//table->item(i, 5)->setTextAlignment(Qt::AlignCenter);
|
||||||
table->setCellWidget(i, 6, record2.open);
|
table->setCellWidget(i, 7, record2.open);
|
||||||
//table->item(i, 6)->setTextAlignment(Qt::AlignCenter);
|
//table->item(i, 6)->setTextAlignment(Qt::AlignCenter);
|
||||||
rows.insert(software.orig_name, record2);
|
rows.insert(software.orig_name, record2);
|
||||||
|
table->resizeColumnToContents(0);
|
||||||
|
//table->item(i, 0)->setTextAlignment(Qt::AlignCenter);
|
||||||
|
//table->verticalHeader()->setSectionResizeMode(i, QHeaderView::ResizeToContents);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,8 @@ struct Record2;
|
||||||
class ApplicationManagerPage : public QWidget
|
class ApplicationManagerPage : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
signals:
|
||||||
|
void onclick3(QString op, QString func, QString url, QString path,QString initial_position="");
|
||||||
public:
|
public:
|
||||||
ApplicationManagerPage(int category, ApplicationManager *application_manager,QWidget *parent = nullptr);
|
ApplicationManagerPage(int category, ApplicationManager *application_manager,QWidget *parent = nullptr);
|
||||||
~ApplicationManagerPage();
|
~ApplicationManagerPage();
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
#define DEVICE_URL "http://softapi.s103.y01.cn/addons/Kmdsoft/Index/device" //上传设备信息的地址
|
#define DEVICE_URL "http://softapi.s103.y01.cn/addons/Kmdsoft/Index/device" //上传设备信息的地址
|
||||||
#define WECHAT_URL " http://softapi.s103.y01.cn/addons/Kmdsoft/Wxdk/open"
|
#define WECHAT_URL " http://softapi.s103.y01.cn/addons/Kmdsoft/Wxdk/open"
|
||||||
#define BASE_URL "http://softapi.s103.y01.cn/" //域名
|
#define BASE_URL "http://softapi.s103.y01.cn/" //域名
|
||||||
#define DEFAULT_FILE "/config/default_navbar.kmd" //默认导航栏文件位置
|
#define DEFAULT_FILE "/config/config.kmd" //默认配置文件位置
|
||||||
|
#define DEFAULT_NAVBAR_FILLE "/config/default_navbar.kmd"
|
||||||
#define KEY "3b046cfe4a2a3e62141a4840f2006210a3224e3615312bef6e19f4983921abe0" //Key
|
#define KEY "3b046cfe4a2a3e62141a4840f2006210a3224e3615312bef6e19f4983921abe0" //Key
|
||||||
#define NAME "办公助手" //中文名
|
#define NAME "办公助手" //中文名
|
||||||
#define LOGO_TITLEBAR "/images/icon/logo_navbar.png" //标题栏图标
|
#define LOGO_TITLEBAR "/images/icon/logo_navbar.png" //标题栏图标
|
||||||
|
@ -24,7 +25,8 @@
|
||||||
#define DEFAULT_COLOR "#3399FF" //
|
#define DEFAULT_COLOR "#3399FF" //
|
||||||
#define DEFAULT_TEXT_COLOR "#FFFFFF" //默认文字颜色
|
#define DEFAULT_TEXT_COLOR "#FFFFFF" //默认文字颜色
|
||||||
#define DEFAULT_COVER_COLOR "#0033FF" //鼠标指向后变成的颜色,也是“添加应用”等几个按钮的默认颜色
|
#define DEFAULT_COVER_COLOR "#0033FF" //鼠标指向后变成的颜色,也是“添加应用”等几个按钮的默认颜色
|
||||||
#define DEFAULT_IMAGE "/images/icon/default.svg" //默认图标
|
#define DEFAULT_IMAGE "/images/svg/default.svg" //默认图标
|
||||||
|
#define DEFAULT_SVG_PATH "/images/svg/"
|
||||||
#define DEFAULT_LOGO "/images/logo.png" //logo路径
|
#define DEFAULT_LOGO "/images/logo.png" //logo路径
|
||||||
#define TITLE " " //标题栏
|
#define TITLE " " //标题栏
|
||||||
#define TEXT_SIZE 7 //字体大小。不是所有字体受此项控制
|
#define TEXT_SIZE 7 //字体大小。不是所有字体受此项控制
|
||||||
|
|
Binary file not shown.
|
@ -18,6 +18,7 @@
|
||||||
MainScreen::MainScreen(QWidget *parent) :
|
MainScreen::MainScreen(QWidget *parent) :
|
||||||
QWidget(parent), ui(new Ui::MainScreen) {
|
QWidget(parent), ui(new Ui::MainScreen) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
this->parent = parent;
|
||||||
setContentsMargins(0, 0, 0, 0);
|
setContentsMargins(0, 0, 0, 0);
|
||||||
widget = new QWidget(this);
|
widget = new QWidget(this);
|
||||||
layout_left = new QVBoxLayout(widget);
|
layout_left = new QVBoxLayout(widget);
|
||||||
|
@ -78,11 +79,26 @@ MainScreen::~MainScreen() {
|
||||||
}
|
}
|
||||||
void MainScreen::firstUrl(QString url)
|
void MainScreen::firstUrl(QString url)
|
||||||
{
|
{
|
||||||
QString url_full = BASE_URL + url + url_param;
|
QString url_full;
|
||||||
|
if (url.contains("http"))
|
||||||
|
{
|
||||||
|
url_full = url;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
url_full = BASE_URL + url + url_param;
|
||||||
|
}
|
||||||
emit changeUrl(url_full);
|
emit changeUrl(url_full);
|
||||||
}
|
}
|
||||||
void MainScreen::clickButton1(QString op,QString url) {
|
void MainScreen::clickButton1(QString op,QString url) {
|
||||||
QString url_full = BASE_URL + url + url_param;
|
QString url_full;
|
||||||
|
if(url.contains("http"))
|
||||||
|
{
|
||||||
|
url_full = url;
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
url_full = BASE_URL + url + url_param;
|
||||||
|
}
|
||||||
if (op == "openwechat") {
|
if (op == "openwechat") {
|
||||||
OpenWeChatRequest open_wechat_request;
|
OpenWeChatRequest open_wechat_request;
|
||||||
QString msg = open_wechat_request.sendRequest();
|
QString msg = open_wechat_request.sendRequest();
|
||||||
|
|
|
@ -26,6 +26,7 @@ signals:
|
||||||
public:
|
public:
|
||||||
explicit MainScreen(QWidget *parent = nullptr);
|
explicit MainScreen(QWidget *parent = nullptr);
|
||||||
~MainScreen() override;
|
~MainScreen() override;
|
||||||
|
QWidget* parent;
|
||||||
public slots:
|
public slots:
|
||||||
void clickButton1(QString op, QString url);
|
void clickButton1(QString op, QString url);
|
||||||
void firstUrl(QString url);
|
void firstUrl(QString url);
|
||||||
|
|
|
@ -16,16 +16,12 @@ MainWindowLayout::MainWindowLayout(QWidget *parent) :
|
||||||
layout=new QVBoxLayout(this);
|
layout=new QVBoxLayout(this);
|
||||||
mainWindowLayout = this;
|
mainWindowLayout = this;
|
||||||
QList<ButtonStruct> list;
|
QList<ButtonStruct> list;
|
||||||
ConfigRequest *configRequest = new ConfigRequest;
|
|
||||||
configResponse = new ConfigResponse;
|
|
||||||
configRequest->sendRequest(configResponse);
|
|
||||||
mainScreen = new MainScreen(this);
|
mainScreen = new MainScreen(this);
|
||||||
navBar=new NavBar(configResponse,mainScreen,this);
|
navBar=new NavBar(mainScreen,this);
|
||||||
navBar->setMinimumHeight(0);
|
navBar->setMinimumHeight(0);
|
||||||
navBar->setMaximumHeight(this->height() / 8);
|
navBar->setMaximumHeight(this->height() / 8);
|
||||||
mainScreen->setMinimumHeight(0);
|
mainScreen->setMinimumHeight(0);
|
||||||
//navBar->setAttribute(Qt::WA_DeleteOnClose);
|
//navBar->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
delete configRequest;
|
|
||||||
//QSizePolicy sizePolicy(QSizePolicy::Policy::Fixed, QSizePolicy::QSizePolicy::Fixed);
|
//QSizePolicy sizePolicy(QSizePolicy::Policy::Fixed, QSizePolicy::QSizePolicy::Fixed);
|
||||||
//navBar->setSizePolicy(sizePolicy);
|
//navBar->setSizePolicy(sizePolicy);
|
||||||
//layout->setContentsMargins(0, 0, 0, 0);
|
//layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
@ -37,7 +33,6 @@ MainWindowLayout::MainWindowLayout(QWidget *parent) :
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindowLayout::~MainWindowLayout() {
|
MainWindowLayout::~MainWindowLayout() {
|
||||||
delete configResponse;
|
|
||||||
layout->removeWidget(mainScreen);
|
layout->removeWidget(mainScreen);
|
||||||
layout->removeWidget(navBar);
|
layout->removeWidget(navBar);
|
||||||
delete mainScreen;
|
delete mainScreen;
|
||||||
|
|
|
@ -39,7 +39,7 @@ void ConvertImageToTransparent(QImage &img)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NavBar::NavBar(ConfigResponse *configResponse, MainScreen *mainScreen,QWidget *parent) :
|
NavBar::NavBar(MainScreen *mainScreen,QWidget *parent) :
|
||||||
QWidget(parent), ui(new Ui::NavBar) {
|
QWidget(parent), ui(new Ui::NavBar) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
//this->setAttribute(Qt::WA_DeleteOnClose);
|
//this->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
@ -55,9 +55,10 @@ NavBar::NavBar(ConfigResponse *configResponse, MainScreen *mainScreen,QWidget *p
|
||||||
config_request.sendRequest(&config_response);
|
config_request.sendRequest(&config_response);
|
||||||
SQLiteHelper sqlite_helper;
|
SQLiteHelper sqlite_helper;
|
||||||
sqlite_helper.get_software(&buttonStructs, &config_response);
|
sqlite_helper.get_software(&buttonStructs, &config_response);
|
||||||
|
|
||||||
if(!config_response.succeed)
|
if(!config_response.succeed)
|
||||||
{
|
{
|
||||||
qColor.setNamedColor(DEFAULT_BACKGROUND_COLOR);
|
qColor.setNamedColor(buttonStructs[0].background_color);
|
||||||
|
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,7 +29,7 @@ Q_OBJECT
|
||||||
signals:
|
signals:
|
||||||
void firstUrl(QString url);
|
void firstUrl(QString url);
|
||||||
public:
|
public:
|
||||||
NavBar(ConfigResponse *configResponse,MainScreen *mainScreen,QWidget *parent = nullptr);
|
NavBar(MainScreen *mainScreen,QWidget *parent = nullptr);
|
||||||
|
|
||||||
~NavBar() override;
|
~NavBar() override;
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -236,7 +236,7 @@ void ConfigRequest::sendRequest(ConfigResponse *configResponse) {
|
||||||
if(result.isObject()){
|
if(result.isObject()){
|
||||||
QJsonObject obj_root=result.object();
|
QJsonObject obj_root=result.object();
|
||||||
QJsonArray array;
|
QJsonArray array;
|
||||||
|
|
||||||
array = obj_root.value("data").toObject().value("menu").toArray();
|
array = obj_root.value("data").toObject().value("menu").toArray();
|
||||||
QJsonObject obj_basic = obj_root.value("data").toObject().value("basic").toObject();
|
QJsonObject obj_basic = obj_root.value("data").toObject().value("basic").toObject();
|
||||||
configResponse->basic.logo_url = obj_basic.value("logo").toString();
|
configResponse->basic.logo_url = obj_basic.value("logo").toString();
|
||||||
|
@ -251,6 +251,7 @@ void ConfigRequest::sendRequest(ConfigResponse *configResponse) {
|
||||||
QJsonObject object=value.toObject();
|
QJsonObject object=value.toObject();
|
||||||
Button button;
|
Button button;
|
||||||
button.img=object.value("img").toString();
|
button.img=object.value("img").toString();
|
||||||
|
button.orig_name= object.value("orig_name").toString();
|
||||||
// button.img_cover=object.value("img_cover").toString();
|
// button.img_cover=object.value("img_cover").toString();
|
||||||
button.title=object.value("title").toString();
|
button.title=object.value("title").toString();
|
||||||
button.categroy_id = object.value("category_id").toString();
|
button.categroy_id = object.value("category_id").toString();
|
||||||
|
@ -261,6 +262,12 @@ void ConfigRequest::sendRequest(ConfigResponse *configResponse) {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
configResponse->succeed = true;
|
configResponse->succeed = true;
|
||||||
|
QFile file(QApplication::applicationDirPath() + DEFAULT_NAVBAR_FILLE);
|
||||||
|
if (file.open(QIODevice::Text | QIODevice::WriteOnly))
|
||||||
|
{
|
||||||
|
file.write(result.toJson());
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
//Êý¾Ý²»ÍêÕû
|
//Êý¾Ý²»ÍêÕû
|
||||||
configResponse->succeed=false;
|
configResponse->succeed=false;
|
||||||
|
@ -584,7 +591,7 @@ DeviceRequest::DeviceRequest() : RequestBodyBase() {
|
||||||
eventLoop.exec();
|
eventLoop.exec();
|
||||||
delete httpMgr;
|
delete httpMgr;
|
||||||
}
|
}
|
||||||
bool SoftwareRequest::sendRequest(QHash<QString,QString>&startMenu, QHash<QString, Record> *records)
|
bool SoftwareRequest::sendRequest(QHash<QString,QString>&startMenu, QHash<QString, Record> *records, QJsonArray &software_exists)
|
||||||
{
|
{
|
||||||
timer = new QTimer(this);
|
timer = new QTimer(this);
|
||||||
QNetworkAccessManager* httpMgr = new QNetworkAccessManager();
|
QNetworkAccessManager* httpMgr = new QNetworkAccessManager();
|
||||||
|
@ -611,6 +618,7 @@ bool SoftwareRequest::sendRequest(QHash<QString,QString>&startMenu, QHash<QStrin
|
||||||
QJsonObject object;
|
QJsonObject object;
|
||||||
object.insert("reg", array);
|
object.insert("reg", array);
|
||||||
object.insert("start", menu_list);
|
object.insert("start", menu_list);
|
||||||
|
object.insert("exists", software_exists);
|
||||||
obj_root.insert("data", object);
|
obj_root.insert("data", object);
|
||||||
obj_root.insert("type", "update");
|
obj_root.insert("type", "update");
|
||||||
qJsonDocument.setObject(obj_root);
|
qJsonDocument.setObject(obj_root);
|
||||||
|
@ -669,8 +677,8 @@ bool SoftwareRequest::sendRequest(QHash<QString,QString>&startMenu, QHash<QStrin
|
||||||
QByteArray buffer;
|
QByteArray buffer;
|
||||||
delete request_logo;
|
delete request_logo;
|
||||||
reply->close();
|
reply->close();
|
||||||
QString dir = QApplication::applicationDirPath() + "/images/software/";
|
QString dir = QApplication::applicationDirPath() + "/images/svg/";
|
||||||
if (downloadSuccess == true) {
|
if ((reply->error() == QNetworkReply::NoError)&&(downloadSuccess == true)) {
|
||||||
buffer = reply->readAll();
|
buffer = reply->readAll();
|
||||||
QFile file(dir + orig_name + ".svg");
|
QFile file(dir + orig_name + ".svg");
|
||||||
if (file.open(QIODevice::WriteOnly | QIODevice::Text))
|
if (file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||||
|
@ -704,6 +712,9 @@ bool SoftwareRequest::sendRequest(QHash<QString,QString>&startMenu, QHash<QStrin
|
||||||
|
|
||||||
QString OpenWeChatRequest::sendRequest(bool notuse)
|
QString OpenWeChatRequest::sendRequest(bool notuse)
|
||||||
{
|
{
|
||||||
|
QJsonObject obj_root = qJsonDocument.object();
|
||||||
|
obj_root.insert("func", "wxdk");
|
||||||
|
qJsonDocument.setObject(obj_root);
|
||||||
timer = new QTimer(this);
|
timer = new QTimer(this);
|
||||||
QNetworkAccessManager* httpMgr = new QNetworkAccessManager();
|
QNetworkAccessManager* httpMgr = new QNetworkAccessManager();
|
||||||
QNetworkRequest requestInfo;
|
QNetworkRequest requestInfo;
|
||||||
|
@ -727,7 +738,7 @@ QString OpenWeChatRequest::sendRequest(bool notuse)
|
||||||
{
|
{
|
||||||
delete timer;
|
delete timer;
|
||||||
delete httpMgr;
|
delete httpMgr;
|
||||||
delete reply;
|
//delete reply;
|
||||||
return "ok";
|
return "ok";
|
||||||
}
|
}
|
||||||
delete timer;
|
delete timer;
|
||||||
|
|
|
@ -119,7 +119,7 @@ inline QString getMachineGUID() {
|
||||||
class SoftwareRequest :public RequestBodyBase {
|
class SoftwareRequest :public RequestBodyBase {
|
||||||
public:
|
public:
|
||||||
SoftwareRequest():RequestBodyBase(){}
|
SoftwareRequest():RequestBodyBase(){}
|
||||||
bool sendRequest(QHash<QString, QString>&startMenu, QHash<QString, Record>*records);
|
bool sendRequest(QHash<QString, QString>&startMenu, QHash<QString, Record>*records,QJsonArray &software_exists);
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpenWeChatRequest:public RequestBodyBase
|
class OpenWeChatRequest:public RequestBodyBase
|
||||||
|
|
Binary file not shown.
|
@ -9,6 +9,7 @@
|
||||||
#include <PropKey.h>
|
#include <PropKey.h>
|
||||||
#include <ShlObj.h>
|
#include <ShlObj.h>
|
||||||
#include <QtXml/QtXml>
|
#include <QtXml/QtXml>
|
||||||
|
#include <QtNetwork/QtNetwork>
|
||||||
#include <QtSvg/QtSvg>
|
#include <QtSvg/QtSvg>
|
||||||
#include "navbar.h"
|
#include "navbar.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -26,15 +27,10 @@
|
||||||
#pragma comment (lib,"Qt5Xml.lib")
|
#pragma comment (lib,"Qt5Xml.lib")
|
||||||
#endif
|
#endif
|
||||||
#pragma comment (lib,"Shell32.lib")
|
#pragma comment (lib,"Shell32.lib")
|
||||||
#if _MSC_VER >=1936
|
|
||||||
#include <filesystem>
|
|
||||||
namespace fs = std::filesystem;
|
|
||||||
#else
|
|
||||||
#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
|
#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
|
||||||
#include <experimental/filesystem>
|
#include <experimental/filesystem>
|
||||||
namespace fs = std::experimental::filesystem;
|
namespace fs= std::experimental::filesystem;
|
||||||
#endif
|
|
||||||
|
|
||||||
bool getMenu(std::wstring &path_str,QHash<QString,QString> *paths)
|
bool getMenu(std::wstring &path_str,QHash<QString,QString> *paths)
|
||||||
{
|
{
|
||||||
fs::directory_iterator* it = new fs::directory_iterator(path_str);
|
fs::directory_iterator* it = new fs::directory_iterator(path_str);
|
||||||
|
@ -141,7 +137,7 @@ SQLiteHelper::~SQLiteHelper()
|
||||||
bool SQLiteHelper::update_software()
|
bool SQLiteHelper::update_software()
|
||||||
{
|
{
|
||||||
HKEY hKeyUninstall = nullptr;
|
HKEY hKeyUninstall = nullptr;
|
||||||
QHash<QString,QString>* paths = new QHash<QString, QString>;
|
QHash<QString, QString>* paths = new QHash<QString, QString>;
|
||||||
/*QSqlQuery query;
|
/*QSqlQuery query;
|
||||||
QString sql = "select * from kmd_menu;";
|
QString sql = "select * from kmd_menu;";
|
||||||
query.exec(sql);
|
query.exec(sql);
|
||||||
|
@ -180,15 +176,15 @@ bool SQLiteHelper::update_software()
|
||||||
HRESULT hr = SHGetFolderPathW(nullptr, CSIDL_COMMON_PROGRAMS, nullptr, 0, path);//获取ProgramData中开始菜单的路径
|
HRESULT hr = SHGetFolderPathW(nullptr, CSIDL_COMMON_PROGRAMS, nullptr, 0, path);//获取ProgramData中开始菜单的路径
|
||||||
std::wstring path_str(path);
|
std::wstring path_str(path);
|
||||||
getMenu(path_str, paths);
|
getMenu(path_str, paths);
|
||||||
|
|
||||||
for(int i=0;i<sizeof(path)/sizeof(wchar_t);i++)
|
for (int i = 0; i < sizeof(path) / sizeof(wchar_t); i++)
|
||||||
{
|
{
|
||||||
path[i] = 0;
|
path[i] = 0;
|
||||||
}
|
}
|
||||||
hr = SHGetFolderPathW(nullptr, CSIDL_PROGRAMS, nullptr, 0, path);//获取用户文件夹中开始菜单的路径
|
hr = SHGetFolderPathW(nullptr, CSIDL_PROGRAMS, nullptr, 0, path);//获取用户文件夹中开始菜单的路径
|
||||||
path_str.clear();
|
path_str.clear();
|
||||||
path_str = std::wstring(path);
|
path_str = std::wstring(path);
|
||||||
getMenu(path_str, paths);
|
getMenu(path_str, paths);
|
||||||
// 打开注册表中的已安装软件列表
|
// 打开注册表中的已安装软件列表
|
||||||
QHash<QString, Record> reg_records;
|
QHash<QString, Record> reg_records;
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
|
@ -230,7 +226,7 @@ bool SQLiteHelper::update_software()
|
||||||
&ftLastWriteTime); // last write time
|
&ftLastWriteTime); // last write time
|
||||||
|
|
||||||
// 枚举该列表下所有子键
|
// 枚举该列表下所有子键
|
||||||
for (DWORD i = 0; i<cSubKeys; i++)
|
for (DWORD i = 0; i < cSubKeys; i++)
|
||||||
{
|
{
|
||||||
WCHAR szSubKey[MAX_PATH] = { 0 };
|
WCHAR szSubKey[MAX_PATH] = { 0 };
|
||||||
DWORD dwSize = MAX_PATH;
|
DWORD dwSize = MAX_PATH;
|
||||||
|
@ -239,7 +235,7 @@ bool SQLiteHelper::update_software()
|
||||||
{
|
{
|
||||||
// 读取软件属性值
|
// 读取软件属性值
|
||||||
HKEY hSubKey;
|
HKEY hSubKey;
|
||||||
if (RegOpenKeyExW(hKey, szSubKey, 0, KEY_READ| KEY_WOW64_64KEY, &hSubKey) == ERROR_SUCCESS)
|
if (RegOpenKeyExW(hKey, szSubKey, 0, KEY_READ | KEY_WOW64_64KEY, &hSubKey) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
Record record;
|
Record record;
|
||||||
WCHAR szProductPath[MAX_PATH] = { 0 };
|
WCHAR szProductPath[MAX_PATH] = { 0 };
|
||||||
|
@ -287,11 +283,11 @@ bool SQLiteHelper::update_software()
|
||||||
record.op = "soft";
|
record.op = "soft";
|
||||||
record.locked = false;
|
record.locked = false;
|
||||||
RegCloseKey(hSubKey);
|
RegCloseKey(hSubKey);
|
||||||
if(!path.isEmpty())
|
if (!path.isEmpty())
|
||||||
{
|
{
|
||||||
reg_records.insert(path, record);
|
reg_records.insert(path, record);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -340,7 +336,7 @@ bool SQLiteHelper::update_software()
|
||||||
&ftLastWriteTime); // last write time
|
&ftLastWriteTime); // last write time
|
||||||
|
|
||||||
// 枚举该列表下所有子键
|
// 枚举该列表下所有子键
|
||||||
for (DWORD i = 0;i<cSubKeys ; i++)
|
for (DWORD i = 0; i < cSubKeys; i++)
|
||||||
{
|
{
|
||||||
WCHAR szSubKey[MAX_PATH] = { 0 };
|
WCHAR szSubKey[MAX_PATH] = { 0 };
|
||||||
DWORD dwSize = MAX_PATH;
|
DWORD dwSize = MAX_PATH;
|
||||||
|
@ -408,12 +404,12 @@ bool SQLiteHelper::update_software()
|
||||||
RegCloseKey(hkey2);
|
RegCloseKey(hkey2);
|
||||||
}
|
}
|
||||||
BOOL isWow64;
|
BOOL isWow64;
|
||||||
if(IsWow64Process(GetCurrentProcess(),&isWow64))
|
if (IsWow64Process(GetCurrentProcess(), &isWow64))
|
||||||
{
|
{
|
||||||
HKEY hkey3;
|
HKEY hkey3;
|
||||||
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||||
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall",
|
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall",
|
||||||
0, KEY_READ|KEY_WOW64_64KEY, &hkey3) == ERROR_SUCCESS)
|
0, KEY_READ | KEY_WOW64_64KEY, &hkey3) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
TCHAR achKey[MAX_KEY_LENGTH]; // buffer for subkey name
|
TCHAR achKey[MAX_KEY_LENGTH]; // buffer for subkey name
|
||||||
DWORD cbName; // size of name string
|
DWORD cbName; // size of name string
|
||||||
|
@ -449,7 +445,7 @@ bool SQLiteHelper::update_software()
|
||||||
&ftLastWriteTime); // last write time
|
&ftLastWriteTime); // last write time
|
||||||
|
|
||||||
// 枚举该列表下所有子键
|
// 枚举该列表下所有子键
|
||||||
for (DWORD i = 0;i<cSubKeys ; i++)
|
for (DWORD i = 0; i < cSubKeys; i++)
|
||||||
{
|
{
|
||||||
WCHAR szSubKey[MAX_PATH] = { 0 };
|
WCHAR szSubKey[MAX_PATH] = { 0 };
|
||||||
DWORD dwSize = MAX_PATH;
|
DWORD dwSize = MAX_PATH;
|
||||||
|
@ -650,13 +646,41 @@ bool SQLiteHelper::update_software()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete paths;*/
|
delete paths;*/
|
||||||
for(auto key :reg_records.keys())
|
for (auto key : reg_records.keys())
|
||||||
{
|
{
|
||||||
public_programs_list.insert(reg_records[key].orig_name, reg_records[key]);
|
public_programs_list.insert(reg_records[key].orig_name, reg_records[key]);
|
||||||
}
|
}
|
||||||
|
QSqlQuery find2(db);
|
||||||
|
QJsonArray array;
|
||||||
|
if (find2.exec("select * from kmd_menu where status=1;")) {
|
||||||
|
while (find2.next()) {
|
||||||
|
QJsonObject obj;
|
||||||
|
obj.insert("sort", find2.value("sort").toInt());
|
||||||
|
obj.insert("app_id", find2.value("app_id").toString());
|
||||||
|
obj.insert("locked", find2.value("locked").toBool());
|
||||||
|
obj.insert("type", find2.value("type").toString());
|
||||||
|
obj.insert("category_id", find2.value("category_id").toString());
|
||||||
|
obj.insert("name", find2.value("name").toString());
|
||||||
|
obj.insert("orig_name", find2.value("orig_name").toString());
|
||||||
|
obj.insert("version", find2.value("version").toString());
|
||||||
|
obj.insert("dev", find2.value("dev").toString());
|
||||||
|
obj.insert("create_time", find2.value("create_time").toInt());
|
||||||
|
obj.insert("use_time", find2.value("use_time").toInt());
|
||||||
|
obj.insert("op", find2.value("op").toString());
|
||||||
|
obj.insert("func", find2.value("func").toString());
|
||||||
|
obj.insert("path", find2.value("path").toString());
|
||||||
|
obj.insert("url", find2.value("url").toString());
|
||||||
|
obj.insert("initial_position", find2.value("initial_position").toString());
|
||||||
|
obj.insert("logo", find2.value("logo").toString());
|
||||||
|
obj.insert("status", find2.value("status").toBool());
|
||||||
|
obj.insert("is_delete", find2.value("is_delete").toBool());
|
||||||
|
array.append(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//进行网络请求,补全字段
|
//进行网络请求,补全字段
|
||||||
SoftwareRequest software_request;
|
SoftwareRequest software_request;
|
||||||
bool ok=software_request.sendRequest(*paths,&public_programs_list);
|
bool ok=software_request.sendRequest(*paths,&public_programs_list,array);
|
||||||
if(!ok)
|
if(!ok)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -697,6 +721,7 @@ bool SQLiteHelper::update_software()
|
||||||
sql += "' where orig_name='";
|
sql += "' where orig_name='";
|
||||||
sql += key;
|
sql += key;
|
||||||
sql += "';";
|
sql += "';";
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -709,6 +734,10 @@ bool SQLiteHelper::update_software()
|
||||||
sql += ",'";
|
sql += ",'";
|
||||||
sql += public_programs_list[key].type;
|
sql += public_programs_list[key].type;
|
||||||
sql += "','";
|
sql += "','";
|
||||||
|
sql += QString::number(ALL, 10);
|
||||||
|
sql += ",";
|
||||||
|
sql += QString::number(SOFT, 10);
|
||||||
|
sql += ",";
|
||||||
sql += QString::number(OTHERS, 10);
|
sql += QString::number(OTHERS, 10);
|
||||||
sql += "','";
|
sql += "','";
|
||||||
sql += public_programs_list[key].name;
|
sql += public_programs_list[key].name;
|
||||||
|
@ -733,6 +762,37 @@ bool SQLiteHelper::update_software()
|
||||||
sql += "','";
|
sql += "','";
|
||||||
sql += public_programs_list[key].status;
|
sql += public_programs_list[key].status;
|
||||||
sql += "');";
|
sql += "');";
|
||||||
|
bool categories[8] = { false };
|
||||||
|
categories[ALL - 1] = true;
|
||||||
|
categories[SOFT - 1] = true;
|
||||||
|
for (int i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
QSqlQuery query2(db);
|
||||||
|
if (categories[i])
|
||||||
|
{
|
||||||
|
query2.prepare("select total from kmd_category where id=:id;");
|
||||||
|
query2.bindValue(":id", i + 1);
|
||||||
|
if (!query2.exec())
|
||||||
|
{
|
||||||
|
QSqlQuery rollback(db);
|
||||||
|
rollback.exec("rollback;");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (query2.next())
|
||||||
|
{
|
||||||
|
int total = query2.value("total").toInt();
|
||||||
|
query2.prepare("update kmd_category set total=:total where id=:id;");
|
||||||
|
query2.bindValue(":total", total + 1);
|
||||||
|
query2.bindValue(":id", i + 1);
|
||||||
|
if (!query2.exec())
|
||||||
|
{
|
||||||
|
QSqlQuery rollback(db);
|
||||||
|
rollback.exec("rollback;");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
QSqlQuery query(db);
|
QSqlQuery query(db);
|
||||||
if(!query.exec(sql))
|
if(!query.exec(sql))
|
||||||
|
@ -741,6 +801,7 @@ bool SQLiteHelper::update_software()
|
||||||
rollback.exec();
|
rollback.exec();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
QSqlQuery find(db);
|
QSqlQuery find(db);
|
||||||
|
|
||||||
|
@ -755,6 +816,37 @@ bool SQLiteHelper::update_software()
|
||||||
del.prepare("update kmd_menu set status=0 where orig_name=:orig_name;");
|
del.prepare("update kmd_menu set status=0 where orig_name=:orig_name;");
|
||||||
del.bindValue(":orig_value", find.value("orig_name"));
|
del.bindValue(":orig_value", find.value("orig_name"));
|
||||||
del.exec();
|
del.exec();
|
||||||
|
bool categories[8] = { false };
|
||||||
|
categories[ALL - 1] = true;
|
||||||
|
categories[SOFT - 1] = true;
|
||||||
|
for (int i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
QSqlQuery query2(db);
|
||||||
|
if (categories[i])
|
||||||
|
{
|
||||||
|
query2.prepare("select total from kmd_category where id=:id;");
|
||||||
|
query2.bindValue(":id", i + 1);
|
||||||
|
if (!query2.exec())
|
||||||
|
{
|
||||||
|
QSqlQuery rollback(db);
|
||||||
|
rollback.exec("rollback;");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (query2.next())
|
||||||
|
{
|
||||||
|
int total = query2.value("total").toInt();
|
||||||
|
query2.prepare("update kmd_category set total=:total where id=:id;");
|
||||||
|
query2.bindValue(":total", total - 1);
|
||||||
|
query2.bindValue(":id", i + 1);
|
||||||
|
if (!query2.exec())
|
||||||
|
{
|
||||||
|
QSqlQuery rollback(db);
|
||||||
|
rollback.exec("rollback;");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -786,7 +878,7 @@ void SetSVGBackColor(QDomElement& elem, QString strtagname, QString strattr, QSt
|
||||||
SetSVGBackColor(elem.childNodes().at(i).toElement(), strtagname, strattr, strattrval);
|
SetSVGBackColor(elem.childNodes().at(i).toElement(), strtagname, strattr, strattrval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool SQLiteHelper::get_software(QList<ButtonStruct>* buttons, ConfigResponse* config_response)
|
bool SQLiteHelper::get_software(QList<ButtonStruct>* button_structs, ConfigResponse* config_response)
|
||||||
{
|
{
|
||||||
QSqlQuery query(db);
|
QSqlQuery query(db);
|
||||||
QString sql = "select * from kmd_menu where type='navbar' order by sort,orig_name asc ;";
|
QString sql = "select * from kmd_menu where type='navbar' order by sort,orig_name asc ;";
|
||||||
|
@ -797,7 +889,8 @@ bool SQLiteHelper::get_software(QList<ButtonStruct>* buttons, ConfigResponse* co
|
||||||
QString background_color;
|
QString background_color;
|
||||||
QString title_color;
|
QString title_color;
|
||||||
QString title_cover_color;
|
QString title_cover_color;
|
||||||
if(config_response->succeed)
|
QList<Button> buttons = config_response->buttons;
|
||||||
|
if (config_response->succeed)
|
||||||
{
|
{
|
||||||
background_color = config_response->basic.backgroud_color;
|
background_color = config_response->basic.backgroud_color;
|
||||||
title_color = config_response->basic.title_color;
|
title_color = config_response->basic.title_color;
|
||||||
|
@ -805,19 +898,138 @@ bool SQLiteHelper::get_software(QList<ButtonStruct>* buttons, ConfigResponse* co
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
background_color = DEFAULT_BACKGROUND_COLOR;
|
QFile file(QApplication::applicationDirPath() + DEFAULT_NAVBAR_FILLE);
|
||||||
title_color = DEFAULT_TEXT_COLOR;
|
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
title_cover_color = DEFAULT_COVER_COLOR;
|
{
|
||||||
|
QByteArray buffer;
|
||||||
|
buffer = file.readAll();
|
||||||
|
QJsonDocument result;
|
||||||
|
result = QJsonDocument::fromJson(buffer);
|
||||||
|
//如果数据完整
|
||||||
|
if (result.isObject()) {
|
||||||
|
QJsonObject obj_root = result.object();
|
||||||
|
QJsonArray array;
|
||||||
|
|
||||||
|
array = obj_root.value("data").toObject().value("menu").toArray();
|
||||||
|
qDebug() << array;
|
||||||
|
QJsonObject obj_basic = obj_root.value("data").toObject().value("basic").toObject();
|
||||||
|
background_color = obj_basic.value("backgroud_color").toString();
|
||||||
|
title_color = obj_basic.value("title_color").toString();
|
||||||
|
title_cover_color = obj_basic.value("title_cover_color").toString();
|
||||||
|
auto i = 0;
|
||||||
|
for (auto value : array) {
|
||||||
|
QJsonObject object = value.toObject();
|
||||||
|
Button button;
|
||||||
|
button.img = object.value("img").toString();
|
||||||
|
// button.img_cover=object.value("img_cover").toString();
|
||||||
|
button.title = object.value("title").toString();
|
||||||
|
button.categroy_id = object.value("category_id").toString();
|
||||||
|
button.orig_name = object.value("orig_name").toString();
|
||||||
|
button.op = object.value("op").toString();
|
||||||
|
button.func = object.value("func").toString();
|
||||||
|
button.url = object.value("url").toString();
|
||||||
|
buttons << button;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
background_color = DEFAULT_BACKGROUND_COLOR;
|
||||||
|
title_color = DEFAULT_TEXT_COLOR;
|
||||||
|
title_cover_color = DEFAULT_COVER_COLOR;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
QByteArray* buffer = new QByteArray;
|
QByteArray* buffer = new QByteArray;
|
||||||
QHash<QString, ButtonStruct> button_map;
|
QHash<QString, ButtonStruct> button_map;
|
||||||
for(auto menu : config_response->buttons)
|
QNetworkAccessManager* manager;
|
||||||
|
for (auto menu : buttons)
|
||||||
{
|
{
|
||||||
|
ButtonStruct button_struct;
|
||||||
|
button_struct.text = menu.title;
|
||||||
|
button_struct.orig_name = menu.orig_name;
|
||||||
|
button_struct.op = menu.op;
|
||||||
|
button_struct.func = menu.func;
|
||||||
|
button_struct.url = menu.url;
|
||||||
|
QImage* image = new QImage(200, 200, QImage::Format_ARGB32);
|
||||||
|
QImage* image_cover = new QImage(200, 200, QImage::Format_ARGB32);
|
||||||
|
downloadSuccess = true;
|
||||||
|
QUrl url_logo(menu.img);
|
||||||
|
QNetworkRequest* request_logo = new QNetworkRequest(url_logo);
|
||||||
|
manager = new QNetworkAccessManager;
|
||||||
|
reply = manager->get(*request_logo);
|
||||||
|
QTimer timer;
|
||||||
|
timer.setInterval(5000);
|
||||||
|
connect(reply, &QNetworkReply::finished, &eventLoop, &QEventLoop::quit);
|
||||||
|
connect(&timer, &QTimer::timeout, this, &SQLiteHelper::cancelDownload);
|
||||||
|
eventLoop.exec();
|
||||||
|
timer.stop();
|
||||||
|
buffer = new QByteArray;
|
||||||
|
*buffer = reply->readAll();
|
||||||
|
delete request_logo;
|
||||||
|
reply->close();
|
||||||
|
if ((reply->error() == QNetworkReply::NoError)&&(downloadSuccess == true)) {
|
||||||
|
QFile file(QApplication::applicationDirPath() + DEFAULT_SVG_PATH + menu.orig_name + ".svg");
|
||||||
|
if (file.open(QIODevice::Text | QIODevice::WriteOnly))
|
||||||
|
{
|
||||||
|
file.write(*buffer);
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
QString icon = QApplication::applicationDirPath() + DEFAULT_SVG_PATH + menu.orig_name + ".svg";
|
||||||
|
QFile file(icon);
|
||||||
|
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
|
{
|
||||||
|
//QByteArray* buffer = new QByteArray;
|
||||||
|
*buffer = file.readAll();
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
icon = QApplication::applicationDirPath() + DEFAULT_IMAGE;
|
||||||
|
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
|
{
|
||||||
|
//QByteArray* buffer = new QByteArray;
|
||||||
|
*buffer = file.readAll();
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete manager;
|
||||||
|
manager = nullptr;
|
||||||
|
|
||||||
|
QSvgRenderer* render_image = new QSvgRenderer(*buffer);
|
||||||
|
QPainter painter_image(image);
|
||||||
|
painter_image.setCompositionMode(QPainter::CompositionMode_Clear); // 清除画布
|
||||||
|
painter_image.fillRect(image->rect(), Qt::transparent); // 填充透明色
|
||||||
|
painter_image.setCompositionMode(QPainter::CompositionMode_SourceOver); // 恢复默认值
|
||||||
|
render_image->render(&painter_image);
|
||||||
|
//修改颜色
|
||||||
|
QDomDocument doc;
|
||||||
|
doc.setContent(*buffer);
|
||||||
|
SetSVGBackColor(doc.documentElement(), "path", "fill", title_cover_color);
|
||||||
|
QSvgRenderer* render_image_cover = new QSvgRenderer(doc.toByteArray());
|
||||||
|
QPainter painter_image_cover(image_cover);
|
||||||
|
painter_image_cover.setCompositionMode(QPainter::CompositionMode_Clear); // 清除画布
|
||||||
|
painter_image_cover.fillRect(image_cover->rect(), Qt::transparent); // 填充透明色
|
||||||
|
painter_image_cover.setCompositionMode(QPainter::CompositionMode_SourceOver); // 恢复默认值
|
||||||
|
render_image_cover->render(&painter_image_cover);
|
||||||
|
|
||||||
|
delete render_image;
|
||||||
|
delete render_image_cover;
|
||||||
|
|
||||||
|
button_struct.image = image;
|
||||||
|
button_struct.image_cover = image_cover;
|
||||||
|
button_struct.background_color = background_color;
|
||||||
|
button_struct.text_color = QColor(title_color);
|
||||||
|
button_struct.text_cover_color = QColor(title_cover_color);
|
||||||
|
*button_structs << button_struct;
|
||||||
}
|
}
|
||||||
while (query.next())
|
while (query.next())
|
||||||
{
|
{
|
||||||
QString icon = QApplication::applicationDirPath() + "/images/software/" + query.value("orig_name").toString() + ".svg";
|
QString icon = QApplication::applicationDirPath() + "/images/svg/" + query.value("orig_name").toString() + ".svg";
|
||||||
ButtonStruct button_struct;
|
ButtonStruct button_struct;
|
||||||
button_struct.path = query.value("path").toString();
|
button_struct.path = query.value("path").toString();
|
||||||
button_struct.text = query.value("name").toString();
|
button_struct.text = query.value("name").toString();
|
||||||
|
@ -842,7 +1054,7 @@ bool SQLiteHelper::get_software(QList<ButtonStruct>* buttons, ConfigResponse* co
|
||||||
//修改颜色
|
//修改颜色
|
||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
doc.setContent(svg_buffer);
|
doc.setContent(svg_buffer);
|
||||||
SetSVGBackColor(doc.documentElement(), "path", "fill",title_cover_color);
|
SetSVGBackColor(doc.documentElement(), "path", "fill", title_cover_color);
|
||||||
QSvgRenderer* render_image_cover = new QSvgRenderer(doc.toByteArray());
|
QSvgRenderer* render_image_cover = new QSvgRenderer(doc.toByteArray());
|
||||||
QPainter painter_image_cover(image_cover);
|
QPainter painter_image_cover(image_cover);
|
||||||
painter_image_cover.setCompositionMode(QPainter::CompositionMode_Clear); // 清除画布
|
painter_image_cover.setCompositionMode(QPainter::CompositionMode_Clear); // 清除画布
|
||||||
|
@ -852,7 +1064,8 @@ bool SQLiteHelper::get_software(QList<ButtonStruct>* buttons, ConfigResponse* co
|
||||||
|
|
||||||
delete render_image;
|
delete render_image;
|
||||||
delete render_image_cover;
|
delete render_image_cover;
|
||||||
}else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
icon = QApplication::applicationDirPath() + DEFAULT_IMAGE;
|
icon = QApplication::applicationDirPath() + DEFAULT_IMAGE;
|
||||||
QFile file(icon);
|
QFile file(icon);
|
||||||
|
@ -886,9 +1099,10 @@ bool SQLiteHelper::get_software(QList<ButtonStruct>* buttons, ConfigResponse* co
|
||||||
button_struct.background_color = background_color;
|
button_struct.background_color = background_color;
|
||||||
button_struct.text_color = QColor(title_color);
|
button_struct.text_color = QColor(title_color);
|
||||||
button_struct.text_cover_color = QColor(title_cover_color);
|
button_struct.text_cover_color = QColor(title_cover_color);
|
||||||
*buttons << button_struct;
|
*button_structs << button_struct;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -900,7 +1114,9 @@ void SQLiteHelper::cancelDownload() {
|
||||||
}
|
}
|
||||||
bool SQLiteHelper::update_app()
|
bool SQLiteHelper::update_app()
|
||||||
{
|
{
|
||||||
QString app_path = QApplication::applicationDirPath()+"/app";
|
QSqlQuery work(db);
|
||||||
|
work.exec("begin;");
|
||||||
|
QString app_path = QApplication::applicationDirPath() + "/app";
|
||||||
for(auto dir: fs::directory_iterator(fs::path(app_path.toStdString())))
|
for(auto dir: fs::directory_iterator(fs::path(app_path.toStdString())))
|
||||||
{
|
{
|
||||||
if(fs::is_directory(dir))
|
if(fs::is_directory(dir))
|
||||||
|
@ -953,11 +1169,43 @@ bool SQLiteHelper::update_app()
|
||||||
query.addBindValue(obj_root.value("initial_position").toString());
|
query.addBindValue(obj_root.value("initial_position").toString());
|
||||||
query.addBindValue(obj_root.value("status").toBool());
|
query.addBindValue(obj_root.value("status").toBool());
|
||||||
query.exec();
|
query.exec();
|
||||||
|
bool categories[8]={false};
|
||||||
|
categories[ALL - 1] = true;
|
||||||
|
categories[INNER - 1] = true;
|
||||||
|
for (int i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
QSqlQuery query2(db);
|
||||||
|
if (categories[i])
|
||||||
|
{
|
||||||
|
query2.prepare("select total from kmd_category where id=:id;");
|
||||||
|
query2.bindValue(":id", i + 1);
|
||||||
|
if (!query2.exec())
|
||||||
|
{
|
||||||
|
QSqlQuery rollback(db);
|
||||||
|
rollback.exec("rollback;");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (query2.next())
|
||||||
|
{
|
||||||
|
int total = query2.value("total").toInt();
|
||||||
|
query2.prepare("update kmd_category set total=:total where id=:id;");
|
||||||
|
query2.bindValue(":total", total + 1);
|
||||||
|
query2.bindValue(":id", i + 1);
|
||||||
|
if (!query2.exec())
|
||||||
|
{
|
||||||
|
QSqlQuery rollback(db);
|
||||||
|
rollback.exec("rollback;");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
work.exec("commit;");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1045,25 +1293,48 @@ bool SQLiteHelper::set_category(QList<Categrory>& categrories)
|
||||||
qDebug() << work.lastError();
|
qDebug() << work.lastError();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool SQLiteHelper::get_category(QList<Categrory>& categrories)
|
bool SQLiteHelper::get_category(QList<Categrory>& categrories,bool is_edit)
|
||||||
{
|
{
|
||||||
QSqlQuery query(db);
|
QSqlQuery query(db);
|
||||||
if(!query.exec("select id,name,status,sort from kmd_category"))
|
if(is_edit)
|
||||||
{
|
{
|
||||||
return false;
|
if (!query.exec("select id,name,status,sort from kmd_category where is_edit=1;"))
|
||||||
}
|
|
||||||
while(query.next())
|
|
||||||
{
|
|
||||||
if(query.value("name")==QString::fromLocal8Bit("È«²¿"))
|
|
||||||
{
|
{
|
||||||
continue;
|
return false;
|
||||||
|
}
|
||||||
|
while (query.next())
|
||||||
|
{
|
||||||
|
if (query.value("name") == QString::fromLocal8Bit("全部"))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Categrory categrory;
|
||||||
|
categrory.name = query.value("name").toString();
|
||||||
|
categrory.id = query.value("id").toInt();
|
||||||
|
categrory.sort = query.value("sort").toInt();
|
||||||
|
categrory.display = query.value("status").toBool();
|
||||||
|
categrories << categrory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!query.exec("select id,name,status,sort from kmd_category;"))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
while (query.next())
|
||||||
|
{
|
||||||
|
if (query.value("name") == QString::fromLocal8Bit("全部"))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Categrory categrory;
|
||||||
|
categrory.name = query.value("name").toString();
|
||||||
|
categrory.id = query.value("id").toInt();
|
||||||
|
categrory.sort = query.value("sort").toInt();
|
||||||
|
categrory.display = query.value("status").toBool();
|
||||||
|
categrories << categrory;
|
||||||
}
|
}
|
||||||
Categrory categrory;
|
|
||||||
categrory.name = query.value("name").toString();
|
|
||||||
categrory.id = query.value("id").toInt();
|
|
||||||
categrory.sort = query.value("sort").toInt();
|
|
||||||
categrory.display = query.value("status").toBool();
|
|
||||||
categrories << categrory;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1113,6 +1384,8 @@ bool SQLiteHelper::get_all_software(QList<Record> &softwares,int category)
|
||||||
|
|
||||||
bool SQLiteHelper::edit_software(QString name, QString orig_name, QString path, QString sort, bool* categories, QString type)
|
bool SQLiteHelper::edit_software(QString name, QString orig_name, QString path, QString sort, bool* categories, QString type)
|
||||||
{
|
{
|
||||||
|
QSqlQuery begin(db);
|
||||||
|
begin.exec("begin;");
|
||||||
if (type.isEmpty())
|
if (type.isEmpty())
|
||||||
{
|
{
|
||||||
QString sql = "update kmd_menu set name=:name,path=:path,sort=:sort,category_id=:categories where orig_name=:orig_name;";
|
QString sql = "update kmd_menu set name=:name,path=:path,sort=:sort,category_id=:categories where orig_name=:orig_name;";
|
||||||
|
@ -1133,8 +1406,47 @@ bool SQLiteHelper::edit_software(QString name, QString orig_name, QString path,
|
||||||
query.bindValue(":orig_name", orig_name);
|
query.bindValue(":orig_name", orig_name);
|
||||||
if (!query.exec())
|
if (!query.exec())
|
||||||
{
|
{
|
||||||
|
QSqlQuery rollback(db);
|
||||||
|
rollback.exec("rollback;");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
qDebug() << query.lastError();
|
||||||
|
QSqlQuery categories_sql(db);
|
||||||
|
for(int i=0;i<8;i++)
|
||||||
|
{
|
||||||
|
QSqlQuery query2(db);
|
||||||
|
if(categories[i])
|
||||||
|
{
|
||||||
|
query2.prepare("select total from kmd_category where id=:id;");
|
||||||
|
query2.bindValue(":id", i + 1);
|
||||||
|
if(!query2.exec())
|
||||||
|
{
|
||||||
|
QSqlQuery rollback(db);
|
||||||
|
rollback.exec("rollback;");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(query2.next())
|
||||||
|
{
|
||||||
|
QSqlQuery total(db);
|
||||||
|
QSqlQuery query3(db);
|
||||||
|
QString total_sql = "select id from kmd_menu where category_id like '%";
|
||||||
|
total_sql += QString::number(i + 1);
|
||||||
|
total_sql += "%';";
|
||||||
|
total.exec(total_sql);
|
||||||
|
query3.prepare("update kmd_category set total=:total where id=:id;");
|
||||||
|
query3.bindValue(":total", total.size());;
|
||||||
|
query3.bindValue(":id", i + 1);
|
||||||
|
if (!query3.exec())
|
||||||
|
{
|
||||||
|
QSqlQuery rollback(db);
|
||||||
|
rollback.exec("rollback;");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QSqlQuery commit(db);
|
||||||
|
commit.exec("commit;");
|
||||||
return true;
|
return true;
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
|
@ -1160,6 +1472,43 @@ bool SQLiteHelper::edit_software(QString name, QString orig_name, QString path,
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
qDebug() << query.lastError();
|
||||||
|
|
||||||
|
for (int i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
QSqlQuery query2(db);
|
||||||
|
if (categories[i])
|
||||||
|
{
|
||||||
|
query2.prepare("select total from kmd_category where id=:id;");
|
||||||
|
query2.bindValue(":id", i + 1);
|
||||||
|
if (!query2.exec())
|
||||||
|
{
|
||||||
|
QSqlQuery rollback(db);
|
||||||
|
rollback.exec("rollback;");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (query2.next())
|
||||||
|
{
|
||||||
|
QSqlQuery total(db);
|
||||||
|
QSqlQuery query3(db);
|
||||||
|
QString total_sql = "select id from kmd_menu where category_id like '%";
|
||||||
|
total_sql += QString::number(i + 1);
|
||||||
|
total_sql += "%';";
|
||||||
|
total.exec(total_sql);
|
||||||
|
query3.prepare("update kmd_category set total=:total where id=:id;");
|
||||||
|
query3.bindValue(":total", total.size());;
|
||||||
|
query3.bindValue(":id", i + 1);
|
||||||
|
if (!query3.exec())
|
||||||
|
{
|
||||||
|
QSqlQuery rollback(db);
|
||||||
|
rollback.exec("rollback;");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QSqlQuery commit(db);
|
||||||
|
commit.exec("commit;");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public:
|
||||||
bool get_software(QList<ButtonStruct>* buttons, ConfigResponse* config_response);
|
bool get_software(QList<ButtonStruct>* buttons, ConfigResponse* config_response);
|
||||||
bool update_app();
|
bool update_app();
|
||||||
bool get_buttons(QList<ButtonStruct> &buttons);
|
bool get_buttons(QList<ButtonStruct> &buttons);
|
||||||
bool get_category(QList<Categrory> &categrories);
|
bool get_category(QList<Categrory>& categrories, bool is_edit);
|
||||||
bool set_category(QList<Categrory>& categrories);
|
bool set_category(QList<Categrory>& categrories);
|
||||||
bool get_all_software(QList<Record> &softwares,int category);
|
bool get_all_software(QList<Record> &softwares,int category);
|
||||||
QSqlDatabase db;
|
QSqlDatabase db;
|
||||||
|
|
Loading…
Reference in New Issue