Medical Imaging Interaction Toolkit  2018.4.99-4c24e3cb
Medical Imaging Interaction Toolkit
berryQtStyleManager.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 
14 #ifndef BERRYQTSTYLEMANAGER_H_
15 #define BERRYQTSTYLEMANAGER_H_
16 
17 #include <berryIQtStyleManager.h>
19 
20 #include <QHash>
21 
22 namespace berry {
23 
24 class BERRY_UI_QT QtStyleManager : public QObject, public IQtStyleManager
25 {
26  Q_OBJECT
27  Q_INTERFACES(berry::IQtStyleManager)
28 
29 public:
30  static QIcon ThemeIcon(const QByteArray &originalSVG);
31  static QIcon ThemeIcon(const QString &resourcePath);
32 
34  ~QtStyleManager() override;
35 
36  Style GetStyle() const override;
37  QString GetStylesheet() const override;
38  QString GetActiveTabStylesheet() const override;
39  QString GetTabStylesheet() const override;
40  QString GetFont() const override;
41 
42  void AddStyle(const QString& styleFileName,
43  const QString& styleName = QString()) override;
44  void AddStyles(const QString& path) override;
45  void RemoveStyle(const QString& styleFileName) override;
46  void RemoveStyles(const QString& path = QString()) override;
47 
48  void GetStyles(StyleList& styles) const override;
49  void SetStyle(const QString& fileName) override;
50 
51  void GetFonts(QStringList& fontNames) const override;
52 
53  void SetFont(const QString& fontName) override;
54  void SetFontSize(const int fontSize) override;
55  void UpdateWorkbenchFont() override;
56 
57  Style GetDefaultStyle() const override;
58  void SetDefaultStyle() override;
59 
60  bool Contains(const QString& fileName) const override;
61 
62  bool IsA( const std::type_info& type ) const;
63  const std::type_info& GetType() const;
64 
65 private:
66 
67  void AddDefaultStyle();
68  void AddDefaultFonts();
69  void ClearStyles();
70  void ReadPreferences();
71 
72  void SetStyle(const QString& fileName, bool update);
73  void SetDefaultStyle(bool update);
74 
75  struct ExtStyle : public Style
76  {
77  QString stylesheet;
78  QString tabStylesheet;
79  QString activeTabStylesheet;
80  };
81 
82  QStringList m_customFontNames;
83  void ReadStyleData(ExtStyle* style);
84 
85  typedef QHash<QString, ExtStyle*> FileNameToStyleMap;
86  FileNameToStyleMap styles;
87 
88  QString m_currentFont;
89  int m_currentFontSize;
90  ExtStyle const* currentStyle;
91  ExtStyle* defaultStyle;
92 
93 };
94 }
95 
96 #endif /* BERRYQTSTYLEMANAGER_H_ */
#define BERRY_UI_QT