ctkConfirmExitDialog.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0.txt
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. #ifndef __ctkConfirmExitDialog_h
  15. #define __ctkConfirmExitDialog_h
  16. // Qt includes
  17. #include <QDialog>
  18. // CTK includes
  19. #include "ctkWidgetsExport.h"
  20. class ctkConfirmExitDialogPrivate;
  21. ///
  22. class CTK_WIDGETS_EXPORT ctkConfirmExitDialog : public QDialog
  23. {
  24. Q_OBJECT
  25. public:
  26. typedef QDialog Superclass;
  27. ctkConfirmExitDialog(QWidget* newParent = 0);
  28. virtual ~ctkConfirmExitDialog();
  29. /// Customize the pixmap
  30. void setPixmap(const QPixmap& pixmap);
  31. /// Customize the text
  32. void setText(const QString& text);
  33. /// Synchronize the state of the checkbox "Don't show this message again"
  34. /// with the given settings key.
  35. void setDontShowAnymoreSettingsKey(const QString& key);
  36. QString dontShowAnymoreSettingsKey()const;
  37. /// Is the checkbox "Don't show this message again" checked ?
  38. bool dontShowAnymore()const;
  39. /// Utility function that opens a dialog to confirm exit.
  40. static bool confirmExit(const QString& dontShowAgainKey = QString(),
  41. QWidget* parentWidget = 0);
  42. /// Reimplemented for internal reasons
  43. virtual void setVisible(bool visible);
  44. public Q_SLOTS:
  45. /// reimplemented for internal reasons
  46. virtual void accept();
  47. /// Change the checkbox and the settings if any
  48. void setDontShowAnymore(bool dontShow);
  49. protected:
  50. QScopedPointer<ctkConfirmExitDialogPrivate> d_ptr;
  51. private:
  52. Q_DECLARE_PRIVATE(ctkConfirmExitDialog);
  53. Q_DISABLE_COPY(ctkConfirmExitDialog);
  54. };
  55. #endif