Seamly2D
Code documentation
Utils::CheckableMessageBox Class Reference

The CheckableMessageBox class implements a message box suitable for questions with a "Do not ask me again" checkbox. More...

#include <checkablemessagebox.h>

Inheritance diagram for Utils::CheckableMessageBox:
Collaboration diagram for Utils::CheckableMessageBox:

Public Member Functions

 CheckableMessageBox (QWidget *parent)
 
virtual ~CheckableMessageBox () Q_DECL_OVERRIDE
 
QString text () const
 
void setText (const QString &)
 
bool isChecked () const
 
void setChecked (bool s)
 
QString checkBoxText () const
 
void setCheckBoxText (const QString &)
 
bool isCheckBoxVisible () const
 
void setCheckBoxVisible (bool)
 
QDialogButtonBox::StandardButtons standardButtons () const
 
void setStandardButtons (QDialogButtonBox::StandardButtons s)
 
QPushButton * button (QDialogButtonBox::StandardButton b) const
 
QPushButton * addButton (const QString &text, QDialogButtonBox::ButtonRole role)
 
QDialogButtonBox::StandardButton defaultButton () const
 
void setDefaultButton (QDialogButtonBox::StandardButton s)
 
void setIconPixmap (const QPixmap &p)
 
QAbstractButton * clickedButton () const
 
QDialogButtonBox::StandardButton clickedStandardButton () const
 

Static Public Member Functions

static QDialogButtonBox::StandardButton question (QWidget *parent, const QString &title, const QString &question, const QString &checkBoxText, bool *checkBoxSetting, QDialogButtonBox::StandardButtons buttons=QDialogButtonBox::Yes|QDialogButtonBox::No, QDialogButtonBox::StandardButton defaultButton=QDialogButtonBox::No)
 
static QDialogButtonBox::StandardButton information (QWidget *parent, const QString &title, const QString &text, const QString &checkBoxText, bool *checkBoxSetting, QDialogButtonBox::StandardButtons buttons=QDialogButtonBox::Ok, QDialogButtonBox::StandardButton defaultButton=QDialogButtonBox::NoButton)
 
static QDialogButtonBox::StandardButton doNotAskAgainQuestion (QWidget *parent, const QString &title, const QString &text, QSettings *settings, const QString &settingsSubKey, QDialogButtonBox::StandardButtons buttons=QDialogButtonBox::Yes|QDialogButtonBox::No, QDialogButtonBox::StandardButton defaultButton=QDialogButtonBox::No, QDialogButtonBox::StandardButton acceptButton=QDialogButtonBox::Yes)
 Shows a message box with given title and text, and a \gui {Do not ask again} check box. More...
 
static QDialogButtonBox::StandardButton doNotShowAgainInformation (QWidget *parent, const QString &title, const QString &text, QSettings *settings, const QString &settingsSubKey, QDialogButtonBox::StandardButtons buttons=QDialogButtonBox::Ok, QDialogButtonBox::StandardButton defaultButton=QDialogButtonBox::NoButton)
 Shows a message box with given title and text, and a \gui {Do not show again} check box. More...
 
static QMessageBox::StandardButton dialogButtonBoxToMessageBoxButton (QDialogButtonBox::StandardButton)
 
static void resetAllDoNotAskAgainQuestions (QSettings *settings)
 Resets all suppression settings for doNotAskAgainQuestion() found in settings, so all these message boxes are shown again. More...
 
static bool hasSuppressedQuestions (QSettings *settings)
 Returns whether any message boxes from doNotAskAgainQuestion() are suppressed in the settings. More...
 
static QString msgDoNotAskAgain ()
 Returns the standard \gui {Do not ask again} check box text. More...
 
static QString msgDoNotShowAgain ()
 Returns the standard \gui {Do not show again} check box text. More...
 

Properties

QString text
 
bool isChecked
 
QString checkBoxText
 
QDialogButtonBox::StandardButtons buttons
 
QDialogButtonBox::StandardButton defaultButton
 

Private Types

enum  DoNotAskAgainType { Question , Information }
 

Private Slots

void slotClicked (QAbstractButton *b)
 

Static Private Member Functions

static bool askAgain (QSettings *settings, const QString &settingsSubKey)
 
static void initDoNotAskAgainMessageBox (CheckableMessageBox &messageBox, const QString &title, const QString &text, QDialogButtonBox::StandardButtons buttons, QDialogButtonBox::StandardButton defaultButton, DoNotAskAgainType type)
 
static void doNotAskAgain (QSettings *settings, const QString &settingsSubKey)
 

Private Attributes

CheckableMessageBoxPrivated
 

Detailed Description

The CheckableMessageBox class implements a message box suitable for questions with a "Do not ask me again" checkbox.

Emulates the QMessageBox API with static conveniences. The message label can open external URLs.

Definition at line 39 of file checkablemessagebox.h.

Member Enumeration Documentation

◆ DoNotAskAgainType

Enumerator
Question 
Information 

Definition at line 131 of file checkablemessagebox.h.

Constructor & Destructor Documentation

◆ CheckableMessageBox()

Utils::CheckableMessageBox::CheckableMessageBox ( QWidget *  parent)
explicit

◆ ~CheckableMessageBox()

Utils::CheckableMessageBox::~CheckableMessageBox ( )
virtual

Definition at line 122 of file checkablemessagebox.cpp.

References d.

Member Function Documentation

◆ addButton()

QPushButton * Utils::CheckableMessageBox::addButton ( const QString &  text,
QDialogButtonBox::ButtonRole  role 
)

Definition at line 216 of file checkablemessagebox.cpp.

References Utils::CheckableMessageBoxPrivate::buttonBox, d, and text.

◆ askAgain()

bool Utils::CheckableMessageBox::askAgain ( QSettings *  settings,
const QString &  settingsSubKey 
)
staticprivate

Definition at line 293 of file checkablemessagebox.cpp.

References kDoNotAskAgainKey.

Referenced by doNotAskAgainQuestion(), and doNotShowAgainInformation().

◆ button()

QPushButton * Utils::CheckableMessageBox::button ( QDialogButtonBox::StandardButton  b) const

Definition at line 211 of file checkablemessagebox.cpp.

References Utils::CheckableMessageBoxPrivate::buttonBox, and d.

◆ checkBoxText()

QString Utils::CheckableMessageBox::checkBoxText ( ) const

Definition at line 180 of file checkablemessagebox.cpp.

References Utils::CheckableMessageBoxPrivate::checkBox, and d.

◆ clickedButton()

QAbstractButton * Utils::CheckableMessageBox::clickedButton ( ) const

Definition at line 132 of file checkablemessagebox.cpp.

References Utils::CheckableMessageBoxPrivate::clickedButton, and d.

◆ clickedStandardButton()

QDialogButtonBox::StandardButton Utils::CheckableMessageBox::clickedStandardButton ( ) const

◆ defaultButton()

QDialogButtonBox::StandardButton Utils::CheckableMessageBox::defaultButton ( ) const

Definition at line 221 of file checkablemessagebox.cpp.

References Utils::CheckableMessageBoxPrivate::buttonBox, and d.

◆ dialogButtonBoxToMessageBoxButton()

QMessageBox::StandardButton Utils::CheckableMessageBox::dialogButtonBoxToMessageBoxButton ( QDialogButtonBox::StandardButton  db)
static

Definition at line 288 of file checkablemessagebox.cpp.

◆ doNotAskAgain()

void Utils::CheckableMessageBox::doNotAskAgain ( QSettings *  settings,
const QString &  settingsSubKey 
)
staticprivate

Definition at line 327 of file checkablemessagebox.cpp.

References kDoNotAskAgainKey.

Referenced by doNotAskAgainQuestion(), and doNotShowAgainInformation().

◆ doNotAskAgainQuestion()

QDialogButtonBox::StandardButton Utils::CheckableMessageBox::doNotAskAgainQuestion ( QWidget *  parent,
const QString &  title,
const QString &  text,
QSettings *  settings,
const QString &  settingsSubKey,
QDialogButtonBox::StandardButtons  buttons = QDialogButtonBox::Yes|QDialogButtonBox::No,
QDialogButtonBox::StandardButton  defaultButton = QDialogButtonBox::No,
QDialogButtonBox::StandardButton  acceptButton = QDialogButtonBox::Yes 
)
static

Shows a message box with given title and text, and a \gui {Do not ask again} check box.

If the user checks the check box and accepts the dialog with the acceptButton, further invocations of this function with the same settings and settingsSubKey will not show the dialog, but instantly return acceptButton.

Returns the clicked button, or QDialogButtonBox::NoButton if the user rejects the dialog with the escape key, or acceptButton if the dialog is suppressed.

Definition at line 350 of file checkablemessagebox.cpp.

References askAgain(), buttons, clickedStandardButton(), defaultButton, doNotAskAgain(), initDoNotAskAgainMessageBox(), isChecked, Question, and text.

◆ doNotShowAgainInformation()

QDialogButtonBox::StandardButton Utils::CheckableMessageBox::doNotShowAgainInformation ( QWidget *  parent,
const QString &  title,
const QString &  text,
QSettings *  settings,
const QString &  settingsSubKey,
QDialogButtonBox::StandardButtons  buttons = QDialogButtonBox::Ok,
QDialogButtonBox::StandardButton  defaultButton = QDialogButtonBox::NoButton 
)
static

Shows a message box with given title and text, and a \gui {Do not show again} check box.

If the user checks the check box and quits the dialog, further invocations of this function with the same settings and settingsSubKey will not show the dialog, but instantly return.

Returns the clicked button, or QDialogButtonBox::NoButton if the user rejects the dialog with the escape key, or defaultButton if the dialog is suppressed.

Definition at line 384 of file checkablemessagebox.cpp.

References askAgain(), buttons, clickedStandardButton(), defaultButton, doNotAskAgain(), Information, initDoNotAskAgainMessageBox(), isChecked, and text.

◆ hasSuppressedQuestions()

bool Utils::CheckableMessageBox::hasSuppressedQuestions ( QSettings *  settings)
static

Returns whether any message boxes from doNotAskAgainQuestion() are suppressed in the settings.

Definition at line 425 of file checkablemessagebox.cpp.

References kDoNotAskAgainKey.

◆ information()

QDialogButtonBox::StandardButton Utils::CheckableMessageBox::information ( QWidget *  parent,
const QString &  title,
const QString &  text,
const QString &  checkBoxText,
bool *  checkBoxSetting,
QDialogButtonBox::StandardButtons  buttons = QDialogButtonBox::Ok,
QDialogButtonBox::StandardButton  defaultButton = QDialogButtonBox::NoButton 
)
static

◆ initDoNotAskAgainMessageBox()

void Utils::CheckableMessageBox::initDoNotAskAgainMessageBox ( CheckableMessageBox messageBox,
const QString &  title,
const QString &  text,
QDialogButtonBox::StandardButtons  buttons,
QDialogButtonBox::StandardButton  defaultButton,
DoNotAskAgainType  type 
)
staticprivate

◆ isCheckBoxVisible()

bool Utils::CheckableMessageBox::isCheckBoxVisible ( ) const

Definition at line 191 of file checkablemessagebox.cpp.

References Utils::CheckableMessageBoxPrivate::checkBox, and d.

◆ isChecked()

bool Utils::CheckableMessageBox::isChecked ( ) const

Definition at line 170 of file checkablemessagebox.cpp.

References Utils::CheckableMessageBoxPrivate::checkBox, and d.

◆ msgDoNotAskAgain()

QString Utils::CheckableMessageBox::msgDoNotAskAgain ( )
static

Returns the standard \gui {Do not ask again} check box text.

See also
doNotAskAgainQuestion()

Definition at line 446 of file checkablemessagebox.cpp.

References translate.

Referenced by initDoNotAskAgainMessageBox().

◆ msgDoNotShowAgain()

QString Utils::CheckableMessageBox::msgDoNotShowAgain ( )
static

Returns the standard \gui {Do not show again} check box text.

See also
doNotShowAgainInformation()

Definition at line 455 of file checkablemessagebox.cpp.

References translate.

Referenced by initDoNotAskAgainMessageBox().

◆ question()

QDialogButtonBox::StandardButton Utils::CheckableMessageBox::question ( QWidget *  parent,
const QString &  title,
const QString &  question,
const QString &  checkBoxText,
bool *  checkBoxSetting,
QDialogButtonBox::StandardButtons  buttons = QDialogButtonBox::Yes|QDialogButtonBox::No,
QDialogButtonBox::StandardButton  defaultButton = QDialogButtonBox::No 
)
static

◆ resetAllDoNotAskAgainQuestions()

void Utils::CheckableMessageBox::resetAllDoNotAskAgainQuestions ( QSettings *  settings)
static

Resets all suppression settings for doNotAskAgainQuestion() found in settings, so all these message boxes are shown again.

Definition at line 412 of file checkablemessagebox.cpp.

References kDoNotAskAgainKey.

◆ setCheckBoxText()

void Utils::CheckableMessageBox::setCheckBoxText ( const QString &  t)

◆ setCheckBoxVisible()

void Utils::CheckableMessageBox::setCheckBoxVisible ( bool  v)

Definition at line 196 of file checkablemessagebox.cpp.

References Utils::CheckableMessageBoxPrivate::checkBox, and d.

Referenced by initDoNotAskAgainMessageBox().

◆ setChecked()

void Utils::CheckableMessageBox::setChecked ( bool  s)

◆ setDefaultButton()

void Utils::CheckableMessageBox::setDefaultButton ( QDialogButtonBox::StandardButton  s)

◆ setIconPixmap()

void Utils::CheckableMessageBox::setIconPixmap ( const QPixmap &  p)

◆ setStandardButtons()

void Utils::CheckableMessageBox::setStandardButtons ( QDialogButtonBox::StandardButtons  s)

◆ setText()

void Utils::CheckableMessageBox::setText ( const QString &  t)

◆ slotClicked

void Utils::CheckableMessageBox::slotClicked ( QAbstractButton *  b)
privateslot

Definition at line 127 of file checkablemessagebox.cpp.

References Utils::CheckableMessageBoxPrivate::clickedButton, and d.

Referenced by CheckableMessageBox().

◆ standardButtons()

QDialogButtonBox::StandardButtons Utils::CheckableMessageBox::standardButtons ( ) const

Definition at line 201 of file checkablemessagebox.cpp.

References Utils::CheckableMessageBoxPrivate::buttonBox, and d.

◆ text()

QString Utils::CheckableMessageBox::text ( ) const

Definition at line 146 of file checkablemessagebox.cpp.

References d, and Utils::CheckableMessageBoxPrivate::messageLabel.

Member Data Documentation

◆ d

Property Documentation

◆ buttons

QDialogButtonBox::StandardButtons Utils::CheckableMessageBox::buttons
readwrite

◆ checkBoxText

QString Utils::CheckableMessageBox::checkBoxText
readwrite

Definition at line 1 of file checkablemessagebox.h.

Referenced by information(), and question().

◆ defaultButton

QDialogButtonBox::StandardButton Utils::CheckableMessageBox::defaultButton
readwrite

◆ isChecked

bool Utils::CheckableMessageBox::isChecked
readwrite

◆ text

QString Utils::CheckableMessageBox::text
readwrite

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