Fix narrowing conversions in connects
This commit is contained in:
parent
78d6fd634b
commit
93f12baf51
@ -399,8 +399,8 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
app_->player()->SetEqualizer(equalizer_.get());
|
||||
app_->player()->Init();
|
||||
EngineChanged(app_->player()->engine()->type());
|
||||
int volume = static_cast<int>(app_->player()->GetVolume());
|
||||
ui_->volume->setValue(volume);
|
||||
const uint volume = app_->player()->GetVolume();
|
||||
ui_->volume->SetValueFromVolume(volume);
|
||||
VolumeChanged(volume);
|
||||
|
||||
// Models
|
||||
@ -583,7 +583,7 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
ui_->stop_button->setMenu(stop_menu);
|
||||
|
||||
// Player connections
|
||||
QObject::connect(ui_->volume, &VolumeSlider::valueChanged, app_->player(), &Player::SetVolume);
|
||||
QObject::connect(ui_->volume, &VolumeSlider::valueChanged, app_->player(), &Player::SetVolumeFromValue);
|
||||
|
||||
QObject::connect(app_->player(), &Player::EngineChanged, this, &MainWindow::EngineChanged);
|
||||
QObject::connect(app_->player(), &Player::Error, this, &MainWindow::ShowErrorDialog);
|
||||
@ -606,7 +606,7 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
QObject::connect(app_->player(), &Player::Stopped, osd_, &OSDBase::Stopped);
|
||||
QObject::connect(app_->player(), &Player::PlaylistFinished, osd_, &OSDBase::PlaylistFinished);
|
||||
QObject::connect(app_->player(), &Player::VolumeChanged, osd_, &OSDBase::VolumeChanged);
|
||||
QObject::connect(app_->player(), &Player::VolumeChanged, ui_->volume, &VolumeSlider::setValue);
|
||||
QObject::connect(app_->player(), &Player::VolumeChanged, ui_->volume, &VolumeSlider::SetValueFromVolume);
|
||||
QObject::connect(app_->player(), &Player::ForceShowOSD, this, &MainWindow::ForceShowOSD);
|
||||
|
||||
QObject::connect(app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, this, &MainWindow::SongChanged);
|
||||
@ -1351,7 +1351,7 @@ void MainWindow::SendNowPlaying() {
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::VolumeChanged(const int volume) {
|
||||
void MainWindow::VolumeChanged(const uint volume) {
|
||||
ui_->action_mute->setChecked(volume == 0);
|
||||
tray_icon_->MuteButtonStateChanged(volume == 0);
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
void StopAfterCurrent();
|
||||
|
||||
void SongChanged(const Song &song);
|
||||
void VolumeChanged(const int volume);
|
||||
void VolumeChanged(const uint volume);
|
||||
|
||||
void CopyFilesToCollection(const QList<QUrl> &urls);
|
||||
void MoveFilesToCollection(const QList<QUrl> &urls);
|
||||
|
@ -641,16 +641,21 @@ uint Player::GetVolume() const {
|
||||
|
||||
}
|
||||
|
||||
void Player::SetVolume(const uint value) {
|
||||
void Player::SetVolumeFromValue(const int value) {
|
||||
|
||||
SetVolume(static_cast<uint>(std::max(0, value)));
|
||||
|
||||
}
|
||||
|
||||
void Player::SetVolume(const uint volume) {
|
||||
|
||||
uint old_volume = engine_->volume();
|
||||
uint new_volume = qBound(0U, volume, 100U);
|
||||
settings_.setValue("volume", new_volume);
|
||||
engine_->SetVolume(new_volume);
|
||||
|
||||
uint volume = qBound(0U, value, 100U);
|
||||
settings_.setValue("volume", volume);
|
||||
engine_->SetVolume(volume);
|
||||
|
||||
if (volume != old_volume) {
|
||||
emit VolumeChanged(volume);
|
||||
if (new_volume != old_volume) {
|
||||
emit VolumeChanged(new_volume);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -84,7 +84,8 @@ class PlayerInterface : public QObject {
|
||||
virtual void Next() = 0;
|
||||
virtual void Previous() = 0;
|
||||
virtual void PlayPlaylist(const QString &playlist_name) = 0;
|
||||
virtual void SetVolume(const uint value) = 0;
|
||||
virtual void SetVolumeFromValue(const int value) = 0;
|
||||
virtual void SetVolume(const uint volume) = 0;
|
||||
virtual void VolumeUp() = 0;
|
||||
virtual void VolumeDown() = 0;
|
||||
virtual void SeekTo(const quint64 seconds) = 0;
|
||||
@ -166,6 +167,7 @@ class Player : public PlayerInterface {
|
||||
void Next() override;
|
||||
void Previous() override;
|
||||
void PlayPlaylist(const QString &playlist_name) override;
|
||||
void SetVolumeFromValue(const int value) override;
|
||||
void SetVolume(const uint value) override;
|
||||
void VolumeUp() override;
|
||||
void VolumeDown() override;
|
||||
|
@ -62,7 +62,7 @@ class LyricsProvider : public QObject {
|
||||
void AuthenticationComplete(bool, QStringList = QStringList());
|
||||
void AuthenticationSuccess();
|
||||
void AuthenticationFailure(QStringList);
|
||||
void SearchFinished(quint64 id, LyricsSearchResults results);
|
||||
void SearchFinished(int id, LyricsSearchResults results);
|
||||
|
||||
protected:
|
||||
NetworkAccessManager *network_;
|
||||
|
@ -265,7 +265,7 @@ void OSDBase::Stopped() {
|
||||
|
||||
}
|
||||
|
||||
void OSDBase::StopAfterToggle(bool stop) {
|
||||
void OSDBase::StopAfterToggle(const bool stop) {
|
||||
ShowMessage(app_name_, tr("Stop playing after track: %1").arg(stop ? tr("On") : tr("Off")));
|
||||
}
|
||||
|
||||
@ -278,7 +278,7 @@ void OSDBase::PlaylistFinished() {
|
||||
|
||||
}
|
||||
|
||||
void OSDBase::VolumeChanged(int value) {
|
||||
void OSDBase::VolumeChanged(const uint value) {
|
||||
|
||||
if (!show_on_volume_change_) return;
|
||||
|
||||
@ -338,7 +338,7 @@ void OSDBase::ShowMessage(const QString &summary, const QString &message, const
|
||||
|
||||
}
|
||||
|
||||
void OSDBase::ShuffleModeChanged(PlaylistSequence::ShuffleMode mode) {
|
||||
void OSDBase::ShuffleModeChanged(const PlaylistSequence::ShuffleMode mode) {
|
||||
|
||||
if (show_on_play_mode_change_) {
|
||||
QString current_mode = QString();
|
||||
@ -353,7 +353,7 @@ void OSDBase::ShuffleModeChanged(PlaylistSequence::ShuffleMode mode) {
|
||||
|
||||
}
|
||||
|
||||
void OSDBase::RepeatModeChanged(PlaylistSequence::RepeatMode mode) {
|
||||
void OSDBase::RepeatModeChanged(const PlaylistSequence::RepeatMode mode) {
|
||||
|
||||
if (show_on_play_mode_change_) {
|
||||
QString current_mode = QString();
|
||||
@ -435,7 +435,7 @@ void OSDBase::ShowPreview(const Behaviour type, const QString &line1, const QStr
|
||||
|
||||
}
|
||||
|
||||
void OSDBase::SetPrettyOSDToggleMode(bool toggle) {
|
||||
void OSDBase::SetPrettyOSDToggleMode(const bool toggle) {
|
||||
pretty_popup_->set_toggle_mode(toggle);
|
||||
}
|
||||
|
||||
|
@ -72,11 +72,11 @@ class OSDBase : public QObject {
|
||||
void Paused();
|
||||
void Resumed();
|
||||
void Stopped();
|
||||
void StopAfterToggle(bool stop);
|
||||
void StopAfterToggle(const bool stop);
|
||||
void PlaylistFinished();
|
||||
void VolumeChanged(int value);
|
||||
void RepeatModeChanged(PlaylistSequence::RepeatMode mode);
|
||||
void ShuffleModeChanged(PlaylistSequence::ShuffleMode mode);
|
||||
void VolumeChanged(const uint value);
|
||||
void RepeatModeChanged(const PlaylistSequence::RepeatMode mode);
|
||||
void ShuffleModeChanged(const PlaylistSequence::ShuffleMode mode);
|
||||
|
||||
void ReshowCurrentSong();
|
||||
|
||||
|
@ -185,7 +185,7 @@ void TrackSlider::ValueMaybeChanged(const int value) {
|
||||
if (setting_value_) return;
|
||||
|
||||
UpdateTimes(static_cast<int>(value / kMsecPerSec));
|
||||
emit ValueChangedSeconds(static_cast<int>(value / kMsecPerSec));
|
||||
emit ValueChangedSeconds(static_cast<quint64>(value / kMsecPerSec));
|
||||
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ class TrackSlider : public QWidget {
|
||||
|
||||
signals:
|
||||
void ValueChanged(int value);
|
||||
void ValueChangedSeconds(int value);
|
||||
void ValueChangedSeconds(quint64 value);
|
||||
|
||||
void SeekForward();
|
||||
void SeekBackward();
|
||||
|
@ -141,14 +141,21 @@ void SliderSlider::mouseReleaseEvent(QMouseEvent*) {
|
||||
|
||||
}
|
||||
|
||||
void SliderSlider::setValue(int newValue) {
|
||||
// don't adjust the slider while the user is dragging it!
|
||||
void SliderSlider::SetValueFromVolume(const uint value) {
|
||||
|
||||
setValue(static_cast<int>(value));
|
||||
|
||||
}
|
||||
|
||||
void SliderSlider::setValue(int value) {
|
||||
|
||||
// Don't adjust the slider while the user is dragging it!
|
||||
|
||||
if (!sliding_ || outside_) {
|
||||
QSlider::setValue(adjustValue(newValue));
|
||||
QSlider::setValue(adjustValue(value));
|
||||
}
|
||||
else {
|
||||
prev_value_ = newValue;
|
||||
prev_value_ = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -44,7 +44,8 @@ class SliderSlider : public QSlider {
|
||||
public:
|
||||
explicit SliderSlider(const Qt::Orientation, QWidget*, const int max = 0);
|
||||
|
||||
virtual void setValue(int);
|
||||
virtual void SetValueFromVolume(const uint value);
|
||||
virtual void setValue(int value);
|
||||
|
||||
// WARNING non-virtual - and thus only really intended for internal use this is a major flaw in the class presently, however it suits our current needs fine
|
||||
int value() const { return adjustValue(QSlider::value()); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user