Commit 43b046fa authored by Tomaz  Canabrava's avatar Tomaz Canabrava
Browse files

New profile setting: value of the dim color

This adds the a configuration option for the amount of alpha channel
we can use for konsole when in Dim inactive mode. Me and Sipos Miklos
implemented this together.
parent 4a0f1195
......@@ -68,7 +68,6 @@ const Profile::PropertyInfo Profile::DefaultPropertyNames[] = {
, { LocalTabTitleFormat , "tabtitle" , nullptr , QVariant::String }
, { RemoteTabTitleFormat , "RemoteTabTitleFormat" , GENERAL_GROUP , QVariant::String }
, { ShowTerminalSizeHint , "ShowTerminalSizeHint" , GENERAL_GROUP , QVariant::Bool }
, { DimWhenInactive , "DimWhenInactive" , GENERAL_GROUP , QVariant::Bool }
, { StartInCurrentSessionDir , "StartInCurrentSessionDir" , GENERAL_GROUP , QVariant::Bool }
, { SilenceSeconds, "SilenceSeconds" , GENERAL_GROUP , QVariant::Int }
, { TerminalColumns, "TerminalColumns" , GENERAL_GROUP , QVariant::Int }
......@@ -85,6 +84,8 @@ const Profile::PropertyInfo Profile::DefaultPropertyNames[] = {
, { UseFontLineCharacters, "UseFontLineChararacters", APPEARANCE_GROUP, QVariant::Bool }
, { LineSpacing , "LineSpacing" , APPEARANCE_GROUP , QVariant::Int }
, { TabColor, "TabColor", APPEARANCE_GROUP, QVariant::Color }
, { DimValue, "DimmValue", APPEARANCE_GROUP, QVariant::Int }
, { DimWhenInactive , "DimWhenInactive" , GENERAL_GROUP , QVariant::Bool }
// Keyboard
, { KeyBindings , "KeyBindings" , KEYBOARD_GROUP , QVariant::String }
......@@ -172,6 +173,7 @@ void Profile::useFallback()
setProperty(RemoteTabTitleFormat, QStringLiteral("(%u) %H"));
setProperty(ShowTerminalSizeHint, true);
setProperty(DimWhenInactive, false);
setProperty(DimValue, 128);
setProperty(StartInCurrentSessionDir, true);
setProperty(MenuIndex, QStringLiteral("0"));
setProperty(SilenceSeconds, 10);
......
......@@ -306,7 +306,9 @@ public:
/** (bool) Reverse the order of URL hints */
ReverseUrlHints,
/** (QColor) used in tab color */
TabColor
TabColor,
/** (int) Value of the Dimm Effect */
DimValue
};
Q_ENUM(Property)
......@@ -469,6 +471,11 @@ public:
return property<bool>(Profile::DimWhenInactive);
}
int dimValue() const
{
return property<int>(Profile::DimValue);
}
/** Convenience method for property<QFont>(Profile::Font) */
QFont font() const
{
......
......@@ -26,7 +26,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="colorSchemeTab">
<attribute name="title">
......@@ -469,12 +469,9 @@
<attribute name="title">
<string comment="Items that do not fit in other categories">Miscellaneous</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="miscTabLayout" columnstretch="0,1">
<layout class="QGridLayout" name="miscTabLayout" columnstretch="0,0,0">
<property name="spacing">
<number>6</number>
</property>
......@@ -620,6 +617,13 @@
</layout>
</widget>
</item>
<item row="2" column="0" alignment="Qt::AlignRight|Qt::AlignVCenter">
<widget class="QLabel" name="label">
<property name="text">
<string>Window:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer>
<property name="orientation">
......@@ -636,10 +640,13 @@
</property>
</spacer>
</item>
<item row="2" column="0" alignment="Qt::AlignRight|Qt::AlignVCenter">
<widget class="QLabel" name="label">
<item row="3" column="1">
<widget class="QCheckBox" name="dimWhenInactiveCheckbox">
<property name="toolTip">
<string>Indicate whether the window is active by dimming the colors</string>
</property>
<property name="text">
<string>Window:</string>
<string>Dim the colors when the window loses focus</string>
</property>
</widget>
</item>
......@@ -653,15 +660,36 @@
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="dimWhenInactiveCheckbox">
<property name="toolTip">
<string>Indicate whether the window is active by dimming the colors</string>
</property>
<property name="text">
<string>Dim the colors when the window loses focus</string>
</property>
</widget>
<item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>translucent</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="dimValue">
<property name="maximum">
<number>255</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksAbove</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>opaque</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
......
......@@ -573,6 +573,11 @@ void EditProfileDialog::setDimWhenInactive(bool value)
updateTempProfileProperty(Profile::DimWhenInactive, value);
}
void EditProfileDialog::setDimValue(int value)
{
updateTempProfileProperty(Profile::DimValue, value);
}
void EditProfileDialog::tabTitleFormatChanged(const QString &format)
{
updateTempProfileProperty(Profile::LocalTabTitleFormat, format);
......@@ -768,6 +773,10 @@ void EditProfileDialog::setupAppearancePage(const Profile::Ptr &profile)
_appearanceUi->dimWhenInactiveCheckbox->setChecked(profile->dimWhenInactive());
connect(_appearanceUi->dimWhenInactiveCheckbox, &QCheckBox::toggled, this,
&Konsole::EditProfileDialog::setDimWhenInactive);
_appearanceUi->dimValue->setValue(profile->dimValue());
connect(_appearanceUi->dimValue, &QSlider::valueChanged,
this, &Konsole::EditProfileDialog::setDimValue);
}
void EditProfileDialog::setAntialiasText(bool enable)
......
......@@ -132,6 +132,7 @@ private Q_SLOTS:
void terminalRowsEntryChanged(int);
void showTerminalSizeHint(bool);
void setDimWhenInactive(bool);
void setDimValue(int value);
void showEnvironmentEditor();
// appearance page
......
......@@ -1352,9 +1352,9 @@ void TerminalDisplay::paintEvent(QPaintEvent* pe)
paintFilters(paint);
const bool drawDimmed = _dimWhenInactive && !hasFocus();
const QColor dimColor(0, 0, 0, 128);
for (const QRect &rect : region) {
if (drawDimmed) {
if (drawDimmed) {
const QColor dimColor(0, 0, 0, _dimValue);
for (const QRect &rect : region) {
paint.fillRect(rect, dimColor);
}
}
......@@ -4129,6 +4129,7 @@ void TerminalDisplay::applyProfile(const Profile::Ptr &profile)
// mouse wheel zoom
_mouseWheelZoom = profile->mouseWheelZoomEnabled();
setAlternateScrolling(profile->property<bool>(Profile::AlternateScrolling));
_dimValue = profile->dimValue();
}
void TerminalDisplay::printScreen()
......
......@@ -894,6 +894,7 @@ private:
qreal _opacity;
bool _dimWhenInactive;
int _dimValue;
ScrollState _scrollWheelState;
IncrementalSearchBar *_searchBar;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment