| 93 | } |
| 94 | |
| 95 | void |
| 96 | MessageBox::init(const QString & title, |
| 97 | const QString & message, |
| 98 | const StandardButtons& buttons, |
| 99 | StandardButtonEnum defaultButton) |
| 100 | { |
| 101 | if (message.size() < 1000) { |
| 102 | _imp->label = new Label(message); |
| 103 | _imp->label->setTextInteractionFlags( Qt::TextInteractionFlags( style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, 0, this) ) ); |
| 104 | _imp->label->setAlignment(Qt::AlignVCenter | Qt::AlignLeft); |
| 105 | _imp->label->setOpenExternalLinks(true); |
| 106 | #if defined(Q_WS_MAC) |
| 107 | _imp->label->setContentsMargins(16, 0, 0, 0); |
| 108 | #elif !defined(Q_WS_QWS) |
| 109 | _imp->label->setContentsMargins(2, 0, 0, 0); |
| 110 | _imp->label->setIndent(9); |
| 111 | #endif |
| 112 | //QFont f(appFont,appFontSize); |
| 113 | //_imp->label->setFont(f); |
| 114 | } else { |
| 115 | _imp->infoEdit = new QTextEdit; |
| 116 | _imp->infoEdit->setFocusPolicy(Qt::NoFocus); |
| 117 | _imp->infoEdit->setReadOnly(true); |
| 118 | _imp->infoEdit->setAlignment(Qt::AlignVCenter | Qt::AlignLeft); |
| 119 | _imp->infoEdit->append(message); |
| 120 | //QFont f(appFont,appFontSize); |
| 121 | //_imp->infoEdit->setFont(f); |
| 122 | } |
| 123 | |
| 124 | _imp->iconLabel = new Label; |
| 125 | _imp->iconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); |
| 126 | |
| 127 | QStyle::StandardPixmap pixType = QStyle::SP_MessageBoxCritical; |
| 128 | switch (_imp->type) { |
| 129 | case eMessageBoxTypeError: |
| 130 | pixType = QStyle::SP_MessageBoxCritical; |
| 131 | break; |
| 132 | case eMessageBoxTypeWarning: |
| 133 | pixType = QStyle::SP_MessageBoxWarning; |
| 134 | break; |
| 135 | case eMessageBoxTypeInformation: |
| 136 | pixType = QStyle::SP_MessageBoxWarning; |
| 137 | break; |
| 138 | case eMessageBoxTypeQuestion: |
| 139 | pixType = QStyle::SP_MessageBoxQuestion; |
| 140 | break; |
| 141 | } |
| 142 | |
| 143 | QIcon icon = style()->standardIcon(pixType, 0, this); |
| 144 | int iconSize = style()->pixelMetric(QStyle::PM_MessageBoxIconSize, 0, this); |
| 145 | _imp->iconLabel->setPixmap( icon.pixmap(iconSize, iconSize) ); |
| 146 | |
| 147 | _imp->buttonBox = new DialogButtonBox(QDialogButtonBox::StandardButtons( int( QtEnumConvert::toQtStandarButtons(buttons) ) ), |
| 148 | Qt::Horizontal); |
| 149 | QPushButton* defaultB = _imp->buttonBox->button( QDialogButtonBox::StandardButton( |
| 150 | (QDialogButtonBox::StandardButton)QtEnumConvert::toQtStandardButton(defaultButton) ) ); |
| 151 | if ( _imp->buttonBox->buttons().contains(defaultB) ) { |
| 152 | defaultB->setDefault(true); |
nothing calls this directly
no test coverage detected