1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 11:45:53 +01:00

Do not enable alpha channel for background colors

This commit is contained in:
Martin Tůma 2017-09-15 08:30:00 +02:00
parent d0b3f48caf
commit 753c4e8db0
3 changed files with 8 additions and 3 deletions

View File

@ -9,6 +9,8 @@
ColorBox::ColorBox(QWidget *parent) : QWidget(parent) ColorBox::ColorBox(QWidget *parent) : QWidget(parent)
{ {
_color = Qt::red; _color = Qt::red;
_alpha = true;
setSizePolicy(QSizePolicy::QSizePolicy::Minimum, QSizePolicy::Fixed); setSizePolicy(QSizePolicy::QSizePolicy::Minimum, QSizePolicy::Fixed);
} }
@ -51,9 +53,9 @@ void ColorBox::mousePressEvent(QMouseEvent *event)
{ {
if (event->button() != Qt::LeftButton) if (event->button() != Qt::LeftButton)
return; return;
QColorDialog::ColorDialogOptions options = _alpha
QColor color = QColorDialog::getColor(_color, this, QString(), ? QColorDialog::ShowAlphaChannel : (QColorDialog::ColorDialogOptions)0;
QColorDialog::ShowAlphaChannel); QColor color = QColorDialog::getColor(_color, this, QString(), options);
if (color.isValid()) { if (color.isValid()) {
_color = color; _color = color;
update(); update();

View File

@ -12,6 +12,7 @@ public:
const QColor &color() const {return _color;} const QColor &color() const {return _color;}
void setColor(const QColor &color); void setColor(const QColor &color);
void enableAlphaChannel(bool enable) {_alpha = enable;}
QSize sizeHint() const; QSize sizeHint() const;
@ -24,6 +25,7 @@ protected:
private: private:
QColor _color; QColor _color;
bool _alpha;
}; };
#endif // COLORBOX_H #endif // COLORBOX_H

View File

@ -181,6 +181,7 @@ QWidget *OptionsDialog::createAppearancePage()
_mapOpacity->setValue(_options->mapOpacity); _mapOpacity->setValue(_options->mapOpacity);
_backgroundColor = new ColorBox(); _backgroundColor = new ColorBox();
_backgroundColor->setColor(_options->backgroundColor); _backgroundColor->setColor(_options->backgroundColor);
_backgroundColor->enableAlphaChannel(false);
QFormLayout *mapLayout = new QFormLayout(); QFormLayout *mapLayout = new QFormLayout();
mapLayout->addRow(tr("Background color:"), _backgroundColor); mapLayout->addRow(tr("Background color:"), _backgroundColor);
mapLayout->addRow(tr("Map opacity:"), _mapOpacity); mapLayout->addRow(tr("Map opacity:"), _mapOpacity);