1
0
mirror of https://github.com/strawberrymusicplayer/strawberry synced 2024-12-18 03:29:12 +01:00

Rewrite parts of context to be adjustable and adjust album to width

This commit is contained in:
Jonas Kvinge 2020-04-06 02:47:57 +02:00
parent fb8e7d803f
commit 3fdbe84573
13 changed files with 852 additions and 1126 deletions

View File

@ -52,19 +52,14 @@ macos QMenu {
font-size: 13pt;
}
#scrollarea_play {
#context-layout-container {
background-color: %palette-base;
font: 11pt;
}
#scrollarea_stop {
#context-widget-scrollarea {
background-color: %palette-base;
font: 11pt;
}
#scrollAreaWidgetContents_stop {
background-color: %palette-base;
}
#scrollAreaWidgetContents_play {
#context-layout-scrollarea {
background-color: %palette-base;
}

View File

@ -154,6 +154,7 @@ set(SOURCES
equalizer/equalizerslider.cpp
context/contextview.cpp
context/contextalbum.cpp
context/contextalbumsmodel.cpp
context/contextalbumsview.cpp
@ -347,6 +348,7 @@ set(HEADERS
equalizer/equalizerslider.h
context/contextview.h
context/contextalbum.h
context/contextalbumsmodel.h
context/contextalbumsview.h
@ -500,8 +502,6 @@ set(UI
core/mainwindow.ui
context/contextviewcontainer.ui
collection/groupbydialog.ui
collection/collectionfilterwidget.ui
collection/collectionviewcontainer.ui

View File

@ -0,0 +1,177 @@
/*
* Strawberry Music Player
* Copyright 2020, Jonas Kvinge <jonas@jkvinge.net>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Strawberry is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <memory>
#include <QtGlobal>
#include <QObject>
#include <QWidget>
#include <QByteArray>
#include <QImage>
#include <QPixmap>
#include <QPalette>
#include <QBrush>
#include <QMovie>
#include <QTimeLine>
#include <QPainter>
#include <QSizePolicy>
#include <QPaintEvent>
#include "covermanager/albumcoverchoicecontroller.h"
#include "covermanager/albumcoverloader.h"
#include "contextalbum.h"
const int ContextAlbum::kWidgetSpacing = 40;
ContextAlbum::ContextAlbum(QWidget *parent) :
QWidget(parent),
album_cover_choice_controller_(nullptr),
downloading_covers_(false),
timeline_fade_(new QTimeLine(1000, this)),
image_strawberry_(":/pictures/strawberry.png"),
image_original_(image_strawberry_),
prev_width_(width()) {
setObjectName("context-widget-album");
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
cover_loader_options_.desired_height_ = 600;
cover_loader_options_.pad_output_image_ = true;
cover_loader_options_.scale_output_image_ = true;
pixmap_current_ = QPixmap::fromImage(AlbumCoverLoader::ScaleAndPad(cover_loader_options_, image_strawberry_));
connect(timeline_fade_, SIGNAL(valueChanged(qreal)), SLOT(FadePreviousTrack(qreal)));
timeline_fade_->setDirection(QTimeLine::Backward); // 1.0 -> 0.0
}
void ContextAlbum::Init(AlbumCoverChoiceController *album_cover_choice_controller) {
album_cover_choice_controller_ = album_cover_choice_controller;
connect(album_cover_choice_controller_, SIGNAL(AutomaticCoverSearchDone()), this, SLOT(AutomaticCoverSearchDone()));
}
void ContextAlbum::paintEvent(QPaintEvent*) {
QPainter p(this);
DrawImage(&p);
// Draw the previous track's image if we're fading
if (!pixmap_previous_.isNull()) {
p.setOpacity(pixmap_previous_opacity_);
p.drawPixmap(0, 0, pixmap_previous_);
}
}
void ContextAlbum::DrawImage(QPainter *p) {
if (width() != prev_width_) {
cover_loader_options_.desired_height_ = width() - kWidgetSpacing;
pixmap_current_ = QPixmap::fromImage(AlbumCoverLoader::ScaleAndPad(cover_loader_options_, image_original_));
prev_width_ = width();
}
p->drawPixmap(0, 0, width() - kWidgetSpacing, width() - kWidgetSpacing, pixmap_current_);
if (downloading_covers_ && spinner_animation_) {
p->drawPixmap(50, 50, 16, 16, spinner_animation_->currentPixmap());
}
}
void ContextAlbum::FadePreviousTrack(const qreal value) {
pixmap_previous_opacity_ = value;
if (qFuzzyCompare(pixmap_previous_opacity_, qreal(0.0))) {
image_previous_ = QImage();
pixmap_previous_ = QPixmap();
}
update();
if (value == 0 && image_original_ == image_strawberry_) {
emit FadeStopFinished();
}
}
void ContextAlbum::ScaleCover() {
cover_loader_options_.desired_height_ = width() - kWidgetSpacing;
pixmap_current_ = QPixmap::fromImage(AlbumCoverLoader::ScaleAndPad(cover_loader_options_, image_original_));
prev_width_ = width();
update();
}
void ContextAlbum::SetImage(QImage image) {
if (image.isNull()) image = image_strawberry_;
if (downloading_covers_) {
downloading_covers_ = false;
spinner_animation_.reset();
}
// Cache the current pixmap so we can fade between them
pixmap_previous_ = QPixmap(width() - kWidgetSpacing, width() - kWidgetSpacing);
pixmap_previous_.fill(palette().window().color());
pixmap_previous_opacity_ = 1.0;
QPainter p(&pixmap_previous_);
DrawImage(&p);
p.end();
image_previous_ = image_original_;
image_original_ = image;
ScaleCover();
// Were we waiting for this cover to load before we started fading?
if (!pixmap_previous_.isNull() && timeline_fade_) {
timeline_fade_->stop();
timeline_fade_->setDirection(QTimeLine::Backward); // 1.0 -> 0.0
timeline_fade_->start();
}
}
void ContextAlbum::SearchCoverInProgress() {
downloading_covers_ = true;
// Show a spinner animation
spinner_animation_.reset(new QMovie(":/pictures/spinner.gif", QByteArray(), this));
connect(spinner_animation_.get(), SIGNAL(updated(const QRect&)), SLOT(update()));
spinner_animation_->start();
update();
}
void ContextAlbum::AutomaticCoverSearchDone() {
downloading_covers_ = false;
spinner_animation_.reset();
update();
}

View File

@ -0,0 +1,84 @@
/*
* Strawberry Music Player
* Copyright 2020, Jonas Kvinge <jonas@jkvinge.net>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Strawberry is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef CONTEXTALBUM_H
#define CONTEXTALBUM_H
#include "config.h"
#include <memory>
#include <QtGlobal>
#include <QObject>
#include <QWidget>
#include <QString>
#include <QImage>
#include <QPixmap>
#include <QMovie>
#include "covermanager/albumcoverloaderoptions.h"
class QTimeLine;
class QPainter;
class QPaintEvent;
class AlbumCoverChoiceController;
class ContextAlbum : public QWidget {
Q_OBJECT
public:
ContextAlbum(QWidget *parent = nullptr);
void Init(AlbumCoverChoiceController *album_cover_choice_controller);
void SetImage(QImage image = QImage());
protected:
void paintEvent(QPaintEvent*);
private:
void DrawImage(QPainter *p);
void ScaleCover();
void GetCoverAutomatically();
signals:
void FadeStopFinished();
private slots:
void SearchCoverInProgress();
void AutomaticCoverSearchDone();
void FadePreviousTrack(const qreal value);
private:
static const int kWidgetSpacing;
AlbumCoverChoiceController *album_cover_choice_controller_;
AlbumCoverLoaderOptions cover_loader_options_;
bool downloading_covers_;
QTimeLine *timeline_fade_;
QImage image_strawberry_;
QImage image_original_;
QImage image_previous_;
QPixmap pixmap_current_;
QPixmap pixmap_previous_;
qreal pixmap_previous_opacity_;
std::unique_ptr<QMovie> spinner_animation_;
int prev_width_;
};
#endif // CONTEXTALBUM_H

View File

@ -2,7 +2,7 @@
* Strawberry Music Player
* This code was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2013, Jonas Kvinge <jonas@strawbs.net>
* Copyright 2013-2020, Jonas Kvinge <jonas@jkvinge.net>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -2,7 +2,7 @@
* Strawberry Music Player
* This code was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2013, Jonas Kvinge <jonas@strawbs.net>
* Copyright 2013-2020, Jonas Kvinge <jonas@jkvinge.net>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/*
* Strawberry Music Player
* Copyright 2013, Jonas Kvinge <jonas@strawbs.net>
* Copyright 2013-2020, Jonas Kvinge <jonas@jkvinge.net>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -22,39 +22,31 @@
#include "config.h"
#include <memory>
#include <QtGlobal>
#include <QObject>
#include <QWidget>
#include <QString>
#include <QImage>
#include <QPixmap>
#include <QMovie>
#include "core/song.h"
#include "covermanager/albumcoverloaderoptions.h"
#include "contextalbum.h"
#include "ui_contextviewcontainer.h"
using std::unique_ptr;
class QTimeLine;
class QPainter;
class QMenu;
class QAction;
class QLabel;
class QEvent;
class QStackedWidget;
class QVBoxLayout;
class QGridLayout;
class QScrollArea;
class QSpacerItem;
class QResizeEvent;
class QContextMenuEvent;
class QMouseEvent;
class QDragEnterEvent;
class QDropEvent;
class Application;
class CollectionView;
class CollectionModel;
class AlbumCoverChoiceController;
class Ui_ContextViewContainer;
class ContextAlbumsView;
class LyricsFetcher;
@ -63,86 +55,123 @@ class ContextView : public QWidget {
public:
ContextView(QWidget *parent = nullptr);
~ContextView();
void Init(Application *app, CollectionView *collectionview, AlbumCoverChoiceController *album_cover_choice_controller);
ContextAlbumsView *albums() { return ui_->widget_play_albums; }
ContextAlbum *album_widget() const { return widget_album_; }
ContextAlbumsView *albums_widget() const { return widget_albums_; }
bool album_enabled() const { return widget_album_->isVisible(); }
public slots:
protected:
void resizeEvent(QResizeEvent*);
void contextMenuEvent(QContextMenuEvent*);
void dragEnterEvent(QDragEnterEvent*);
void dropEvent(QDropEvent*);
private:
void AddActions();
void SetLabelText(QLabel *label, int value, const QString &suffix, const QString &def = QString());
void NoSong();
void SetSong();
void UpdateSong(const Song &song);
void ResetSong();
void GetCoverAutomatically();
signals:
void AlbumEnabledChanged();
private slots:
void ActionShowAlbum();
void ActionShowData();
void ActionShowOutput();
void ActionShowAlbums();
void ActionShowLyrics();
void UpdateNoSong();
void Playing();
void Stopped();
void Error();
void SongChanged(const Song &song);
void AlbumCoverLoaded(const Song &song, const QUrl &cover_url, const QImage &image);
void FadeStopFinished();
void UpdateLyrics(const quint64 id, const QString &provider, const QString &lyrics);
public slots:
void ReloadSettings();
private:
Ui_ContextViewContainer *ui_;
Application *app_;
CollectionView *collectionview_;
AlbumCoverChoiceController *album_cover_choice_controller_;
LyricsFetcher *lyrics_fetcher_;
QMenu *menu_;
QTimeLine *timeline_fade_;
QImage image_strawberry_;
bool active_;
bool downloading_covers_;
QAction *action_show_album_;
QAction *action_show_data_;
QAction *action_show_output_;
QAction *action_show_albums_;
QAction *action_show_lyrics_;
AlbumCoverLoaderOptions cover_loader_options_;
Song song_;
QVBoxLayout *layout_container_;
QWidget *widget_scrollarea_;
QVBoxLayout *layout_scrollarea_;
QScrollArea *scrollarea_;
QLabel *label_top_;
ContextAlbum *widget_album_;
QStackedWidget *widget_stacked_;
QWidget *widget_stop_;
QWidget *widget_play_;
QVBoxLayout *layout_stop_;
QVBoxLayout *layout_play_;
QLabel *label_stop_summary_;
QSpacerItem *spacer_stop_bottom_;
QWidget *widget_play_data_;
QWidget *widget_play_engine_device_;
QGridLayout *layout_play_data_;
QGridLayout *layout_play_output_;
QLabel *label_play_albums_;
QLabel *label_play_lyrics_;
ContextAlbumsView *widget_albums_;
//QSpacerItem *spacer_play_album_;
QSpacerItem *spacer_play_output_;
QSpacerItem *spacer_play_data_;
QSpacerItem *spacer_play_albums_;
QSpacerItem *spacer_play_bottom_;
QLabel *label_filetype_title_;
QLabel *label_length_title_;
QLabel *label_samplerate_title_;
QLabel *label_bitdepth_title_;
QLabel *label_bitrate_title_;
QLabel *label_filetype_;
QLabel *label_length_;
QLabel *label_samplerate_;
QLabel *label_bitdepth_;
QLabel *label_bitrate_;
QLabel *label_device_title_;
QLabel *label_engine_title_;
QLabel *label_device_space_;
QLabel *label_engine_space_;
QLabel *label_device_;
QLabel *label_engine_;
QLabel *label_device_icon_;
QLabel *label_engine_icon_;
QSpacerItem *spacer_bottom_;
Song song_playing_;
Song song_prev_;
QImage image_original_;
QImage image_previous_;
QPixmap pixmap_current_;
QPixmap pixmap_previous_;
qreal pixmap_previous_opacity_;
std::unique_ptr<QMovie> spinner_animation_;
qint64 lyrics_id_;
QString lyrics_;
QString title_fmt_;
QString summary_fmt_;
void AddActions();
void SetLabelEnabled(QLabel *label);
void SetLabelDisabled(QLabel *label);
void SetLabelText(QLabel *label, int value, const QString &suffix, const QString &def = QString());
void NoSong();
void SetSong(const Song &song);
void UpdateSong(const Song &song);
void SetImage(const QImage &image);
void DrawImage(QPainter *p);
void ScaleCover();
void GetCoverAutomatically();
protected:
bool eventFilter(QObject *, QEvent *);
void handlePaintEvent(QObject *object, QEvent *event);
void PaintEventAlbum(QEvent *event);
void contextMenuEvent(QContextMenuEvent *e);
void mouseReleaseEvent(QMouseEvent *);
void dragEnterEvent(QDragEnterEvent *e);
void dropEvent(QDropEvent *e);
private slots:
void ActionShowData();
void ActionShowOutput();
void ActionShowAlbums();
void ActionShowLyrics();
void UpdateLyrics(const quint64 id, const QString &provider, const QString &lyrics);
void SearchCoverInProgress();
void AutomaticCoverSearchDone();
void AlbumCoverLoaded(const Song &song, const QUrl &cover_url, const QImage &image);
void FadePreviousTrack(qreal value);
int prev_width_;
};
#endif // CONTEXTVIEW_H

View File

@ -1,574 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ContextViewContainer</class>
<widget class="QWidget" name="ContextViewContainer">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>900</height>
</rect>
</property>
<layout class="QVBoxLayout" name="layout_container">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QStackedWidget" name="widget_stacked">
<widget class="QWidget" name="widget_stop">
<layout class="QVBoxLayout" name="widget_layout_stop">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="layout_stop">
<item>
<widget class="QScrollArea" name="scrollarea_stop">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_stop">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>394</width>
<height>894</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_stop_top">
<property name="minimumSize">
<size>
<width>0</width>
<height>70</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>70</height>
</size>
</property>
<property name="text">
<string>No song playing</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_stop_logo">
<property name="minimumSize">
<size>
<width>300</width>
<height>300</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>300</width>
<height>300</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../data/data.qrc">:/pictures/strawberry.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_stop_summary">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="spacer_stop_bottom">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>53</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="widget_play">
<layout class="QVBoxLayout" name="widget_layout_play">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="layout_play">
<item>
<widget class="QScrollArea" name="scrollarea_play">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_play">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>394</width>
<height>894</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_play_top">
<property name="minimumSize">
<size>
<width>0</width>
<height>70</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>700</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_play_album">
<property name="minimumSize">
<size>
<width>300</width>
<height>300</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>300</width>
<height>300</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="spacer_play">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QGridLayout" name="layout_play_data">
<item row="3" column="0">
<widget class="QLabel" name="label_bitdepth">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Bit depth</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="samplerate">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="length">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_length">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="filetype">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_samplerate">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Samplerate</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="bitdepth">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_filetype">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Filetype</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_bitrate">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Bitrate</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="bitrate">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="spacer_play_data">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QGridLayout" name="layout_play_grid">
<item row="1" column="1">
<widget class="QLabel" name="label_device_icon">
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="device">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="engine">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_engine_icon">
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_engine">
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Engine</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_device">
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Device</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="spacer_play_output">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_play_albums">
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>300</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="indent">
<number>6</number>
</property>
</widget>
</item>
<item>
<spacer name="spacer_play_albums1">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="ContextAlbumsView" name="widget_play_albums" native="true"/>
</item>
<item>
<spacer name="spacer_play_albums2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_play_lyrics">
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<spacer name="spacer_play_bottom">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>ContextAlbumsView</class>
<extends>QWidget</extends>
<header>context/contextalbumsview.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../data/data.qrc"/>
<include location="../../data/icons.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -683,8 +683,9 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
connect(app_->player(), SIGNAL(Stopped()), context_view_, SLOT(Stopped()));
connect(app_->player(), SIGNAL(Error()), context_view_, SLOT(Error()));
connect(this, SIGNAL(AlbumCoverReady(Song, QUrl, QImage)), context_view_, SLOT(AlbumCoverLoaded(Song, QUrl, QImage)));
connect(this, SIGNAL(SearchCoverInProgress()), context_view_, SLOT(SearchCoverInProgress()));
connect(context_view_->albums(), SIGNAL(AddToPlaylistSignal(QMimeData*)), SLOT(AddToPlaylist(QMimeData*)));
connect(this, SIGNAL(SearchCoverInProgress()), context_view_->album_widget(), SLOT(SearchCoverInProgress()));
connect(context_view_, SIGNAL(AlbumEnabledChanged()), SLOT(TabSwitched()));
connect(context_view_->albums_widget(), SIGNAL(AddToPlaylistSignal(QMimeData*)), SLOT(AddToPlaylist(QMimeData*)));
// Analyzer
connect(ui_->analyzer, SIGNAL(WheelEvent(int)), SLOT(VolumeWheelEvent(int)));
@ -1105,7 +1106,7 @@ void MainWindow::TrackSkipped(PlaylistItemPtr item) {
void MainWindow::TabSwitched() {
if (playing_widget_ && ui_->tabs->tabBar()->tabData(ui_->tabs->currentIndex()).toString().toLower() != "context") {
if (playing_widget_ && (ui_->tabs->tabBar()->tabData(ui_->tabs->currentIndex()).toString().toLower() != "context" || !context_view_->album_enabled())) {
ui_->widget_playing->SetEnabled();
}
else {

View File

@ -46,30 +46,33 @@ const char *ContextSettingsPage::kSettingsGroupLabels[ContextSettingsOrder::NELE
"Engine and Device",
"Albums by Artist",
"Song Lyrics",
"Album",
};
const char *ContextSettingsPage::kSettingsGroupEnable[ContextSettingsOrder::NELEMS] = {
"TechnicalDataEnable",
"EngineAndDeviceEnable",
"AlbumsByArtistEnable",
"SongLyricsEnable",
"AlbumEnable",
};
ContextSettingsPage::ContextSettingsPage(SettingsDialog* dialog)
: SettingsPage(dialog), ui_(new Ui_ContextSettingsPage) {
ContextSettingsPage::ContextSettingsPage(SettingsDialog* dialog) : SettingsPage(dialog), ui_(new Ui_ContextSettingsPage) {
ui_->setupUi(this);
setWindowIcon(IconLoader::Load("view-choose"));
checkboxes[ContextSettingsOrder::TECHNICAL_DATA] = ui_->context_item1_enable;
checkboxes[ContextSettingsOrder::ENGINE_AND_DEVICE] = ui_->context_item2_enable;
checkboxes[ContextSettingsOrder::ALBUMS_BY_ARTIST] = ui_->context_item3_enable;
checkboxes[ContextSettingsOrder::SONG_LYRICS] = ui_->context_item4_enable;
checkboxes[ContextSettingsOrder::ALBUM] = ui_->context_item1_enable;
checkboxes[ContextSettingsOrder::TECHNICAL_DATA] = ui_->context_item2_enable;
checkboxes[ContextSettingsOrder::ENGINE_AND_DEVICE] = ui_->context_item3_enable;
checkboxes[ContextSettingsOrder::ALBUMS_BY_ARTIST] = ui_->context_item4_enable;
checkboxes[ContextSettingsOrder::SONG_LYRICS] = ui_->context_item5_enable;
// Create and populate the helper menus
QMenu *menu = new QMenu(this);
menu->addAction(ui_->action_albumartist);
menu->addAction(ui_->action_artist);
menu->addAction(ui_->action_album);
menu->addAction(ui_->action_title);
menu->addAction(ui_->action_albumartist);
menu->addAction(ui_->action_year);
menu->addAction(ui_->action_composer);
menu->addAction(ui_->action_performer);
@ -81,8 +84,6 @@ ContextSettingsPage::ContextSettingsPage(SettingsDialog* dialog)
menu->addAction(ui_->action_playcount);
menu->addAction(ui_->action_skipcount);
menu->addAction(ui_->action_filename);
menu->addAction(ui_->action_rating);
menu->addAction(ui_->action_score);
menu->addSeparator();
menu->addAction(ui_->action_newline);
ui_->context_exp_chooser1->setMenu(menu);
@ -101,10 +102,7 @@ ContextSettingsPage::ContextSettingsPage(SettingsDialog* dialog)
}
ContextSettingsPage::~ContextSettingsPage()
{
delete ui_;
}
ContextSettingsPage::~ContextSettingsPage() { delete ui_; }
void ContextSettingsPage::Load() {
@ -113,7 +111,7 @@ void ContextSettingsPage::Load() {
s.beginGroup(ContextSettingsPage::kSettingsGroup);
ui_->context_custom_text1->setText(s.value(kSettingsTitleFmt, "%title% - %artist%").toString());
ui_->context_custom_text2->setText(s.value(kSettingsSummaryFmt, "%album%").toString());
for (int i = 0; i < ContextSettingsOrder::NELEMS; ++i) {
for (int i = 0 ; i < ContextSettingsOrder::NELEMS ; ++i) {
checkboxes[i]->setChecked(s.value(kSettingsGroupEnable[i], i != ContextSettingsOrder::ALBUMS_BY_ARTIST).toBool());
}
s.endGroup();

View File

@ -35,8 +35,7 @@ class QCheckBox;
class SettingsDialog;
class Ui_ContextSettingsPage;
class ContextSettingsPage : public SettingsPage
{
class ContextSettingsPage : public SettingsPage {
Q_OBJECT
public:
@ -48,7 +47,8 @@ public:
ENGINE_AND_DEVICE,
ALBUMS_BY_ARTIST,
SONG_LYRICS,
NELEMS,
ALBUM,
NELEMS
};
static const char *kSettingsGroup;

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>526</width>
<height>733</height>
<width>500</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
@ -147,64 +147,53 @@
</widget>
</item>
<item>
<widget class="QFrame" name="frame2">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
<widget class="QCheckBox" name="context_item1_enable">
<property name="text">
<string>Album</string>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
<property name="checked">
<bool>true</bool>
</property>
<property name="lineWidth">
<number>0</number>
</widget>
</item>
<item>
<widget class="QCheckBox" name="context_item2_enable">
<property name="text">
<string>Technical Data</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="context_item3_enable">
<property name="text">
<string>Engine and Device</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="context_item4_enable">
<property name="text">
<string>Albums by Artist</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="context_item5_enable">
<property name="text">
<string>Song Lyrics</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout2">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QCheckBox" name="context_item1_enable">
<property name="text">
<string>Technical Data</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="context_item2_enable">
<property name="text">
<string>Engine and Device</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="context_item3_enable">
<property name="text">
<string>Albums by Artist</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="context_item4_enable">
<property name="text">
<string>Song Lyrics</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
@ -336,22 +325,6 @@
<string>Add song skip count</string>
</property>
</action>
<action name="action_rating">
<property name="text">
<string notr="true">%rating%</string>
</property>
<property name="toolTip">
<string>Add song rating</string>
</property>
</action>
<action name="action_score">
<property name="text">
<string notr="true">%score%</string>
</property>
<property name="toolTip">
<string>Add song auto score</string>
</property>
</action>
<action name="action_newline">
<property name="text">
<string notr="true">%newline%</string>