From ca3501834648d03fcfe3e06679ceebf85d57cb29 Mon Sep 17 00:00:00 2001 From: Mike Solar Date: Tue, 1 Aug 2023 09:04:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E7=82=B9=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OfficeAssistant_msvc/MyButton.cpp | 18 +++++++--- OfficeAssistant_msvc/MyButton.h | 2 ++ OfficeAssistant_msvc/buttonstruct.h | 3 ++ OfficeAssistant_msvc/config.h | 1 + OfficeAssistant_msvc/globalvariables.h | 1 + OfficeAssistant_msvc/mainscreen.cpp | 45 ++++++++++++++----------- OfficeAssistant_msvc/mainscreen.h | 1 + OfficeAssistant_msvc/navbar.cpp | 6 ++++ OfficeAssistant_msvc/navbar.h | 2 -- OfficeAssistant_msvc/netio.cpp | 44 +++++++++++++++++++----- OfficeAssistant_msvc/netio.h | 2 +- OfficeAssistant_msvc/settingsscreen.cpp | 2 ++ 12 files changed, 91 insertions(+), 36 deletions(-) diff --git a/OfficeAssistant_msvc/MyButton.cpp b/OfficeAssistant_msvc/MyButton.cpp index a860a69..611c0db 100644 --- a/OfficeAssistant_msvc/MyButton.cpp +++ b/OfficeAssistant_msvc/MyButton.cpp @@ -11,7 +11,13 @@ MyButton::MyButton(ButtonStruct &buttonStruct,int width,int height,QListurl = buttonStruct.url; this->logo=buttonStruct.image; this->logo_cover = buttonStruct.image_cover; - this->setStyleSheet("background-color:#333332;/*border:none;*/"); + QString style = "background-color:"; + style += buttonStruct.background_color; + style += ";border:none;"; + this->setStyleSheet(style); + this->text_color = buttonStruct.text_color; + this->text_cover_color = buttonStruct.text_cover_color; + this->checked = false; } MyButton::~MyButton() { @@ -33,12 +39,12 @@ void MyButton::paintEvent(QPaintEvent *e) { QRectF text_rect(text_x,text_y, TEXT_SIZE*text.length()*scale*2,TEXT_SIZE*scale*2); if(checked){ - painter.setPen(QColor("#FFFFFF")); + painter.setPen(text_cover_color); painter.drawImage(logo_rect, *logo_cover); painter.drawText(text_rect, Qt::AlignCenter, text); } else { - painter.setPen(QColor("#FFFFFF")); + painter.setPen(text_color); painter.drawImage(logo_rect, *logo); painter.drawText(text_rect, Qt::AlignCenter, text); } @@ -50,12 +56,14 @@ QSize MyButton::sizeHint() const { void MyButton::enterEvent(QEvent *event) { QWidget::enterEvent(event); - this->setStyleSheet("background-color:#646464;border:none;"); + checked = true; + update(); } void MyButton::leaveEvent(QEvent *event) { QWidget::leaveEvent(event); - this->setStyleSheet("background-color:#333332;border:none;"); + checked = false; + update(); } void MyButton::mousePressEvent(QMouseEvent *event) { diff --git a/OfficeAssistant_msvc/MyButton.h b/OfficeAssistant_msvc/MyButton.h index 80f1a7c..cce91fb 100644 --- a/OfficeAssistant_msvc/MyButton.h +++ b/OfficeAssistant_msvc/MyButton.h @@ -49,6 +49,8 @@ protected: void mousePressEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override; private: + QColor text_color; + QColor text_cover_color; QList *buttons; QImage *logo; QImage *logo_cover; diff --git a/OfficeAssistant_msvc/buttonstruct.h b/OfficeAssistant_msvc/buttonstruct.h index 5299ca5..0b45f0d 100644 --- a/OfficeAssistant_msvc/buttonstruct.h +++ b/OfficeAssistant_msvc/buttonstruct.h @@ -11,5 +11,8 @@ typedef struct taButtonStruct{ QImage *image_cover; QString text; QString url; + QString background_color; + QColor text_color; + QColor text_cover_color; }ButtonStruct; #endif //OFFICEASSISTANT_BUTTONSTRUCT_H diff --git a/OfficeAssistant_msvc/config.h b/OfficeAssistant_msvc/config.h index a20eac7..95430e3 100644 --- a/OfficeAssistant_msvc/config.h +++ b/OfficeAssistant_msvc/config.h @@ -9,6 +9,7 @@ #define DEVICE_URL "http://softapi.s103.y01.cn/addons/Kmdsoft/Index/device" #define BASE_URL "http://softapi.s103.y01.cn/" #define DEFAULT_FILE "/config/default_navbar.kmd" +#define KEY "3b046cfe4a2a3e62141a4840f2006210a3224e3615312bef6e19f4983921abe0" #define ADD_AUTOSTART 1 #define ADD_SHORTCUT 2 diff --git a/OfficeAssistant_msvc/globalvariables.h b/OfficeAssistant_msvc/globalvariables.h index 1cff5af..619b194 100644 --- a/OfficeAssistant_msvc/globalvariables.h +++ b/OfficeAssistant_msvc/globalvariables.h @@ -7,4 +7,5 @@ class MainWindowLayout; extern double scale; extern MainWindowLayout *mainWindowLayout; +extern QString url_param; #endif //OFFICEASSISTANT_GLOBALVARIABLES_H diff --git a/OfficeAssistant_msvc/mainscreen.cpp b/OfficeAssistant_msvc/mainscreen.cpp index 288ca0d..b37abc0 100644 --- a/OfficeAssistant_msvc/mainscreen.cpp +++ b/OfficeAssistant_msvc/mainscreen.cpp @@ -13,27 +13,30 @@ #include "globalvariables.h" #include "settingsscreen.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); - button = new QPushButton(this); - button->setHidden(true); - button->setStyleSheet("border-style:none;padding:10px;border-radius:5px;background-color:#FFFFFF"); + widget = new QWidget(this); + layout_left = new QVBoxLayout(widget); + button = new QPushButton(widget); + layout_left->addStretch(4); + layout_left->addWidget(button,1); + widget->setLayout(layout_left); + widget->setHidden(true); + button->setStyleSheet("border-style:none;padding:10px;border-radius:5px;background-color:#09bb07"); //Plus Math icon by Icons8 QString dir = QApplication::applicationDirPath(); - icon = new QIcon(dir + QString::fromLocal8Bit("/images/add.png")); - button->setIcon(*icon); + button->setText(QString::fromLocal8Bit("打开微信")); layout = new QHBoxLayout; - QSizePolicy sizePolicy(QSizePolicy::Policy::Expanding, QSizePolicy::QSizePolicy::Expanding); - button->setSizePolicy(sizePolicy); miniblink = new QMiniBlink(this); settingScreen = new SettingsScreen; + settingScreen->setMinimumHeight(height()); settingScreen->setHidden(true); - layout->addWidget(button, 1); + layout->addWidget(widget, 1); layout->addWidget(miniblink, 4); layout->addWidget(settingScreen); this->setLayout(layout); @@ -56,41 +59,45 @@ MainScreen::MainScreen(QWidget *parent) : } MainScreen::~MainScreen() { + layout_left->removeWidget(button); + widget->setLayout(nullptr); + delete layout_left; + delete button; emit ondestroy(); layout->removeWidget(miniblink); layout->removeWidget(settingScreen); - layout->removeWidget(button); - button->setIcon(QIcon(nullptr)); + layout->removeWidget(widget); delete miniblink; delete settingScreen; - delete button; - delete icon; + delete widget; delete layout; delete ui; } void MainScreen::firstUrl(QString url) { - emit changeUrl(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("微信多开")) { - button->setHidden(false); + widget->setHidden(false); miniblink->setHidden(false); settingScreen->setHidden(true); - emit changeUrl(url); + emit changeUrl(url_full); } else if (text == QString::fromLocal8Bit("软件设置")){ miniblink->setHidden(true); - button->setHidden(true); + widget->setHidden(true); settingScreen->setHidden(false); } else { - button->setHidden(true); + widget->setHidden(true); miniblink->setHidden(false); settingScreen->setHidden(true); - emit changeUrl(url); + emit changeUrl(url_full); } } void MainScreen::startWeChat() { diff --git a/OfficeAssistant_msvc/mainscreen.h b/OfficeAssistant_msvc/mainscreen.h index 317b7be..7ebf923 100644 --- a/OfficeAssistant_msvc/mainscreen.h +++ b/OfficeAssistant_msvc/mainscreen.h @@ -40,6 +40,7 @@ private: QIcon *icon; QWidget *broswer; static bool isInited(); + QWidget *widget; MyThread *thread; QMiniBlink *miniblink; SettingsScreen *settingScreen; diff --git a/OfficeAssistant_msvc/navbar.cpp b/OfficeAssistant_msvc/navbar.cpp index 3f96beb..334eec6 100644 --- a/OfficeAssistant_msvc/navbar.cpp +++ b/OfficeAssistant_msvc/navbar.cpp @@ -16,6 +16,7 @@ #else #pragma comment(lib, "Qt5Svg.lib") #endif +QString url_param; NavBar::NavBar(ConfigResponse *configResponse, MainScreen *mainScreen,QWidget *parent) : QWidget(parent), ui(new Ui::NavBar) { ui->setupUi(this); @@ -42,6 +43,7 @@ NavBar::NavBar(ConfigResponse *configResponse, MainScreen *mainScreen,QWidget *p connect(this, &NavBar::firstUrl, mainScreen, &MainScreen::firstUrl); emit firstUrl(buttonStructs[0].url); } + } NavBar::~NavBar() { @@ -81,6 +83,7 @@ void NavBar::resizeEvent(QResizeEvent *event) { } void NavBar::getLogoFromInternet(ConfigResponse *configResponse) { qColor.setNamedColor(configResponse->basic.backgroud_color); + QUrl url_logo(configResponse->basic.logo_url); QNetworkRequest *request_logo = new QNetworkRequest(url_logo); manager = new QNetworkAccessManager; @@ -138,6 +141,9 @@ void NavBar::getLogoFromInternet(ConfigResponse *configResponse) { 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; diff --git a/OfficeAssistant_msvc/navbar.h b/OfficeAssistant_msvc/navbar.h index be04d3f..d151b6d 100644 --- a/OfficeAssistant_msvc/navbar.h +++ b/OfficeAssistant_msvc/navbar.h @@ -40,8 +40,6 @@ protected: private: Ui::NavBar *ui; QColor qColor; - QColor text_color; - QColor text_cover_color; QList buttons; QList buttonStructs; QByteArray *buffer; diff --git a/OfficeAssistant_msvc/netio.cpp b/OfficeAssistant_msvc/netio.cpp index 3cd6558..c3ec4ad 100644 --- a/OfficeAssistant_msvc/netio.cpp +++ b/OfficeAssistant_msvc/netio.cpp @@ -22,6 +22,7 @@ #include #include #include +#include "globalvariables.h" #pragma comment(lib, "wbemuuid.lib") #ifdef _DEBUG #pragma comment(lib, "Qt5Networkd.lib") @@ -59,11 +60,11 @@ RequestBodyBase::RequestBodyBase(){ exit(1); } product=obj_root.value("product").toString(); - if(obj_root.value("partner_id")==QJsonValue::Undefined){ + if(obj_root.value("parter_id")==QJsonValue::Undefined){ QMessageBox::warning(nullptr, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("配置文件损坏")); exit(1); } - partner_id=obj_root.value("partner_id").toString(); + parter_id=obj_root.value("parter_id").toString(); if(obj_root.value("release")==QJsonValue::Undefined){ QMessageBox::warning(nullptr, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("配置文件损坏")); exit(1); @@ -138,15 +139,39 @@ RequestBodyBase::RequestBodyBase(){ } QJsonValue os_json(this->os); QJsonValue os_version_json(this->os_version); - QJsonValue sign_json(QString("123456789890")); + QString key_hash = QCryptographicHash::hash(QString(KEY).toUtf8(), QCryptographicHash::Md5).toHex(); + QByteArray request_id_byte = request_id.toUtf8(); + QByteArray sign_byte= QCryptographicHash::hash(key_hash.toUtf8()+request_id_byte, QCryptographicHash::Md5); + sign = sign_byte.toHex(); + QJsonValue sign_json(sign); QJsonValue requestId_json=QJsonValue(request_id); QJsonObject obj_root=qJsonDocument.object(); //插入request_id - obj_root.insert("request_id",requestId_json); - obj_root.insert("os", os_json); - obj_root.insert("os_version", os_version_json); - obj_root.insert("sign", sign_json); + obj_root.insert(QString::fromLocal8Bit("request_id"),requestId_json); + obj_root.insert(QString::fromLocal8Bit("os"), os_json); + obj_root.insert(QString::fromLocal8Bit("os_version"), os_version_json); + obj_root.insert(QString::fromLocal8Bit("sign"), sign_json); qJsonDocument.setObject(obj_root); + url_param = "?"; + url_param += "product="; + url_param += product; + url_param += "&parter_id="; + url_param += parter_id; + url_param += "&os="; + url_param += this->os; + url_param += "&os_version="; + url_param += os_version; + url_param += "&device_id="; + url_param += device_id; + url_param += "&request_id="; + url_param += request_id; + url_param += "&version="; + url_param += version; + url_param += "&release="; + url_param += release; + url_param += "&sign="; + url_param += sign; + qDebug() << url_param; } @@ -157,6 +182,7 @@ void ConfigRequest::sendRequest(ConfigResponse *configResponse) { QNetworkRequest requestInfo; //HTTP请求 //请求头 + QString url = CONFIG_URL; requestInfo.setUrl(QUrl(CONFIG_URL)); requestInfo.setHeader(QNetworkRequest::ContentTypeHeader,QVariant("application/json")); //保存响应的变量 @@ -194,8 +220,8 @@ void ConfigRequest::sendRequest(ConfigResponse *configResponse) { QJsonArray array; array = obj_root.value("data").toObject().value("menu").toArray(); - QJsonObject obj_basic = obj_root.value("basic").toObject(); - configResponse->basic.logo_url = obj_basic.value("logo_url").toString(); + QJsonObject obj_basic = obj_root.value("data").toObject().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(); configResponse->basic.token = obj_basic.value("token").toString(); diff --git a/OfficeAssistant_msvc/netio.h b/OfficeAssistant_msvc/netio.h index 9ebe15c..521d3b3 100644 --- a/OfficeAssistant_msvc/netio.h +++ b/OfficeAssistant_msvc/netio.h @@ -42,7 +42,7 @@ public: virtual void sendRequest(); protected: QString product; - QString partner_id; + QString parter_id; QString os; QString os_version; QString device_id; diff --git a/OfficeAssistant_msvc/settingsscreen.cpp b/OfficeAssistant_msvc/settingsscreen.cpp index 62fd163..6000ef8 100644 --- a/OfficeAssistant_msvc/settingsscreen.cpp +++ b/OfficeAssistant_msvc/settingsscreen.cpp @@ -27,6 +27,8 @@ SettingsScreen::SettingsScreen(QWidget *parent) QString device_id = QCryptographicHash::hash(getMachineGUID().toUtf8(), QCryptographicHash::Md5).toHex(); QString inf_str = QString::fromLocal8Bit("硬件ID:\n"); inf_str += device_id; + inf_str+= QString::fromLocal8Bit("\n本软件采用了Qt,Qt是The Qt Company的产品,采用LGPL协议发布。\n"); + inf_str += QString::fromLocal8Bit("本软件采用了MiniBlink,MiniBlink是珠海独角兽科技有限公司的产品,采用Apache 2.0协议发布。\n"); information->setText(inf_str); layout->addWidget(information); }