SWMMVis  6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
themehelpers.h
Go to the documentation of this file.
1#ifndef THEMEHELPERS_H
2#define THEMEHELPERS_H
3
24#include <QString>
25#include <QWidget>
26
29
31
32enum class Banner { Info, Success, Error };
33
35inline void applyHintRole(QWidget *w)
36{
37 if (w)
38 w->setForegroundRole(QPalette::PlaceholderText);
39}
40
42inline QString hintStyle()
43{
44 return QStringLiteral("color: palette(mid);");
45}
46
47inline QString hintItalicStyle()
48{
49 return QStringLiteral("color: palette(mid); font-style: italic;");
50}
51
53inline QString errorTextStyle()
54{
55 return QStringLiteral("color: %1;")
56 .arg(ThemeManager::instance()->colors().error.name(QColor::HexRgb));
57}
58
60inline QString errorBorderStyle()
61{
62 return QStringLiteral("border: 1px solid %1;")
63 .arg(ThemeManager::instance()->colors().error.name(QColor::HexRgb));
64}
65
69inline QString sectionHeadingStyle()
70{
71 return QStringLiteral("font-weight: bold;");
72}
73
78inline QString errorFillStyle()
79{
81 return QStringLiteral("background-color: %1; color: %2;")
82 .arg(c.bannerErrorBg.name(QColor::HexRgb),
83 c.bannerErrorFg.name(QColor::HexRgb));
84}
85
88inline QString bannerStyle(Banner kind)
89{
91 QColor bg, fg;
92 switch (kind) {
93 case Banner::Error: bg = c.bannerErrorBg; fg = c.bannerErrorFg; break;
94 case Banner::Success: bg = c.bannerSuccessBg; fg = c.bannerSuccessFg; break;
95 case Banner::Info: bg = c.bannerInfoBg; fg = c.bannerInfoFg; break;
96 }
97 return QStringLiteral("background-color: %1; color: %2;")
98 .arg(bg.name(QColor::HexRgb), fg.name(QColor::HexRgb));
99}
100
101} // namespace openswmmvis::ui::theme
102
103#endif // THEMEHELPERS_H
static ThemeManager * instance()
Definition thememanager.cpp:37
const ThemeColors & colors() const
Definition thememanager.cpp:71
int w
Definition mesh2dresultsexport.cpp:387
Definition themehelpers.h:30
QString bannerStyle(Banner kind)
Definition themehelpers.h:88
QString hintItalicStyle()
Definition themehelpers.h:47
QString sectionHeadingStyle()
Definition themehelpers.h:69
QString errorFillStyle()
Definition themehelpers.h:78
Banner
Definition themehelpers.h:32
QString errorTextStyle()
Definition themehelpers.h:53
QString errorBorderStyle()
Definition themehelpers.h:60
void applyHintRole(QWidget *w)
Definition themehelpers.h:35
QString hintStyle()
Definition themehelpers.h:42
TokenKind kind
Definition queryparser.cpp:34
Definition themetokens.h:25
QColor bannerErrorFg
Definition themetokens.h:48
QColor bannerSuccessBg
Definition themetokens.h:49
QColor bannerSuccessFg
Definition themetokens.h:49
QColor bannerInfoBg
Definition themetokens.h:50
QColor bannerErrorBg
Definition themetokens.h:48
QColor bannerInfoFg
Definition themetokens.h:50