几乎完成

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

@ -42,6 +42,7 @@ void ConvertImageToTransparent(QImage &img)
NavBar::NavBar(MainScreen *mainScreen,QWidget *parent) :
QWidget(parent), ui(new Ui::NavBar) {
ui->setupUi(this);
this->parent = parent;
//this->setAttribute(Qt::WA_DeleteOnClose);
buffer = new QByteArray;
/*QString style = "background-color:";
@ -55,7 +56,9 @@ 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);
@ -177,31 +180,24 @@ void NavBar::cancelDownload() {
downloadSuccess = false;
}
/*void NavBar::getLogoFromLocal() {
QString dir = QApplication::applicationDirPath();
QFile file(dir + DEFAULT_FILE);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QMessageBox::warning(nullptr, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("无法打开配置文件"));
exit(1);
void NavBar::refresh(int state)
{
SQLiteHelper sqlite_helper;
buttonStructs.clear();
sqlite_helper.get_software(&buttonStructs, background_color,text_color,text_cover_color);
for(auto button:buttons)
{
layout_right->removeWidget(button);
delete button;
buttons.removeOne(button);
}
buffer->clear();
*buffer = file.readAll();
file.close();
QJsonDocument *qJsonDocument = new QJsonDocument;
*qJsonDocument = QJsonDocument::fromJson(*buffer);
QJsonObject *obj_root = new QJsonObject;
if (qJsonDocument->isObject()) {
*obj_root = qJsonDocument->object();
delete qJsonDocument;
QString logo_path = obj_root->value("basic").toObject().value("logo").toString();
logo = new QPixmap(logo_path);
QJsonArray *array = new QJsonArray;
for (auto buttonStruct : buttonStructs) {
MyButton* myButton = new MyButton(buttonStruct, height(), height(), &buttons, this);
myButton->setMaximumHeight(parent->height() / 8);
layout_right->addWidget(myButton);
//myButton->show();
connect(myButton, &MyButton::clicked1, mainWindowLayout, &MainWindowLayout::clickButton);
buttons << myButton;
}
else {
QMessageBox::warning(nullptr, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("配置文件损坏"));
delete obj_root;
exit(1);
}
delete obj_root;
}*/
emit application_manager->refresh();//在这里refresh避免因为refresh导致信号和槽断开
}