Qt 4.8
Public Functions | Public Variables | List of all members
QDialogButtonBoxPrivate Class Reference
Inheritance diagram for QDialogButtonBoxPrivate:
QWidgetPrivate QObjectPrivate QObjectData

Public Functions

void _q_handleButtonClicked ()
 
void _q_handleButtonDestroyed ()
 
void addButton (QAbstractButton *button, QDialogButtonBox::ButtonRole role, bool doLayout=true)
 
void addButtonsToLayout (const QList< QAbstractButton *> &buttonList, bool reverse)
 
QPushButtoncreateButton (QDialogButtonBox::StandardButton button, bool doLayout=true)
 
void createStandardButtons (QDialogButtonBox::StandardButtons buttons)
 
void initLayout ()
 
void layoutButtons ()
 
 QDialogButtonBoxPrivate (Qt::Orientation orient)
 
void resetLayout ()
 
void retranslateStrings ()
 
const char * standardButtonText (QDialogButtonBox::StandardButton sbutton) const
 
- Public Functions inherited from QWidgetPrivate
void _q_showIfNotHidden ()
 
virtual void aboutToDestroy ()
 
void activateChildLayoutsRecursively ()
 
QSize adjustedSize () const
 
void adjustQuitOnCloseAttribute ()
 
QInputContextassignedInputContext () const
 
QPainterbeginSharedPainter ()
 
QWidgetchildAt_helper (const QPoint &, bool) const
 
QWidgetchildAtRecursiveHelper (const QPoint &p, bool, bool includeFrame=false) const
 
QRect clipRect () const
 
QRegion clipRegion () const
 
void clipToEffectiveMask (QRegion &region) const
 
bool close_helper (CloseMode mode)
 
void create_sys (WId window, bool initializeWindow, bool destroyOldWindow)
 
QWindowSurfacecreateDefaultWindowSurface ()
 
QWindowSurfacecreateDefaultWindowSurface_sys ()
 
void createExtra ()
 Creates the widget extra data. More...
 
void createRecursively ()
 
void createSysExtra ()
 
void createTLExtra ()
 
void createTLSysExtra ()
 
void createWinId (WId id=0)
 
void deactivateWidgetCleanup ()
 
void deleteExtra ()
 Deletes the widget extra data. More...
 
void deleteSysExtra ()
 
void deleteTLSysExtra ()
 
void drawWidget (QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter=0, QWidgetBackingStore *backingStore=0)
 
QWidgeteffectiveFocusWidget ()
 
QRect effectiveRectFor (const QRect &rect) const
 
bool endSharedPainter ()
 
void enforceNativeChildren ()
 
QWExtraextraData () const
 
QRect frameStrut () const
 
void getLayoutItemMargins (int *left, int *top, int *right, int *bottom) const
 
const QRegiongetOpaqueChildren () const
 
void handleSoftwareInputPanel (Qt::MouseButton button, bool clickCausedFocus)
 
virtual bool hasHeightForWidth () const
 
void hide_helper ()
 
void hide_sys ()
 Platform-specific part of QWidget::hide(). More...
 
void hideChildren (bool spontaneous)
 
void inheritStyle ()
 
void init (QWidget *desktopWidget, Qt::WindowFlags f)
 
QInputContextinputContext () const
 
void invalidateBuffer (const QRegion &)
 Invalidates the rgn (in widget's coordinates) of the backing store, i.e. More...
 
void invalidateBuffer (const QRect &)
 This function is equivalent to calling invalidateBuffer(QRegion(rect), ...), but is more efficient as it eliminates QRegion operations/allocations and can use the rect more precisely for additional cut-offs. More...
 
void invalidateBuffer_resizeHelper (const QPoint &oldPos, const QSize &oldSize)
 Invalidates the buffer when the widget is resized. More...
 
void invalidateGraphicsEffectsRecursively ()
 
bool isAboutToShow () const
 
bool isBackgroundInherited () const
 
bool isOverlapped (const QRect &) const
 
void lower_sys ()
 
QPoint mapFromGlobal (const QPoint &pos) const
 
QPoint mapToGlobal (const QPoint &pos) const
 
QWidgetBackingStoremaybeBackingStore () const
 
QTLWExtramaybeTopData () const
 
void moveRect (const QRect &, int dx, int dy)
 
bool nativeChildrenForced () const
 
QFont naturalWidgetFont (uint inheritedMask) const
 
QPalette naturalWidgetPalette (uint inheritedMask) const
 Returns the palette that the widget w inherits from its ancestors and QApplication::palette. More...
 
void paintBackground (QPainter *, const QRegion &, int flags=DrawAsRoot) const
 
bool paintOnScreen () const
 
void paintSiblingsRecursive (QPaintDevice *pdev, const QObjectList &children, int index, const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter, QWidgetBackingStore *backingStore)
 
bool pointInsideRectAndMask (const QPoint &) const
 
QRegion prepareToRender (const QRegion &region, QWidget::RenderFlags renderFlags)
 
void propagatePaletteChange ()
 Propagate this widget's palette to all children, except style sheet widgets, and windows that don't enable window propagation (palettes don't normally propagate to windows). More...
 
 QWidgetPrivate (int version=QObjectPrivateVersion)
 
void raise_sys ()
 
QPaintDeviceredirected (QPoint *offset) const
 
void registerDropSite (bool)
 
void render (QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags, bool readyToRender)
 
void render_helper (QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags)
 
void repaint_sys (const QRegion &rgn)
 
void reparentFocusWidgets (QWidget *oldtlw)
 
void resolveFont ()
 Determine which font is implicitly imposed on this widget by its ancestors and QApplication::font, resolve this against its own font (attributes from the implicit font are copied over). More...
 
void resolveLayoutDirection ()
 
void resolveLocale ()
 
void resolvePalette ()
 Determine which palette is inherited from this widget's ancestors and QApplication::palette, resolve this against this widget's palette (attributes from the inherited palette are copied over this widget's palette). More...
 
void restoreRedirected ()
 
void scroll_sys (int dx, int dy)
 
void scroll_sys (int dx, int dy, const QRect &r)
 
void scrollChildren (int dx, int dy)
 
void scrollRect (const QRect &, int dx, int dy)
 
void sendPendingMoveAndResizeEvents (bool recursive=false, bool disableUpdates=false)
 
void sendStartupMessage (const char *message) const
 Platform-specific part of QWidget::show(). More...
 
void setConstraints_sys ()
 
void setCursor_sys (const QCursor &cursor)
 
void setDirtyOpaqueRegion ()
 
void setEnabled_helper (bool)
 
void setFocus_sys ()
 
void setFont_helper (const QFont &font)
 
void setGeometry_sys (int, int, int, int, bool)
 
void setLayoutDirection_helper (Qt::LayoutDirection)
 
void setLayoutItemMargins (int left, int top, int right, int bottom)
 
void setLayoutItemMargins (QStyle::SubElement element, const QStyleOption *opt=0)
 
void setLocale_helper (const QLocale &l, bool forceUpdate=false)
 
void setMask_sys (const QRegion &)
 
bool setMaximumSize_helper (int &maxw, int &maxh)
 
bool setMinimumSize_helper (int &minw, int &minh)
 
void setModal_sys ()
 
void setNetWmWindowTypes ()
 
void setOpaque (bool opaque)
 
void setPalette_helper (const QPalette &)
 
void setParent_sys (QWidget *parent, Qt::WindowFlags)
 
void setRedirected (QPaintDevice *replacement, const QPoint &offset)
 
void setSharedPainter (QPainter *painter)
 
void setStyle_helper (QStyle *newStyle, bool propagate, bool metalHack=false)
 
void setUpdatesEnabled_helper (bool)
 
void setWindowFilePath_helper (const QString &filePath)
 
void setWindowIcon_helper ()
 
void setWindowIcon_sys (bool forceReset=false)
 
void setWindowIconText_helper (const QString &cap)
 
void setWindowIconText_sys (const QString &cap)
 
void setWindowOpacity_sys (qreal opacity)
 
void setWindowRole ()
 
void setWindowTitle_helper (const QString &cap)
 
void setWindowTitle_sys (const QString &cap)
 
void setWinId (WId)
 
QPaintersharedPainter () const
 
void show_helper ()
 
void show_recursive ()
 Makes the widget visible in the isVisible() meaning of the word. More...
 
void show_sys ()
 Platform-specific part of QWidget::show(). More...
 
void showChildren (bool spontaneous)
 
void stackUnder_sys (QWidget *)
 
void subtractOpaqueChildren (QRegion &rgn, const QRect &clipRect) const
 
void subtractOpaqueSiblings (QRegion &source, bool *hasDirtySiblingsAbove=0, bool alsoNonOpaque=false) const
 
void syncBackingStore ()
 
void syncBackingStore (const QRegion &region)
 
QTLWExtratopData () const
 
void unsetCursor_sys ()
 
void updateFont (const QFont &)
 Assign font to this widget, and propagate it to all children, except style sheet widgets (handled differently) and windows that don't enable window propagation. More...
 
void updateFrameStrut ()
 Computes the frame rectangle when needed. More...
 
void updateGeometry_helper (bool forceUpdate)
 
void updateIsOpaque ()
 
void updateIsTranslucent ()
 
void updateSystemBackground ()
 
void updateX11AcceptFocus ()
 
void x11UpdateIsOpaque ()
 
 ~QWidgetPrivate ()
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Public Variables

QBoxLayoutbuttonLayout
 
QList< QAbstractButton * > buttonLists [QDialogButtonBox::NRoles]
 
bool center
 
bool internalRemove
 
QDialogButtonBox::ButtonLayout layoutPolicy
 
Qt::Orientation orientation
 
QHash< QPushButton *, QDialogButtonBox::StandardButtonstandardButtonHash
 
- Public Variables inherited from QWidgetPrivate
QString accessibleDescription
 
QString accessibleName
 
QList< QAction * > actions
 
QPalette::ColorRole bg_role: 8
 
signed char bottomLayoutItemMargin
 
short bottommargin
 
QWidgetData data
 
QRegion dirty
 
uint dirtyOpaqueChildren: 1
 
QWExtraextra
 
QPaintEngineextraPaintEngine
 
QPalette::ColorRole fg_role: 8
 
QWidgetfocus_child
 
QWidgetfocus_next
 
QWidgetfocus_prev
 
QMap< Qt::GestureType, Qt::GestureFlags > gestureContext
 
QGraphicsEffectgraphicsEffect
 
Qt::HANDLE hd
 
uint high_attributes [4]
 
QPointer< QInputContextic
 
Qt::InputMethodHints imHints
 
uint inDirtyList: 1
 
uint inheritedFontResolveMask
 
uint inheritedPaletteResolveMask
 
uint inheritsInputMethodHints: 1
 
uint inSetParent: 1
 
uint isGLWidget: 1
 
uint isMoved: 1
 
uint isOpaque: 1
 
uint isScrolled: 1
 
QLayoutlayout
 
signed char leftLayoutItemMargin
 
short leftmargin
 
QLocale locale
 
QRegionneedsFlush
 
QRegion opaqueChildren
 
Qt::HANDLE picture
 
const QMetaObjectpolished
 
QPaintDeviceredirectDev
 
QPoint redirectOffset
 
signed char rightLayoutItemMargin
 
short rightmargin
 
QSizePolicy size_policy
 
QString statusTip
 
QString toolTip
 
signed char topLayoutItemMargin
 
short topmargin
 
uint usesDoubleBufferedGLContext: 1
 
QString whatsThis
 
QWidgetItemV2widgetItem
 
QX11Info xinfo
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Additional Inherited Members

- Public Types inherited from QWidgetPrivate
enum  CloseMode { CloseNoEvent, CloseWithEvent, CloseWithSpontaneousEvent }
 
enum  Direction { DirectionNorth = 0x01, DirectionEast = 0x10, DirectionSouth = 0x02, DirectionWest = 0x20 }
 
enum  DrawWidgetFlags {
  DrawAsRoot = 0x01, DrawPaintOnScreen = 0x02, DrawRecursive = 0x04, DrawInvisible = 0x08,
  DontSubtractOpaqueChildren = 0x10, DontSetCompositionMode = 0x20, DontDrawOpaqueChildren = 0x40, DontDrawNativeChildren = 0x80
}
 
- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 
- Static Public Functions inherited from QWidgetPrivate
static void adjustFlags (Qt::WindowFlags &flags, QWidget *w=0)
 
static QGraphicsProxyWidgetnearestGraphicsProxyWidget (const QWidget *origin)
 Finds the nearest widget embedded in a graphics proxy widget along the chain formed by this widget and its ancestors. More...
 
static int pointToRect (const QPoint &p, const QRect &r)
 
static QRect screenGeometry (const QWidget *widget)
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 
- Static Public Variables inherited from QWidgetPrivate
static QWidgetSetallWidgets = 0
 
static int instanceCounter = 0
 
static QWidgetkeyboardGrabber = 0
 
static QWidgetMappermapper = 0
 
static int maxInstances = 0
 
static QWidgetmouseGrabber = 0
 

Detailed Description

Definition at line 291 of file qdialogbuttonbox.cpp.

Constructors and Destructors

◆ QDialogButtonBoxPrivate()

QDialogButtonBoxPrivate::QDialogButtonBoxPrivate ( Qt::Orientation  orient)

Definition at line 327 of file qdialogbuttonbox.cpp.

328  : orientation(orient), buttonLayout(0), internalRemove(false), center(false)
329 {
330 }

Functions

◆ _q_handleButtonClicked()

void QDialogButtonBoxPrivate::_q_handleButtonClicked ( )

Definition at line 1162 of file qdialogbuttonbox.cpp.

Referenced by addButton().

1163 {
1165  if (QAbstractButton *button = qobject_cast<QAbstractButton *>(q->sender())) {
1166  emit q->clicked(button);
1167 
1168  switch (q->buttonRole(button)) {
1169  case AcceptRole:
1170  case YesRole:
1171  emit q->accepted();
1172  break;
1173  case RejectRole:
1174  case NoRole:
1175  emit q->rejected();
1176  break;
1177  case HelpRole:
1178  emit q->helpRequested();
1179  break;
1180  default:
1181  break;
1182  }
1183  }
1184 }
The QAbstractButton class is the abstract base class of button widgets, providing functionality commo...
#define Q_Q(Class)
Definition: qglobal.h:2483
#define emit
Definition: qobjectdefs.h:76
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...

◆ _q_handleButtonDestroyed()

void QDialogButtonBoxPrivate::_q_handleButtonDestroyed ( )

Definition at line 1186 of file qdialogbuttonbox.cpp.

Referenced by addButton().

1187 {
1189  if (QObject *object = q->sender()) {
1190  QBoolBlocker skippy(internalRemove);
1191  q->removeButton(static_cast<QAbstractButton *>(object));
1192  }
1193 }
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
Definition: qobject.cpp:2327
#define Q_Q(Class)
Definition: qglobal.h:2483
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...

◆ addButton()

void QDialogButtonBoxPrivate::addButton ( QAbstractButton button,
QDialogButtonBox::ButtonRole  role,
bool  doLayout = true 
)

Definition at line 580 of file qdialogbuttonbox.cpp.

Referenced by createButton().

582 {
584  QObject::connect(button, SIGNAL(clicked()), q, SLOT(_q_handleButtonClicked()));
585  QObject::connect(button, SIGNAL(destroyed()), q, SLOT(_q_handleButtonDestroyed()));
586  buttonLists[role].append(button);
587 #if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION)
588  QAction *action = createSoftKey(button, role);
589  softKeyActions.insert(button, action);
590  new QDialogButtonEnabledProxy(action, button, action);
591 #endif
592  if (doLayout)
593  layoutButtons();
594 }
QList< QAbstractButton * > buttonLists[QDialogButtonBox::NRoles]
#define SLOT(a)
Definition: qobjectdefs.h:226
#define Q_Q(Class)
Definition: qglobal.h:2483
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64

◆ addButtonsToLayout()

void QDialogButtonBoxPrivate::addButtonsToLayout ( const QList< QAbstractButton *> &  buttonList,
bool  reverse 
)

Definition at line 371 of file qdialogbuttonbox.cpp.

Referenced by layoutButtons().

373 {
374  int start = reverse ? buttonList.count() - 1 : 0;
375  int end = reverse ? -1 : buttonList.count();
376  int step = reverse ? -1 : 1;
377 
378  for (int i = start; i != end; i += step) {
379  QAbstractButton *button = buttonList.at(i);
380  buttonLayout->addWidget(button);
381  button->show();
382  }
383 }
The QAbstractButton class is the abstract base class of button widgets, providing functionality commo...
static C reverse(const C &l)
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=0)
Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment...
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
void show()
Shows the widget and its child widgets.
static const KeyPair *const end

◆ createButton()

QPushButton * QDialogButtonBoxPrivate::createButton ( QDialogButtonBox::StandardButton  button,
bool  doLayout = true 
)

Definition at line 502 of file qdialogbuttonbox.cpp.

Referenced by createStandardButtons().

504 {
506  const char *buttonText = 0;
507  int icon = 0;
508 
509  switch (sbutton) {
512  break;
515  break;
518  break;
521  break;
524  break;
527  break;
530  break;
533  break;
536  break;
539  break;
542  break;
550  break;
552  return 0;
553  ;
554  }
555  buttonText = standardButtonText(sbutton);
556 
557  QPushButton *button = new QPushButton(QDialogButtonBox::tr(buttonText), q);
558  QStyle *style = q->style();
559  if (style->styleHint(QStyle::SH_DialogButtonBox_ButtonsHaveIcons, 0, q) && icon != 0)
560  button->setIcon(style->standardIcon(QStyle::StandardPixmap(icon), 0, q));
561  if (style != QApplication::style()) // Propagate style
562  button->setStyle(style);
563  standardButtonHash.insert(button, sbutton);
564  if (roleFor(sbutton) != QDialogButtonBox::InvalidRole) {
565  addButton(button, roleFor(sbutton), doLayout);
566  } else {
567  qWarning("QDialogButtonBox::createButton: Invalid ButtonRole, button not added");
568  }
569 
570 #ifdef Q_WS_MAC
571  // Since mnemonics is off by default on Mac, we add a Cmd-D
572  // shortcut here to e.g. make the "Don't Save" button work nativly:
573  if (sbutton == QDialogButtonBox::Discard)
574  button->setShortcut(QKeySequence(QLatin1String("Ctrl+D")));
575 #endif
576 
577  return button;
578 }
void addButton(QAbstractButton *button, QDialogButtonBox::ButtonRole role, bool doLayout=true)
void setShortcut(const QKeySequence &key)
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
static QDialogButtonBox::ButtonRole roleFor(QDialogButtonBox::StandardButton button)
The QPushButton widget provides a command button.
Definition: qpushbutton.h:57
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QStyle * style()
Returns the application&#39;s style object.
StandardPixmap
This enum describes the available standard pixmaps.
Definition: qstyle.h:755
void setStyle(QStyle *)
Sets the widget&#39;s GUI style to style.
Definition: qwidget.cpp:2772
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
#define Q_Q(Class)
Definition: qglobal.h:2483
const char * standardButtonText(QDialogButtonBox::StandardButton sbutton) const
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=0, const QWidget *widget=0) const
Returns an icon for the given standardIcon.
Definition: qstyle.cpp:2327
Q_CORE_EXPORT void qWarning(const char *,...)
The QKeySequence class encapsulates a key sequence as used by shortcuts.
Definition: qkeysequence.h:72
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...
QHash< QPushButton *, QDialogButtonBox::StandardButton > standardButtonHash
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
Definition: qstyle.h:68
void setIcon(const QIcon &icon)

◆ createStandardButtons()

void QDialogButtonBoxPrivate::createStandardButtons ( QDialogButtonBox::StandardButtons  buttons)

Definition at line 643 of file qdialogbuttonbox.cpp.

644 {
646  while (i <= QDialogButtonBox::LastButton) {
647  if (i & buttons) {
649  }
650  i = i << 1;
651  }
652  layoutButtons();
653 }
static Qt::MouseButtons buttons
QPushButton * createButton(QDialogButtonBox::StandardButton button, bool doLayout=true)
unsigned int uint
Definition: qglobal.h:996
StandardButton
These enums describe flags for standard buttons.

◆ initLayout()

void QDialogButtonBoxPrivate::initLayout ( )

Definition at line 332 of file qdialogbuttonbox.cpp.

Referenced by resetLayout().

333 {
336  bool createNewLayout = buttonLayout == 0
339  if (createNewLayout) {
340  delete buttonLayout;
342  buttonLayout = new QHBoxLayout(q);
343  else
344  buttonLayout = new QVBoxLayout(q);
345  }
346 
347  int left, top, right, bottom;
349  getLayoutItemMargins(&left, &top, &right, &bottom);
350  buttonLayout->setContentsMargins(-left, -top, -right, -bottom);
351 
352  if (!q->testAttribute(Qt::WA_WState_OwnSizePolicy)) {
354  if (orientation == Qt::Vertical)
355  sp.transpose();
356  q->setSizePolicy(sp);
357  q->setAttribute(Qt::WA_WState_OwnSizePolicy, false);
358  }
359 
360  // ### move to a real init() function
361  q->setFocusPolicy(Qt::TabFocus);
362 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
void setLayoutItemMargins(int left, int top, int right, int bottom)
Definition: qwidget.cpp:12860
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
#define Q_Q(Class)
Definition: qglobal.h:2483
QDialogButtonBox::ButtonLayout layoutPolicy
void getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const
Definition: qwidget.cpp:12848
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...
The QHBoxLayout class lines up widgets horizontally.
Definition: qboxlayout.h:129
void setContentsMargins(int left, int top, int right, int bottom)
Sets the left, top, right, and bottom margins to use around the layout.
Definition: qlayout.cpp:502
ButtonLayout
This enum describes the layout policy to be used when arranging the buttons contained in the button b...
The QVBoxLayout class lines up widgets vertically.
Definition: qboxlayout.h:149
Q_CORE_EXPORT QTextStream & left(QTextStream &s)

◆ layoutButtons()

void QDialogButtonBoxPrivate::layoutButtons ( )

Definition at line 385 of file qdialogbuttonbox.cpp.

Referenced by addButton(), createStandardButtons(), and resetLayout().

386 {
388  const int MacGap = 36 - 8; // 8 is the default gap between a widget and a spacer item
389 
390  for (int i = buttonLayout->count() - 1; i >= 0; --i) {
391  QLayoutItem *item = buttonLayout->takeAt(i);
392  if (QWidget *widget = item->widget())
393  widget->hide();
394  delete item;
395  }
396 
397  int tmpPolicy = layoutPolicy;
398 
399  static const int M = 5;
400  static const int ModalRoles[M] = { AcceptRole, RejectRole, DestructiveRole, YesRole, NoRole };
401  if (tmpPolicy == QDialogButtonBox::MacLayout) {
402  bool hasModalButton = false;
403  for (int i = 0; i < M; ++i) {
404  if (!buttonLists[ModalRoles[i]].isEmpty()) {
405  hasModalButton = true;
406  break;
407  }
408  }
409  if (!hasModalButton)
410  tmpPolicy = 4; // Mac modeless
411  }
412 
413  const uint *currentLayout = layouts[orientation == Qt::Vertical][tmpPolicy];
414 
415  if (center)
417 
419 
420  while (*currentLayout != EOL) {
421  int role = (*currentLayout & ~Reverse);
422  bool reverse = (*currentLayout & Reverse);
423 
424  switch (role) {
425  case Stretch:
426  if (!center)
428  break;
429  case AcceptRole: {
430  if (acceptRoleList.isEmpty())
431  break;
432  // Only the first one
433  QAbstractButton *button = acceptRoleList.first();
434  buttonLayout->addWidget(button);
435  button->show();
436  }
437  break;
438  case AlternateRole:
439  {
440  if (acceptRoleList.size() < 2)
441  break;
442  QList<QAbstractButton *> list = acceptRoleList;
443  list.removeFirst();
444  addButtonsToLayout(list, reverse);
445  }
446  break;
447  case DestructiveRole:
448  {
449  const QList<QAbstractButton *> &list = buttonLists[role];
450 
451  /*
452  Mac: Insert a gap on the left of the destructive
453  buttons to ensure that they don't get too close to
454  the help and action buttons (but only if there are
455  some buttons to the left of the destructive buttons
456  (and the stretch, whence buttonLayout->count() > 1
457  and not 0)).
458  */
459  if (tmpPolicy == QDialogButtonBox::MacLayout
460  && !list.isEmpty() && buttonLayout->count() > 1)
461  buttonLayout->addSpacing(MacGap);
462 
463  addButtonsToLayout(list, reverse);
464 
465  /*
466  Insert a gap between the destructive buttons and the
467  accept and reject buttons.
468  */
469  if (tmpPolicy == QDialogButtonBox::MacLayout && !list.isEmpty())
470  buttonLayout->addSpacing(MacGap);
471  }
472  break;
473  case RejectRole:
474  case ActionRole:
475  case HelpRole:
476  case YesRole:
477  case NoRole:
478  case ApplyRole:
479  case ResetRole:
480  addButtonsToLayout(buttonLists[role], reverse);
481  }
482  ++currentLayout;
483  }
484 
485  QWidget *lastWidget = 0;
486  q->setFocusProxy(0);
487  for (int i = 0; i < buttonLayout->count(); ++i) {
488  QLayoutItem *item = buttonLayout->itemAt(i);
489  if (QWidget *widget = item->widget()) {
490  if (lastWidget)
491  QWidget::setTabOrder(lastWidget, widget);
492  else
493  q->setFocusProxy(widget);
494  lastWidget = widget;
495  }
496  }
497 
498  if (center)
500 }
The QAbstractButton class is the abstract base class of button widgets, providing functionality commo...
QLayoutItem * itemAt(int) const
Reimplemented Function
Definition: qboxlayout.cpp:778
QPointer< QWidget > widget
QList< QAbstractButton * > buttonLists[QDialogButtonBox::NRoles]
void addButtonsToLayout(const QList< QAbstractButton *> &buttonList, bool reverse)
static C reverse(const C &l)
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=0)
Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment...
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
#define Q_Q(Class)
Definition: qglobal.h:2483
#define M(row, col)
void addStretch(int stretch=0)
Adds a stretchable space (a QSpacerItem) with zero minimum size and stretch factor stretch to the end...
The QLayoutItem class provides an abstract item that a QLayout manipulates.
Definition: qlayoutitem.h:64
static bool isEmpty(const char *str)
int count() const
Reimplemented Function
Definition: qboxlayout.cpp:769
unsigned int uint
Definition: qglobal.h:996
void removeFirst()
Removes the first item in the list.
Definition: qlist.h:286
QDialogButtonBox::ButtonLayout layoutPolicy
void show()
Shows the widget and its child widgets.
void hide()
Hides the widget.
Definition: qwidget.h:501
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
void setFocusProxy(QWidget *)
Sets the widget&#39;s focus proxy to widget w.
Definition: qwidget.cpp:6537
QLayoutItem * takeAt(int)
Reimplemented Function
Definition: qboxlayout.cpp:787
void addSpacing(int size)
Adds a non-stretchable space (a QSpacerItem) with size size to the end of this box layout...
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.
static void setTabOrder(QWidget *, QWidget *)
Puts the second widget after the first widget in the focus order.
Definition: qwidget.cpp:6975
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
static const uint layouts[2][5][14]

◆ resetLayout()

void QDialogButtonBoxPrivate::resetLayout ( )

Definition at line 364 of file qdialogbuttonbox.cpp.

365 {
366  //delete buttonLayout;
367  initLayout();
368  layoutButtons();
369 }

◆ retranslateStrings()

void QDialogButtonBoxPrivate::retranslateStrings ( )

Definition at line 725 of file qdialogbuttonbox.cpp.

726 {
727  const char *buttonText = 0;
729  while (it != standardButtonHash.end()) {
730  buttonText = standardButtonText(it.value());
731  if (buttonText) {
732  QPushButton *button = it.key();
733  button->setText(QDialogButtonBox::tr(buttonText));
734 #if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION)
735  QAction *action = softKeyActions.value(button, 0);
736  if (action)
737  action->setText(button->text());
738 #endif
739  }
740  ++it;
741  }
742 }
QString text() const
void setText(const QString &text)
#define it(className, varName)
The QPushButton widget provides a command button.
Definition: qpushbutton.h:57
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
const char * standardButtonText(QDialogButtonBox::StandardButton sbutton) const
void setText(const QString &text)
Definition: qaction.cpp:860
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
const Key key(const T &value) const
Returns the first key mapped to value.
Definition: qhash.h:674
QHash< QPushButton *, QDialogButtonBox::StandardButton > standardButtonHash
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:464
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64

◆ standardButtonText()

const char * QDialogButtonBoxPrivate::standardButtonText ( QDialogButtonBox::StandardButton  sbutton) const

Definition at line 655 of file qdialogbuttonbox.cpp.

Referenced by createButton(), and retranslateStrings().

656 {
657  const char *buttonText = 0;
658  bool gnomeLayout = (layoutPolicy == QDialogButtonBox::GnomeLayout);
659  switch (sbutton) {
661  buttonText = gnomeLayout ? QT_TRANSLATE_NOOP("QDialogButtonBox", "&OK") : QT_TRANSLATE_NOOP("QDialogButtonBox", "OK");
662  break;
664  buttonText = gnomeLayout ? QT_TRANSLATE_NOOP("QDialogButtonBox", "&Save") : QT_TRANSLATE_NOOP("QDialogButtonBox", "Save");
665  break;
667  buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Open");
668  break;
670  buttonText = gnomeLayout ? QT_TRANSLATE_NOOP("QDialogButtonBox", "&Cancel") : QT_TRANSLATE_NOOP("QDialogButtonBox", "Cancel");
671  break;
673  buttonText = gnomeLayout ? QT_TRANSLATE_NOOP("QDialogButtonBox", "&Close") : QT_TRANSLATE_NOOP("QDialogButtonBox", "Close");
674  break;
676  buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Apply");
677  break;
679  buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Reset");
680  break;
682  buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Help");
683  break;
686  buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Don't Save");
688  buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Close without Saving");
689  else
690  buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Discard");
691  break;
693  buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "&Yes");
694  break;
696  buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Yes to &All");
697  break;
699  buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "&No");
700  break;
702  buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "N&o to All");
703  break;
705  buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Save All");
706  break;
708  buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Abort");
709  break;
711  buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Retry");
712  break;
714  buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Ignore");
715  break;
717  buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Restore Defaults");
718  break;
720  ;
721  } // switch
722  return buttonText;
723 }
#define QT_TRANSLATE_NOOP(scope, x)
Marks the string literal sourceText for dynamic translation in the given context; i...
Definition: qglobal.h:2487
QDialogButtonBox::ButtonLayout layoutPolicy

Properties

◆ buttonLayout

QBoxLayout* QDialogButtonBoxPrivate::buttonLayout

Definition at line 306 of file qdialogbuttonbox.cpp.

Referenced by addButtonsToLayout(), initLayout(), and layoutButtons().

◆ buttonLists

QList<QAbstractButton *> QDialogButtonBoxPrivate::buttonLists[QDialogButtonBox::NRoles]

Definition at line 298 of file qdialogbuttonbox.cpp.

Referenced by addButton(), and layoutButtons().

◆ center

bool QDialogButtonBoxPrivate::center

Definition at line 308 of file qdialogbuttonbox.cpp.

Referenced by layoutButtons().

◆ internalRemove

bool QDialogButtonBoxPrivate::internalRemove

Definition at line 307 of file qdialogbuttonbox.cpp.

◆ layoutPolicy

QDialogButtonBox::ButtonLayout QDialogButtonBoxPrivate::layoutPolicy

Definition at line 305 of file qdialogbuttonbox.cpp.

Referenced by initLayout(), layoutButtons(), and standardButtonText().

◆ orientation

Qt::Orientation QDialogButtonBoxPrivate::orientation

Definition at line 304 of file qdialogbuttonbox.cpp.

Referenced by initLayout(), and layoutButtons().

◆ standardButtonHash

QHash<QPushButton *, QDialogButtonBox::StandardButton> QDialogButtonBoxPrivate::standardButtonHash

Definition at line 299 of file qdialogbuttonbox.cpp.

Referenced by createButton(), and retranslateStrings().


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