BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
UpdateNotifierWidget Class Reference

Small on WelcomeView for notofications about updates. More...

Inheritance diagram for UpdateNotifierWidget:
[legend]
Collaboration diagram for UpdateNotifierWidget:
[legend]

Public Member Functions

 UpdateNotifierWidget (UpdateNotifier *updateNotifier, QWidget *parent=nullptr)
 

Protected Member Functions

void showEvent (QShowEvent *event)
 Schedule check for updates if it was not done yet. More...
 

Private Slots

void onLinkActivated (const QString &text)
 Processes mouse click on update notification label. More...
 
void onUpdateNotification (const QString &text)
 Updates label when notification is coming. More...
 

Private Attributes

bool m_check_for_updates
 
QLabel * m_updateLabel
 
UpdateNotifierm_updateNotifier
 

Detailed Description

Small on WelcomeView for notofications about updates.

Definition at line 26 of file UpdateNotifierWidget.h.

Constructor & Destructor Documentation

◆ UpdateNotifierWidget()

UpdateNotifierWidget::UpdateNotifierWidget ( UpdateNotifier updateNotifier,
QWidget *  parent = nullptr 
)
explicit

Definition at line 39 of file UpdateNotifierWidget.cpp.

40  : QWidget(parent)
41  , m_updateNotifier(updateNotifier)
42  , m_updateLabel(new QLabel)
43  , m_check_for_updates(true)
44 {
45  auto layout = new QHBoxLayout();
46  layout->addWidget(m_updateLabel);
47  setLayout(layout);
48 
49  m_updateLabel->setContentsMargins(30, 10, 0, 0);
50  m_updateLabel->setOpenExternalLinks(false);
51  m_updateLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
52  m_updateLabel->setTextFormat(Qt::RichText);
53  m_updateLabel->setText("");
54 
55  m_updateNotifier = updateNotifier;
58 
59  connect(m_updateLabel, &QLabel::linkActivated, this, &UpdateNotifierWidget::onLinkActivated);
60 
62  m_updateLabel->setText(update_question());
63  m_updateLabel->setToolTip("This setting can be changed later in the main window "
64  "Settings menu.");
65  }
66 }
void onLinkActivated(const QString &text)
Processes mouse click on update notification label.
UpdateNotifier * m_updateNotifier
void onUpdateNotification(const QString &text)
Updates label when notification is coming.
bool hasDefinedUpdatesFlag() const
Returns true if settings contain record about user choice for updates.
void onUpdateNotification(const QString &text)

References UpdateNotifier::hasDefinedUpdatesFlag(), m_updateLabel, m_updateNotifier, onLinkActivated(), UpdateNotifier::onUpdateNotification(), and onUpdateNotification().

Here is the call graph for this function:

Member Function Documentation

◆ onLinkActivated

void UpdateNotifierWidget::onLinkActivated ( const QString &  text)
privateslot

Processes mouse click on update notification label.

Definition at line 88 of file UpdateNotifierWidget.cpp.

89 {
90  if (text == yes) {
93  } else if (text == no) {
95  QTimer::singleShot(200, this, [&]() { m_updateLabel->setText(""); });
96  } else {
97  QDesktopServices::openUrl(QUrl(text));
98  }
99 }
void setCheckUpdatesFlag(bool flag)

References UpdateNotifier::checkForUpdates(), m_updateLabel, m_updateNotifier, and UpdateNotifier::setCheckUpdatesFlag().

Referenced by UpdateNotifierWidget().

Here is the call graph for this function:

◆ onUpdateNotification

void UpdateNotifierWidget::onUpdateNotification ( const QString &  text)
privateslot

Updates label when notification is coming.

Definition at line 81 of file UpdateNotifierWidget.cpp.

82 {
83  m_updateLabel->setText(text);
84 }

References m_updateLabel.

Referenced by UpdateNotifierWidget().

◆ showEvent()

void UpdateNotifierWidget::showEvent ( QShowEvent *  event)
protected

Schedule check for updates if it was not done yet.

Definition at line 70 of file UpdateNotifierWidget.cpp.

71 {
72  QWidget::showEvent(event);
73  if (m_check_for_updates) {
74  m_check_for_updates = false;
75  QTimer::singleShot(1000, this, [&]() { m_updateNotifier->checkForUpdates(); });
76  }
77 }

References UpdateNotifier::checkForUpdates(), m_check_for_updates, and m_updateNotifier.

Here is the call graph for this function:

Member Data Documentation

◆ m_check_for_updates

bool UpdateNotifierWidget::m_check_for_updates
private

Definition at line 41 of file UpdateNotifierWidget.h.

Referenced by showEvent().

◆ m_updateLabel

QLabel* UpdateNotifierWidget::m_updateLabel
private

◆ m_updateNotifier

UpdateNotifier* UpdateNotifierWidget::m_updateNotifier
private

Definition at line 39 of file UpdateNotifierWidget.h.

Referenced by UpdateNotifierWidget(), onLinkActivated(), and showEvent().


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