Changeset View
Changeset View
Standalone View
Standalone View
src/ExportManager.cpp
Show First 20 Lines • Show All 164 Lines • ▼ Show 20 Line(s) | 161 | { | |||
---|---|---|---|---|---|
165 | constexpr auto maxCounterLength = 20; // std::numeric_limits<quint64>::max() == 18446744073709551615 | 165 | constexpr auto maxCounterLength = 20; // std::numeric_limits<quint64>::max() == 18446744073709551615 | ||
166 | constexpr auto maxLength = maxFilenameLength - maxCounterLength - maxExtensionLength; | 166 | constexpr auto maxLength = maxFilenameLength - maxCounterLength - maxExtensionLength; | ||
167 | result.truncate(maxLength); | 167 | result.truncate(maxLength); | ||
168 | return result; | 168 | return result; | ||
169 | } | 169 | } | ||
170 | 170 | | |||
171 | QString ExportManager::makeAutosaveFilename() | 171 | QString ExportManager::makeAutosaveFilename() | ||
172 | { | 172 | { | ||
173 | KSharedConfigPtr config = KSharedConfig::openConfig(QStringLiteral("spectaclerc")); | | |||
174 | KConfigGroup generalConfig = KConfigGroup(config, "General"); | | |||
175 | | ||||
176 | const QDateTime timestamp = QDateTime::currentDateTime(); | 173 | const QDateTime timestamp = QDateTime::currentDateTime(); | ||
177 | QString baseName = generalConfig.readEntry("save-filename-format", "Screenshot_%Y%M%D_%H%m%S"); | 174 | QString baseName = SpectacleConfig::instance()->autoSaveFilenameFormat(); | ||
178 | 175 | | |||
179 | QString title; | 176 | QString title; | ||
180 | 177 | | |||
181 | if (mGrabMode == ImageGrabber::GrabMode::ActiveWindow || | 178 | if (mGrabMode == ImageGrabber::GrabMode::ActiveWindow || | ||
182 | mGrabMode == ImageGrabber::GrabMode::TransientWithParent || | 179 | mGrabMode == ImageGrabber::GrabMode::TransientWithParent || | ||
183 | mGrabMode == ImageGrabber::GrabMode::WindowUnderCursor) { | 180 | mGrabMode == ImageGrabber::GrabMode::WindowUnderCursor) { | ||
184 | title = mWindowTitle.replace(QLatin1String("/"), QLatin1String("_")); // POSIX doesn't allow "/" in filenames | 181 | title = mWindowTitle.replace(QLatin1String("/"), QLatin1String("_")); // POSIX doesn't allow "/" in filenames | ||
185 | } else { | 182 | } else { | ||
Show All 17 Lines | |||||
203 | while (result.startsWith(QLatin1Char('/'))) { | 200 | while (result.startsWith(QLatin1Char('/'))) { | ||
204 | result.remove(0, 1); | 201 | result.remove(0, 1); | ||
205 | } | 202 | } | ||
206 | while (result.endsWith(QLatin1Char('/'))) { | 203 | while (result.endsWith(QLatin1Char('/'))) { | ||
207 | result.chop(1); | 204 | result.chop(1); | ||
208 | } | 205 | } | ||
209 | 206 | | |||
210 | if (result.isEmpty()) { | 207 | if (result.isEmpty()) { | ||
211 | result = QStringLiteral("Screenshot"); | 208 | result = SpectacleConfig::instance()->defaultFilename(); | ||
212 | } | 209 | } | ||
213 | return truncatedFilename(result); | 210 | return truncatedFilename(result); | ||
214 | } | 211 | } | ||
215 | 212 | | |||
216 | QString ExportManager::autoIncrementFilename(const QString &baseName, const QString &extension, | 213 | QString ExportManager::autoIncrementFilename(const QString &baseName, const QString &extension, | ||
217 | FileNameAlreadyUsedCheck isFileNameUsed) | 214 | FileNameAlreadyUsedCheck isFileNameUsed) | ||
218 | { | 215 | { | ||
219 | QString result = truncatedFilename(baseName) + QLatin1Literal(".") + extension; | 216 | QString result = truncatedFilename(baseName) + QLatin1Literal(".") + extension; | ||
▲ Show 20 Lines • Show All 263 Lines • Show Last 20 Lines |