TTKMusicPlayer  4.3.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicsoundeffectswidget.cpp
Go to the documentation of this file.
2 #include "ui_musicsoundeffectswidget.h"
3 #include "musicsettingmanager.h"
4 #include "musicwidgetheaders.h"
5 
7  : QWidget(parent),
8  m_enabled(false),
9  m_property(property)
10 {
11  QVBoxLayout *layout = new QVBoxLayout(this);
12  layout->setContentsMargins(1, 1, 1, 1);
13  layout->setSpacing(0);
14 
15  m_textLabel = new QLabel(TTK_SPACE + property.m_name, this);
16  m_textLabel->setObjectName("Background");
17  m_textLabel->setStyleSheet(QString("#%1{ %2 }").arg(m_textLabel->objectName(), TTK::UI::BackgroundStyle05) +
23 
24  QWidget *func = new QWidget(this);
25  func->setStyleSheet(TTK::UI::BackgroundStyle04);
26  QHBoxLayout *funcLayout = new QHBoxLayout(func);
27  funcLayout->setContentsMargins(0, 5, 5, 0);
28  funcLayout->setSpacing(0);
29 
30  m_settingButton = new QPushButton(func);
32  m_settingButton->setCursor(QCursor(Qt::PointingHandCursor));
33  m_settingButton->setFixedWidth(40);
34  m_settingButton->setText(tr("Sets"));
35  m_settingButton->setEnabled(false);
36  connect(m_settingButton, SIGNAL(clicked()), SLOT(soundEffectValueChanged()));
37 
38  m_openButton = new QPushButton(func);
40  m_openButton->setIcon(QIcon(":/tiny/btn_effect_on"));
41  m_openButton->setToolTip(tr("On"));
42  m_openButton->setCursor(QCursor(Qt::PointingHandCursor));
43  m_openButton->setFixedSize(16, 16);
44  connect(m_openButton, SIGNAL(clicked()), SLOT(setPluginEnabled()));
45 
46 #ifdef Q_OS_UNIX
47  m_settingButton->setFocusPolicy(Qt::NoFocus);
48  m_openButton->setFocusPolicy(Qt::NoFocus);
49 #endif
50 
51  QLabel *iconLabel = new QLabel(func);
52  iconLabel->setStyleSheet(TTK::UI::BackgroundStyle01);
53  iconLabel->setPixmap(QPixmap(":/tiny/lb_arrow_down_normal"));
54  iconLabel->setFixedSize(16, 16);
55 
56  funcLayout->addWidget(m_settingButton);
57  funcLayout->addWidget(iconLabel);
58  funcLayout->addStretch(1);
59  funcLayout->addWidget(m_openButton);
60 
61  layout->addWidget(m_textLabel);
62  layout->addWidget(func);
63 
64  setLayout(layout);
65  setFixedHeight(60);
66 }
67 
69 {
70  delete m_textLabel;
71  delete m_openButton;
72  delete m_settingButton;
73 }
74 
76 {
77  m_enabled = !enabled;
79 }
80 
82 {
83  return m_enabled;
84 }
85 
87 {
88  if(!m_enabled)
89  {
90  m_enabled = true;
91  m_openButton->setIcon(QIcon(":/tiny/btn_effect_off"));
93 
95  m_openButton->setToolTip(tr("Off"));
96  }
97  else
98  {
99  m_enabled = false;
100  m_openButton->setIcon(QIcon(":/tiny/btn_effect_on"));
102  m_settingButton->setEnabled(false);
103  m_openButton->setToolTip(tr("On"));
104  }
105 }
106 
108 {
110 }
111 
112 
113 
115  : MusicAbstractMoveDialog(parent),
116  m_ui(new Ui::MusicSoundEffectsWidget)
117 {
118  m_ui->setupUi(this);
119  setFixedSize(size());
120  setBackgroundLabel(m_ui->background);
121 
122  m_ui->topTitleCloseButton->setIcon(QIcon(":/functions/btn_close_hover"));
123  m_ui->topTitleCloseButton->setStyleSheet(TTK::UI::ToolButtonStyle04);
124  m_ui->topTitleCloseButton->setCursor(QCursor(Qt::PointingHandCursor));
125  m_ui->topTitleCloseButton->setToolTip(tr("Close"));
126  connect(m_ui->topTitleCloseButton, SIGNAL(clicked()), SLOT(close()));
127 
129  m_ui->stateComboBox->addItems({tr("OperatorAll"), tr("All Off")});
130  connect(m_ui->stateComboBox, SIGNAL(currentIndexChanged(int)), SLOT(stateComboBoxChanged(int)));
131 
132  TTK::Widget::generateVScrollAreaStyle(m_ui->scrollArea, m_ui->effectContainer);
133  initialize();
134 }
135 
137 {
138  qDeleteAll(m_items);
139  delete m_ui;
140 }
141 
143 {
144  if(v)
145  {
146  const QString &value = G_SETTING_PTR->value(MusicSettingManager::EnhancedEffectValue).toString();
147  const QStringList &effects = value.split(";", QtSkipEmptyParts);
148  for(const QString &effect : qAsConst(effects))
149  {
150  TTK::TTKQmmp::setEffectEnabled(effect, true);
151  }
152  }
153  else
154  {
155  QString value;
156  for(const MusicPluginProperty &property : TTK::TTKQmmp::effectModules())
157  {
158  if(TTK::TTKQmmp::isEffectEnabled(property.m_type))
159  {
160  value.append(property.m_type + ";");
161  }
162  }
163 
165  }
166 }
167 
169 {
170  m_ui->stateComboBox->blockSignals(true);
171  m_ui->stateComboBox->setCurrentIndex(0);
172  m_ui->stateComboBox->blockSignals(false);
173 
174  if(index == 1)
175  {
177  {
178  item->setPluginEnabled(false);
179  }
180  }
181 }
182 
184 {
185  QVBoxLayout *layout = new QVBoxLayout(m_ui->effectContainer);
186  layout->setContentsMargins(0, 0, 0, 0);
187  layout->setSpacing(10);
188  m_ui->effectContainer->setLayout(layout);
189 
190  for(const MusicPluginProperty &property : TTK::TTKQmmp::effectModules())
191  {
192  MusicSoundEffectsItemWidget *item = new MusicSoundEffectsItemWidget(property, this);
193  m_items.append(item);
194  item->setPluginEnabled(TTK::TTKQmmp::isEffectEnabled(property.m_type));
195  layout->addWidget(item);
196  }
197 }
#define QtSkipEmptyParts
String skip empty parts.
Definition: ttkqtcompat.h:143
QList< MusicSoundEffectsItemWidget * > m_items
static const QString BackgroundStyle05
Definition: musicuiobject.h:94
The class of the sound effect item widget.
TTK_MODULE_EXPORT void generateComboBoxStyle(QComboBox *widget, const QString &style={})
static const QString CheckBoxStyle01
CheckBox.
static const QString SliderStyle06
static const QString PushButtonStyle01
PushButton.
TTK_MODULE_EXPORT MusicPluginPropertyList effectModules()
voidpf void uLong size
Definition: ioapi.h:136
static const QString PushButtonStyle12
void setBackgroundLabel(QLabel *label) noexcept
static const QString BackgroundStyle04
Definition: musicuiobject.h:91
#define qAsConst
Definition: ttkqtglobal.h:57
MusicSoundEffectsItemWidget(const MusicPluginProperty &property, QWidget *parent=nullptr)
Ui::MusicSoundEffectsWidget * m_ui
static const QString SpinBoxStyle01
SpinBox.
MusicSoundEffectsWidget(QWidget *parent=nullptr)
static const QString BackgroundStyle01
Background.
Definition: musicuiobject.h:77
TTK_MODULE_EXPORT void setEffectEnabled(const QString &name, bool enabled)
TTK_MODULE_EXPORT void generateVScrollAreaStyle(QWidget *widget, QWidget *parent, bool background=true)
The class of the moving dialog base.
static const QString ToolButtonStyle04
TTK_MODULE_EXPORT void showEffectSetting(const QString &name, QWidget *parent)
static const QString ComboBoxStyle01
ComboBox.
TTK_MODULE_EXPORT bool isEffectEnabled(const QString &name)
The class of the sound effect widget.
The class of the plugin property.
#define TTK_SPACE
Definition: ttkglobal.h:268
#define G_SETTING_PTR