一点修复

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->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) {

View File

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

View File

@ -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

View File

@ -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

View File

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

View File

@ -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() {

View File

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

View File

@ -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;

View File

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

View File

@ -22,6 +22,7 @@
#include <QApplication>
#include <ctime>
#include <qDebug>
#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();

View File

@ -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;

View File

@ -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本软件采用了QtQt是The Qt Company的产品采用LGPL协议发布。\n");
inf_str += QString::fromLocal8Bit("本软件采用了MiniBlinkMiniBlink是珠海独角兽科技有限公司的产品采用Apache 2.0协议发布。\n");
information->setText(inf_str);
layout->addWidget(information);
}