kwave  18.07.70
Kwave::MessageBox Class Reference

#include <MessageBox.h>

Inheritance diagram for Kwave::MessageBox:
Inheritance graph
Collaboration diagram for Kwave::MessageBox:
Collaboration graph

Classes

class  Trigger
 

Static Public Member Functions

static int questionYesNo (QWidget *widget, QString message, QString caption=QString(), const QString buttonYes=QString(), const QString buttonNo=QString(), const QString &dontAskAgainName=QString())
 
static int questionYesNoCancel (QWidget *widget, QString message, QString caption=QString(), const QString buttonYes=QString(), const QString buttonNo=QString(), const QString &dontAskAgainName=QString())
 
static int sorry (QWidget *widget, QString message, QString caption=QString())
 
static int warningYesNo (QWidget *widget, QString message, QString caption=QString(), const QString buttonYes=QString(), const QString buttonNo=QString(), const QString &dontAskAgainName=QString())
 
static int warningYesNoCancel (QWidget *widget, QString message, QString caption=QString(), const QString buttonYes=QString(), const QString buttonNo=QString(), const QString &dontAskAgainName=QString())
 
static int warningContinueCancel (QWidget *widget, QString message, QString caption=QString(), const QString buttonContinue=QString(), const QString buttonCancel=QString(), const QString &dontAskAgainName=QString())
 
static int error (QWidget *widget, QString message, QString caption=QString())
 

Protected Member Functions

void show ()
 

Private Member Functions

 MessageBox ()
 
 MessageBox (KMessageBox::DialogType mode, QWidget *parent, QString message, QString caption, const QString &button1=QString(), const QString &button2=QString(), const QString &dontAskAgainName=QString())
 
virtual ~MessageBox ()
 
virtual int retval () const
 

Static Private Member Functions

static int exec (KMessageBox::DialogType mode, QWidget *parent, QString message, QString caption=QString(), const QString &button1=QString(), const QString &button2=QString(), const QString &dontAskAgainName=QString())
 

Private Attributes

QSemaphore m_semaphore
 
int m_retval
 
KMessageBox::DialogType m_mode
 
QWidget * m_parent
 
QString m_message
 
QString m_caption
 
const QString m_button1
 
const QString m_button2
 
const QString m_dont_ask_again_name
 

Detailed Description

Definition at line 35 of file MessageBox.h.

Constructor & Destructor Documentation

◆ MessageBox() [1/2]

Kwave::MessageBox::MessageBox ( )
private

Default constructor (not implemented)

◆ MessageBox() [2/2]

Kwave::MessageBox::MessageBox ( KMessageBox::DialogType  mode,
QWidget *  parent,
QString  message,
QString  caption,
const QString &  button1 = QString(),
const QString &  button2 = QString(),
const QString &  dontAskAgainName = QString() 
)
private

Constructor

Parameters
modethe mode of the message box, error/warning/etc...
parentparent widget
messagethe message text of the box
captiontitle of the window
button1a KGuiItem for the first button (optional)
button2a KGuiItem for the second button (optional)
dontAskAgainNametag name for "do not ask again"

Definition at line 29 of file MessageBox.cpp.

References m_semaphore, and show().

33  :QObject(Q_NULLPTR), m_semaphore(0), m_retval(-1),
34  m_mode(mode), m_parent(parent), m_message(message), m_caption(caption),
35  m_button1(button1), m_button2(button2),
36  m_dont_ask_again_name(dontAskAgainName)
37 {
38  if (QThread::currentThread() == QApplication::instance()->thread()) {
39  // we are already in the GUI thread -> direct call
40  show();
41  } else {
42  // schedule execution in the GUI thread ...
43  Trigger *trigger = new Trigger(*this);
44  trigger->deleteLater();
45 
46  // ... and wait
47  m_semaphore.acquire();
48  }
49 }
const QString m_button2
Definition: MessageBox.h:188
KMessageBox::DialogType m_mode
Definition: MessageBox.h:173
const QString m_button1
Definition: MessageBox.h:185
const QString m_dont_ask_again_name
Definition: MessageBox.h:191
QWidget * m_parent
Definition: MessageBox.h:176
QSemaphore m_semaphore
Definition: MessageBox.h:167
Here is the call graph for this function:

◆ ~MessageBox()

Kwave::MessageBox::~MessageBox ( )
privatevirtual

Destructor

Definition at line 58 of file MessageBox.cpp.

59 {
60 }

Member Function Documentation

◆ error()

int Kwave::MessageBox::error ( QWidget *  widget,
QString  message,
QString  caption = QString() 
)
static

◆ exec()

int Kwave::MessageBox::exec ( KMessageBox::DialogType  mode,
QWidget *  parent,
QString  message,
QString  caption = QString(),
const QString &  button1 = QString(),
const QString &  button2 = QString(),
const QString &  dontAskAgainName = QString() 
)
staticprivate

Creates and executes a KMessageBox in the same thread or via a blocking signal, depending on whether the current context is the GUI thread or not.

Parameters
modetype of the message box
See also
KMessageBox::DialogType
Parameters
parentthe parent widget
messagethe text of the message box
captionthe window title (optional)
button1a KGuiItem for the first button (optional)
button2a KGuiItem for the second button (optional)
dontAskAgainNametag name for "do not ask again"
Returns
the result of the call to KMessageBox::xxx or -1

Definition at line 134 of file MessageBox.cpp.

References retval().

Referenced by error(), questionYesNo(), questionYesNoCancel(), sorry(), warningContinueCancel(), warningYesNo(), and warningYesNoCancel().

138 {
139  Kwave::MessageBox box(
140  mode, parent, message, caption,
141  button1, button2,
142  dontAskAgainName
143  );
144  return box.retval();
145 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ questionYesNo()

int Kwave::MessageBox::questionYesNo ( QWidget *  widget,
QString  message,
QString  caption = QString(),
const QString  buttonYes = QString(),
const QString  buttonNo = QString(),
const QString &  dontAskAgainName = QString() 
)
static
See also
KMessageBox::questionYesNo

Definition at line 63 of file MessageBox.cpp.

References exec().

Referenced by Kwave::ConfirmCancelProxy::cancel(), Kwave::TopWidget::executeCommand(), Kwave::FileContext::parseCommands(), and Kwave::K3BExportPlugin::start().

67 {
68  return Kwave::MessageBox::exec(KMessageBox::QuestionYesNo,
69  parent, message, caption, buttonYes, buttonNo,
70  dontAskAgainName);
71 }
static int exec(KMessageBox::DialogType mode, QWidget *parent, QString message, QString caption=QString(), const QString &button1=QString(), const QString &button2=QString(), const QString &dontAskAgainName=QString())
Definition: MessageBox.cpp:134
Here is the call graph for this function:
Here is the caller graph for this function:

◆ questionYesNoCancel()

int Kwave::MessageBox::questionYesNoCancel ( QWidget *  widget,
QString  message,
QString  caption = QString(),
const QString  buttonYes = QString(),
const QString  buttonNo = QString(),
const QString &  dontAskAgainName = QString() 
)
static
See also
KMessageBox::questionYesNoCancel

Definition at line 74 of file MessageBox.cpp.

References exec().

Referenced by Kwave::FileInfoPlugin::apply().

78 {
79  return Kwave::MessageBox::exec(KMessageBox::QuestionYesNoCancel,
80  parent, message, caption, buttonYes, buttonNo,
81  dontAskAgainName);
82 }
static int exec(KMessageBox::DialogType mode, QWidget *parent, QString message, QString caption=QString(), const QString &button1=QString(), const QString &button2=QString(), const QString &dontAskAgainName=QString())
Definition: MessageBox.cpp:134
Here is the call graph for this function:
Here is the caller graph for this function:

◆ retval()

int Kwave::MessageBox::retval ( ) const
privatevirtual

returns the return value of the KMessageBox

Definition at line 52 of file MessageBox.cpp.

References m_retval.

Referenced by exec().

53 {
54  return m_retval;
55 }
Here is the caller graph for this function:

◆ show()

void Kwave::MessageBox::show ( )
protected

shows the KMessageBox, always called in the GUI thread context.

Definition at line 148 of file MessageBox.cpp.

References m_button1, m_button2, m_caption, m_dont_ask_again_name, m_message, m_mode, m_parent, m_retval, and m_semaphore.

Referenced by MessageBox(), and Kwave::MessageBox::Trigger::~Trigger().

149 {
150  switch (m_mode) {
151  // QuestionYesNo
152  case KMessageBox::QuestionYesNo:
153  m_retval = KMessageBox::questionYesNo(m_parent,
155  (!m_button1.isEmpty()) ? KGuiItem(m_button1) :
156  KStandardGuiItem::yes(),
157  (!m_button2.isEmpty()) ? KGuiItem(m_button2) :
158  KStandardGuiItem::no(),
160  break;
161  // QuestionYesNoCancel
162  case KMessageBox::QuestionYesNoCancel:
163  m_retval = KMessageBox::questionYesNoCancel(m_parent,
165  (!m_button1.isEmpty()) ? KGuiItem(m_button1) :
166  KStandardGuiItem::yes(),
167  (!m_button2.isEmpty()) ? KGuiItem(m_button2) :
168  KStandardGuiItem::no(),
169  KStandardGuiItem::cancel(),
171  break;
172  // Sorry
173  case KMessageBox::Sorry:
174  KMessageBox::sorry(m_parent, m_message, m_caption);
175  break;
176  // WarningYesNoCancel
177  case KMessageBox::WarningYesNoCancel:
178  m_retval = KMessageBox::warningYesNoCancel(m_parent,
180  (!m_button1.isEmpty()) ? KGuiItem(m_button1) :
181  KStandardGuiItem::yes(),
182  (!m_button2.isEmpty()) ? KGuiItem(m_button2) :
183  KStandardGuiItem::no(),
184  KStandardGuiItem::cancel(),
186  break;
187  // WarningYesNo
188  case KMessageBox::WarningYesNo:
189  m_retval = KMessageBox::warningYesNo(m_parent,
191  (!m_button1.isEmpty()) ? KGuiItem(m_button1) :
192  KStandardGuiItem::yes(),
193  (!m_button2.isEmpty()) ? KGuiItem(m_button2) :
194  KStandardGuiItem::no(),
196  break;
197  // WarningContinueCancel
198  case KMessageBox::WarningContinueCancel:
199  m_retval = KMessageBox::warningContinueCancel(m_parent,
201  (!m_button1.isEmpty()) ? KGuiItem(m_button1) :
202  KStandardGuiItem::cont(),
203  (!m_button2.isEmpty()) ? KGuiItem(m_button2) :
204  KStandardGuiItem::cancel(),
206  break;
207  // Error
208  case KMessageBox::Error:
209  KMessageBox::error(m_parent, m_message, m_caption);
210  break;
211  case KMessageBox::Information:
212  KMessageBox::information(m_parent, m_message, m_caption,
214  break;
215  default:
216  qWarning("unsupported messagebox mode");
217  Q_ASSERT(0);
218  }
219 
220  m_semaphore.release();
221 }
const QString m_button2
Definition: MessageBox.h:188
KMessageBox::DialogType m_mode
Definition: MessageBox.h:173
const QString m_button1
Definition: MessageBox.h:185
const QString m_dont_ask_again_name
Definition: MessageBox.h:191
QWidget * m_parent
Definition: MessageBox.h:176
QSemaphore m_semaphore
Definition: MessageBox.h:167
Here is the caller graph for this function:

◆ sorry()

int Kwave::MessageBox::sorry ( QWidget *  widget,
QString  message,
QString  caption = QString() 
)
static
See also
KMessageBox::sorry

Definition at line 85 of file MessageBox.cpp.

References exec().

Referenced by Kwave::VorbisEncoder::open(), Kwave::MP3Decoder::open(), Kwave::WavDecoder::open(), Kwave::RecordPlugin::setDevice(), Kwave::OpusEncoder::setupCodingRate(), Kwave::RecordPlugin::setupRecordThread(), Kwave::K3BExportPlugin::start(), Kwave::RecordPlugin::startRecording(), and Kwave::PlayBackPlugin::testPlayBack().

87 {
88  return Kwave::MessageBox::exec(KMessageBox::Sorry,
89  parent, message, caption);
90 }
static int exec(KMessageBox::DialogType mode, QWidget *parent, QString message, QString caption=QString(), const QString &button1=QString(), const QString &button2=QString(), const QString &dontAskAgainName=QString())
Definition: MessageBox.cpp:134
Here is the call graph for this function:
Here is the caller graph for this function:

◆ warningContinueCancel()

int Kwave::MessageBox::warningContinueCancel ( QWidget *  widget,
QString  message,
QString  caption = QString(),
const QString  buttonContinue = QString(),
const QString  buttonCancel = QString(),
const QString &  dontAskAgainName = QString() 
)
static
See also
KMessageBox::warningContinueCancel

Definition at line 115 of file MessageBox.cpp.

References exec().

Referenced by Kwave::SignalManager::continueWithoutUndo(), Kwave::MP3Encoder::encode(), Kwave::MP3Decoder::handleError(), Kwave::VorbisEncoder::open(), Kwave::WavDecoder::open(), Kwave::Logger::open(), Kwave::MP3Decoder::parseMp3Header(), Kwave::FileContext::revert(), Kwave::SignalManager::save(), Kwave::OpusEncoder::setupBitrate(), Kwave::OpusEncoder::setupDownMix(), and Kwave::SaveBlocksPlugin::start().

119 {
120  return Kwave::MessageBox::exec(KMessageBox::WarningContinueCancel,
121  parent, message, caption, buttonContinue, buttonCancel,
122  dontAskAgainName);
123 }
static int exec(KMessageBox::DialogType mode, QWidget *parent, QString message, QString caption=QString(), const QString &button1=QString(), const QString &button2=QString(), const QString &dontAskAgainName=QString())
Definition: MessageBox.cpp:134
Here is the call graph for this function:
Here is the caller graph for this function:

◆ warningYesNo()

int Kwave::MessageBox::warningYesNo ( QWidget *  widget,
QString  message,
QString  caption = QString(),
const QString  buttonYes = QString(),
const QString  buttonNo = QString(),
const QString &  dontAskAgainName = QString() 
)
static
See also
KMessageBox::warningYesNo

Definition at line 93 of file MessageBox.cpp.

References exec().

Referenced by Kwave::FileProgress::closeEvent(), Kwave::MP3Decoder::handleError(), Kwave::FileContext::saveFileAs(), Kwave::MainWidget::saveLabels(), and Kwave::SaveBlocksPlugin::start().

97 {
98  return Kwave::MessageBox::exec(KMessageBox::WarningYesNo,
99  parent, message, caption, buttonYes, buttonNo,
100  dontAskAgainName);
101 }
static int exec(KMessageBox::DialogType mode, QWidget *parent, QString message, QString caption=QString(), const QString &button1=QString(), const QString &button2=QString(), const QString &dontAskAgainName=QString())
Definition: MessageBox.cpp:134
Here is the call graph for this function:
Here is the caller graph for this function:

◆ warningYesNoCancel()

int Kwave::MessageBox::warningYesNoCancel ( QWidget *  widget,
QString  message,
QString  caption = QString(),
const QString  buttonYes = QString(),
const QString  buttonNo = QString(),
const QString &  dontAskAgainName = QString() 
)
static
See also
KMessageBox::warningYesNoCancel

Definition at line 104 of file MessageBox.cpp.

References exec().

Referenced by Kwave::FileContext::closeFile(), Kwave::WavEncoder::encode(), and Kwave::MainWidget::labelProperties().

108 {
109  return Kwave::MessageBox::exec(KMessageBox::WarningYesNoCancel,
110  parent, message, caption, buttonYes, buttonNo,
111  dontAskAgainName);
112 }
static int exec(KMessageBox::DialogType mode, QWidget *parent, QString message, QString caption=QString(), const QString &button1=QString(), const QString &button2=QString(), const QString &dontAskAgainName=QString())
Definition: MessageBox.cpp:134
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_button1

const QString Kwave::MessageBox::m_button1
private

first button (optional)

Definition at line 185 of file MessageBox.h.

Referenced by show().

◆ m_button2

const QString Kwave::MessageBox::m_button2
private

second button (optional)

Definition at line 188 of file MessageBox.h.

Referenced by show().

◆ m_caption

QString Kwave::MessageBox::m_caption
private

the window title (optional)

Definition at line 182 of file MessageBox.h.

Referenced by show().

◆ m_dont_ask_again_name

const QString Kwave::MessageBox::m_dont_ask_again_name
private

tag for "do not ask again" (optional)

Definition at line 191 of file MessageBox.h.

Referenced by show().

◆ m_message

QString Kwave::MessageBox::m_message
private

the text of the message box

Definition at line 179 of file MessageBox.h.

Referenced by show().

◆ m_mode

KMessageBox::DialogType Kwave::MessageBox::m_mode
private
See also
KMessageBox::DialogType

Definition at line 173 of file MessageBox.h.

Referenced by show().

◆ m_parent

QWidget* Kwave::MessageBox::m_parent
private

the parent widget

Definition at line 176 of file MessageBox.h.

Referenced by show().

◆ m_retval

int Kwave::MessageBox::m_retval
private

return value of the execution of the message box

Definition at line 170 of file MessageBox.h.

Referenced by retval(), and show().

◆ m_semaphore

QSemaphore Kwave::MessageBox::m_semaphore
private

semaphore for waiting on the GUI thread

Definition at line 167 of file MessageBox.h.

Referenced by MessageBox(), and show().


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