From 0fae57ea62c717691e792a8a5b99c8f1b36d0c25 Mon Sep 17 00:00:00 2001 From: Krad Date: Thu, 11 Aug 2022 09:11:34 +0800 Subject: [PATCH] Add ImageView titleBar message --- src/src/IO/DICOM/DICOMDirectoryHelper.cpp | 3 + src/src/UI/Widget/Component/mytitlebar.cpp | 16 ++-- src/src/UI/Widget/Component/mytitlebar.h | 81 +++++++++---------- .../UI/Widget/ImageView/dicomimageview.cpp | 15 +++- 4 files changed, 62 insertions(+), 53 deletions(-) diff --git a/src/src/IO/DICOM/DICOMDirectoryHelper.cpp b/src/src/IO/DICOM/DICOMDirectoryHelper.cpp index 60381b6..455e5cf 100644 --- a/src/src/IO/DICOM/DICOMDirectoryHelper.cpp +++ b/src/src/IO/DICOM/DICOMDirectoryHelper.cpp @@ -97,8 +97,11 @@ void DICOMDirectoryHelper::getFileProperty(const std::string &path, DICOMFileMap ReadTAGToProperty(PatientName, 0x0010, 0x0010) ReadTAGToProperty(PatientBirthDate, 0x0010, 0x0030) ReadTAGToProperty(PatientSex, 0x0010, 0x0040) + ReadTAGToProperty(PatientAge, 0x0010, 0x1010) ReadTAGToProperty(StudyDate, 0x0008, 0x0020) + ReadTAGToProperty(AcquisitionDate, 0x0008, 0x0022) ReadTAGToProperty(StudyTime, 0x0008, 0x0030) + ReadTAGToProperty(AcquisitionTime, 0x0008, 0x0032) ReadTAGToProperty(Modality, 0x0008, 0x0060) ReadTAGToProperty(InstitutionName, 0x0008, 0x0080) ReadTAGToProperty(StudyDescription, 0x0008, 0x1030) diff --git a/src/src/UI/Widget/Component/mytitlebar.cpp b/src/src/UI/Widget/Component/mytitlebar.cpp index 3ebabfd..0a8c7b6 100644 --- a/src/src/UI/Widget/Component/mytitlebar.cpp +++ b/src/src/UI/Widget/Component/mytitlebar.cpp @@ -8,8 +8,9 @@ #define BUTTON_WIDTH 15 // Button width; #define TITLE_HEIGHT 15 // Title bar height; -static QString unpick_style = "*{background-color:#2d2d2d;border: 0px;}"; -static QString pick_style = "*{background-color:#463232;border: 0px;color:ebebc8;}"; +//title字体用申布伦黄 +static QString unpick_style = "*{background-color:#2d2d2d;border: 0px;} QLabel#titleContent{color:#FBD26A;font-weight:20}"; +static QString pick_style = "*{background-color:#463232;border: 0px;color:ebebc8;} QLabel#titleContent{color:#FBD26A;font-weight:20}"; MyTitleBar::MyTitleBar(QWidget *parent) @@ -48,7 +49,7 @@ void MyTitleBar::initControl() m_pButtonMax->setFixedSize(QSize(BUTTON_WIDTH, BUTTON_HEIGHT)); m_pButtonClose->setFixedSize(QSize(BUTTON_WIDTH, BUTTON_HEIGHT)); - m_pTitleContent->setObjectName("TitleContent"); + m_pTitleContent->setObjectName("titleContent"); // m_pButtonMin->setObjectName("ButtonMin"); //m_pButtonRestore->setObjectName("ButtonRestore"); m_pButtonMax->setObjectName("ButtonMax"); @@ -69,7 +70,7 @@ void MyTitleBar::initControl() QHBoxLayout* mylayout = new QHBoxLayout(this); mylayout->addWidget(m_pIcon); mylayout->addWidget(m_pTitleContent); - + mylayout->addSpacerItem(new QSpacerItem(BUTTON_WIDTH,BUTTON_WIDTH, QSizePolicy::Expanding)); //mylayout->addWidget(m_pButtonMin); // mylayout->addWidget(m_pButtonRestore); mylayout->addWidget(m_pButtonMax); @@ -112,13 +113,8 @@ void MyTitleBar::setTitleIcon(QString filePath, QSize IconSize) } // Set the title content; -void MyTitleBar::setTitleContent(QString titleContent, int titleFontSize) +void MyTitleBar::setTitleContent(QString titleContent) { - // Set the title font size; - //QFont font = m_pTitleContent->font(); - //font.setPointSize(titleFontSize); - //m_pTitleContent->setFont(font); - // Set the title content; m_pTitleContent->setText(titleContent); m_titleContent = titleContent; } diff --git a/src/src/UI/Widget/Component/mytitlebar.h b/src/src/UI/Widget/Component/mytitlebar.h index 0665e2f..ddf2137 100644 --- a/src/src/UI/Widget/Component/mytitlebar.h +++ b/src/src/UI/Widget/Component/mytitlebar.h @@ -10,88 +10,85 @@ // ONLY_CLOSE_BUTTON // Only close button; //}; -class MyTitleBar : public QFrame -{ - Q_OBJECT +class MyTitleBar : public QFrame { +Q_OBJECT public: MyTitleBar(QWidget *parent); - //Here parent does not give the default value of NULL, to ensure that the parent pointer must be assigned when the MyTitleBar object is created; and the assignment is not NULL; + ~MyTitleBar(); - void SetHighlight(bool yes); - // Set the background color of the title bar and whether to set the background color of the title bar to be transparent; -//protected: -// void paintEvent(QPaintEvent *event); - // Set the button type on the title bar; - //void setButtonType(ButtonType buttonType); - // Set whether the title in the title bar will scroll; you can see the effect for details; - //void setTitleRoll(); - // Set the width of the window border; - //void setWindowBorderWidth(int borderWidth); + void SetHighlight(bool yes); - // Save/Get the position and size of the window before maximizing; - //void saveRestoreInfo(const QPoint point, const QSize size); - //void getRestoreInfo(QPoint& point, QSize& size); + void setTitleContent(QString titleContent); private: - // Set the title bar icon; - void setTitleIcon(QString filePath, QSize IconSize = QSize(25, 25)); - // Set the title content; - void setTitleContent(QString titleContent, int titleFontSize = 9); - // Set the length of the title bar; - void setTitleWidth(int width); - void setBackgroundColor(QColor pickColor); + // Set the title bar icon; + void setTitleIcon(QString filePath, QSize IconSize = QSize(25, 25)); + + // Set the title content; + // Set the length of the title bar; + void setTitleWidth(int width); + + void setBackgroundColor(QColor pickColor); + - void mouseDoubleClickEvent(QMouseEvent *event); + void mousePressEvent(QMouseEvent *event); - // void mouseMoveEvent(QMouseEvent *event); + + // void mouseMoveEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); // Initialize the control; void initControl(); + // Binding of signal slots; void initConnections(); + // Load the style file; void loadStyleSheet(const QString &sheetName); signals: + // The signal triggered by the button; //void signalViewClicked(); void signalButtonMaxClicked(); + void signalButtonCloseClicked(); private slots: - // The slot triggered by the button; - // void onButtonMinClicked(); + + // The slot triggered by the button; + // void onButtonMinClicked(); //void onButtonRestoreClicked(); void onButtonMaxClicked(); + void onButtonCloseClicked(); //void onRollTitle(); private: - QLabel* m_pIcon; // title bar icon; - QLabel* m_pTitleContent; // Title bar content; + QLabel *m_pIcon; // title bar icon; + QLabel *m_pTitleContent; // Title bar content; //QPushButton* m_pButtonMin; // Minimize button; //QPushButton* m_pButtonRestore; // Maximize restore button; - QPushButton* m_pButtonMax; // Maximize button; - QPushButton* m_pButtonClose; // Close button; + QPushButton *m_pButtonMax; // Maximize button; + QPushButton *m_pButtonClose; // Close button; - //QColor m_color; + //QColor m_color; // The background color of the title bar; - // int m_colorR; - // int m_colorG; - // int m_colorB; - //int m_alpha; + // int m_colorR; + // int m_colorG; + // int m_colorB; + //int m_alpha; // maximize and minimize variables; - // QPoint m_restorePos; + // QPoint m_restorePos; //QSize m_restoreSize; // Variables of moving window; bool m_isPressed; - // QPoint m_startMovePos; + // QPoint m_startMovePos; // marquee effect clock in title bar; - // QTimer m_titleRollTimer; + // QTimer m_titleRollTimer; // Title bar content; QString m_titleContent; // Button type; @@ -101,6 +98,6 @@ private: // Whether the title bar is transparent; //bool m_isTransparent; - QIcon icon_close; - QIcon icon_max; + QIcon icon_close; + QIcon icon_max; }; diff --git a/src/src/UI/Widget/ImageView/dicomimageview.cpp b/src/src/UI/Widget/ImageView/dicomimageview.cpp index 2dee20b..be9ea35 100644 --- a/src/src/UI/Widget/ImageView/dicomimageview.cpp +++ b/src/src/UI/Widget/ImageView/dicomimageview.cpp @@ -1,4 +1,4 @@ -#include "dicomimageview.h" +#include "dicomimageview.h" #include #include @@ -140,6 +140,19 @@ void DicomImageView::loadSeries(SeriesImageSet *series) { if (!series) return; initImageViewer(); mSeries = series; + QString age = series->GetProperty()->GetPatientAge(); + age = age.isEmpty()?"":QString("%1%2").arg(age.left(age.length()-1).toInt()).arg(age.back()); + QString date = series->GetProperty()->GetAcquisitionDate(); + date = date.length()<8?"": + QString("%1/%2/%3").arg(date.left(4), date.mid(4,2), date.right(2)); + QString time = series->GetProperty()->GetAcquisitionTime(); + time = time.length()<6?"": QString("%1:%2:%3").arg(time.left(2), time.mid(2,2), time.mid(4,2)); + mTitleBar->setTitleContent(QString("%1 (%2) - %3 %4 - %5") + .arg(series->GetProperty()->GetPatientName()) + .arg(age) + .arg(date) + .arg(time) + .arg(series->GetProperty()->GetSeriesDescription())); mImageViewer->SetInputData(mSeries->GetData()); mImageViewer->InitCornerInfo(series->GetProperty()); mImageViewer->SetupImageViewer();