diff --git a/IntegratedPlatform/IntegratedPlatform.pro.user b/IntegratedPlatform/IntegratedPlatform.pro.user index 13aadfc..f4958ed 100644 --- a/IntegratedPlatform/IntegratedPlatform.pro.user +++ b/IntegratedPlatform/IntegratedPlatform.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/untitled/images/大于等于.png b/untitled/images/大于等于.png index dafae93..2aba72f 100644 Binary files a/untitled/images/大于等于.png and b/untitled/images/大于等于.png differ diff --git a/untitled/images/小于等于.png b/untitled/images/小于等于.png index dfa037e..d6654a2 100644 Binary files a/untitled/images/小于等于.png and b/untitled/images/小于等于.png differ diff --git a/untitled/images/添加线圈.png b/untitled/images/添加线圈.png new file mode 100644 index 0000000..fdda419 Binary files /dev/null and b/untitled/images/添加线圈.png differ diff --git a/untitled/images/等于.png b/untitled/images/等于.png new file mode 100644 index 0000000..b25f250 Binary files /dev/null and b/untitled/images/等于.png differ diff --git a/untitled/mainwindow.cpp b/untitled/mainwindow.cpp index cca8cf4..5f35d9f 100644 --- a/untitled/mainwindow.cpp +++ b/untitled/mainwindow.cpp @@ -30,32 +30,43 @@ MainWindow::MainWindow(QWidget *parent) setCentralWidget(m_tabWidget); connect(m_tabWidget, &QTabWidget::currentChanged, this, &MainWindow::onTabChanged); connect(m_tabWidget, &QTabWidget::tabCloseRequested, this, &MainWindow::onCloseTab); - // 创建菜单和工具栏 - createMenus(); + createMenus();// 创建菜单和工具栏 createToolbars(); } MainWindow::~MainWindow() { - // 标签页和工具栏由Qt自动销毁 } // 创建菜单栏 void MainWindow::createMenus() { + // 设置菜单栏字体大小 + QFont menuFont = menuBar()->font(); + menuFont.setPointSize(15); // 菜单栏文字大小 + menuBar()->setFont(menuFont); + // 创建文件菜单 QMenu *fileMenu = menuBar()->addMenu("文件"); QMenu *editMenu = menuBar()->addMenu("操作"); + // 设置菜单项字体大小(适用于所有子菜单) + QFont itemFont = fileMenu->font(); + itemFont.setPointSize(12); // 菜单项文字大小 + fileMenu->setFont(itemFont); + editMenu->setFont(itemFont); + // 新建HMI动作 QAction *newHmiAction = new QAction("新建HMI(&H)", this); newHmiAction->setShortcut(tr("Ctrl+H")); + newHmiAction->setFont(itemFont); // 设置动作文字大小 connect(newHmiAction, &QAction::triggered, this, &MainWindow::onNewHMI); fileMenu->addAction(newHmiAction); // 新建PLC动作 QAction *newPlcAction = new QAction("新建PLC(&P)", this); newPlcAction->setShortcut(tr("Ctrl+P")); + newPlcAction->setFont(itemFont); connect(newPlcAction, &QAction::triggered, this, &MainWindow::onNewPLC); fileMenu->addAction(newPlcAction); @@ -63,6 +74,7 @@ void MainWindow::createMenus() m_openAction = new QAction("打开(&O)", this); m_openAction->setShortcut(QKeySequence::Open); m_openAction->setStatusTip("打开现有文档"); + m_openAction->setFont(itemFont); connect(m_openAction, &QAction::triggered, this, &MainWindow::onOpen); fileMenu->addAction(m_openAction); @@ -70,6 +82,7 @@ void MainWindow::createMenus() m_saveAction = new QAction("保存(&S)", this); m_saveAction->setShortcut(QKeySequence::Save); m_saveAction->setStatusTip("保存当前文档"); + m_saveAction->setFont(itemFont); connect(m_saveAction, &QAction::triggered, this, &MainWindow::onSave); fileMenu->addAction(m_saveAction); @@ -77,23 +90,25 @@ void MainWindow::createMenus() m_saveAsAction = new QAction("另存为(&A)", this); m_saveAsAction->setShortcut(QKeySequence::SaveAs); m_saveAsAction->setStatusTip("将文档另存为"); + m_saveAsAction->setFont(itemFont); connect(m_saveAsAction, &QAction::triggered, this, &MainWindow::onSaveAs); fileMenu->addAction(m_saveAsAction); // 操作菜单 - 添加复制、粘贴、删除功能 QAction *copyAction = new QAction("复制(&C)", this); - copyAction->setShortcut(QKeySequence::Copy); // 标准复制快捷键 Ctrl+C + copyAction->setShortcut(QKeySequence::Copy); copyAction->setStatusTip("复制选中的项目"); + copyAction->setFont(itemFont); connect(copyAction, &QAction::triggered, this, [this]() { - // 获取当前活动的HMI文档 if (auto hmiDoc = dynamic_cast(m_tabWidget->currentWidget())) { hmiDoc->copySelectedItems(); } }); QAction *pasteAction = new QAction("粘贴(&V)", this); - pasteAction->setShortcut(QKeySequence::Paste); // 标准粘贴快捷键 Ctrl+V + pasteAction->setShortcut(QKeySequence::Paste); pasteAction->setStatusTip("粘贴复制的项目"); + pasteAction->setFont(itemFont); connect(pasteAction, &QAction::triggered, this, [this]() { if (auto hmiDoc = dynamic_cast(m_tabWidget->currentWidget())) { hmiDoc->pasteItems(); @@ -101,8 +116,9 @@ void MainWindow::createMenus() }); QAction *deleteAction = new QAction("删除(&D)", this); - deleteAction->setShortcut(QKeySequence::Delete); // 删除键 + deleteAction->setShortcut(QKeySequence::Delete); deleteAction->setStatusTip("删除选中的项目"); + deleteAction->setFont(itemFont); connect(deleteAction, &QAction::triggered, this, [this]() { if (auto hmiDoc = dynamic_cast(m_tabWidget->currentWidget())) { hmiDoc->deleteSelectedItems(); @@ -115,13 +131,14 @@ void MainWindow::createMenus() editMenu->addAction(deleteAction); } + // 创建左侧工具栏 void MainWindow::createToolbars() { m_leftToolBar = new QToolBar("绘图工具栏", this); addToolBar(Qt::LeftToolBarArea, m_leftToolBar); m_leftToolBar->setAllowedAreas(Qt::LeftToolBarArea); // 仅允许在左侧 - m_leftToolBar->setFixedWidth(200); + m_leftToolBar->setFixedWidth(230); } // 更新工具栏(根据当前文档类型) @@ -147,8 +164,8 @@ void MainWindow::updateToolBar(BaseDocument *doc) background-color: #f0f0f0; border-radius: 10px; border: 1px solid #ccc; - padding: 10px 12px; - font-size: 18px; + padding: 10px 15px; + font-size: 25px; font-weight: bold; color: #333; } @@ -159,7 +176,7 @@ void MainWindow::updateToolBar(BaseDocument *doc) // 画按钮按钮(支持拖拽) QToolButton *rectBtn = new QToolButton; - rectBtn->setText("按 钮"); + rectBtn->setText("按钮"); rectBtn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); rectBtn->setIcon(QIcon("../two/untitled/images/按钮.png"));//可替换为实际图标 rectBtn->installEventFilter(this); @@ -171,8 +188,8 @@ void MainWindow::updateToolBar(BaseDocument *doc) background-color: #f0f0f0; border-radius: 10px; border: 1px solid #ccc; - padding: 10px 15px; - font-size: 18px; + padding: 10px 28px; + font-size: 25px; font-weight: bold; color: #333; } @@ -186,11 +203,11 @@ void MainWindow::updateToolBar(BaseDocument *doc) { // 常开触点按钮 QToolButton *normallyOpenBtn = new QToolButton; - normallyOpenBtn->setText("常开触点"); + normallyOpenBtn->setText("常开"); normallyOpenBtn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); normallyOpenBtn->setIcon(QIcon("../two/untitled/images/T-常开触点-01.png")); // 替换为实际图标 normallyOpenBtn->installEventFilter(this); - normallyOpenBtn->setProperty("toolType", "常开触点"); + normallyOpenBtn->setProperty("toolType", "常开"); m_leftToolBar->addWidget(normallyOpenBtn); normallyOpenBtn->setStyleSheet(R"( QToolButton { @@ -198,8 +215,8 @@ void MainWindow::updateToolBar(BaseDocument *doc) background-color: #f0f0f0; border-radius: 10px; border: 1px solid #ccc; - padding: 10px 1px; - font-size: 18px; + padding: 10px 28px; + font-size: 25px; font-weight: bold; color: #333; } @@ -210,11 +227,11 @@ void MainWindow::updateToolBar(BaseDocument *doc) // 常闭触点按钮 QToolButton *normallyClosedBtn = new QToolButton; - normallyClosedBtn->setText("常闭触点"); + normallyClosedBtn->setText("常闭"); normallyClosedBtn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); normallyClosedBtn->setIcon(QIcon("../two/untitled/images/T-常闭触点-01-01.png")); // 替换为实际图标 normallyClosedBtn->installEventFilter(this); - normallyClosedBtn->setProperty("toolType", "常闭触点"); + normallyClosedBtn->setProperty("toolType", "常闭"); m_leftToolBar->addWidget(normallyClosedBtn); normallyClosedBtn->setStyleSheet(R"( QToolButton { @@ -222,8 +239,8 @@ void MainWindow::updateToolBar(BaseDocument *doc) background-color: #f0f0f0; border-radius: 10px; border: 1px solid #ccc; - padding: 10px 1px; - font-size: 18px; + padding: 10px 28px; + font-size: 25px; font-weight: bold; color: #333; } @@ -246,8 +263,8 @@ void MainWindow::updateToolBar(BaseDocument *doc) background-color: #f0f0f0; border-radius: 10px; border: 1px solid #ccc; - padding: 10px 20px; - font-size: 18px; + padding: 10px 28px; + font-size: 25px; font-weight: bold; color: #333; } @@ -270,8 +287,8 @@ void MainWindow::updateToolBar(BaseDocument *doc) background-color: #f0f0f0; border-radius: 10px; border: 1px solid #ccc; - padding: 10px 1px; - font-size: 18px; + padding: 10px 2px; + font-size: 25px; font-weight: bold; color: #333; } @@ -294,8 +311,8 @@ void MainWindow::updateToolBar(BaseDocument *doc) background-color: #f0f0f0; border-radius: 10px; border: 1px solid #ccc; - padding: 10px 20px; - font-size: 18px; + padding: 10px 28px; + font-size: 25px; font-weight: bold; color: #333; } @@ -318,8 +335,31 @@ void MainWindow::updateToolBar(BaseDocument *doc) background-color: #f0f0f0; border-radius: 10px; border: 1px solid #ccc; - padding: 10px 1px; - font-size: 18px; + padding: 10px 2px; + font-size: 25px; + font-weight: bold; + color: #333; + } + QToolButton:hover { + background-color: #e0e0e0; + } + )"); + // 等于按钮 + QToolButton *equalBtn = new QToolButton; + equalBtn->setText("等于"); + equalBtn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + equalBtn->setIcon(QIcon("../two/untitled/images/等于.png")); // 替换为实际图标 + equalBtn->installEventFilter(this); + equalBtn->setProperty("toolType", "等于"); + m_leftToolBar->addWidget(equalBtn); + equalBtn->setStyleSheet(R"( + QToolButton { + margin: 2 auto; + background-color: #f0f0f0; + border-radius: 10px; + border: 1px solid #ccc; + padding: 10px 28px; + font-size: 25px; font-weight: bold; color: #333; } @@ -327,12 +367,11 @@ void MainWindow::updateToolBar(BaseDocument *doc) background-color: #e0e0e0; } )"); - // 线圈按钮 QToolButton *coilBtn = new QToolButton; coilBtn->setText("线圈"); coilBtn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - coilBtn->setIcon(QIcon("../two/untitled/images/线-圈-圈.png")); // 替换为实际图标 + coilBtn->setIcon(QIcon("../two/untitled/images/添加线圈.png")); // 替换为实际图标 coilBtn->installEventFilter(this); coilBtn->setProperty("toolType", "小于等于"); m_leftToolBar->addWidget(coilBtn); @@ -342,8 +381,8 @@ void MainWindow::updateToolBar(BaseDocument *doc) background-color: #f0f0f0; border-radius: 10px; border: 1px solid #ccc; - padding: 10px 20px; - font-size: 18px; + padding: 10px 28px; + font-size: 25px; font-weight: bold; color: #333; } diff --git a/untitled/untitled.pro.user b/untitled/untitled.pro.user index 563ea85..cff81f3 100644 --- a/untitled/untitled.pro.user +++ b/untitled/untitled.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId