parent
75394d0e8a
commit
f40b8ab892
@ -51,10 +51,6 @@ const int PlaylistView::kGlowIntensitySteps = 24;
|
||||
const int PlaylistView::kAutoscrollGraceTimeout = 60; // seconds
|
||||
const int PlaylistView::kDropIndicatorWidth = 2;
|
||||
const int PlaylistView::kDropIndicatorGradientWidth = 5;
|
||||
// Opacity value used by all background images but the default clementine one
|
||||
// (because it is already opaque and load through the mainwindow.css file)
|
||||
const qreal PlaylistView::kBackgroundOpacity = 0.4;
|
||||
|
||||
const char* PlaylistView::kSettingBackgroundImageType = "playlistview_background_type";
|
||||
const char* PlaylistView::kSettingBackgroundImageFilename = "playlistview_background_image_file";
|
||||
|
||||
@ -208,7 +204,7 @@ void PlaylistView::SetItemDelegates(LibraryBackend* backend) {
|
||||
#ifdef HAVE_MOODBAR
|
||||
setItemDelegateForColumn(Playlist::Column_Mood, new MoodbarItemDelegate(app_, this, this));
|
||||
#endif
|
||||
|
||||
|
||||
if (app_ && app_->player()) {
|
||||
setItemDelegateForColumn(Playlist::Column_Source, new SongSourceDelegate(this, app_->player()));
|
||||
} else {
|
||||
@ -303,7 +299,7 @@ void PlaylistView::LoadGeometry() {
|
||||
// Clementine. Hide them again here
|
||||
const int state_version = settings.value("state_version", 0).toInt();
|
||||
upgrading_from_version_ = state_version;
|
||||
|
||||
|
||||
if (state_version < 1) {
|
||||
header_->HideSection(Playlist::Column_Rating);
|
||||
header_->HideSection(Playlist::Column_PlayCount);
|
||||
@ -885,7 +881,7 @@ void PlaylistView::paintEvent(QPaintEvent* event) {
|
||||
drawTree(&p, event->region());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const int first_column = header_->logicalIndex(0);
|
||||
|
||||
// Find the y position of the drop indicator
|
||||
@ -1020,18 +1016,21 @@ void PlaylistView::ReloadSettings() {
|
||||
}
|
||||
QString background_image_filename = s.value(kSettingBackgroundImageFilename).toString();
|
||||
int blur_radius = s.value("blur_radius").toInt();
|
||||
int opacity_level = s.value("opacity_level").toInt();
|
||||
// Check if background properties have changed.
|
||||
// We change properties only if they have actually changed, to avoid to call
|
||||
// set_background_image when it is not needed, as this will cause the fading
|
||||
// animation to start again. This also avoid to do useless
|
||||
// "force_background_redraw".
|
||||
if (background_image_filename != background_image_filename_ ||
|
||||
background_type != background_image_type_ ||
|
||||
blur_radius_ != blur_radius) {
|
||||
background_type != background_image_type_ ||
|
||||
blur_radius_ != blur_radius ||
|
||||
opacity_level_ != opacity_level) {
|
||||
// Store background properties
|
||||
background_image_type_ = background_type;
|
||||
background_image_filename_ = background_image_filename;
|
||||
blur_radius_ = blur_radius;
|
||||
opacity_level_ = opacity_level;
|
||||
if (background_image_type_ == Custom) {
|
||||
set_background_image(QImage(background_image_filename));
|
||||
} else if (background_image_type_ == AlbumCover) {
|
||||
@ -1198,7 +1197,7 @@ void PlaylistView::set_background_image(const QImage& image) {
|
||||
// Apply opacity filter
|
||||
uchar* bits = background_image_.bits();
|
||||
for (int i = 0; i < background_image_.height() * background_image_.bytesPerLine(); i+=4) {
|
||||
bits[i+3] = kBackgroundOpacity * 255;
|
||||
bits[i+3] = (opacity_level_ / 100.0) * 255;
|
||||
}
|
||||
|
||||
if (blur_radius_ != 0) {
|
||||
|
@ -173,8 +173,7 @@ class PlaylistView : public QTreeView {
|
||||
static const int kAutoscrollGraceTimeout;
|
||||
static const int kDropIndicatorWidth;
|
||||
static const int kDropIndicatorGradientWidth;
|
||||
static const qreal kBackgroundOpacity;
|
||||
|
||||
|
||||
QList<int> GetEditableColumns();
|
||||
QModelIndex NextEditableIndex(const QModelIndex& current);
|
||||
QModelIndex PrevEditableIndex(const QModelIndex& current);
|
||||
@ -196,16 +195,17 @@ class PlaylistView : public QTreeView {
|
||||
// set_background_image_type instead of modifying background_image_ directly
|
||||
QImage background_image_;
|
||||
int blur_radius_;
|
||||
int opacity_level_;
|
||||
// Used if background image is a filemane
|
||||
QString background_image_filename_;
|
||||
QImage current_song_cover_art_;
|
||||
QPixmap cached_scaled_background_image_;
|
||||
|
||||
|
||||
// For fading when image change
|
||||
QPixmap previous_background_image_;
|
||||
qreal previous_background_image_opacity_;
|
||||
QTimeLine* fade_animation_;
|
||||
|
||||
|
||||
// To know if we should redraw the background or not
|
||||
int last_height_;
|
||||
int last_width_;
|
||||
|
@ -57,6 +57,7 @@ AppearanceSettingsPage::AppearanceSettingsPage(SettingsDialog* dialog)
|
||||
connect(ui_->select_background_color, SIGNAL(pressed()), SLOT(SelectBackgroundColor()));
|
||||
connect(ui_->use_a_custom_color_set, SIGNAL(toggled(bool)), SLOT(UseCustomColorSetOptionChanged(bool)));
|
||||
connect(ui_->blur_slider, SIGNAL(valueChanged(int)), SLOT(BlurLevelChanged(int)));
|
||||
connect(ui_->opacity_slider, SIGNAL(valueChanged(int)), SLOT(OpacityLevelChanged(int)));
|
||||
|
||||
connect(ui_->select_background_image_filename_button, SIGNAL(pressed()), SLOT(SelectBackgroundImage()));
|
||||
connect(ui_->use_custom_background_image, SIGNAL(toggled(bool)),
|
||||
@ -127,6 +128,10 @@ void AppearanceSettingsPage::Load() {
|
||||
DisableBlurSlider(true);
|
||||
}
|
||||
ui_->background_image_filename->setText(playlist_view_background_image_filename_);
|
||||
/* There has to be a way to just simulate the change... */
|
||||
ui_->opacity_slider->setValue(s.value("opacity_level").toInt());
|
||||
OpacityLevelChanged(s.value("opacity_level").toInt());
|
||||
|
||||
|
||||
s.endGroup();
|
||||
|
||||
@ -171,6 +176,7 @@ void AppearanceSettingsPage::Save() {
|
||||
s.setValue(PlaylistView::kSettingBackgroundImageType,
|
||||
playlist_view_background_image_type_);
|
||||
s.setValue("blur_radius", ui_->blur_slider->value());
|
||||
s.setValue("opacity_level", ui_->opacity_slider->value());
|
||||
s.endGroup();
|
||||
|
||||
// Moodbar settings
|
||||
@ -252,6 +258,11 @@ void AppearanceSettingsPage::BlurLevelChanged(int value) {
|
||||
ui_->background_blur_radius_label->setText(QString("%1px").arg(value));
|
||||
}
|
||||
|
||||
void AppearanceSettingsPage::OpacityLevelChanged(int percent) {
|
||||
background_opacity_level_ = percent;
|
||||
ui_->background_opacity_label->setText(QString("%1\%").arg(percent));
|
||||
}
|
||||
|
||||
void AppearanceSettingsPage::InitMoodbarPreviews() {
|
||||
#ifdef HAVE_MOODBAR
|
||||
if (initialised_moodbar_previews_)
|
||||
|
@ -43,6 +43,7 @@ private slots:
|
||||
void UseCustomColorSetOptionChanged(bool);
|
||||
void SelectBackgroundImage();
|
||||
void BlurLevelChanged(int);
|
||||
void OpacityLevelChanged(int);
|
||||
void DisableBlurSlider(bool);
|
||||
|
||||
private:
|
||||
@ -65,6 +66,7 @@ private:
|
||||
PlaylistView::BackgroundImageType playlist_view_background_image_type_;
|
||||
QString playlist_view_background_image_filename_;
|
||||
int background_blur_radius_;
|
||||
int background_opacity_level_;
|
||||
|
||||
bool initialised_moodbar_previews_;
|
||||
};
|
||||
|
@ -201,6 +201,37 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||
<item>
|
||||
<widget class="QLabel" name="select_opacity_level_label">
|
||||
<property name="text">
|
||||
<string>Opacity level:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="background_opacity_label">
|
||||
<property name="text">
|
||||
<string>40%</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="opacity_slider">
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>40</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user