Maki
Formally verified low-code orchestration
Loading...
Searching...
No Matches
style_helpers.h
1#pragma once
2
3#include <QFlags>
4#include <QIcon>
5#include <QList>
6#include <QString>
7#include <QTreeWidgetItem>
8#include <QVBoxLayout>
9#include <QWidget>
10#include <oclero/qlementine/utils/BadgeUtils.hpp>
11
12#include "config.h"
13#include "logging.h"
14
15class QSvgRenderer;
16
21{
22 QObject* widget;
23 QString path;
24 int index;
25 QColor color;
26 QModelIndex mindex;
27};
28
33{
34 QObject* widget;
35 const char* text;
36 int index;
37 bool tooltip = false;
38 QModelIndex mindex;
39};
40
45{
46 QTreeWidgetItem* widget;
47 QString path;
48 QColor color;
49};
50
57void addClass(QWidget* object, const QString& className);
58
66QPointF snapToGrid(const QPointF& point, const int gridSize);
67
74QString ToLabel(const QString& str);
75QString ToLabel(const std::string& str);
76
84QPixmap applyColorToIcon(const QString& path, const QColor& color);
85
93QPixmap applyColorToIcon(QPixmap pixmap, const QColor& color);
94
102QIcon addIconWithColor(const QString& path, const QColor& color);
103
112QIcon iconFromTheme(const QString& name, bool fallback = false);
113
114QString iconPathFromTheme(const QString& name, bool useLocal = true);
115
122QString timeToQT(std::chrono::system_clock::time_point ts);
123
130QString logLevelToQT(logging::LogLevel logLevel);
131
138oclero::qlementine::StatusBadge logLevelToStatusBadge(logging::LogLevel logLevel);
139
148QString toQT(std::chrono::system_clock::time_point ts, logging::LogLevel level, const std::string& message);
149
157void addDynamicWidget(QVBoxLayout* layout, QWidget* dynamicWidget, QWidget* parent);
158
166void updateProperty(QWidget* widget, const QString& property, bool value);
167
174void applyStyle(QWidget* widget, const QString& style);
175
182void addSectionLabel(QMenu* menu, const QString& text);
183
191QString elideLeft(const QString& text, const QWidget* const component);
192
200QString elideRight(const QString& text, const QWidget* const component);
201
207void clearLayout(QLayout* layout, int start = 0);
208
214void updateIconTheme(QList<WidgetWithIcon>& icons);
215
221void updateTreeIconTheme(QList<TreeWidgetWithIcon>& icons);
222
229QString htmlEscape(const QString& s);
230
237QString createInformationMessage(const NodeConfig& node);
238
239QString createInformationMessage(const FlowConfig& flow, bool defineBody = true);
240
241namespace maki
242{
243enum Style
244{
245 Normal = 0,
246 Bold = 1 << 0,
247 Italic = 1 << 1,
248 Monospace = 1 << 2,
249 Underline = 1 << 3,
250 Strikeout = 1 << 4
251};
252
253Q_DECLARE_FLAGS(Styles, Style)
254QString textStyleCss(Styles styles);
255
256Q_DECLARE_OPERATORS_FOR_FLAGS(Styles)
257} // namespace maki
258
259QString textHtml(const QString& text, const QString& color, maki::Styles styles = maki::Normal);
260QString fieldHtml(const QString& title, const QString& field, const QString& textColor, const QString& fieldColor, maki::Styles styles = maki::Normal);
261QString hlineHtml(const QString& foreground, const QString& background = "#FFFFFF", qreal opacity = 1);
262QString referenceHtml(const QString& text, const QString& foreground, const QString& background, const QString& browserBackground);
263QString formatDescriptionHtml(const QString& description, const FlowConfig& event);
264
265QColor blendColors(const QColor& foreground, const QColor& background, qreal opacity);
266QString spacerHtml(int height = 4);
267QString indentHtml(const QString& content, int indentation = 16);
268QString typeLinkHtml(const QString& typeName, const QString& color, bool clickable);
269
270QString typeFromLink(const QUrl& url);
271
277QString createDefaultMessage();
278
284void paintSvg(QSvgRenderer* renderer, QPainter* painter, const QPointF& center, qreal width, qreal height);
285
294QString nameFromNodeId(const QString& id);
Configuration for a flow or process.
Definition config.h:70
Configuration for a node.
Definition config.h:236
Contains UI helper widgets and layout grouping utilities used by MAKI.
Definition macros.h:9
Represents a translatable widget with text and optional tooltip.
Definition style_helpers.h:33
bool tooltip
Index of the widget.
Definition style_helpers.h:37
const char * text
Pointer to the widget.
Definition style_helpers.h:35
int index
Text for the widget.
Definition style_helpers.h:36
QModelIndex mindex
Whether the widget has a tooltip.
Definition style_helpers.h:38
Represents a tree widget with an associated icon and path.
Definition style_helpers.h:45
QColor color
Path to the icon.
Definition style_helpers.h:48
QString path
Pointer to the tree widget.
Definition style_helpers.h:47
Represents a widget with an associated icon and path.
Definition style_helpers.h:21
QColor color
Index of the widget.
Definition style_helpers.h:25
QString path
Pointer to the widget.
Definition style_helpers.h:23
QModelIndex mindex
Color for the icon.
Definition style_helpers.h:26
int index
Path to the icon.
Definition style_helpers.h:24