Skip to content

Commit

Permalink
Decrease app icon opacity when storing is disabled
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Holecek <[email protected]>
  • Loading branch information
hluk committed May 17, 2020
1 parent aae6e05 commit cea49a0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/gui/iconfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ const char imagesRecourcePath[] = ":/images/";
/// Up to this value of background lightness, icon color will be lighter.
const int lightThreshold = 100;

bool sessionIconTagEnabledFlag = true;

QPointer<QObject> activePaintDevice;

QIcon fromTheme(const QString &name)
Expand Down Expand Up @@ -239,6 +241,18 @@ void replaceColor(QPixmap *pix, const QColor &targetColor)
p.drawPixmap(0, 0, pix2);
}

void disableIcon(QPixmap *pix)
{
QPixmap pix2(pix->size());
pix2.fill(Qt::transparent);
{
QPainter p(&pix2);
p.setOpacity(0.7);
p.drawPixmap(0, 0, *pix);
}
*pix = pix2;
}

QPixmap drawFontIcon(ushort id, int w, int h, const QColor &color)
{
const auto cacheKey = QString("id:%1|%2x%3|%4")
Expand Down Expand Up @@ -535,10 +549,11 @@ class AppIconEngine final : public BaseIconEngine
const bool useColoredIcon = !hasNormalIcon();
const auto sessionColor = useColoredIcon ? sessionIconColor() : QColor();

const auto cacheKey = QString("app:%1|%2x%3")
const auto cacheKey = QString("app:%1|%2x%3|%4")
.arg(sessionColor.name())
.arg(size.width())
.arg(size.height());
.arg(size.height())
.arg(sessionIconTagEnabledFlag);

{
QPixmap pixmap;
Expand All @@ -551,6 +566,9 @@ class AppIconEngine final : public BaseIconEngine
if ( sessionColor.isValid() )
replaceColor(&pix, sessionColor);

if (!sessionIconTagEnabledFlag)
disableIcon(&pix);

QPixmapCache::insert(cacheKey, pix);

return pix;
Expand Down Expand Up @@ -683,6 +701,11 @@ void setSessionIconTagColor(QColor color)
sessionIconTagColorVariable() = color;
}

void setSessionIconEnabled(bool enabled)
{
sessionIconTagEnabledFlag = enabled;
}

QColor sessionIconColor()
{
return ::sessionIconColorVariable();
Expand Down
2 changes: 2 additions & 0 deletions src/gui/iconfactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ void setSessionIconTag(const QString &tag);

void setSessionIconTagColor(QColor color);

void setSessionIconEnabled(bool enabled);

QColor sessionIconColor();

QString sessionIconTag();
Expand Down
4 changes: 4 additions & 0 deletions src/gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3061,6 +3061,10 @@ void MainWindow::disableClipboardStoring(bool disable)

updateMonitoringActions();

::setSessionIconEnabled(!disable);

updateIcon();

if (m_clipboardStoringDisabled)
runScript("setTitle(); showDataNotification()");

Expand Down

0 comments on commit cea49a0

Please sign in to comment.