几乎完成

This commit is contained in:
Mike Solar
2023-08-18 19:09:55 +08:00
parent bc3b3f69a7
commit b728e697fb
33 changed files with 1299 additions and 1182 deletions

View File

@ -1,4 +1,4 @@
#include "addapp.h"
#include "addapp.h"
#include <QFileDialog>
#include <QProcessEnvironment>
#include <QMessageBox>
@ -18,19 +18,19 @@ AddApp::AddApp(bool isEdit, Record2 *row , QWidget* parent)
ui.setupUi(this);
this->row=row;
SQLiteHelper sqlite_helper;
setFixedSize(450, 450);
setFixedSize(450, 600);
Record2 record;
sqlite_helper.get_a_software(row->orig_name, &record);
setWindowFlags(Qt::WindowCloseButtonHint);
form = new QFormLayout;
name = new QLineEdit;
form->addRow(QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"), name);
form->addRow(QString::fromLocal8Bit("名称"), name);
if (isEdit)
{
sqlite_helper.get_a_software(row->orig_name, &record);
name_label = new QLabel(orig_name_str);
form->addRow(QString::fromLocal8Bit("ȫ<EFBFBD><EFBFBD>"), name_label);
form->addRow(QString::fromLocal8Bit("全名"), name_label);
record = *row;//最初为啥这么写我也忘了
if (!record.orig_name.isEmpty())
{
name_label->setText(record.orig_name);
@ -40,17 +40,17 @@ AddApp::AddApp(bool isEdit, Record2 *row , QWidget* parent)
else
{
orig_name = new QLineEdit;
form->addRow(QString::fromLocal8Bit("ȫ<EFBFBD><EFBFBD>"), orig_name);
form->addRow(QString::fromLocal8Bit("全名"), orig_name);
}
if (record.orig_name.isEmpty())
{
path = new QPushButton(QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
path = new QPushButton(QString::fromLocal8Bit("浏览"));
connect(path, &QPushButton::clicked, this, &AddApp::broswer_exe);
form->addRow(QString::fromLocal8Bit("·<EFBFBD><EFBFBD>"), path);
form->addRow(QString::fromLocal8Bit("路径"), path);
sort = new QLineEdit;
sort->setValidator(new QIntValidator(10, 100));
form->addRow(QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"), sort);
form->addRow(QString::fromLocal8Bit("排序"), sort);
QList<Categrory> categrories;
layout_inner = new QVBoxLayout;
sqlite_helper.get_category(categrories, true);
@ -62,8 +62,8 @@ AddApp::AddApp(bool isEdit, Record2 *row , QWidget* parent)
layout_inner->addWidget(check_box);
categories_list.insert(category.id, check_box);
}
form->addRow(QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"), layout_inner);
submit_btn = new QPushButton(QString::fromLocal8Bit("<EFBFBD>"));
form->addRow(QString::fromLocal8Bit("类别"), layout_inner);
submit_btn = new QPushButton(QString::fromLocal8Bit("提交"));
form->addWidget(submit_btn);
this->setLayout(form);
connect(path, &QPushButton::click, this, &AddApp::broswer_exe);
@ -75,15 +75,18 @@ AddApp::AddApp(bool isEdit, Record2 *row , QWidget* parent)
name->setText(record.name);
name_str = record.name;
sort_str = QString::number(record.sort);
path = new QPushButton(QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
path = new QPushButton(QString::fromLocal8Bit("浏览"));
path_str = record.exe_file;
path->setText(QString::fromWCharArray(fs::path(path_str.toStdWString()).filename().c_str()));
connect(path, &QPushButton::clicked, this, &AddApp::broswer_exe);
form->addRow(QString::fromLocal8Bit("·<EFBFBD><EFBFBD>"), path);
if (record.op == "soft")
{
form->addRow(QString::fromLocal8Bit("路径"), path);
}
sort = new QLineEdit;
sort->setText(QString::number(record.sort));
sort->setValidator(new QIntValidator(10, 100));
form->addRow(QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"), sort);
form->addRow(QString::fromLocal8Bit("排序"), sort);
QList<Categrory> categrories;
layout_inner = new QVBoxLayout;
sqlite_helper.get_category(categrories, true);
@ -98,15 +101,14 @@ AddApp::AddApp(bool isEdit, Record2 *row , QWidget* parent)
layout_inner->addWidget(check_box);
categories_list.insert(category.id, check_box);
}
form->addRow(QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"), layout_inner);
submit_btn = new QPushButton(QString::fromLocal8Bit("<EFBFBD>"));
form->addRow(QString::fromLocal8Bit("类别"), layout_inner);
submit_btn = new QPushButton(QString::fromLocal8Bit("提交"));
form->addWidget(submit_btn);
this->setLayout(form);
connect(path, &QPushButton::click, this, &AddApp::broswer_exe);
connect(submit_btn, &QPushButton::clicked, this, &AddApp::submit);
this->isEdit = isEdit;
}
}
AddApp::~AddApp()
@ -130,13 +132,13 @@ void AddApp::broswer_exe(){
QString path_str_old = path_str;
if(path_str.isEmpty())
{
path_str = QFileDialog::getOpenFileName(this, QString::fromLocal8Bit("ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"),
QApplication::applicationDirPath(), QString::fromLocal8Bit("Ӧ<EFBFBD>ó<EFBFBD><EFBFBD><EFBFBD> (*.exe)"));
path_str = QFileDialog::getOpenFileName(this, QString::fromLocal8Bit("选择程序"),
QApplication::applicationDirPath(), QString::fromLocal8Bit("应用程序 (*.exe)"));
}
else
{
path_str = QFileDialog::getOpenFileName(this, QString::fromLocal8Bit("ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"),
path_str, QString::fromLocal8Bit("Ӧ<EFBFBD>ó<EFBFBD><EFBFBD><EFBFBD> (*.exe)"));
path_str = QFileDialog::getOpenFileName(this, QString::fromLocal8Bit("选择程序"),
path_str, QString::fromLocal8Bit("应用程序 (*.exe)"));
}
if (path_str.isEmpty()) {
path_str = path_str_old;
@ -147,25 +149,17 @@ void AddApp::broswer_exe(){
}
void AddApp::submit() {
if(isEdit)
if (isEdit)
{
if (!path->text().isEmpty())
{
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;
}
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;
}
else
{
QMessageBox::critical(this, QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"), QString::fromLocal8Bit("δ<EFBFBD><EFBFBD>д·<EFBFBD><EFBFBD>"));
return;
if (sort_str.isEmpty()) {
sort_str = sort_str_old;
}
}
else
@ -184,27 +178,21 @@ void AddApp::submit() {
}
else
{
QMessageBox::critical(this, QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"), QString::fromLocal8Bit("δ<EFBFBD><EFBFBD>дȫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD>"));
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("未填写全名或路径"));
return;
}
}
categories = new bool[8];
for (int i = 0; i < 8; i++) {
for (int i = 0; i < CATEGORIES_NUM; i++) {
categories[i] = false;
}
categories[ALL-1] = true;
if (row->op == "soft") {
categories[SOFT-1] = true;
}
else if (row->op == "app") {
categories[INNER-1] = true;
}
for(auto key:categories_list.keys())
{
categories[key - 1] = categories_list[key]->checkState();
}
for (int i = 0; i < 8; i++) {
for (int i = 0; i < CATEGORIES_NUM; i++) {
qDebug() << categories[i];
}