File indexing completed on 2024-04-21 14:55:52

0001 /*  This file is part of the KDE Libraries
0002  *  Copyright (C) 1998 Thomas Tanghus (tanghus@earthling.net)
0003  *  Additions 1999-2000 by Espen Sand (espen@kde.org)
0004  *                      and Holger Freyther <freyther@kde.org>
0005  *            2005-2009 Olivier Goffart <ogoffart @ kde.org>
0006  *            2006      Tobias Koenig <tokoe@kde.org>
0007  *
0008  *  This library is free software; you can redistribute it and/or
0009  *  modify it under the terms of the GNU Library General Public
0010  *  License as published by the Free Software Foundation; either
0011  *  version 2 of the License, or (at your option) any later version.
0012  *
0013  *  This library is distributed in the hope that it will be useful,
0014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0016  *  Library General Public License for more details.
0017  *
0018  *  You should have received a copy of the GNU Library General Public License
0019  *  along with this library; see the file COPYING.LIB.  If not, write to
0020  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0021  *  Boston, MA 02110-1301, USA.
0022  */
0023 
0024 #ifndef KDIALOG_H
0025 #define KDIALOG_H
0026 
0027 class QPushButton;
0028 class QMenu;
0029 class KDialogPrivate;
0030 
0031 #include <kdelibs4support_export.h>
0032 #include <kconfiggroup.h>
0033 #include <kguiitem.h>
0034 
0035 #include <QDialog>
0036 
0037 /**
0038  * @short A dialog base class with standard buttons and predefined layouts.
0039  *
0040  * Provides basic functionality needed by nearly all dialogs.
0041  *
0042  * It offers the standard action buttons you'd expect to find in a
0043  * dialog as well as the capability to define at most three configurable
0044  * buttons. You can define a main widget that contains your specific
0045  * dialog layout
0046  *
0047  * The class takes care of the geometry management. You only need to define
0048  * a minimum size for the widget you want to use as the main widget.
0049  *
0050  * By default, the dialog is non-modal.
0051  *
0052  * <b>Standard buttons (action buttons):</b>\n
0053  *
0054  * You select which buttons should be displayed, but you do not choose the
0055  * order in which they are displayed. This ensures a standard interface in
0056  * KDE. The button order can be changed, but this ability is only available
0057  * for a central KDE control tool. The following buttons are available:
0058  * OK, Cancel/Close, Apply/Try, Default, Help and three user definable
0059  * buttons: User1, User2 and User3. You must specify the text of the UserN
0060  * buttons. Each button emit a signal, so you can choose to connect that signal.
0061  *
0062  * The default action of the Help button will open the help system if you have
0063  * provided a path to the help text.
0064  * The default action of Ok and Cancel will run QDialog::accept() and QDialog::reject(),
0065  * which you can override by reimplementing slotButtonClicked(). The default
0066  * action of the Close button will close the dialog.
0067  *
0068  * Note that the KDialog will animate a button press
0069  * when the user presses Escape. The button that is enabled is either Cancel,
0070  * Close or the button that is defined by setEscapeButton().
0071  * Your custom dialog code should reimplement the keyPressEvent and
0072  * animate the cancel button so that the dialog behaves like regular
0073  * dialogs.
0074  *
0075  * <b>Layout:</b>\n
0076  *
0077  * The dialog consists of a help area on top (becomes visible if you define
0078  * a help path and use enableLinkedHelp()), the main area which is
0079  * the built-in dialog face or your own widget in the middle and by default
0080  * a button box at the bottom. The button box can also be placed at the
0081  * right edge (to the right of the main widget). Use
0082  * setButtonsOrientation() to control this behavior. A separator
0083  * can be placed above the button box (or to the left when the button box
0084  * is at the right edge).
0085  *
0086  * <b>Standard compliance:</b>\n
0087  *
0088  * The marginHint() and spacingHint() sizes shall be used
0089  * whenever you lay out the interior of a dialog. One special note. If
0090  * you make your own action buttons (OK, Cancel etc), the space
0091  * between the buttons shall be spacingHint(), whereas the space
0092  * above, below, to the right and to the left shall be marginHint().
0093  * If you add a separator line above the buttons, there shall be a
0094  * marginHint() between the buttons and the separator and a
0095  * marginHint() above the separator as well.
0096  *
0097  * <b>Example:</b>\n
0098  *
0099  * \code
0100  *   KDialog *dialog = new KDialog( this );
0101  *   dialog->setCaption( "My title" );
0102  *   dialog->setButtons( KDialog::Ok | KDialog::Cancel | KDialog::Apply );
0103  *
0104  *   FooWidget *widget = new FooWidget( dialog );
0105  *   dialog->setMainWidget( widget );
0106  *   connect( dialog, SIGNAL( applyClicked() ), widget, SLOT( save() ) );
0107  *   connect( dialog, SIGNAL( okClicked() ), widget, SLOT( save() ) );
0108  *   connect( widget, SIGNAL( changed( bool ) ), dialog, SLOT( enableButtonApply( bool ) ) );
0109  *
0110  *   dialog->enableButtonApply( false );
0111  *   dialog->show();
0112  * \endcode
0113  *
0114  * \image html kdialog.png "KDE Dialog example"
0115  *
0116  * This class can be used in many ways. Note that most KDE ui widgets
0117  * and many of KDE core applications use the KDialog so for more
0118  * inspiration you should study the code for these.
0119  *
0120  *
0121  * @see KPageDialog
0122  * @author Thomas Tanghus <tanghus@earthling.net>
0123  * @author Espen Sand <espensa@online.no>
0124  * @author Mirko Boehm <mirko@kde.org>
0125  * @author Olivier Goffart <ogoffart at kde.org>
0126  * @author Tobias Koenig <tokoe@kde.org>
0127  */
0128 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KDialog : public QDialog //krazy:exclude=qclasses
0129 {
0130     Q_OBJECT
0131     Q_ENUMS(ButtonCode)
0132     Q_DECLARE_PRIVATE(KDialog)
0133 
0134 public:
0135 
0136     enum ButtonCode {
0137         None    = 0x00000000,
0138         Help    = 0x00000001, ///< Show Help button. (this button will run the help set with setHelp)
0139         Default = 0x00000002, ///< Show Default button.
0140         Ok      = 0x00000004, ///< Show Ok button. (this button accept()s the dialog; result set to QDialog::Accepted)
0141         Apply   = 0x00000008, ///< Show Apply button.
0142         Try     = 0x00000010, ///< Show Try button.
0143         Cancel  = 0x00000020, ///< Show Cancel-button. (this button reject()s the dialog; result set to QDialog::Rejected)
0144         Close   = 0x00000040, ///< Show Close-button. (this button closes the dialog)
0145         No      = 0x00000080, ///< Show No button. (this button closes the dialog and sets the result to KDialog::No)
0146         Yes     = 0x00000100, ///< Show Yes button. (this button closes the dialog and sets the result to KDialog::Yes)
0147         Reset   = 0x00000200, ///< Show Reset button
0148         Details = 0x00000400, ///< Show Details button. (this button will show the detail widget set with setDetailsWidget)
0149         User1   = 0x00001000, ///< Show User defined button 1.
0150         User2   = 0x00002000, ///< Show User defined button 2.
0151         User3   = 0x00004000, ///< Show User defined button 3.
0152         NoDefault = 0x00008000 ///< Used when specifying a default button; indicates that no button should be marked by default.
0153     };
0154     // TODO KDE5: remove NoDefault and use the value None instead
0155     Q_DECLARE_FLAGS(ButtonCodes, ButtonCode)
0156 
0157     enum ButtonPopupMode {
0158         InstantPopup = 0,
0159         DelayedPopup = 1
0160     };
0161     Q_DECLARE_FLAGS(ButtonPopupModes, ButtonPopupMode)
0162 
0163 public:
0164     /**
0165      * Creates a dialog.
0166      *
0167      * @param parent The parent of the dialog.
0168      * @param flags  The widget flags passed to the QDialog constructor
0169      */
0170     KDELIBS4SUPPORT_DEPRECATED explicit KDialog(QWidget *parent = nullptr, Qt::WindowFlags flags = {});
0171 
0172     /**
0173      * Destroys the dialog.
0174      */
0175     ~KDialog() override;
0176 
0177     /**
0178      * Creates (or recreates) the button box and all the buttons in it.
0179      *
0180      * Note that some combinations are not possible. That means, you can't
0181      * have the following pairs of buttons in a dialog:
0182      * - Default and Details
0183      * - Cancel and Close
0184      * - Ok and Try
0185      *
0186      * This will reset all default KGuiItem of all button.
0187      *
0188      * @param buttonMask Specifies what buttons will be made.
0189      *
0190      * @deprecated Since 5.0 use QDialogButtonBox
0191      */
0192     void setButtons(ButtonCodes buttonMask);
0193 
0194     /**
0195      * Sets the orientation of the button box.
0196      *
0197      * It can be @p Vertical or @p Horizontal. If @p Horizontal
0198      * (default), the button box is positioned at the bottom of the
0199      * dialog. If @p Vertical it will be placed at the right edge of the
0200      * dialog.
0201      *
0202      * @param orientation The button box orientation.
0203      */
0204     void setButtonsOrientation(Qt::Orientation orientation);
0205 
0206     /**
0207      * Sets the button that will be activated when the Escape key
0208      * is pressed.
0209      *
0210      * By default, the Escape key is mapped to either the Cancel or the Close button
0211      * if one of these buttons are defined. The user expects that Escape will
0212      * cancel an operation so use this function with caution.
0213      *
0214      * @param id The button code.
0215      */
0216     void setEscapeButton(ButtonCode id);
0217 
0218     /**
0219      * Sets the button that will be activated when the Enter key
0220      * is pressed.
0221      *
0222      * By default, this is the Ok button if it is present
0223      *
0224      * @param id The button code.
0225      */
0226     void setDefaultButton(ButtonCode id);
0227 
0228     /**
0229      * Returns the button code of the default button,
0230      * or NoDefault if there is no default button.
0231      */
0232     ButtonCode defaultButton() const;
0233 
0234     /**
0235      * Hide or display the a separator line drawn between the action
0236      * buttons an the main widget.
0237      */
0238     void showButtonSeparator(bool state);
0239 
0240     /**
0241      * Hide or display a general action button.
0242      *
0243      *  Only buttons that have
0244      * been created in the constructor can be displayed. This method will
0245      * not create a new button.
0246      *
0247      * @param id Button identifier.
0248      * @param state true display the button(s).
0249      */
0250     void showButton(ButtonCode id, bool state);
0251 
0252     /**
0253      * Sets the text of any button.
0254      *
0255      * @param id The button identifier.
0256      * @param text Button text.
0257      */
0258     void setButtonText(ButtonCode id, const QString &text);
0259 
0260     /**
0261      * Returns the text of any button.
0262      */
0263     QString buttonText(ButtonCode id) const;
0264 
0265     /**
0266      * Sets the icon of any button.
0267      *
0268      * @param id The button identifier.
0269      * @param icon Button icon.
0270      */
0271     void setButtonIcon(ButtonCode id, const QIcon &icon);
0272 
0273     /**
0274      * Returns the icon of any button.
0275      */
0276     QIcon buttonIcon(ButtonCode id) const;
0277 
0278     /**
0279      * Sets the tooltip text of any button.
0280      *
0281      * @param id The button identifier.
0282      * @param text Button text.
0283      */
0284     void setButtonToolTip(ButtonCode id, const QString &text);
0285 
0286     /**
0287      * Returns the tooltip of any button.
0288      */
0289     QString buttonToolTip(ButtonCode id) const;
0290 
0291     /**
0292      * Sets the "What's this?" text of any button.
0293      *
0294      * @param id The button identifier.
0295      * @param text Button text.
0296      */
0297     void setButtonWhatsThis(ButtonCode id, const QString &text);
0298 
0299     /**
0300      * Returns the "What's this?" text of any button.
0301      */
0302     QString buttonWhatsThis(ButtonCode id) const;
0303 
0304     /**
0305      * Sets the KGuiItem directly for the button instead of using 3 methods to
0306      * set the text, tooltip and whatsthis strings. This also allows to set an
0307      * icon for the button which is otherwise not possible for the extra
0308      * buttons beside Ok, Cancel and Apply.
0309      *
0310      * @param id The button identifier.
0311      * @param item The KGuiItem for the button.
0312      */
0313     void setButtonGuiItem(ButtonCode id, const KGuiItem &item);
0314 
0315     /**
0316      * Sets the menu of any button.
0317      *
0318      * @param id The button identifier.
0319      * @param menu The menu.
0320      * @param popupmode Choose if QPushButton setMenu or setDelayedMenu is used
0321      */
0322     void setButtonMenu(ButtonCode id, QMenu *menu, ButtonPopupMode popupmode = InstantPopup);
0323 
0324     /**
0325      * Sets the focus to the button of the passed @p id.
0326      */
0327     void setButtonFocus(ButtonCode id);
0328 
0329     /**
0330      * Convenience method. Sets the initial dialog size.
0331      *
0332      * This method should only be called right before show() or exec().
0333      * The initial size will be ignored if smaller than
0334      * the dialog's minimum size.
0335      *
0336      * @param size Startup size.
0337      */
0338     void setInitialSize(const QSize &size);
0339 
0340     /**
0341      * Convenience method. Add a size to the default minimum size of a
0342      * dialog.
0343      *
0344      * This method should only be called right before show() or exec().
0345      *
0346      * @param size  Size added to minimum size.
0347      */
0348     void incrementInitialSize(const QSize &size);
0349 
0350     /**
0351      * Restores the dialog's size from the configuration according to
0352      * the screen size.
0353      *
0354      * @note the group must be set before calling
0355      *
0356      * @param config The config group to read from.
0357      * @deprecated use KWindowConfig::restoreWindowSize() instead
0358      */
0359 #ifndef KDELIBS4SUPPORT_NO_DEPRECATED
0360     KDELIBS4SUPPORT_DEPRECATED void restoreDialogSize(const KConfigGroup &config);
0361 #endif
0362 
0363     /**
0364      * Saves the dialog's size dependent on the screen dimension either to the
0365      * global or application config file.
0366      *
0367      * @note the group must be set before calling
0368      *
0369      * @param config The config group to read from.
0370      * @param options passed to KConfigGroup::writeEntry()
0371      * @deprecated use KWindowConfig::saveWindowSize() instead
0372      */
0373 #ifndef KDELIBS4SUPPORT_NO_DEPRECATED
0374     KDELIBS4SUPPORT_DEPRECATED void saveDialogSize(KConfigGroup &config, KConfigGroup::WriteConfigFlags options = KConfigGroup::Normal) const;
0375 #endif
0376 
0377     /**
0378      * Returns the help link text.
0379      *
0380      *  If no text has been defined,
0381      * "Get help..." (internationalized) is returned.
0382      *
0383      * @return The help link text.
0384      *
0385      * @see enableLinkedHelp()
0386      * @see setHelpLinkText()
0387      * @see setHelp()
0388      */
0389     QString helpLinkText() const;
0390 
0391     /**
0392      * Returns whether any button is enabled.
0393      */
0394     bool isButtonEnabled(ButtonCode id) const;
0395 
0396     /**
0397      * Returns the button that corresponds to the @p id.
0398      *
0399      * Normally you should not use this function.
0400      * @em Never delete the object returned by this function.
0401      * See also enableButton(), showButton(), setButtonGuiItem().
0402      *
0403      * @param id Identifier of the button.
0404      * @return The button or 0 if the button does not exist.
0405      */
0406     QPushButton *button(ButtonCode id) const;
0407 
0408     /**
0409      * Returns the number of pixels that should be used between a
0410      * dialog edge and the outermost widget(s) according to the KDE standard.
0411      *
0412      * @deprecated Use the style's pixelMetric() function to query individual margins.
0413      * Different platforms may use different values for the four margins.
0414      */
0415     static int marginHint();
0416 
0417     /**
0418      * Returns the number of pixels that should be used between
0419      * widgets inside a dialog according to the KDE standard.
0420      *
0421      * @deprecated Use the style's layoutSpacing() function to query individual spacings.
0422      * Different platforms may use different values depending on widget types and pairs.
0423      */
0424     static int spacingHint();
0425 
0426     /**
0427      * Returns the number of pixels that should be used to visually
0428      * separate groups of related options in a dialog according to
0429      * the KDE standard.
0430      * @since 4.2
0431      */
0432     static int groupSpacingHint();
0433 
0434     /**
0435      * @enum StandardCaptionFlag
0436      * Used to specify how to construct a window caption
0437      *
0438      * @value AppName Indicates that the method shall include
0439      * the application name when making the caption string.
0440      * @value Modified Causes a 'modified' sign will be included in the
0441      * returned string. This is useful when indicating that a file is
0442      * modified, i.e., it contains data that has not been saved.
0443      * @value HIGCompliant The base minimum flags required to align a
0444      * caption with the KDE Human Interface Guidelines
0445      */
0446     enum CaptionFlag {
0447         NoCaptionFlags = 0,
0448         AppNameCaption = 1,
0449         ModifiedCaption = 2,
0450         HIGCompliantCaption = AppNameCaption
0451     };
0452     Q_DECLARE_FLAGS(CaptionFlags, CaptionFlag)
0453 
0454     /**
0455      * Builds a caption that contains the application name along with the
0456      * userCaption using a standard layout.
0457      *
0458      * To make a compliant caption for your window, simply do:
0459      * @p setWindowTitle(KDialog::makeStandardCaption(yourCaption));
0460      *
0461      * To ensure that the caption is appropriate to the desktop in which the
0462      * application is running, pass in a pointer to the window the caption will
0463      * be applied to.
0464      *
0465      * If using a KDialog or KMainWindow subclass, call setCaption instead and
0466      * an appropraite standard caption will be created for you
0467      *
0468      * @param userCaption The caption string you want to display in the
0469      * window caption area. Do not include the application name!
0470      * @param window a pointer to the window this application will apply to
0471      * @param flags
0472      * @return the created caption
0473      */
0474     static QString makeStandardCaption(const QString &userCaption,
0475                                        QWidget *window = nullptr,
0476                                        CaptionFlags flags = HIGCompliantCaption);
0477 
0478     /**
0479      * Resize every layout manager used in @p widget and its nested children.
0480      *
0481      * @param widget The widget used.
0482      * @param margin The new layout margin.
0483      * @param spacing The new layout spacing.
0484      *
0485      * @deprecated Use QLayout functions where necessary. Setting margin and spacing
0486      * values recursively for all children prevents QLayout from creating platform native
0487      * layouts.
0488      */
0489     static void resizeLayout(QWidget *widget, int margin, int spacing);
0490 
0491     /**
0492      * Resize every layout associated with @p lay and its children.
0493      *
0494      * @param lay layout to be resized
0495      * @param margin The new layout margin
0496      * @param spacing The new layout spacing
0497      *
0498      * @deprecated Use QLayout functions where necessary. Setting margin and spacing
0499      * values recursively for all children prevents QLayout from creating platform native
0500      * layouts.
0501      */
0502     static void resizeLayout(QLayout *lay, int margin, int spacing);
0503 
0504     /**
0505      * Centers @p widget on the desktop, taking multi-head setups into
0506      * account. If @p screen is -1, @p widget will be centered on its
0507      * current screen (if it was shown already) or on the primary screen.
0508      * If @p screen is -3, @p widget will be centered on the screen that
0509      * currently contains the mouse pointer.
0510      * @p screen will be ignored if a merged display (like Xinerama) is not
0511      * in use, or merged display placement is not enabled in kdeglobals.
0512      */
0513     static void centerOnScreen(QWidget *widget, int screen = -1);
0514 
0515     /**
0516      * Places @p widget so that it doesn't cover a certain @p area of the screen.
0517      * This is typically used by the "find dialog" so that the match it finds can
0518      * be read.
0519      * For @p screen, see centerOnScreen
0520      * @return true on success (widget doesn't cover area anymore, or never did),
0521      * false on failure (not enough space found)
0522      */
0523     static bool avoidArea(QWidget *widget, const QRect &area, int screen = -1);
0524 
0525     /**
0526      * Sets the main widget of the dialog.
0527      */
0528     void setMainWidget(QWidget *widget);
0529 
0530     /**
0531      * @return The current main widget. Will create a QWidget as the mainWidget
0532      * if none was set before. This way you can write
0533      * \code
0534      *   ui.setupUi(mainWidget());
0535      * \endcode
0536      * when using designer.
0537      */
0538     QWidget *mainWidget();
0539 
0540     /**
0541      * Reimplemented from QDialog.
0542      */
0543     QSize sizeHint() const override;
0544 
0545     /**
0546      * Reimplemented from QDialog.
0547      */
0548     QSize minimumSizeHint() const override;
0549 
0550     /**
0551      * Allow embedding the dialogs based on KDialog into a graphics view. By default embedding is not allowed, dialogs
0552      * will appear as separate windows.
0553      * @since 4.6
0554     */
0555     static void setAllowEmbeddingInGraphicsView(bool allowEmbedding);
0556 
0557 public Q_SLOTS:
0558     /**
0559      * Make a KDE compliant caption.
0560      *
0561      * @param caption Your caption. Do @p not include the application name
0562      * in this string. It will be added automatically according to the KDE
0563      * standard.
0564      *
0565      * @deprecated Since 5.0 use QWidget::setWindowTitle
0566      */
0567     virtual void setCaption(const QString &caption);
0568 
0569     /**
0570      * Makes a KDE compliant caption.
0571      *
0572      * @param caption Your caption. @em Do @em not include the application name
0573      * in this string. It will be added automatically according to the KDE
0574      * standard.
0575      * @param modified Specify whether the document is modified. This displays
0576      * an additional sign in the title bar, usually "**".
0577      *
0578      * @deprecated Since 5.0 use QWidget::setWindowTitle and QWidget::setWindowModified.
0579      */
0580     virtual void setCaption(const QString &caption, bool modified);
0581 
0582     /**
0583      * Make a plain caption without any modifications.
0584      *
0585      * @param caption Your caption. This is the string that will be
0586      * displayed in the window title.
0587      */
0588     virtual void setPlainCaption(const QString &caption);
0589 
0590     /**
0591      * Enable or disable (gray out) a general action button.
0592      *
0593      * @param id Button identifier.
0594      * @param state @p true enables the button(s).
0595      */
0596     void enableButton(ButtonCode id, bool state);
0597 
0598     /**
0599      * Enable or disable (gray out) the OK button.
0600      *
0601      * @param state @p true enables the button.
0602      */
0603     void enableButtonOk(bool state);
0604 
0605     /**
0606      * Enable or disable (gray out) the Apply button.
0607      *
0608      * @param state true enables the button.
0609      */
0610     void enableButtonApply(bool state);
0611 
0612     /**
0613      * Enable or disable (gray out) the Cancel button.
0614      *
0615      * @param state true enables the button.
0616      */
0617     void enableButtonCancel(bool state);
0618 
0619     /**
0620      * Display or hide the help link area on the top of the dialog.
0621      *
0622      * @param state @p true will display the area.
0623      *
0624      * @see helpLinkText()
0625      * @see setHelpLinkText()
0626      * @see setHelp()
0627      */
0628     void enableLinkedHelp(bool state);
0629 
0630     /**
0631      * Sets the text that is shown as the linked text.
0632      *
0633      * If text is empty,
0634      * the text "Get help..." (internationalized) is used instead.
0635      *
0636      * @param text The link text.
0637      *
0638      * @see helpLinkText()
0639      * @see enableLinkedHelp()
0640      * @see setHelp()
0641      */
0642     void setHelpLinkText(const QString &text);
0643 
0644     /**
0645      * Sets the help path and topic.
0646      *
0647      * @param anchor Defined anchor in your docbook sources
0648      * @param appname Defines the appname the help belongs to
0649      *                If empty it's the current one
0650      *
0651      * @note The help button works differently for the class
0652      * KCMultiDialog, so it does not make sense to call this
0653      * function for Dialogs of that type.  See
0654      * KCMultiDialog::slotHelp() for more information.
0655      */
0656     void setHelp(const QString &anchor, const QString &appname = QString());
0657 
0658     /**
0659      * Returns the status of the Details button.
0660      */
0661     bool isDetailsWidgetVisible() const;
0662 
0663     /**
0664      * Sets the status of the Details button.
0665      */
0666     void setDetailsWidgetVisible(bool visible);
0667 
0668     /**
0669      * Sets the widget that gets shown when "Details" is enabled.
0670      *
0671      * The dialog takes over ownership of the widget.
0672      * Any previously set widget gets deleted.
0673      */
0674     void setDetailsWidget(QWidget *detailsWidget);
0675 
0676     /**
0677      * Destruct the dialog delayed.
0678      *
0679      * You can call this function from slots like closeClicked() and hidden().
0680      * You should not use the dialog any more after calling this function.
0681      * @deprecated use hide()+deleteLater()
0682      */
0683     void delayedDestruct();
0684 
0685 Q_SIGNALS:
0686     /**
0687      * Emitted when the margin size and/or spacing size
0688      * have changed.
0689      *
0690      * Use marginHint() and spacingHint() in your slot
0691      * to get the new values.
0692      *
0693      * @deprecated This signal is not emitted. Listen to QEvent::StyleChange events instead.
0694      */
0695     void layoutHintChanged();
0696 
0697     /**
0698      * The Help button was pressed. This signal is only emitted if
0699      * slotButtonClicked() is not replaced
0700      */
0701     void helpClicked();
0702 
0703     /**
0704      * The Default button was pressed. This signal is only emitted if
0705      * slotButtonClicked() is not replaced
0706      */
0707     void defaultClicked();
0708 
0709     /**
0710      * The Reset button was pressed. This signal is only emitted if
0711      * slotButtonClicked() is not replaced
0712      */
0713     void resetClicked();
0714 
0715     /**
0716      * The User3 button was pressed. This signal is only emitted if
0717      * slotButtonClicked() is not replaced
0718      */
0719     void user3Clicked();
0720 
0721     /**
0722      * The User2 button was pressed. This signal is only emitted if
0723      * slotButtonClicked() is not replaced
0724      */
0725     void user2Clicked();
0726 
0727     /**
0728      * The User1 button was pressed. This signal is only emitted if
0729      * slotButtonClicked() is not replaced
0730      */
0731     void user1Clicked();
0732 
0733     /**
0734      * The Apply button was pressed. This signal is only emitted if
0735      * slotButtonClicked() is not replaced
0736      */
0737     void applyClicked();
0738 
0739     /**
0740      * The Try button was pressed. This signal is only emitted if
0741      * slotButtonClicked() is not replaced
0742      */
0743     void tryClicked();
0744 
0745     /**
0746      * The OK button was pressed. This signal is only emitted if
0747      * slotButtonClicked() is not replaced
0748      */
0749     void okClicked();
0750 
0751     /**
0752      * The Yes button was pressed. This signal is only emitted if
0753      * slotButtonClicked() is not replaced
0754      */
0755     void yesClicked();
0756 
0757     /**
0758      * The No button was pressed. This signal is only emitted if
0759      * slotButtonClicked() is not replaced
0760      */
0761     void noClicked();
0762 
0763     /**
0764      * The Cancel button was pressed. This signal is only emitted if
0765      * slotButtonClicked() is not replaced
0766      */
0767     void cancelClicked();
0768 
0769     /**
0770      * The Close button was pressed. This signal is only emitted if
0771      * slotButtonClicked() is not replaced
0772      */
0773     void closeClicked();
0774 
0775     /**
0776      * A button has been pressed. This signal is only emitted if
0777      * slotButtonClicked() is not replaced
0778      * @param button is the code of the pressed button.
0779      */
0780     void buttonClicked(KDialog::ButtonCode button);
0781 
0782     /**
0783      * The dialog is about to be hidden.
0784      *
0785      * A dialog is hidden after a user clicks a button that ends
0786      * the dialog or when the user switches to another desktop or
0787      * minimizes the dialog.
0788      */
0789     void hidden();
0790 
0791     /**
0792      * The dialog has finished.
0793      *
0794      * A dialog emits finished after a user clicks a button that ends
0795      * the dialog.
0796      *
0797      * This signal is also emitted when you call hide()
0798      *
0799      * If you have stored a pointer to the
0800      * dialog do @em not try to delete the pointer in the slot that is
0801      * connected to this signal.
0802      *
0803      * You should use deleteLater() instead.
0804      */
0805     void finished();
0806 
0807     /**
0808      * The detailsWidget is about to get shown. This is your last chance
0809      * to call setDetailsWidget if you haven't done so yet.
0810      */
0811     void aboutToShowDetails();
0812 
0813 protected:
0814     /**
0815      * Emits the #hidden signal. You can connect to that signal to
0816      * detect when a dialog has been closed.
0817      */
0818     void hideEvent(QHideEvent *) override;
0819 
0820     /**
0821      * Detects when a dialog is being closed from the window manager
0822      * controls. If the Cancel or Close button is present then the button
0823      * is activated. Otherwise standard QDialog behavior
0824      * will take place.
0825      */
0826     void closeEvent(QCloseEvent *e) override;
0827 
0828     /**
0829      * @internal
0830      */
0831     void keyPressEvent(QKeyEvent *) override;
0832 
0833 protected Q_SLOTS:
0834     /**
0835      * Activated when the button @p button is clicked
0836      *
0837      * Sample that shows how to catch and handle button clicks within
0838      * an own dialog;
0839      * @code
0840      * class MyDialog : public KDialog {
0841      *     protected Q_SLOTS:
0842      *         virtual void slotButtonClicked(int button) {
0843      *             if (button == KDialog::Ok)
0844      *                 accept();
0845      *             else
0846      *                 KDialog::slotButtonClicked(button);
0847      *         }
0848      * }
0849      * @endcode
0850      *
0851      * @param button is the type @a KDialog::ButtonCode
0852      *
0853      * @deprecated since 5.0 use QDialogButtonBox and connect to the clicked signal
0854      */
0855     virtual void slotButtonClicked(int button);
0856 
0857     /**
0858      * Updates the margins and spacings.
0859      *
0860      * @deprecated KDialog respects the style's margins and spacings automatically. Calling
0861      * this function has no effect.
0862      */
0863     void updateGeometry();
0864 
0865 protected:
0866     KDialog(KDialogPrivate &dd, QWidget *parent, Qt::WindowFlags flags = {});
0867     KDialogPrivate *const d_ptr;
0868 
0869 private:
0870     Q_DISABLE_COPY(KDialog)
0871     Q_PRIVATE_SLOT(d_ptr, void queuedLayoutUpdate())
0872     Q_PRIVATE_SLOT(d_ptr, void helpLinkClicked())
0873 };
0874 
0875 Q_DECLARE_OPERATORS_FOR_FLAGS(KDialog::ButtonCodes)
0876 Q_DECLARE_OPERATORS_FOR_FLAGS(KDialog::CaptionFlags)
0877 
0878 #endif // KDIALOG_H