ctkFontButton.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 __ctkFontButton_h
  15. #define __ctkFontButton_h
  16. // Qt includes
  17. #include <QFont>
  18. #include <QPushButton>
  19. // CTK includes
  20. #include "ctkWidgetsExport.h"
  21. class ctkFontButtonPrivate;
  22. /// \ingroup Widgets
  23. class CTK_WIDGETS_EXPORT ctkFontButton: public QPushButton
  24. {
  25. Q_OBJECT
  26. Q_PROPERTY(QFont currentFont READ currentFont WRITE setCurrentFont NOTIFY currentFontChanged USER true)
  27. public:
  28. /// Constructor
  29. /// Creates a default ctkFontButton initialized with QApplication font
  30. ctkFontButton(QWidget * parent = 0);
  31. /// Constructor
  32. /// Creates a ctkFontButton with a given font
  33. ctkFontButton(const QFont& font, QWidget * parent = 0);
  34. /// Destructor
  35. virtual ~ctkFontButton();
  36. /// Set/get the current font
  37. void setCurrentFont(const QFont& newFont);
  38. QFont currentFont()const;
  39. public Q_SLOTS:
  40. /// browse() opens a pop up where the user can select a new font.
  41. /// browse() is automatically called when the button is clicked.
  42. void browseFont();
  43. Q_SIGNALS:
  44. /// Fired anytime the current font changed.
  45. /// Programatically or by the user via the file dialog that pop up when
  46. /// clicking on the button.
  47. void currentFontChanged(const QFont&);
  48. protected:
  49. QScopedPointer<ctkFontButtonPrivate> d_ptr;
  50. private:
  51. Q_DECLARE_PRIVATE(ctkFontButton);
  52. Q_DISABLE_COPY(ctkFontButton);
  53. };
  54. #endif