KDELibs4Support

kdialog.h
1 /* This file is part of the KDE Libraries
2  * Copyright (C) 1998 Thomas Tanghus ([email protected])
3  * Additions 1999-2000 by Espen Sand ([email protected])
4  * and Holger Freyther <[email protected]>
5  * 2005-2009 Olivier Goffart <ogoffart @ kde.org>
6  * 2006 Tobias Koenig <[email protected]>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public License
19  * along with this library; see the file COPYING.LIB. If not, write to
20  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  */
23 
24 #ifndef KDIALOG_H
25 #define KDIALOG_H
26 
27 class QPushButton;
28 class QMenu;
29 class KDialogPrivate;
30 
31 #include <kdelibs4support_export.h>
32 #include <kconfiggroup.h>
33 #include <kguiitem.h>
34 
35 #include <QDialog>
36 
128 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KDialog : public QDialog //krazy:exclude=qclasses
129 {
130  Q_OBJECT
132  Q_DECLARE_PRIVATE(KDialog)
133 
134 public:
135 
136  enum ButtonCode {
137  None = 0x00000000,
138  Help = 0x00000001,
139  Default = 0x00000002,
140  Ok = 0x00000004,
141  Apply = 0x00000008,
142  Try = 0x00000010,
143  Cancel = 0x00000020,
144  Close = 0x00000040,
145  No = 0x00000080,
146  Yes = 0x00000100,
147  Reset = 0x00000200,
148  Details = 0x00000400,
149  User1 = 0x00001000,
150  User2 = 0x00002000,
151  User3 = 0x00004000,
152  NoDefault = 0x00008000
153  };
154  // TODO KDE5: remove NoDefault and use the value None instead
155  Q_DECLARE_FLAGS(ButtonCodes, ButtonCode)
156 
157  enum ButtonPopupMode {
158  InstantPopup = 0,
159  DelayedPopup = 1
160  };
161  Q_DECLARE_FLAGS(ButtonPopupModes, ButtonPopupMode)
162 
163 public:
170  KDELIBS4SUPPORT_DEPRECATED explicit KDialog(QWidget *parent = nullptr, Qt::WindowFlags flags = {});
171 
175  ~KDialog();
176 
192  void setButtons(ButtonCodes buttonMask);
193 
204  void setButtonsOrientation(Qt::Orientation orientation);
205 
216  void setEscapeButton(ButtonCode id);
217 
226  void setDefaultButton(ButtonCode id);
227 
232  ButtonCode defaultButton() const;
233 
238  void showButtonSeparator(bool state);
239 
250  void showButton(ButtonCode id, bool state);
251 
258  void setButtonText(ButtonCode id, const QString &text);
259 
263  QString buttonText(ButtonCode id) const;
264 
271  void setButtonIcon(ButtonCode id, const QIcon &icon);
272 
276  QIcon buttonIcon(ButtonCode id) const;
277 
284  void setButtonToolTip(ButtonCode id, const QString &text);
285 
289  QString buttonToolTip(ButtonCode id) const;
290 
297  void setButtonWhatsThis(ButtonCode id, const QString &text);
298 
302  QString buttonWhatsThis(ButtonCode id) const;
303 
313  void setButtonGuiItem(ButtonCode id, const KGuiItem &item);
314 
322  void setButtonMenu(ButtonCode id, QMenu *menu, ButtonPopupMode popupmode = InstantPopup);
323 
327  void setButtonFocus(ButtonCode id);
328 
338  void setInitialSize(const QSize &size);
339 
348  void incrementInitialSize(const QSize &size);
349 
359 #ifndef KDELIBS4SUPPORT_NO_DEPRECATED
360  KDELIBS4SUPPORT_DEPRECATED void restoreDialogSize(const KConfigGroup &config);
361 #endif
362 
373 #ifndef KDELIBS4SUPPORT_NO_DEPRECATED
374  KDELIBS4SUPPORT_DEPRECATED void saveDialogSize(KConfigGroup &config, KConfigGroup::WriteConfigFlags options = KConfigGroup::Normal) const;
375 #endif
376 
389  QString helpLinkText() const;
390 
394  bool isButtonEnabled(ButtonCode id) const;
395 
406  QPushButton *button(ButtonCode id) const;
407 
415  static int marginHint();
416 
424  static int spacingHint();
425 
432  static int groupSpacingHint();
433 
446  enum CaptionFlag {
447  NoCaptionFlags = 0,
448  AppNameCaption = 1,
449  ModifiedCaption = 2,
450  HIGCompliantCaption = AppNameCaption
451  };
452  Q_DECLARE_FLAGS(CaptionFlags, CaptionFlag)
453 
454 
474  static QString makeStandardCaption(const QString &userCaption,
475  QWidget *window = nullptr,
476  CaptionFlags flags = HIGCompliantCaption);
477 
489  static void resizeLayout(QWidget *widget, int margin, int spacing);
490 
502  static void resizeLayout(QLayout *lay, int margin, int spacing);
503 
513  static void centerOnScreen(QWidget *widget, int screen = -1);
514 
523  static bool avoidArea(QWidget *widget, const QRect &area, int screen = -1);
524 
528  void setMainWidget(QWidget *widget);
529 
538  QWidget *mainWidget();
539 
543  QSize sizeHint() const override;
544 
548  QSize minimumSizeHint() const override;
549 
555  static void setAllowEmbeddingInGraphicsView(bool allowEmbedding);
556 
557 public Q_SLOTS:
567  virtual void setCaption(const QString &caption);
568 
580  virtual void setCaption(const QString &caption, bool modified);
581 
588  virtual void setPlainCaption(const QString &caption);
589 
596  void enableButton(ButtonCode id, bool state);
597 
603  void enableButtonOk(bool state);
604 
610  void enableButtonApply(bool state);
611 
617  void enableButtonCancel(bool state);
618 
628  void enableLinkedHelp(bool state);
629 
642  void setHelpLinkText(const QString &text);
643 
656  void setHelp(const QString &anchor, const QString &appname = QString());
657 
661  bool isDetailsWidgetVisible() const;
662 
666  void setDetailsWidgetVisible(bool visible);
667 
674  void setDetailsWidget(QWidget *detailsWidget);
675 
683  void delayedDestruct();
684 
685 Q_SIGNALS:
695  void layoutHintChanged();
696 
701  void helpClicked();
702 
707  void defaultClicked();
708 
713  void resetClicked();
714 
719  void user3Clicked();
720 
725  void user2Clicked();
726 
731  void user1Clicked();
732 
737  void applyClicked();
738 
743  void tryClicked();
744 
749  void okClicked();
750 
755  void yesClicked();
756 
761  void noClicked();
762 
767  void cancelClicked();
768 
773  void closeClicked();
774 
780  void buttonClicked(KDialog::ButtonCode button);
781 
789  void hidden();
790 
805  void finished();
806 
811  void aboutToShowDetails();
812 
813 protected:
818  void hideEvent(QHideEvent *) override;
819 
826  void closeEvent(QCloseEvent *e) override;
827 
831  void keyPressEvent(QKeyEvent *) override;
832 
833 protected Q_SLOTS:
855  virtual void slotButtonClicked(int button);
856 
863  void updateGeometry();
864 
865 protected:
866  KDialog(KDialogPrivate &dd, QWidget *parent, Qt::WindowFlags flags = {});
867  KDialogPrivate *const d_ptr;
868 
869 private:
871  Q_PRIVATE_SLOT(d_ptr, void queuedLayoutUpdate())
872  Q_PRIVATE_SLOT(d_ptr, void helpLinkClicked())
873 };
874 
875 Q_DECLARE_OPERATORS_FOR_FLAGS(KDialog::ButtonCodes)
876 Q_DECLARE_OPERATORS_FOR_FLAGS(KDialog::CaptionFlags)
877 
878 #endif // KDIALOG_H
virtual QSize minimumSizeHint() const const override
virtual void closeEvent(QCloseEvent *e) override
void updateGeometry()
A dialog base class with standard buttons and predefined layouts.
Definition: kdialog.h:128
ButtonCode
Definition: kdialog.h:136
void finished(int result)
virtual void hideEvent(QHideEvent *event)
virtual QSize sizeHint() const const override
virtual void keyPressEvent(QKeyEvent *e) override
Q_DISABLE_COPY(Class)
Q_ENUMS(...)
Orientation
typedef WindowFlags
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue Sep 29 2020 23:06:08 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.