TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicvolumepopwidget.cpp
Go to the documentation of this file.
1 #include "musicvolumepopwidget.h"
3 #include "musicwidgetheaders.h"
4 #include "ttkclickedslider.h"
5 
6 #include <QTimer>
7 
9  : MusicToolMenuWidget(parent),
10  m_menuShown(false)
11 {
12  initialize();
13 
14  disconnect(this, SIGNAL(clicked()), this, SLOT(popupMenu()));
15 }
16 
18 {
19  delete m_volumeSlider;
20 }
21 
23 {
24  m_volumeSlider->blockSignals(true);
25  m_volumeSlider->setValue(value);
26  m_volumeSlider->blockSignals(false);
27 
28  QString style = TTK::UI::BtnSound;
29  if(66 < value && value <=100)
30  {
31  style += "QToolButton{ margin-left:-60px; }";
32  }
33  else if(33 < value && value <=66)
34  {
35  style += "QToolButton{ margin-left:-40px; }";
36  }
37  else if(0 < value && value <=33)
38  {
39  style += "QToolButton{ margin-left:-20px; }";
40  }
41  else
42  {
43  style += "QToolButton{ margin-left:-80px; }";
44  }
45  setStyleSheet(style);
46  setToolTip(QString::number(value));
47 }
48 
50 {
51  return m_volumeSlider->value();
52 }
53 
55 {
56  MusicToolMenuWidget::leaveEvent(event);
58 }
59 
61 {
62  MusicToolMenuWidget::enterEvent(event);
63  if(!m_menuShown)
64  {
65  m_menuShown = true;
66  popupMenu();
68  }
69 }
70 
72 {
73  m_menuShown = false;
74 }
75 
77 {
79  m_containWidget->setFixedSize(20, 100);
80  QHBoxLayout *layout = new QHBoxLayout(m_containWidget);
81  layout->setContentsMargins(0, 9, 0, 9);
82  layout->setSpacing(0);
83 
84  m_volumeSlider = new TTKClickedSlider(Qt::Vertical, this);
85  m_volumeSlider->setCursor(QCursor(Qt::PointingHandCursor));
86  m_volumeSlider->setRange(0, 100);
87  m_volumeSlider->setStyleSheet(TTK::UI::SliderStyle02);
88 
89  connect(m_volumeSlider, SIGNAL(valueChanged(int)), SIGNAL(volumeChanged(int)));
90 
91  layout->addWidget(m_volumeSlider);
92  m_containWidget->setLayout(layout);
93 }
#define QtEnterEvent
Event enter.
Definition: ttkqtcompat.h:160
The class of the tool menu base widget.
MusicVolumePopWidget(QWidget *parent=nullptr)
TTKClickedSlider * m_volumeSlider
void volumeChanged(int volume)
MusicToolMenu * m_menu
The class of the slider that can clicked any position.
static const QString SliderStyle02
virtual void leaveEvent(QEvent *event) overridefinal
#define TTK_SIGNLE_SHOT(...)
Definition: ttkqtglobal.h:177
static constexpr const char * BtnSound
#define TTK_SLOT
Definition: ttkqtglobal.h:165
#define TTK_DN_S2MS
Definition: ttkglobal.h:276
virtual void enterEvent(QtEnterEvent *event) overridefinal