mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-04 22:17:31 +00:00
Customizable graph colors
This commit is contained in:
parent
978ac89aa9
commit
74e068d8d1
22 changed files with 266 additions and 97 deletions
35
Software/PC_Application/CustomWidgets/colorpickerbutton.cpp
Normal file
35
Software/PC_Application/CustomWidgets/colorpickerbutton.cpp
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#include "colorpickerbutton.h"
|
||||
#include <QColorDialog>
|
||||
|
||||
ColorPickerButton::ColorPickerButton(QWidget *parent)
|
||||
: QPushButton(parent)
|
||||
{
|
||||
color = Qt::white;
|
||||
connect(this, &ColorPickerButton::clicked, this, &ColorPickerButton::changeColor);
|
||||
updateBackground();
|
||||
}
|
||||
|
||||
void ColorPickerButton::setColor(const QColor &color)
|
||||
{
|
||||
this->color = color;
|
||||
updateBackground();
|
||||
}
|
||||
|
||||
const QColor &ColorPickerButton::getColor()
|
||||
{
|
||||
return color;
|
||||
}
|
||||
|
||||
void ColorPickerButton::changeColor()
|
||||
{
|
||||
auto newColor = QColorDialog::getColor(color, parentWidget(), "Select color", QColorDialog::DontUseNativeDialog);
|
||||
if(newColor.isValid() && newColor != color) {
|
||||
setColor(newColor);
|
||||
emit colorChanged(newColor);
|
||||
}
|
||||
}
|
||||
|
||||
void ColorPickerButton::updateBackground()
|
||||
{
|
||||
setStyleSheet("background-color:"+color.name());
|
||||
}
|
||||
23
Software/PC_Application/CustomWidgets/colorpickerbutton.h
Normal file
23
Software/PC_Application/CustomWidgets/colorpickerbutton.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#ifndef COLORPICKERBUTTON_H
|
||||
#define COLORPICKERBUTTON_H
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
class ColorPickerButton : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ColorPickerButton(QWidget *parent = nullptr);
|
||||
|
||||
void setColor(const QColor& color);
|
||||
const QColor& getColor();
|
||||
signals:
|
||||
void colorChanged(const QColor& color);
|
||||
private slots:
|
||||
void changeColor();
|
||||
private:
|
||||
void updateBackground();
|
||||
QColor color;
|
||||
};
|
||||
|
||||
#endif // COLORPICKERBUTTON_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue