先提交下
parent
442feb1283
commit
e3c650dbfd
|
@ -100,10 +100,11 @@
|
|||
<ClInclude Include="buttonstruct.h" />
|
||||
<ClInclude Include="config.h" />
|
||||
<ClInclude Include="globalvariables.h" />
|
||||
<QtMoc Include="qminiblink.h" />
|
||||
<ClInclude Include="wke.h" />
|
||||
<QtMoc Include="mainwindowlayout.h" />
|
||||
<QtMoc Include="mainwindow.h" />
|
||||
<QtMoc Include="mainscreen.h" />
|
||||
<ClInclude Include="mb.h" />
|
||||
<QtMoc Include="MyButton.h" />
|
||||
<QtMoc Include="netio.h" />
|
||||
<QtMoc Include="navbar.h" />
|
||||
|
@ -116,12 +117,14 @@
|
|||
<ClCompile Include="MyButton.cpp" />
|
||||
<ClCompile Include="navbar.cpp" />
|
||||
<ClCompile Include="netio.cpp" />
|
||||
<ClCompile Include="qminiblink.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtUic Include="mainscreen.ui" />
|
||||
<QtUic Include="mainwindow.ui" />
|
||||
<QtUic Include="mainwindowlayout.ui" />
|
||||
<QtUic Include="navbar.ui" />
|
||||
<QtUic Include="qminiblink.ui" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.targets')">
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
<ClInclude Include="globalvariables.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="mb.h">
|
||||
<ClInclude Include="wke.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
|
@ -60,6 +60,9 @@
|
|||
<QtMoc Include="MyButton.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="qminiblink.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
|
@ -83,6 +86,9 @@
|
|||
<ClCompile Include="netio.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="qminiblink.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtUic Include="navbar.ui">
|
||||
|
@ -97,5 +103,8 @@
|
|||
<QtUic Include="mainwindowlayout.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
<QtUic Include="qminiblink.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -5,9 +5,9 @@
|
|||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<QtLastBackgroundBuild>2023-07-29T22:55:59.2650920Z</QtLastBackgroundBuild>
|
||||
<QtLastBackgroundBuild>2023-07-30T09:15:49.0117730Z</QtLastBackgroundBuild>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<QtLastBackgroundBuild>2023-07-29T22:56:00.1037375Z</QtLastBackgroundBuild>
|
||||
<QtLastBackgroundBuild>2023-07-30T09:15:57.3451755Z</QtLastBackgroundBuild>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -9,71 +9,70 @@
|
|||
#include "netio.h"
|
||||
#include <QPixmap>
|
||||
#include <exception>
|
||||
#include <QResizeEvent>
|
||||
|
||||
|
||||
MainScreen::MainScreen(QWidget *parent) :
|
||||
QWidget(parent), ui(new Ui::MainScreen) {
|
||||
ui->setupUi(this);
|
||||
layout = nullptr;
|
||||
layout_left = nullptr;
|
||||
broswer = nullptr;
|
||||
broswer = new QWidget(this);
|
||||
button = new QPushButton(this);
|
||||
button->setHidden(true);
|
||||
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);
|
||||
layout = new QHBoxLayout;
|
||||
layout->addWidget(broswer,4);
|
||||
this->setLayout(layout);
|
||||
//QSizePolicy sizePolicy(QSizePolicy::Policy::Expanding, QSizePolicy::QSizePolicy::Expanding);
|
||||
//broswer->setSizePolicy(sizePolicy);
|
||||
miniblink = new QMiniBlink(broswer,this);
|
||||
miniblink->show();
|
||||
//miniblink->setSizePolicy(sizePolicy);
|
||||
thread = new QThread;
|
||||
miniblink->moveToThread(thread);
|
||||
connect(thread, &QThread::started, miniblink, &QMiniBlink::init);
|
||||
connect(thread, &QThread::finished, thread, &QThread::deleteLater);
|
||||
connect(this, &MainScreen::destroy, miniblink, &QMiniBlink::destroy);
|
||||
connect(this, &MainScreen::changeUrl, miniblink, &QMiniBlink::switchUrl);
|
||||
thread->start();
|
||||
}
|
||||
|
||||
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();
|
||||
if (text == QString::fromLocal8Bit("΢ÐŶ࿪")) {
|
||||
button->setHidden(false);
|
||||
connect(button, &QPushButton::click, this, &MainScreen::startWeChat);
|
||||
if (button->layout() == nullptr) {
|
||||
layout->insertWidget(1, button);
|
||||
}
|
||||
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();
|
||||
if (broswer->layout() == nullptr) {
|
||||
layout->addWidget(broswer, 4);
|
||||
}
|
||||
emit changeUrl(url);
|
||||
|
||||
}
|
||||
else {
|
||||
if (broswer == nullptr) {
|
||||
broswer = new QWidget;
|
||||
if (button->layout() != nullptr) {
|
||||
layout->removeWidget(button);
|
||||
button->setHidden(true);
|
||||
}
|
||||
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();
|
||||
emit changeUrl(url);
|
||||
}
|
||||
}
|
||||
void MainScreen::startWeChat() {
|
||||
ShellExecute(GetDesktopWindow(), L"open", L"wxdk.exe", L"", QApplication::applicationDirPath().toStdWString().c_str(), SW_SHOW);
|
||||
}
|
||||
QString path = QApplication::applicationDirPath();
|
||||
QString exe = path + "/wxdk.exe";
|
||||
ShellExecute(GetDesktopWindow(), L"open", exe.toStdWString().c_str(), L"", path.toStdWString().c_str(), SW_SHOW);
|
||||
}
|
||||
//void MainScreen::resizeEvent(QResizeEvent *event) {
|
||||
// QWidget::resizeEvent(event);
|
||||
// //broswer->resize(event->size().width() / 5 * 4, event->size().height());
|
||||
// miniblink->resize(event->size().width() / 5 * 4, event->size().height());
|
||||
// miniblink->update();
|
||||
//}
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include "mb.h"
|
||||
#include "wke.h"
|
||||
#include "qminiblink.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class MainScreen; }
|
||||
|
@ -17,12 +18,16 @@ QT_END_NAMESPACE
|
|||
|
||||
class MainScreen : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
signals:
|
||||
void destroy();
|
||||
void changeUrl(QString url);
|
||||
public:
|
||||
explicit MainScreen(QWidget *parent = nullptr);
|
||||
~MainScreen() override;
|
||||
public slots:
|
||||
void clickButton1(QString text, QString url);
|
||||
protected:
|
||||
//void resizeEvent(QResizeEvent *event) override;
|
||||
private:
|
||||
Ui::MainScreen *ui;
|
||||
QHBoxLayout *layout;
|
||||
|
@ -30,9 +35,12 @@ private:
|
|||
QPushButton *button;
|
||||
QIcon *icon;
|
||||
QWidget *broswer;
|
||||
mbWebView mbView;
|
||||
static bool isInited();
|
||||
QThread *thread;
|
||||
QMiniBlink *miniblink;
|
||||
private slots:
|
||||
void startWeChat();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -19,10 +19,10 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
setCentralWidget(mainWindowLayout);
|
||||
if(deskRect.width()*scale>1920){
|
||||
resize(1600,1080);
|
||||
this->setMaximumWidth(1600);
|
||||
//this->setMaximumWidth(1600);
|
||||
}else{
|
||||
resize(800, 540);
|
||||
this->setMaximumWidth(800);
|
||||
//this->setMaximumWidth(800);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -17,12 +17,12 @@ MainWindowLayout::MainWindowLayout(QWidget *parent) :
|
|||
configRequest->sendRequest(configResponse);
|
||||
navBar=new NavBar(configResponse,this);
|
||||
mainScreen=new MainScreen();
|
||||
//QSizePolicy sizePolicy(QSizePolicy::Policy::Fixed, QSizePolicy::QSizePolicy::Fixed);
|
||||
//navBar->setSizePolicy(sizePolicy);
|
||||
|
||||
layout->setMargin(0);
|
||||
layout->addWidget(navBar,1);
|
||||
layout->addWidget(mainScreen,4);
|
||||
layout->addWidget(mainScreen,7);
|
||||
setLayout(layout);
|
||||
connect(this, &MainWindowLayout::clickButton1, mainScreen, &MainScreen::clickButton1);
|
||||
}
|
||||
|
||||
MainWindowLayout::~MainWindowLayout() {
|
||||
|
@ -35,13 +35,15 @@ MainWindowLayout::~MainWindowLayout() {
|
|||
|
||||
void MainWindowLayout::resizeEvent(QResizeEvent *event) {
|
||||
QWidget::resizeEvent(event);
|
||||
navBar->resize(navBar->width(),height()/5);
|
||||
navBar->resize(navBar->width(),height()/8);
|
||||
//layout->setAlignment(Qt::AlignmentFlag::AlignHCenter);
|
||||
}
|
||||
|
||||
void MainWindowLayout::clickButton(QString text, QString url) {
|
||||
if (text == "¼ÆËãÆ÷") {
|
||||
ShellExecute(GetDesktopWindow(), L"open", L"startclas.exe", L"", QApplication::applicationDirPath().toStdWString().c_str(), SW_SHOW);
|
||||
QString path = QApplication::applicationDirPath();
|
||||
path += "/startcalc.exe";
|
||||
if (text== QString::fromLocal8Bit("¼ÆËãÆ÷")) {
|
||||
WinExec(path.toStdString().c_str(), SW_SHOW);
|
||||
}
|
||||
else{
|
||||
emit clickButton1(text, url);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -26,16 +26,17 @@ NavBar::NavBar(ConfigResponse *configResponse,QWidget *parent) :
|
|||
else {
|
||||
getLogoFromLocal();
|
||||
}
|
||||
this->setLayout(nullptr);
|
||||
int n = buttonStructs.length();
|
||||
int x = (width() - height()*n) / 2;
|
||||
for (auto buttonStruct : buttonStructs) {
|
||||
MyButton *myButton = new MyButton(buttonStruct, height(), height(), &buttons);
|
||||
MyButton *myButton = new MyButton(buttonStruct, height(), height(), &buttons,this);
|
||||
myButton->setGeometry(x, 0, height(), height());
|
||||
myButton->show();
|
||||
connect(myButton, &MyButton::clicked1, mainWindowLayout, &MainWindowLayout::clickButton);
|
||||
x += height();
|
||||
buttons << myButton;
|
||||
}
|
||||
this->setLayout(nullptr);
|
||||
}
|
||||
|
||||
NavBar::~NavBar() {
|
||||
|
@ -63,7 +64,7 @@ void NavBar::paintEvent(QPaintEvent *event) {
|
|||
|
||||
}
|
||||
void NavBar::resizeEvent(QResizeEvent *event) {
|
||||
QWidget::resizeEvent(event);
|
||||
QWidget::resizeEvent(event);
|
||||
int n = buttonStructs.length();
|
||||
int x = (width() - height()*n) / 2;
|
||||
for(auto button:buttons){
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
#include "qminiblink.h"
|
||||
#pragma comment (lib,"Comctl32.lib")
|
||||
|
||||
QMiniBlink::QMiniBlink(QWidget *broswer,QWidget *parent)
|
||||
: QWidget(parent){
|
||||
this->broswer = broswer;
|
||||
//QSizePolicy sizePolicy(QSizePolicy::Policy::Expanding, QSizePolicy::QSizePolicy::Expanding);
|
||||
//setSizePolicy(sizePolicy);
|
||||
}
|
||||
void QMiniBlink::init() {
|
||||
ui.setupUi(this);
|
||||
wkeInit();
|
||||
wkeView = wkeCreateWebWindow(WKE_WINDOW_TYPE_CONTROL, (HWND)this->winId(), 0, 0, this->width(), this->height());
|
||||
wkeSetNavigationToNewWindowEnable(wkeView, false);
|
||||
wkeShowWindow(wkeView, TRUE);
|
||||
SetParent(wkeGetWindowHandle(wkeView), (HWND)this->winId());
|
||||
SetWindowSubclass((HWND)this->winId(), subClassProc, 0, (DWORD_PTR)this);
|
||||
wkeRunMessageLoop();
|
||||
}
|
||||
QMiniBlink::~QMiniBlink(){}
|
||||
void QMiniBlink::destroy() {
|
||||
wkeDestroyWebView(wkeView);
|
||||
}
|
||||
|
||||
void QMiniBlink::switchUrl(QString url) {
|
||||
wkeLoadURL(wkeView, url.toStdString().c_str());
|
||||
}
|
||||
LRESULT CALLBACK QMiniBlink::subClassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
|
||||
{
|
||||
QMiniBlink *obj = (QMiniBlink *)dwRefData;
|
||||
if (obj == nullptr)
|
||||
return DefSubclassProc(hWnd, uMsg, wParam, lParam);
|
||||
switch (uMsg) {
|
||||
case WM_SIZE:
|
||||
obj->autojustWebViewSize();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return DefSubclassProc(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
void QMiniBlink::autojustWebViewSize()
|
||||
{
|
||||
RECT rect;
|
||||
GetWindowRect((HWND)this->winId(), &rect);
|
||||
wkeMoveWindow(wkeView, 0, 0, rect.right - rect.left, rect.bottom - rect.top);
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include "ui_qminiblink.h"
|
||||
#include "wke.h"
|
||||
#include <Windows.h>
|
||||
#include <CommCtrl.h>
|
||||
|
||||
class QMiniBlink : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QMiniBlink(QWidget *broswer,QWidget *parent = Q_NULLPTR);
|
||||
~QMiniBlink();
|
||||
void init();
|
||||
void destroy();
|
||||
void autojustWebViewSize();
|
||||
public slots:
|
||||
void switchUrl(QString url);
|
||||
private:
|
||||
Ui::QMiniBlink ui;
|
||||
wkeWebView wkeView;
|
||||
QWidget *broswer;
|
||||
static LRESULT CALLBACK subClassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData);
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
<UI version="4.0" >
|
||||
<class>QMiniBlink</class>
|
||||
<widget class="QWidget" name="QMiniBlink" >
|
||||
<property name="objectName" >
|
||||
<string notr="true">QMiniBlink</string>
|
||||
</property>
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>QMiniBlink</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layoutDefault spacing="6" margin="11" />
|
||||
<pixmapfunction></pixmapfunction>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</UI>
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue