diff --git a/OfficeAssistant_msvc/MyButton.cpp b/OfficeAssistant_msvc/MyButton.cpp index b9ecc60..31522b1 100644 --- a/OfficeAssistant_msvc/MyButton.cpp +++ b/OfficeAssistant_msvc/MyButton.cpp @@ -8,7 +8,11 @@ MyButton::MyButton(ButtonStruct &buttonStruct,int width,int height,QListwidth2=width; this->height2=height; this->text=buttonStruct.text; + this->op = buttonStruct.op; + this->func = buttonStruct.func; this->url = buttonStruct.url; + this->path = buttonStruct.path; + this->initial_position = buttonStruct.initial_position; this->logo=buttonStruct.image; this->logo_cover = buttonStruct.image_cover; this->background_color = buttonStruct.background_color; @@ -82,6 +86,6 @@ void MyButton::mouseReleaseEvent(QMouseEvent *event) { checked=false; else checked=true; - emit clicked1(text, url); + emit clicked1(op, func, url, path, initial_position); } diff --git a/OfficeAssistant_msvc/MyButton.h b/OfficeAssistant_msvc/MyButton.h index 3b9934e..c2e1967 100644 --- a/OfficeAssistant_msvc/MyButton.h +++ b/OfficeAssistant_msvc/MyButton.h @@ -16,7 +16,7 @@ class MyButton: public QPushButton{ Q_OBJECT signals: - void clicked1(QString text, QString url); + void clicked1(QString op, QString func, QString url, QString path, QString initial_position); public: MyButton(ButtonStruct &buttonStruct,int width,int height,QList *buttons,QWidget *parent=nullptr); ~MyButton() override; @@ -58,6 +58,10 @@ private: QVBoxLayout *layout; QString text; QString url; + QString op; + QString path; + QString initial_position; + QString func; int width2; int height2; int logicalwidth; diff --git a/kmd.db b/OfficeAssistant_msvc/OfficeAssistant.db similarity index 100% rename from kmd.db rename to OfficeAssistant_msvc/OfficeAssistant.db diff --git a/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.filters b/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.filters index e432da6..ccae62c 100644 --- a/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.filters +++ b/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.filters @@ -72,9 +72,6 @@ - - Source Files - Source Files @@ -102,6 +99,9 @@ Source Files + + Source Files + diff --git a/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.user b/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.user index a7aae0c..e4c8fb0 100644 --- a/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.user +++ b/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.user @@ -5,7 +5,7 @@ WindowsLocalDebugger - 2023-08-06T14:26:06.9540300Z + 2023-08-08T01:58:42.4896992Z 2023-08-08T01:58:34.1935757Z diff --git a/OfficeAssistant_msvc/buttonstruct.h b/OfficeAssistant_msvc/buttonstruct.h index de185e2..d3392f9 100644 --- a/OfficeAssistant_msvc/buttonstruct.h +++ b/OfficeAssistant_msvc/buttonstruct.h @@ -16,5 +16,8 @@ typedef struct taButtonStruct{ QColor text_color; QColor text_cover_color; QString path; + QString initial_position; + QString op; + QString func; }ButtonStruct; #endif //OFFICEASSISTANT_BUTTONSTRUCT_H diff --git a/OfficeAssistant_msvc/config.h b/OfficeAssistant_msvc/config.h index dd27b17..641758b 100644 --- a/OfficeAssistant_msvc/config.h +++ b/OfficeAssistant_msvc/config.h @@ -11,7 +11,7 @@ #define DEFAULT_FILE "/config/default_navbar.kmd" //默认导航栏文件位置 #define KEY "3b046cfe4a2a3e62141a4840f2006210a3224e3615312bef6e19f4983921abe0" //Key #define NAME "办公助手" //中文名 -#define LOGO_TITLEBAR "/icon/logo_navbar.png" //标题栏图标 +#define LOGO_TITLEBAR "/images/icon/logo_navbar.png" //标题栏图标 #define ENG_NAME "OfficeAssistant" //英文名 #define LENG_NAME L"OfficeAssistant" //英文名(宽字符) #define ADD_AUTOSTART 1 @@ -19,4 +19,6 @@ #define VERSION "1.0.0" //软件版本 #define RELEASE "20230801" //Release #define SOFTWARE_URL "http://softapi.1.y01.cn/addons/Kmdsoft/Index/soft" +#define DEFAULT_COLOR "#3399FF" +#define DEFAULT_IMAGE "/images/icon/default.svg" #endif //OFFICEASSISTANT_CONFIG_H diff --git a/OfficeAssistant_msvc/kmd.db b/OfficeAssistant_msvc/kmd.db new file mode 100644 index 0000000..e69de29 diff --git a/OfficeAssistant_msvc/main.cpp b/OfficeAssistant_msvc/main.cpp index d9a30cf..db9b549 100644 --- a/OfficeAssistant_msvc/main.cpp +++ b/OfficeAssistant_msvc/main.cpp @@ -1,15 +1,14 @@ -#include "mainwindow.h" - -#include -#include -double scale; -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - HDC hdc = GetDC(NULL); - scale = GetDeviceCaps(hdc, LOGPIXELSX)/96; - ReleaseDC(NULL,hdc); - MainWindow w; - w.show(); - return a.exec(); -} +#include "mainwindow.h" +#include +#include +double scale; +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + HDC hdc = GetDC(NULL); + scale = GetDeviceCaps(hdc, LOGPIXELSX)/96; + ReleaseDC(NULL,hdc); + MainWindow w; + w.show(); + return a.exec(); +} diff --git a/OfficeAssistant_msvc/mainscreen.cpp b/OfficeAssistant_msvc/mainscreen.cpp index 36c90c3..e8db25d 100644 --- a/OfficeAssistant_msvc/mainscreen.cpp +++ b/OfficeAssistant_msvc/mainscreen.cpp @@ -1,103 +1,103 @@ -// -// Created by HW on 2023/07/27. -// - -// You may need to build the project (run Qt uic code generator) to get "ui_MainScreen.h" resolved - -#include "mainscreen.h" -#include "ui_MainScreen.h" -#include "netio.h" -#include -#include -#include -#include "globalvariables.h" -#include "mythread.h" -#include "config.h" - - -MainScreen::MainScreen(QWidget *parent) : - QWidget(parent), ui(new Ui::MainScreen) { - ui->setupUi(this); - setContentsMargins(0, 0, 0, 0); - widget = new QWidget(this); - layout_left = new QVBoxLayout(widget); - button = new QPushButton(widget); - layout_left->addStretch(4); - layout_left->addWidget(button,1); - layout_left->setAlignment(Qt::AlignCenter); - button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - button->setMinimumSize(100,50); - button->setMaximumSize(200,100); - widget->setLayout(layout_left); - widget->setHidden(true); - button->setStyleSheet("border-style:none;padding:10px;border-radius:5px;background-color:#09bb07;color:white;font-family:SimHei"); - //Plus Math icon by Icons8 - QString dir = QApplication::applicationDirPath(); - button->setText(QString::fromLocal8Bit("打开微信")); - //button->setStyleSheet("text-color:white"); - layout = new QHBoxLayout; - miniblink = new QMiniBlink(this); - layout->addWidget(widget, 1); - layout->addWidget(miniblink, 4); - this->setLayout(layout); - layout->setMargin(0); - //miniblink->setAttribute(Qt::WA_DeleteOnClose); - miniblink->show(); - //miniblink->setSizePolicy(sizePolicy); - //thread = new MyThread(this,&miniblink); - //thread->start(); - //miniblink->moveToThread(thread); - connect(this, &MainScreen::ondestroy, miniblink, &QMiniBlink::ondestroy); - connect(button, &QPushButton::pressed, this, &MainScreen::startWeChat); - connect(this, &MainScreen::started, miniblink, &QMiniBlink::init); - //connect(miniblink, SIGNAL(finish()), miniblink, SLOT(deleteLater())); - //connect(miniblink, SIGNAL(destroyed()), thread, SLOT(quit())); - //connect(thread, &QThread::finished, thread, &QThread::deleteLater); - while(miniblink==nullptr){} - connect(this, &MainScreen::changeUrl, miniblink, &QMiniBlink::switchUrl); - emit started(); -} - -MainScreen::~MainScreen() { - layout_left->removeWidget(button); - widget->setLayout(nullptr); - delete layout_left; - delete button; - emit ondestroy(); - layout->removeWidget(miniblink); - layout->removeWidget(widget); - delete miniblink; - delete widget; - delete layout; - delete ui; -} -void MainScreen::firstUrl(QString url) -{ - QString url_full = BASE_URL + url + url_param; - emit changeUrl(url_full); -} -void MainScreen::clickButton1(QString text, QString url) { - QString url_full = BASE_URL + url + url_param; - if (text == QString::fromLocal8Bit("微信多开")) { - widget->setHidden(false); - miniblink->setHidden(false); - emit changeUrl(url_full); - } - else { - widget->setHidden(true); - miniblink->setHidden(false); - emit changeUrl(url_full); - } -} -void MainScreen::startWeChat() { - QString path = QApplication::applicationDirPath(); - QString exe = path + "/app/wxdk.exe"; - path.replace("/", "\\"); - ShellExecute(GetDesktopWindow(), L"open", exe.toStdWString().c_str(), L"79c86fb12b36dfa33d1a537c9af100b4c7928a9c", path.toStdWString().c_str(), SW_SHOW); -} -//void MainScreen::resizeEvent(QResizeEvent *event) { -// QWidget::resizeEvent(event); -// //broswer->resize(event->size().width() / 5 * 4, event->size().height()); -// miniblink->resize(event->size().width() / 5 * 4, event->size().height()); -// miniblink->update(); -//} +// +// Created by HW on 2023/07/27. +// + +// You may need to build the project (run Qt uic code generator) to get "ui_MainScreen.h" resolved + +#include "mainscreen.h" +#include "ui_MainScreen.h" +#include "netio.h" +#include +#include +#include +#include "globalvariables.h" +#include "mythread.h" +#include "config.h" + + +MainScreen::MainScreen(QWidget *parent) : + QWidget(parent), ui(new Ui::MainScreen) { + ui->setupUi(this); + setContentsMargins(0, 0, 0, 0); + widget = new QWidget(this); + layout_left = new QVBoxLayout(widget); + button = new QPushButton(widget); + layout_left->addStretch(4); + layout_left->addWidget(button,1); + layout_left->setAlignment(Qt::AlignCenter); + button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + button->setMinimumSize(100,50); + button->setMaximumSize(200,100); + widget->setLayout(layout_left); + widget->setHidden(true); + button->setStyleSheet("border-style:none;padding:10px;border-radius:5px;background-color:#09bb07;color:white;font-family:SimHei"); + //Plus Math icon by Icons8 + QString dir = QApplication::applicationDirPath(); + button->setText(QString::fromLocal8Bit("打开微信")); + //button->setStyleSheet("text-color:white"); + layout = new QHBoxLayout; + miniblink = new QMiniBlink(this); + layout->addWidget(widget, 1); + layout->addWidget(miniblink, 4); + this->setLayout(layout); + layout->setMargin(0); + //miniblink->setAttribute(Qt::WA_DeleteOnClose); + miniblink->show(); + //miniblink->setSizePolicy(sizePolicy); + //thread = new MyThread(this,&miniblink); + //thread->start(); + //miniblink->moveToThread(thread); + connect(this, &MainScreen::ondestroy, miniblink, &QMiniBlink::ondestroy); + connect(button, &QPushButton::pressed, this, &MainScreen::startWeChat); + connect(this, &MainScreen::started, miniblink, &QMiniBlink::init); + //connect(miniblink, SIGNAL(finish()), miniblink, SLOT(deleteLater())); + //connect(miniblink, SIGNAL(destroyed()), thread, SLOT(quit())); + //connect(thread, &QThread::finished, thread, &QThread::deleteLater); + while(miniblink==nullptr){} + connect(this, &MainScreen::changeUrl, miniblink, &QMiniBlink::switchUrl); + emit started(); +} + +MainScreen::~MainScreen() { + layout_left->removeWidget(button); + widget->setLayout(nullptr); + delete layout_left; + delete button; + emit ondestroy(); + layout->removeWidget(miniblink); + layout->removeWidget(widget); + delete miniblink; + delete widget; + delete layout; + delete ui; +} +void MainScreen::firstUrl(QString url) +{ + QString url_full = BASE_URL + url + url_param; + emit changeUrl(url_full); +} +void MainScreen::clickButton1(QString op,QString url) { + QString url_full = BASE_URL + url + url_param; + if (op == "openwechat") { + widget->setHidden(false); + miniblink->setHidden(false); + emit changeUrl(url_full); + } + else { + widget->setHidden(true); + miniblink->setHidden(false); + emit changeUrl(url_full); + } +} +void MainScreen::startWeChat() { + QString path = QApplication::applicationDirPath(); + QString exe = path + "/app/wxdk/wxdk.exe"; + path.replace("/", "\\"); + ShellExecute(GetDesktopWindow(), L"open", exe.toStdWString().c_str(), L"79c86fb12b36dfa33d1a537c9af100b4c7928a9c", path.toStdWString().c_str(), SW_SHOW); +} +//void MainScreen::resizeEvent(QResizeEvent *event) { +// QWidget::resizeEvent(event); +// //broswer->resize(event->size().width() / 5 * 4, event->size().height()); +// miniblink->resize(event->size().width() / 5 * 4, event->size().height()); +// miniblink->update(); +//} diff --git a/OfficeAssistant_msvc/mainscreen.h b/OfficeAssistant_msvc/mainscreen.h index 5a087f3..af3ac49 100644 --- a/OfficeAssistant_msvc/mainscreen.h +++ b/OfficeAssistant_msvc/mainscreen.h @@ -1,51 +1,51 @@ -// -// Created by HW on 2023/07/27. -// - -#ifndef OFFICEASSISTANT_MAINSCREEN_H -#define OFFICEASSISTANT_MAINSCREEN_H - -#include -#include -#include -#include -#include "wke.h" -#include "qminiblink.h" -class MyThread; -QT_BEGIN_NAMESPACE -namespace Ui { class MainScreen; } -QT_END_NAMESPACE - -class MainScreen : public QWidget { -Q_OBJECT -signals: - void started(); - void ondestroy(); - void changeUrl(QString url); - void initMiniBlink(); -public: - explicit MainScreen(QWidget *parent = nullptr); - ~MainScreen() override; -public slots: - void clickButton1(QString text, QString url); - void firstUrl(QString url); -protected: - //void resizeEvent(QResizeEvent *event) override; -private: - Ui::MainScreen *ui; - QHBoxLayout *layout; - QVBoxLayout *layout_left; - QPushButton *button; - QIcon *icon; - QWidget *broswer; - static bool isInited(); - QWidget *widget; - MyThread *thread; - QMiniBlink *miniblink; - -private slots: - void startWeChat(); -}; - - -#endif //OFFICEASSISTANT_MAINSCREEN_H +// +// Created by HW on 2023/07/27. +// + +#ifndef OFFICEASSISTANT_MAINSCREEN_H +#define OFFICEASSISTANT_MAINSCREEN_H + +#include +#include +#include +#include +#include "wke.h" +#include "qminiblink.h" +class MyThread; +QT_BEGIN_NAMESPACE +namespace Ui { class MainScreen; } +QT_END_NAMESPACE + +class MainScreen : public QWidget { +Q_OBJECT +signals: + void started(); + void ondestroy(); + void changeUrl(QString url); + void initMiniBlink(); +public: + explicit MainScreen(QWidget *parent = nullptr); + ~MainScreen() override; +public slots: + void clickButton1(QString op, QString url); + void firstUrl(QString url); +protected: + //void resizeEvent(QResizeEvent *event) override; +private: + Ui::MainScreen *ui; + QHBoxLayout *layout; + QVBoxLayout *layout_left; + QPushButton *button; + QIcon *icon; + QWidget *broswer; + static bool isInited(); + QWidget *widget; + MyThread *thread; + QMiniBlink *miniblink; + +private slots: + void startWeChat(); +}; + + +#endif //OFFICEASSISTANT_MAINSCREEN_H diff --git a/OfficeAssistant_msvc/mainwindowlayout.cpp b/OfficeAssistant_msvc/mainwindowlayout.cpp index 01241bd..ddd0dce 100644 --- a/OfficeAssistant_msvc/mainwindowlayout.cpp +++ b/OfficeAssistant_msvc/mainwindowlayout.cpp @@ -7,16 +7,18 @@ #include "mainwindowlayout.h" #include "ui_MainWindowLayout.h" #include "mysettingsdialog.h" +#include "netio.h" #include "sqlitehelper.h" MainWindowLayout::MainWindowLayout(QWidget *parent) : QWidget(parent), ui(new Ui::MainWindowLayout) { ui->setupUi(this); setContentsMargins(0, 0, 0, 0); + SQLiteHelper sqlite_helper; + sqlite_helper.update_app(); + sqlite_helper.update_software(); layout=new QVBoxLayout(this); mainWindowLayout = this; - SQLiteHelper sqlite_helper; QList list; - sqlite_helper.get_software(&list); ConfigRequest *configRequest = new ConfigRequest; configResponse = new ConfigResponse; configRequest->sendRequest(configResponse); @@ -54,20 +56,35 @@ void MainWindowLayout::resizeEvent(QResizeEvent *event) { //layout->setAlignment(Qt::AlignmentFlag::AlignHCenter); } -void MainWindowLayout::clickButton(QString text, QString url) { - QString path = QApplication::applicationDirPath(); - path += "/app/startcalc.exe"; - path.replace("/", "\\"); - if (text== QString::fromLocal8Bit("计算器")) { - WinExec(path.toStdString().c_str(), SW_SHOW); +void MainWindowLayout::clickButton(QString op, QString func, QString url,QString path,QString initial_position) { + QString root_path = QApplication::applicationDirPath(); + if(op=="app") + { + if(func=="openwechat") + { + emit clickButton1("openwechat", url); + }else + { + path = root_path + path; + path.replace("/", "\\"); + WinExec(path.toStdString().c_str(), SW_SHOW); + emit clickButton1(op, url); + } } - else if (text == QString::fromLocal8Bit("软件设置")) { - MySettingsDialog *settings = new MySettingsDialog; - settings->exec(); - delete settings; + else if (op == "self") { + if(func=="settings") + { + MySettingsDialog* settings = new MySettingsDialog; + settings->exec(); + delete settings; + } } - else{ - emit clickButton1(text, url); + else if(op=="soft"){ + ShellExecute(GetDesktopWindow(), L"open",path.toStdWString().c_str(),L"",initial_position.toStdWString().c_str(),SW_SHOW); + emit clickButton1(op, url); + }else + { + emit clickButton1(op, url); } } diff --git a/OfficeAssistant_msvc/mainwindowlayout.h b/OfficeAssistant_msvc/mainwindowlayout.h index dc62507..e6cb108 100644 --- a/OfficeAssistant_msvc/mainwindowlayout.h +++ b/OfficeAssistant_msvc/mainwindowlayout.h @@ -1,44 +1,44 @@ - -// -// Created by HW on 2023/07/26. -// - -#ifndef OFFICEASSISTANT_MAINWINDOWLAYOUT_H -#define OFFICEASSISTANT_MAINWINDOWLAYOUT_H - -#include -#include -#include "navbar.h" -#include "mainscreen.h" -#include "netio.h" -class NavBar; -QT_BEGIN_NAMESPACE -namespace Ui { class MainWindowLayout; } -QT_END_NAMESPACE - -class MainWindowLayout : public QWidget { -Q_OBJECT -signals: -void clickButton1(QString text, QString url); -public: - explicit MainWindowLayout(QWidget *parent = nullptr); - - ~MainWindowLayout() override; -public slots: - void clickButton(QString text, QString url); -protected: - void resizeEvent(QResizeEvent *event) override; - //void paintEvent(QPaintEvent *event) override; - -private: - Ui::MainWindowLayout *ui; - QVBoxLayout *layout; - //QList list; - NavBar *navBar; - ButtonStruct *buttons; - MainScreen *mainScreen; - ConfigResponse *configResponse; -}; - - -#endif //OFFICEASSISTANT_MAINWINDOWLAYOUT_H + +// +// Created by HW on 2023/07/26. +// + +#ifndef OFFICEASSISTANT_MAINWINDOWLAYOUT_H +#define OFFICEASSISTANT_MAINWINDOWLAYOUT_H + +#include +#include +#include "navbar.h" +#include "mainscreen.h" +#include "netio.h" +class NavBar; +QT_BEGIN_NAMESPACE +namespace Ui { class MainWindowLayout; } +QT_END_NAMESPACE + +class MainWindowLayout : public QWidget { +Q_OBJECT +signals: +void clickButton1(QString op,QString url); +public: + explicit MainWindowLayout(QWidget *parent = nullptr); + + ~MainWindowLayout() override; +public slots: + void clickButton(QString op, QString func, QString url, QString path, QString initial_position); +protected: + void resizeEvent(QResizeEvent *event) override; + //void paintEvent(QPaintEvent *event) override; + +private: + Ui::MainWindowLayout *ui; + QVBoxLayout *layout; + //QList list; + NavBar *navBar; + ButtonStruct *buttons; + MainScreen *mainScreen; + ConfigResponse *configResponse; +}; + + +#endif //OFFICEASSISTANT_MAINWINDOWLAYOUT_H diff --git a/OfficeAssistant_msvc/mysettingsdialog.cpp b/OfficeAssistant_msvc/mysettingsdialog.cpp index f7c8081..11d08c4 100644 --- a/OfficeAssistant_msvc/mysettingsdialog.cpp +++ b/OfficeAssistant_msvc/mysettingsdialog.cpp @@ -2,6 +2,7 @@ #include #include #include "netio.h" +#include "sqlitehelper.h" #include "config.h" #include "globalvariables.h" MySettingsDialog::MySettingsDialog(QWidget *parent) diff --git a/OfficeAssistant_msvc/navbar.cpp b/OfficeAssistant_msvc/navbar.cpp index 1420b19..d95cdf4 100644 --- a/OfficeAssistant_msvc/navbar.cpp +++ b/OfficeAssistant_msvc/navbar.cpp @@ -12,6 +12,7 @@ #include #include "mainwindowlayout.h" #include "globalvariables.h" +#include "sqlitehelper.h" #ifdef _DEBUG #pragma comment(lib, "Qt5Svgd.lib") #pragma comment(lib, "Qt5Sqld.lib") @@ -48,10 +49,16 @@ NavBar::NavBar(ConfigResponse *configResponse, MainScreen *mainScreen,QWidget *p setStyleSheet(style);*/ //setStyleSheet("margin:0"); setContentsMargins(0, 0, 0, 0); - if (configResponse->succeed&&configResponse->buttons.empty()!=true) { - getLogoFromInternet(configResponse); - } - else { + ConfigResponse config_response; + ConfigRequest config_request; + config_request.sendRequest(&config_response); + SQLiteHelper sqlite_helper; + sqlite_helper.get_software(&buttonStructs, &config_response); + if(config_response.succeed==true) + { + getLogoFromInternet(&config_response); + }else + { getLogoFromLocal(); } layout2 = new QHBoxLayout; @@ -143,68 +150,9 @@ void NavBar::getLogoFromInternet(ConfigResponse *configResponse) { logo = new QImage(); logo->loadFromData(*buffer); buffer->clear(); - for (auto button : configResponse->buttons) { - QUrl url_image(button.img); - QNetworkRequest *request_image = new QNetworkRequest(url_image); - reply = manager->get(*request_image); - QTimer timer; - timer.setInterval(5000); - connect(reply, &QNetworkReply::finished, &eventLoop, &QEventLoop::quit); - connect(&timer, &QTimer::timeout, this, &NavBar::cancelDownload); - eventLoop.exec(); - timer.stop(); - if (!downloadSuccess) { - break; - } - *buffer = reply->readAll(); - - QSvgRenderer *render_image = new QSvgRenderer(*buffer); - - QImage *image = new QImage(200, 200, QImage::Format_ARGB32); - QPainter painter_image(image); - painter_image.setCompositionMode(QPainter::CompositionMode_Clear); // 清除画布 - painter_image.fillRect(rect(), Qt::transparent); // 填充透明色 - painter_image.setCompositionMode(QPainter::CompositionMode_SourceOver); // 恢复默认值 - render_image->render(&painter_image); - buffer->clear(); - reply->close(); - - QUrl url_image_cover(button.img_cover); - QNetworkRequest *request_image_cover = new QNetworkRequest(url_image_cover); - reply = manager->get(*request_image_cover); - timer.setInterval(5000); - connect(reply, &QNetworkReply::finished, &eventLoop, &QEventLoop::quit); - connect(&timer, &QTimer::timeout, this, &NavBar::cancelDownload); - if (!downloadSuccess) { - break; - } - eventLoop.exec(); - *buffer = reply->readAll(); - qDebug() << *buffer; - QSvgRenderer *render_image_cover = new QSvgRenderer(*buffer); - QImage *image_cover = new QImage(200, 200, QImage::Format_ARGB32); - QPainter painter_image_cover(image_cover); - painter_image_cover.setCompositionMode(QPainter::CompositionMode_Clear); // 清除画布 - painter_image_cover.fillRect(rect(), Qt::transparent); // 填充透明色 - painter_image_cover.setCompositionMode(QPainter::CompositionMode_SourceOver); // 恢复默认值 - render_image_cover->render(&painter_image_cover); - buffer->clear(); - reply->close(); - - ButtonStruct buttonStruct; - buttonStruct.image = image; - buttonStruct.image_cover = image_cover; - buttonStruct.text = button.title; - buttonStruct.url = button.url; - buttonStruct.background_color = configResponse->basic.backgroud_color; - buttonStruct.text_color.setNamedColor(configResponse->basic.title_color); - buttonStruct.text_cover_color.setNamedColor(configResponse->basic.title_cover_color); - buttonStructs << buttonStruct; - delete request_image; - delete render_image; - delete request_image_cover; - delete render_image_cover; - } + }else + { + getLogoFromLocal(); } delete manager; manager = nullptr; @@ -242,16 +190,6 @@ void NavBar::getLogoFromLocal() { QString color= obj_root->value("basic").toObject().value("backgroud_color").toString(); qColor.setNamedColor(color); QJsonArray *array = new QJsonArray; - *array = obj_root->value("menu").toArray(); - for (auto obj : *array) { - ButtonStruct buttonStruct; - buttonStruct.text = obj.toObject().value("title").toString(); - buttonStruct.url = QString(BASE_URL)+obj.toObject().value("url").toString(); - buttonStruct.image = new QImage(obj.toObject().value("img").toString()); - buttonStruct.image_cover = new QImage(obj.toObject().value("img_cover").toString()); - buttonStructs << buttonStruct; - } - delete array; } else { QMessageBox::warning(nullptr, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("配置文件损坏")); diff --git a/OfficeAssistant_msvc/netio.cpp b/OfficeAssistant_msvc/netio.cpp index 46f6db2..c40676c 100644 --- a/OfficeAssistant_msvc/netio.cpp +++ b/OfficeAssistant_msvc/netio.cpp @@ -585,10 +585,13 @@ bool SoftwareRequest::sendRequest(QHash *records) QJsonArray array; for(auto record : *records) { - array.append(record.orig_name); + QJsonObject object; + object.insert("orig_name", record.orig_name); + object.insert("path", record.path); + array.append(object); } QJsonObject obj_root = qJsonDocument.object(); - obj_root.insert("orig_names", array); + obj_root.insert("software", array); qJsonDocument.setObject(obj_root); QString url = SOFTWARE_URL; requestInfo.setUrl(url); @@ -626,9 +629,8 @@ bool SoftwareRequest::sendRequest(QHash *records) QJsonObject object = value.toObject(); QString orig_name = object.value("orig_name").toString(); (*records)[orig_name].logo = object.value("img").toString(); - (*records)[orig_name].op = object.value("op").toString(); - (*records)[orig_name].func = object.value("func").toString(); (*records)[orig_name].url = object.value("url").toString(); + (*records)[orig_name].path = object.value("path").toString(); } } else { diff --git a/OfficeAssistant_msvc/netio.h b/OfficeAssistant_msvc/netio.h index b217fc6..ca0904a 100644 --- a/OfficeAssistant_msvc/netio.h +++ b/OfficeAssistant_msvc/netio.h @@ -25,7 +25,7 @@ typedef struct { QString func; QString url; } Button; -typedef struct { +struct ConfigResponse { bool succeed; struct { QString logo_url; @@ -37,7 +37,7 @@ typedef struct { QString title_cover_color; }basic; QList