BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
GUI::Util::Style Namespace Reference

Functions

QFont labelFont (bool bold=false)
 Returns font for labels. More...
 
int PropertyPanelWidth ()
 Returns typical width of the vertical property panel. More...
 
QString propertyTreeStyle ()
 Returns string representing the style of QTreeView intended for property editor. More...
 
QFont sectionFont (bool bold=false)
 Returns font for sections. More...
 
void setPropertyStyle (QTreeView *tree)
 Sets style for the tree to use in property editors. More...
 
void setResizable (QDialog *dialog)
 Make modal dialog resizable. More...
 
QSize SizeOfLetterM (const QWidget *widget=nullptr)
 Returns size of largest letter of default system font. More...
 
int SystemPointSize ()
 Returns size in points of default system font. More...
 

Function Documentation

◆ labelFont()

QFont GUI::Util::Style::labelFont ( bool  bold = false)

Returns font for labels.

Definition at line 91 of file StyleUtils.cpp.

92 {
93  QFont result;
94  result.setPointSize(DesignerHelper::getLabelFontSize());
95  result.setBold(bold);
96 
97  return result;
98 }
static int getLabelFontSize()

References DesignerHelper::getLabelFontSize().

Here is the call graph for this function:

◆ PropertyPanelWidth()

int GUI::Util::Style::PropertyPanelWidth ( )

Returns typical width of the vertical property panel.

Definition at line 124 of file StyleUtils.cpp.

125 {
126  return SizeOfLetterM().width() * 16;
127 }
QSize SizeOfLetterM(const QWidget *widget=nullptr)
Returns size of largest letter of default system font.
Definition: StyleUtils.cpp:113

References SizeOfLetterM().

Referenced by JobPropertiesWidget::minimumSizeHint(), and JobPropertiesWidget::sizeHint().

Here is the call graph for this function:

◆ propertyTreeStyle()

QString GUI::Util::Style::propertyTreeStyle ( )

Returns string representing the style of QTreeView intended for property editor.

Definition at line 56 of file StyleUtils.cpp.

57 {
58  QString result;
59 
60  // lines arount cell content
61  result += "QTreeView::item {"
62  " border-bottom: 1px solid #c7c8c9; "
63  " border-right: 1px solid #c7c8c9;}"
64  "QTreeView::branch {border-bottom: 1px solid #c7c8c9;}";
65 
66  // styling of branch to restore open/closed signs eliminated by previous styling
67  result += "QTreeView::branch:has-children:!has-siblings:closed,"
68  "QTreeView::branch:closed:has-children:has-siblings {"
69  "padding:2px 2px 2px 2px;border-image: none;"
70  "image: url(:/images/caret-right.svg);}"
71  "QTreeView::branch:open:has-children:!has-siblings,"
72  "QTreeView::branch:open:has-children:has-siblings {"
73  "padding:2px 2px 2px 2px;border-image: none; image: url(:/images/caret-down.svg);"
74  "}";
75 
76  // background of selected rows restored
77  result += "QTreeView::item:selected{background:#3daee9;}";
78 
79  return result;
80 }

Referenced by setPropertyStyle().

◆ sectionFont()

QFont GUI::Util::Style::sectionFont ( bool  bold = false)

Returns font for sections.

Definition at line 82 of file StyleUtils.cpp.

83 {
84  QFont result;
85  result.setPointSize(DesignerHelper::getSectionFontSize());
86  result.setBold(bold);
87 
88  return result;
89 }
static int getSectionFontSize()
Returns system dependent font size.

References DesignerHelper::getSectionFontSize().

Here is the call graph for this function:

◆ setPropertyStyle()

void GUI::Util::Style::setPropertyStyle ( QTreeView *  tree)

Sets style for the tree to use in property editors.

Definition at line 49 of file StyleUtils.cpp.

50 {
51  ASSERT(tree);
52  tree->setStyleSheet(GUI::Util::Style::propertyTreeStyle());
53  tree->setAlternatingRowColors(true);
54 }
QString propertyTreeStyle()
Returns string representing the style of QTreeView intended for property editor.
Definition: StyleUtils.cpp:56

References propertyTreeStyle().

Referenced by SessionModelView::SessionModelView().

Here is the call graph for this function:

◆ setResizable()

void GUI::Util::Style::setResizable ( QDialog *  dialog)

Make modal dialog resizable.

Definition at line 100 of file StyleUtils.cpp.

105 {
106 #ifdef Q_OS_MAC
107  dialog->setWindowFlags(Qt::WindowCloseButtonHint | Qt::CustomizeWindowHint
108  | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint
109  | Qt::Window);
110 #endif
111 }

Referenced by InstrumentLibraryEditor::InstrumentLibraryEditor(), MaterialEditorDialog::MaterialEditorDialog(), and PythonScriptWidget::PythonScriptWidget().

◆ SizeOfLetterM()

QSize GUI::Util::Style::SizeOfLetterM ( const QWidget *  widget = nullptr)

Returns size of largest letter of default system font.

Definition at line 113 of file StyleUtils.cpp.

114 {
115  static QSize default_size = DefaultSizeOfLetterM();
116  return widget ? FindSizeOfLetterM(widget) : default_size;
117 }

Referenced by ColorMap::initColorMap(), HistogramPlot::initGraph(), OverlayLabelWidget::paintEvent(), GUI::Constants::plot_colorbar_size(), and PropertyPanelWidth().

◆ SystemPointSize()

int GUI::Util::Style::SystemPointSize ( )

Returns size in points of default system font.

Definition at line 119 of file StyleUtils.cpp.

120 {
121  return QApplication::font().pointSize();
122 }

Referenced by DesignerHelper::getLabelFontSize(), DesignerHelper::getPortFontSize(), DesignerHelper::getPythonEditorFontSize(), DesignerHelper::getSectionFontSize(), GUI::Constants::plot_axes_label_size(), and GUI::Constants::plot_tick_label_size().