音量控制滑块优化,音量控制区显示优化
This commit is contained in:
parent
95719184ec
commit
85aa2f9bc3
|
@ -338,6 +338,7 @@ void MainWindow::volume_control(int value, int abs)
|
|||
// 音量调整到 value 大小(-数减+数加), abs 为 0 时在当前音量上加减一个值,abs 不为 0 时将当前音量设置为 value 大小
|
||||
int len = sprintf(changeSongBuf, "volume %d %d\n", value, abs);
|
||||
write(this->fifo_fd, changeSongBuf, len); // 将音量控制指令写入到有名管道中
|
||||
ui->volume_label->setText(QString::number(currentVolume) + " %");
|
||||
}
|
||||
|
||||
void MainWindow::volume_mute_switch(int mute_arg)
|
||||
|
@ -365,11 +366,24 @@ void MainWindow::on_mute_btn_clicked()
|
|||
// volume_mute_switch(1);
|
||||
// mute_flag = 1;
|
||||
volume_mute_switch(++mute_flag);
|
||||
ui->volume_down_btn->setDisabled(true);
|
||||
ui->volume_up_btn->setDisabled(true);
|
||||
ui->volume_slider->setDisabled(true);
|
||||
ui->volume_slider->setStyleSheet("QSlider::groove:horizontal { background-color: white; }"
|
||||
"QSlider::handle:horizontal { background-color: gray; width: 20px;}");
|
||||
ui->volume_label->setText("Muted");
|
||||
}
|
||||
else if (mute_flag == 1) // 已静音则按下后取消静音
|
||||
{
|
||||
ui->mute_btn->setIcon(QIcon(":/icon2/sound-off"));
|
||||
volume_mute_switch(--mute_flag);
|
||||
ui->volume_down_btn->setDisabled(false);
|
||||
ui->volume_up_btn->setDisabled(false);
|
||||
ui->volume_slider->setDisabled(false);
|
||||
ui->volume_slider->setStyleSheet("QSlider::groove:horizontal { background-color: gray; }"
|
||||
"QSlider::handle:horizontal { background-color: yellow; width: 20px;}");
|
||||
ui->volume_label->setText(QString::number(currentVolume) + " %");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -393,3 +407,9 @@ void MainWindow::on_volume_up_btn_clicked()
|
|||
setVolumeSlider(currentVolume); // 设置音量滑块位置
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_volume_slider_sliderMoved(int position)
|
||||
{
|
||||
currentVolume = position;
|
||||
volume_control(position, 1);
|
||||
}
|
||||
|
|
|
@ -77,6 +77,8 @@ private slots:
|
|||
|
||||
void on_volume_up_btn_clicked();
|
||||
|
||||
void on_volume_slider_sliderMoved(int position);
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
};
|
||||
|
|
|
@ -244,10 +244,26 @@ color: rgb(255, 255, 0);</string>
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QSlider" name="volume_slider">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QSlider" name="volume_slider">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="volume_label">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(255, 255, 0);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>------</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
|
Loading…
Reference in New Issue