From 0483fe84f9bb938998b180ed5167d845e59f9aee Mon Sep 17 00:00:00 2001 From: Mike Solar Date: Sun, 30 Jul 2023 10:26:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B9=9F=E8=AE=B8=E5=AE=8C=E6=88=90=E4=BA=86?= =?UTF-8?q?=EF=BC=9F=E5=BE=85=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OfficeAssistant_msvc/MyButton.cpp | 5 +- OfficeAssistant_msvc/MyButton.h | 4 ++ .../OfficeAssistant_msvc.vcxproj | 7 +- .../OfficeAssistant_msvc.vcxproj.filters | 9 ++- .../OfficeAssistant_msvc.vcxproj.user | 4 +- OfficeAssistant_msvc/config.h | 8 +-- OfficeAssistant_msvc/globalvariables.h | 2 + OfficeAssistant_msvc/images/add.png | Bin 0 -> 2780 bytes OfficeAssistant_msvc/mainscreen.cpp | 62 +++++++++++++++++- OfficeAssistant_msvc/mainscreen.h | 17 ++++- OfficeAssistant_msvc/mainwindow.cpp | 2 +- OfficeAssistant_msvc/mainwindowlayout.cpp | 17 ++--- OfficeAssistant_msvc/mainwindowlayout.h | 7 +- OfficeAssistant_msvc/navbar.cpp | 3 + OfficeAssistant_msvc/navbar.h | 1 + OfficeAssistant_msvc/netio.cpp | 6 +- 16 files changed, 122 insertions(+), 32 deletions(-) create mode 100644 OfficeAssistant_msvc/images/add.png diff --git a/OfficeAssistant_msvc/MyButton.cpp b/OfficeAssistant_msvc/MyButton.cpp index e240d87..ed2a854 100644 --- a/OfficeAssistant_msvc/MyButton.cpp +++ b/OfficeAssistant_msvc/MyButton.cpp @@ -8,6 +8,7 @@ MyButton::MyButton(ButtonStruct &buttonStruct,int width,int height,QListwidth2=width; this->height2=height; this->text=buttonStruct.text; + this->url = buttonStruct.url; this->logo=buttonStruct.image; this->logo_cover = buttonStruct.image_cover; this->setStyleSheet("background-color:#333332;/*border:none;*/"); @@ -69,8 +70,6 @@ void MyButton::mouseReleaseEvent(QMouseEvent *event) { checked=false; else checked=true; - if (text == "计算器") { - - } + emit clicked1(text, url); } diff --git a/OfficeAssistant_msvc/MyButton.h b/OfficeAssistant_msvc/MyButton.h index a3ff14d..80f1a7c 100644 --- a/OfficeAssistant_msvc/MyButton.h +++ b/OfficeAssistant_msvc/MyButton.h @@ -14,6 +14,9 @@ #include "buttonstruct.h" class MyButton: public QPushButton{ +Q_OBJECT +signals: + void clicked1(QString text, QString url); public: MyButton(ButtonStruct &buttonStruct,int width,int height,QList *buttons,QWidget *parent=nullptr); ~MyButton() override; @@ -51,6 +54,7 @@ private: QImage *logo_cover; QVBoxLayout *layout; QString text; + QString url; int width2; int height2; int logicalwidth; diff --git a/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj b/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj index 922bfad..c3651fd 100644 --- a/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj +++ b/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj @@ -59,12 +59,12 @@ - $(ProjectDir)\$(Configuration);%(AdditionalIncludeDirectories) + $(ProjectDir)\$(Configuration);.\;%(AdditionalIncludeDirectories) - $(ProjectDir)\$(Configuration);%(AdditionalIncludeDirectories) + $(ProjectDir)\$(Configuration);.\;%(AdditionalIncludeDirectories) @@ -103,7 +103,8 @@ - + + diff --git a/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.filters b/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.filters index 7812fde..7ff2528 100644 --- a/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.filters +++ b/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.filters @@ -28,9 +28,6 @@ - - Header Files - Header Files @@ -40,6 +37,9 @@ Header Files + + Header Files + @@ -57,6 +57,9 @@ Header Files + + Header Files + diff --git a/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.user b/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.user index 5160224..d642770 100644 --- a/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.user +++ b/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.user @@ -5,9 +5,9 @@ WindowsLocalDebugger - 2023-07-29T21:43:00.7608665Z + 2023-07-29T22:55:59.2650920Z - 2023-07-29T21:43:07.2652440Z + 2023-07-29T22:56:00.1037375Z \ No newline at end of file diff --git a/OfficeAssistant_msvc/config.h b/OfficeAssistant_msvc/config.h index 72fedb3..57a8f7e 100644 --- a/OfficeAssistant_msvc/config.h +++ b/OfficeAssistant_msvc/config.h @@ -4,9 +4,9 @@ #ifndef OFFICEASSISTANT_CONFIG_H #define OFFICEASSISTANT_CONFIG_H -#define CONFIG_URL "http://softapi.1.y01.cn/addons/Kmdsoft/Index/config" -#define OP_URL "http://softapi.1.y01.cn/addons/Kmdsoft/Index/op" -#define DEVICE_URL "http://softapi.1.y01.cn/addons/Kmdsoft/Index/device" -#define BASE_URL "http://softapi.1.y01.cn/" +#define CONFIG_URL "http://apisoft.s103.y01.cn/addons/Kmdsoft/Index/config" +#define OP_URL "http://apisoft.s103.y01.cn/addons/Kmdsoft/Index/op" +#define DEVICE_URL "http://apisoft.s103.y01.cn/addons/Kmdsoft/Index/device" +#define BASE_URL "http://apisoft.s103.y01.cn/" #define DEFAULT_FILE "/config/default.kmd" #endif //OFFICEASSISTANT_CONFIG_H diff --git a/OfficeAssistant_msvc/globalvariables.h b/OfficeAssistant_msvc/globalvariables.h index 88a728f..1cff5af 100644 --- a/OfficeAssistant_msvc/globalvariables.h +++ b/OfficeAssistant_msvc/globalvariables.h @@ -4,5 +4,7 @@ #ifndef OFFICEASSISTANT_GLOBALVARIABLES_H #define OFFICEASSISTANT_GLOBALVARIABLES_H +class MainWindowLayout; extern double scale; +extern MainWindowLayout *mainWindowLayout; #endif //OFFICEASSISTANT_GLOBALVARIABLES_H diff --git a/OfficeAssistant_msvc/images/add.png b/OfficeAssistant_msvc/images/add.png new file mode 100644 index 0000000000000000000000000000000000000000..4790ef0e757feeea28710b42e4d505c2384343bd GIT binary patch literal 2780 zcmeHJO>Epm6rPsyla?R>7gRWm+zSQl8LzY1^{8%0vw__ThbUdtfGWZ4cy`y#+T+@j zt`mfaxb=WQs2ox%1QHw&w6~s+NRT)oaY290I>h5haOPYxy8@3jj^cuY68Ha$FuJ~aOv_B z035jG*B9lY`x0RyFsLUQ+(?5+p#eBHl}3~;aS0o|<%f=T`|Ax2`ktemF1px_W_a7L zuEzY->Rg?zE-~BFrjEm7DNzIgmlUQ!Crn7{Xgyw{?CdqtU=Jdf9Bn#t2p8RXI3r>X zONOa4j4>?PhRqn8@c47EfC~kLEo4sUrb!Bu#I)hyqbYZ>*CY#-7Y5GMlcTkzj0i&A zZrA8qhKO6pv~3&V0xA@Ah0v3gP|{QnlOsch3Qt(`qHtYO3lm90#%mQvQ#l*H?-6EMEx#bN|U})9b!}=BqRFo0rxPJ+rY2zH!$+J5W8jx9n-K`#$*P>VxUo zE3dqVKe{6~*Kee^8~1(i7(BXfL<_m~*5=aI@z<|>jNX3!_pvA6zX)n$+m`DW{#^UR z`RU88G5g)|QP%P757&Qw?KeI-x>QD}${y9I`s@Eu@{6g%pFUbzKXLQJ?EhzNcCK>u I#2fGY1v)!3_y7O^ literal 0 HcmV?d00001 diff --git a/OfficeAssistant_msvc/mainscreen.cpp b/OfficeAssistant_msvc/mainscreen.cpp index 0d5db32..0dffaec 100644 --- a/OfficeAssistant_msvc/mainscreen.cpp +++ b/OfficeAssistant_msvc/mainscreen.cpp @@ -6,14 +6,74 @@ #include "mainscreen.h" #include "ui_MainScreen.h" +#include "netio.h" +#include +#include MainScreen::MainScreen(QWidget *parent) : QWidget(parent), ui(new Ui::MainScreen) { ui->setupUi(this); - + layout = nullptr; + layout_left = nullptr; + broswer = nullptr; } MainScreen::~MainScreen() { 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); +} \ No newline at end of file diff --git a/OfficeAssistant_msvc/mainscreen.h b/OfficeAssistant_msvc/mainscreen.h index e1f09f0..5b5b817 100644 --- a/OfficeAssistant_msvc/mainscreen.h +++ b/OfficeAssistant_msvc/mainscreen.h @@ -6,7 +6,10 @@ #define OFFICEASSISTANT_MAINSCREEN_H #include - +#include +#include +#include +#include "mb.h" QT_BEGIN_NAMESPACE namespace Ui { class MainScreen; } @@ -17,11 +20,19 @@ Q_OBJECT public: explicit MainScreen(QWidget *parent = nullptr); - ~MainScreen() override; - +public slots: + void clickButton1(QString text, QString url); private: Ui::MainScreen *ui; + QHBoxLayout *layout; + QVBoxLayout *layout_left; + QPushButton *button; + QIcon *icon; + QWidget *broswer; + mbWebView mbView; +private slots: + void startWeChat(); }; diff --git a/OfficeAssistant_msvc/mainwindow.cpp b/OfficeAssistant_msvc/mainwindow.cpp index 28b8cd7..ef8af04 100644 --- a/OfficeAssistant_msvc/mainwindow.cpp +++ b/OfficeAssistant_msvc/mainwindow.cpp @@ -14,7 +14,7 @@ MainWindow::MainWindow(QWidget *parent) : ui->setupUi(this); QDesktopWidget* desktopWidget = QApplication::desktop(); QRect deskRect = desktopWidget->availableGeometry(); - delete desktopWidget; + //delete desktopWidget; mainWindowLayout=new MainWindowLayout(this); setCentralWidget(mainWindowLayout); if(deskRect.width()*scale>1920){ diff --git a/OfficeAssistant_msvc/mainwindowlayout.cpp b/OfficeAssistant_msvc/mainwindowlayout.cpp index d0ecdfb..455f711 100644 --- a/OfficeAssistant_msvc/mainwindowlayout.cpp +++ b/OfficeAssistant_msvc/mainwindowlayout.cpp @@ -7,7 +7,6 @@ #include "mainwindowlayout.h" #include "ui_MainWindowLayout.h" - MainWindowLayout::MainWindowLayout(QWidget *parent) : QWidget(parent), ui(new Ui::MainWindowLayout) { ui->setupUi(this); @@ -39,11 +38,13 @@ void MainWindowLayout::resizeEvent(QResizeEvent *event) { //layout->setAlignment(Qt::AlignmentFlag::AlignHCenter); } -/*void MainWindowLayout::paintEvent(QPaintEvent *event) { - QWidget::paintEvent(event); - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing); +void MainWindowLayout::clickButton(QString text, QString url) { + if (text == "计算器") { + ShellExecute(GetDesktopWindow(), L"open", L"startclas.exe", L"", QApplication::applicationDirPath().toStdWString().c_str(), SW_SHOW); + } + else{ + emit clickButton1(text, url); + } +} - QRectF rect(0, 0, this->width(), this->height()/5); - painter.fillRect(rect, QColor("#333332")); -}*/ +MainWindowLayout *mainWindowLayout; diff --git a/OfficeAssistant_msvc/mainwindowlayout.h b/OfficeAssistant_msvc/mainwindowlayout.h index 1aec9d6..ff506e9 100644 --- a/OfficeAssistant_msvc/mainwindowlayout.h +++ b/OfficeAssistant_msvc/mainwindowlayout.h @@ -11,18 +11,21 @@ #include "navbar.h" #include "mainscreen.h" #include "netio.h" - +class NavBar; QT_BEGIN_NAMESPACE namespace Ui { class MainWindowLayout; } QT_END_NAMESPACE class MainWindowLayout : public QWidget { Q_OBJECT - +signals: +void clickButton1(QString text, QString url); public: explicit MainWindowLayout(QWidget *parent = nullptr); ~MainWindowLayout() override; +public slots: + void clickButton(QString text, QString url); protected: void resizeEvent(QResizeEvent *event) override; //void paintEvent(QPaintEvent *event) override; diff --git a/OfficeAssistant_msvc/navbar.cpp b/OfficeAssistant_msvc/navbar.cpp index 318f0be..d01f4e6 100644 --- a/OfficeAssistant_msvc/navbar.cpp +++ b/OfficeAssistant_msvc/navbar.cpp @@ -9,6 +9,8 @@ #include "config.h" #include #include +#include "mainwindowlayout.h" +#include "globalvariables.h" #ifdef _DEBUG #pragma comment(lib, "Qt5Svgd.lib") #else @@ -28,6 +30,7 @@ NavBar::NavBar(ConfigResponse *configResponse,QWidget *parent) : for (auto buttonStruct : buttonStructs) { MyButton *myButton = new MyButton(buttonStruct, height(), height(), &buttons); myButton->setGeometry(x, 0, height(), height()); + connect(myButton, &MyButton::clicked1, mainWindowLayout, &MainWindowLayout::clickButton); x += height(); buttons << myButton; } diff --git a/OfficeAssistant_msvc/navbar.h b/OfficeAssistant_msvc/navbar.h index 0119b08..b28e5b7 100644 --- a/OfficeAssistant_msvc/navbar.h +++ b/OfficeAssistant_msvc/navbar.h @@ -15,6 +15,7 @@ #include #include "buttonstruct.h" #include +#include "mainwindowlayout.h" QT_BEGIN_NAMESPACE diff --git a/OfficeAssistant_msvc/netio.cpp b/OfficeAssistant_msvc/netio.cpp index 4ff5cd8..87c5643 100644 --- a/OfficeAssistant_msvc/netio.cpp +++ b/OfficeAssistant_msvc/netio.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #pragma comment(lib, "wbemuuid.lib") #ifdef _DEBUG @@ -45,7 +46,8 @@ RequestBodyBase::RequestBodyBase(){ wsprintf(unix_time,L"%ld",std::time(0)); 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)){ QMessageBox::critical(nullptr,QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("无法打开配置文件")); delete infFile; @@ -128,7 +130,7 @@ RequestBodyBase::RequestBodyBase(){ //读取MachineGUID并取MD5作为device_id QByteArray hash = QCryptographicHash::hash(getMachineGUID().toUtf8(), QCryptographicHash::Md5); device_id=hash.toHex(); - infFile=new QFile(".\\config\\information.cfg"); + infFile=new QFile(".\\config\\information.kmd"); if(!infFile->open(QIODevice::WriteOnly|QIODevice::Text)){ //处理错误 QMessageBox::warning(nullptr, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("无法覆写配置文件"));