也许完成了?待调试

master
Mike Solar 2023-07-30 10:26:41 +08:00
parent f1ffe592f3
commit 0483fe84f9
16 changed files with 122 additions and 32 deletions

View File

@ -8,6 +8,7 @@ MyButton::MyButton(ButtonStruct &buttonStruct,int width,int height,QList<MyButto
this->width2=width; this->width2=width;
this->height2=height; this->height2=height;
this->text=buttonStruct.text; this->text=buttonStruct.text;
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;*/"); this->setStyleSheet("background-color:#333332;/*border:none;*/");
@ -69,8 +70,6 @@ void MyButton::mouseReleaseEvent(QMouseEvent *event) {
checked=false; checked=false;
else else
checked=true; checked=true;
if (text == "计算器") { emit clicked1(text, url);
}
} }

View File

@ -14,6 +14,9 @@
#include "buttonstruct.h" #include "buttonstruct.h"
class MyButton: public QPushButton{ class MyButton: public QPushButton{
Q_OBJECT
signals:
void clicked1(QString text, QString url);
public: public:
MyButton(ButtonStruct &buttonStruct,int width,int height,QList<MyButton *> *buttons,QWidget *parent=nullptr); MyButton(ButtonStruct &buttonStruct,int width,int height,QList<MyButton *> *buttons,QWidget *parent=nullptr);
~MyButton() override; ~MyButton() override;
@ -51,6 +54,7 @@ private:
QImage *logo_cover; QImage *logo_cover;
QVBoxLayout *layout; QVBoxLayout *layout;
QString text; QString text;
QString url;
int width2; int width2;
int height2; int height2;
int logicalwidth; int logicalwidth;

View File

@ -59,12 +59,12 @@
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile> <ClCompile>
<AdditionalIncludeDirectories>$(ProjectDir)\$(Configuration);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(ProjectDir)\$(Configuration);.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile> <ClCompile>
<AdditionalIncludeDirectories>$(ProjectDir)\$(Configuration);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(ProjectDir)\$(Configuration);.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|Win32'" Label="Configuration"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|Win32'" Label="Configuration">
@ -103,7 +103,8 @@
<QtMoc Include="mainwindowlayout.h" /> <QtMoc Include="mainwindowlayout.h" />
<QtMoc Include="mainwindow.h" /> <QtMoc Include="mainwindow.h" />
<QtMoc Include="mainscreen.h" /> <QtMoc Include="mainscreen.h" />
<ClInclude Include="MyButton.h" /> <ClInclude Include="mb.h" />
<QtMoc Include="MyButton.h" />
<QtMoc Include="netio.h" /> <QtMoc Include="netio.h" />
<QtMoc Include="navbar.h" /> <QtMoc Include="navbar.h" />
</ItemGroup> </ItemGroup>

View File

@ -28,9 +28,6 @@
</QtRcc> </QtRcc>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="MyButton.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="buttonstruct.h"> <ClInclude Include="buttonstruct.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
@ -40,6 +37,9 @@
<ClInclude Include="globalvariables.h"> <ClInclude Include="globalvariables.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="mb.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<QtMoc Include="navbar.h"> <QtMoc Include="navbar.h">
@ -57,6 +57,9 @@
<QtMoc Include="netio.h"> <QtMoc Include="netio.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</QtMoc> </QtMoc>
<QtMoc Include="MyButton.h">
<Filter>Header Files</Filter>
</QtMoc>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="main.cpp"> <ClCompile Include="main.cpp">

View File

@ -5,9 +5,9 @@
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<QtLastBackgroundBuild>2023-07-29T21:43:00.7608665Z</QtLastBackgroundBuild> <QtLastBackgroundBuild>2023-07-29T22:55:59.2650920Z</QtLastBackgroundBuild>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<QtLastBackgroundBuild>2023-07-29T21:43:07.2652440Z</QtLastBackgroundBuild> <QtLastBackgroundBuild>2023-07-29T22:56:00.1037375Z</QtLastBackgroundBuild>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@ -4,9 +4,9 @@
#ifndef OFFICEASSISTANT_CONFIG_H #ifndef OFFICEASSISTANT_CONFIG_H
#define OFFICEASSISTANT_CONFIG_H #define OFFICEASSISTANT_CONFIG_H
#define CONFIG_URL "http://softapi.1.y01.cn/addons/Kmdsoft/Index/config" #define CONFIG_URL "http://apisoft.s103.y01.cn/addons/Kmdsoft/Index/config"
#define OP_URL "http://softapi.1.y01.cn/addons/Kmdsoft/Index/op" #define OP_URL "http://apisoft.s103.y01.cn/addons/Kmdsoft/Index/op"
#define DEVICE_URL "http://softapi.1.y01.cn/addons/Kmdsoft/Index/device" #define DEVICE_URL "http://apisoft.s103.y01.cn/addons/Kmdsoft/Index/device"
#define BASE_URL "http://softapi.1.y01.cn/" #define BASE_URL "http://apisoft.s103.y01.cn/"
#define DEFAULT_FILE "/config/default.kmd" #define DEFAULT_FILE "/config/default.kmd"
#endif //OFFICEASSISTANT_CONFIG_H #endif //OFFICEASSISTANT_CONFIG_H

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -6,14 +6,74 @@
#include "mainscreen.h" #include "mainscreen.h"
#include "ui_MainScreen.h" #include "ui_MainScreen.h"
#include "netio.h"
#include <QPixmap>
#include <exception>
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);
layout = nullptr;
layout_left = nullptr;
broswer = nullptr;
} }
MainScreen::~MainScreen() { MainScreen::~MainScreen() {
delete ui; delete ui;
} }
void MainScreen::clickButton1(QString text, QString url) {
LRESULT *result=new LRESULT;
try {
mbFireWindowsMessage(mbView, mbGetHostHWND(mbView), WM_DESTROY, 0, 0, result);
delete result;
}
catch(std::exception e){
delete result;
}
if (text == "΢ÐŶ࿪") {
if (layout == nullptr) {
layout = new QHBoxLayout;
button = new QPushButton;
button->setStyleSheet("border-style:none;padding:10px;border-radius:5px;background-color:#FFFFFF");
//Plus Math icon by Icons8
QString dir = QApplication::applicationDirPath();
icon = new QIcon(dir + "/images/add.png");
button->setIcon(*icon);
connect(button, &QPushButton::click, this, &MainScreen::startWeChat);
layout->addWidget(button, 1);
if (broswer == nullptr) {
broswer = new QWidget;
}
layout->addWidget(broswer,4);
this->setLayout(layout);
mbView = mbCreateWebWindow(MB_WINDOW_TYPE_CONTROL, (HWND)broswer->winId(), 0, 0, broswer->width(), broswer->height());
mbShowWindow(mbView, TRUE);
mbLoadURL(mbView, url.toStdString().c_str());
mbRunMessageLoop();
mbUninit();
}
else {
mbView = mbCreateWebWindow(MB_WINDOW_TYPE_CONTROL, (HWND)broswer->winId(), 0, 0, broswer->width(), broswer->height());
mbShowWindow(mbView, TRUE);
mbLoadURL(mbView, url.toStdString().c_str());
mbRunMessageLoop();
mbUninit();
}
}
else {
if (broswer == nullptr) {
broswer = new QWidget;
}
setLayout(nullptr);
broswer->setGeometry(0, 0, width(), height());
mbView = mbCreateWebWindow(MB_WINDOW_TYPE_CONTROL, (HWND)broswer->winId(), 0, 0, broswer->width(), broswer->height());
mbShowWindow(mbView, TRUE);
mbLoadURL(mbView, url.toStdString().c_str());
mbRunMessageLoop();
mbUninit();
}
}
void MainScreen::startWeChat() {
ShellExecute(GetDesktopWindow(), L"open", L"wxdk.exe", L"", QApplication::applicationDirPath().toStdWString().c_str(), SW_SHOW);
}

View File

@ -6,7 +6,10 @@
#define OFFICEASSISTANT_MAINSCREEN_H #define OFFICEASSISTANT_MAINSCREEN_H
#include <QWidget> #include <QWidget>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QPushButton>
#include "mb.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
namespace Ui { class MainScreen; } namespace Ui { class MainScreen; }
@ -17,11 +20,19 @@ Q_OBJECT
public: public:
explicit MainScreen(QWidget *parent = nullptr); explicit MainScreen(QWidget *parent = nullptr);
~MainScreen() override; ~MainScreen() override;
public slots:
void clickButton1(QString text, QString url);
private: private:
Ui::MainScreen *ui; Ui::MainScreen *ui;
QHBoxLayout *layout;
QVBoxLayout *layout_left;
QPushButton *button;
QIcon *icon;
QWidget *broswer;
mbWebView mbView;
private slots:
void startWeChat();
}; };

View File

@ -14,7 +14,7 @@ MainWindow::MainWindow(QWidget *parent) :
ui->setupUi(this); ui->setupUi(this);
QDesktopWidget* desktopWidget = QApplication::desktop(); QDesktopWidget* desktopWidget = QApplication::desktop();
QRect deskRect = desktopWidget->availableGeometry(); QRect deskRect = desktopWidget->availableGeometry();
delete desktopWidget; //delete desktopWidget;
mainWindowLayout=new MainWindowLayout(this); mainWindowLayout=new MainWindowLayout(this);
setCentralWidget(mainWindowLayout); setCentralWidget(mainWindowLayout);
if(deskRect.width()*scale>1920){ if(deskRect.width()*scale>1920){

View File

@ -7,7 +7,6 @@
#include "mainwindowlayout.h" #include "mainwindowlayout.h"
#include "ui_MainWindowLayout.h" #include "ui_MainWindowLayout.h"
MainWindowLayout::MainWindowLayout(QWidget *parent) : MainWindowLayout::MainWindowLayout(QWidget *parent) :
QWidget(parent), ui(new Ui::MainWindowLayout) { QWidget(parent), ui(new Ui::MainWindowLayout) {
ui->setupUi(this); ui->setupUi(this);
@ -39,11 +38,13 @@ void MainWindowLayout::resizeEvent(QResizeEvent *event) {
//layout->setAlignment(Qt::AlignmentFlag::AlignHCenter); //layout->setAlignment(Qt::AlignmentFlag::AlignHCenter);
} }
/*void MainWindowLayout::paintEvent(QPaintEvent *event) { void MainWindowLayout::clickButton(QString text, QString url) {
QWidget::paintEvent(event); if (text == "¼ÆËãÆ÷") {
QPainter painter(this); ShellExecute(GetDesktopWindow(), L"open", L"startclas.exe", L"", QApplication::applicationDirPath().toStdWString().c_str(), SW_SHOW);
painter.setRenderHint(QPainter::Antialiasing); }
else{
emit clickButton1(text, url);
}
}
QRectF rect(0, 0, this->width(), this->height()/5); MainWindowLayout *mainWindowLayout;
painter.fillRect(rect, QColor("#333332"));
}*/

View File

@ -11,18 +11,21 @@
#include "navbar.h" #include "navbar.h"
#include "mainscreen.h" #include "mainscreen.h"
#include "netio.h" #include "netio.h"
class NavBar;
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
namespace Ui { class MainWindowLayout; } namespace Ui { class MainWindowLayout; }
QT_END_NAMESPACE QT_END_NAMESPACE
class MainWindowLayout : public QWidget { class MainWindowLayout : public QWidget {
Q_OBJECT Q_OBJECT
signals:
void clickButton1(QString text, QString url);
public: public:
explicit MainWindowLayout(QWidget *parent = nullptr); explicit MainWindowLayout(QWidget *parent = nullptr);
~MainWindowLayout() override; ~MainWindowLayout() override;
public slots:
void clickButton(QString text, QString url);
protected: protected:
void resizeEvent(QResizeEvent *event) override; void resizeEvent(QResizeEvent *event) override;
//void paintEvent(QPaintEvent *event) override; //void paintEvent(QPaintEvent *event) override;

View File

@ -9,6 +9,8 @@
#include "config.h" #include "config.h"
#include <QTimer> #include <QTimer>
#include <QtSvg/QtSvg> #include <QtSvg/QtSvg>
#include "mainwindowlayout.h"
#include "globalvariables.h"
#ifdef _DEBUG #ifdef _DEBUG
#pragma comment(lib, "Qt5Svgd.lib") #pragma comment(lib, "Qt5Svgd.lib")
#else #else
@ -28,6 +30,7 @@ NavBar::NavBar(ConfigResponse *configResponse,QWidget *parent) :
for (auto buttonStruct : buttonStructs) { for (auto buttonStruct : buttonStructs) {
MyButton *myButton = new MyButton(buttonStruct, height(), height(), &buttons); MyButton *myButton = new MyButton(buttonStruct, height(), height(), &buttons);
myButton->setGeometry(x, 0, height(), height()); myButton->setGeometry(x, 0, height(), height());
connect(myButton, &MyButton::clicked1, mainWindowLayout, &MainWindowLayout::clickButton);
x += height(); x += height();
buttons << myButton; buttons << myButton;
} }

View File

@ -15,6 +15,7 @@
#include <QResizeEvent> #include <QResizeEvent>
#include "buttonstruct.h" #include "buttonstruct.h"
#include <QtNetwork/QtNetwork> #include <QtNetwork/QtNetwork>
#include "mainwindowlayout.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE

View File

@ -19,6 +19,7 @@
#include <comutil.h> #include <comutil.h>
#include <iostream> #include <iostream>
#include <QGuiApplication> #include <QGuiApplication>
#include <QApplication>
#include <ctime> #include <ctime>
#pragma comment(lib, "wbemuuid.lib") #pragma comment(lib, "wbemuuid.lib")
#ifdef _DEBUG #ifdef _DEBUG
@ -45,7 +46,8 @@ RequestBodyBase::RequestBodyBase(){
wsprintf(unix_time,L"%ld",std::time(0)); wsprintf(unix_time,L"%ld",std::time(0));
QString request_id=QString::fromWCharArray(unix_time); QString request_id=QString::fromWCharArray(unix_time);
//打开配置文件 //打开配置文件
QFile *infFile=new QFile(".\\config\\information.cfg"); QString dir=QApplication::applicationDirPath();
QFile *infFile=new QFile(dir+"config/information.kmd");
if(!infFile->open(QIODevice::ReadOnly|QIODevice::Text)){ if(!infFile->open(QIODevice::ReadOnly|QIODevice::Text)){
QMessageBox::critical(nullptr,QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("无法打开配置文件")); QMessageBox::critical(nullptr,QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("无法打开配置文件"));
delete infFile; delete infFile;
@ -128,7 +130,7 @@ RequestBodyBase::RequestBodyBase(){
//读取MachineGUID并取MD5作为device_id //读取MachineGUID并取MD5作为device_id
QByteArray hash = QCryptographicHash::hash(getMachineGUID().toUtf8(), QCryptographicHash::Md5); QByteArray hash = QCryptographicHash::hash(getMachineGUID().toUtf8(), QCryptographicHash::Md5);
device_id=hash.toHex(); device_id=hash.toHex();
infFile=new QFile(".\\config\\information.cfg"); infFile=new QFile(".\\config\\information.kmd");
if(!infFile->open(QIODevice::WriteOnly|QIODevice::Text)){ if(!infFile->open(QIODevice::WriteOnly|QIODevice::Text)){
//处理错误 //处理错误
QMessageBox::warning(nullptr, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("无法覆写配置文件")); QMessageBox::warning(nullptr, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("无法覆写配置文件"));