File indexing completed on 2024-05-12 16:02:08

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