79 lines
2.4 KiB
C++
79 lines
2.4 KiB
C++
//
|
|
// 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 <QPixmap>
|
|
#include <exception>
|
|
#include <QResizeEvent>
|
|
|
|
|
|
MainScreen::MainScreen(QWidget *parent) :
|
|
QWidget(parent), ui(new Ui::MainScreen) {
|
|
ui->setupUi(this);
|
|
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;
|
|
}
|
|
void MainScreen::clickButton1(QString text, QString url) {
|
|
if (text == QString::fromLocal8Bit("΢ÐŶ࿪")) {
|
|
button->setHidden(false);
|
|
connect(button, &QPushButton::click, this, &MainScreen::startWeChat);
|
|
if (button->layout() == nullptr) {
|
|
layout->insertWidget(1, button);
|
|
}
|
|
if (broswer->layout() == nullptr) {
|
|
layout->addWidget(broswer, 4);
|
|
}
|
|
emit changeUrl(url);
|
|
|
|
}
|
|
else {
|
|
if (button->layout() != nullptr) {
|
|
layout->removeWidget(button);
|
|
button->setHidden(true);
|
|
}
|
|
emit changeUrl(url);
|
|
}
|
|
}
|
|
void MainScreen::startWeChat() {
|
|
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();
|
|
//}
|