| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qdialogbuttonbox.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | class QDialogButtonBoxPrivate : public QWidgetPrivate | - | ||||||||||||||||||
| 5 | { | - | ||||||||||||||||||
| 6 | inline QDialogButtonBox* q_func() { return static_cast<QDialogButtonBox *>(q_ptr); } inline const QDialogButtonBox* q_func() const { return static_cast<const QDialogButtonBox *>(q_ptr); } friend class QDialogButtonBox; | - | ||||||||||||||||||
| 7 | - | |||||||||||||||||||
| 8 | public: | - | ||||||||||||||||||
| 9 | QDialogButtonBoxPrivate(Qt::Orientation orient); | - | ||||||||||||||||||
| 10 | - | |||||||||||||||||||
| 11 | QList<QAbstractButton *> buttonLists[QDialogButtonBox::NRoles]; | - | ||||||||||||||||||
| 12 | QHash<QPushButton *, QDialogButtonBox::StandardButton> standardButtonHash; | - | ||||||||||||||||||
| 13 | - | |||||||||||||||||||
| 14 | Qt::Orientation orientation; | - | ||||||||||||||||||
| 15 | QDialogButtonBox::ButtonLayout layoutPolicy; | - | ||||||||||||||||||
| 16 | QBoxLayout *buttonLayout; | - | ||||||||||||||||||
| 17 | bool internalRemove; | - | ||||||||||||||||||
| 18 | bool center; | - | ||||||||||||||||||
| 19 | - | |||||||||||||||||||
| 20 | void createStandardButtons(QDialogButtonBox::StandardButtons buttons); | - | ||||||||||||||||||
| 21 | - | |||||||||||||||||||
| 22 | void layoutButtons(); | - | ||||||||||||||||||
| 23 | void initLayout(); | - | ||||||||||||||||||
| 24 | void resetLayout(); | - | ||||||||||||||||||
| 25 | QPushButton *createButton(QDialogButtonBox::StandardButton button, bool doLayout = true); | - | ||||||||||||||||||
| 26 | void addButton(QAbstractButton *button, QDialogButtonBox::ButtonRole role, bool doLayout = true); | - | ||||||||||||||||||
| 27 | void _q_handleButtonDestroyed(); | - | ||||||||||||||||||
| 28 | void _q_handleButtonClicked(); | - | ||||||||||||||||||
| 29 | void addButtonsToLayout(const QList<QAbstractButton *> &buttonList, bool reverse); | - | ||||||||||||||||||
| 30 | void retranslateStrings(); | - | ||||||||||||||||||
| 31 | }; | - | ||||||||||||||||||
| 32 | - | |||||||||||||||||||
| 33 | QDialogButtonBoxPrivate::QDialogButtonBoxPrivate(Qt::Orientation orient) | - | ||||||||||||||||||
| 34 | : orientation(orient), buttonLayout(0), internalRemove(false), center(false) | - | ||||||||||||||||||
| 35 | { | - | ||||||||||||||||||
| 36 | } | - | ||||||||||||||||||
| 37 | - | |||||||||||||||||||
| 38 | void QDialogButtonBoxPrivate::initLayout() | - | ||||||||||||||||||
| 39 | { | - | ||||||||||||||||||
| 40 | QDialogButtonBox * const q = q_func(); | - | ||||||||||||||||||
| 41 | layoutPolicy = QDialogButtonBox::ButtonLayout(q->style()->styleHint(QStyle::SH_DialogButtonLayout, 0, q)); | - | ||||||||||||||||||
| 42 | bool createNewLayout = buttonLayout == 0 | - | ||||||||||||||||||
| 43 | || (orientation == Qt::Horizontal && qobject_cast<QVBoxLayout *>(buttonLayout) != 0) | - | ||||||||||||||||||
| 44 | || (orientation == Qt::Vertical && qobject_cast<QHBoxLayout *>(buttonLayout) != 0); | - | ||||||||||||||||||
| 45 | if (createNewLayout) { | - | ||||||||||||||||||
| 46 | delete buttonLayout; | - | ||||||||||||||||||
| 47 | if (orientation == Qt::Horizontal) | - | ||||||||||||||||||
| 48 | buttonLayout = new QHBoxLayout(q); | - | ||||||||||||||||||
| 49 | else | - | ||||||||||||||||||
| 50 | buttonLayout = new QVBoxLayout(q); | - | ||||||||||||||||||
| 51 | } | - | ||||||||||||||||||
| 52 | - | |||||||||||||||||||
| 53 | int left, top, right, bottom; | - | ||||||||||||||||||
| 54 | setLayoutItemMargins(QStyle::SE_PushButtonLayoutItem); | - | ||||||||||||||||||
| 55 | getLayoutItemMargins(&left, &top, &right, &bottom); | - | ||||||||||||||||||
| 56 | buttonLayout->setContentsMargins(-left, -top, -right, -bottom); | - | ||||||||||||||||||
| 57 | - | |||||||||||||||||||
| 58 | if (!q->testAttribute(Qt::WA_WState_OwnSizePolicy)) { | - | ||||||||||||||||||
| 59 | QSizePolicy sp(QSizePolicy::Expanding, QSizePolicy::Fixed, QSizePolicy::ButtonBox); | - | ||||||||||||||||||
| 60 | if (orientation == Qt::Vertical) | - | ||||||||||||||||||
| 61 | sp.transpose(); | - | ||||||||||||||||||
| 62 | q->setSizePolicy(sp); | - | ||||||||||||||||||
| 63 | q->setAttribute(Qt::WA_WState_OwnSizePolicy, false); | - | ||||||||||||||||||
| 64 | } | - | ||||||||||||||||||
| 65 | } | - | ||||||||||||||||||
| 66 | - | |||||||||||||||||||
| 67 | void QDialogButtonBoxPrivate::resetLayout() | - | ||||||||||||||||||
| 68 | { | - | ||||||||||||||||||
| 69 | - | |||||||||||||||||||
| 70 | initLayout(); | - | ||||||||||||||||||
| 71 | layoutButtons(); | - | ||||||||||||||||||
| 72 | } | - | ||||||||||||||||||
| 73 | - | |||||||||||||||||||
| 74 | void QDialogButtonBoxPrivate::addButtonsToLayout(const QList<QAbstractButton *> &buttonList, | - | ||||||||||||||||||
| 75 | bool reverse) | - | ||||||||||||||||||
| 76 | { | - | ||||||||||||||||||
| 77 | int start = reverse ? buttonList.count() - 1 : 0; | - | ||||||||||||||||||
| 78 | int end = reverse ? -1 : buttonList.count(); | - | ||||||||||||||||||
| 79 | int step = reverse ? -1 : 1; | - | ||||||||||||||||||
| 80 | - | |||||||||||||||||||
| 81 | for (int i = start; i != end; i += step) { | - | ||||||||||||||||||
| 82 | QAbstractButton *button = buttonList.at(i); | - | ||||||||||||||||||
| 83 | buttonLayout->addWidget(button); | - | ||||||||||||||||||
| 84 | button->show(); | - | ||||||||||||||||||
| 85 | } | - | ||||||||||||||||||
| 86 | } | - | ||||||||||||||||||
| 87 | - | |||||||||||||||||||
| 88 | void QDialogButtonBoxPrivate::layoutButtons() | - | ||||||||||||||||||
| 89 | { | - | ||||||||||||||||||
| 90 | QDialogButtonBox * const q = q_func(); | - | ||||||||||||||||||
| 91 | const int MacGap = 36 - 8; | - | ||||||||||||||||||
| 92 | - | |||||||||||||||||||
| 93 | for (int i = buttonLayout->count() - 1; i >= 0
| 0 | ||||||||||||||||||
| 94 | QLayoutItem *item = buttonLayout->takeAt(i); | - | ||||||||||||||||||
| 95 | if (QWidget *widget = item->widget()
| 0 | ||||||||||||||||||
| 96 | widget->hide(); never executed: widget->hide(); | 0 | ||||||||||||||||||
| 97 | delete item; | - | ||||||||||||||||||
| 98 | } never executed: end of block | 0 | ||||||||||||||||||
| 99 | - | |||||||||||||||||||
| 100 | int tmpPolicy = layoutPolicy; | - | ||||||||||||||||||
| 101 | - | |||||||||||||||||||
| 102 | static const int M = 5; | - | ||||||||||||||||||
| 103 | static const int ModalRoles[M] = { QPlatformDialogHelper::AcceptRole, QPlatformDialogHelper::RejectRole, | - | ||||||||||||||||||
| 104 | QPlatformDialogHelper::DestructiveRole, QPlatformDialogHelper::YesRole, QPlatformDialogHelper::NoRole }; | - | ||||||||||||||||||
| 105 | if (tmpPolicy == QDialogButtonBox::MacLayout
| 0 | ||||||||||||||||||
| 106 | bool hasModalButton = false; | - | ||||||||||||||||||
| 107 | for (int i = 0; i < M
| 0 | ||||||||||||||||||
| 108 | if (!buttonLists[ModalRoles[i]].isEmpty()
| 0 | ||||||||||||||||||
| 109 | hasModalButton = true; | - | ||||||||||||||||||
| 110 | break; never executed: break; | 0 | ||||||||||||||||||
| 111 | } | - | ||||||||||||||||||
| 112 | } never executed: end of block | 0 | ||||||||||||||||||
| 113 | if (!hasModalButton
| 0 | ||||||||||||||||||
| 114 | tmpPolicy = 4; never executed: tmpPolicy = 4; | 0 | ||||||||||||||||||
| 115 | } never executed: end of block | 0 | ||||||||||||||||||
| 116 | - | |||||||||||||||||||
| 117 | const int *currentLayout = QPlatformDialogHelper::buttonLayout( | - | ||||||||||||||||||
| 118 | orientation, static_cast<QPlatformDialogHelper::ButtonLayout>(tmpPolicy)); | - | ||||||||||||||||||
| 119 | - | |||||||||||||||||||
| 120 | if (center
| 0 | ||||||||||||||||||
| 121 | buttonLayout->addStretch(); never executed: buttonLayout->addStretch(); | 0 | ||||||||||||||||||
| 122 | - | |||||||||||||||||||
| 123 | const QList<QAbstractButton *> &acceptRoleList = buttonLists[QPlatformDialogHelper::AcceptRole]; | - | ||||||||||||||||||
| 124 | - | |||||||||||||||||||
| 125 | while (*
| 0 | ||||||||||||||||||
| 126 | int role = (*currentLayout & ~QPlatformDialogHelper::Reverse); | - | ||||||||||||||||||
| 127 | bool reverse = (*currentLayout & QPlatformDialogHelper::Reverse); | - | ||||||||||||||||||
| 128 | - | |||||||||||||||||||
| 129 | switch (role) { | - | ||||||||||||||||||
| 130 | case never executed: QPlatformDialogHelper::Stretch:case QPlatformDialogHelper::Stretch:never executed: case QPlatformDialogHelper::Stretch: | 0 | ||||||||||||||||||
| 131 | if (!center
| 0 | ||||||||||||||||||
| 132 | buttonLayout->addStretch(); never executed: buttonLayout->addStretch(); | 0 | ||||||||||||||||||
| 133 | break; never executed: break; | 0 | ||||||||||||||||||
| 134 | case never executed: QPlatformDialogHelper::AcceptRole:case QPlatformDialogHelper::AcceptRole:never executed: {case QPlatformDialogHelper::AcceptRole: | 0 | ||||||||||||||||||
| 135 | if (acceptRoleList.isEmpty()
| 0 | ||||||||||||||||||
| 136 | break; never executed: break; | 0 | ||||||||||||||||||
| 137 | - | |||||||||||||||||||
| 138 | QAbstractButton *button = acceptRoleList.first(); | - | ||||||||||||||||||
| 139 | buttonLayout->addWidget(button); | - | ||||||||||||||||||
| 140 | button->show(); | - | ||||||||||||||||||
| 141 | } | - | ||||||||||||||||||
| 142 | break; never executed: break; | 0 | ||||||||||||||||||
| 143 | case never executed: QPlatformDialogHelper::AlternateRole:case QPlatformDialogHelper::AlternateRole:never executed: case QPlatformDialogHelper::AlternateRole: | 0 | ||||||||||||||||||
| 144 | {if (acceptRoleList.size() < 2> 1
| 0 | ||||||||||||||||||
| 145 | break; | 0 | ||||||||||||||||||
| QList<QAbstractButton *> list =addButtonsToLayout( never executed: acceptRoleList;addButtonsToLayout(acceptRoleList.mid(1), reverse);never executed: addButtonsToLayout(acceptRoleList.mid(1), reverse); | ||||||||||||||||||||
| list never executed: addButtonsToLayout(acceptRoleList.mid(1), reverse);never executed: .removeFirst();addButtonsToLayout(acceptRoleList.mid(1), reverse);never executed: addButtonsToLayout(acceptRoleList.mid(1), reverse); | ||||||||||||||||||||
| addButtonsToLayout never executed: addButtonsToLayout(acceptRoleList.mid(1), reverse);never executed: mid(list,1), reverse);addButtonsToLayout(acceptRoleList.mid(1), reverse);never executed: addButtonsToLayout(acceptRoleList.mid(1), reverse); | ||||||||||||||||||||
| 146 | }break; never executed: break; | 0 | ||||||||||||||||||
| 147 | case never executed: QPlatformDialogHelper::DestructiveRole:case QPlatformDialogHelper::DestructiveRole:never executed: case QPlatformDialogHelper::DestructiveRole: | 0 | ||||||||||||||||||
| 148 | { | - | ||||||||||||||||||
| 149 | const QList<QAbstractButton *> &list = buttonLists[role]; | - | ||||||||||||||||||
| 150 | if (tmpPolicy == QDialogButtonBox::MacLayout
| 0 | ||||||||||||||||||
| 151 | && !list.isEmpty()
| 0 | ||||||||||||||||||
| 152 | buttonLayout->addSpacing(MacGap); never executed: buttonLayout->addSpacing(MacGap); | 0 | ||||||||||||||||||
| 153 | - | |||||||||||||||||||
| 154 | addButtonsToLayout(list, reverse); | - | ||||||||||||||||||
| 155 | - | |||||||||||||||||||
| 156 | - | |||||||||||||||||||
| 157 | - | |||||||||||||||||||
| 158 | - | |||||||||||||||||||
| 159 | - | |||||||||||||||||||
| 160 | if (tmpPolicy == QDialogButtonBox::MacLayout
| 0 | ||||||||||||||||||
| 161 | buttonLayout->addSpacing(MacGap); never executed: buttonLayout->addSpacing(MacGap); | 0 | ||||||||||||||||||
| 162 | } | - | ||||||||||||||||||
| 163 | break; never executed: break; | 0 | ||||||||||||||||||
| 164 | case never executed: QPlatformDialogHelper::RejectRole:case QPlatformDialogHelper::RejectRole:never executed: case QPlatformDialogHelper::RejectRole: | 0 | ||||||||||||||||||
| 165 | case never executed: QPlatformDialogHelper::ActionRole:case QPlatformDialogHelper::ActionRole:never executed: case QPlatformDialogHelper::ActionRole: | 0 | ||||||||||||||||||
| 166 | case never executed: QPlatformDialogHelper::HelpRole:case QPlatformDialogHelper::HelpRole:never executed: case QPlatformDialogHelper::HelpRole: | 0 | ||||||||||||||||||
| 167 | case never executed: QPlatformDialogHelper::YesRole:case QPlatformDialogHelper::YesRole:never executed: case QPlatformDialogHelper::YesRole: | 0 | ||||||||||||||||||
| 168 | case never executed: QPlatformDialogHelper::NoRole:case QPlatformDialogHelper::NoRole:never executed: case QPlatformDialogHelper::NoRole: | 0 | ||||||||||||||||||
| 169 | case never executed: QPlatformDialogHelper::ApplyRole:case QPlatformDialogHelper::ApplyRole:never executed: case QPlatformDialogHelper::ApplyRole: | 0 | ||||||||||||||||||
| 170 | case never executed: QPlatformDialogHelper::ResetRole:case QPlatformDialogHelper::ResetRole:never executed: case QPlatformDialogHelper::ResetRole: | 0 | ||||||||||||||||||
| 171 | addButtonsToLayout(buttonLists[role], reverse); | - | ||||||||||||||||||
| 172 | } never executed: end of block | 0 | ||||||||||||||||||
| 173 | ++currentLayout; | - | ||||||||||||||||||
| 174 | } never executed: end of block | 0 | ||||||||||||||||||
| 175 | - | |||||||||||||||||||
| 176 | QWidget *lastWidget = 0; | - | ||||||||||||||||||
| 177 | q->setFocusProxy(0); | - | ||||||||||||||||||
| 178 | for (int i = 0; i < buttonLayout->count()
| 0 | ||||||||||||||||||
| 179 | QLayoutItem *item = buttonLayout->itemAt(i); | - | ||||||||||||||||||
| 180 | if (QWidget *widget = item->widget()
| 0 | ||||||||||||||||||
| 181 | if (lastWidget
| 0 | ||||||||||||||||||
| 182 | QWidget::setTabOrder(lastWidget, widget); never executed: QWidget::setTabOrder(lastWidget, widget); | 0 | ||||||||||||||||||
| 183 | else | - | ||||||||||||||||||
| 184 | q->setFocusProxy(widget); never executed: q->setFocusProxy(widget); | 0 | ||||||||||||||||||
| 185 | lastWidget = widget; | - | ||||||||||||||||||
| 186 | } never executed: end of block | 0 | ||||||||||||||||||
| 187 | } never executed: end of block | 0 | ||||||||||||||||||
| 188 | - | |||||||||||||||||||
| 189 | if (center
| 0 | ||||||||||||||||||
| 190 | buttonLayout->addStretch(); never executed: buttonLayout->addStretch(); | 0 | ||||||||||||||||||
| 191 | } never executed: end of block | 0 | ||||||||||||||||||
| 192 | - | |||||||||||||||||||
| 193 | QPushButton *QDialogButtonBoxPrivate::createButton(QDialogButtonBox::StandardButton sbutton, | - | ||||||||||||||||||
| 194 | bool doLayout) | - | ||||||||||||||||||
| 195 | { | - | ||||||||||||||||||
| 196 | QDialogButtonBox * const q = q_func(); | - | ||||||||||||||||||
| 197 | int icon = 0; | - | ||||||||||||||||||
| 198 | - | |||||||||||||||||||
| 199 | switch (sbutton) { | - | ||||||||||||||||||
| 200 | case never executed: QDialogButtonBox::Ok:case QDialogButtonBox::Ok:never executed: case QDialogButtonBox::Ok: | 0 | ||||||||||||||||||
| 201 | icon = QStyle::SP_DialogOkButton; | - | ||||||||||||||||||
| 202 | break; never executed: break; | 0 | ||||||||||||||||||
| 203 | case never executed: QDialogButtonBox::Save:case QDialogButtonBox::Save:never executed: case QDialogButtonBox::Save: | 0 | ||||||||||||||||||
| 204 | icon = QStyle::SP_DialogSaveButton; | - | ||||||||||||||||||
| 205 | break; never executed: break; | 0 | ||||||||||||||||||
| 206 | case never executed: QDialogButtonBox::Open:case QDialogButtonBox::Open:never executed: case QDialogButtonBox::Open: | 0 | ||||||||||||||||||
| 207 | icon = QStyle::SP_DialogOpenButton; | - | ||||||||||||||||||
| 208 | break; never executed: break; | 0 | ||||||||||||||||||
| 209 | case never executed: QDialogButtonBox::Cancel:case QDialogButtonBox::Cancel:never executed: case QDialogButtonBox::Cancel: | 0 | ||||||||||||||||||
| 210 | icon = QStyle::SP_DialogCancelButton; | - | ||||||||||||||||||
| 211 | break; never executed: break; | 0 | ||||||||||||||||||
| 212 | case never executed: QDialogButtonBox::Close:case QDialogButtonBox::Close:never executed: case QDialogButtonBox::Close: | 0 | ||||||||||||||||||
| 213 | icon = QStyle::SP_DialogCloseButton; | - | ||||||||||||||||||
| 214 | break; never executed: break; | 0 | ||||||||||||||||||
| 215 | case never executed: QDialogButtonBox::Apply:case QDialogButtonBox::Apply:never executed: case QDialogButtonBox::Apply: | 0 | ||||||||||||||||||
| 216 | icon = QStyle::SP_DialogApplyButton; | - | ||||||||||||||||||
| 217 | break; never executed: break; | 0 | ||||||||||||||||||
| 218 | case never executed: QDialogButtonBox::Reset:case QDialogButtonBox::Reset:never executed: case QDialogButtonBox::Reset: | 0 | ||||||||||||||||||
| 219 | icon = QStyle::SP_DialogResetButton; | - | ||||||||||||||||||
| 220 | break; never executed: break; | 0 | ||||||||||||||||||
| 221 | case never executed: QDialogButtonBox::Help:case QDialogButtonBox::Help:never executed: case QDialogButtonBox::Help: | 0 | ||||||||||||||||||
| 222 | icon = QStyle::SP_DialogHelpButton; | - | ||||||||||||||||||
| 223 | break; never executed: break; | 0 | ||||||||||||||||||
| 224 | case never executed: QDialogButtonBox::Discard:case QDialogButtonBox::Discard:never executed: case QDialogButtonBox::Discard: | 0 | ||||||||||||||||||
| 225 | icon = QStyle::SP_DialogDiscardButton; | - | ||||||||||||||||||
| 226 | break; never executed: break; | 0 | ||||||||||||||||||
| 227 | case never executed: QDialogButtonBox::Yes:case QDialogButtonBox::Yes:never executed: case QDialogButtonBox::Yes: | 0 | ||||||||||||||||||
| 228 | icon = QStyle::SP_DialogYesButton; | - | ||||||||||||||||||
| 229 | break; never executed: break; | 0 | ||||||||||||||||||
| 230 | case never executed: QDialogButtonBox::No:case QDialogButtonBox::No:never executed: case QDialogButtonBox::No: | 0 | ||||||||||||||||||
| 231 | icon = QStyle::SP_DialogNoButton; | - | ||||||||||||||||||
| 232 | break; never executed: break; | 0 | ||||||||||||||||||
| 233 | case never executed: QDialogButtonBox::YesToAll:case QDialogButtonBox::YesToAll:never executed: case QDialogButtonBox::YesToAll: | 0 | ||||||||||||||||||
| 234 | case never executed: QDialogButtonBox::NoToAll:case QDialogButtonBox::NoToAll:never executed: case QDialogButtonBox::NoToAll: | 0 | ||||||||||||||||||
| 235 | case never executed: QDialogButtonBox::SaveAll:case QDialogButtonBox::SaveAll:never executed: case QDialogButtonBox::SaveAll: | 0 | ||||||||||||||||||
| 236 | case never executed: QDialogButtonBox::Abort:case QDialogButtonBox::Abort:never executed: case QDialogButtonBox::Abort: | 0 | ||||||||||||||||||
| 237 | case never executed: QDialogButtonBox::Retry:case QDialogButtonBox::Retry:never executed: case QDialogButtonBox::Retry: | 0 | ||||||||||||||||||
| 238 | case never executed: QDialogButtonBox::Ignore:case QDialogButtonBox::Ignore:never executed: case QDialogButtonBox::Ignore: | 0 | ||||||||||||||||||
| 239 | case never executed: QDialogButtonBox::RestoreDefaults:case QDialogButtonBox::RestoreDefaults:never executed: case QDialogButtonBox::RestoreDefaults: | 0 | ||||||||||||||||||
| 240 | break; never executed: break; | 0 | ||||||||||||||||||
| 241 | case never executed: QDialogButtonBox::NoButton:case QDialogButtonBox::NoButton:never executed: case QDialogButtonBox::NoButton: | 0 | ||||||||||||||||||
| 242 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 243 | ; | - | ||||||||||||||||||
| 244 | } | - | ||||||||||||||||||
| 245 | QPushButton *button = new QPushButton(QGuiApplicationPrivate::platformTheme()->standardButtonText(sbutton), q); | - | ||||||||||||||||||
| 246 | QStyle *style = q->style(); | - | ||||||||||||||||||
| 247 | if (style->styleHint(QStyle::SH_DialogButtonBox_ButtonsHaveIcons, 0, q)
| 0 | ||||||||||||||||||
| 248 | button->setIcon(style->standardIcon(QStyle::StandardPixmap(icon), 0, q)); never executed: button->setIcon(style->standardIcon(QStyle::StandardPixmap(icon), 0, q)); | 0 | ||||||||||||||||||
| 249 | if (style != QApplication::style()
| 0 | ||||||||||||||||||
| 250 | button->setStyle(style); never executed: button->setStyle(style); | 0 | ||||||||||||||||||
| 251 | standardButtonHash.insert(button, sbutton); | - | ||||||||||||||||||
| 252 | QPlatformDialogHelper::ButtonRole role = QPlatformDialogHelper::buttonRole(static_cast<QPlatformDialogHelper::StandardButton>(sbutton)); | - | ||||||||||||||||||
| 253 | if (__builtin_expect(!!(
| 0 | ||||||||||||||||||
addButton(button, static_cast<QDialogButtonBox::ButtonRole>(role
| ||||||||||||||||||||
} else {
| ||||||||||||||||||||
| 254 | QMessageLogger(__FILE__, 411410, __PRETTY_FUNCTION__).warning("QDialogButtonBox::createButton: Invalid ButtonRole, button not added"); never executed: QMessageLogger(__FILE__, 410, __PRETTY_FUNCTION__).warning("QDialogButtonBox::createButton: Invalid ButtonRole, button not added"); | 0 | ||||||||||||||||||
| 255 | }else | - | ||||||||||||||||||
| 256 | addButton(button, static_cast<QDialogButtonBox::ButtonRole>(role), doLayout); never executed: addButton(button, static_cast<QDialogButtonBox::ButtonRole>(role), doLayout); | 0 | ||||||||||||||||||
| 257 | return never executed: button;return button;never executed: return button; | 0 | ||||||||||||||||||
| 258 | } | - | ||||||||||||||||||
| 259 | - | |||||||||||||||||||
| 260 | void QDialogButtonBoxPrivate::addButton(QAbstractButton *button, QDialogButtonBox::ButtonRole role, | - | ||||||||||||||||||
| 261 | bool doLayout) | - | ||||||||||||||||||
| 262 | { | - | ||||||||||||||||||
| 263 | QDialogButtonBox * const q = q_func(); | - | ||||||||||||||||||
| 264 | QObject::connect(button, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "428"), q, qFlagLocation("1""_q_handleButtonClicked()" "\0" __FILE__ ":" "428")); | - | ||||||||||||||||||
| 265 | QObject::connect(button, qFlagLocation("2""destroyed()" "\0" __FILE__ ":" "429"), q, qFlagLocation("1""_q_handleButtonDestroyed()" "\0" __FILE__ ":" "429")); | - | ||||||||||||||||||
| 266 | buttonLists[role].append(button); | - | ||||||||||||||||||
| 267 | if (doLayout) | - | ||||||||||||||||||
| 268 | layoutButtons(); | - | ||||||||||||||||||
| 269 | } | - | ||||||||||||||||||
| 270 | - | |||||||||||||||||||
| 271 | void QDialogButtonBoxPrivate::createStandardButtons(QDialogButtonBox::StandardButtons buttons) | - | ||||||||||||||||||
| 272 | { | - | ||||||||||||||||||
| 273 | uint i = QDialogButtonBox::FirstButton; | - | ||||||||||||||||||
| 274 | while (i <= QDialogButtonBox::LastButton) { | - | ||||||||||||||||||
| 275 | if (i & buttons) { | - | ||||||||||||||||||
| 276 | createButton(QDialogButtonBox::StandardButton(i), false); | - | ||||||||||||||||||
| 277 | } | - | ||||||||||||||||||
| 278 | i = i << 1; | - | ||||||||||||||||||
| 279 | } | - | ||||||||||||||||||
| 280 | layoutButtons(); | - | ||||||||||||||||||
| 281 | } | - | ||||||||||||||||||
| 282 | - | |||||||||||||||||||
| 283 | void QDialogButtonBoxPrivate::retranslateStrings() | - | ||||||||||||||||||
| 284 | { | - | ||||||||||||||||||
| 285 | typedef QHash<QPushButton *, QDialogButtonBox::StandardButton>::iterator Iterator; | - | ||||||||||||||||||
| 286 | - | |||||||||||||||||||
| 287 | const Iterator end = standardButtonHash.end(); | - | ||||||||||||||||||
| 288 | for (Iterator it = standardButtonHash.begin(); it != end; ++it) { | - | ||||||||||||||||||
| 289 | const QString text = QGuiApplicationPrivate::platformTheme()->standardButtonText(it.value()); | - | ||||||||||||||||||
| 290 | if (!text.isEmpty()) | - | ||||||||||||||||||
| 291 | it.key()->setText(text); | - | ||||||||||||||||||
| 292 | } | - | ||||||||||||||||||
| 293 | } | - | ||||||||||||||||||
| 294 | - | |||||||||||||||||||
| 295 | - | |||||||||||||||||||
| 296 | - | |||||||||||||||||||
| 297 | - | |||||||||||||||||||
| 298 | - | |||||||||||||||||||
| 299 | - | |||||||||||||||||||
| 300 | QDialogButtonBox::QDialogButtonBox(QWidget *parent) | - | ||||||||||||||||||
| 301 | : QWidget(*new QDialogButtonBoxPrivate(Qt::Horizontal), parent, 0) | - | ||||||||||||||||||
| 302 | { | - | ||||||||||||||||||
| 303 | d_func()->initLayout(); | - | ||||||||||||||||||
| 304 | } | - | ||||||||||||||||||
| 305 | - | |||||||||||||||||||
| 306 | - | |||||||||||||||||||
| 307 | - | |||||||||||||||||||
| 308 | - | |||||||||||||||||||
| 309 | - | |||||||||||||||||||
| 310 | - | |||||||||||||||||||
| 311 | QDialogButtonBox::QDialogButtonBox(Qt::Orientation orientation, QWidget *parent) | - | ||||||||||||||||||
| 312 | : QWidget(*new QDialogButtonBoxPrivate(orientation), parent, 0) | - | ||||||||||||||||||
| 313 | { | - | ||||||||||||||||||
| 314 | d_func()->initLayout(); | - | ||||||||||||||||||
| 315 | } | - | ||||||||||||||||||
| 316 | QDialogButtonBox::QDialogButtonBox(StandardButtons buttons, QWidget *parent) | - | ||||||||||||||||||
| 317 | : QWidget(*new QDialogButtonBoxPrivate(Qt::Horizontal), parent, 0) | - | ||||||||||||||||||
| 318 | { | - | ||||||||||||||||||
| 319 | d_func()->initLayout(); | - | ||||||||||||||||||
| 320 | d_func()->createStandardButtons(buttons); | - | ||||||||||||||||||
| 321 | } | - | ||||||||||||||||||
| 322 | - | |||||||||||||||||||
| 323 | - | |||||||||||||||||||
| 324 | - | |||||||||||||||||||
| 325 | - | |||||||||||||||||||
| 326 | - | |||||||||||||||||||
| 327 | - | |||||||||||||||||||
| 328 | - | |||||||||||||||||||
| 329 | QDialogButtonBox::QDialogButtonBox(StandardButtons buttons, Qt::Orientation orientation, | - | ||||||||||||||||||
| 330 | QWidget *parent) | - | ||||||||||||||||||
| 331 | : QWidget(*new QDialogButtonBoxPrivate(orientation), parent, 0) | - | ||||||||||||||||||
| 332 | { | - | ||||||||||||||||||
| 333 | d_func()->initLayout(); | - | ||||||||||||||||||
| 334 | d_func()->createStandardButtons(buttons); | - | ||||||||||||||||||
| 335 | } | - | ||||||||||||||||||
| 336 | - | |||||||||||||||||||
| 337 | - | |||||||||||||||||||
| 338 | - | |||||||||||||||||||
| 339 | - | |||||||||||||||||||
| 340 | QDialogButtonBox::~QDialogButtonBox() | - | ||||||||||||||||||
| 341 | { | - | ||||||||||||||||||
| 342 | } | - | ||||||||||||||||||
| 343 | Qt::Orientation QDialogButtonBox::orientation() const | - | ||||||||||||||||||
| 344 | { | - | ||||||||||||||||||
| 345 | return d_func()->orientation; | - | ||||||||||||||||||
| 346 | } | - | ||||||||||||||||||
| 347 | - | |||||||||||||||||||
| 348 | void QDialogButtonBox::setOrientation(Qt::Orientation orientation) | - | ||||||||||||||||||
| 349 | { | - | ||||||||||||||||||
| 350 | QDialogButtonBoxPrivate * const d = d_func(); | - | ||||||||||||||||||
| 351 | if (orientation == d->orientation) | - | ||||||||||||||||||
| 352 | return; | - | ||||||||||||||||||
| 353 | - | |||||||||||||||||||
| 354 | d->orientation = orientation; | - | ||||||||||||||||||
| 355 | d->resetLayout(); | - | ||||||||||||||||||
| 356 | } | - | ||||||||||||||||||
| 357 | - | |||||||||||||||||||
| 358 | - | |||||||||||||||||||
| 359 | - | |||||||||||||||||||
| 360 | - | |||||||||||||||||||
| 361 | - | |||||||||||||||||||
| 362 | - | |||||||||||||||||||
| 363 | void QDialogButtonBox::clear() | - | ||||||||||||||||||
| 364 | { | - | ||||||||||||||||||
| 365 | QDialogButtonBoxPrivate * const d = d_func(); | - | ||||||||||||||||||
| 366 | - | |||||||||||||||||||
| 367 | - | |||||||||||||||||||
| 368 | d->standardButtonHash.clear(); | - | ||||||||||||||||||
| 369 | for (int i = 0; i < NRoles; ++i) { | - | ||||||||||||||||||
| 370 | QList<QAbstractButton *> &list = d->buttonLists[i]; | - | ||||||||||||||||||
| 371 | while (list.count()) { | - | ||||||||||||||||||
| 372 | QAbstractButton *button = list.takeAt(0); | - | ||||||||||||||||||
| 373 | QObject::disconnect(button, qFlagLocation("2""destroyed()" "\0" __FILE__ ":" "668"), this, qFlagLocation("1""_q_handleButtonDestroyed()" "\0" __FILE__ ":" "668")); | - | ||||||||||||||||||
| 374 | delete button; | - | ||||||||||||||||||
| 375 | } | - | ||||||||||||||||||
| 376 | } | - | ||||||||||||||||||
| 377 | } | - | ||||||||||||||||||
| 378 | - | |||||||||||||||||||
| 379 | - | |||||||||||||||||||
| 380 | - | |||||||||||||||||||
| 381 | - | |||||||||||||||||||
| 382 | - | |||||||||||||||||||
| 383 | - | |||||||||||||||||||
| 384 | QList<QAbstractButton *> QDialogButtonBox::buttons() const | - | ||||||||||||||||||
| 385 | { | - | ||||||||||||||||||
| 386 | const QDialogButtonBoxPrivate * const d = d_func(); | - | ||||||||||||||||||
| 387 | QList<QAbstractButton *> finalList; | - | ||||||||||||||||||
| 388 | for (int i = 0; i < NRoles; ++i) { | - | ||||||||||||||||||
| 389 | const QList<QAbstractButton *> &list = d->buttonLists[i]; | - | ||||||||||||||||||
| 390 | for (int j = 0; j < list.count(); ++j) | - | ||||||||||||||||||
| 391 | finalList.append(list.at(j)); | - | ||||||||||||||||||
| 392 | } | - | ||||||||||||||||||
| 393 | return finalList; | - | ||||||||||||||||||
| 394 | } | - | ||||||||||||||||||
| 395 | - | |||||||||||||||||||
| 396 | - | |||||||||||||||||||
| 397 | - | |||||||||||||||||||
| 398 | - | |||||||||||||||||||
| 399 | - | |||||||||||||||||||
| 400 | - | |||||||||||||||||||
| 401 | - | |||||||||||||||||||
| 402 | QDialogButtonBox::ButtonRole QDialogButtonBox::buttonRole(QAbstractButton *button) const | - | ||||||||||||||||||
| 403 | { | - | ||||||||||||||||||
| 404 | const QDialogButtonBoxPrivate * const d = d_func(); | - | ||||||||||||||||||
| 405 | for (int i = 0; i < NRoles; ++i) { | - | ||||||||||||||||||
| 406 | const QList<QAbstractButton *> &list = d->buttonLists[i]; | - | ||||||||||||||||||
| 407 | for (int j = 0; j < list.count(); ++j) { | - | ||||||||||||||||||
| 408 | if (list.at(j) == button) | - | ||||||||||||||||||
| 409 | return ButtonRole(i); | - | ||||||||||||||||||
| 410 | } | - | ||||||||||||||||||
| 411 | } | - | ||||||||||||||||||
| 412 | return InvalidRole; | - | ||||||||||||||||||
| 413 | } | - | ||||||||||||||||||
| 414 | - | |||||||||||||||||||
| 415 | - | |||||||||||||||||||
| 416 | - | |||||||||||||||||||
| 417 | - | |||||||||||||||||||
| 418 | - | |||||||||||||||||||
| 419 | - | |||||||||||||||||||
| 420 | void QDialogButtonBox::removeButton(QAbstractButton *button) | - | ||||||||||||||||||
| 421 | { | - | ||||||||||||||||||
| 422 | QDialogButtonBoxPrivate * const d = d_func(); | - | ||||||||||||||||||
| 423 | - | |||||||||||||||||||
| 424 | if (!button) | - | ||||||||||||||||||
| 425 | return; | - | ||||||||||||||||||
| 426 | - | |||||||||||||||||||
| 427 | - | |||||||||||||||||||
| 428 | if (QPushButton *pushButton = qobject_cast<QPushButton *>(button)) | - | ||||||||||||||||||
| 429 | d->standardButtonHash.remove(pushButton); | - | ||||||||||||||||||
| 430 | for (int i = 0; i < NRoles; ++i) { | - | ||||||||||||||||||
| 431 | QList<QAbstractButton *> &list = d->buttonLists[i]; | - | ||||||||||||||||||
| 432 | for (int j = 0; j < list.count(); ++j) { | - | ||||||||||||||||||
| 433 | if (list.at(j) == button) { | - | ||||||||||||||||||
| 434 | list.takeAt(j); | - | ||||||||||||||||||
| 435 | if (!d->internalRemove) { | - | ||||||||||||||||||
| 436 | disconnect(button, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "731"), this, qFlagLocation("1""_q_handleButtonClicked()" "\0" __FILE__ ":" "731")); | - | ||||||||||||||||||
| 437 | disconnect(button, qFlagLocation("2""destroyed()" "\0" __FILE__ ":" "732"), this, qFlagLocation("1""_q_handleButtonDestroyed()" "\0" __FILE__ ":" "732")); | - | ||||||||||||||||||
| 438 | } | - | ||||||||||||||||||
| 439 | break; | - | ||||||||||||||||||
| 440 | } | - | ||||||||||||||||||
| 441 | } | - | ||||||||||||||||||
| 442 | } | - | ||||||||||||||||||
| 443 | if (!d->internalRemove) | - | ||||||||||||||||||
| 444 | button->setParent(0); | - | ||||||||||||||||||
| 445 | } | - | ||||||||||||||||||
| 446 | void QDialogButtonBox::addButton(QAbstractButton *button, ButtonRole role) | - | ||||||||||||||||||
| 447 | { | - | ||||||||||||||||||
| 448 | QDialogButtonBoxPrivate * const d = d_func(); | - | ||||||||||||||||||
| 449 | if (__builtin_expect(!!(
| 0 | ||||||||||||||||||
| 450 | QMessageLogger(__FILE__, 757, __PRETTY_FUNCTION__).warning("QDialogButtonBox::addButton: Invalid ButtonRole, button not added"); | - | ||||||||||||||||||
| 451 | return; never executed: return; | 0 | ||||||||||||||||||
| 452 | } | - | ||||||||||||||||||
| 453 | removeButton(button); | - | ||||||||||||||||||
| 454 | button->setParent(this); | - | ||||||||||||||||||
| 455 | d->addButton(button, role); | - | ||||||||||||||||||
| 456 | } never executed: end of block | 0 | ||||||||||||||||||
| 457 | QPushButton *QDialogButtonBox::addButton(const QString &text, ButtonRole role) | - | ||||||||||||||||||
| 458 | { | - | ||||||||||||||||||
| 459 | QDialogButtonBoxPrivate * const d = d_func(); | - | ||||||||||||||||||
| 460 | if (__builtin_expect(!!(
| 0 | ||||||||||||||||||
| 461 | QMessageLogger(__FILE__, 776, __PRETTY_FUNCTION__).warning("QDialogButtonBox::addButton: Invalid ButtonRole, button not added"); | - | ||||||||||||||||||
| 462 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 463 | } | - | ||||||||||||||||||
| 464 | QPushButton *button = new QPushButton(text, this); | - | ||||||||||||||||||
| 465 | d->addButton(button, role); | - | ||||||||||||||||||
| 466 | return never executed: button;return button;never executed: return button; | 0 | ||||||||||||||||||
| 467 | } | - | ||||||||||||||||||
| 468 | QPushButton *QDialogButtonBox::addButton(StandardButton button) | - | ||||||||||||||||||
| 469 | { | - | ||||||||||||||||||
| 470 | QDialogButtonBoxPrivate * const d = d_func(); | - | ||||||||||||||||||
| 471 | return d->createButton(button); | - | ||||||||||||||||||
| 472 | } | - | ||||||||||||||||||
| 473 | void QDialogButtonBox::setStandardButtons(StandardButtons buttons) | - | ||||||||||||||||||
| 474 | { | - | ||||||||||||||||||
| 475 | QDialogButtonBoxPrivate * const d = d_func(); | - | ||||||||||||||||||
| 476 | - | |||||||||||||||||||
| 477 | qDeleteAll(d->standardButtonHash.keys()); | - | ||||||||||||||||||
| 478 | d->standardButtonHash.clear(); | - | ||||||||||||||||||
| 479 | - | |||||||||||||||||||
| 480 | d->createStandardButtons(buttons); | - | ||||||||||||||||||
| 481 | } | - | ||||||||||||||||||
| 482 | - | |||||||||||||||||||
| 483 | QDialogButtonBox::StandardButtons QDialogButtonBox::standardButtons() const | - | ||||||||||||||||||
| 484 | { | - | ||||||||||||||||||
| 485 | const QDialogButtonBoxPrivate * const d = d_func(); | - | ||||||||||||||||||
| 486 | StandardButtons standardButtons = NoButton; | - | ||||||||||||||||||
| 487 | QHash<QPushButton *, StandardButton>::const_iterator it = d->standardButtonHash.constBegin(); | - | ||||||||||||||||||
| 488 | while (it != d->standardButtonHash.constEnd()) { | - | ||||||||||||||||||
| 489 | standardButtons |= it.value(); | - | ||||||||||||||||||
| 490 | ++it; | - | ||||||||||||||||||
| 491 | } | - | ||||||||||||||||||
| 492 | return standardButtons; | - | ||||||||||||||||||
| 493 | } | - | ||||||||||||||||||
| 494 | - | |||||||||||||||||||
| 495 | - | |||||||||||||||||||
| 496 | - | |||||||||||||||||||
| 497 | - | |||||||||||||||||||
| 498 | - | |||||||||||||||||||
| 499 | - | |||||||||||||||||||
| 500 | - | |||||||||||||||||||
| 501 | QPushButton *QDialogButtonBox::button(StandardButton which) const | - | ||||||||||||||||||
| 502 | { | - | ||||||||||||||||||
| 503 | const QDialogButtonBoxPrivate * const d = d_func(); | - | ||||||||||||||||||
| 504 | return d->standardButtonHash.key(which); | - | ||||||||||||||||||
| 505 | } | - | ||||||||||||||||||
| 506 | - | |||||||||||||||||||
| 507 | - | |||||||||||||||||||
| 508 | - | |||||||||||||||||||
| 509 | - | |||||||||||||||||||
| 510 | - | |||||||||||||||||||
| 511 | - | |||||||||||||||||||
| 512 | - | |||||||||||||||||||
| 513 | QDialogButtonBox::StandardButton QDialogButtonBox::standardButton(QAbstractButton *button) const | - | ||||||||||||||||||
| 514 | { | - | ||||||||||||||||||
| 515 | const QDialogButtonBoxPrivate * const d = d_func(); | - | ||||||||||||||||||
| 516 | return d->standardButtonHash.value(static_cast<QPushButton *>(button)); | - | ||||||||||||||||||
| 517 | } | - | ||||||||||||||||||
| 518 | - | |||||||||||||||||||
| 519 | void QDialogButtonBoxPrivate::_q_handleButtonClicked() | - | ||||||||||||||||||
| 520 | { | - | ||||||||||||||||||
| 521 | QDialogButtonBox * const q = q_func(); | - | ||||||||||||||||||
| 522 | if (QAbstractButton *button = qobject_cast<QAbstractButton *>(q->sender())) { | - | ||||||||||||||||||
| 523 | - | |||||||||||||||||||
| 524 | - | |||||||||||||||||||
| 525 | - | |||||||||||||||||||
| 526 | - | |||||||||||||||||||
| 527 | const QDialogButtonBox::ButtonRole buttonRole = q->buttonRole(button); | - | ||||||||||||||||||
| 528 | QPointer<QDialogButtonBox> guard(q); | - | ||||||||||||||||||
| 529 | - | |||||||||||||||||||
| 530 | q->clicked(button); | - | ||||||||||||||||||
| 531 | - | |||||||||||||||||||
| 532 | if (!guard) | - | ||||||||||||||||||
| 533 | return; | - | ||||||||||||||||||
| 534 | - | |||||||||||||||||||
| 535 | switch (buttonRole) { | - | ||||||||||||||||||
| 536 | case QPlatformDialogHelper::AcceptRole: | - | ||||||||||||||||||
| 537 | case QPlatformDialogHelper::YesRole: | - | ||||||||||||||||||
| 538 | q->accepted(); | - | ||||||||||||||||||
| 539 | break; | - | ||||||||||||||||||
| 540 | case QPlatformDialogHelper::RejectRole: | - | ||||||||||||||||||
| 541 | case QPlatformDialogHelper::NoRole: | - | ||||||||||||||||||
| 542 | q->rejected(); | - | ||||||||||||||||||
| 543 | break; | - | ||||||||||||||||||
| 544 | case QPlatformDialogHelper::HelpRole: | - | ||||||||||||||||||
| 545 | q->helpRequested(); | - | ||||||||||||||||||
| 546 | break; | - | ||||||||||||||||||
| 547 | default: | - | ||||||||||||||||||
| 548 | break; | - | ||||||||||||||||||
| 549 | } | - | ||||||||||||||||||
| 550 | } | - | ||||||||||||||||||
| 551 | } | - | ||||||||||||||||||
| 552 | - | |||||||||||||||||||
| 553 | void QDialogButtonBoxPrivate::_q_handleButtonDestroyed() | - | ||||||||||||||||||
| 554 | { | - | ||||||||||||||||||
| 555 | QDialogButtonBox * const q = q_func(); | - | ||||||||||||||||||
| 556 | if (QObject *object = q->sender()) { | - | ||||||||||||||||||
| 557 | QBoolBlocker skippy(internalRemove); | - | ||||||||||||||||||
| 558 | q->removeButton(static_cast<QAbstractButton *>(object)); | - | ||||||||||||||||||
| 559 | } | - | ||||||||||||||||||
| 560 | } | - | ||||||||||||||||||
| 561 | void QDialogButtonBox::setCenterButtons(bool center) | - | ||||||||||||||||||
| 562 | { | - | ||||||||||||||||||
| 563 | QDialogButtonBoxPrivate * const d = d_func(); | - | ||||||||||||||||||
| 564 | if (d->center != center) { | - | ||||||||||||||||||
| 565 | d->center = center; | - | ||||||||||||||||||
| 566 | d->resetLayout(); | - | ||||||||||||||||||
| 567 | } | - | ||||||||||||||||||
| 568 | } | - | ||||||||||||||||||
| 569 | - | |||||||||||||||||||
| 570 | bool QDialogButtonBox::centerButtons() const | - | ||||||||||||||||||
| 571 | { | - | ||||||||||||||||||
| 572 | const QDialogButtonBoxPrivate * const d = d_func(); | - | ||||||||||||||||||
| 573 | return d->center; | - | ||||||||||||||||||
| 574 | } | - | ||||||||||||||||||
| 575 | - | |||||||||||||||||||
| 576 | - | |||||||||||||||||||
| 577 | - | |||||||||||||||||||
| 578 | - | |||||||||||||||||||
| 579 | void QDialogButtonBox::changeEvent(QEvent *event) | - | ||||||||||||||||||
| 580 | { | - | ||||||||||||||||||
| 581 | typedef QHash<QPushButton *, QDialogButtonBox::StandardButton> StandardButtonHash; | - | ||||||||||||||||||
| 582 | - | |||||||||||||||||||
| 583 | QDialogButtonBoxPrivate * const d = d_func(); | - | ||||||||||||||||||
| 584 | switch (event->type()) { | - | ||||||||||||||||||
| 585 | case QEvent::StyleChange: | - | ||||||||||||||||||
| 586 | if (!d->standardButtonHash.empty()) { | - | ||||||||||||||||||
| 587 | QStyle *newStyle = style(); | - | ||||||||||||||||||
| 588 | const StandardButtonHash::iterator end = d->standardButtonHash.end(); | - | ||||||||||||||||||
| 589 | for (StandardButtonHash::iterator it = d->standardButtonHash.begin(); it != end; ++it) | - | ||||||||||||||||||
| 590 | it.key()->setStyle(newStyle); | - | ||||||||||||||||||
| 591 | } | - | ||||||||||||||||||
| 592 | - | |||||||||||||||||||
| 593 | - | |||||||||||||||||||
| 594 | - | |||||||||||||||||||
| 595 | - | |||||||||||||||||||
| 596 | d->resetLayout(); | - | ||||||||||||||||||
| 597 | QWidget::changeEvent(event); | - | ||||||||||||||||||
| 598 | break; | - | ||||||||||||||||||
| 599 | default: | - | ||||||||||||||||||
| 600 | QWidget::changeEvent(event); | - | ||||||||||||||||||
| 601 | break; | - | ||||||||||||||||||
| 602 | } | - | ||||||||||||||||||
| 603 | } | - | ||||||||||||||||||
| 604 | - | |||||||||||||||||||
| 605 | - | |||||||||||||||||||
| 606 | - | |||||||||||||||||||
| 607 | - | |||||||||||||||||||
| 608 | bool QDialogButtonBox::event(QEvent *event) | - | ||||||||||||||||||
| 609 | { | - | ||||||||||||||||||
| 610 | QDialogButtonBoxPrivate * const d = d_func(); | - | ||||||||||||||||||
| 611 | if (event->type() == QEvent::Show
| 0 | ||||||||||||||||||
| 612 | QList<QAbstractButton *> acceptRoleList = d->buttonLists[AcceptRole]; | - | ||||||||||||||||||
| 613 | QPushButton *firstAcceptButton = acceptRoleList.isEmpty()
| 0 | ||||||||||||||||||
| 614 | bool hasDefault = false; | - | ||||||||||||||||||
| 615 | QWidget *dialog = 0; | - | ||||||||||||||||||
| 616 | QWidget *p = this; | - | ||||||||||||||||||
| 617 | while (p
| 0 | ||||||||||||||||||
| 618 | p = p->parentWidget(); | - | ||||||||||||||||||
| 619 | if ((
| 0 | ||||||||||||||||||
| 620 | break; never executed: break; | 0 | ||||||||||||||||||
| 621 | } never executed: end of block | 0 | ||||||||||||||||||
| 622 | - | |||||||||||||||||||
| 623 | forconst auto pbs = (QForeachContainer<typename QtPrivate::remove_reference<decltype((dialog ? dialog : this)->findChildren<QPushButton *>())>::type> _container_(((dialog
| 0 | ||||||||||||||||||
| 624 | for (QPushButton *pb = *_container_.i; _container_.control; _container_.control = 0: pbs) { | - | ||||||||||||||||||
| 625 | if (pb->isDefault()
| 0 | ||||||||||||||||||
| 626 | hasDefault = true; | - | ||||||||||||||||||
| 627 | break; never executed: break; | 0 | ||||||||||||||||||
| 628 | } | - | ||||||||||||||||||
| 629 | } never executed: end of block | 0 | ||||||||||||||||||
| 630 | if (!hasDefault
| 0 | ||||||||||||||||||
| 631 | firstAcceptButton->setDefault(true); never executed: firstAcceptButton->setDefault(true); | 0 | ||||||||||||||||||
| 632 | } never executed: else if (event->type() == QEvent::LanguageChangeend of block
| 0 | ||||||||||||||||||
| 633 | d->retranslateStrings(); | - | ||||||||||||||||||
| 634 | } never executed: end of block | 0 | ||||||||||||||||||
| 635 | return never executed: QWidget::event(event);return QWidget::event(event);never executed: return QWidget::event(event); | 0 | ||||||||||||||||||
| 636 | } | - | ||||||||||||||||||
| 637 | - | |||||||||||||||||||
| 638 | - | |||||||||||||||||||
| 639 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |