2
|
1 #include "window.h"
|
|
2 #include "ui_utils.h"
|
|
3 #ifdef MACOSX
|
|
4 #include "sys/osx/dark_theme.h"
|
|
5 #else
|
|
6 #include "sys/win32/dark_theme.h"
|
|
7 #endif
|
|
8
|
|
9 bool UiUtils::IsInDarkMode() {
|
|
10 if (session.config.theme != OS)
|
|
11 return (session.config.theme == DARK);
|
|
12 #ifdef MACOSX
|
|
13 if (osx::DarkThemeAvailable()) {
|
|
14 if (osx::IsInDarkTheme()) {
|
|
15 return true;
|
|
16 } else {
|
|
17 return false;
|
|
18 }
|
|
19 }
|
|
20 #elif defined(WIN32)
|
|
21 if (win32::DarkThemeAvailable()) {
|
|
22 if (win32::IsInDarkTheme()) {
|
|
23 return true;
|
|
24 } else {
|
|
25 return false;
|
|
26 }
|
|
27 }
|
|
28 #endif
|
|
29 return (session.config.theme == DARK);
|
|
30 }
|
|
31
|
|
32 void UiUtils::CreateTextHeader(QWidget* parent, QString title, QPoint point, QSize size) {
|
|
33 QLabel* static_text_title = new QLabel(title, parent);
|
|
34 static_text_title->setTextFormat(Qt::PlainText);
|
|
35 static_text_title->setStyleSheet("font-weight: bold");
|
|
36 static_text_title->move(point.x(), point.y());
|
|
37 static_text_title->resize(size.width(), 16);
|
|
38
|
|
39 QFrame* static_text_line = new QFrame(parent);
|
|
40 static_text_line->setFrameShape(QFrame::HLine);
|
|
41 static_text_line->setFrameShadow(QFrame::Sunken);
|
|
42 static_text_line->resize(size.width(), 2);
|
|
43 static_text_line->move(point.x(), point.y()+18);
|
|
44 }
|
|
45
|
|
46 QPlainTextEdit* UiUtils::CreateTextParagraph(QWidget* parent, QString title, QString data, QPoint point, QSize size) {
|
|
47 CreateTextHeader(parent, title, point, size);
|
|
48
|
|
49 QPlainTextEdit* paragraph = new QPlainTextEdit(data, parent);
|
|
50 paragraph->setTextInteractionFlags(Qt::NoTextInteraction);
|
|
51 paragraph->setWordWrapMode(QTextOption::NoWrap);
|
|
52 paragraph->setFrameShape(QFrame::NoFrame);
|
|
53 paragraph->move(point.x()+12, point.y()+32);
|
|
54 paragraph->resize(size.width()-12, size.height()-32);
|
|
55 return paragraph;
|
|
56 }
|
|
57
|
|
58 QPlainTextEdit* UiUtils::CreateTextParagraphWithLabels(QWidget* parent, QString title, QString label, QString data, QPoint point, QSize size) {
|
|
59 CreateTextHeader(parent, title, point, size);
|
|
60
|
|
61 QPlainTextEdit* label_t = new QPlainTextEdit(label, parent);
|
|
62 label_t->setTextInteractionFlags(Qt::NoTextInteraction);
|
|
63 label_t->setWordWrapMode(QTextOption::NoWrap);
|
|
64 label_t->setFrameShape(QFrame::NoFrame);
|
|
65 label_t->move(point.x()+12, point.y()+32);
|
|
66 label_t->resize(90, size.height()-32);
|
|
67
|
|
68 QPlainTextEdit* paragraph = new QPlainTextEdit(data, parent);
|
|
69 paragraph->setTextInteractionFlags(Qt::NoTextInteraction);
|
|
70 paragraph->setWordWrapMode(QTextOption::NoWrap);
|
|
71 paragraph->setFrameShape(QFrame::NoFrame);
|
|
72 paragraph->move(point.x()+102, point.y()+32);
|
|
73 paragraph->resize(size.width()-102, size.height()-32);
|
|
74 return paragraph;
|
|
75 }
|
|
76
|
|
77 /* As far as I can tell, this is identical to the way Taiga implements it.
|
|
78 Kind of cool, I didn't even look into the source code for it :p */
|
|
79 QPlainTextEdit* UiUtils::CreateSelectableTextParagraph(QWidget* parent, QString title, QString data, QPoint point, QSize size) {
|
|
80 CreateTextHeader(parent, title, point, size);
|
|
81
|
|
82 QPlainTextEdit* text_edit = new QPlainTextEdit(data, parent);
|
|
83 text_edit->setReadOnly(true);
|
|
84 text_edit->setFrameShape(QFrame::NoFrame);
|
|
85 text_edit->move(point.x()+12, point.y()+32);
|
|
86 text_edit->resize(size.width()-12, size.height()-32);
|
|
87 return text_edit;
|
|
88 }
|