Add volume slider
Some checks failed
Build eismuliplexer for linux / Build (push) Has been cancelled
Some checks failed
Build eismuliplexer for linux / Build (push) Has been cancelled
This commit is contained in:
parent
7edd7660a6
commit
e4b5f9af5e
5 changed files with 76 additions and 2 deletions
|
|
@ -120,6 +120,19 @@ int AudioPlayer::position() const
|
||||||
return mediaPlayer->position();
|
return mediaPlayer->position();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudioPlayer::setVolume(int volume)
|
||||||
|
{
|
||||||
|
// Convert from 0-100 range to 0.0-1.0 range
|
||||||
|
qreal volumeLevel = static_cast<qreal>(volume) / 100.0;
|
||||||
|
audioOutput->setVolume(volumeLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
int AudioPlayer::getVolume() const
|
||||||
|
{
|
||||||
|
// Convert from 0.0-1.0 range to 0-100 range
|
||||||
|
return static_cast<int>(audioOutput->volume() * 100);
|
||||||
|
}
|
||||||
|
|
||||||
void AudioPlayer::handlePlaybackStateChanged(QMediaPlayer::PlaybackState state)
|
void AudioPlayer::handlePlaybackStateChanged(QMediaPlayer::PlaybackState state)
|
||||||
{
|
{
|
||||||
if (state == QMediaPlayer::PlayingState)
|
if (state == QMediaPlayer::PlayingState)
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,8 @@ public:
|
||||||
bool isPlaying() const;
|
bool isPlaying() const;
|
||||||
int duration() const;
|
int duration() const;
|
||||||
int position() const;
|
int position() const;
|
||||||
|
void setVolume(int volume);
|
||||||
|
int getVolume() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void playbackStarted();
|
void playbackStarted();
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
connect(ui->skipButton, &QPushButton::clicked, this, &MainWindow::onSkipButtonClicked);
|
connect(ui->skipButton, &QPushButton::clicked, this, &MainWindow::onSkipButtonClicked);
|
||||||
connect(ui->stopButton, &QPushButton::clicked, this, &MainWindow::onStopButtonClicked);
|
connect(ui->stopButton, &QPushButton::clicked, this, &MainWindow::onStopButtonClicked);
|
||||||
connect(ui->shuffleButton, &QPushButton::clicked, this, &MainWindow::onShuffleButtonClicked);
|
connect(ui->shuffleButton, &QPushButton::clicked, this, &MainWindow::onShuffleButtonClicked);
|
||||||
|
connect(ui->volumeSlider, &QSlider::valueChanged, this, &MainWindow::onVolumeSliderValueChanged);
|
||||||
connect(ui->addSongButton, &QPushButton::clicked, this, &MainWindow::onAddSongButtonClicked);
|
connect(ui->addSongButton, &QPushButton::clicked, this, &MainWindow::onAddSongButtonClicked);
|
||||||
connect(ui->removeSongButton, &QPushButton::clicked, this, &MainWindow::onRemoveSongButtonClicked);
|
connect(ui->removeSongButton, &QPushButton::clicked, this, &MainWindow::onRemoveSongButtonClicked);
|
||||||
connect(ui->actionAdvancedSettings, &QAction::triggered, this, &MainWindow::onAdvancedSettingsButtonClicked);
|
connect(ui->actionAdvancedSettings, &QAction::triggered, this, &MainWindow::onAdvancedSettingsButtonClicked);
|
||||||
|
|
@ -111,6 +112,9 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
|
|
||||||
currentSong = songModel->getSong(0);
|
currentSong = songModel->getSong(0);
|
||||||
|
|
||||||
|
// Set default volume (50% from UI)
|
||||||
|
audioPlayer->setVolume(ui->volumeSlider->value());
|
||||||
|
|
||||||
// Start the worker thread and enter its event loop
|
// Start the worker thread and enter its event loop
|
||||||
QObject::connect(&aceThread, &QThread::started, [this]() {qDebug() << "Worker thread started";});
|
QObject::connect(&aceThread, &QThread::started, [this]() {qDebug() << "Worker thread started";});
|
||||||
aceThread.start();
|
aceThread.start();
|
||||||
|
|
@ -161,6 +165,10 @@ void MainWindow::loadSettings()
|
||||||
shuffleMode = settings.value("shuffleMode", false).toBool();
|
shuffleMode = settings.value("shuffleMode", false).toBool();
|
||||||
ui->shuffleButton->setChecked(shuffleMode);
|
ui->shuffleButton->setChecked(shuffleMode);
|
||||||
|
|
||||||
|
// Load volume setting
|
||||||
|
int savedVolume = settings.value("volume", 50).toInt();
|
||||||
|
ui->volumeSlider->setValue(savedVolume);
|
||||||
|
|
||||||
// Load path settings with defaults based on application directory
|
// Load path settings with defaults based on application directory
|
||||||
QString appDir = QCoreApplication::applicationDirPath();
|
QString appDir = QCoreApplication::applicationDirPath();
|
||||||
qwen3ModelPath = settings.value("qwen3ModelPath",
|
qwen3ModelPath = settings.value("qwen3ModelPath",
|
||||||
|
|
@ -189,6 +197,9 @@ void MainWindow::saveSettings()
|
||||||
// Save shuffle mode
|
// Save shuffle mode
|
||||||
settings.setValue("shuffleMode", shuffleMode);
|
settings.setValue("shuffleMode", shuffleMode);
|
||||||
|
|
||||||
|
// Save volume setting
|
||||||
|
settings.setValue("volume", ui->volumeSlider->value());
|
||||||
|
|
||||||
// Save path settings
|
// Save path settings
|
||||||
settings.setValue("qwen3ModelPath", qwen3ModelPath);
|
settings.setValue("qwen3ModelPath", qwen3ModelPath);
|
||||||
settings.setValue("textEncoderModelPath", textEncoderModelPath);
|
settings.setValue("textEncoderModelPath", textEncoderModelPath);
|
||||||
|
|
@ -548,6 +559,11 @@ void MainWindow::onPositionSliderSliderMoved(int position)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::onVolumeSliderValueChanged(int value)
|
||||||
|
{
|
||||||
|
audioPlayer->setVolume(value);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::ensureSongsInQueue(bool enqeueCurrent)
|
void MainWindow::ensureSongsInQueue(bool enqeueCurrent)
|
||||||
{
|
{
|
||||||
// Only generate more songs if we're playing and not already at capacity
|
// Only generate more songs if we're playing and not already at capacity
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ private slots:
|
||||||
void onStopButtonClicked();
|
void onStopButtonClicked();
|
||||||
void onShuffleButtonClicked();
|
void onShuffleButtonClicked();
|
||||||
void onPositionSliderSliderMoved(int position);
|
void onPositionSliderSliderMoved(int position);
|
||||||
|
void onVolumeSliderValueChanged(int value);
|
||||||
void updatePosition(int position);
|
void updatePosition(int position);
|
||||||
void updateDuration(int duration);
|
void updateDuration(int duration);
|
||||||
void onAddSongButtonClicked();
|
void onAddSongButtonClicked();
|
||||||
|
|
|
||||||
|
|
@ -223,13 +223,55 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer_2">
|
<spacer name="horizontalSpacer_3">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Orientation::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>40</width>
|
<width>15</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="volumeLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Volume:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSlider" name="volumeSlider">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>100</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>100</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>50</number>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Policy::Fixed</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>35</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue