Mantid
Loading...
Searching...
No Matches
WindowIcons.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7//-----------------------------------------------------------------------------
8// Includes
9//-----------------------------------------------------------------------------
12
13namespace MantidQt {
14namespace API {
15
16//-----------------------------------------------------------------------------
17// Public member functions
18//-----------------------------------------------------------------------------
22WindowIcons::WindowIcons() : m_idToPixmapName() { initInternalLookup(); }
23
28QIcon WindowIcons::getIcon(const std::string &windowID) const {
29 auto value = m_idToPixmapName.value(windowID);
30 if (QString::fromStdString(value).endsWith(".png")) {
31 return makeIconFromFile(value);
32 } else {
33 return getQPixmap(value);
34 }
35}
36
42std::string WindowIcons::getIconID(const std::string &windowID) const {
43 if (m_idToPixmapName.contains(windowID))
44 return m_idToPixmapName.value(windowID);
45 else
46 return "";
47}
48
49//-----------------------------------------------------------------------------
50// Private member functions
51//-----------------------------------------------------------------------------
52
57 m_idToPixmapName.clear();
58 m_idToPixmapName["Matrix"] = "matrix_xpm";
59 m_idToPixmapName["MantidMatrix"] = "mantid_matrix_xpm";
60 m_idToPixmapName["Table"] = "worksheet_xpm";
61 m_idToPixmapName["Note"] = "note_xpm";
62 m_idToPixmapName["MultiLayer"] = "graph_xpm";
63 m_idToPixmapName["Graph3D"] = "trajectory_xpm";
64 m_idToPixmapName["Graph"] = "graph_xpm";
65 m_idToPixmapName["Workspace"] = "mantid_matrix_xpm";
66 m_idToPixmapName["SliceViewer"] = ":/SliceViewer/icons/SliceViewerWindow_icon.png";
67}
68
78QIcon WindowIcons::makeIconFromFile(const std::string &path) const {
79 QIcon icon;
80 icon.addFile(QString::fromStdString(path), QSize(), QIcon::Normal, QIcon::Off);
81 return icon;
82}
83} // namespace API
84} // namespace MantidQt
double value
The value of the point.
Definition: FitMW.cpp:51
std::string getIconID(const std::string &windowID) const
Returns an icon ID for the given window ID.
Definition: WindowIcons.cpp:42
QIcon getIcon(const std::string &windowID) const
Returns an icon for the given ID.
Definition: WindowIcons.cpp:28
WindowIcons()
Default constructor.
Definition: WindowIcons.cpp:22
QIcon makeIconFromFile(const std::string &path) const
Build a icon object from an image file.
Definition: WindowIcons.cpp:78
QMap< std::string, std::string > m_idToPixmapName
Internal map instance.
Definition: WindowIcons.h:35
void initInternalLookup()
Defines the mapping between ID & pixmap name.
Definition: WindowIcons.cpp:56
EXPORT_OPT_MANTIDQT_COMMON QPixmap getQPixmap(const std::string &name)
Function that returns a QPixmap given a string name.
Definition: pixmaps.cpp:12823
The AlgorithmProgressDialogPresenter keeps track of the running algorithms and displays a progress ba...