ctkFontButton.h 2.0 KB

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