ctkScreenshotDialog.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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.commontk.org/LICENSE
  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 __ctkScreenshotDialog_h
  15. #define __ctkScreenshotDialog_h
  16. // Qt includes
  17. #include <QDialog>
  18. // CTK includes
  19. #include "ctkWidgetsExport.h"
  20. class ctkScreenshotDialogPrivate;
  21. ///
  22. /// ctkScreenshotDialog is simple dialog allowing to grab the content
  23. /// of any widget and save it into a PNG file.
  24. /// \sa ctkScreenshotDialog::setWidgetToGrab, QDialog
  25. class CTK_WIDGETS_EXPORT ctkScreenshotDialog : public QDialog
  26. {
  27. Q_OBJECT
  28. public:
  29. typedef QDialog Superclass;
  30. ctkScreenshotDialog(QWidget* newParent = 0);
  31. virtual ~ctkScreenshotDialog();
  32. /// Get widget to grab content from
  33. QWidget* widgetToGrab()const;
  34. /// Set widget to grab content from
  35. void setWidgetToGrab(QWidget* newWidgetToGrab);
  36. /// Set image name
  37. void setImageName(const QString& newImageName);
  38. /// Get image name
  39. QString imageName() const;
  40. /// Set directory where image should be saved
  41. void setImageDirectory(const QString& newDirectory);
  42. /// Get directory were images are saved
  43. QString imageDirectory()const;
  44. public slots:
  45. /// Grab the content of specified widget after \a delayInSeconds
  46. /// \sa setWidgetToGrab
  47. void saveScreenshot(int delayInSeconds = 0);
  48. protected:
  49. QScopedPointer<ctkScreenshotDialogPrivate> d_ptr;
  50. private:
  51. Q_DECLARE_PRIVATE(ctkScreenshotDialog);
  52. Q_DISABLE_COPY(ctkScreenshotDialog);
  53. };
  54. #endif