ACF $AcfVersion:0$
iqtgui.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
3
4
5// Qt includes
6#include <QtCore/QFile>
7#include <QtCore/QDebug>
8#include <QtCore/QTextStream>
9#include <QtGui/QIcon>
10#include <QtGui/QPixmap>
11
12#if QT_VERSION > 0x050000
13#include <QtWidgets/QWidget>
14#include <QtWidgets/QStyle>
15#else
16#include <QtGui/QWidget>
17#include <QtGui/QStyle>
18#endif
19
20// ACF includes
21#include <iqt/iqt.h>
22
23
27namespace iqtgui
28{
29
30
31QIcon GetIconFromCache(const QString& iconName);
32void AddIconToCache(const QString& iconName, const QIcon& icon);
33
34
38template <class StyleSheetConsumer>
39static bool SetStyleSheetFromFile(StyleSheetConsumer* styleSheetConsumer, const QString& styleSheetFilePath)
40{
41 if (styleSheetConsumer == NULL){
42 return false;
43 }
44
45 if (styleSheetFilePath.isEmpty()){
46 styleSheetConsumer->setStyleSheet("");
47
48 return true;
49 }
50
51 QFile styleSheetFile(styleSheetFilePath);
52 if (styleSheetFile.open(QIODevice::ReadOnly | QIODevice::Text)){
53 QTextStream stream(&styleSheetFile);
54 QString styleSheetText;
55 QString textLine;
56 do{
57 textLine = stream.readLine();
58 styleSheetText += textLine;
59 } while (!textLine.isNull());
60
61 styleSheetConsumer->setStyleSheet(styleSheetText);
62
63 return true;
64 }
65 else{
66 qDebug(qPrintable(QString("Style sheet file could not be opened: '%1'").arg(styleSheetFilePath)));
67 }
68
69 return false;
70}
71
72
73} // namespace iqtgui
74
75
#define NULL
Definition istd.h:74
Standard GUI specific interfaces and components based on Qt.
static bool SetStyleSheetFromFile(StyleSheetConsumer *styleSheetConsumer, const QString &styleSheetFilePath)
Set style sheet to any supported object.
Definition iqtgui.h:39
void AddIconToCache(const QString &iconName, const QIcon &icon)
QIcon GetIconFromCache(const QString &iconName)