[LyX/master] Change the transparency background to checker
Koji Yokota
yokota at lyx.org
Mon Jul 6 02:56:02 UTC 2026
commit f17336e4fa644aac62c8347919eff7a7abd1d09c
Author: Koji Yokota <yokota at lyx.org>
Date: Mon Jul 6 11:54:24 2026 +0900
Change the transparency background to checker
Thanks to Jürgen
---
src/frontends/qt/ColorCache.cpp | 24 ++++++++++++------------
src/frontends/qt/ColorCache.h | 2 +-
src/frontends/qt/GuiBranches.cpp | 2 +-
src/frontends/qt/GuiIndices.cpp | 2 +-
src/frontends/qt/GuiPrefs.cpp | 4 ++--
5 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/src/frontends/qt/ColorCache.cpp b/src/frontends/qt/ColorCache.cpp
index fadaa153c6..558774b9b7 100644
--- a/src/frontends/qt/ColorCache.cpp
+++ b/src/frontends/qt/ColorCache.cpp
@@ -196,23 +196,23 @@ bool ColorCache::isLightColor(ARGBColor const & fg, ARGBColor const & bg)
return (L + 0.05) / (0.0 + 0.05) > (1.0 + 0.05) / (L + 0.05);
}
-QPixmap ColorCache::setSwatchBackground(int width, int height)
+QPixmap ColorCache::getTransparencySymbol(int width, int height)
{
QPixmap background(width, height);
- background.fill(Qt::white);
+ background.fill(Qt::lightGray);
- // paint a triangle
QPainter painter(&background);
- painter.setRenderHint(QPainter::Antialiasing);
- QPolygon polygon;
- polygon << QPoint(width, 0)
- << QPoint(0, height)
- << QPoint(0, 0);
- painter.setPen(QColor(Qt::black));
- painter.setBrush(QColor(Qt::black));
- painter.drawPolygon(polygon);
+ int squareSize = width / 8;
+
+ for (int i = 0; i < 8; ++i) {
+ for (int j = 0; j < 8; ++j) {
+ // Paint a chessboard-like structure
+ if ((i + j) % 2 == 1)
+ painter.fillRect(j * squareSize, i * squareSize, squareSize,
+ squareSize, Qt::darkGray);
+ }
+ }
painter.end();
-
return background;
}
diff --git a/src/frontends/qt/ColorCache.h b/src/frontends/qt/ColorCache.h
index 81644f03c0..4899988ef2 100644
--- a/src/frontends/qt/ColorCache.h
+++ b/src/frontends/qt/ColorCache.h
@@ -60,7 +60,7 @@ public:
/// clear all colors
void clear() { initialized_ = false; }
- static QPixmap setSwatchBackground(int width, int height);
+ static QPixmap getTransparencySymbol(int width, int height);
static QPixmap mergePixmaps(QPixmap const *fg, QPixmap const *bg);
private:
diff --git a/src/frontends/qt/GuiBranches.cpp b/src/frontends/qt/GuiBranches.cpp
index e3ce31d9cd..4b9c62d229 100644
--- a/src/frontends/qt/GuiBranches.cpp
+++ b/src/frontends/qt/GuiBranches.cpp
@@ -77,7 +77,7 @@ GuiBranches::GuiBranches(QWidget * parent)
newBranchLE->installEventFilter(this);
newBranchLE->setValidator(new NoNewLineValidator(newBranchLE));
- swatchbg_ = ColorCache::setSwatchBackground(30, 10);
+ swatchbg_ = ColorCache::getTransparencySymbol(30, 10);
}
diff --git a/src/frontends/qt/GuiIndices.cpp b/src/frontends/qt/GuiIndices.cpp
index c4650391bf..c7e2f4a9fb 100644
--- a/src/frontends/qt/GuiIndices.cpp
+++ b/src/frontends/qt/GuiIndices.cpp
@@ -64,7 +64,7 @@ GuiIndices::GuiIndices(QWidget * parent)
indexOptionsLE->setValidator(new NoNewLineValidator(indexOptionsLE));
newIndexLE->setValidator(new NoNewLineValidator(newIndexLE));
- swatchbg_ = ColorCache::setSwatchBackground(30, 10);
+ swatchbg_ = ColorCache::getTransparencySymbol(30, 10);
}
diff --git a/src/frontends/qt/GuiPrefs.cpp b/src/frontends/qt/GuiPrefs.cpp
index f1357e42ce..f186f0b470 100644
--- a/src/frontends/qt/GuiPrefs.cpp
+++ b/src/frontends/qt/GuiPrefs.cpp
@@ -4721,8 +4721,8 @@ ColorSwatchDelegate::ColorSwatchDelegate(QObject *parent)
{
pane_ = static_cast<PrefColors*>(parent);
- bg_pixmap_ = ColorCache::setSwatchBackground(pane_->swatch_width_,
- pane_->swatch_height_);
+ bg_pixmap_ = ColorCache::getTransparencySymbol(pane_->swatch_width_,
+ pane_->swatch_height_);
}
More information about the lyx-cvs
mailing list