Fix button color assignation on creation

This commit is contained in:
lupoDharkael
2017-05-31 14:40:55 +02:00
parent a75572c518
commit 78b27e3780
2 changed files with 13 additions and 5 deletions

View File

@@ -82,9 +82,6 @@ CaptureWidget::CaptureWidget(QWidget *parent) :
// we need to increase by 1 the size to reach to the end of the screen
resize(size.width()+1, size.height()+1);
// init interface color
QSettings settings;
m_uiColor = settings.value("uiColor").value<QColor>();
m_contrastUiColor = settings.value("contastUiColor").value<QColor>();
show();
m_colorPicker = new ColorPicker(this);
@@ -99,14 +96,22 @@ CaptureWidget::~CaptureWidget() {
// selection in the capture
void CaptureWidget::redefineButtons() {
QSettings settings;
m_uiColor = settings.value("uiColor").value<QColor>();
m_contrastUiColor = settings.value("contastUiColor").value<QColor>();
auto buttonsInt = settings.value("buttons").value<QList<int> >();
QVector<Button*> vectorButtons;
bool iconIsWhite = Button::iconIsWhite(m_uiColor);
QString buttonStyle = Button::getStyle(m_uiColor);
for (auto i: buttonsInt) {
auto t = static_cast<Button::Type>(i);
Button *b = new Button(t, this);
Button *b = new Button(t, iconIsWhite, this);
if (t == Button::Type::selectionIndicator) {
m_sizeIndButton = b;
}
b->setStyleSheet(buttonStyle);
connect(b, &Button::hovered, this, &CaptureWidget::enterButton);
connect(b, &Button::mouseExited, this, &CaptureWidget::leaveButton);

View File

@@ -86,6 +86,7 @@ void UIcolorEditor::initButtons() {
frame->setFixedSize(frameSize, frameSize);
frame->setFrameStyle(QFrame::StyledPanel);
m_buttonMainColor = new Button(Button::Type::circle, frame);
m_buttonMainColor->move(m_buttonMainColor->x() + extraSize/2, m_buttonMainColor->y() + extraSize/2);
QHBoxLayout *h1 = new QHBoxLayout();
@@ -101,8 +102,10 @@ void UIcolorEditor::initButtons() {
frame2->setFixedSize(frameSize, frameSize);
frame2->setFrameStyle(QFrame::StyledPanel);
m_buttonContrast = new Button(Button::Type::circle, frame2);
QColor contrastColor = QSettings().value("contastUiColor").value<QColor>();
bool whiteIconWithContast = Button::iconIsWhite(contrastColor);
m_buttonContrast = new Button(Button::Type::circle,
whiteIconWithContast, frame2);
m_buttonContrast->setStyleSheet(Button::getStyle(contrastColor));
m_buttonContrast->move(m_buttonContrast->x() + extraSize/2,
m_buttonContrast->y() + extraSize/2);