OfficeAssistant_Win10/OfficeAssistant_msvc/mainwindowlayout.cpp

90 lines
2.5 KiB
C++
Raw Normal View History

2023-08-18 19:09:55 +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"
#include "mysettingsdialog.h"
#include "netio.h"
#include "sqlitehelper.h"
MainWindowLayout::MainWindowLayout(QWidget *parent) :
QWidget(parent), ui(new Ui::MainWindowLayout) {
ui->setupUi(this);
setContentsMargins(0, 0, 0, 0);
layout=new QVBoxLayout(this);
mainWindowLayout = this;
QList<ButtonStruct> list;
mainScreen = new MainScreen(this);
2023-08-18 19:09:55 +08:00
navBar = new NavBar(mainScreen, this);
emit mainScreen->application_manager->refresh_tab();
navBar->setMinimumHeight(0);
navBar->setMaximumHeight(this->height() / 8);
mainScreen->setMinimumHeight(0);
layout->addWidget(navBar,1);
layout->addWidget(mainScreen,7);
layout->setMargin(0);
setLayout(layout);
connect(this,&MainWindowLayout::clickButton1,mainScreen,&MainScreen::clickButton1);
}
MainWindowLayout::~MainWindowLayout() {
layout->removeWidget(mainScreen);
layout->removeWidget(navBar);
delete mainScreen;
//delete[] list[0];
delete navBar;
delete layout;
delete ui;
}
void MainWindowLayout::resizeEvent(QResizeEvent *event) {
QWidget::resizeEvent(event);
navBar->setMaximumHeight(event->size().height()/8);
//layout->setAlignment(Qt::AlignmentFlag::AlignHCenter);
}
2023-08-18 19:09:55 +08:00
void MainWindowLayout::clickButton(QString orig_name,QString op, QString func, QString url,QString path,QString initial_position) {
SQLiteHelper sqlite_helper;
sqlite_helper.use_software(orig_name);
emit mainScreen->application_manager->refresh();
QString root_path = QApplication::applicationDirPath();
if(op=="app")
{
if(func=="openwechat")
{
emit clickButton1("openwechat", url);
}else
{
path = root_path + path;
path.replace("/", "\\");
2023-08-18 19:09:55 +08:00
ShellExecute(GetDesktopWindow(), L"open", path.toStdWString().c_str(), L"", initial_position.toStdWString().c_str(), SW_SHOW);
emit clickButton1(op, url);
}
}
else if (op == "self") {
if(func=="settings")
{
MySettingsDialog* settings = new MySettingsDialog;
settings->exec();
delete settings;
}
2023-08-13 12:16:22 +08:00
else
{
emit clickButton1(func, url);
}
}
else if(op=="soft"){
2023-09-06 21:22:06 +08:00
path.replace("/", "\\");
initial_position.replace("/", "\\");
WinExec(path.toStdString().c_str(), SW_SHOW);
emit clickButton1(op, url);
}else
{
emit clickButton1(op, url);
}
}
MainWindowLayout *mainWindowLayout;