2023-07-26 19:48:14 +08:00
|
|
|
|
//
|
|
|
|
|
// Created by HW on 2023/07/26.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
// You may need to build the project (run Qt uic code generator) to get "ui_MainWindowLagout.h" resolved
|
|
|
|
|
|
|
|
|
|
#include "mainwindowlayout.h"
|
|
|
|
|
#include "ui_MainWindowLayout.h"
|
2023-08-01 15:22:48 +08:00
|
|
|
|
#include "mysettingsdialog.h"
|
2023-07-26 19:48:14 +08:00
|
|
|
|
|
|
|
|
|
MainWindowLayout::MainWindowLayout(QWidget *parent) :
|
|
|
|
|
QWidget(parent), ui(new Ui::MainWindowLayout) {
|
|
|
|
|
ui->setupUi(this);
|
2023-08-01 23:51:40 +08:00
|
|
|
|
setContentsMargins(0, 0, 0, 0);
|
2023-07-26 19:48:14 +08:00
|
|
|
|
layout=new QVBoxLayout(this);
|
2023-07-30 13:57:54 +08:00
|
|
|
|
mainWindowLayout = this;
|
2023-07-30 01:06:42 +08:00
|
|
|
|
ConfigRequest *configRequest = new ConfigRequest;
|
2023-07-31 19:06:37 +08:00
|
|
|
|
configResponse = new ConfigResponse;
|
2023-07-30 01:06:42 +08:00
|
|
|
|
configRequest->sendRequest(configResponse);
|
2023-07-31 19:06:37 +08:00
|
|
|
|
mainScreen = new MainScreen(this);
|
|
|
|
|
navBar=new NavBar(configResponse,mainScreen,this);
|
2023-08-01 23:51:40 +08:00
|
|
|
|
navBar->setMinimumHeight(0);
|
|
|
|
|
navBar->setMaximumHeight(this->height() / 8);
|
|
|
|
|
mainScreen->setMinimumHeight(0);
|
|
|
|
|
//navBar->setAttribute(Qt::WA_DeleteOnClose);
|
2023-07-31 19:06:37 +08:00
|
|
|
|
delete configRequest;
|
|
|
|
|
//QSizePolicy sizePolicy(QSizePolicy::Policy::Fixed, QSizePolicy::QSizePolicy::Fixed);
|
|
|
|
|
//navBar->setSizePolicy(sizePolicy);
|
2023-08-01 23:51:40 +08:00
|
|
|
|
//layout->setContentsMargins(0, 0, 0, 0);
|
2023-07-27 13:44:54 +08:00
|
|
|
|
layout->addWidget(navBar,1);
|
2023-07-30 18:57:41 +08:00
|
|
|
|
layout->addWidget(mainScreen,7);
|
2023-08-01 23:51:40 +08:00
|
|
|
|
layout->setMargin(0);
|
2023-07-26 19:48:14 +08:00
|
|
|
|
setLayout(layout);
|
2023-07-31 19:06:37 +08:00
|
|
|
|
connect(this,&MainWindowLayout::clickButton1,mainScreen,&MainScreen::clickButton1);
|
2023-07-26 19:48:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MainWindowLayout::~MainWindowLayout() {
|
2023-07-31 19:06:37 +08:00
|
|
|
|
delete configResponse;
|
|
|
|
|
layout->removeWidget(mainScreen);
|
|
|
|
|
layout->removeWidget(navBar);
|
|
|
|
|
delete mainScreen;
|
2023-07-30 13:57:54 +08:00
|
|
|
|
//delete[] list[0];
|
2023-07-26 19:48:14 +08:00
|
|
|
|
delete navBar;
|
2023-07-31 19:06:37 +08:00
|
|
|
|
delete layout;
|
2023-07-26 19:48:14 +08:00
|
|
|
|
delete ui;
|
|
|
|
|
}
|
2023-07-27 13:44:54 +08:00
|
|
|
|
|
|
|
|
|
void MainWindowLayout::resizeEvent(QResizeEvent *event) {
|
|
|
|
|
QWidget::resizeEvent(event);
|
2023-08-01 23:51:40 +08:00
|
|
|
|
navBar->setMaximumHeight(event->size().height()/8);
|
2023-07-27 13:44:54 +08:00
|
|
|
|
//layout->setAlignment(Qt::AlignmentFlag::AlignHCenter);
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-30 10:26:41 +08:00
|
|
|
|
void MainWindowLayout::clickButton(QString text, QString url) {
|
2023-07-30 18:57:41 +08:00
|
|
|
|
QString path = QApplication::applicationDirPath();
|
2023-08-01 15:22:48 +08:00
|
|
|
|
path += "/app/startcalc.exe";
|
2023-08-02 07:18:10 +08:00
|
|
|
|
path.replace("/", "\\");
|
2023-07-30 18:57:41 +08:00
|
|
|
|
if (text== QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")) {
|
|
|
|
|
WinExec(path.toStdString().c_str(), SW_SHOW);
|
2023-07-30 10:26:41 +08:00
|
|
|
|
}
|
2023-08-01 15:22:48 +08:00
|
|
|
|
else if (text == QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")) {
|
|
|
|
|
MySettingsDialog *settings = new MySettingsDialog;
|
|
|
|
|
settings->exec();
|
|
|
|
|
delete settings;
|
|
|
|
|
}
|
2023-07-30 10:26:41 +08:00
|
|
|
|
else{
|
|
|
|
|
emit clickButton1(text, url);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-27 13:44:54 +08:00
|
|
|
|
|
2023-07-30 10:26:41 +08:00
|
|
|
|
MainWindowLayout *mainWindowLayout;
|