Changeset View
Changeset View
Standalone View
Standalone View
src/ExportManager.cpp
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Line(s) | 76 | { | |||
---|---|---|---|---|---|
77 | mWindowTitle = windowTitle; | 77 | mWindowTitle = windowTitle; | ||
78 | } | 78 | } | ||
79 | 79 | | |||
80 | QString ExportManager::windowTitle() const | 80 | QString ExportManager::windowTitle() const | ||
81 | { | 81 | { | ||
82 | return mWindowTitle; | 82 | return mWindowTitle; | ||
83 | } | 83 | } | ||
84 | 84 | | |||
85 | Spectacle::CaptureMode ExportManager::captureMode() const | 85 | CaptureMode ExportManager::captureMode() const | ||
86 | { | 86 | { | ||
87 | return mCaptureMode; | 87 | return mCaptureMode; | ||
88 | } | 88 | } | ||
89 | 89 | | |||
90 | void ExportManager::setCaptureMode(const Spectacle::CaptureMode &theCaptureMode) | 90 | void ExportManager::setCaptureMode(const CaptureMode &theCaptureMode) | ||
91 | { | 91 | { | ||
92 | mCaptureMode = theCaptureMode; | 92 | mCaptureMode = theCaptureMode; | ||
93 | } | 93 | } | ||
94 | 94 | | |||
95 | void ExportManager::setPixmap(const QPixmap &pixmap) | 95 | void ExportManager::setPixmap(const QPixmap &pixmap) | ||
96 | { | 96 | { | ||
97 | mSavePixmap = pixmap; | 97 | mSavePixmap = pixmap; | ||
98 | 98 | | |||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | |||||
165 | 165 | | |||
166 | QString ExportManager::formatFilename(const QString &nameTemplate) | 166 | QString ExportManager::formatFilename(const QString &nameTemplate) | ||
167 | { | 167 | { | ||
168 | const QDateTime timestamp = mPixmapTimestamp; | 168 | const QDateTime timestamp = mPixmapTimestamp; | ||
169 | QString baseName = nameTemplate; | 169 | QString baseName = nameTemplate; | ||
170 | const QString baseDir = defaultSaveLocation(); | 170 | const QString baseDir = defaultSaveLocation(); | ||
171 | QString title; | 171 | QString title; | ||
172 | 172 | | |||
173 | if (mCaptureMode == Spectacle::CaptureMode::ActiveWindow || | 173 | if (mCaptureMode == CaptureMode::ActiveWindow || | ||
174 | mCaptureMode == Spectacle::CaptureMode::TransientWithParent || | 174 | mCaptureMode == CaptureMode::TransientWithParent || | ||
175 | mCaptureMode == Spectacle::CaptureMode::WindowUnderCursor) { | 175 | mCaptureMode == CaptureMode::WindowUnderCursor) { | ||
176 | title = mWindowTitle.replace(QLatin1String("/"), QLatin1String("_")); // POSIX doesn't allow "/" in filenames | 176 | title = mWindowTitle.replace(QLatin1String("/"), QLatin1String("_")); // POSIX doesn't allow "/" in filenames | ||
177 | } else { | 177 | } else { | ||
178 | // Remove '%T' with separators around it | 178 | // Remove '%T' with separators around it | ||
179 | const auto wordSymbol = QStringLiteral(R"(\p{L}\p{M}\p{N})"); | 179 | const auto wordSymbol = QStringLiteral(R"(\p{L}\p{M}\p{N})"); | ||
180 | const auto separator = QStringLiteral("([^%1]+)").arg(wordSymbol); | 180 | const auto separator = QStringLiteral("([^%1]+)").arg(wordSymbol); | ||
181 | const auto re = QRegularExpression(QStringLiteral("(.*?)(%1%T|%T%1)(.*?)").arg(separator)); | 181 | const auto re = QRegularExpression(QStringLiteral("(.*?)(%1%T|%T%1)(.*?)").arg(separator)); | ||
182 | baseName.replace(re, QStringLiteral(R"(\1\5)")); | 182 | baseName.replace(re, QStringLiteral(R"(\1\5)")); | ||
183 | } | 183 | } | ||
▲ Show 20 Lines • Show All 391 Lines • Show Last 20 Lines |