LibrePCB Developers Documentation
MessageWidget Class Referencefinal

A widget containing a hidable, optionally dismissable message label. More...

#include <messagewidget.h>

Inherits QWidget.

+ Collaboration diagram for MessageWidget:

Signals

void linkActivated (const QString &link)
 A link in the message label has been clicked. More...
 

Public Member Functions

 MessageWidget (QWidget *parent=nullptr) noexcept
 
 MessageWidget (const MessageWidget &other)=delete
 
 ~MessageWidget () noexcept
 
void init (const QString &message, bool active) noexcept
 Initialize widget without the "don't show again" feature. More...
 
void init (Workspace &workspace, const QString &dismissKey, const QString &message, bool active) noexcept
 Initialize widget with the "don't show again" feature. More...
 
void setActive (bool active) noexcept
 Set whether the message should be shown (if not dismissed) or not. More...
 
MessageWidgetoperator= (const MessageWidget &rhs)=delete
 

Private Member Functions

void setWorkspace (Workspace *workspace) noexcept
 
void dismissedMessagesModified () noexcept
 
void updateVisibility () noexcept
 

Private Attributes

QPointer< QHBoxLayout > mLayout
 
QScopedPointer< QLabel > mMessageLabel
 
QScopedPointer< QLabel > mDismissLabel
 
QScopedPointer< QLabel > mHideLabel
 
QPointer< WorkspacemWorkspace
 
QString mDismissKey
 
bool mActive
 
bool mTemporarilyHidden
 

Detailed Description

A widget containing a hidable, optionally dismissable message label.

This is a QLabel to show a custom message in the GUI, with a "hide" and "don't show again" label on the right side to allow hiding it. The "don't show again" feature is implemented with librepcb::WorkspaceSettings::dismissedMessages and is therefore only available if the Workspace is set.

You have to call one of the init() methods to make this widget working. Do not call QWidget::show(), QWidget::hide() or QWidget::setVisible() manually!

Constructor & Destructor Documentation

◆ MessageWidget() [1/2]

MessageWidget ( QWidget *  parent = nullptr)
explicitnoexcept
+ Here is the call graph for this function:

◆ MessageWidget() [2/2]

MessageWidget ( const MessageWidget other)
delete

◆ ~MessageWidget()

~MessageWidget ( )
noexcept

Member Function Documentation

◆ init() [1/2]

void init ( const QString &  message,
bool  active 
)
noexcept

Initialize widget without the "don't show again" feature.

Allows only temporary dismissing, but not permanently.

Parameters
messageThe message to show.
activeWhether the message should currently be shown or not.

◆ init() [2/2]

void init ( Workspace workspace,
const QString &  dismissKey,
const QString &  message,
bool  active 
)
noexcept

Initialize widget with the "don't show again" feature.

Allows both, temporary or permanently dismissing the message.

Parameters
workspaceThe workspace to use for the persistent settings.
dismissKeyThe unique identifier for this message, see details at librepcb::WorkspaceSettings::dismissedMessages.
messageThe message to show.
activeWhether the message should currently be shown or not.

◆ setActive()

void setActive ( bool  active)
noexcept

Set whether the message should be shown (if not dismissed) or not.

The widget will be visible only if true is passed and the message was not dismissed.

Parameters
activeWhether the message should currently be shown or not.

◆ operator=()

MessageWidget & operator= ( const MessageWidget rhs)
delete

◆ linkActivated

void linkActivated ( const QString &  link)
signal

A link in the message label has been clicked.

Parameters
linkThe clicked link.
+ Here is the caller graph for this function:

◆ setWorkspace()

void setWorkspace ( Workspace workspace)
privatenoexcept

◆ dismissedMessagesModified()

void dismissedMessagesModified ( )
privatenoexcept

◆ updateVisibility()

void updateVisibility ( )
privatenoexcept

Member Data Documentation

◆ mLayout

QPointer<QHBoxLayout> mLayout
private

◆ mMessageLabel

QScopedPointer<QLabel> mMessageLabel
private

◆ mDismissLabel

QScopedPointer<QLabel> mDismissLabel
private

◆ mHideLabel

QScopedPointer<QLabel> mHideLabel
private

◆ mWorkspace

QPointer<Workspace> mWorkspace
private

◆ mDismissKey

QString mDismissKey
private

◆ mActive

bool mActive
private

◆ mTemporarilyHidden

bool mTemporarilyHidden
private

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