1 /******************************************************************************\ 2 * Copyright (c) 2004-2020 3 * 4 * Author(s): 5 * Volker Fischer 6 * 7 ****************************************************************************** 8 * 9 * This program is free software; you can redistribute it and/or modify it under 10 * the terms of the GNU General Public License as published by the Free Software 11 * Foundation; either version 2 of the License, or (at your option) any later 12 * version. 13 * 14 * This program is distributed in the hope that it will be useful, but WITHOUT 15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 * details. 18 * 19 * You should have received a copy of the GNU General Public License along with 20 * this program; if not, write to the Free Software Foundation, Inc., 21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 22 * 23 \******************************************************************************/ 24 25 #pragma once 26 27 #include <QFrame> 28 #include <QPixmap> 29 #include <QTimer> 30 #include <QLayout> 31 #include <QProgressBar> 32 #include <QStackedLayout> 33 #include "util.h" 34 #include "global.h" 35 36 /* Definitions ****************************************************************/ 37 #define NUM_LEDS_INCL_CLIP_LED ( NUM_STEPS_LED_BAR + 1 ) 38 #define CLIP_IND_TIME_OUT_MS 20000 39 40 /* Classes ********************************************************************/ 41 class CLevelMeter : public QWidget 42 { 43 Q_OBJECT 44 45 public: 46 enum ELevelMeterType 47 { 48 MT_LED, 49 MT_BAR, 50 MT_SLIM_BAR 51 }; 52 53 CLevelMeter ( QWidget* parent = nullptr ); 54 virtual ~CLevelMeter(); 55 56 void SetValue ( const double dValue ); 57 void SetLevelMeterType ( const ELevelMeterType eNType ); 58 59 protected: 60 class cLED 61 { 62 public: 63 enum ELightColor 64 { 65 RL_DISABLED, 66 RL_BLACK, 67 RL_GREEN, 68 RL_YELLOW, 69 RL_RED 70 }; 71 72 cLED ( QWidget* parent ); 73 74 void SetColor ( const ELightColor eNewColor ); GetColor()75 ELightColor GetColor() { return eCurLightColor; }; GetLabelPointer()76 QLabel* GetLabelPointer() { return pLEDLabel; } 77 78 protected: 79 QPixmap BitmCubeRoundBlack; 80 QPixmap BitmCubeRoundGreen; 81 QPixmap BitmCubeRoundYellow; 82 QPixmap BitmCubeRoundRed; 83 84 ELightColor eCurLightColor; 85 QLabel* pLEDLabel; 86 }; 87 mousePressEvent(QMouseEvent *)88 virtual void mousePressEvent ( QMouseEvent* ) override { ClipReset(); } 89 90 void SetBarMeterStyleAndClipStatus ( const ELevelMeterType eNType, const bool bIsClip ); 91 92 QStackedLayout* pStackedLayout; 93 ELevelMeterType eLevelMeterType; 94 CVector<cLED*> vecpLEDs; 95 QProgressBar* pBarMeter; 96 97 QTimer TimerClip; 98 99 public slots: 100 void ClipReset(); 101 }; 102