Changeset View
Changeset View
Standalone View
Standalone View
plugins/filetemplates/licensepage.cpp
Show First 20 Lines • Show All 111 Lines • ▼ Show 20 Line(s) | 110 | { | |||
---|---|---|---|---|---|
112 | QFile newLicense(availableLicenses[licenseIndex].path); | 112 | QFile newLicense(availableLicenses[licenseIndex].path); | ||
113 | 113 | | |||
114 | if(newLicense.open(QIODevice::ReadOnly | QIODevice::Text)) | 114 | if(newLicense.open(QIODevice::ReadOnly | QIODevice::Text)) | ||
115 | { | 115 | { | ||
116 | QTextStream newLicenseText(&newLicense); | 116 | QTextStream newLicenseText(&newLicense); | ||
117 | newLicenseText.setAutoDetectUnicode(true); | 117 | newLicenseText.setAutoDetectUnicode(true); | ||
118 | licenseText = newLicenseText.readAll(); | 118 | licenseText = newLicenseText.readAll(); | ||
119 | newLicense.close(); | 119 | newLicense.close(); | ||
120 | | ||||
121 | // license text files are stored with a trailing linebreak, | ||||
122 | // as otherwise some tools complain about it | ||||
123 | // so deal with that and remove any potential trailing linebreak | ||||
124 | // which otherwise would result in a trailing empty line | ||||
125 | QRegularExpression anyLinebreakAtEnd(QStringLiteral("(\n|\r\n)$")); | ||||
126 | licenseText.remove(anyLinebreakAtEnd); | ||||
120 | } | 127 | } | ||
121 | else | 128 | else | ||
122 | licenseText = QStringLiteral("Error, could not open license file.\n Was it deleted?"); | 129 | licenseText = QStringLiteral("Error, could not open license file.\n Was it deleted?"); | ||
123 | } | 130 | } | ||
124 | 131 | | |||
125 | availableLicenses[licenseIndex].contents = licenseText; | 132 | availableLicenses[licenseIndex].contents = licenseText; | ||
126 | } | 133 | } | ||
127 | 134 | | |||
▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Line(s) | 233 | { | |||
243 | 250 | | |||
244 | delete d->license; | 251 | delete d->license; | ||
245 | delete d; | 252 | delete d; | ||
246 | } | 253 | } | ||
247 | 254 | | |||
248 | QString LicensePage::license() const | 255 | QString LicensePage::license() const | ||
249 | { | 256 | { | ||
250 | QString licenseText = d->license->licenseTextEdit->document()->toPlainText(); | 257 | QString licenseText = d->license->licenseTextEdit->document()->toPlainText(); | ||
251 | /* Add date, name and email to license text */ | 258 | /* Add date, name and email to license text */ | ||
kfunk: I think the additional newline should be rather stripped inside `LicensePagePrivate… | |||||
252 | licenseText.replace(QLatin1String("<year>"), QDate::currentDate().toString(QStringLiteral("yyyy"))); | 259 | licenseText.replace(QLatin1String("<year>"), QDate::currentDate().toString(QStringLiteral("yyyy"))); | ||
253 | licenseText.replace(QLatin1String("<month>"), QDate::currentDate().toString(QStringLiteral("MM"))); | 260 | licenseText.replace(QLatin1String("<month>"), QDate::currentDate().toString(QStringLiteral("MM"))); | ||
254 | licenseText.replace(QLatin1String("<day>"), QDate::currentDate().toString(QStringLiteral("dd"))); | 261 | licenseText.replace(QLatin1String("<day>"), QDate::currentDate().toString(QStringLiteral("dd"))); | ||
255 | QString developer(QStringLiteral("%1 <%2>")); | 262 | QString developer(QStringLiteral("%1 <%2>")); | ||
256 | KEMailSettings emailSettings; | 263 | KEMailSettings emailSettings; | ||
257 | QString name = emailSettings.getSetting(KEMailSettings::RealName); | 264 | QString name = emailSettings.getSetting(KEMailSettings::RealName); | ||
258 | if (name.isEmpty()) | 265 | if (name.isEmpty()) | ||
259 | { | 266 | { | ||
Show All 24 Lines |
I think the additional newline should be rather stripped inside LicensePagePrivate::readLicense, not here.
I just tested this:
-> We just need to fix the contents of the presets after they were loaded from disk.