解决兼容性问题
parent
5ec58b3bfb
commit
9ee232cead
|
@ -23,24 +23,9 @@ AddApp::AddApp(bool isEdit, Record2 *row , QWidget* parent)
|
|||
setWindowFlags(Qt::WindowCloseButtonHint);
|
||||
form = new QFormLayout;
|
||||
name = new QLineEdit;
|
||||
form->addRow(QString::fromLocal8Bit("名称"), name);
|
||||
|
||||
if (isEdit)
|
||||
if(isEdit)
|
||||
{
|
||||
sqlite_helper.get_a_software(row->orig_name, &record);
|
||||
name_label = new QLabel(orig_name_str);
|
||||
form->addRow(QString::fromLocal8Bit("全名"), name_label);
|
||||
record = *row;//最初为啥这么写我也忘了
|
||||
if (!record.orig_name.isEmpty())
|
||||
{
|
||||
name_label->setText(record.orig_name);
|
||||
}
|
||||
orig_name_str = record.orig_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
orig_name = new QLineEdit;
|
||||
form->addRow(QString::fromLocal8Bit("全名"), orig_name);
|
||||
record=*row;//最初为啥这么写我也忘了
|
||||
}
|
||||
|
||||
if (record.orig_name.isEmpty())
|
||||
|
@ -48,8 +33,27 @@ AddApp::AddApp(bool isEdit, Record2 *row , QWidget* parent)
|
|||
path = new QPushButton(QString::fromLocal8Bit("浏览"));
|
||||
connect(path, &QPushButton::clicked, this, &AddApp::broswer_exe);
|
||||
form->addRow(QString::fromLocal8Bit("路径"), path);
|
||||
if (isEdit)
|
||||
{
|
||||
sqlite_helper.get_a_software(row->orig_name, &record);
|
||||
name_label = new QLabel(orig_name_str);
|
||||
form->addRow(QString::fromLocal8Bit("全名"), name_label);
|
||||
if (!record.orig_name.isEmpty())
|
||||
{
|
||||
name_label->setText(record.orig_name);
|
||||
}
|
||||
orig_name_str = record.orig_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
orig_name = new QLineEdit;
|
||||
form->addRow(QString::fromLocal8Bit("全名"), orig_name);
|
||||
}
|
||||
form->addRow(QString::fromLocal8Bit("名称"), name);
|
||||
|
||||
sort = new QLineEdit;
|
||||
sort->setValidator(new QIntValidator(10, 100));
|
||||
sort->setText("50");
|
||||
form->addRow(QString::fromLocal8Bit("排序"), sort);
|
||||
QList<Categrory> categrories;
|
||||
layout_inner = new QVBoxLayout;
|
||||
|
@ -83,6 +87,24 @@ AddApp::AddApp(bool isEdit, Record2 *row , QWidget* parent)
|
|||
{
|
||||
form->addRow(QString::fromLocal8Bit("路径"), path);
|
||||
}
|
||||
if (isEdit)
|
||||
{
|
||||
sqlite_helper.get_a_software(row->orig_name, &record);
|
||||
name_label = new QLabel(orig_name_str);
|
||||
form->addRow(QString::fromLocal8Bit("全名"), name_label);
|
||||
if (!record.orig_name.isEmpty())
|
||||
{
|
||||
name_label->setText(record.orig_name);
|
||||
}
|
||||
orig_name_str = record.orig_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
orig_name = new QLineEdit;
|
||||
form->addRow(QString::fromLocal8Bit("全名"), orig_name);
|
||||
}
|
||||
form->addRow(QString::fromLocal8Bit("名称"), name);
|
||||
|
||||
sort = new QLineEdit;
|
||||
sort->setText(QString::number(record.sort));
|
||||
sort->setValidator(new QIntValidator(10, 100));
|
||||
|
@ -145,7 +167,10 @@ void AddApp::broswer_exe(){
|
|||
}
|
||||
fs::path file(path_str.toStdWString());
|
||||
path->setText(QString::fromStdWString(file.filename().c_str()));
|
||||
|
||||
if(!isEdit)
|
||||
{
|
||||
orig_name->setText(QString::fromStdWString(file.filename().c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
void AddApp::submit() {
|
||||
|
|
|
@ -126,7 +126,7 @@ void ApplicationManager::onclick1(QString op, QString func, QString path, QStrin
|
|||
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("插入失败,全名是否重名"));
|
||||
}
|
||||
|
||||
emit refresh();
|
||||
emit refresh_tab();
|
||||
}
|
||||
}
|
||||
else if (func == "app_update")
|
||||
|
@ -237,7 +237,7 @@ void ApplicationManager::onclick2(QString orig_name, QString op)
|
|||
{
|
||||
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("编辑失败"));
|
||||
}
|
||||
emit refresh();
|
||||
emit refresh_tab();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ signals:
|
|||
void refresh();
|
||||
void refresh_tab();
|
||||
public:
|
||||
QList<MiniButton*> buttons;
|
||||
ApplicationManager(QWidget *parent = nullptr);
|
||||
~ApplicationManager();
|
||||
QWidget* parent;
|
||||
|
@ -69,7 +70,6 @@ private:
|
|||
QHBoxLayout* layout_top;
|
||||
QHBoxLayout* layout_bottom;
|
||||
QMiniBlink* miniblink;
|
||||
QList<MiniButton*> buttons;
|
||||
QList<Record> softwares;
|
||||
QList<ButtonStruct> button_structs;
|
||||
ApplicationManagerPage* application_manager_page_all;
|
||||
|
|
|
@ -86,6 +86,10 @@ void ApplicationManagerPage::onclicked(int state)
|
|||
//刷新页面
|
||||
void ApplicationManagerPage::refresh()
|
||||
{
|
||||
for(auto button:application_manager->buttons)
|
||||
{
|
||||
button->update();
|
||||
}
|
||||
int rowcount = table->rowCount();
|
||||
for(auto i : connections)
|
||||
{
|
||||
|
@ -141,13 +145,18 @@ void ApplicationManagerPage::refresh()
|
|||
}
|
||||
|
||||
table->setCellWidget(i, 0, record2.icon);
|
||||
record2.settings = new MiniButton(software.orig_name, "settings");
|
||||
record2.settings->setText(QString::fromLocal8Bit("设置"));
|
||||
record2.settings->setMaximumSize(60, 40);
|
||||
QMetaObject::Connection connect1=connect(record2.settings, &MiniButton::clicked, record2.settings, &MiniButton::onclick2);
|
||||
connections << connect1;
|
||||
QMetaObject::Connection connect2 = connect(record2.settings, &MiniButton::click2, application_manager, &ApplicationManager::onclick2);
|
||||
connections << connect2;
|
||||
|
||||
if(!software.locked)
|
||||
{
|
||||
record2.settings = new MiniButton(software.orig_name, "settings");
|
||||
record2.settings->setText(QString::fromLocal8Bit("设置"));
|
||||
record2.settings->setMaximumSize(60, 40);
|
||||
QMetaObject::Connection connect1 = connect(record2.settings, &MiniButton::clicked, record2.settings, &MiniButton::onclick2);
|
||||
connections << connect1;
|
||||
QMetaObject::Connection connect2 = connect(record2.settings, &MiniButton::click2, application_manager, &ApplicationManager::onclick2);
|
||||
connections << connect2;
|
||||
table->setCellWidget(i, 7, record2.settings);
|
||||
}
|
||||
record2.open = new MiniButton(software.orig_name, "open");
|
||||
record2.open->setText(QString::fromLocal8Bit("打开"));
|
||||
record2.open->setMaximumSize(60, 40);
|
||||
|
@ -203,7 +212,6 @@ void ApplicationManagerPage::refresh()
|
|||
table->setItem(i, 6, check_box_item);
|
||||
table->setCellWidget(i, 6, record2.check_box);
|
||||
check_box_item->setTextAlignment(Qt::AlignCenter);
|
||||
table->setCellWidget(i, 7, record2.settings);
|
||||
table->setCellWidget(i, 8, record2.open);
|
||||
rows.insert(software.orig_name, record2);
|
||||
table->resizeColumnToContents(0);
|
||||
|
|
|
@ -13,5 +13,7 @@ extern MainWindowLayout *mainWindowLayout;
|
|||
extern QString url_param;
|
||||
extern bool autostart;
|
||||
extern bool agree;
|
||||
extern QString background_color;
|
||||
extern QString text_color;
|
||||
extern ApplicationManager *application_manager;
|
||||
#endif //OFFICEASSISTANT_GLOBALVARIABLES_H
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
MiniButton::MiniButton(QString orig_name, QString op, QWidget* parent)
|
||||
{
|
||||
this->orig_name = orig_name;
|
||||
q_color.setNamedColor(DEFAULT_BACKGROUND_COLOR);
|
||||
|
||||
this->op = op;
|
||||
connect(this, &MiniButton::click, this, &MiniButton::onclick2);
|
||||
|
@ -15,11 +14,6 @@ MiniButton::MiniButton(ButtonStruct button_struct, QWidget *parent)
|
|||
: QPushButton(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
q_color.setNamedColor(DEFAULT_COVER_COLOR);
|
||||
QString style_sheet = "MiniButton:{background-color:";
|
||||
style_sheet += DEFAULT_TEXT_COLOR;
|
||||
style_sheet += ";}";
|
||||
setStyleSheet(style_sheet);
|
||||
connect(this, &MiniButton::click, this, &MiniButton::onclick1);
|
||||
this->button_struct = button_struct;
|
||||
}
|
||||
|
@ -33,6 +27,7 @@ void MiniButton::paintEvent(QPaintEvent* event)
|
|||
setContentsMargins(0, 0, 0, 0);
|
||||
QRect rect(0, 0, this->width(), this->height());
|
||||
QPainter painter(this);
|
||||
q_color.setNamedColor(background_color);
|
||||
|
||||
painter.fillRect(rect, q_color);
|
||||
int text_x = (width() - TEXT_SIZE * text().length() * scale * 3) / 2;
|
||||
|
@ -40,7 +35,7 @@ void MiniButton::paintEvent(QPaintEvent* event)
|
|||
QFont ft;
|
||||
ft.setPixelSize(TEXT_SIZE);
|
||||
QRectF text_rect(text_x, text_y, TEXT_SIZE * text().length() * scale * 3, TEXT_SIZE * scale * 3);
|
||||
painter.setPen(DEFAULT_TEXT_COLOR);
|
||||
painter.setPen(text_color);
|
||||
painter.drawText(text_rect, Qt::AlignCenter, text());
|
||||
|
||||
}
|
||||
|
|
|
@ -155,8 +155,8 @@ void NavBar::getLogoFromInternet(ConfigResponse *configResponse) {
|
|||
timer.stop();
|
||||
buffer = new QByteArray;
|
||||
delete request_logo;
|
||||
reply->close();
|
||||
if (downloadSuccess == true) {
|
||||
|
||||
if (downloadSuccess == true&& reply->error() == QNetworkReply::NoError) {
|
||||
*buffer = reply->readAll();
|
||||
QFile logo(QApplication::applicationDirPath() + DEFAULT_LOGO);
|
||||
if (logo.open(QIODevice::WriteOnly)) {
|
||||
|
@ -164,10 +164,11 @@ void NavBar::getLogoFromInternet(ConfigResponse *configResponse) {
|
|||
logo.close();
|
||||
}
|
||||
buffer->clear();
|
||||
reply->close();
|
||||
|
||||
}
|
||||
delete manager;
|
||||
manager = nullptr;
|
||||
|
||||
}
|
||||
void NavBar::storeToBuffer() {
|
||||
buffer = new QByteArray;
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#pragma comment(lib, "Qt5Network.lib")
|
||||
#endif
|
||||
#pragma comment(lib,"comsuppw.lib")
|
||||
QString background_color;
|
||||
QString text_color;
|
||||
//读取注册表获取MachineUUID
|
||||
bool IsWin11AndLater()
|
||||
{
|
||||
|
@ -187,12 +189,9 @@ RequestBodyBase::RequestBodyBase(){
|
|||
|
||||
void ConfigRequest::sendRequest(ConfigResponse *configResponse) {
|
||||
timer = new QTimer(this);
|
||||
if(agree)
|
||||
{
|
||||
QJsonObject obj_root = qJsonDocument.object();
|
||||
obj_root.insert("autostart", autostart);
|
||||
qJsonDocument.setObject(obj_root);
|
||||
}
|
||||
QJsonObject obj_root = qJsonDocument.object();
|
||||
obj_root.insert("autostart", autostart);
|
||||
qJsonDocument.setObject(obj_root);
|
||||
|
||||
QNetworkAccessManager *httpMgr = new QNetworkAccessManager();
|
||||
QNetworkRequest requestInfo;
|
||||
|
@ -238,8 +237,13 @@ void ConfigRequest::sendRequest(ConfigResponse *configResponse) {
|
|||
|
||||
array = obj_root.value("data").toObject().value("menu").toArray();
|
||||
QJsonObject obj_data = obj_root.value("data").toObject();
|
||||
QString basic_str= obj_data.value("basic").toString();
|
||||
QJsonObject obj_basic=QJsonDocument::fromJson(basic_str.toUtf8()).object();
|
||||
if(!obj_data.value("basic").isObject())
|
||||
{
|
||||
configResponse->succeed=false;
|
||||
delete timer;
|
||||
return;
|
||||
}
|
||||
QJsonObject obj_basic=obj_data.value("basic").toObject();
|
||||
configResponse->basic.logo_url = obj_basic.value("logo").toString();
|
||||
configResponse->basic.device_id = obj_basic.value("device_id").toString();
|
||||
configResponse->basic.dev_id = obj_basic.value("dev_id").toString();
|
||||
|
@ -247,6 +251,7 @@ void ConfigRequest::sendRequest(ConfigResponse *configResponse) {
|
|||
configResponse->basic.backgroud_color = obj_basic.value("backgroud_color").toString();
|
||||
configResponse->basic.title_color = obj_basic.value("title_color").toString();
|
||||
configResponse->basic.title_cover_color = obj_basic.value("title_cover_color").toString();
|
||||
|
||||
auto i=0;
|
||||
for(auto value:array){
|
||||
QJsonObject object=value.toObject();
|
||||
|
|
|
@ -673,6 +673,7 @@ bool SQLiteHelper::update_software()
|
|||
}
|
||||
else
|
||||
{
|
||||
public_programs_list[key].img.replace(QApplication::applicationDirPath(), "");
|
||||
sql = "insert into kmd_menu (sort,app_id,locked,type,category_id,name,orig_name,version,dev,create_time,use_time,op,func,path,url,status,is_navbar,is_elite) values "
|
||||
"(:sort,:app_id,:locked,:type,:category_id,:name,:orig_name,:version,:dev,:create_time,:use_time,:op,:func,:path,:url,:status,:is_navbar,:is_elite); ";
|
||||
query.prepare(sql);
|
||||
|
@ -760,13 +761,13 @@ bool SQLiteHelper::get_software(QList<ButtonStruct>* button_structs, ConfigRespo
|
|||
QSqlQuery query(db);
|
||||
QString sql = "select * from kmd_menu where is_navbar=1 order by sort,orig_name asc ;";
|
||||
|
||||
QString background_color;
|
||||
QString title_color;
|
||||
QString title_cover_color;
|
||||
QList<Button> buttons = config_response->buttons;
|
||||
if (config_response->succeed)
|
||||
{
|
||||
background_color = config_response->basic.backgroud_color;
|
||||
text_color = config_response->basic.title_color;
|
||||
title_color = config_response->basic.title_color;
|
||||
title_cover_color = config_response->basic.title_cover_color;
|
||||
|
||||
|
@ -791,11 +792,13 @@ bool SQLiteHelper::get_software(QList<ButtonStruct>* button_structs, ConfigRespo
|
|||
QJsonObject obj_basic=QJsonDocument::fromJson(obj_data.value("basic").toString().toUtf8()).object();
|
||||
background_color = obj_basic.value("backgroud_color").toString();
|
||||
title_color = obj_basic.value("title_color").toString();
|
||||
text_color = obj_basic.value("title_color").toString();
|
||||
title_cover_color = obj_basic.value("title_cover_color").toString();
|
||||
}
|
||||
else {
|
||||
background_color = DEFAULT_BACKGROUND_COLOR;
|
||||
title_color = DEFAULT_TEXT_COLOR;
|
||||
text_color = DEFAULT_TEXT_COLOR;
|
||||
title_cover_color = DEFAULT_COVER_COLOR;
|
||||
}
|
||||
}
|
||||
|
@ -920,8 +923,8 @@ bool SQLiteHelper::get_software(QList<ButtonStruct>* button_structs, ConfigRespo
|
|||
}else
|
||||
{
|
||||
insert_software(menu.name, menu.orig_name, "", QString::number(menu.sort),
|
||||
categories, QApplication::applicationDirPath() + DEFAULT_SVG_PATH + menu.img_name + ".svg",
|
||||
QApplication::applicationDirPath() + DEFAULT_PNG_PATH + menu.img_name + ".png", menu.type,
|
||||
categories, DEFAULT_SVG_PATH + menu.img_name + ".svg",
|
||||
DEFAULT_PNG_PATH + menu.img_name + ".png", menu.type,
|
||||
menu.locked, menu.op, menu.func, menu.url, menu.is_navbar, menu.is_elite, menu.dev);
|
||||
}
|
||||
|
||||
|
@ -1008,7 +1011,15 @@ bool SQLiteHelper::get_software(QList<ButtonStruct>* button_structs, ConfigRespo
|
|||
delete render_image_cover;
|
||||
}
|
||||
}
|
||||
button_struct.png = new QImage(query.value("png").toString());
|
||||
QFile png(QApplication::applicationDirPath() + query.value("img").toString());
|
||||
if(png.exists())
|
||||
{
|
||||
button_struct.png = new QImage(QApplication::applicationDirPath() + query.value("img").toString());
|
||||
}else
|
||||
{
|
||||
button_struct.png = new QImage(QApplication::applicationDirPath()+DEFAULT_PNG);
|
||||
}
|
||||
|
||||
button_struct.image = image;
|
||||
button_struct.image_cover = image_cover;
|
||||
button_struct.background_color = background_color;
|
||||
|
@ -1102,7 +1113,15 @@ bool SQLiteHelper::get_software(QList<ButtonStruct>* button_structs,QString back
|
|||
delete render_image_cover;
|
||||
}
|
||||
}
|
||||
button_struct.png = new QImage(query.value("png").toString());
|
||||
QFile png(QApplication::applicationDirPath() + query.value("img").toString());
|
||||
if (png.exists())
|
||||
{
|
||||
button_struct.png = new QImage(QApplication::applicationDirPath() + query.value("img").toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
button_struct.png = new QImage(QApplication::applicationDirPath() + DEFAULT_PNG);
|
||||
}
|
||||
button_struct.image = image;
|
||||
button_struct.image_cover = image_cover;
|
||||
button_struct.background_color = background_color;
|
||||
|
@ -1444,7 +1463,7 @@ bool SQLiteHelper::get_all_software(QList<Record> &softwares,int category)
|
|||
record.id = query.value("id").toInt();
|
||||
record.logo=query.value("logo").toString();
|
||||
record.is_navbar=query.value("is_navbar").toBool();
|
||||
record.img = query.value("img").toString();
|
||||
record.img = QApplication::applicationDirPath()+query.value("img").toString();
|
||||
record.sort = query.value("sort").toInt();
|
||||
record.app_id = query.value("app_id").toString();
|
||||
record.locked = query.value("locked").toBool();
|
||||
|
|
Loading…
Reference in New Issue