先提交下
This commit is contained in:
@ -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 == "<EFBFBD>Ŷ") {
|
||||
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("<EFBFBD>Ŷ")) {
|
||||
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();
|
||||
//}
|
||||
|
Reference in New Issue
Block a user