Mercurial > minori
comparison src/gui/dialog/licenses.cc @ 365:f81bed4e04ac
*: megacommit that probably breaks things
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Wed, 02 Oct 2024 23:06:43 -0400 |
parents | a0aa8c8c4307 |
children | 8d45d892be88 |
comparison
equal
deleted
inserted
replaced
364:99c961c91809 | 365:f81bed4e04ac |
---|---|
22 #include <curl/curl.h> | 22 #include <curl/curl.h> |
23 #ifdef WIN32 | 23 #ifdef WIN32 |
24 # include "sys/win32/dark_theme.h" | 24 # include "sys/win32/dark_theme.h" |
25 #endif | 25 #endif |
26 | 26 |
27 static QWidget *create_license_widget(QWidget *parent, const std::string& license) { | 27 static QWidget *create_license_widget(QWidget *parent, const QString& license) { |
28 QTextBrowser* paragraph = new QTextBrowser(parent); | 28 QTextBrowser* paragraph = new QTextBrowser(parent); |
29 paragraph->setFrameShape(QFrame::NoFrame); | 29 paragraph->setFrameShape(QFrame::NoFrame); |
30 paragraph->setPlainText(Strings::ToQString(license)); | 30 paragraph->setPlainText(license); |
31 paragraph->setFont(QFont("monospace")); | 31 paragraph->setFont(QFont("monospace")); |
32 return paragraph; | 32 return paragraph; |
33 } | |
34 | |
35 static void create_basic_license(QTabWidget *tab_widget, const QString& filename, const QString& title) { | |
36 QFile f(filename); | |
37 if (!f.exists()) | |
38 return; | |
39 | |
40 f.open(QFile::ReadOnly | QFile::Text); | |
41 tab_widget->addTab(create_license_widget(tab_widget, f.readAll()), title); | |
42 } | |
43 | |
44 static void create_dual_license(QTabWidget *tab_widget, const QString& filename1, const QString& title1, const QString& filename2, const QString& title2) { | |
45 QString l1, l2; | |
46 { | |
47 QFile f1(filename1), f2(filename2); | |
48 if (!f1.exists() || !f2.exists()) | |
49 return; | |
50 | |
51 f1.open(QFile::ReadOnly | QFile::Text); | |
52 f2.open(QFile::ReadOnly | QFile::Text); | |
53 | |
54 l1 = f1.readAll(); | |
55 l2 = f2.readAll(); | |
56 } | |
57 | |
58 QWidget *dual = new QWidget(tab_widget); | |
59 QVBoxLayout *dual_layout = new QVBoxLayout(dual); | |
60 | |
61 QLabel *dual_notice = new QLabel(QCoreApplication::tr("%1 was originally forked from %2, where any changes divergent from %2 are now under a different license. Both the licenses for %1 and %2 are provided below, respectfully:").arg(title1, title2), dual); | |
62 dual_notice->setWordWrap(true); | |
63 dual_layout->addWidget(dual_notice); | |
64 dual_layout->addWidget(create_license_widget(dual, l1)); | |
65 dual_layout->addWidget(create_license_widget(dual, l2)); | |
66 | |
67 tab_widget->addTab(dual, title1); | |
33 } | 68 } |
34 | 69 |
35 LicensesWindow::LicensesWindow(QWidget* parent) : QDialog(parent) { | 70 LicensesWindow::LicensesWindow(QWidget* parent) : QDialog(parent) { |
36 resize(641, 500); | 71 resize(641, 500); |
37 setWindowTitle(tr("About Minori")); | 72 setWindowTitle(tr("About Minori")); |
44 | 79 |
45 QTabWidget *tab_widget = new QTabWidget(this); | 80 QTabWidget *tab_widget = new QTabWidget(this); |
46 | 81 |
47 layout->addWidget(tab_widget); | 82 layout->addWidget(tab_widget); |
48 | 83 |
49 do { | 84 create_basic_license(tab_widget, ":/licenses/LICENSE.minori", tr("Minori")); |
50 QFile f(":/licenses/LICENSE.minori"); | |
51 if (!f.exists()) | |
52 break; | |
53 | 85 |
54 f.open(QFile::ReadOnly | QFile::Text); | 86 create_dual_license(tab_widget, ":/licenses/LICENSE.MIT.animone", tr("Animone"), ":/licenses/LICENSE.BSD.animone", tr("Anisthesia")); |
55 tab_widget->addTab(create_license_widget(this, Strings::ToUtf8String(f.readAll())), tr("Minori")); | |
56 } while (0); | |
57 | 87 |
58 do { | 88 create_basic_license(tab_widget, ":/licenses/LICENSE.anitomy", tr("Anitomy")); |
59 QFile f(":/licenses/LICENSE.MIT.animone"); | 89 create_basic_license(tab_widget, ":/licenses/LICENSE.fmt", tr("fmt")); |
60 QFile b(":/licenses/LICENSE.BSD.animone"); | 90 create_basic_license(tab_widget, ":/licenses/LICENSE.nlohmann", tr("JSON for Modern C++")); |
61 if (!f.exists() || !b.exists()) | 91 create_basic_license(tab_widget, ":/licenses/LICENSE.pugixml", tr("pugixml")); |
62 break; | 92 create_basic_license(tab_widget, ":/licenses/LICENSE.semver", tr("semver")); |
63 | 93 create_basic_license(tab_widget, ":/licenses/LICENSE.toml11", tr("toml11")); |
64 f.open(QFile::ReadOnly | QFile::Text); | 94 create_basic_license(tab_widget, ":/licenses/LICENSE.utf8proc", tr("utf8proc")); |
65 b.open(QFile::ReadOnly | QFile::Text); | |
66 | |
67 std::string mit = Strings::ToUtf8String(f.readAll()); | |
68 std::string bsd = Strings::ToUtf8String(b.readAll()); | |
69 | |
70 QWidget *dual = new QWidget(this); | |
71 QVBoxLayout *dual_layout = new QVBoxLayout(dual); | |
72 | |
73 QLabel *dual_notice = new QLabel(tr("Animone was originally forked from Anisthesia, where any changes divergent from Anisthesia are now under a different license. Both the licenses for Animone and Anisthesia are provided below, respectfully:"), dual); | |
74 dual_notice->setWordWrap(true); | |
75 dual_layout->addWidget(dual_notice); | |
76 dual_layout->addWidget(create_license_widget(dual, bsd)); | |
77 dual_layout->addWidget(create_license_widget(dual, mit)); | |
78 | |
79 tab_widget->addTab(dual, tr("Animone")); | |
80 } while (0); | |
81 | |
82 do { | |
83 QFile f(":/licenses/LICENSE.anitomy"); | |
84 if (!f.exists()) | |
85 break; | |
86 | |
87 f.open(QFile::ReadOnly | QFile::Text); | |
88 tab_widget->addTab(create_license_widget(this, Strings::ToUtf8String(f.readAll())), tr("Anitomy")); | |
89 } while (0); | |
90 | |
91 do { | |
92 QFile f(":/licenses/LICENSE.fmt"); | |
93 if (!f.exists()) | |
94 break; | |
95 | |
96 f.open(QFile::ReadOnly | QFile::Text); | |
97 tab_widget->addTab(create_license_widget(this, Strings::ToUtf8String(f.readAll())), tr("fmt")); | |
98 } while (0); | |
99 | |
100 do { | |
101 QFile f(":/licenses/LICENSE.nlohmann"); | |
102 if (!f.exists()) | |
103 break; | |
104 | |
105 f.open(QFile::ReadOnly | QFile::Text); | |
106 tab_widget->addTab(create_license_widget(this, Strings::ToUtf8String(f.readAll())), tr("JSON for Modern C++")); | |
107 } while (0); | |
108 | |
109 do { | |
110 QFile f(":/licenses/LICENSE.pugixml"); | |
111 if (!f.exists()) | |
112 break; | |
113 | |
114 f.open(QFile::ReadOnly | QFile::Text); | |
115 tab_widget->addTab(create_license_widget(this, Strings::ToUtf8String(f.readAll())), tr("pugixml")); | |
116 } while (0); | |
117 | |
118 do { | |
119 QFile f(":/licenses/LICENSE.semver"); | |
120 if (!f.exists()) | |
121 break; | |
122 | |
123 f.open(QFile::ReadOnly | QFile::Text); | |
124 tab_widget->addTab(create_license_widget(this, Strings::ToUtf8String(f.readAll())), tr("semver")); | |
125 } while (0); | |
126 | |
127 do { | |
128 QFile f(":/licenses/LICENSE.toml11"); | |
129 if (!f.exists()) | |
130 break; | |
131 | |
132 f.open(QFile::ReadOnly | QFile::Text); | |
133 tab_widget->addTab(create_license_widget(this, Strings::ToUtf8String(f.readAll())), tr("toml11")); | |
134 } while (0); | |
135 | |
136 do { | |
137 QFile f(":/licenses/LICENSE.utf8proc"); | |
138 if (!f.exists()) | |
139 break; | |
140 | |
141 f.open(QFile::ReadOnly | QFile::Text); | |
142 tab_widget->addTab(create_license_widget(this, Strings::ToUtf8String(f.readAll())), tr("utf8proc")); | |
143 } while (0); | |
144 } | 95 } |
145 | 96 |
146 void LicensesWindow::showEvent(QShowEvent* event) { | 97 void LicensesWindow::showEvent(QShowEvent* event) { |
147 QDialog::showEvent(event); | 98 QDialog::showEvent(event); |
148 #ifdef WIN32 | 99 #ifdef WIN32 |