Public Slots | Public Member Functions | Static Public Member Functions | Properties | Friends

QxtConfirmationMessage Class Reference
[QxtGui]

A confirmation message. More...

#include <qxtconfirmationmessage.h>

Collaboration diagram for QxtConfirmationMessage:
Collaboration graph
[legend]

List of all members.

Public Slots

int exec ()
void reset ()
virtual void done (int result)

Public Member Functions

 QxtConfirmationMessage (QWidget *parent=0)
virtual ~QxtConfirmationMessage ()
QString confirmationText () const
void setConfirmationText (const QString &confirmation)
QString overrideSettingsApplication () const
void setOverrideSettingsApplication (const QString &application)
QString overrideSettingsKey () const
void setOverrideSettingsKey (const QString &key)
QString overrideSettingsOrganization () const
void setOverrideSettingsOrganization (const QString &organization)
bool rememberOnReject () const
void setRememberOnReject (bool remember)

Static Public Member Functions

static QSettings::Format settingsFormat ()
static void setSettingsFormat (QSettings::Format format)
static QSettings::Scope settingsScope ()
static void setSettingsScope (QSettings::Scope scope)
static QString settingsPath ()
static void setSettingsPath (const QString &path)

Properties

QString confirmationText
 This property holds the confirmation text.
QString overrideSettingsApplication
 This property holds the override application name used for settings.
QString overrideSettingsKey
 This property holds the override key used for settings.
QString overrideSettingsOrganization
 This property holds the override organization name used for settings.
bool rememberOnReject
 This property holds whether "Do not show again" option is stored even if the message box is rejected (eg. user presses Cancel).

Friends

class QxtConfirmationMessagePrivate

Detailed Description

A confirmation message.

QxtConfirmationMessage is a confirmation message with checkable "Do not show again." option. A checked and accepted confirmation message is no more shown until reseted.

Example usage:

    void MainWindow::closeEvent(QCloseEvent* event)
    {
        static const QString text(tr("Are you sure you want to quit?"));
        if (QxtConfirmationMessage::confirm(this, tr("Confirm"), text) == QMessageBox::No)
            event->ignore();
    }
qxtconfirmationmessage.png

QxtConfirmationMessage in action.

Note:
QCoreApplication::organizationName and QCoreApplication::applicationName are used for storing settings. In case these properties are empty, "QxtGui" and "QxtConfirmationMessage" are used, respectively.
Requires Qt 4.2 or newer.

Definition at line 35 of file qxtconfirmationmessage.h.


Constructor & Destructor Documentation

QxtConfirmationMessage::QxtConfirmationMessage ( QWidget *  parent = 0 ) [explicit]

Constructs a new QxtConfirmationMessage with parent.

Definition at line 182 of file qxtconfirmationmessage.cpp.

References QXT_INIT_PRIVATE.

        : QMessageBox(parent)
{
    QXT_INIT_PRIVATE(QxtConfirmationMessage);
    qxt_d().init();
}
QxtConfirmationMessage::~QxtConfirmationMessage (  ) [virtual]

Constructs a new QxtConfirmationMessage with icon, title, text, confirmation, buttons, parent and flags.

Destructs the confirmation message.

Definition at line 205 of file qxtconfirmationmessage.cpp.

{}

Member Function Documentation

QString QxtConfirmationMessage::confirmationText (  ) const
void QxtConfirmationMessage::done ( int  result ) [virtual, slot]

Definition at line 412 of file qxtconfirmationmessage.cpp.

{
#if QT_VERSION >= 0x040200
    QDialogButtonBox* buttons = qFindChild<QDialogButtonBox*>(this);
    Q_ASSERT(buttons != 0);

    int role = buttons->buttonRole(clickedButton());
    if (qxt_d().confirm->isChecked() &&
            (qxt_d().remember || role != QDialogButtonBox::RejectRole))
    {
        qxt_d().doNotShowAgain(result);
    }
#endif // QT_VERSION
    QMessageBox::done(result);
}
int QxtConfirmationMessage::exec (  ) [slot]

Shows the confirmation message if necessary. The confirmation message is not shown in case "Do not show again." has been checked while the same confirmation message was earlierly accepted.

A confirmation message is identified by the combination of title, QMessageBox::text and optional QMessageBox::informativeText.

A clicked button with role QDialogButtonBox::AcceptRole or QDialogButtonBox::YesRole is considered as "accepted".

Warning:
This function does not reimplement but shadows QMessageBox::exec().
See also:
QWidget::windowTitle, QMessageBox::text, QMessageBox::informativeText

Definition at line 401 of file qxtconfirmationmessage.cpp.

{
    int res = qxt_d().showAgain();
    if (res == -1)
        res = QMessageBox::exec();
    return res;
}
QString QxtConfirmationMessage::overrideSettingsApplication (  ) const
QString QxtConfirmationMessage::overrideSettingsKey (  ) const
QString QxtConfirmationMessage::overrideSettingsOrganization (  ) const
bool QxtConfirmationMessage::rememberOnReject (  ) const
void QxtConfirmationMessage::reset (  ) [slot]

Resets this instance of QxtConfirmationMessage. A reseted confirmation message is shown again until user checks "Do not show again." and accepts the confirmation message.

Definition at line 433 of file qxtconfirmationmessage.cpp.

{
#if QT_VERSION >= 0x040200
    qxt_d().reset();
#endif // QT_VERSION
}
void QxtConfirmationMessage::setConfirmationText ( const QString &  confirmation )

Definition at line 250 of file qxtconfirmationmessage.cpp.

{
    qxt_d().confirm->setText(confirmation);
}
void QxtConfirmationMessage::setOverrideSettingsApplication ( const QString &  application )

Definition at line 270 of file qxtconfirmationmessage.cpp.

{
    qxt_d().overrideApp = application;
}
void QxtConfirmationMessage::setOverrideSettingsKey ( const QString &  key )

Definition at line 289 of file qxtconfirmationmessage.cpp.

{
    qxt_d().overrideKey = key;
}
void QxtConfirmationMessage::setOverrideSettingsOrganization ( const QString &  organization )

Definition at line 309 of file qxtconfirmationmessage.cpp.

{
    qxt_d().overrideOrg = organization;
}
void QxtConfirmationMessage::setRememberOnReject ( bool  remember )

Definition at line 327 of file qxtconfirmationmessage.cpp.

{
    qxt_d().remember = remember;
}
void QxtConfirmationMessage::setSettingsFormat ( QSettings::Format  format ) [static]

Sets the format used for storing settings.

Definition at line 345 of file qxtconfirmationmessage.cpp.

void QxtConfirmationMessage::setSettingsPath ( const QString &  path ) [static]

Sets the path used for storing settings.

Definition at line 381 of file qxtconfirmationmessage.cpp.

void QxtConfirmationMessage::setSettingsScope ( QSettings::Scope  scope ) [static]

Sets the scope used for storing settings.

Definition at line 363 of file qxtconfirmationmessage.cpp.

QSettings::Format QxtConfirmationMessage::settingsFormat (  ) [static]
Returns:
The format used for storing settings.

The default value is QSettings::NativeFormat.

Definition at line 337 of file qxtconfirmationmessage.cpp.

QString QxtConfirmationMessage::settingsPath (  ) [static]
Returns:
The path used for storing settings.

The default value is an empty string.

Definition at line 373 of file qxtconfirmationmessage.cpp.

QSettings::Scope QxtConfirmationMessage::settingsScope (  ) [static]
Returns:
The scope used for storing settings.

The default value is QSettings::UserScope.

Definition at line 355 of file qxtconfirmationmessage.cpp.


Friends And Related Function Documentation

friend class QxtConfirmationMessagePrivate [friend]

Definition at line 38 of file qxtconfirmationmessage.h.


Property Documentation

QString QxtConfirmationMessage::confirmationText [read, write]

This property holds the confirmation text.

The default value is "Do not show again."

Definition at line 38 of file qxtconfirmationmessage.h.

QString QxtConfirmationMessage::overrideSettingsApplication [read, write]

This property holds the override application name used for settings.

QCoreApplication::applicationName is used when no overrideSettingsApplication has been set. The application name falls back to "QxtConfirmationMessage" when no QCoreApplication::applicationName has been set.

The default value is an empty string.

Definition at line 39 of file qxtconfirmationmessage.h.

QString QxtConfirmationMessage::overrideSettingsKey [read, write]

This property holds the override key used for settings.

When no overrideSettingsKey has been set, the key is calculated with qChecksum() based on title, text and confirmation message.

The default value is an empty string.

Definition at line 40 of file qxtconfirmationmessage.h.

QString QxtConfirmationMessage::overrideSettingsOrganization [read, write]

This property holds the override organization name used for settings.

QCoreApplication::organizationName is used when no overrideSettingsOrganization has been set. The organization name falls back to "QxtGui" when no QCoreApplication::organizationName has been set.

The default value is an empty string.

Definition at line 41 of file qxtconfirmationmessage.h.

bool QxtConfirmationMessage::rememberOnReject [read, write]

This property holds whether "Do not show again" option is stored even if the message box is rejected (eg. user presses Cancel).

The default value is false.

Definition at line 42 of file qxtconfirmationmessage.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines