From b23aedc6c7aa0b4927b27a23c7b032ab9b40046c Mon Sep 17 00:00:00 2001 From: tangchao0503 <735056338@qq.com> Date: Wed, 18 Mar 2026 15:56:06 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BE=8E=E5=8C=96ui?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HPPA/Carousel.cpp | 26 +++++++++++ HPPA/HPPA.cpp | 95 ++++++++++++++++++++++++++++++++++------ HPPA/HPPA.h | 1 + HPPA/HPPA.ui | 6 +-- HPPA/LayerTreeModel.cpp | 4 +- HPPA/LayerTreeView.cpp | 13 ++++++ HPPA/TwoMotorControl.cpp | 36 ++++++++++++--- HPPA/about.ui | 13 +++--- HPPA/aboutWindow.cpp | 7 --- HPPA/imageControl.cpp | 4 +- 10 files changed, 164 insertions(+), 41 deletions(-) diff --git a/HPPA/Carousel.cpp b/HPPA/Carousel.cpp index fe1544f..5a9dc85 100644 --- a/HPPA/Carousel.cpp +++ b/HPPA/Carousel.cpp @@ -126,10 +126,27 @@ void MyCarousel::contextMenuEvent(QContextMenuEvent* event) void MyCarousel::showContextMenu(const QPoint& pos) { QMenu menu(this); + menu.setStyleSheet(R"( + QMenu { + background-color: #2a5dec; + color: white; + } + QMenu::item:selected { + background-color: #1a4ddc; + } + QMenu::separator { + height: 1px; + background: white; + } + )"); QAction* startAct = menu.addAction(QString::fromLocal8Bit("开始轮播")); QAction* stopAct = menu.addAction(QString::fromLocal8Bit("停止轮播")); + menu.addSeparator(); + QAction* incAct = menu.addAction("+1"); + QAction* decAct = menu.addAction("-1"); + if (!m_isLocked) startAct->setEnabled(false); @@ -142,6 +159,15 @@ void MyCarousel::showContextMenu(const QPoint& pos) startAutoPlay(); else if (act == stopAct) stopAutoPlay(); + else if (act == incAct) { + m_playInterval += 1000; + m_autoPlayerTimer->setInterval(m_playInterval); + } + else if (act == decAct) { + if (m_playInterval > 1) + m_playInterval -= 1000; + m_autoPlayerTimer->setInterval(m_playInterval); + } } void MyCarousel::startAutoPlay() diff --git a/HPPA/HPPA.cpp b/HPPA/HPPA.cpp index d9e03fb..9ebeb4c 100644 --- a/HPPA/HPPA.cpp +++ b/HPPA/HPPA.cpp @@ -31,7 +31,7 @@ HPPA::HPPA(QWidget* parent) s_instance = this; ui.setupUi(this); - //setWindowFlags(Qt::FramelessWindowHint); + setWindowFlags(Qt::FramelessWindowHint); // register MapLayer* metatype for queued signal/slot across threads qRegisterMetaType("MapLayer*"); @@ -276,8 +276,9 @@ sizePolicy1.setHeightForWidth(graphicsView_delete->sizePolicy().hasHeightForWidt connect(m_layerTreeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(onLayerTreeSelectionChanged(QItemSelection,QItemSelection))); - dock_layers->setWidget(dock_layersWidgetContents); dock_layersWidgetContents->setStyleSheet(qss_DockWidget_contentWidget); + dock_layers->setWidget(tmp(dock_layersWidgetContents)); + //dock_layers->setMinimumWidth(449); //dock_layers->setMaximumWidth(450); @@ -403,11 +404,12 @@ sizePolicy1.setHeightForWidth(graphicsView_delete->sizePolicy().hasHeightForWidt } )"); - dock_hyperimgViewer->setWidget(dock_hyperimgViewerWidgetContents); mPanelMenu->addAction(dock_hyperimgViewer->toggleViewAction()); QWidget* tmp6 = new QWidget(); dock_hyperimgViewer->setTitleBarWidget(tmp6); + dock_hyperimgViewer->setWidget(tmp(dock_hyperimgViewerWidgetContents)); + //轮播看板 m_dock_carousel = new CustomDockWidgetBase(QString::fromLocal8Bit("轮播"), this); m_dock_carousel->setObjectName("mDockCarousel"); @@ -429,8 +431,8 @@ sizePolicy1.setHeightForWidth(graphicsView_delete->sizePolicy().hasHeightForWidt border-top-left-radius: 0px; border-top-right-radius: 0px; - border-bottom-left-radius: 0px; - border-bottom-right-radius: 0px; + border-bottom-left-radius: 10px; + border-bottom-right-radius: 10px; } )"); QGridLayout* gridLayout_carouselContainer = new QGridLayout(carouselContainer); @@ -476,7 +478,7 @@ sizePolicy1.setHeightForWidth(graphicsView_delete->sizePolicy().hasHeightForWidt gridLayout_carouselContainer->addWidget(m_carousel); - m_dock_carousel->setWidget(carouselContainer); + m_dock_carousel->setWidget(tmp(carouselContainer)); //控制看板 ui.mDockWidgetSpectrometer->setTile(QString::fromLocal8Bit("控制")); @@ -484,6 +486,8 @@ sizePolicy1.setHeightForWidth(graphicsView_delete->sizePolicy().hasHeightForWidt initControlTabwidget(); m_tabManager = new TabManager(ui.controlTabWidget, this); + ui.mDockWidgetSpectrometer->setWidget(tmp(ui.dockWidgetContents_4)); + //3D模型看板 ui.mDockWidgetSimulator->setTile(QString::fromLocal8Bit("3D模型")); //ui.mDockWidgetSimulator->show(); @@ -519,7 +523,7 @@ sizePolicy1.setHeightForWidth(graphicsView_delete->sizePolicy().hasHeightForWidt connect(m_view3DModelManager, SIGNAL(created3DModelPlantPhenotype()), this, SLOT(onCreated3DModelPlantPhenotype())); connect(m_view3DModelManager, SIGNAL(created3DModelOneMotor()), this, SLOT(onCreated3DModelOneMotor())); - ui.mDockWidgetSimulator->setWidget(modelWidgetContainer); + ui.mDockWidgetSimulator->setWidget(tmp(modelWidgetContainer)); //看板排版 splitDockWidget(dock_layers, dock_hyperimgViewer, Qt::Horizontal); @@ -779,6 +783,22 @@ void HPPA::initMenubarToolbar() setMenuWidget(topWidget); } +QWidget* HPPA::tmp(QWidget* a) +{ + QWidget* Background = new QWidget(this); + Background->setObjectName("Background"); + QGridLayout* layout_Background = new QGridLayout(Background); + layout_Background->setContentsMargins(0, 0, 0, 0); + Background->setStyleSheet(R"( + QWidget #Background{ + background: #040125; + } + )"); + layout_Background->addWidget(a); + + return Background; +} + void HPPA::initControlTabwidget() { //rgb相机 @@ -1102,6 +1122,29 @@ void HPPA::initPanelToolbar() ui.mWindowsMenu->addMenu(mPanelMenu); ui.mWindowsMenu->addMenu(mToolbarMenu); + mPanelMenu->setStyleSheet(R"( + QMenu { + background-color: #0A1245; /* 菜单背景色 */ + border: 1px solid gray; /* 可选,边框样式 */ + color: white; /* 根据你的背景调整文字颜色 */ + } + QMenu::item:selected { + background-color: rgba(255, 255, 255, 50); /* 选中时的背景色 */ + color: white; /* 选中项字体颜色,可选 */ + } + )"); + mToolbarMenu->setStyleSheet(R"( + QMenu { + background-color: #0A1245; /* 菜单背景色 */ + border: 1px solid gray; /* 可选,边框样式 */ + color: white; /* 根据你的背景调整文字颜色 */ + } + QMenu::item:selected { + background-color: rgba(255, 255, 255, 50); /* 选中时的背景色 */ + color: white; /* 选中项字体颜色,可选 */ + } + )"); + mPanelMenu->addAction(ui.mDockWidgetSpectrometer->toggleViewAction()); mPanelMenu->addAction(ui.mDockWidgetSimulator->toggleViewAction()); @@ -1698,14 +1741,38 @@ void HPPA::onExit() void HPPA::closeEvent(QCloseEvent* event) { - QMessageBox::StandardButton ret; + QMessageBox msgBox(this); + msgBox.setWindowTitle(QString::fromLocal8Bit("退出确认")); + msgBox.setText(QString::fromLocal8Bit("确定要退出程序吗?")); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + msgBox.setDefaultButton(QMessageBox::No); + msgBox.setStyleSheet(R"( + QMessageBox { + background-color: #0D1233; + } + QMessageBox QLabel { + color: #ACCDFF; + font-size: 14px; + } + QPushButton { + background-color: #142D7F; + color: #e6eeff; + border: 1px solid #2f6bff; + border-radius: 6px; + padding: 6px 20px; + min-width: 60px; + font-size: 13px; + } + QPushButton:hover { + border: 1px solid #4d8dff; + background-color: red; + } + QPushButton:pressed { + background-color: #23345c; + } + )"); - ret = QMessageBox::question( - this, - QString::fromLocal8Bit("退出确认"), - QString::fromLocal8Bit("确定要退出程序吗?"), - QMessageBox::Yes | QMessageBox::No - ); + QMessageBox::StandardButton ret = static_cast(msgBox.exec()); if (ret == QMessageBox::Yes) { diff --git a/HPPA/HPPA.h b/HPPA/HPPA.h index 16c2574..3c00340 100644 --- a/HPPA/HPPA.h +++ b/HPPA/HPPA.h @@ -199,6 +199,7 @@ private: void initMenubarToolbar(); void initPanelToolbar(); void initControlTabwidget(); + QWidget* tmp(QWidget* a); QLineEdit * frame_number; QLineEdit * m_FilenameLineEdit; diff --git a/HPPA/HPPA.ui b/HPPA/HPPA.ui index cec621b..0536d81 100644 --- a/HPPA/HPPA.ui +++ b/HPPA/HPPA.ui @@ -11,11 +11,11 @@ - Hyper Plant Phenotypic Analysis + Spectral Insight - - :/HPPA/HPPA.ico:/HPPA/HPPA.ico + + icon/all/png/Group 356_slices/22.pngicon/all/png/Group 356_slices/22.png diff --git a/HPPA/LayerTreeModel.cpp b/HPPA/LayerTreeModel.cpp index 2f010d5..d0e5dda 100644 --- a/HPPA/LayerTreeModel.cpp +++ b/HPPA/LayerTreeModel.cpp @@ -68,8 +68,8 @@ QVariant LayerTreeModel::data(const QModelIndex& index, int role) const } } - case Qt::CheckStateRole: - return static_cast(n->visible()); + //case Qt::CheckStateRole: + // return static_cast(n->visible()); case Qt::ToolTipRole: return (n->type() == LayerTreeNode::Type::Group) ? "Group" : "Layer"; diff --git a/HPPA/LayerTreeView.cpp b/HPPA/LayerTreeView.cpp index 4b0d98d..fd73c17 100644 --- a/HPPA/LayerTreeView.cpp +++ b/HPPA/LayerTreeView.cpp @@ -30,6 +30,19 @@ void LayerTreeView::contextMenuEvent(QContextMenuEvent* event) setCurrentIndex(QModelIndex()); QMenu* menu = m_menuProvider->createContextMenu(); + menu->setStyleSheet(R"( + QMenu { + background-color: #2a5dec; + color: white; + } + QMenu::item:selected { + background-color: #1a4ddc; + } + QMenu::separator { + height: 1px; + background: white; + } + )"); if (menu) { menu->exec(event->globalPos()); diff --git a/HPPA/TwoMotorControl.cpp b/HPPA/TwoMotorControl.cpp index bf77758..964b023 100644 --- a/HPPA/TwoMotorControl.cpp +++ b/HPPA/TwoMotorControl.cpp @@ -232,20 +232,44 @@ void TwoMotorControl::display_motors_connectivity(std::vector connectivity) //std::cout << "-----------------------------------"<ui.xMotorStateLabel->setStyleSheet("QLabel{background-color:rgb(0,255,0);}"); + this->ui.xMotorStateLabel->setStyleSheet(R"( + QLabel + { + background-color: #08FACE; + border-radius: 4px; + } + )"); } else { - this->ui.xMotorStateLabel->setStyleSheet("QLabel{background-color:rgb(255,0,0);}"); + this->ui.xMotorStateLabel->setStyleSheet(R"( + QLabel + { + background-color: red; + border-radius: 4px; + } + )"); } if (connectivity[1]) { - this->ui.yMotorStateLabel->setStyleSheet("QLabel{background-color:rgb(0,255,0);}"); + this->ui.yMotorStateLabel->setStyleSheet(R"( + QLabel + { + background-color: #08FACE; + border-radius: 4px; + } + )"); } else { - this->ui.yMotorStateLabel->setStyleSheet("QLabel{background-color:rgb(255,0,0);}"); + this->ui.yMotorStateLabel->setStyleSheet(R"( + QLabel + { + background-color: red; + border-radius: 4px; + } + )"); } } @@ -440,7 +464,7 @@ void TwoMotorControl::onSaveRecordLine2File_btn() fclose(RecordLineFileHandle); delete[] data; - QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("保存成功!")); + //QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("保存成功!")); } void TwoMotorControl::onReadRecordLineFile_btn() @@ -499,5 +523,5 @@ void TwoMotorControl::onReadRecordLineFile_btn() fclose(RecordLineFileHandle); delete[] data; - QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("读取成功!")); + //QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("读取成功!")); } diff --git a/HPPA/about.ui b/HPPA/about.ui index 04910a3..9226048 100644 --- a/HPPA/about.ui +++ b/HPPA/about.ui @@ -18,7 +18,7 @@ - HPPA.icoHPPA.ico + C:/Users/73505/.designer/backup/HPPA.icoC:/Users/73505/.designer/backup/HPPA.ico @@ -93,7 +93,10 @@ - + + + + icon/all/png/Group 356_slices/22.png @@ -193,7 +196,7 @@ QPushButton:pressed - icon/all/png/Group 356_slices/Group 356.png + C:/Users/73505/.designer/backup/icon/all/png/Group 356_slices/Group 356.png @@ -295,10 +298,6 @@ QPushButton:pressed - label_7 - widget_2 - widget_3 - companylname_label diff --git a/HPPA/aboutWindow.cpp b/HPPA/aboutWindow.cpp index c50be7f..7cddd1c 100644 --- a/HPPA/aboutWindow.cpp +++ b/HPPA/aboutWindow.cpp @@ -6,13 +6,6 @@ aboutWindow::aboutWindow(QWidget* parent) { ui.setupUi(this); - QSvgRenderer svgRenderer(QString(".//icon//all//software_icon.svg")); - QPixmap pixmap(24, 24); - pixmap.fill(Qt::transparent); // ͸ - QPainter painter(&pixmap); - svgRenderer.render(&painter); - ui.iconLabel->setPixmap(pixmap); - ui.companylname_label->setOpenExternalLinks(true);//Ϊtrueܴҳ QString text = ui.companylname_label->text(); ui.companylname_label->setText("" + text); diff --git a/HPPA/imageControl.cpp b/HPPA/imageControl.cpp index 1bc492e..e2c95db 100644 --- a/HPPA/imageControl.cpp +++ b/HPPA/imageControl.cpp @@ -64,13 +64,13 @@ ImageControl::ImageControl(QWidget* parent) } QDoubleSpinBox::up-arrow { - image: url(:/icons/up.svg); + image: url(D:/cpp_project_vs2022/HPPA/HPPA/icon/all/arrow_up.svg); width: 10px; height: 10px; } QDoubleSpinBox::down-arrow { - image: url(:/icons/down.svg); + image: url(D:/cpp_project_vs2022/HPPA/HPPA/icon/all/arrow_down.svg); width: 10px; height: 10px; }