一点修复

master
Mike Solar 2023-08-01 09:04:53 +08:00
parent 57aea93735
commit ca35018346
12 changed files with 91 additions and 36 deletions

View File

@ -11,7 +11,13 @@ MyButton::MyButton(ButtonStruct &buttonStruct,int width,int height,QList<MyButto
this->url = buttonStruct.url; this->url = buttonStruct.url;
this->logo=buttonStruct.image; this->logo=buttonStruct.image;
this->logo_cover = buttonStruct.image_cover; 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() { 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); QRectF text_rect(text_x,text_y, TEXT_SIZE*text.length()*scale*2,TEXT_SIZE*scale*2);
if(checked){ if(checked){
painter.setPen(QColor("#FFFFFF")); painter.setPen(text_cover_color);
painter.drawImage(logo_rect, *logo_cover); painter.drawImage(logo_rect, *logo_cover);
painter.drawText(text_rect, Qt::AlignCenter, text); painter.drawText(text_rect, Qt::AlignCenter, text);
} }
else { else {
painter.setPen(QColor("#FFFFFF")); painter.setPen(text_color);
painter.drawImage(logo_rect, *logo); painter.drawImage(logo_rect, *logo);
painter.drawText(text_rect, Qt::AlignCenter, text); painter.drawText(text_rect, Qt::AlignCenter, text);
} }
@ -50,12 +56,14 @@ QSize MyButton::sizeHint() const {
void MyButton::enterEvent(QEvent *event) { void MyButton::enterEvent(QEvent *event) {
QWidget::enterEvent(event); QWidget::enterEvent(event);
this->setStyleSheet("background-color:#646464;border:none;"); checked = true;
update();
} }
void MyButton::leaveEvent(QEvent *event) { void MyButton::leaveEvent(QEvent *event) {
QWidget::leaveEvent(event); QWidget::leaveEvent(event);
this->setStyleSheet("background-color:#333332;border:none;"); checked = false;
update();
} }
void MyButton::mousePressEvent(QMouseEvent *event) { void MyButton::mousePressEvent(QMouseEvent *event) {

View File

@ -49,6 +49,8 @@ protected:
void mousePressEvent(QMouseEvent *event) override; void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override;
private: private:
QColor text_color;
QColor text_cover_color;
QList<MyButton *> *buttons; QList<MyButton *> *buttons;
QImage *logo; QImage *logo;
QImage *logo_cover; QImage *logo_cover;

View File

@ -11,5 +11,8 @@ typedef struct taButtonStruct{
QImage *image_cover; QImage *image_cover;
QString text; QString text;
QString url; QString url;
QString background_color;
QColor text_color;
QColor text_cover_color;
}ButtonStruct; }ButtonStruct;
#endif //OFFICEASSISTANT_BUTTONSTRUCT_H #endif //OFFICEASSISTANT_BUTTONSTRUCT_H

View File

@ -9,6 +9,7 @@
#define DEVICE_URL "http://softapi.s103.y01.cn/addons/Kmdsoft/Index/device" #define DEVICE_URL "http://softapi.s103.y01.cn/addons/Kmdsoft/Index/device"
#define BASE_URL "http://softapi.s103.y01.cn/" #define BASE_URL "http://softapi.s103.y01.cn/"
#define DEFAULT_FILE "/config/default_navbar.kmd" #define DEFAULT_FILE "/config/default_navbar.kmd"
#define KEY "3b046cfe4a2a3e62141a4840f2006210a3224e3615312bef6e19f4983921abe0"
#define ADD_AUTOSTART 1 #define ADD_AUTOSTART 1
#define ADD_SHORTCUT 2 #define ADD_SHORTCUT 2

View File

@ -7,4 +7,5 @@
class MainWindowLayout; class MainWindowLayout;
extern double scale; extern double scale;
extern MainWindowLayout *mainWindowLayout; extern MainWindowLayout *mainWindowLayout;
extern QString url_param;
#endif //OFFICEASSISTANT_GLOBALVARIABLES_H #endif //OFFICEASSISTANT_GLOBALVARIABLES_H

View File

@ -13,27 +13,30 @@
#include "globalvariables.h" #include "globalvariables.h"
#include "settingsscreen.h" #include "settingsscreen.h"
#include "mythread.h" #include "mythread.h"
#include "config.h"
MainScreen::MainScreen(QWidget *parent) : MainScreen::MainScreen(QWidget *parent) :
QWidget(parent), ui(new Ui::MainScreen) { QWidget(parent), ui(new Ui::MainScreen) {
ui->setupUi(this); ui->setupUi(this);
setContentsMargins(0, 0, 0, 0); setContentsMargins(0, 0, 0, 0);
button = new QPushButton(this); widget = new QWidget(this);
button->setHidden(true); layout_left = new QVBoxLayout(widget);
button->setStyleSheet("border-style:none;padding:10px;border-radius:5px;background-color:#FFFFFF"); 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 //Plus Math icon by Icons8
QString dir = QApplication::applicationDirPath(); QString dir = QApplication::applicationDirPath();
icon = new QIcon(dir + QString::fromLocal8Bit("/images/add.png")); button->setText(QString::fromLocal8Bit("´ò¿ªÎ¢ÐÅ"));
button->setIcon(*icon);
layout = new QHBoxLayout; layout = new QHBoxLayout;
QSizePolicy sizePolicy(QSizePolicy::Policy::Expanding, QSizePolicy::QSizePolicy::Expanding);
button->setSizePolicy(sizePolicy);
miniblink = new QMiniBlink(this); miniblink = new QMiniBlink(this);
settingScreen = new SettingsScreen; settingScreen = new SettingsScreen;
settingScreen->setMinimumHeight(height());
settingScreen->setHidden(true); settingScreen->setHidden(true);
layout->addWidget(button, 1); layout->addWidget(widget, 1);
layout->addWidget(miniblink, 4); layout->addWidget(miniblink, 4);
layout->addWidget(settingScreen); layout->addWidget(settingScreen);
this->setLayout(layout); this->setLayout(layout);
@ -56,41 +59,45 @@ MainScreen::MainScreen(QWidget *parent) :
} }
MainScreen::~MainScreen() { MainScreen::~MainScreen() {
layout_left->removeWidget(button);
widget->setLayout(nullptr);
delete layout_left;
delete button;
emit ondestroy(); emit ondestroy();
layout->removeWidget(miniblink); layout->removeWidget(miniblink);
layout->removeWidget(settingScreen); layout->removeWidget(settingScreen);
layout->removeWidget(button); layout->removeWidget(widget);
button->setIcon(QIcon(nullptr));
delete miniblink; delete miniblink;
delete settingScreen; delete settingScreen;
delete button; delete widget;
delete icon;
delete layout; delete layout;
delete ui; delete ui;
} }
void MainScreen::firstUrl(QString url) 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) { void MainScreen::clickButton1(QString text, QString url) {
QString url_full = BASE_URL + url + url_param;
if (text == QString::fromLocal8Bit("΢ÐŶ࿪")) { if (text == QString::fromLocal8Bit("΢ÐŶ࿪")) {
button->setHidden(false); widget->setHidden(false);
miniblink->setHidden(false); miniblink->setHidden(false);
settingScreen->setHidden(true); settingScreen->setHidden(true);
emit changeUrl(url); emit changeUrl(url_full);
} }
else if (text == QString::fromLocal8Bit("Èí¼þÉèÖÃ")){ else if (text == QString::fromLocal8Bit("Èí¼þÉèÖÃ")){
miniblink->setHidden(true); miniblink->setHidden(true);
button->setHidden(true); widget->setHidden(true);
settingScreen->setHidden(false); settingScreen->setHidden(false);
} }
else { else {
button->setHidden(true); widget->setHidden(true);
miniblink->setHidden(false); miniblink->setHidden(false);
settingScreen->setHidden(true); settingScreen->setHidden(true);
emit changeUrl(url); emit changeUrl(url_full);
} }
} }
void MainScreen::startWeChat() { void MainScreen::startWeChat() {

View File

@ -40,6 +40,7 @@ private:
QIcon *icon; QIcon *icon;
QWidget *broswer; QWidget *broswer;
static bool isInited(); static bool isInited();
QWidget *widget;
MyThread *thread; MyThread *thread;
QMiniBlink *miniblink; QMiniBlink *miniblink;
SettingsScreen *settingScreen; SettingsScreen *settingScreen;

View File

@ -16,6 +16,7 @@
#else #else
#pragma comment(lib, "Qt5Svg.lib") #pragma comment(lib, "Qt5Svg.lib")
#endif #endif
QString url_param;
NavBar::NavBar(ConfigResponse *configResponse, MainScreen *mainScreen,QWidget *parent) : NavBar::NavBar(ConfigResponse *configResponse, MainScreen *mainScreen,QWidget *parent) :
QWidget(parent), ui(new Ui::NavBar) { QWidget(parent), ui(new Ui::NavBar) {
ui->setupUi(this); ui->setupUi(this);
@ -42,6 +43,7 @@ NavBar::NavBar(ConfigResponse *configResponse, MainScreen *mainScreen,QWidget *p
connect(this, &NavBar::firstUrl, mainScreen, &MainScreen::firstUrl); connect(this, &NavBar::firstUrl, mainScreen, &MainScreen::firstUrl);
emit firstUrl(buttonStructs[0].url); emit firstUrl(buttonStructs[0].url);
} }
} }
NavBar::~NavBar() { NavBar::~NavBar() {
@ -81,6 +83,7 @@ void NavBar::resizeEvent(QResizeEvent *event) {
} }
void NavBar::getLogoFromInternet(ConfigResponse *configResponse) { void NavBar::getLogoFromInternet(ConfigResponse *configResponse) {
qColor.setNamedColor(configResponse->basic.backgroud_color); qColor.setNamedColor(configResponse->basic.backgroud_color);
QUrl url_logo(configResponse->basic.logo_url); QUrl url_logo(configResponse->basic.logo_url);
QNetworkRequest *request_logo = new QNetworkRequest(url_logo); QNetworkRequest *request_logo = new QNetworkRequest(url_logo);
manager = new QNetworkAccessManager; manager = new QNetworkAccessManager;
@ -138,6 +141,9 @@ void NavBar::getLogoFromInternet(ConfigResponse *configResponse) {
buttonStruct.image_cover = image_cover; buttonStruct.image_cover = image_cover;
buttonStruct.text = button.title; buttonStruct.text = button.title;
buttonStruct.url = button.url; 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; buttonStructs << buttonStruct;
delete request_image; delete request_image;
delete render_image; delete render_image;

View File

@ -40,8 +40,6 @@ protected:
private: private:
Ui::NavBar *ui; Ui::NavBar *ui;
QColor qColor; QColor qColor;
QColor text_color;
QColor text_cover_color;
QList<MyButton *> buttons; QList<MyButton *> buttons;
QList<ButtonStruct> buttonStructs; QList<ButtonStruct> buttonStructs;
QByteArray *buffer; QByteArray *buffer;

View File

@ -22,6 +22,7 @@
#include <QApplication> #include <QApplication>
#include <ctime> #include <ctime>
#include <qDebug> #include <qDebug>
#include "globalvariables.h"
#pragma comment(lib, "wbemuuid.lib") #pragma comment(lib, "wbemuuid.lib")
#ifdef _DEBUG #ifdef _DEBUG
#pragma comment(lib, "Qt5Networkd.lib") #pragma comment(lib, "Qt5Networkd.lib")
@ -59,11 +60,11 @@ RequestBodyBase::RequestBodyBase(){
exit(1); exit(1);
} }
product=obj_root.value("product").toString(); 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("配置文件损坏")); QMessageBox::warning(nullptr, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("配置文件损坏"));
exit(1); 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){ if(obj_root.value("release")==QJsonValue::Undefined){
QMessageBox::warning(nullptr, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("配置文件损坏")); QMessageBox::warning(nullptr, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("配置文件损坏"));
exit(1); exit(1);
@ -138,15 +139,39 @@ RequestBodyBase::RequestBodyBase(){
} }
QJsonValue os_json(this->os); QJsonValue os_json(this->os);
QJsonValue os_version_json(this->os_version); 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); QJsonValue requestId_json=QJsonValue(request_id);
QJsonObject obj_root=qJsonDocument.object(); QJsonObject obj_root=qJsonDocument.object();
//插入request_id //插入request_id
obj_root.insert("request_id",requestId_json); obj_root.insert(QString::fromLocal8Bit("request_id"),requestId_json);
obj_root.insert("os", os_json); obj_root.insert(QString::fromLocal8Bit("os"), os_json);
obj_root.insert("os_version", os_version_json); obj_root.insert(QString::fromLocal8Bit("os_version"), os_version_json);
obj_root.insert("sign", sign_json); obj_root.insert(QString::fromLocal8Bit("sign"), sign_json);
qJsonDocument.setObject(obj_root); 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; QNetworkRequest requestInfo;
//HTTP请求 //HTTP请求
//请求头 //请求头
QString url = CONFIG_URL;
requestInfo.setUrl(QUrl(CONFIG_URL)); requestInfo.setUrl(QUrl(CONFIG_URL));
requestInfo.setHeader(QNetworkRequest::ContentTypeHeader,QVariant("application/json")); requestInfo.setHeader(QNetworkRequest::ContentTypeHeader,QVariant("application/json"));
//保存响应的变量 //保存响应的变量
@ -194,8 +220,8 @@ void ConfigRequest::sendRequest(ConfigResponse *configResponse) {
QJsonArray array; QJsonArray array;
array = obj_root.value("data").toObject().value("menu").toArray(); array = obj_root.value("data").toObject().value("menu").toArray();
QJsonObject obj_basic = obj_root.value("basic").toObject(); QJsonObject obj_basic = obj_root.value("data").toObject().value("basic").toObject();
configResponse->basic.logo_url = obj_basic.value("logo_url").toString(); configResponse->basic.logo_url = obj_basic.value("logo").toString();
configResponse->basic.device_id = obj_basic.value("device_id").toString(); configResponse->basic.device_id = obj_basic.value("device_id").toString();
configResponse->basic.dev_id = obj_basic.value("dev_id").toString(); configResponse->basic.dev_id = obj_basic.value("dev_id").toString();
configResponse->basic.token = obj_basic.value("token").toString(); configResponse->basic.token = obj_basic.value("token").toString();

View File

@ -42,7 +42,7 @@ public:
virtual void sendRequest(); virtual void sendRequest();
protected: protected:
QString product; QString product;
QString partner_id; QString parter_id;
QString os; QString os;
QString os_version; QString os_version;
QString device_id; QString device_id;

View File

@ -27,6 +27,8 @@ SettingsScreen::SettingsScreen(QWidget *parent)
QString device_id = QCryptographicHash::hash(getMachineGUID().toUtf8(), QCryptographicHash::Md5).toHex(); QString device_id = QCryptographicHash::hash(getMachineGUID().toUtf8(), QCryptographicHash::Md5).toHex();
QString inf_str = QString::fromLocal8Bit("Ó²¼þID:\n"); QString inf_str = QString::fromLocal8Bit("Ó²¼þID:\n");
inf_str += device_id; inf_str += device_id;
inf_str+= QString::fromLocal8Bit("\n本软件采用了QtQt是The Qt Company的产品采用LGPL协议发布。\n");
inf_str += QString::fromLocal8Bit("本软件采用了MiniBlinkMiniBlink是珠海独角兽科技有限公司的产品采用Apache 2.0协议发布。\n");
information->setText(inf_str); information->setText(inf_str);
layout->addWidget(information); layout->addWidget(information);
} }