diff --git a/OfficeAssistant_msvc/OfficeAssistant_msvc.qrc b/OfficeAssistant_msvc/OfficeAssistant_msvc.qrc
index c6fd62d..f4afed3 100644
--- a/OfficeAssistant_msvc/OfficeAssistant_msvc.qrc
+++ b/OfficeAssistant_msvc/OfficeAssistant_msvc.qrc
@@ -1,4 +1,3 @@
-
-
+
diff --git a/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj b/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj
index 654475d..d599502 100644
--- a/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj
+++ b/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj
@@ -102,6 +102,7 @@
+
@@ -129,6 +130,12 @@
+
+
+
+
+
+
diff --git a/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.filters b/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.filters
index 90781a1..07c050c 100644
--- a/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.filters
+++ b/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.filters
@@ -40,6 +40,9 @@
Header Files
+
+ Header Files
+
@@ -116,4 +119,14 @@
Form Files
+
+
+ Resource Files
+
+
+
+
+ Resource Files
+
+
\ No newline at end of file
diff --git a/OfficeAssistant_msvc/config.h b/OfficeAssistant_msvc/config.h
index 95430e3..5fdd6e9 100644
--- a/OfficeAssistant_msvc/config.h
+++ b/OfficeAssistant_msvc/config.h
@@ -4,13 +4,18 @@
#ifndef OFFICEASSISTANT_CONFIG_H
#define OFFICEASSISTANT_CONFIG_H
-#define CONFIG_URL "http://softapi.s103.y01.cn/addons/Kmdsoft/Index/config"
-#define OP_URL "http://softapi.s103.y01.cn/addons/Kmdsoft/Index/op"
-#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 CONFIG_URL "http://softapi.s103.y01.cn/addons/Kmdsoft/Index/config" //获取导航栏信息的地址
+#define OP_URL "http://softapi.s103.y01.cn/addons/Kmdsoft/Index/op" //上传是否设置开机启动、是否建立桌面快捷方式的地址
+#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" //Key
+#define NAME "办公助手" //中文名
+#define LOGO_TITLEBAR "/icon/logo_navbar.png" //标题栏图标
+#define ENG_NAME "OfficeAssistant" //英文名
+#define LENG_NAME L"OfficeAssistant" //英文名(宽字符)
#define ADD_AUTOSTART 1
#define ADD_SHORTCUT 2
+#define VERSION "1.0.0" //软件版本
+#define RELEASE "20230801" //Release
#endif //OFFICEASSISTANT_CONFIG_H
diff --git a/OfficeAssistant_msvc/icon/wechat.ico b/OfficeAssistant_msvc/icon/wechat.ico
new file mode 100644
index 0000000..59e8ef8
Binary files /dev/null and b/OfficeAssistant_msvc/icon/wechat.ico differ
diff --git a/OfficeAssistant_msvc/logo.aps b/OfficeAssistant_msvc/logo.aps
new file mode 100644
index 0000000..0d23131
Binary files /dev/null and b/OfficeAssistant_msvc/logo.aps differ
diff --git a/OfficeAssistant_msvc/logo.rc b/OfficeAssistant_msvc/logo.rc
new file mode 100644
index 0000000..eddaf8d
Binary files /dev/null and b/OfficeAssistant_msvc/logo.rc differ
diff --git a/OfficeAssistant_msvc/mainscreen.cpp b/OfficeAssistant_msvc/mainscreen.cpp
index b296a86..099f63f 100644
--- a/OfficeAssistant_msvc/mainscreen.cpp
+++ b/OfficeAssistant_msvc/mainscreen.cpp
@@ -24,12 +24,17 @@ MainScreen::MainScreen(QWidget *parent) :
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");
+ 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);
diff --git a/OfficeAssistant_msvc/mainwindow.cpp b/OfficeAssistant_msvc/mainwindow.cpp
index 9211661..1689572 100644
--- a/OfficeAssistant_msvc/mainwindow.cpp
+++ b/OfficeAssistant_msvc/mainwindow.cpp
@@ -6,23 +6,27 @@
#include "mainwindow.h"
#include "ui_MainWindow.h"
-
-
-
+#include "config.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent), ui(new Ui::MainWindow) {
ui->setupUi(this);
- QDesktopWidget* desktopWidget = QApplication::desktop();
+ QDesktopWidget* desktopWidget = QApplication::desktop();
QRect deskRect = desktopWidget->availableGeometry();
- //delete desktopWidget;
+ resize(deskRect.width()*0.8, deskRect.height()*0.8);
+ setWindowState(Qt::WindowMaximized);
mainWindowLayout=new MainWindowLayout(this);
setCentralWidget(mainWindowLayout);
- setWindowState(Qt::WindowMaximized);
+ setWindowTitle(QString::fromLocal8Bit(NAME));
+ QString path = QApplication::applicationDirPath();
+ path += LOGO_TITLEBAR;
+ icon = new QIcon(path);
+ setWindowIcon(*icon);
}
MainWindow::~MainWindow() {
+ delete icon;
this->setCentralWidget(nullptr);
delete mainWindowLayout;
delete ui;
diff --git a/OfficeAssistant_msvc/mainwindow.h b/OfficeAssistant_msvc/mainwindow.h
index 2e0eef1..fae4151 100644
--- a/OfficeAssistant_msvc/mainwindow.h
+++ b/OfficeAssistant_msvc/mainwindow.h
@@ -8,6 +8,8 @@
#include
#include
#include "mainwindowlayout.h"
+#include
+
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
@@ -22,6 +24,7 @@ public:
private:
Ui::MainWindow *ui;
+ QIcon *icon;
QVBoxLayout *layout;
MainWindowLayout *mainWindowLayout;
};
diff --git a/OfficeAssistant_msvc/mainwindowlayout.cpp b/OfficeAssistant_msvc/mainwindowlayout.cpp
index 0ceb15e..ceb9dfe 100644
--- a/OfficeAssistant_msvc/mainwindowlayout.cpp
+++ b/OfficeAssistant_msvc/mainwindowlayout.cpp
@@ -11,6 +11,7 @@
MainWindowLayout::MainWindowLayout(QWidget *parent) :
QWidget(parent), ui(new Ui::MainWindowLayout) {
ui->setupUi(this);
+ setContentsMargins(0, 0, 0, 0);
layout=new QVBoxLayout(this);
mainWindowLayout = this;
ConfigRequest *configRequest = new ConfigRequest;
@@ -18,13 +19,17 @@ MainWindowLayout::MainWindowLayout(QWidget *parent) :
configRequest->sendRequest(configResponse);
mainScreen = new MainScreen(this);
navBar=new NavBar(configResponse,mainScreen,this);
- navBar->setAttribute(Qt::WA_DeleteOnClose);
+ navBar->setMinimumHeight(0);
+ navBar->setMaximumHeight(this->height() / 8);
+ mainScreen->setMinimumHeight(0);
+ //navBar->setAttribute(Qt::WA_DeleteOnClose);
delete configRequest;
//QSizePolicy sizePolicy(QSizePolicy::Policy::Fixed, QSizePolicy::QSizePolicy::Fixed);
//navBar->setSizePolicy(sizePolicy);
- layout->setMargin(0);
+ //layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(navBar,1);
layout->addWidget(mainScreen,7);
+ layout->setMargin(0);
setLayout(layout);
connect(this,&MainWindowLayout::clickButton1,mainScreen,&MainScreen::clickButton1);
}
@@ -42,7 +47,7 @@ MainWindowLayout::~MainWindowLayout() {
void MainWindowLayout::resizeEvent(QResizeEvent *event) {
QWidget::resizeEvent(event);
- navBar->resize(navBar->width(),height()/8);
+ navBar->setMaximumHeight(event->size().height()/8);
//layout->setAlignment(Qt::AlignmentFlag::AlignHCenter);
}
diff --git a/OfficeAssistant_msvc/mysettingsdialog.cpp b/OfficeAssistant_msvc/mysettingsdialog.cpp
index 307afa7..1888e71 100644
--- a/OfficeAssistant_msvc/mysettingsdialog.cpp
+++ b/OfficeAssistant_msvc/mysettingsdialog.cpp
@@ -2,11 +2,13 @@
#include
#include
#include "netio.h"
+#include "config.h"
#include "globalvariables.h"
MySettingsDialog::MySettingsDialog(QWidget *parent)
: QDialog(parent)
{
ui.setupUi(this);
+ setWindowFlags(Qt::WindowCloseButtonHint);
this->setFixedSize(width(), height());
HKEY hRoot = HKEY_CURRENT_USER;
wchar_t *szSubKey = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
@@ -19,10 +21,10 @@ MySettingsDialog::MySettingsDialog(QWidget *parent)
}
QString app = QApplication::applicationFilePath();
app.replace("/", "\\");
- DWORD size=128;
- wchar_t reg[128];
- lRet = RegGetValue(hRoot, szSubKey, L"OfficeAssistant", RRF_RT_ANY, nullptr, reg, &size);
- if (wcscmp(reg,app.toStdWString().c_str())==0) {
+ DWORD size=128+sizeof(wchar_t);
+ char reg[128] = { 0 };
+ lRet = RegQueryValueEx(hKey, L"OfficeAssistant", NULL, NULL,(LPBYTE)reg, &size);
+ if (lRet==0) {
ui.autostart->setChecked(true);
}
copyButton = ui.copy;
@@ -31,6 +33,7 @@ MySettingsDialog::MySettingsDialog(QWidget *parent)
connect(ui.addshortcut, &QPushButton::clicked, this, &MySettingsDialog::createShortcut);
connect(ui.law_button, &QPushButton::clicked, this, &MySettingsDialog::law);
ui.code->setText(QString(QCryptographicHash::hash(getMachineGUID().toUtf8(), QCryptographicHash::Md5).toHex()));
+ ui.version->setText(QString(VERSION) + "-" + QString(RELEASE));
}
MySettingsDialog::~MySettingsDialog()
@@ -53,7 +56,7 @@ void MySettingsDialog::autoStart(int state)
QString app = QApplication::applicationFilePath();
app.replace("/", "\\");
qDebug() << app.toStdWString().c_str();
- lRet = RegSetValueEx(hKey, L"OfficeAssistant", 0, REG_SZ, (BYTE*)app.toStdWString().c_str(), app.length()*sizeof(wchar_t));
+ lRet = RegSetValueEx(hKey, LENG_NAME, 0, REG_SZ, (BYTE*)app.toStdWString().c_str(), app.length()*sizeof(wchar_t));
if (lRet == ERROR_SUCCESS)
{
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("创建开机启动项成功"));
@@ -72,7 +75,7 @@ void MySettingsDialog::autoStart(int state)
return;
}
QString app = QApplication::applicationFilePath();
- lRet = RegDeleteValue(hKey, L"OfficeAssistant");
+ lRet = RegDeleteValue(hKey, LENG_NAME);
if (lRet == ERROR_SUCCESS)
{
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("移除开机启动项成功。"));
@@ -95,7 +98,9 @@ void MySettingsDialog::copyToCLipboard() {
}
void MySettingsDialog::createShortcut() {
QString deskTopPath = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
- deskTopPath = deskTopPath + QString::fromLocal8Bit("/办公助手.lnk");
+ deskTopPath = deskTopPath + QString::fromLocal8Bit("/");
+ deskTopPath = deskTopPath + QString::fromLocal8Bit(NAME);
+ deskTopPath = deskTopPath + QString::fromLocal8Bit(".lnk");
QString srcFile = QApplication::applicationFilePath();
bool succeed=QFile::link(srcFile, deskTopPath);
if (succeed) {
diff --git a/OfficeAssistant_msvc/mysettingsdialog.ui b/OfficeAssistant_msvc/mysettingsdialog.ui
index cef95d5..a9423cf 100644
--- a/OfficeAssistant_msvc/mysettingsdialog.ui
+++ b/OfficeAssistant_msvc/mysettingsdialog.ui
@@ -26,12 +26,51 @@
70
- 70
+ 40
581
- 381
+ 461
+ -
+
+
+
+ 0
+ 1
+
+
+
+ 鐗堟湰淇℃伅
+
+
+
+
+ 20
+ 50
+ 108
+ 24
+
+
+
+ 鐗堟湰鍙
+
+
+
+
+
+ 130
+ 50
+ 261
+ 24
+
+
+
+ TextLabel
+
+
+
+
-
@@ -151,6 +190,8 @@
+ gridLayoutWidget
+ hardware
diff --git a/OfficeAssistant_msvc/navbar.cpp b/OfficeAssistant_msvc/navbar.cpp
index 334eec6..181c6a4 100644
--- a/OfficeAssistant_msvc/navbar.cpp
+++ b/OfficeAssistant_msvc/navbar.cpp
@@ -9,6 +9,7 @@
#include "config.h"
#include
#include
+#include
#include "mainwindowlayout.h"
#include "globalvariables.h"
#ifdef _DEBUG
@@ -20,30 +21,50 @@ QString url_param;
NavBar::NavBar(ConfigResponse *configResponse, MainScreen *mainScreen,QWidget *parent) :
QWidget(parent), ui(new Ui::NavBar) {
ui->setupUi(this);
- this->setAttribute(Qt::WA_DeleteOnClose);
+ //this->setAttribute(Qt::WA_DeleteOnClose);
buffer = new QByteArray;
+ /*QString style = "background-color:";
+ style += configResponse->basic.backgroud_color.toUpper();
+ style += ";";
+ setStyleSheet(style);*/
+ //setStyleSheet("margin:0");
+ setContentsMargins(0, 0, 0, 0);
if (configResponse->succeed&&configResponse->menus.empty()!=true) {
getLogoFromInternet(configResponse);
}
else {
getLogoFromLocal();
}
- this->setLayout(nullptr);
- int n = buttonStructs.length();
- int x = (width() - height()*n) / 2;
+ layout2 = new QHBoxLayout;
+ layout_right = new QHBoxLayout;
+ layout_left = new QHBoxLayout;
+ logo_label = new QLabel(this);
+ //*logo = logo->scaled(this->width() / (5 / scale), this->height());
+ logo_label->setScaledContents(true);
+ logo_label->setPixmap(QPixmap::fromImage(*logo));
+ logo_label->setMaximumHeight(parent->height() / 8);
+ layout_left->addWidget(logo_label);
+ layout_left->setAlignment(Qt::AlignCenter);
for (auto buttonStruct : buttonStructs) {
MyButton *myButton = new MyButton(buttonStruct, height(), height(), &buttons,this);
- myButton->setGeometry(x, 0, height(), height());
- myButton->show();
+ myButton->setMaximumHeight(parent->height() / 8);
+ layout_right->addWidget(myButton);
+ //myButton->show();
connect(myButton, &MyButton::clicked1, mainWindowLayout, &MainWindowLayout::clickButton);
- x += height();
buttons << myButton;
}
+ layout_right->setAlignment(Qt::AlignLeft);
if (!buttonStructs.empty()) {
connect(this, &NavBar::firstUrl, mainScreen, &MainScreen::firstUrl);
emit firstUrl(buttonStructs[0].url);
}
-
+ layout2->addLayout(layout_left, 1);
+ layout2->addLayout(layout_right, 4);
+ layout_right->setMargin(0);
+ layout2->setMargin(0);
+ //layout2->setAlignment(Qt::AlignJustify);
+ this->setLayout(layout2);
+ logo_label->show();
}
NavBar::~NavBar() {
@@ -52,8 +73,15 @@ NavBar::~NavBar() {
delete buttonStruct.image_cover;
}
for(auto button : buttons){
+ layout_right->removeWidget(button);
delete button;
}
+ layout2->removeWidget(logo_label);
+ delete logo_label;
+ delete logo;
+ //delete layout_left;
+ delete layout_right;
+ delete layout2;
delete ui;
}
@@ -66,20 +94,14 @@ void NavBar::paintEvent(QPaintEvent *event) {
QRectF rect(0, 0, this->width(), this->height());
painter.fillRect(rect, qColor);
- QRectF rect2(0, 0, this->width()/5, this->height());
- painter.drawImage(rect2, *logo);
-
}
void NavBar::resizeEvent(QResizeEvent *event) {
QWidget::resizeEvent(event);
- int n = buttonStructs.length();
- int x = (width() - height()*n) / 2;
for(auto button:buttons){
- button->setSize(event->size().height(),event->size().height(),event->size().height(),event->size().height());
- button->setGeometry(x, 0, event->size().height(), event->size().height());
- x += event->size().height();
+ button->setMaximumSize(event->size().height(), event->size().height());
button->update();
}
+ logo_label->setMaximumSize(event->size().width() / 5, event->size().height());
}
void NavBar::getLogoFromInternet(ConfigResponse *configResponse) {
qColor.setNamedColor(configResponse->basic.backgroud_color);
@@ -98,10 +120,8 @@ void NavBar::getLogoFromInternet(ConfigResponse *configResponse) {
delete request_logo;
if (downloadSuccess == true) {
*buffer = reply->readAll();
- QSvgRenderer *render_logo = new QSvgRenderer(*buffer);
- logo = new QImage(400, 200, QImage::Format_ARGB32);
- QPainter painter_logo(logo);
- render_logo->render(&painter_logo);
+ logo = new QImage();
+ logo->loadFromData(*buffer);
buffer->clear();
for (auto button : configResponse->menus) {
QUrl url_image(button.img);
diff --git a/OfficeAssistant_msvc/navbar.h b/OfficeAssistant_msvc/navbar.h
index d151b6d..32f3f68 100644
--- a/OfficeAssistant_msvc/navbar.h
+++ b/OfficeAssistant_msvc/navbar.h
@@ -16,6 +16,7 @@
#include "buttonstruct.h"
#include
#include "mainscreen.h"
+#include
#include "mainwindowlayout.h"
@@ -49,10 +50,14 @@ private:
QNetworkReply *reply;
QEventLoop eventLoop;
QImage *logo;
+ QLabel *logo_label;
bool downloadSuccess=true;
void getLogoFromInternet(ConfigResponse *configResponse);
void getLogoFromLocal();
MainScreen *mainScreen;
+ QHBoxLayout *layout_left;
+ QHBoxLayout *layout_right;
+ QHBoxLayout *layout2;
private slots:
void storeToBuffer();
void cancelDownload();
diff --git a/OfficeAssistant_msvc/netio.cpp b/OfficeAssistant_msvc/netio.cpp
index 590327c..d39fe52 100644
--- a/OfficeAssistant_msvc/netio.cpp
+++ b/OfficeAssistant_msvc/netio.cpp
@@ -65,11 +65,6 @@ RequestBodyBase::RequestBodyBase(){
exit(1);
}
parter_id=obj_root.value("parter_id").toString();
- if(obj_root.value("release")==QJsonValue::Undefined){
- QMessageBox::warning(nullptr, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("配置文件损坏"));
- exit(1);
- }
- release=obj_root.value("release").toString();
}else{
//处理错误
QMessageBox::warning(nullptr, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("配置文件损坏"));
@@ -107,6 +102,8 @@ RequestBodyBase::RequestBodyBase(){
default:
os_version="Unknown";
}
+ this->release = RELEASE;
+ this->version = VERSION;
//读取MachineGUID并取MD5作为device_id
QByteArray hash = QCryptographicHash::hash(getMachineGUID().toUtf8(), QCryptographicHash::Md5);
device_id = hash.toHex();
@@ -114,6 +111,10 @@ RequestBodyBase::RequestBodyBase(){
QJsonValue value = device_id;
QJsonObject obj_root = qJsonDocument.object();
obj_root.insert("device_id", value);
+ QJsonValue version_json = this->version;
+ obj_root.insert("version", version_json);
+ QJsonValue release_json = this->release;
+ obj_root.insert("release", release_json);
qJsonDocument.setObject(obj_root);
QJsonValue os_json(this->os);
QJsonValue os_version_json(this->os_version);
diff --git a/OfficeAssistant_msvc/qminiblink.cpp b/OfficeAssistant_msvc/qminiblink.cpp
index 2802e75..45ef1aa 100644
--- a/OfficeAssistant_msvc/qminiblink.cpp
+++ b/OfficeAssistant_msvc/qminiblink.cpp
@@ -15,7 +15,7 @@ void QMiniBlink::init() {
ui.setupUi(this);
wkeInit();
RECT rect;
- GetWindowRect((HWND)this->winId(), &rect);
+ GetWindowRect((HWND)parent->winId(), &rect);
resize(rect.right - rect.left, rect.bottom - rect.top);
this->wkeView = wkeCreateWebWindow(WKE_WINDOW_TYPE_CONTROL, (HWND)this->winId(), 0, 0, rect.right - rect.left, rect.bottom - rect.top);
diff --git a/OfficeAssistant_msvc/resource.h b/OfficeAssistant_msvc/resource.h
new file mode 100644
index 0000000..5bfe071
Binary files /dev/null and b/OfficeAssistant_msvc/resource.h differ
diff --git a/icon/logo_navbar.png b/icon/logo_navbar.png
new file mode 100644
index 0000000..e8c0e4a
Binary files /dev/null and b/icon/logo_navbar.png differ
diff --git a/icon/wechat.ico b/icon/wechat.ico
new file mode 100644
index 0000000..8db0171
Binary files /dev/null and b/icon/wechat.ico differ