Add ImageView titleBar message

This commit is contained in:
Krad
2022-08-11 09:11:34 +08:00
parent 457af3a27b
commit 0fae57ea62
4 changed files with 62 additions and 53 deletions

View File

@@ -97,8 +97,11 @@ void DICOMDirectoryHelper::getFileProperty(const std::string &path, DICOMFileMap
ReadTAGToProperty(PatientName, 0x0010, 0x0010) ReadTAGToProperty(PatientName, 0x0010, 0x0010)
ReadTAGToProperty(PatientBirthDate, 0x0010, 0x0030) ReadTAGToProperty(PatientBirthDate, 0x0010, 0x0030)
ReadTAGToProperty(PatientSex, 0x0010, 0x0040) ReadTAGToProperty(PatientSex, 0x0010, 0x0040)
ReadTAGToProperty(PatientAge, 0x0010, 0x1010)
ReadTAGToProperty(StudyDate, 0x0008, 0x0020) ReadTAGToProperty(StudyDate, 0x0008, 0x0020)
ReadTAGToProperty(AcquisitionDate, 0x0008, 0x0022)
ReadTAGToProperty(StudyTime, 0x0008, 0x0030) ReadTAGToProperty(StudyTime, 0x0008, 0x0030)
ReadTAGToProperty(AcquisitionTime, 0x0008, 0x0032)
ReadTAGToProperty(Modality, 0x0008, 0x0060) ReadTAGToProperty(Modality, 0x0008, 0x0060)
ReadTAGToProperty(InstitutionName, 0x0008, 0x0080) ReadTAGToProperty(InstitutionName, 0x0008, 0x0080)
ReadTAGToProperty(StudyDescription, 0x0008, 0x1030) ReadTAGToProperty(StudyDescription, 0x0008, 0x1030)

View File

@@ -8,8 +8,9 @@
#define BUTTON_WIDTH 15 // Button width; #define BUTTON_WIDTH 15 // Button width;
#define TITLE_HEIGHT 15 // Title bar height; #define TITLE_HEIGHT 15 // Title bar height;
static QString unpick_style = "*{background-color:#2d2d2d;border: 0px;}"; //title字体用申布伦黄
static QString pick_style = "*{background-color:#463232;border: 0px;color:ebebc8;}"; 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) MyTitleBar::MyTitleBar(QWidget *parent)
@@ -48,7 +49,7 @@ void MyTitleBar::initControl()
m_pButtonMax->setFixedSize(QSize(BUTTON_WIDTH, BUTTON_HEIGHT)); m_pButtonMax->setFixedSize(QSize(BUTTON_WIDTH, BUTTON_HEIGHT));
m_pButtonClose->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_pButtonMin->setObjectName("ButtonMin");
//m_pButtonRestore->setObjectName("ButtonRestore"); //m_pButtonRestore->setObjectName("ButtonRestore");
m_pButtonMax->setObjectName("ButtonMax"); m_pButtonMax->setObjectName("ButtonMax");
@@ -69,7 +70,7 @@ void MyTitleBar::initControl()
QHBoxLayout* mylayout = new QHBoxLayout(this); QHBoxLayout* mylayout = new QHBoxLayout(this);
mylayout->addWidget(m_pIcon); mylayout->addWidget(m_pIcon);
mylayout->addWidget(m_pTitleContent); mylayout->addWidget(m_pTitleContent);
mylayout->addSpacerItem(new QSpacerItem(BUTTON_WIDTH,BUTTON_WIDTH, QSizePolicy::Expanding));
//mylayout->addWidget(m_pButtonMin); //mylayout->addWidget(m_pButtonMin);
// mylayout->addWidget(m_pButtonRestore); // mylayout->addWidget(m_pButtonRestore);
mylayout->addWidget(m_pButtonMax); mylayout->addWidget(m_pButtonMax);
@@ -112,13 +113,8 @@ void MyTitleBar::setTitleIcon(QString filePath, QSize IconSize)
} }
// Set the title content; // 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_pTitleContent->setText(titleContent);
m_titleContent = titleContent; m_titleContent = titleContent;
} }

View File

@@ -10,88 +10,85 @@
// ONLY_CLOSE_BUTTON // Only close button; // ONLY_CLOSE_BUTTON // Only close button;
//}; //};
class MyTitleBar : public QFrame class MyTitleBar : public QFrame {
{ Q_OBJECT
Q_OBJECT
public: public:
MyTitleBar(QWidget *parent); 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(); ~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 SetHighlight(bool yes);
//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);
// Save/Get the position and size of the window before maximizing; void setTitleContent(QString titleContent);
//void saveRestoreInfo(const QPoint point, const QSize size);
//void getRestoreInfo(QPoint& point, QSize& size);
private: private:
// Set the title bar icon; // Set the title bar icon;
void setTitleIcon(QString filePath, QSize IconSize = QSize(25, 25)); void setTitleIcon(QString filePath, QSize IconSize = QSize(25, 25));
// Set the title content;
void setTitleContent(QString titleContent, int titleFontSize = 9); // Set the title content;
// Set the length of the title bar; // Set the length of the title bar;
void setTitleWidth(int width); void setTitleWidth(int width);
void setBackgroundColor(QColor pickColor);
void setBackgroundColor(QColor pickColor);
void mouseDoubleClickEvent(QMouseEvent *event); void mouseDoubleClickEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event); void mousePressEvent(QMouseEvent *event);
// void mouseMoveEvent(QMouseEvent *event);
// void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event);
// Initialize the control; // Initialize the control;
void initControl(); void initControl();
// Binding of signal slots; // Binding of signal slots;
void initConnections(); void initConnections();
// Load the style file; // Load the style file;
void loadStyleSheet(const QString &sheetName); void loadStyleSheet(const QString &sheetName);
signals: signals:
// The signal triggered by the button; // The signal triggered by the button;
//void signalViewClicked(); //void signalViewClicked();
void signalButtonMaxClicked(); void signalButtonMaxClicked();
void signalButtonCloseClicked(); void signalButtonCloseClicked();
private slots: private slots:
// The slot triggered by the button;
// void onButtonMinClicked(); // The slot triggered by the button;
// void onButtonMinClicked();
//void onButtonRestoreClicked(); //void onButtonRestoreClicked();
void onButtonMaxClicked(); void onButtonMaxClicked();
void onButtonCloseClicked(); void onButtonCloseClicked();
//void onRollTitle(); //void onRollTitle();
private: private:
QLabel* m_pIcon; // title bar icon; QLabel *m_pIcon; // title bar icon;
QLabel* m_pTitleContent; // Title bar content; QLabel *m_pTitleContent; // Title bar content;
//QPushButton* m_pButtonMin; // Minimize button; //QPushButton* m_pButtonMin; // Minimize button;
//QPushButton* m_pButtonRestore; // Maximize restore button; //QPushButton* m_pButtonRestore; // Maximize restore button;
QPushButton* m_pButtonMax; // Maximize button; QPushButton *m_pButtonMax; // Maximize button;
QPushButton* m_pButtonClose; // Close button; QPushButton *m_pButtonClose; // Close button;
//QColor m_color; //QColor m_color;
// The background color of the title bar; // The background color of the title bar;
// int m_colorR; // int m_colorR;
// int m_colorG; // int m_colorG;
// int m_colorB; // int m_colorB;
//int m_alpha; //int m_alpha;
// maximize and minimize variables; // maximize and minimize variables;
// QPoint m_restorePos; // QPoint m_restorePos;
//QSize m_restoreSize; //QSize m_restoreSize;
// Variables of moving window; // Variables of moving window;
bool m_isPressed; bool m_isPressed;
// QPoint m_startMovePos; // QPoint m_startMovePos;
// marquee effect clock in title bar; // marquee effect clock in title bar;
// QTimer m_titleRollTimer; // QTimer m_titleRollTimer;
// Title bar content; // Title bar content;
QString m_titleContent; QString m_titleContent;
// Button type; // Button type;
@@ -101,6 +98,6 @@ private:
// Whether the title bar is transparent; // Whether the title bar is transparent;
//bool m_isTransparent; //bool m_isTransparent;
QIcon icon_close; QIcon icon_close;
QIcon icon_max; QIcon icon_max;
}; };

View File

@@ -1,4 +1,4 @@
#include "dicomimageview.h" #include "dicomimageview.h"
#include <QMessageBox> #include <QMessageBox>
#include <QDebug> #include <QDebug>
@@ -140,6 +140,19 @@ void DicomImageView::loadSeries(SeriesImageSet *series) {
if (!series) return; if (!series) return;
initImageViewer(); initImageViewer();
mSeries = series; 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->SetInputData(mSeries->GetData());
mImageViewer->InitCornerInfo(series->GetProperty()); mImageViewer->InitCornerInfo(series->GetProperty());
mImageViewer->SetupImageViewer(); mImageViewer->SetupImageViewer();