소스 검색

改进图标图片,新增等于判断

main
email 2 일 전
부모
커밋
4ef29cabc9
7개의 변경된 파일74개의 추가작업 그리고 35개의 파일을 삭제
  1. +1
    -1
      IntegratedPlatform/IntegratedPlatform.pro.user
  2. BIN
      untitled/images/大于等于.png
  3. BIN
      untitled/images/小于等于.png
  4. BIN
      untitled/images/添加线圈.png
  5. BIN
      untitled/images/等于.png
  6. +72
    -33
      untitled/mainwindow.cpp
  7. +1
    -1
      untitled/untitled.pro.user

+ 1
- 1
IntegratedPlatform/IntegratedPlatform.pro.user 파일 보기

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.11.1, 2025-08-07T21:29:05. -->
<!-- Written by QtCreator 4.11.1, 2025-08-08T20:16:09. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>


BIN
untitled/images/大于等于.png 파일 보기

Before After
Width: 200  |  Height: 200  |  Size: 3.4 KiB Width: 200  |  Height: 200  |  Size: 5.8 KiB

BIN
untitled/images/小于等于.png 파일 보기

Before After
Width: 200  |  Height: 200  |  Size: 3.4 KiB Width: 200  |  Height: 200  |  Size: 6.1 KiB

BIN
untitled/images/添加线圈.png 파일 보기

Before After
Width: 200  |  Height: 200  |  Size: 4.8 KiB

BIN
untitled/images/等于.png 파일 보기

Before After
Width: 200  |  Height: 200  |  Size: 2.2 KiB

+ 72
- 33
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<HMIDocument*>(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<HMIDocument*>(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<HMIDocument*>(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;
}


+ 1
- 1
untitled/untitled.pro.user 파일 보기

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.11.1, 2025-08-07T21:30:35. -->
<!-- Written by QtCreator 4.11.1, 2025-08-08T20:16:09. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>


불러오는 중...
취소
저장