From 753c4e8db0b5a76e3dcc60ea005777c4d3796f78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Fri, 15 Sep 2017 08:30:00 +0200 Subject: [PATCH] Do not enable alpha channel for background colors --- src/colorbox.cpp | 8 +++++--- src/colorbox.h | 2 ++ src/optionsdialog.cpp | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/colorbox.cpp b/src/colorbox.cpp index 95e3cc79..be67d368 100644 --- a/src/colorbox.cpp +++ b/src/colorbox.cpp @@ -9,6 +9,8 @@ ColorBox::ColorBox(QWidget *parent) : QWidget(parent) { _color = Qt::red; + _alpha = true; + setSizePolicy(QSizePolicy::QSizePolicy::Minimum, QSizePolicy::Fixed); } @@ -51,9 +53,9 @@ void ColorBox::mousePressEvent(QMouseEvent *event) { if (event->button() != Qt::LeftButton) return; - - QColor color = QColorDialog::getColor(_color, this, QString(), - QColorDialog::ShowAlphaChannel); + QColorDialog::ColorDialogOptions options = _alpha + ? QColorDialog::ShowAlphaChannel : (QColorDialog::ColorDialogOptions)0; + QColor color = QColorDialog::getColor(_color, this, QString(), options); if (color.isValid()) { _color = color; update(); diff --git a/src/colorbox.h b/src/colorbox.h index f596fcbc..7954b0b2 100644 --- a/src/colorbox.h +++ b/src/colorbox.h @@ -12,6 +12,7 @@ public: const QColor &color() const {return _color;} void setColor(const QColor &color); + void enableAlphaChannel(bool enable) {_alpha = enable;} QSize sizeHint() const; @@ -24,6 +25,7 @@ protected: private: QColor _color; + bool _alpha; }; #endif // COLORBOX_H diff --git a/src/optionsdialog.cpp b/src/optionsdialog.cpp index 1159388e..3caeae10 100644 --- a/src/optionsdialog.cpp +++ b/src/optionsdialog.cpp @@ -181,6 +181,7 @@ QWidget *OptionsDialog::createAppearancePage() _mapOpacity->setValue(_options->mapOpacity); _backgroundColor = new ColorBox(); _backgroundColor->setColor(_options->backgroundColor); + _backgroundColor->enableAlphaChannel(false); QFormLayout *mapLayout = new QFormLayout(); mapLayout->addRow(tr("Background color:"), _backgroundColor); mapLayout->addRow(tr("Map opacity:"), _mapOpacity);