TTKMusicPlayer  4.3.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_slider;
20 }
21 
23 {
24  m_slider->blockSignals(true);
25  m_slider->setValue(value);
26  m_slider->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 
46  setStyleSheet(style);
47  setToolTip(QString::number(value));
48 }
49 
51 {
52  return m_slider->value();
53 }
54 
56 {
57  MusicToolMenuWidget::leaveEvent(event);
59 }
60 
62 {
63  MusicToolMenuWidget::enterEvent(event);
64  if(!m_menuShown)
65  {
66  m_menuShown = true;
67  popupMenu();
69  }
70 }
71 
73 {
74  m_menuShown = false;
75 }
76 
78 {
80 
81  m_containWidget->setFixedSize(20, 100);
82  QHBoxLayout *layout = new QHBoxLayout(m_containWidget);
83  layout->setContentsMargins(0, 9, 0, 9);
84  layout->setSpacing(0);
85 
86  m_slider = new TTKClickedSlider(Qt::Vertical, this);
87  m_slider->setCursor(QCursor(Qt::PointingHandCursor));
88  m_slider->setRange(0, 100);
89  m_slider->setStyleSheet(TTK::UI::SliderStyle02);
90 
91  connect(m_slider, SIGNAL(valueChanged(int)), SIGNAL(volumeChanged(int)));
92 
93  layout->addWidget(m_slider);
94  m_containWidget->setLayout(layout);
95 }
#define QtEnterEvent
Event enter.
Definition: ttkqtcompat.h:178
The class of the tool menu base widget.
MusicVolumePopWidget(QWidget *parent=nullptr)
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:189
static constexpr const char * BtnSound
#define TTK_SLOT
Definition: ttkqtglobal.h:177
#define TTK_DN_S2MS
Definition: ttkglobal.h:355
virtual void enterEvent(QtEnterEvent *event) overridefinal
TTKClickedSlider * m_slider