parent
9b743e55d1
commit
25e48d6cae
@ -162,6 +162,7 @@ PlaylistView::PlaylistView(QWidget *parent)
|
||||
current_background_image_y_(0),
|
||||
previous_background_image_x_(0),
|
||||
previous_background_image_y_(0),
|
||||
bars_enabled_(true),
|
||||
glow_enabled_(true),
|
||||
select_track_(false),
|
||||
auto_sort_(false),
|
||||
@ -486,6 +487,15 @@ QList<QPixmap> PlaylistView::LoadBarPixmap(const QString &filename) {
|
||||
|
||||
}
|
||||
|
||||
void PlaylistView::LoadTinyPlayPausePixmaps(const int desired_size) {
|
||||
|
||||
QImage image_play = QImage(":/pictures/tiny-play.png").scaled(desired_size, desired_size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
QImage image_pause = QImage(":/pictures/tiny-pause.png").scaled(desired_size, desired_size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
pixmap_tinyplay_ = QPixmap::fromImage(image_play);
|
||||
pixmap_tinypause_ = QPixmap::fromImage(image_pause);
|
||||
|
||||
}
|
||||
|
||||
void PlaylistView::drawTree(QPainter *painter, const QRegion ®ion) const {
|
||||
|
||||
const_cast<PlaylistView*>(this)->current_paint_region_ = region;
|
||||
@ -502,66 +512,93 @@ void PlaylistView::drawRow(QPainter *painter, const QStyleOptionViewItem &option
|
||||
bool is_paused = idx.data(Playlist::Role_IsPaused).toBool();
|
||||
|
||||
if (is_current) {
|
||||
const_cast<PlaylistView*>(this)->last_current_item_ = idx;
|
||||
const_cast<PlaylistView*>(this)->last_glow_rect_ = opt.rect;
|
||||
|
||||
int step = glow_intensity_step_;
|
||||
if (step >= kGlowIntensitySteps) {
|
||||
step = 2 * (kGlowIntensitySteps - 1) - step + 1;
|
||||
}
|
||||
if (bars_enabled_) {
|
||||
|
||||
int row_height = opt.rect.height();
|
||||
if (row_height != row_height_) {
|
||||
// Recreate the pixmaps if the height changed since last time
|
||||
const_cast<PlaylistView*>(this)->row_height_ = row_height;
|
||||
const_cast<PlaylistView*>(this)->ReloadBarPixmaps();
|
||||
}
|
||||
const_cast<PlaylistView*>(this)->last_current_item_ = idx;
|
||||
const_cast<PlaylistView*>(this)->last_glow_rect_ = opt.rect;
|
||||
|
||||
QRect middle(opt.rect);
|
||||
middle.setLeft(middle.left() + currenttrack_bar_left_[0].width());
|
||||
middle.setRight(middle.right() - currenttrack_bar_right_[0].width());
|
||||
int step = glow_intensity_step_;
|
||||
if (step >= kGlowIntensitySteps) {
|
||||
step = 2 * (kGlowIntensitySteps - 1) - step + 1;
|
||||
}
|
||||
|
||||
// Selection
|
||||
if (selectionModel()->isSelected(idx)) {
|
||||
painter->fillRect(opt.rect, opt.palette.color(QPalette::Highlight));
|
||||
}
|
||||
if (currenttrack_bar_left_.count() < kGlowIntensitySteps ||
|
||||
currenttrack_bar_mid_.count() < kGlowIntensitySteps ||
|
||||
currenttrack_bar_right_.count() < kGlowIntensitySteps ||
|
||||
opt.rect.height() != row_height_) {
|
||||
// Recreate the pixmaps if the height changed since last time
|
||||
const_cast<PlaylistView*>(this)->row_height_ = opt.rect.height();
|
||||
const_cast<PlaylistView*>(this)->ReloadBarPixmaps();
|
||||
}
|
||||
|
||||
// Draw the bar
|
||||
painter->setRenderHint(QPainter::SmoothPixmapTransform);
|
||||
painter->drawPixmap(opt.rect.topLeft(), currenttrack_bar_left_[step]);
|
||||
painter->drawPixmap(opt.rect.topRight() - currenttrack_bar_right_[0].rect().topRight(), currenttrack_bar_right_[step]);
|
||||
painter->drawPixmap(middle, currenttrack_bar_mid_[step]);
|
||||
QRect middle(opt.rect);
|
||||
middle.setLeft(middle.left() + currenttrack_bar_left_[0].width());
|
||||
middle.setRight(middle.right() - currenttrack_bar_right_[0].width());
|
||||
|
||||
// Draw the play icon
|
||||
QPoint play_pos(currenttrack_bar_left_[0].width() / 3 * 2, (row_height - currenttrack_play_.height()) / 2);
|
||||
painter->drawPixmap(opt.rect.topLeft() + play_pos, is_paused ? currenttrack_pause_ : currenttrack_play_);
|
||||
// Selection
|
||||
if (selectionModel()->isSelected(idx)) {
|
||||
painter->fillRect(opt.rect, opt.palette.color(QPalette::Highlight));
|
||||
}
|
||||
|
||||
// Set the font
|
||||
opt.palette.setColor(QPalette::Inactive, QPalette::HighlightedText, QApplication::palette().color(QPalette::Active, QPalette::HighlightedText));
|
||||
opt.palette.setColor(QPalette::Text, QApplication::palette().color(QPalette::HighlightedText));
|
||||
opt.palette.setColor(QPalette::Highlight, Qt::transparent);
|
||||
opt.palette.setColor(QPalette::AlternateBase, Qt::transparent);
|
||||
opt.decorationSize = QSize(20, 20);
|
||||
// Draw the bar
|
||||
painter->setRenderHint(QPainter::SmoothPixmapTransform);
|
||||
painter->drawPixmap(opt.rect.topLeft(), currenttrack_bar_left_[step]);
|
||||
painter->drawPixmap(opt.rect.topRight() - currenttrack_bar_right_[0].rect().topRight(), currenttrack_bar_right_[step]);
|
||||
painter->drawPixmap(middle, currenttrack_bar_mid_[step]);
|
||||
|
||||
// Draw the actual row data on top. We cache this, because it's fairly expensive (1-2ms), and we do it many times per second.
|
||||
const bool cache_dirty = cached_current_row_rect_ != opt.rect || cached_current_row_row_ != idx.row() || cached_current_row_.isNull();
|
||||
// Draw the play icon
|
||||
QPoint play_pos(currenttrack_bar_left_[0].width() / 3 * 2, (opt.rect.height() - currenttrack_play_.height()) / 2);
|
||||
painter->drawPixmap(opt.rect.topLeft() + play_pos, is_paused ? currenttrack_pause_ : currenttrack_play_);
|
||||
|
||||
// We can't update the cache if we're not drawing the entire region,
|
||||
// QTreeView clips its drawing to only the columns in the region, so it wouldn't update the whole pixmap properly.
|
||||
const bool whole_region = current_paint_region_.boundingRect().width() == viewport()->width();
|
||||
// Set the font
|
||||
opt.palette.setColor(QPalette::Inactive, QPalette::HighlightedText, QApplication::palette().color(QPalette::Active, QPalette::HighlightedText));
|
||||
opt.palette.setColor(QPalette::Text, QApplication::palette().color(QPalette::HighlightedText));
|
||||
opt.palette.setColor(QPalette::Highlight, Qt::transparent);
|
||||
opt.palette.setColor(QPalette::AlternateBase, Qt::transparent);
|
||||
opt.decorationSize = QSize(20, 20);
|
||||
|
||||
if (!cache_dirty) {
|
||||
painter->drawPixmap(opt.rect, cached_current_row_);
|
||||
}
|
||||
else {
|
||||
if (whole_region) {
|
||||
const_cast<PlaylistView*>(this)->UpdateCachedCurrentRowPixmap(opt, idx);
|
||||
painter->drawPixmap(opt.rect, cached_current_row_);
|
||||
// Draw the actual row data on top. We cache this, because it's fairly expensive (1-2ms), and we do it many times per second.
|
||||
if (cached_current_row_rect_ != opt.rect || cached_current_row_row_ != idx.row() || cached_current_row_.isNull()) {
|
||||
// We can't update the cache if we're not drawing the entire region,
|
||||
// QTreeView clips its drawing to only the columns in the region, so it wouldn't update the whole pixmap properly.
|
||||
const bool whole_region = current_paint_region_.boundingRect().width() == viewport()->width();
|
||||
if (whole_region) {
|
||||
const_cast<PlaylistView*>(this)->UpdateCachedCurrentRowPixmap(opt, idx);
|
||||
painter->drawPixmap(opt.rect, cached_current_row_);
|
||||
}
|
||||
else {
|
||||
QTreeView::drawRow(painter, opt, idx);
|
||||
}
|
||||
}
|
||||
else {
|
||||
QTreeView::drawRow(painter, opt, idx);
|
||||
painter->drawPixmap(opt.rect, cached_current_row_);
|
||||
}
|
||||
}
|
||||
else {
|
||||
painter->save();
|
||||
if (pixmap_tinyplay_.isNull() || pixmap_tinypause_.isNull() || opt.rect.height() != row_height_) {
|
||||
const_cast<PlaylistView*>(this)->row_height_ = opt.rect.height();
|
||||
const_cast<PlaylistView*>(this)->LoadTinyPlayPausePixmaps(static_cast<int>(static_cast<float>(opt.rect.height()) / 1.4F));
|
||||
}
|
||||
int pixmap_width = 0;
|
||||
int pixmap_height = 0;
|
||||
if (is_paused) {
|
||||
pixmap_width = pixmap_tinypause_.width();
|
||||
pixmap_height = pixmap_tinypause_.height();
|
||||
}
|
||||
else {
|
||||
pixmap_width = pixmap_tinyplay_.width();
|
||||
pixmap_height = pixmap_tinyplay_.height();
|
||||
}
|
||||
QPoint play_pos(pixmap_width / 2, (opt.rect.height() - pixmap_height) / 2);
|
||||
if (selectionModel()->isSelected(idx)) {
|
||||
painter->fillRect(opt.rect, opt.palette.color(QPalette::Highlight));
|
||||
}
|
||||
painter->drawPixmap(opt.rect.topLeft() + play_pos, is_paused ? pixmap_tinypause_ : pixmap_tinyplay_);
|
||||
painter->restore();
|
||||
QTreeView::drawRow(painter, opt, idx);
|
||||
}
|
||||
}
|
||||
else {
|
||||
QTreeView::drawRow(painter, opt, idx);
|
||||
@ -1174,12 +1211,13 @@ void PlaylistView::ReloadSettings() {
|
||||
QSettings s;
|
||||
|
||||
s.beginGroup(PlaylistSettingsPage::kSettingsGroup);
|
||||
bars_enabled_ = s.value("show_bars", true).toBool();
|
||||
#ifdef Q_OS_MACOS
|
||||
bool glow_effect = false;
|
||||
#else
|
||||
bool glow_effect = true;
|
||||
#endif
|
||||
glow_enabled_ = s.value("glow_effect", glow_effect).toBool();
|
||||
glow_enabled_ = bars_enabled_ && s.value("glow_effect", glow_effect).toBool();
|
||||
bool editmetadatainline = s.value("editmetadatainline", false).toBool();
|
||||
select_track_ = s.value("select_track", false).toBool();
|
||||
auto_sort_ = s.value("auto_sort", false).toBool();
|
||||
|
@ -195,6 +195,7 @@ class PlaylistView : public QTreeView {
|
||||
|
||||
void ReloadBarPixmaps();
|
||||
QList<QPixmap> LoadBarPixmap(const QString &filename);
|
||||
void LoadTinyPlayPausePixmaps(const int desired_size);
|
||||
void UpdateCachedCurrentRowPixmap(QStyleOptionViewItem option, const QModelIndex &idx);
|
||||
|
||||
void set_background_image_type(AppearanceSettingsPage::BackgroundImageType bg) {
|
||||
@ -259,6 +260,7 @@ class PlaylistView : public QTreeView {
|
||||
int previous_background_image_x_;
|
||||
int previous_background_image_y_;
|
||||
|
||||
bool bars_enabled_;
|
||||
bool glow_enabled_;
|
||||
bool select_track_;
|
||||
bool auto_sort_;
|
||||
@ -301,6 +303,9 @@ class PlaylistView : public QTreeView {
|
||||
|
||||
QColor playlist_playing_song_color_;
|
||||
|
||||
QPixmap pixmap_tinyplay_;
|
||||
QPixmap pixmap_tinypause_;
|
||||
|
||||
};
|
||||
|
||||
#endif // PLAYLISTVIEW_H
|
||||
|
@ -55,14 +55,18 @@ void PlaylistSettingsPage::Load() {
|
||||
s.beginGroup(kSettingsGroup);
|
||||
|
||||
ui_->checkbox_alternating_row_colors->setChecked(s.value("alternating_row_colors", true).toBool());
|
||||
ui_->checkbox_barscurrenttrack->setChecked(s.value("show_bars", true).toBool());
|
||||
|
||||
ui_->checkbox_glowcurrenttrack->setEnabled(ui_->checkbox_barscurrenttrack->isChecked());
|
||||
if (ui_->checkbox_barscurrenttrack->isChecked()) {
|
||||
#ifdef Q_OS_MACOS
|
||||
bool glow_effect = false;
|
||||
bool glow_effect = false;
|
||||
#else
|
||||
bool glow_effect = true;
|
||||
bool glow_effect = true;
|
||||
#endif
|
||||
ui_->checkbox_glowcurrenttrack->setChecked(s.value("glow_effect", glow_effect).toBool());
|
||||
}
|
||||
|
||||
ui_->checkbox_glowcurrenttrack->setChecked(s.value("glow_effect", glow_effect).toBool());
|
||||
ui_->checkbox_warncloseplaylist->setChecked(s.value("warn_close_playlist", true).toBool());
|
||||
ui_->checkbox_continueonerror->setChecked(s.value("continue_on_error", false).toBool());
|
||||
ui_->checkbox_greyout_songs_startup->setChecked(s.value("greyout_songs_startup", true).toBool());
|
||||
@ -124,6 +128,7 @@ void PlaylistSettingsPage::Save() {
|
||||
QSettings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
s.setValue("alternating_row_colors", ui_->checkbox_alternating_row_colors->isChecked());
|
||||
s.setValue("show_bars", ui_->checkbox_barscurrenttrack->isChecked());
|
||||
s.setValue("glow_effect", ui_->checkbox_glowcurrenttrack->isChecked());
|
||||
s.setValue("warn_close_playlist", ui_->checkbox_warncloseplaylist->isChecked());
|
||||
s.setValue("continue_on_error", ui_->checkbox_continueonerror->isChecked());
|
||||
|
@ -21,10 +21,17 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkbox_barscurrenttrack">
|
||||
<property name="text">
|
||||
<string>Show bars on the currently playing track</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkbox_glowcurrenttrack">
|
||||
<property name="text">
|
||||
<string>Show a glowing animation on the current track</string>
|
||||
<string>Show a glowing animation on the currently playing track</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -176,5 +183,22 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>checkbox_barscurrenttrack</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>checkbox_glowcurrenttrack</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>258</x>
|
||||
<y>55</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>258</x>
|
||||
<y>88</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
Loading…
x
Reference in New Issue
Block a user