Skip to content

Commit

Permalink
fix issue #63 and more
Browse files Browse the repository at this point in the history
  • Loading branch information
sardid committed Sep 2, 2022
1 parent b0a5734 commit a315a09
Show file tree
Hide file tree
Showing 11 changed files with 299 additions and 136 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

project(sierrabreezeenhanced)
set(PROJECT_VERSION "1.2.0")
set(PROJECT_VERSION "1.3.0")
set(PROJECT_VERSION_MAJOR 0)

cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
Expand Down
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

V1.3.0
---------

*

V1.2.0
---------

Expand Down
335 changes: 223 additions & 112 deletions breezebutton.cpp

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions breezebutton.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ namespace Breeze

//*@name colors
//@{
QColor fontColor() const;
QColor foregroundColor() const;
QColor backgroundColor() const;
QColor mixColors(const QColor&, const QColor&, qreal) const;
Expand Down
45 changes: 29 additions & 16 deletions breezedecoration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,25 +306,38 @@ namespace Breeze
//________________________________________________________________
QColor Decoration::fontColor() const
{
auto c = client().toStrongRef().data();

QColor darkTextColor( !c->isActive() && matchColorForTitleBar() ? QColor(81, 102, 107) : QColor(34, 45, 50) );
QColor lightTextColor( !c->isActive() && matchColorForTitleBar() ? QColor(192, 193, 194) : QColor(250, 251, 252) );
auto c = client().toStrongRef().data();

if (systemForegroundColor()) {
if( m_animation->state() == QAbstractAnimation::Running ) {
return KColorUtils::mix(
c->color( ColorGroup::Inactive, ColorRole::Foreground ),
c->color( ColorGroup::Active, ColorRole::Foreground ),
m_opacity );
}
else {
return c->color( c->isActive() ? ColorGroup::Active : ColorGroup::Inactive, ColorRole::Foreground );
}
}
else {
QColor darkTextColor( !c->isActive() && matchColorForTitleBar() ? QColor(81, 102, 107) : QColor(34, 45, 50) );
QColor lightTextColor( !c->isActive() && matchColorForTitleBar() ? QColor(192, 193, 194) : QColor(250, 251, 252) );

QColor titleBarColor = this->titleBarColor();
QColor titleBarColor = this->titleBarColor();

uint r = qRed(titleBarColor.rgb());
uint g = qGreen(titleBarColor.rgb());
uint b = qBlue(titleBarColor.rgb());
uint r = qRed(titleBarColor.rgb());
uint g = qGreen(titleBarColor.rgb());
uint b = qBlue(titleBarColor.rgb());

// modified from https://stackoverflow.com/questions/3942878/how-to-decide-font-color-in-white-or-black-depending-on-background-color
// qreal titleBarLuminance = (0.2126 * static_cast<qreal>(r) + 0.7152 * static_cast<qreal>(g) + 0.0722 * static_cast<qreal>(b)) / 255.;
// if ( titleBarLuminance > sqrt(1.05 * 0.05) - 0.05 )
qreal colorConditional = 0.299 * static_cast<qreal>(r) + 0.587 * static_cast<qreal>(g) + 0.114 * static_cast<qreal>(b);
if ( colorConditional > 186 || g > 186 ) // ( colorConditional > 186 ) // if ( colorConditional > 150 )
return darkTextColor;
else
return lightTextColor;
// modified from https://stackoverflow.com/questions/3942878/how-to-decide-font-color-in-white-or-black-depending-on-background-color
// qreal titleBarLuminance = (0.2126 * static_cast<qreal>(r) + 0.7152 * static_cast<qreal>(g) + 0.0722 * static_cast<qreal>(b)) / 255.;
// if ( titleBarLuminance > sqrt(1.05 * 0.05) - 0.05 )
qreal colorConditional = 0.299 * static_cast<qreal>(r) + 0.587 * static_cast<qreal>(g) + 0.114 * static_cast<qreal>(b);
if ( colorConditional > 186 || g > 186 ) // ( colorConditional > 186 ) // if ( colorConditional > 150 )
return darkTextColor;
else
return lightTextColor;
}

}

Expand Down
4 changes: 4 additions & 0 deletions breezedecoration.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ namespace Breeze
inline int titleBarAlpha() const;
inline bool matchColorForTitleBar() const;
inline bool drawBackgroundGradient() const;
inline bool systemForegroundColor() const;
//@}

//*@Decoration has a hovered button
Expand Down Expand Up @@ -242,6 +243,9 @@ namespace Breeze

bool Decoration::drawBackgroundGradient() const
{ return m_internalSettings->drawBackgroundGradient(); }

bool Decoration::systemForegroundColor() const
{ return m_internalSettings->systemForegroundColor(); }
}

#endif
5 changes: 5 additions & 0 deletions breezesettingsdata.kcfg
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@
<default>false</default>
</entry>

<!-- match colors -->
<entry name="SystemForegroundColor" type = "Bool">
<default>false</default>
</entry>

<!-- unison hovering -->
<entry name="UnisonHovering" type = "Bool">
<default>true</default>
Expand Down
5 changes: 5 additions & 0 deletions config/breezeconfigwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ namespace Breeze
connect( m_ui.drawTitleBarSeparator, &QAbstractButton::clicked, this, &ConfigWidget::updateChanged );
connect( m_ui.hideTitleBar, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
connect( m_ui.matchColorForTitleBar, &QAbstractButton::clicked, this, &ConfigWidget::updateChanged );
connect( m_ui.systemForegroundColor, &QAbstractButton::clicked, this, &ConfigWidget::updateChanged );

// track animations changes
connect( m_ui.animationsEnabled, &QAbstractButton::clicked, this, &ConfigWidget::updateChanged );
Expand Down Expand Up @@ -110,6 +111,7 @@ namespace Breeze
m_ui.drawTitleBarSeparator->setChecked( m_internalSettings->drawTitleBarSeparator() );
m_ui.hideTitleBar->setCurrentIndex( m_internalSettings->hideTitleBar() );
m_ui.matchColorForTitleBar->setChecked( m_internalSettings->matchColorForTitleBar() );
m_ui.systemForegroundColor->setChecked( m_internalSettings->systemForegroundColor() );

// load shadows
if( m_internalSettings->shadowSize() <= InternalSettings::ShadowVeryLarge ) m_ui.shadowSize->setCurrentIndex( m_internalSettings->shadowSize() );
Expand Down Expand Up @@ -160,6 +162,7 @@ namespace Breeze
m_internalSettings->setDrawTitleBarSeparator(m_ui.drawTitleBarSeparator->isChecked());
m_internalSettings->setHideTitleBar( m_ui.hideTitleBar->currentIndex() );
m_internalSettings->setMatchColorForTitleBar( m_ui.matchColorForTitleBar->isChecked() );
m_internalSettings->setSystemForegroundColor( m_ui.systemForegroundColor->isChecked() );

m_internalSettings->setShadowSize( m_ui.shadowSize->currentIndex() );
m_internalSettings->setShadowStrength( qRound( qreal(m_ui.shadowStrength->value()*255)/100 ) );
Expand Down Expand Up @@ -219,6 +222,7 @@ namespace Breeze
m_ui.drawTitleBarSeparator->setChecked( m_internalSettings->drawTitleBarSeparator() );
m_ui.hideTitleBar->setCurrentIndex( m_internalSettings->hideTitleBar() );
m_ui.matchColorForTitleBar->setChecked( m_internalSettings->matchColorForTitleBar() );
m_ui.systemForegroundColor->setChecked( m_internalSettings->systemForegroundColor() );

m_ui.animationsEnabled->setChecked( m_internalSettings->animationsEnabled() );
m_ui.animationsDuration->setValue( m_internalSettings->animationsDuration() );
Expand Down Expand Up @@ -265,6 +269,7 @@ namespace Breeze
else if (m_ui.drawTitleBarSeparator->isChecked() != m_internalSettings->drawTitleBarSeparator()) modified = true;
else if ( m_ui.hideTitleBar->currentIndex() != m_internalSettings->hideTitleBar() ) modified = true;
else if ( m_ui.matchColorForTitleBar->isChecked() != m_internalSettings->matchColorForTitleBar() ) modified = true;
else if ( m_ui.systemForegroundColor->isChecked() != m_internalSettings->systemForegroundColor() ) modified = true;

// animations
else if( m_ui.animationsEnabled->isChecked() != m_internalSettings->animationsEnabled() ) modified = true;
Expand Down
4 changes: 4 additions & 0 deletions config/breezeexceptiondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ namespace Breeze

connect( m_ui.hideTitleBar, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
connect( m_ui.matchColorForTitleBar, &QAbstractButton::clicked, this, &ExceptionDialog::updateChanged );
connect( m_ui.systemForegroundColor, &QAbstractButton::clicked, this, &ExceptionDialog::updateChanged );
connect( m_ui.drawTitleBarSeparator, &QAbstractButton::clicked, this, &ExceptionDialog::updateChanged );
connect( m_ui.drawBackgroundGradient, &QAbstractButton::clicked, this, &ExceptionDialog::updateChanged );
m_ui.gradientOverrideLabelSpinBox->setSpecialValueText(tr("None"));
Expand Down Expand Up @@ -89,6 +90,7 @@ namespace Breeze
m_ui.borderSizeComboBox->setCurrentIndex( m_exception->borderSize() );
m_ui.hideTitleBar->setCurrentIndex( m_exception->hideTitleBar() );
m_ui.matchColorForTitleBar->setChecked( m_exception->matchColorForTitleBar() );
m_ui.systemForegroundColor->setChecked( m_exception->systemForegroundColor() );
m_ui.drawTitleBarSeparator->setChecked( m_exception->drawTitleBarSeparator() );
m_ui.drawBackgroundGradient->setChecked( m_exception->drawBackgroundGradient() );
m_ui.gradientOverrideLabelSpinBox->setValue( m_exception->gradientOverride() );
Expand All @@ -112,6 +114,7 @@ namespace Breeze
m_exception->setBorderSize( m_ui.borderSizeComboBox->currentIndex() );
m_exception->setHideTitleBar( m_ui.hideTitleBar->currentIndex() );
m_exception->setMatchColorForTitleBar( m_ui.matchColorForTitleBar->isChecked() );
m_exception->setSystemForegroundColor( m_ui.systemForegroundColor->isChecked() );
m_exception->setDrawTitleBarSeparator( m_ui.drawTitleBarSeparator->isChecked() );
m_exception->setDrawBackgroundGradient( m_ui.drawBackgroundGradient->isChecked() );
m_exception->setGradientOverride( m_ui.gradientOverrideLabelSpinBox->value() );
Expand Down Expand Up @@ -139,6 +142,7 @@ namespace Breeze
else if( m_exception->borderSize() != m_ui.borderSizeComboBox->currentIndex() ) modified = true;
else if( m_exception->hideTitleBar() != m_ui.hideTitleBar->currentIndex() ) modified = true;
else if( m_exception->matchColorForTitleBar() != m_ui.matchColorForTitleBar->isChecked() ) modified = true;
else if( m_exception->systemForegroundColor() != m_ui.systemForegroundColor->isChecked() ) modified = true;
else if( m_exception->drawTitleBarSeparator() != m_ui.drawTitleBarSeparator->isChecked() ) modified = true;
else if( m_exception->drawBackgroundGradient() != m_ui.drawBackgroundGradient->isChecked() ) modified = true;
else if( m_exception->gradientOverride() != m_ui.gradientOverrideLabelSpinBox->value() ) modified = true;
Expand Down
12 changes: 10 additions & 2 deletions config/ui/breezeconfigurationui.ui
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
</property>
</widget>
</item>
<item row="10" column="1" colspan="4">
<item row="11" column="1" colspan="4">
<widget class="QCheckBox" name="drawBorderOnMaximizedWindows">
<property name="text">
<string>Allow resizing maximized windows from window edges</string>
Expand Down Expand Up @@ -120,7 +120,7 @@
</property>
</widget>
</item>
<item row="11" column="1" colspan="4">
<item row="12" column="1" colspan="4">
<widget class="QCheckBox" name="drawBackgroundGradient">
<property name="text">
<string>Draw window background gradient</string>
Expand Down Expand Up @@ -433,6 +433,13 @@
</property>
</widget>
</item>
<item row="10" column="1" colspan="4">
<widget class="QCheckBox" name="systemForegroundColor">
<property name="text">
<string>Use System Foreground Colors</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
Expand Down Expand Up @@ -785,6 +792,7 @@
<tabstop>buttonHOffset</tabstop>
<tabstop>hideTitleBar</tabstop>
<tabstop>matchColorForTitleBar</tabstop>
<tabstop>systemForegroundColor</tabstop>
<tabstop>unisonHovering</tabstop>
<tabstop>drawBorderOnMaximizedWindows</tabstop>
<tabstop>cornerRadiusSpinBox</tabstop>
Expand Down
17 changes: 12 additions & 5 deletions config/ui/breezeexceptiondialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,20 @@
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="systemForegroundColor">
<property name="text">
<string>Use System Foreground Colors</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="drawBackgroundGradient">
<property name="text">
<string>Draw window background gradient</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<item row="5" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
Expand Down Expand Up @@ -249,21 +256,21 @@
</item>
</layout>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QCheckBox" name="drawTitleBarSeparator">
<property name="text">
<string>Draw separator between Title Bar and Window</string>
</property>
</widget>
</item>
<item row="6" column="0">
<item row="7" column="0">
<widget class="QCheckBox" name="opaqueTitleBar">
<property name="text">
<string>Opaque title bar</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<item row="8" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer_3">
Expand Down Expand Up @@ -319,7 +326,7 @@
</item>
</layout>
</item>
<item row="8" column="0">
<item row="9" column="0">
<widget class="QCheckBox" name="isDialog">
<property name="text">
<string>Only for dialogs</string>
Expand Down

0 comments on commit a315a09

Please sign in to comment.