// // Created by HW on 2023/07/27. // // You may need to build the project (run Qt uic code generator) to get "ui_MainScreen.h" resolved #include "mainscreen.h" #include "ui_MainScreen.h" #include "netio.h" #include #include #include #include "globalvariables.h" #include "mythread.h" #include "config.h" MainScreen::MainScreen(QWidget *parent) : QWidget(parent), ui(new Ui::MainScreen) { ui->setupUi(this); this->parent = parent; setContentsMargins(0, 0, 0, 0); widget = new QWidget(this); layout_left = new QVBoxLayout(widget); 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;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); application_manager = new ApplicationManager(this); application_manager->setHidden(true); layout->addWidget(application_manager); layout->addWidget(widget, 1); layout->addWidget(miniblink, 4); this->setLayout(layout); layout->setMargin(0); //miniblink->setAttribute(Qt::WA_DeleteOnClose); miniblink->show(); //miniblink->setSizePolicy(sizePolicy); //thread = new MyThread(this,&miniblink); //thread->start(); //miniblink->moveToThread(thread); connect(this, &MainScreen::ondestroy, miniblink, &QMiniBlink::ondestroy); connect(button, &QPushButton::pressed, this, &MainScreen::startWeChat); connect(this, &MainScreen::started, miniblink, &QMiniBlink::init); //connect(miniblink, SIGNAL(finish()), miniblink, SLOT(deleteLater())); //connect(miniblink, SIGNAL(destroyed()), thread, SLOT(quit())); //connect(thread, &QThread::finished, thread, &QThread::deleteLater); while(miniblink==nullptr){} connect(this, &MainScreen::changeUrl, miniblink, &QMiniBlink::switchUrl); emit started(); } MainScreen::~MainScreen() { layout_left->removeWidget(button); widget->setLayout(nullptr); delete layout_left; delete button; emit ondestroy(); layout->removeWidget(application_manager); layout->removeWidget(miniblink); layout->removeWidget(widget); delete application_manager; delete miniblink; delete widget; delete layout; delete ui; } void MainScreen::firstUrl(QString url) { QString url_full; if (url.isEmpty()) { url_full = ""; } else if (url.contains("?")) { url_full = BASE_URL + url + url_param; emit changeUrl(url_full); } else { url_full = BASE_URL + url + "?" + url_param; emit changeUrl(url_full); } } void MainScreen::clickButton1(QString op,QString url) { QString url_full; if (url.isEmpty()) { url_full = ""; } else if (url.contains("?")) { url_full = BASE_URL + url + url_param; emit changeUrl(url_full); } else { url_full = BASE_URL + url + "?" + url_param; emit changeUrl(url_full); } if (op == "openwechat") { OpenWeChatRequest open_wechat_request; QString msg = open_wechat_request.sendRequest(); if(msg!="ok") { QMessageBox::information(this, QString::fromLocal8Bit("提示"), msg); return; } widget->setHidden(false); miniblink->setHidden(false); application_manager->setHidden(true); emit changeUrl(url_full); } else if(op=="app_mgr") { miniblink->setHidden(true); widget->setHidden(true); application_manager->setHidden(false); } else { widget->setHidden(true); miniblink->setHidden(false); application_manager->setHidden(true); emit changeUrl(url_full); } } void MainScreen::startWeChat() { QString path = QApplication::applicationDirPath(); QString exe = path + "/app/wxdk/wxdk.exe"; path.replace("/", "\\"); ShellExecute(GetDesktopWindow(), L"open", exe.toStdWString().c_str(), L"79c86fb12b36dfa33d1a537c9af100b4c7928a9c", 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(); //}