LCOV - code coverage report
Current view: top level - src/notationscene/widgets - colorlabel.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 30 0
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : /*
       2              :  * SPDX-License-Identifier: GPL-3.0-only
       3              :  * MuseScore-Studio-CLA-applies
       4              :  *
       5              :  * MuseScore Studio
       6              :  * Music Composition & Notation
       7              :  *
       8              :  * Copyright (C) 2021 MuseScore Limited and others
       9              :  *
      10              :  * This program is free software: you can redistribute it and/or modify
      11              :  * it under the terms of the GNU General Public License version 3 as
      12              :  * published by the Free Software Foundation.
      13              :  *
      14              :  * This program is distributed in the hope that it will be useful,
      15              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17              :  * GNU General Public License for more details.
      18              :  *
      19              :  * You should have received a copy of the GNU General Public License
      20              :  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
      21              :  */
      22              : 
      23              : #include "colorlabel.h"
      24              : 
      25              : #include <QColorDialog>
      26              : #include <QPainter>
      27              : 
      28              : #include "translation.h"
      29              : 
      30              : using namespace muse;
      31              : 
      32              : namespace Awl {
      33            0 : ColorLabel::ColorLabel(QWidget* parent)
      34            0 :     : QPushButton(parent)
      35              : {
      36            0 :     connect(this, &QPushButton::clicked, this, &ColorLabel::colorButtonClicked);
      37            0 :     setFlat(true);
      38            0 : }
      39              : 
      40            0 : void ColorLabel::setColor(const QColor& c)
      41              : {
      42            0 :     const bool changed = _color != c;
      43            0 :     _color = c;
      44            0 :     update();
      45            0 :     if (changed) {
      46            0 :         emit this->colorChanged(_color);
      47              :     }
      48            0 : }
      49              : 
      50            0 : QSize ColorLabel::sizeHint() const
      51              : {
      52            0 :     return QSize(30, 30);
      53              : }
      54              : 
      55            0 : void ColorLabel::paintEvent(QPaintEvent* ev)
      56              : {
      57            0 :     QPainter p(this);
      58            0 :     p.setPen(Qt::NoPen);
      59            0 :     p.setBrush(_color);
      60            0 :     p.drawRoundedRect(rect(), 3, 3);
      61              : 
      62            0 :     QPushButton::paintEvent(ev);
      63            0 : }
      64              : 
      65            0 : void ColorLabel::colorButtonClicked(bool)
      66              : {
      67            0 :     QColor c = QColorDialog::getColor(_color, this,
      68            0 :                                       muse::qtrc("notation", "Select color"),
      69              :                                       QColorDialog::ShowAlphaChannel
      70              :                                       );
      71            0 :     if (c.isValid()) {
      72            0 :         if (_color != c) {
      73            0 :             _color = c;
      74            0 :             emit colorChanged(_color);
      75            0 :             update();
      76              :         }
      77              :     }
      78            0 : }
      79              : }
        

Generated by: LCOV version 2.0-1