BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
gui2::RecentProjectWidget Class Reference

Widget with the name of current project and collection of recent projects. More...

Inheritance diagram for gui2::RecentProjectWidget:
[legend]
Collaboration diagram for gui2::RecentProjectWidget:
[legend]

Signals

void projectSelected (const QString &project_dir)
 

Public Member Functions

 RecentProjectWidget (QWidget *parent=nullptr)
 
QSize minimumSizeHint () const override
 
void setCurrentProject (const QString &project_dir, bool is_modified)
 Set current project title and label on appropriate widget. More...
 
void setRecentProjectsList (const QStringList &projects)
 Set name of all recent projects to appropriate widgets. More...
 
QSize sizeHint () const override
 

Private Member Functions

QBoxLayout * createCurrentProjectLayout () const
 
QBoxLayout * createRecentProjectLayout ()
 
QWidget * createRecentProjectScrollArea ()
 

Private Attributes

ProjectPaneWidgetm_currentProjectPane
 
std::vector< ProjectPaneWidget * > m_recentProjectPanes
 

Detailed Description

Widget with the name of current project and collection of recent projects.

Occupies left part of WelcomeView.

Definition at line 32 of file recentprojectwidget.h.

Constructor & Destructor Documentation

◆ RecentProjectWidget()

gui2::RecentProjectWidget::RecentProjectWidget ( QWidget *  parent = nullptr)
explicit

Definition at line 31 of file recentprojectwidget.cpp.

32  : QWidget(parent), m_currentProjectPane(new ProjectPaneWidget)
33 {
34  auto layout = new QVBoxLayout(this);
35  layout->setContentsMargins(20, 0, 10, 0);
36 
37  layout->addWidget(createRecentProjectScrollArea());
38  layout->addStretch(1);
39 }
ProjectPaneWidget * m_currentProjectPane

References createRecentProjectScrollArea().

Here is the call graph for this function:

Member Function Documentation

◆ createCurrentProjectLayout()

QBoxLayout * gui2::RecentProjectWidget::createCurrentProjectLayout ( ) const
private

Definition at line 72 of file recentprojectwidget.cpp.

73 {
74  auto result = new QVBoxLayout;
75  auto label = new QLabel("Current Project");
76  ModelView::Utils::ScaleLabelFont(label, section_label_scale);
77  result->addWidget(label);
78  result->addWidget(m_currentProjectPane);
79  return result;
80 }
MVVM_VIEW_EXPORT void ScaleLabelFont(QLabel *label, double scale)
Set label's font size to system font size scaled by given factor.

References m_currentProjectPane, and ModelView::Utils::ScaleLabelFont().

Referenced by createRecentProjectScrollArea().

Here is the call graph for this function:

◆ createRecentProjectLayout()

QBoxLayout * gui2::RecentProjectWidget::createRecentProjectLayout ( )
private

Definition at line 82 of file recentprojectwidget.cpp.

83 {
84  auto result = new QVBoxLayout;
85  auto label = new QLabel("Recent Projects");
86  ModelView::Utils::ScaleLabelFont(label, section_label_scale);
87  result->addWidget(label);
88 
89  for (int i = 0; i < max_recent_project_count; ++i) {
90  auto widget = new ProjectPaneWidget;
91  connect(widget, &ProjectPaneWidget::projectSelected, this,
93  m_recentProjectPanes.push_back(widget);
94  result->addWidget(widget);
95  }
96  return result;
97 }
void projectSelected(const QString &project_dir)
std::vector< ProjectPaneWidget * > m_recentProjectPanes
void projectSelected(const QString &project_dir)

References m_recentProjectPanes, gui2::ProjectPaneWidget::projectSelected(), projectSelected(), and ModelView::Utils::ScaleLabelFont().

Referenced by createRecentProjectScrollArea().

Here is the call graph for this function:

◆ createRecentProjectScrollArea()

QWidget * gui2::RecentProjectWidget::createRecentProjectScrollArea ( )
private

Definition at line 99 of file recentprojectwidget.cpp.

100 {
101  auto result = new ModelView::AdjustingScrollArea;
102 
103  auto content = new QWidget;
104  auto layout = new QVBoxLayout;
105  layout->addLayout(createCurrentProjectLayout());
106  layout->addSpacing(ModelView::Utils::SizeOfLetterM().height());
107  layout->addLayout(createRecentProjectLayout());
108  content->setLayout(layout);
109 
110  result->setWidget(content);
111  return result;
112 }
Modification of standard scroll area, which makes widget with dynamic layout occupy the whole availab...
QBoxLayout * createCurrentProjectLayout() const
QBoxLayout * createRecentProjectLayout()
MVVM_VIEW_EXPORT QSize SizeOfLetterM()
Returns size corresponding to actual size of letter M basing on current font metrics.

References createCurrentProjectLayout(), createRecentProjectLayout(), ModelView::AdjustingScrollArea::setWidget(), and ModelView::Utils::SizeOfLetterM().

Referenced by RecentProjectWidget().

Here is the call graph for this function:

◆ minimumSizeHint()

QSize gui2::RecentProjectWidget::minimumSizeHint ( ) const
override

Definition at line 46 of file recentprojectwidget.cpp.

47 {
49 }
DAREFLCORE_EXPORT QSize DockMinimumSizeHint()
Hint on minimum size of docks on main reflectometry window.
Definition: styleutils.cpp:34

References gui2::StyleUtils::DockMinimumSizeHint().

Here is the call graph for this function:

◆ projectSelected

void gui2::RecentProjectWidget::projectSelected ( const QString &  project_dir)
signal

◆ setCurrentProject()

void gui2::RecentProjectWidget::setCurrentProject ( const QString &  project_dir,
bool  is_modified 
)

Set current project title and label on appropriate widget.

Definition at line 52 of file recentprojectwidget.cpp.

53 {
54  m_currentProjectPane->setCurrentProject(project_dir, is_modified);
56 }
void setCurrentProject(const QString &project_dir, bool is_modified=false)
Sets current project dir to 'project_dir', adjust title according to 'is_modified'.
void setActive(bool value)
Set 'active' flag to the given value.

References m_currentProjectPane, gui2::ProjectPaneWidget::setActive(), and gui2::ProjectPaneWidget::setCurrentProject().

Referenced by gui2::WelcomeView::setup_connections().

Here is the call graph for this function:

◆ setRecentProjectsList()

void gui2::RecentProjectWidget::setRecentProjectsList ( const QStringList &  projects)

Set name of all recent projects to appropriate widgets.

Definition at line 59 of file recentprojectwidget.cpp.

60 {
61  int widget_index{0};
62  for (auto widget : m_recentProjectPanes) {
63  if (widget_index < projects.size())
64  widget->setCurrentProject(projects.at(widget_index), false);
65  else
66  widget->clear();
67 
68  ++widget_index;
69  }
70 }

References m_recentProjectPanes.

Referenced by gui2::WelcomeView::setup_connections().

◆ sizeHint()

QSize gui2::RecentProjectWidget::sizeHint ( ) const
override

Definition at line 41 of file recentprojectwidget.cpp.

42 {
43  return StyleUtils::DockSizeHint();
44 }
DAREFLCORE_EXPORT QSize DockSizeHint()
Hint on size of docks on main reflectometry window.
Definition: styleutils.cpp:29

References gui2::StyleUtils::DockSizeHint().

Here is the call graph for this function:

Member Data Documentation

◆ m_currentProjectPane

ProjectPaneWidget* gui2::RecentProjectWidget::m_currentProjectPane
private

Definition at line 53 of file recentprojectwidget.h.

Referenced by createCurrentProjectLayout(), and setCurrentProject().

◆ m_recentProjectPanes

std::vector<ProjectPaneWidget*> gui2::RecentProjectWidget::m_recentProjectPanes
private

Definition at line 54 of file recentprojectwidget.h.

Referenced by createRecentProjectLayout(), and setRecentProjectsList().


The documentation for this class was generated from the following files: