| 1 |
namespace phoenix { |
| 2 |
|
| 3 |
static QMessageBox::StandardButtons MessageWindow_buttons(MessageWindow::Buttons buttons) { |
| 4 |
QMessageBox::StandardButtons standardButtons = QMessageBox::NoButton; |
| 5 |
if(buttons == MessageWindow::Buttons::Ok) standardButtons = QMessageBox::Ok; |
| 6 |
if(buttons == MessageWindow::Buttons::OkCancel) standardButtons = QMessageBox::Ok | QMessageBox::Cancel; |
| 7 |
if(buttons == MessageWindow::Buttons::YesNo) standardButtons = QMessageBox::Yes | QMessageBox::No; |
| 8 |
if(buttons == MessageWindow::Buttons::YesNoCancel) standardButtons = QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel; |
| 9 |
return standardButtons; |
| 10 |
} |
| 11 |
|
| 12 |
static MessageWindow::Response MessageWindow_response(MessageWindow::Buttons buttons, QMessageBox::StandardButton response) { |
| 13 |
if(response == QMessageBox::Ok) return MessageWindow::Response::Ok; |
| 14 |
if(response == QMessageBox::Cancel) return MessageWindow::Response::Cancel; |
| 15 |
if(response == QMessageBox::Yes) return MessageWindow::Response::Yes; |
| 16 |
if(response == QMessageBox::No) return MessageWindow::Response::No; |
| 17 |
|
| 18 |
//MessageWindow was closed via window manager, rather than by a button; assume a cancel/no response |
| 19 |
if(buttons == MessageWindow::Buttons::Ok) return MessageWindow::Response::Ok; |
| 20 |
if(buttons == MessageWindow::Buttons::OkCancel) return MessageWindow::Response::Cancel; |
| 21 |
if(buttons == MessageWindow::Buttons::YesNo) return MessageWindow::Response::No; |
| 22 |
if(buttons == MessageWindow::Buttons::YesNoCancel) return MessageWindow::Response::Cancel; |
| 23 |
|
| 24 |
throw; |
| 25 |
} |
| 26 |
|
| 27 |
MessageWindow::Response pMessageWindow::error(MessageWindow::State& state) { |
| 28 |
return MessageWindow_response( |
| 29 |
state.buttons, QMessageBox::critical(state.parent ? state.parent->p.qtWindow : nullptr, state.title ? state.title : " ", |
| 30 |
QString::fromUtf8(state.text), MessageWindow_buttons(state.buttons)) |
| 31 |
); |
| 32 |
} |
| 33 |
|
| 34 |
MessageWindow::Response pMessageWindow::information(MessageWindow::State& state) { |
| 35 |
return MessageWindow_response( |
| 36 |
state.buttons, QMessageBox::information(state.parent ? state.parent->p.qtWindow : nullptr, state.title ? state.title : " ", |
| 37 |
QString::fromUtf8(state.text), MessageWindow_buttons(state.buttons)) |
| 38 |
); |
| 39 |
} |
| 40 |
|
| 41 |
MessageWindow::Response pMessageWindow::question(MessageWindow::State& state) { |
| 42 |
return MessageWindow_response( |
| 43 |
state.buttons, QMessageBox::question(state.parent ? state.parent->p.qtWindow : nullptr, state.title ? state.title : " ", |
| 44 |
QString::fromUtf8(state.text), MessageWindow_buttons(state.buttons)) |
| 45 |
); |
| 46 |
} |
| 47 |
|
| 48 |
MessageWindow::Response pMessageWindow::warning(MessageWindow::State& state) { |
| 49 |
return MessageWindow_response( |
| 50 |
state.buttons, QMessageBox::warning(state.parent ? state.parent->p.qtWindow : nullptr, state.title ? state.title : " ", |
| 51 |
QString::fromUtf8(state.text), MessageWindow_buttons(state.buttons)) |
| 52 |
); |
| 53 |
} |
| 54 |
|
| 55 |
} |