Changeset View
Changeset View
Standalone View
Standalone View
src/Part.cpp
Show All 18 Lines | |||||
19 | 19 | | |||
20 | // Own | 20 | // Own | ||
21 | #include "Part.h" | 21 | #include "Part.h" | ||
22 | 22 | | |||
23 | // Qt | 23 | // Qt | ||
24 | #include <QStringList> | 24 | #include <QStringList> | ||
25 | #include <QDir> | 25 | #include <QDir> | ||
26 | #include <QKeyEvent> | 26 | #include <QKeyEvent> | ||
27 | #include <QMetaEnum> | ||||
27 | #include <QUrl> | 28 | #include <QUrl> | ||
28 | 29 | | |||
29 | // KDE | 30 | // KDE | ||
30 | #include <QAction> | 31 | #include <QAction> | ||
31 | #include <KActionCollection> | 32 | #include <KActionCollection> | ||
32 | #include <KPluginFactory> | 33 | #include <KPluginFactory> | ||
33 | #include <KLocalizedString> | 34 | #include <KLocalizedString> | ||
34 | #include <KConfigDialog> | 35 | #include <KConfigDialog> | ||
▲ Show 20 Lines • Show All 157 Lines • ▼ Show 20 Line(s) | |||||
192 | 193 | | |||
193 | QString Part::currentWorkingDirectory() const | 194 | QString Part::currentWorkingDirectory() const | ||
194 | { | 195 | { | ||
195 | Q_ASSERT(activeSession()); | 196 | Q_ASSERT(activeSession()); | ||
196 | 197 | | |||
197 | return activeSession()->currentWorkingDirectory(); | 198 | return activeSession()->currentWorkingDirectory(); | ||
198 | } | 199 | } | ||
199 | 200 | | |||
201 | #ifdef USE_TERMINALINTERFACEV2 | ||||
202 | QVariant Part::profileProperty(const QString &profileProperty) const | ||||
203 | { | ||||
204 | const auto metaEnum = QMetaEnum::fromType<Profile::Property>(); | ||||
205 | const auto value = metaEnum.keyToValue(profileProperty.toStdString().c_str()); | ||||
206 | | ||||
207 | if (value == -1) { | ||||
208 | return QString(); | ||||
209 | } | ||||
210 | | ||||
211 | const Profile::Property p = static_cast<Profile::Property>(value); | ||||
212 | return SessionManager::instance()->sessionProfile(activeSession())->property<QVariant>(p); | ||||
213 | } | ||||
214 | | ||||
215 | QStringList Part::availableProfiles() const | ||||
216 | { | ||||
217 | return ProfileManager::instance()->availableProfileNames(); | ||||
218 | } | ||||
219 | | ||||
220 | QString Part::currentProfileName() const | ||||
221 | { | ||||
222 | return SessionManager::instance()->sessionProfile(activeSession())->name(); | ||||
223 | } | ||||
224 | | ||||
225 | bool Part::setCurrentProfile(const QString &profileName) | ||||
226 | { | ||||
227 | | ||||
228 | Profile::Ptr profile; | ||||
229 | for(auto p : ProfileManager::instance()->allProfiles()) { | ||||
230 | if (p->name() == profileName) { | ||||
231 | profile = p; | ||||
232 | break; | ||||
233 | } | ||||
234 | } | ||||
235 | | ||||
236 | if (!profile) { | ||||
237 | profile = ProfileManager::instance()->loadProfile(profileName); | ||||
238 | } | ||||
239 | | ||||
240 | SessionManager::instance()->setSessionProfile(activeSession(), profile); | ||||
241 | return currentProfileName() == profileName; | ||||
242 | } | ||||
243 | #endif | ||||
244 | | ||||
200 | void Part::createSession(const QString &profileName, const QString &directory) | 245 | void Part::createSession(const QString &profileName, const QString &directory) | ||
201 | { | 246 | { | ||
202 | Profile::Ptr profile = ProfileManager::instance()->defaultProfile(); | 247 | Profile::Ptr profile = ProfileManager::instance()->defaultProfile(); | ||
203 | if (!profileName.isEmpty()) { | 248 | if (!profileName.isEmpty()) { | ||
204 | profile = ProfileManager::instance()->loadProfile(profileName); | 249 | profile = ProfileManager::instance()->loadProfile(profileName); | ||
205 | } | 250 | } | ||
206 | 251 | | |||
207 | Q_ASSERT(profile); | 252 | Q_ASSERT(profile); | ||
▲ Show 20 Lines • Show All 184 Lines • Show Last 20 Lines |