Changeset View
Changeset View
Standalone View
Standalone View
src/ExportManager.cpp
Show All 35 Lines | |||||
36 | #include <KIO/FileCopyJob> | 36 | #include <KIO/FileCopyJob> | ||
37 | #include <KIO/StatJob> | 37 | #include <KIO/StatJob> | ||
38 | 38 | | |||
39 | #include "SpectacleConfig.h" | 39 | #include "SpectacleConfig.h" | ||
40 | 40 | | |||
41 | ExportManager::ExportManager(QObject *parent) : | 41 | ExportManager::ExportManager(QObject *parent) : | ||
42 | QObject(parent), | 42 | QObject(parent), | ||
43 | mSavePixmap(QPixmap()), | 43 | mSavePixmap(QPixmap()), | ||
44 | mLastSavePath(QUrl()), | ||||
44 | mTempFile(QUrl()), | 45 | mTempFile(QUrl()), | ||
45 | mTempDir(nullptr) | 46 | mTempDir(nullptr) | ||
46 | {} | 47 | { | ||
48 | connect(this, &ExportManager::imageSaved, [this](const QUrl savedAt) { | ||||
49 | mLastSavePath = savedAt; | ||||
50 | }); | ||||
51 | } | ||||
47 | 52 | | |||
48 | ExportManager::~ExportManager() | 53 | ExportManager::~ExportManager() | ||
49 | { | 54 | { | ||
50 | delete mTempDir; | 55 | delete mTempDir; | ||
51 | } | 56 | } | ||
52 | 57 | | |||
53 | ExportManager* ExportManager::instance() | 58 | ExportManager* ExportManager::instance() | ||
54 | { | 59 | { | ||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Line(s) | 106 | { | |||
113 | if (!(savePathDir.exists())) { | 118 | if (!(savePathDir.exists())) { | ||
114 | savePathDir.mkpath(QStringLiteral(".")); | 119 | savePathDir.mkpath(QStringLiteral(".")); | ||
115 | generalConfig.writePathEntry("last-saved-to", savePath); | 120 | generalConfig.writePathEntry("last-saved-to", savePath); | ||
116 | } | 121 | } | ||
117 | 122 | | |||
118 | return savePath; | 123 | return savePath; | ||
119 | } | 124 | } | ||
120 | 125 | | |||
126 | QUrl ExportManager::lastSavePath() const | ||||
127 | { | ||||
128 | return isFileExists(mLastSavePath) ? mLastSavePath : QUrl(); | ||||
129 | } | ||||
130 | | ||||
121 | void ExportManager::setSaveLocation(const QString &savePath) | 131 | void ExportManager::setSaveLocation(const QString &savePath) | ||
122 | { | 132 | { | ||
123 | KSharedConfigPtr config = KSharedConfig::openConfig(QStringLiteral("spectaclerc")); | 133 | KSharedConfigPtr config = KSharedConfig::openConfig(QStringLiteral("spectaclerc")); | ||
124 | KConfigGroup generalConfig = KConfigGroup(config, "General"); | 134 | KConfigGroup generalConfig = KConfigGroup(config, "General"); | ||
125 | 135 | | |||
126 | generalConfig.writePathEntry("last-saved-to", savePath); | 136 | generalConfig.writePathEntry("last-saved-to", savePath); | ||
127 | } | 137 | } | ||
128 | 138 | | |||
▲ Show 20 Lines • Show All 266 Lines • Show Last 20 Lines |