Changeset View
Changeset View
Standalone View
Standalone View
src/Profile.cpp
Show All 26 Lines | |||||
27 | #include <QRegularExpression> | 27 | #include <QRegularExpression> | ||
28 | 28 | | |||
29 | // KDE | 29 | // KDE | ||
30 | #include <KLocalizedString> | 30 | #include <KLocalizedString> | ||
31 | #include <QFontDatabase> | 31 | #include <QFontDatabase> | ||
32 | 32 | | |||
33 | // Konsole | 33 | // Konsole | ||
34 | #include "Enumeration.h" | 34 | #include "Enumeration.h" | ||
35 | #include "ColorSchemeManager.h" | ||||
35 | 36 | | |||
36 | using namespace Konsole; | 37 | using namespace Konsole; | ||
37 | 38 | | |||
38 | // mappings between property enum values and names | 39 | // mappings between property enum values and names | ||
39 | // | 40 | // | ||
40 | // multiple names are defined for some property values, | 41 | // multiple names are defined for some property values, | ||
41 | // in these cases, the "proper" string name comes first, | 42 | // in these cases, the "proper" string name comes first, | ||
42 | // as that is used when reading/writing profiles from/to disk | 43 | // as that is used when reading/writing profiles from/to disk | ||
Show All 28 Lines | 56 | const Profile::PropertyInfo Profile::DefaultPropertyNames[] = { | |||
71 | , { SilenceSeconds, "SilenceSeconds" , GENERAL_GROUP , QVariant::Int } | 72 | , { SilenceSeconds, "SilenceSeconds" , GENERAL_GROUP , QVariant::Int } | ||
72 | , { TerminalColumns, "TerminalColumns" , GENERAL_GROUP , QVariant::Int } | 73 | , { TerminalColumns, "TerminalColumns" , GENERAL_GROUP , QVariant::Int } | ||
73 | , { TerminalRows, "TerminalRows" , GENERAL_GROUP , QVariant::Int } | 74 | , { TerminalRows, "TerminalRows" , GENERAL_GROUP , QVariant::Int } | ||
74 | , { TerminalMargin, "TerminalMargin" , GENERAL_GROUP , QVariant::Int } | 75 | , { TerminalMargin, "TerminalMargin" , GENERAL_GROUP , QVariant::Int } | ||
75 | , { TerminalCenter, "TerminalCenter" , GENERAL_GROUP , QVariant::Bool } | 76 | , { TerminalCenter, "TerminalCenter" , GENERAL_GROUP , QVariant::Bool } | ||
76 | 77 | | |||
77 | // Appearance | 78 | // Appearance | ||
78 | , { Font , "Font" , APPEARANCE_GROUP , QVariant::Font } | 79 | , { Font , "Font" , APPEARANCE_GROUP , QVariant::Font } | ||
79 | , { ColorScheme , "ColorScheme" , APPEARANCE_GROUP , QVariant::String } | 80 | , { ColorSchemeName , "ColorScheme" , APPEARANCE_GROUP , QVariant::String } | ||
80 | , { ColorScheme , "colors" , nullptr , QVariant::String } | 81 | , { ColorSchemeName , "colors" , nullptr , QVariant::String } | ||
81 | , { AntiAliasFonts, "AntiAliasFonts" , APPEARANCE_GROUP , QVariant::Bool } | 82 | , { AntiAliasFonts, "AntiAliasFonts" , APPEARANCE_GROUP , QVariant::Bool } | ||
82 | , { BoldIntense, "BoldIntense", APPEARANCE_GROUP, QVariant::Bool } | 83 | , { BoldIntense, "BoldIntense", APPEARANCE_GROUP, QVariant::Bool } | ||
83 | , { UseFontLineCharacters, "UseFontLineChararacters", APPEARANCE_GROUP, QVariant::Bool } | 84 | , { UseFontLineCharacters, "UseFontLineChararacters", APPEARANCE_GROUP, QVariant::Bool } | ||
84 | , { LineSpacing , "LineSpacing" , APPEARANCE_GROUP , QVariant::Int } | 85 | , { LineSpacing , "LineSpacing" , APPEARANCE_GROUP , QVariant::Int } | ||
85 | 86 | | |||
86 | // Keyboard | 87 | // Keyboard | ||
87 | , { KeyBindings , "KeyBindings" , KEYBOARD_GROUP , QVariant::String } | 88 | , { KeyBindings , "KeyBindings" , KEYBOARD_GROUP , QVariant::String } | ||
88 | 89 | | |||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Line(s) | 155 | { | |||
172 | setProperty(TerminalColumns, 80); | 173 | setProperty(TerminalColumns, 80); | ||
173 | setProperty(TerminalRows, 24); | 174 | setProperty(TerminalRows, 24); | ||
174 | setProperty(TerminalMargin, 1); | 175 | setProperty(TerminalMargin, 1); | ||
175 | setProperty(TerminalCenter, false); | 176 | setProperty(TerminalCenter, false); | ||
176 | setProperty(MouseWheelZoomEnabled, true); | 177 | setProperty(MouseWheelZoomEnabled, true); | ||
177 | setProperty(AlternateScrolling, true); | 178 | setProperty(AlternateScrolling, true); | ||
178 | 179 | | |||
179 | setProperty(KeyBindings, QStringLiteral("default")); | 180 | setProperty(KeyBindings, QStringLiteral("default")); | ||
180 | setProperty(ColorScheme, QStringLiteral("Linux")); //use DarkPastels when is start support blue ncurses UI properly | 181 | setProperty(ColorSchemeName, QStringLiteral("Linux")); //use DarkPastels when is start support blue ncurses UI properly | ||
181 | setProperty(Font, QFontDatabase::systemFont(QFontDatabase::FixedFont)); | 182 | setProperty(Font, QFontDatabase::systemFont(QFontDatabase::FixedFont)); | ||
182 | 183 | | |||
183 | setProperty(HistoryMode, Enum::FixedSizeHistory); | 184 | setProperty(HistoryMode, Enum::FixedSizeHistory); | ||
184 | setProperty(HistorySize, 1000); | 185 | setProperty(HistorySize, 1000); | ||
185 | setProperty(ScrollBarPosition, Enum::ScrollBarRight); | 186 | setProperty(ScrollBarPosition, Enum::ScrollBarRight); | ||
186 | setProperty(ScrollFullPage, false); | 187 | setProperty(ScrollFullPage, false); | ||
187 | 188 | | |||
188 | setProperty(FlowControlEnabled, true); | 189 | setProperty(FlowControlEnabled, true); | ||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | |||||
273 | } | 274 | } | ||
274 | QHash<Profile::Property, QVariant> Profile::setProperties() const | 275 | QHash<Profile::Property, QVariant> Profile::setProperties() const | ||
275 | { | 276 | { | ||
276 | return _propertyValues; | 277 | return _propertyValues; | ||
277 | } | 278 | } | ||
278 | void Profile::setProperty(Property p, const QVariant& value) | 279 | void Profile::setProperty(Property p, const QVariant& value) | ||
279 | { | 280 | { | ||
280 | _propertyValues.insert(p, value); | 281 | _propertyValues.insert(p, value); | ||
282 | | ||||
283 | // Not the best place but we have just one set method. | ||||
284 | if (p == ColorSchemeName) { | ||||
285 | _colorScheme = ColorSchemeManager::instance()->findColorScheme(value.toString()); | ||||
286 | } | ||||
281 | } | 287 | } | ||
282 | bool Profile::isPropertySet(Property p) const | 288 | bool Profile::isPropertySet(Property p) const | ||
283 | { | 289 | { | ||
284 | return _propertyValues.contains(p); | 290 | return _propertyValues.contains(p); | ||
285 | } | 291 | } | ||
286 | 292 | | |||
287 | Profile::Property Profile::lookupByName(const QString& name) | 293 | Profile::Property Profile::lookupByName(const QString& name) | ||
288 | { | 294 | { | ||
Show All 32 Lines | 324 | { | |||
321 | while (iter->name != nullptr) { | 327 | while (iter->name != nullptr) { | ||
322 | info << QLatin1String(iter->name) + QStringLiteral(" : ") + QLatin1String(QVariant(iter->type).typeName()); | 328 | info << QLatin1String(iter->name) + QStringLiteral(" : ") + QLatin1String(QVariant(iter->type).typeName()); | ||
323 | iter++; | 329 | iter++; | ||
324 | } | 330 | } | ||
325 | 331 | | |||
326 | return info; | 332 | return info; | ||
327 | } | 333 | } | ||
328 | 334 | | |||
335 | ColorScheme const *Profile::colorScheme() const { | ||||
336 | return _colorScheme; | ||||
337 | } | ||||
338 | | ||||
329 | QHash<Profile::Property, QVariant> ProfileCommandParser::parse(const QString& input) | 339 | QHash<Profile::Property, QVariant> ProfileCommandParser::parse(const QString& input) | ||
330 | { | 340 | { | ||
331 | QHash<Profile::Property, QVariant> changes; | 341 | QHash<Profile::Property, QVariant> changes; | ||
332 | 342 | | |||
333 | // regular expression to parse profile change requests. | 343 | // regular expression to parse profile change requests. | ||
334 | // | 344 | // | ||
335 | // format: property=value;property=value ... | 345 | // format: property=value;property=value ... | ||
336 | // | 346 | // | ||
Show All 37 Lines | 383 | } else if (value != profileValue) { | |||
374 | value = QVariant(); | 384 | value = QVariant(); | ||
375 | break; | 385 | break; | ||
376 | } | 386 | } | ||
377 | } | 387 | } | ||
378 | Profile::setProperty(properties->property, value); | 388 | Profile::setProperty(properties->property, value); | ||
379 | properties++; | 389 | properties++; | ||
380 | } | 390 | } | ||
381 | } | 391 | } | ||
392 | | ||||
382 | void ProfileGroup::setProperty(Property p, const QVariant& value) | 393 | void ProfileGroup::setProperty(Property p, const QVariant& value) | ||
383 | { | 394 | { | ||
384 | if (_profiles.count() > 1 && !canInheritProperty(p)) { | 395 | if (_profiles.count() > 1 && !canInheritProperty(p)) { | ||
385 | return; | 396 | return; | ||
386 | } | 397 | } | ||
387 | 398 | | |||
388 | Profile::setProperty(p, value); | 399 | Profile::setProperty(p, value); | ||
389 | foreach(Profile::Ptr profile, _profiles) { | 400 | foreach(Profile::Ptr profile, _profiles) { | ||
390 | profile->setProperty(p, value); | 401 | profile->setProperty(p, value); | ||
391 | } | 402 | } | ||
392 | } | 403 | } | ||
393 | 404 | |