Warning, file /office/calligra/libs/widgets/KoDialog.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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 KODIALOG_H 0025 #define KODIALOG_H 0026 0027 class QPushButton; 0028 class QMenu; 0029 class KoDialogPrivate; 0030 0031 #include <kowidgets_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 KoDialog 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 * KoDialog *dialog = new KoDialog( this ); 0101 * dialog->setCaption( "My title" ); 0102 * dialog->setButtons( KoDialog::Ok | KoDialog::Cancel | KoDialog::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 KoDialog 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 KOWIDGETS_EXPORT KoDialog : public QDialog //krazy:exclude=qclasses 0129 { 0130 Q_OBJECT 0131 Q_ENUMS(ButtonCode) 0132 Q_DECLARE_PRIVATE(KoDialog) 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 KoDialog::No) 0146 Yes = 0x00000100, ///< Show Yes button. (this button closes the dialog and sets the result to KoDialog::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 explicit KoDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0); 0171 0172 /** 0173 * Destroys the dialog. 0174 */ 0175 ~KoDialog() 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 focus to the button of the passed @p id. 0317 */ 0318 void setButtonFocus(ButtonCode id); 0319 0320 /** 0321 * Convenience method. Sets the initial dialog size. 0322 * 0323 * This method should only be called right before show() or exec(). 0324 * The initial size will be ignored if smaller than 0325 * the dialog's minimum size. 0326 * 0327 * @param size Startup size. 0328 */ 0329 void setInitialSize(const QSize &size); 0330 0331 /** 0332 * Convenience method. Add a size to the default minimum size of a 0333 * dialog. 0334 * 0335 * This method should only be called right before show() or exec(). 0336 * 0337 * @param size Size added to minimum size. 0338 */ 0339 void incrementInitialSize(const QSize &size); 0340 0341 /** 0342 * Returns the help link text. 0343 * 0344 * If no text has been defined, 0345 * "Get help..." (internationalized) is returned. 0346 * 0347 * @return The help link text. 0348 * 0349 * @see enableLinkedHelp() 0350 * @see setHelpLinkText() 0351 * @see setHelp() 0352 */ 0353 QString helpLinkText() const; 0354 0355 /** 0356 * Returns whether any button is enabled. 0357 */ 0358 bool isButtonEnabled(ButtonCode id) const; 0359 0360 /** 0361 * Returns the button that corresponds to the @p id. 0362 * 0363 * Normally you should not use this function. 0364 * @em Never delete the object returned by this function. 0365 * See also enableButton(), showButton(), setButtonGuiItem(). 0366 * 0367 * @param id Identifier of the button. 0368 * @return The button or 0 if the button does not exist. 0369 */ 0370 QPushButton *button(ButtonCode id) const; 0371 0372 /** 0373 * Returns the number of pixels that should be used between a 0374 * dialog edge and the outermost widget(s) according to the KDE standard. 0375 * 0376 * @deprecated Use the style's pixelMetric() function to query individual margins. 0377 * Different platforms may use different values for the four margins. 0378 */ 0379 static int marginHint(); 0380 0381 /** 0382 * Returns the number of pixels that should be used between 0383 * widgets inside a dialog according to the KDE standard. 0384 * 0385 * @deprecated Use the style's layoutSpacing() function to query individual spacings. 0386 * Different platforms may use different values depending on widget types and pairs. 0387 */ 0388 static int spacingHint(); 0389 0390 /** 0391 * Returns the number of pixels that should be used to visually 0392 * separate groups of related options in a dialog according to 0393 * the KDE standard. 0394 * @since 4.2 0395 */ 0396 static int groupSpacingHint(); 0397 0398 /** 0399 * @enum CaptionFlag 0400 * Used to specify how to construct a window caption 0401 * 0402 * @var NoCaptionFlags Indicates that the method has no caption flags. 0403 * @var AppNameCaption Indicates that the method shall include 0404 * the application name when making the caption string. 0405 * @var ModifiedCaption Causes a 'modified' sign will be included in the 0406 * returned string. This is useful when indicating that a file is 0407 * modified, i.e., it contains data that has not been saved. 0408 * @var HIGCompliantCaption The base minimum flags required to align a 0409 * caption with the KDE Human Interface Guidelines 0410 */ 0411 enum CaptionFlag { 0412 NoCaptionFlags = 0, 0413 AppNameCaption = 1, 0414 ModifiedCaption = 2, 0415 HIGCompliantCaption = AppNameCaption 0416 }; 0417 Q_DECLARE_FLAGS(CaptionFlags, CaptionFlag) 0418 0419 /** 0420 * Builds a caption that contains the application name along with the 0421 * userCaption using a standard layout. 0422 * 0423 * To make a compliant caption for your window, simply do: 0424 * @p setWindowTitle(KoDialog::makeStandardCaption(yourCaption)); 0425 * 0426 * To ensure that the caption is appropriate to the desktop in which the 0427 * application is running, pass in a pointer to the window the caption will 0428 * be applied to. 0429 * 0430 * If using a KoDialog or KMainWindow subclass, call setCaption instead and 0431 * an appropriate standard caption will be created for you 0432 * 0433 * @param userCaption The caption string you want to display in the 0434 * window caption area. Do not include the application name! 0435 * @param window a pointer to the window this application will apply to 0436 * @param flags 0437 * @return the created caption 0438 */ 0439 static QString makeStandardCaption(const QString &userCaption, 0440 QWidget *window = 0, 0441 CaptionFlags flags = HIGCompliantCaption); 0442 0443 /** 0444 * Resize every layout manager used in @p widget and its nested children. 0445 * 0446 * @param widget The widget used. 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(QWidget *widget, int margin, int spacing); 0455 0456 /** 0457 * Resize every layout associated with @p lay and its children. 0458 * 0459 * @param lay layout to be resized 0460 * @param margin The new layout margin 0461 * @param spacing The new layout spacing 0462 * 0463 * @deprecated Use QLayout functions where necessary. Setting margin and spacing 0464 * values recursively for all children prevents QLayout from creating platform native 0465 * layouts. 0466 */ 0467 static void resizeLayout(QLayout *lay, int margin, int spacing); 0468 0469 /** 0470 * Centers @p widget on the desktop, taking multi-head setups into 0471 * account. If @p screen is -1, @p widget will be centered on its 0472 * current screen (if it was shown already) or on the primary screen. 0473 * If @p screen is -3, @p widget will be centered on the screen that 0474 * currently contains the mouse pointer. 0475 * @p screen will be ignored if a merged display (like Xinerama) is not 0476 * in use, or merged display placement is not enabled in kdeglobals. 0477 */ 0478 static void centerOnScreen(QWidget *widget, int screen = -1); 0479 0480 /** 0481 * Places @p widget so that it doesn't cover a certain @p area of the screen. 0482 * This is typically used by the "find dialog" so that the match it finds can 0483 * be read. 0484 * For @p screen, see centerOnScreen 0485 * @return true on success (widget doesn't cover area anymore, or never did), 0486 * false on failure (not enough space found) 0487 */ 0488 static bool avoidArea(QWidget *widget, const QRect &area, int screen = -1); 0489 0490 /** 0491 * Sets the main widget of the dialog. 0492 */ 0493 void setMainWidget(QWidget *widget); 0494 0495 /** 0496 * @return The current main widget. Will create a QWidget as the mainWidget 0497 * if none was set before. This way you can write 0498 * \code 0499 * ui.setupUi(mainWidget()); 0500 * \endcode 0501 * when using designer. 0502 */ 0503 QWidget *mainWidget(); 0504 0505 /** 0506 * Reimplemented from QDialog. 0507 */ 0508 QSize sizeHint() const override; 0509 0510 /** 0511 * Reimplemented from QDialog. 0512 */ 0513 QSize minimumSizeHint() const override; 0514 0515 /** 0516 * Returns the status of the Details button. 0517 */ 0518 bool isDetailsWidgetVisible() const; 0519 0520 public Q_SLOTS: 0521 /** 0522 * Make a KDE compliant caption. 0523 * 0524 * @param caption Your caption. Do @p not include the application name 0525 * in this string. It will be added automatically according to the KDE 0526 * standard. 0527 * 0528 * @deprecated Since 5.0 use QWidget::setWindowTitle 0529 */ 0530 virtual void setCaption(const QString &caption); 0531 0532 /** 0533 * Makes a KDE compliant caption. 0534 * 0535 * @param caption Your caption. @em Do @em not include the application name 0536 * in this string. It will be added automatically according to the KDE 0537 * standard. 0538 * @param modified Specify whether the document is modified. This displays 0539 * an additional sign in the title bar, usually "**". 0540 * 0541 * @deprecated Since 5.0 use QWidget::setWindowTitle and QWidget::setWindowModified. 0542 */ 0543 virtual void setCaption(const QString &caption, bool modified); 0544 0545 /** 0546 * Make a plain caption without any modifications. 0547 * 0548 * @param caption Your caption. This is the string that will be 0549 * displayed in the window title. 0550 */ 0551 virtual void setPlainCaption(const QString &caption); 0552 0553 /** 0554 * Enable or disable (gray out) a general action button. 0555 * 0556 * @param id Button identifier. 0557 * @param state @p true enables the button(s). 0558 */ 0559 void enableButton(ButtonCode id, bool state); 0560 0561 /** 0562 * Enable or disable (gray out) the OK button. 0563 * 0564 * @param state @p true enables the button. 0565 */ 0566 void enableButtonOk(bool state); 0567 0568 /** 0569 * Enable or disable (gray out) the Apply button. 0570 * 0571 * @param state true enables the button. 0572 */ 0573 void enableButtonApply(bool state); 0574 0575 /** 0576 * Enable or disable (gray out) the Cancel button. 0577 * 0578 * @param state true enables the button. 0579 */ 0580 void enableButtonCancel(bool state); 0581 0582 /** 0583 * Display or hide the help link area on the top of the dialog. 0584 * 0585 * @param state @p true will display the area. 0586 * 0587 * @see helpLinkText() 0588 * @see setHelpLinkText() 0589 * @see setHelp() 0590 */ 0591 void enableLinkedHelp(bool state); 0592 0593 /** 0594 * Sets the text that is shown as the linked text. 0595 * 0596 * If text is empty, 0597 * the text "Get help..." (internationalized) is used instead. 0598 * 0599 * @param text The link text. 0600 * 0601 * @see helpLinkText() 0602 * @see enableLinkedHelp() 0603 * @see setHelp() 0604 */ 0605 void setHelpLinkText(const QString &text); 0606 0607 /** 0608 * Sets the help path and topic. 0609 * 0610 * @param anchor Defined anchor in your docbook sources 0611 * @param appname Defines the appname the help belongs to 0612 * If empty it's the current one 0613 * 0614 * @note The help button works differently for the class 0615 * KCMultiDialog, so it does not make sense to call this 0616 * function for Dialogs of that type. See 0617 * KCMultiDialog::slotHelp() for more information. 0618 */ 0619 void setHelp(const QString &anchor, const QString &appname = QString()); 0620 0621 /** 0622 * Sets the status of the Details button. 0623 */ 0624 void setDetailsWidgetVisible(bool visible); 0625 0626 /** 0627 * Sets the widget that gets shown when "Details" is enabled. 0628 * 0629 * The dialog takes over ownership of the widget. 0630 * Any previously set widget gets deleted. 0631 */ 0632 void setDetailsWidget(QWidget *detailsWidget); 0633 0634 /** 0635 * Destruct the dialog delayed. 0636 * 0637 * You can call this function from slots like closeClicked() and hidden(). 0638 * You should not use the dialog any more after calling this function. 0639 * @deprecated use hide()+deleteLater() 0640 */ 0641 void delayedDestruct(); 0642 0643 Q_SIGNALS: 0644 /** 0645 * Emitted when the margin size and/or spacing size 0646 * have changed. 0647 * 0648 * Use marginHint() and spacingHint() in your slot 0649 * to get the new values. 0650 * 0651 * @deprecated This signal is not emitted. Listen to QEvent::StyleChange events instead. 0652 */ 0653 void layoutHintChanged(); 0654 0655 /** 0656 * The Help button was pressed. This signal is only emitted if 0657 * slotButtonClicked() is not replaced 0658 */ 0659 void helpClicked(); 0660 0661 /** 0662 * The Default button was pressed. This signal is only emitted if 0663 * slotButtonClicked() is not replaced 0664 */ 0665 void defaultClicked(); 0666 0667 /** 0668 * The Reset button was pressed. This signal is only emitted if 0669 * slotButtonClicked() is not replaced 0670 */ 0671 void resetClicked(); 0672 0673 /** 0674 * The User3 button was pressed. This signal is only emitted if 0675 * slotButtonClicked() is not replaced 0676 */ 0677 void user3Clicked(); 0678 0679 /** 0680 * The User2 button was pressed. This signal is only emitted if 0681 * slotButtonClicked() is not replaced 0682 */ 0683 void user2Clicked(); 0684 0685 /** 0686 * The User1 button was pressed. This signal is only emitted if 0687 * slotButtonClicked() is not replaced 0688 */ 0689 void user1Clicked(); 0690 0691 /** 0692 * The Apply button was pressed. This signal is only emitted if 0693 * slotButtonClicked() is not replaced 0694 */ 0695 void applyClicked(); 0696 0697 /** 0698 * The Try button was pressed. This signal is only emitted if 0699 * slotButtonClicked() is not replaced 0700 */ 0701 void tryClicked(); 0702 0703 /** 0704 * The OK button was pressed. This signal is only emitted if 0705 * slotButtonClicked() is not replaced 0706 */ 0707 void okClicked(); 0708 0709 /** 0710 * The Yes button was pressed. This signal is only emitted if 0711 * slotButtonClicked() is not replaced 0712 */ 0713 void yesClicked(); 0714 0715 /** 0716 * The No button was pressed. This signal is only emitted if 0717 * slotButtonClicked() is not replaced 0718 */ 0719 void noClicked(); 0720 0721 /** 0722 * The Cancel button was pressed. This signal is only emitted if 0723 * slotButtonClicked() is not replaced 0724 */ 0725 void cancelClicked(); 0726 0727 /** 0728 * The Close button was pressed. This signal is only emitted if 0729 * slotButtonClicked() is not replaced 0730 */ 0731 void closeClicked(); 0732 0733 /** 0734 * A button has been pressed. This signal is only emitted if 0735 * slotButtonClicked() is not replaced 0736 * @param button is the code of the pressed button. 0737 */ 0738 void buttonClicked(KoDialog::ButtonCode button); 0739 0740 /** 0741 * The dialog is about to be hidden. 0742 * 0743 * A dialog is hidden after a user clicks a button that ends 0744 * the dialog or when the user switches to another desktop or 0745 * minimizes the dialog. 0746 */ 0747 void hidden(); 0748 0749 /** 0750 * The dialog has finished. 0751 * 0752 * A dialog emits finished after a user clicks a button that ends 0753 * the dialog. 0754 * 0755 * This signal is also emitted when you call hide() 0756 * 0757 * If you have stored a pointer to the 0758 * dialog do @em not try to delete the pointer in the slot that is 0759 * connected to this signal. 0760 * 0761 * You should use deleteLater() instead. 0762 */ 0763 void finished(); 0764 0765 /** 0766 * The detailsWidget is about to get shown. This is your last chance 0767 * to call setDetailsWidget if you haven't done so yet. 0768 */ 0769 void aboutToShowDetails(); 0770 0771 protected: 0772 /** 0773 * Emits the #hidden signal. You can connect to that signal to 0774 * detect when a dialog has been closed. 0775 */ 0776 void hideEvent(QHideEvent *) override; 0777 0778 /** 0779 * Detects when a dialog is being closed from the window manager 0780 * controls. If the Cancel or Close button is present then the button 0781 * is activated. Otherwise standard QDialog behavior 0782 * will take place. 0783 */ 0784 void closeEvent(QCloseEvent *e) override; 0785 0786 /** 0787 * @internal 0788 */ 0789 void keyPressEvent(QKeyEvent *) override; 0790 0791 protected Q_SLOTS: 0792 /** 0793 * Activated when the button @p button is clicked 0794 * 0795 * Sample that shows how to catch and handle button clicks within 0796 * an own dialog; 0797 * @code 0798 * class MyDialog : public KoDialog { 0799 * protected Q_SLOTS: 0800 * virtual void slotButtonClicked(int button) { 0801 * if (button == KoDialog::Ok) 0802 * accept(); 0803 * else 0804 * KoDialog::slotButtonClicked(button); 0805 * } 0806 * } 0807 * @endcode 0808 * 0809 * @param button is the type @a KoDialog::ButtonCode 0810 * 0811 * @deprecated since 5.0 use QDialogButtonBox and connect to the clicked signal 0812 */ 0813 virtual void slotButtonClicked(int button); 0814 0815 /** 0816 * Updates the margins and spacings. 0817 * 0818 * @deprecated KoDialog respects the style's margins and spacings automatically. Calling 0819 * this function has no effect. 0820 */ 0821 void updateGeometry(); 0822 0823 private: 0824 KoDialog(KoDialogPrivate &dd, QWidget *parent, Qt::WindowFlags flags = nullptr); 0825 KoDialogPrivate *const d_ptr; 0826 0827 private: 0828 Q_DISABLE_COPY(KoDialog) 0829 Q_PRIVATE_SLOT(d_ptr, void queuedLayoutUpdate()) 0830 Q_PRIVATE_SLOT(d_ptr, void helpLinkClicked()) 0831 }; 0832 0833 Q_DECLARE_OPERATORS_FOR_FLAGS(KoDialog::ButtonCodes) 0834 Q_DECLARE_OPERATORS_FOR_FLAGS(KoDialog::CaptionFlags) 0835 0836 #endif // KODIALOG_H