[pim/trojita] src/Gui: Build copyrightholders list in separate method
Espen Sandøy Hustad <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 6621c5a16a366ba87a50319e3a73bd8a0dfa3afb by Espen Sandøy Hustad.
Committed on 03/08/2026 at 18:32.
Pushed by ehustad into branch 'master'.
Build copyrightholders list in separate method
To improve readability.
M +23 -16 src/Gui/Window.cpp
M +2 -0 src/Gui/Window.h
https://invent.kde.org/pim/trojita/-/commit/6621c5a16a366ba87a50319e3a73bd8a0dfa3afb
diff --git a/src/Gui/Window.cpp b/src/Gui/Window.cpp
index eff9b64a5..cea4f291b 100644
--- a/src/Gui/Window.cpp
+++ b/src/Gui/Window.cpp
@@ -2162,27 +2162,34 @@ void MainWindow::slotShowAboutTrojita()
featuresText += QStringLiteral("</ul>");
ui.descriptionLabel->setText(ui.descriptionLabel->text() + featuresText);
- QStringList copyright;
- {
- // Find the names of the authors and remove date codes from there
- QFile license(QStringLiteral(":/LICENSE"));
- license.open(QFile::ReadOnly);
- const auto copyrightHolders = QString::fromUtf8(license.readAll()).split(QLatin1Char('\n'));
- for (const auto &line : std::as_const(copyrightHolders)) {
- const QString prefix(QStringLiteral("Copyright (C) "));
- if (line.startsWith(prefix)) {
- const int pos = prefix.size();
- copyright << QChar(0xa9 /* COPYRIGHT SIGN */) + QLatin1Char(' ') +
- line.mid(pos).replace(QRegularExpression(QLatin1String("(\\d) - (\\d)")),
- QLatin1String("\\1") + QChar(0x2014 /* EM DASH */) + QLatin1String("\\2"));
- }
- }
- }
+ // Find the names of the authors and remove date codes from there
+ QFile license(QStringLiteral(":/LICENSE"));
+ license.open(QFile::ReadOnly);
+ const QStringList copyright = copyrightHolders(&license);
+
ui.credits->setTextFormat(Qt::PlainText);
ui.credits->setText(copyright.join(QStringLiteral("\n")));
widget->show();
}
+QStringList MainWindow::copyrightHolders(QFile *file) const
+{
+ QStringList ret;
+
+ const auto copyrightHolders = QString::fromUtf8(file->readAll()).split(QLatin1Char('\n'));
+ for (const auto &line : std::as_const(copyrightHolders)) {
+ const QString prefix(QStringLiteral("Copyright (C) "));
+ if (line.startsWith(prefix)) {
+ const int pos = prefix.size();
+ ret << QChar(0xa9 /* COPYRIGHT SIGN */) + QLatin1Char(' ') +
+ line.mid(pos).replace(QRegularExpression(QLatin1String("(\\d) - (\\d)")),
+ QLatin1String("\\1") + QChar(0x2014 /* EM DASH */) + QLatin1String("\\2"));
+ }
+ }
+
+ return ret;
+}
+
void MainWindow::slotSaveCurrentMessageBody()
{
Q_FOREACH(const QModelIndex &item, msgListWidget->tree->selectionModel()->selectedIndexes()) {
diff --git a/src/Gui/Window.h b/src/Gui/Window.h
index a31199483..54006163c 100644
--- a/src/Gui/Window.h
+++ b/src/Gui/Window.h
@@ -36,6 +36,7 @@
class QAuthenticator;
class QCloseEvent;
+class QFile;
class QItemSelection;
class QLabel;
class QMessageBox;
@@ -235,6 +236,7 @@ private:
void createActions();
void createWidgets();
void setupModels();
+ QStringList copyrightHolders(QFile *file) const;
void nukeModels();
void connectModelActions();