Mercurial > minori
comparison src/include/ui_utils.h @ 8:b1f73678ef61
update
text paragraphs are now their own objects, as they should be
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sat, 26 Aug 2023 03:39:34 -0400 |
parents | 07a9095eaeed |
children |
comparison
equal
deleted
inserted
replaced
7:07a9095eaeed | 8:b1f73678ef61 |
---|---|
1 #ifndef __ui_utils_h | 1 #ifndef __ui_utils_h |
2 #define __ui_utils_h | 2 #define __ui_utils_h |
3 #include <QLabel> | |
4 #include <QFrame> | |
3 #include <QWidget> | 5 #include <QWidget> |
4 #include <QString> | 6 #include <QString> |
5 #include <QPoint> | 7 #include <QPoint> |
6 #include <QSize> | 8 #include <QSize> |
7 #include <QDateTime> | 9 #include <QDateTime> |
9 #include <QPlainTextEdit> | 11 #include <QPlainTextEdit> |
10 namespace UiUtils { | 12 namespace UiUtils { |
11 QIcon CreateSideBarIcon(const char* file); | 13 QIcon CreateSideBarIcon(const char* file); |
12 bool IsInDarkMode(); | 14 bool IsInDarkMode(); |
13 std::string GetLengthFromQDateTime(QDateTime stamp); | 15 std::string GetLengthFromQDateTime(QDateTime stamp); |
14 QPlainTextEdit* CreateTextParagraph(QWidget* parent, QString title, QString data); | |
15 QPlainTextEdit* CreateTextParagraphWithLabels(QWidget* parent, QString title, QString label, QString data); | |
16 QPlainTextEdit* CreateSelectableTextParagraph(QWidget* parent, QString title, QString data); | |
17 void SetPlainTextEditData(QPlainTextEdit* text_edit, QString data); | 16 void SetPlainTextEditData(QPlainTextEdit* text_edit, QString data); |
18 void CreateTextHeader(QWidget* parent, QString title); | |
19 }; | |
20 | 17 |
21 class Paragraph : public QPlainTextEdit { | 18 class Header : public QWidget { |
22 public: | 19 public: |
23 Paragraph(QString text, QWidget* parent = nullptr); | 20 Header(QString title, QWidget* parent = nullptr); |
24 QSize minimumSizeHint() const override; | 21 void SetTitle(QString title); |
25 QSize sizeHint() const override; | 22 |
23 private: | |
24 QLabel* static_text_title; | |
25 QFrame* static_text_line; | |
26 }; | |
27 | |
28 class Paragraph : public QPlainTextEdit { | |
29 public: | |
30 Paragraph(QString text, QWidget* parent = nullptr); | |
31 QSize minimumSizeHint() const override; | |
32 QSize sizeHint() const override; | |
33 }; | |
34 | |
35 /* Convenience class that combines Paragraph and Header. | |
36 Fairly awful naming, but meh :') */ | |
37 class TextParagraph : public QWidget { | |
38 public: | |
39 TextParagraph(QString title, QString data, QWidget* parent = nullptr); | |
40 Header* GetHeader(); | |
41 Paragraph* GetParagraph(); | |
42 | |
43 private: | |
44 Header* header; | |
45 Paragraph* paragraph; | |
46 }; | |
47 | |
48 class LabelledTextParagraph : public QWidget { | |
49 public: | |
50 LabelledTextParagraph(QString title, QString label, QString data, QWidget* parent = nullptr); | |
51 Header* GetHeader(); | |
52 Paragraph* GetLabels(); | |
53 Paragraph* GetParagraph(); | |
54 | |
55 private: | |
56 Header* header; | |
57 Paragraph* labels; | |
58 Paragraph* paragraph; | |
59 }; | |
60 | |
61 class SelectableTextParagraph : public QWidget { | |
62 public: | |
63 SelectableTextParagraph(QString title, QString data, QWidget* parent = nullptr); | |
64 Header* GetHeader(); | |
65 Paragraph* GetParagraph(); | |
66 | |
67 private: | |
68 Header* header; | |
69 Paragraph* paragraph; | |
70 }; | |
26 }; | 71 }; |
27 #endif // __ui_utils_h | 72 #endif // __ui_utils_h |