Make the playback settings work properly
This commit is contained in:
parent
eb6a836b53
commit
b0cad6cee9
|
@ -150,7 +150,7 @@ int Analyzer::Base::resizeForBands( int bands )
|
|||
return m_fht->size() / 2;
|
||||
}
|
||||
|
||||
void Analyzer::Base::paused(QPainter& p) //virtual
|
||||
void Analyzer::Base::paused(QPainter&) //virtual
|
||||
{}
|
||||
|
||||
void Analyzer::Base::demo(QPainter& p) //virtual
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
|
||||
#ifndef ENGINE_FWD_H
|
||||
#define ENGINE_FWD_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
/// Used by eg engineobserver.h, and thus we reduce header dependencies on enginebase.h
|
||||
|
||||
namespace Engine
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <cmath>
|
||||
|
||||
const char* Engine::Base::kSettingsGroup = "Player";
|
||||
|
||||
Engine::Base::Base()
|
||||
: m_xfadeLength( 0 )
|
||||
|
|
|
@ -237,6 +237,8 @@ namespace Engine
|
|||
|
||||
virtual void reloadSettings() {};
|
||||
|
||||
static const char* kSettingsGroup;
|
||||
|
||||
protected:
|
||||
Base();
|
||||
|
||||
|
|
|
@ -226,6 +226,9 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
connect(next, SIGNAL(activated()), ui_.action_next_track, SLOT(trigger()));
|
||||
connect(prev, SIGNAL(activated()), ui_.action_previous_track, SLOT(trigger()));
|
||||
|
||||
// Settings
|
||||
connect(settings_dialog_, SIGNAL(accepted()), player_, SLOT(ReloadSettings()));
|
||||
|
||||
// Analyzer
|
||||
ui_.analyzer->set_engine(player_->GetEngine());
|
||||
|
||||
|
|
|
@ -23,6 +23,10 @@ Player::Player(Playlist* playlist, LastFMService* lastfm, QObject* parent)
|
|||
connect(engine_, SIGNAL(trackEnded()), SLOT(TrackEnded()));
|
||||
}
|
||||
|
||||
void Player::ReloadSettings() {
|
||||
engine_->reloadSettings();
|
||||
}
|
||||
|
||||
void Player::Next() {
|
||||
if (playlist_->current_item_options() & PlaylistItem::ContainsMultipleTracks) {
|
||||
playlist_->current_item()->LoadNext();
|
||||
|
|
|
@ -26,6 +26,8 @@ class Player : public QObject {
|
|||
Song GetCurrentItem() const { return current_item_; }
|
||||
|
||||
public slots:
|
||||
void ReloadSettings();
|
||||
|
||||
void PlayAt(int index);
|
||||
void PlayPause();
|
||||
void Next();
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "settingsdialog.h"
|
||||
#include "ui_settingsdialog.h"
|
||||
#include "enginebase.h"
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
SettingsDialog::SettingsDialog(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
|
@ -7,7 +9,6 @@ SettingsDialog::SettingsDialog(QWidget* parent)
|
|||
ui_.setupUi(this);
|
||||
|
||||
connect(ui_.list, SIGNAL(currentTextChanged(QString)), SLOT(CurrentTextChanged(QString)));
|
||||
|
||||
ui_.list->setCurrentRow(0);
|
||||
}
|
||||
|
||||
|
@ -18,3 +19,28 @@ void SettingsDialog::CurrentTextChanged(const QString &text) {
|
|||
void SettingsDialog::SetLibraryDirectoryModel(LibraryDirectoryModel* model) {
|
||||
ui_.library_config->SetModel(model);
|
||||
}
|
||||
|
||||
void SettingsDialog::accept() {
|
||||
QSettings s;
|
||||
|
||||
// Playback
|
||||
s.beginGroup(Engine::Base::kSettingsGroup);
|
||||
s.setValue("FadeoutEnabled", ui_.fadeout->isChecked());
|
||||
s.setValue("FadeoutDuration", ui_.fadeout_duration->value());
|
||||
s.endGroup();
|
||||
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void SettingsDialog::showEvent(QShowEvent*) {
|
||||
QSettings s;
|
||||
|
||||
// Playback
|
||||
s.beginGroup(Engine::Base::kSettingsGroup);
|
||||
if (s.value("FadeoutEnabled", true).toBool())
|
||||
ui_.fadeout->setChecked(true);
|
||||
else
|
||||
ui_.no_fadeout->setChecked(true);
|
||||
ui_.fadeout_duration->setValue(s.value("FadeoutDuration", 2000).toInt());
|
||||
s.endGroup();
|
||||
}
|
||||
|
|
|
@ -15,6 +15,12 @@ class SettingsDialog : public QDialog {
|
|||
|
||||
void SetLibraryDirectoryModel(LibraryDirectoryModel* model);
|
||||
|
||||
// QDialog
|
||||
void accept();
|
||||
|
||||
// QWidget
|
||||
void showEvent(QShowEvent* e);
|
||||
|
||||
private slots:
|
||||
void CurrentTextChanged(const QString& text);
|
||||
|
||||
|
|
|
@ -104,14 +104,14 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton">
|
||||
<widget class="QRadioButton" name="no_fadeout">
|
||||
<property name="text">
|
||||
<string>No fadeout</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_2">
|
||||
<widget class="QRadioButton" name="fadeout">
|
||||
<property name="text">
|
||||
<string>Fadeout</string>
|
||||
</property>
|
||||
|
@ -121,6 +121,9 @@
|
|||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Fadeout duration</string>
|
||||
</property>
|
||||
|
@ -130,13 +133,19 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox">
|
||||
<widget class="QSpinBox" name="fadeout_duration">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string>ms</string>
|
||||
<string> ms</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>2000</number>
|
||||
</property>
|
||||
|
@ -218,9 +227,9 @@
|
|||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>list</tabstop>
|
||||
<tabstop>radioButton</tabstop>
|
||||
<tabstop>radioButton_2</tabstop>
|
||||
<tabstop>spinBox</tabstop>
|
||||
<tabstop>no_fadeout</tabstop>
|
||||
<tabstop>fadeout</tabstop>
|
||||
<tabstop>fadeout_duration</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
|
@ -244,9 +253,9 @@
|
|||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>radioButton_2</sender>
|
||||
<sender>fadeout</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>spinBox</receiver>
|
||||
<receiver>fadeout_duration</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
|
@ -260,7 +269,7 @@
|
|||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>radioButton_2</sender>
|
||||
<sender>fadeout</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>label</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
|
|
|
@ -67,7 +67,7 @@ XineEngine::XineEngine()
|
|||
, m_fadeOutRunning ( false )
|
||||
, m_equalizerEnabled( false )
|
||||
{
|
||||
m_settings.beginGroup("Player");
|
||||
m_settings.beginGroup(kSettingsGroup);
|
||||
reloadSettings();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue