WSF
UiResources.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2003-2015 The Boeing Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11
12#ifndef UIRESOURCES_HPP
13#define UIRESOURCES_HPP
14
15#include <QFileIconProvider>
16#include <QFont>
17#include <QIcon>
18#include <QImage>
19#include <QMap>
20
21#include "ViExport.hpp"
22
23namespace wizard
24{
27{
28public:
29 static constexpr unsigned int cBASE_ICON_SIZE = 16;
30 static constexpr unsigned int cMIN_FONT_SIZE = 6;
31 static constexpr unsigned int cMAX_FONT_SIZE = 24;
32
34 virtual ~UiResources();
35
37 static void Create();
38 static void Destroy();
39 static UiResources& GetInstance() { return *sInstancePtr; }
40
41 // Fonts
42 QFont& GetFont() { return mConsoleFont; }
43
44 // Icons
45 QIcon& GetIcon(const QString& aImageName, bool aScale = true);
46 QIcon& GetIconFromTheme(const QString& aImageName,
47 bool aScale = true); // Use this instead of QIcon::fromTheme in model views
48 QIcon GetFileIcon(const QFileInfo& aInfo);
49
50 // Images
51 QImage& GetImageFromTheme(const QString& aImageName, bool aScale = true);
52 QImage& GetDimImageFromTheme(const QString& aImageName, bool aScale = true);
53
55 std::pair<unsigned int, unsigned int> ResizeImageWithFont();
56
57protected:
58 void Initialize();
59
60 QImage ToScale(QImage aImage, int aWidth);
61 QPixmap ToScalePM(QImage aImage, int aWidth);
62
63 // Icons
64 QIcon& AddIcon(const QString& aIconName, bool aScale);
65
66 // Images
67 QImage& AddImage(const QString& aImageName, bool aScale);
68 QImage& AddDimImage(const QString& aImageName, bool aScale);
69
70private:
71 // Fonts
72 QFont mConsoleFont;
73
74 // Icons
75 QMap<QString, QIcon> mIcons;
76 QIcon mEmptyIcon;
77 QFileIconProvider mIconProvider;
78
79 QMap<QString, QImage> mImages;
80 QMap<QString, QImage> mDimImages;
81 QImage mEmptyImage;
82
83 static UiResources* sInstancePtr;
84};
85} // namespace wizard
86#endif
#define VI_EXPORT
Definition ViExport.hpp:38
This class contains the loaded icons used by the application.
Definition UiResources.hpp:27
static UiResources & GetInstance()
Definition UiResources.hpp:39
static constexpr unsigned int cMIN_FONT_SIZE
Definition UiResources.hpp:30
static void Destroy()
Definition UiResources.cpp:39
static constexpr unsigned int cMAX_FONT_SIZE
Definition UiResources.hpp:31
static constexpr unsigned int cBASE_ICON_SIZE
Definition UiResources.hpp:29
QFont & GetFont()
Definition UiResources.hpp:42
static void Create()
Singleton instance.
Definition UiResources.cpp:31
Definition Runner.hpp:22
Copyrights Multiple, All Rights Reserved