TTKMusicPlayer  3.7.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 "musicconnectionpool.h"
5 #include "musicwidgetheaders.h"
6 #include "musicplayer.h"
7 
9  : QWidget(parent),
10  m_enabled(false),
11  m_property(property)
12 {
13  QVBoxLayout *layout = new QVBoxLayout(this);
14  layout->setContentsMargins(1, 1, 1, 1);
15  layout->setSpacing(0);
16 
17  m_textLabel = new QLabel(" " + property.m_name, this);
18  m_textLabel->setObjectName("Background");
19  m_textLabel->setStyleSheet(QString("#Background{%1}").arg(TTK::UI::BackgroundStyle05) +
25 
26  QWidget *func = new QWidget(this);
27  func->setStyleSheet(TTK::UI::BackgroundStyle04);
28  QHBoxLayout *funcLayout = new QHBoxLayout(func);
29  funcLayout->setContentsMargins(0, 5, 5, 0);
30  funcLayout->setSpacing(0);
31 
32  m_settingButton = new QPushButton(func);
34  m_settingButton->setCursor(QCursor(Qt::PointingHandCursor));
35  m_settingButton->setFixedWidth(40);
36  m_settingButton->setText(tr("Sets"));
37  m_settingButton->setEnabled(false);
38  connect(m_settingButton, SIGNAL(clicked()), SLOT(soundEffectValueChanged()));
39 
40  m_openButton = new QPushButton(func);
42  m_openButton->setIcon(QIcon(":/tiny/btn_effect_on"));
43  m_openButton->setToolTip(tr("On"));
44  m_openButton->setCursor(QCursor(Qt::PointingHandCursor));
45  m_openButton->setFixedSize(16, 16);
46  connect(m_openButton, SIGNAL(clicked()), SLOT(setPluginEnabled()));
47 
48 #ifdef Q_OS_UNIX
49  m_settingButton->setFocusPolicy(Qt::NoFocus);
50  m_openButton->setFocusPolicy(Qt::NoFocus);
51 #endif
52 
53  QLabel *iconLabel = new QLabel(func);
54  iconLabel->setStyleSheet(TTK::UI::BackgroundStyle01);
55  iconLabel->setPixmap(QPixmap(":/tiny/lb_arrow_down_normal"));
56  iconLabel->setFixedSize(16, 16);
57 
58  funcLayout->addWidget(m_settingButton);
59  funcLayout->addWidget(iconLabel);
60  funcLayout->addStretch(1);
61  funcLayout->addWidget(m_openButton);
62 
63  layout->addWidget(m_textLabel);
64  layout->addWidget(func);
65 
66  setLayout(layout);
67  setFixedHeight(60);
68 }
69 
71 {
72  delete m_textLabel;
73  delete m_openButton;
74  delete m_settingButton;
75 }
76 
78 {
79  m_enabled = !enabled;
81 }
82 
84 {
85  return m_enabled;
86 }
87 
89 {
90  if(!m_enabled)
91  {
92  m_enabled = true;
93  m_openButton->setIcon(QIcon(":/tiny/btn_effect_off"));
95 
97  m_openButton->setToolTip(tr("Off"));
98  }
99  else
100  {
101  m_enabled = false;
102  m_openButton->setIcon(QIcon(":/tiny/btn_effect_on"));
104  m_settingButton->setEnabled(false);
105  m_openButton->setToolTip(tr("On"));
106  }
107 }
108 
110 {
112 }
113 
114 
115 
117  : MusicAbstractMoveDialog(parent),
118  m_ui(new Ui::MusicSoundEffectsWidget)
119 {
120  m_ui->setupUi(this);
121  setFixedSize(size());
122  setBackgroundLabel(m_ui->background);
123 
124  m_ui->topTitleCloseButton->setIcon(QIcon(":/functions/btn_close_hover"));
125  m_ui->topTitleCloseButton->setStyleSheet(TTK::UI::ToolButtonStyle04);
126  m_ui->topTitleCloseButton->setCursor(QCursor(Qt::PointingHandCursor));
127  m_ui->topTitleCloseButton->setToolTip(tr("Close"));
128  connect(m_ui->topTitleCloseButton, SIGNAL(clicked()), SLOT(close()));
129 
131  m_ui->stateComboBox->addItems({tr("OperatorAll"), tr("All Off")});
132  connect(m_ui->stateComboBox, SIGNAL(currentIndexChanged(int)), SLOT(stateComboBoxChanged(int)));
133 
134  m_ui->eqButton->setStyleSheet(TTK::UI::PushButtonStyle04);
135  m_ui->eqButton->setCursor(QCursor(Qt::PointingHandCursor));
136  m_ui->eqEffectButton->setCursor(QCursor(Qt::PointingHandCursor));
137  m_ui->eqEffectButton->setStyleSheet(TTK::UI::PushButtonStyle04);
138 #ifdef Q_OS_UNIX
139  m_ui->eqButton->setFocusPolicy(Qt::NoFocus);
140  m_ui->eqEffectButton->setFocusPolicy(Qt::NoFocus);
141 #endif
142 
143  TTK::Widget::generateVScrollAreaFormat(m_ui->scrollArea, m_ui->effectContainer);
144  readSoundEffect();
145 
146  G_CONNECTION_PTR->setValue(className(), this);
147  G_CONNECTION_PTR->connect(className(), MusicPlayer::className());
148 }
149 
151 {
152  G_CONNECTION_PTR->removeValue(this);
154  qDeleteAll(m_items);
155  delete m_ui;
156 }
157 
159 {
161  {
162  m_ui->eqButton->setText(tr("Off"));
163  }
164  else
165  {
166  m_ui->eqButton->setText(tr("On"));
167  }
168 
169  connect(m_ui->eqButton, SIGNAL(clicked()), SLOT(equalizerButtonChanged()));
170  connect(m_ui->eqEffectButton, SIGNAL(clicked()), object, SLOT(showEqualizerWidget()));
171 }
172 
174 {
175  m_ui->eqButton->setText(state ? tr("Off") : tr("On"));
176 }
177 
179 {
180  const int state = !G_SETTING_PTR->value(MusicSettingManager::EqualizerEnable).toInt();
181  equalizerButtonChanged(state);
182 
184  Q_EMIT setEqualizerConfig();
185 }
186 
188 {
189  m_ui->stateComboBox->blockSignals(true);
190  m_ui->stateComboBox->setCurrentIndex(0);
191  m_ui->stateComboBox->blockSignals(false);
192 
193  if(index == 1)
194  {
196  {
197  item->setPluginEnabled(false);
198  }
199  }
200 }
201 
203 {
204  QVBoxLayout *layout = new QVBoxLayout(m_ui->effectContainer);
205  layout->setContentsMargins(0, 0, 0, 0);
206  layout->setSpacing(10);
207  m_ui->effectContainer->setLayout(layout);
208 
209  const QString &value = G_SETTING_PTR->value(MusicSettingManager::EnhancedEffectValue).toString();
210  const QStringList &effects = value.split(";", QtSkipEmptyParts);
211  for(const MusicPluginProperty &property : TTK::TTKQmmp::effectPlugins())
212  {
213  MusicSoundEffectsItemWidget *item = new MusicSoundEffectsItemWidget(property, this);
214  m_items.push_back(item);
215  layout->addWidget(item);
216 
217  if(effects.contains(property.m_type))
218  {
219  item->setPluginEnabled(true);
220  }
221  }
222 }
223 
225 {
226  QString value;
227  for(const MusicSoundEffectsItemWidget *item : qAsConst(m_items))
228  {
229  if(item->pluginEnabled())
230  {
231  value.append(item->type() + ";");
232  }
233  }
235 }
#define QtSkipEmptyParts
String skip empty parts.
Definition: ttkqtcompat.h:129
QList< MusicSoundEffectsItemWidget * > m_items
void setBackgroundLabel(QLabel *label)
void setInputModule(QObject *object)
static const QString BackgroundStyle05
Definition: musicuiobject.h:93
The class of the sound effect item widget.
static const QString CheckBoxStyle01
CheckBox.
static const QString SliderStyle06
static const QString PushButtonStyle01
PushButton.
voidpf void uLong size
Definition: ioapi.h:136
static const QString PushButtonStyle12
#define G_CONNECTION_PTR
static const QString BackgroundStyle04
Definition: musicuiobject.h:90
#define qAsConst
Definition: ttkqtglobal.h:53
TTK_MODULE_EXPORT MusicPluginPropertyList effectPlugins()
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
static const QString PushButtonStyle04
The class of the moving dialog base.
TTK_MODULE_EXPORT void generateComboBoxFormat(QComboBox *widget, const QString &style={})
TTK_MODULE_EXPORT void generateVScrollAreaFormat(QWidget *widget, QWidget *parent, bool background=true)
static const QString ToolButtonStyle04
TTK_MODULE_EXPORT void showEffectSetting(const QString &name, QWidget *parent)
static const QString ComboBoxStyle01
ComboBox.
The class of the sound effect widget.
The class of the plugin property.
TTK_MODULE_EXPORT void enabledEffectPlugin(bool enabled, const QString &name={})
state
Definition: http_parser.c:279
#define G_SETTING_PTR