@@ -62,6 +62,7 @@
|
||||
queue.
|
||||
46. Add volume control for HTTP stream playback.
|
||||
47. Update toolbar cover tooltip when song changes.
|
||||
48. Add option to scale album cover in information view.
|
||||
|
||||
2.2.0
|
||||
-----
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "widgets/icons.h"
|
||||
#include "support/actioncollection.h"
|
||||
#include "support/action.h"
|
||||
#include "support/configuration.h"
|
||||
#include "models/mpdlibrarymodel.h"
|
||||
#include "mpd-interface/cuefile.h"
|
||||
#include <QScrollBar>
|
||||
@@ -66,7 +67,10 @@ AlbumView::AlbumView(QWidget *p)
|
||||
{
|
||||
engine=ContextEngine::create(this);
|
||||
refreshAction = ActionCollection::get()->createAction("refreshalbum", tr("Refresh Album Information"), Icons::self()->refreshIcon);
|
||||
scaleCoverAction = ActionCollection::get()->createAction("scalealbumcover", tr("Scale Album Cover"));
|
||||
scaleCoverAction->setCheckable(true);
|
||||
connect(refreshAction, SIGNAL(triggered()), this, SLOT(refresh()));
|
||||
connect(scaleCoverAction, SIGNAL(toggled(bool)), this, SLOT(setScaleImage(bool)));
|
||||
connect(engine, SIGNAL(searchResult(QString,QString)), this, SLOT(searchResponse(QString,QString)));
|
||||
connect(Covers::self(), SIGNAL(cover(Song,QImage,QString)), SLOT(coverRetrieved(Song,QImage,QString)));
|
||||
connect(Covers::self(), SIGNAL(coverUpdated(Song,QImage,QString)), SLOT(coverUpdated(Song,QImage,QString)));
|
||||
@@ -83,6 +87,12 @@ AlbumView::AlbumView(QWidget *p)
|
||||
connect(timer, SIGNAL(timeout()), this, SLOT(clearCache()));
|
||||
timer->start((int)((ArtistView::constCacheAge/2.0)*1000*24*60*60));
|
||||
}
|
||||
scaleCoverAction->setChecked(Configuration(metaObject()->className()).get("scaleCover", false));
|
||||
}
|
||||
|
||||
AlbumView::~AlbumView()
|
||||
{
|
||||
Configuration(metaObject()->className()).set("scaleCover", scaleCoverAction->isChecked());
|
||||
}
|
||||
|
||||
void AlbumView::showContextMenu(const QPoint &pos)
|
||||
@@ -94,6 +104,7 @@ void AlbumView::showContextMenu(const QPoint &pos)
|
||||
} else {
|
||||
menu->addAction(refreshAction);
|
||||
}
|
||||
menu->addAction(scaleCoverAction);
|
||||
menu->exec(text->mapToGlobal(pos));
|
||||
delete menu;
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ public:
|
||||
static const QLatin1String constInfoExt;
|
||||
|
||||
AlbumView(QWidget *p);
|
||||
~AlbumView() override;
|
||||
|
||||
void update(const Song &song, bool force=false) override;
|
||||
|
||||
@@ -69,6 +70,7 @@ private:
|
||||
private:
|
||||
QString currentArtist;
|
||||
Action *refreshAction;
|
||||
Action *scaleCoverAction;
|
||||
ContextEngine *engine;
|
||||
int detailsReceived;
|
||||
QString pic;
|
||||
|
||||
@@ -185,7 +185,7 @@ QString View::createPicTag(const QImage &img, const QString &file)
|
||||
return QString();
|
||||
}
|
||||
// No filename given, or file does not exist - therefore encode & scale image.
|
||||
return encode(img.scaled(texts.at(0)->picSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||
return encode(img);
|
||||
}
|
||||
|
||||
void View::showEvent(QShowEvent *e)
|
||||
@@ -288,3 +288,10 @@ void View::setHtml(const QString &h, int index)
|
||||
void View::abort()
|
||||
{
|
||||
}
|
||||
|
||||
void View::setScaleImage(bool s)
|
||||
{
|
||||
for (TextBrowser *t: texts) {
|
||||
t->setScaleImage(s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ Q_SIGNALS:
|
||||
|
||||
protected Q_SLOTS:
|
||||
virtual void abort();
|
||||
void setScaleImage(bool s);
|
||||
|
||||
protected:
|
||||
Song currentSong;
|
||||
|
||||
@@ -24,9 +24,14 @@
|
||||
#include "textbrowser.h"
|
||||
#include <QImage>
|
||||
#include <QScrollBar>
|
||||
#include <QEvent>
|
||||
#include <QStyle>
|
||||
|
||||
TextBrowser::TextBrowser(QWidget *p)
|
||||
: QTextBrowser(p)
|
||||
, lastImageSize(0)
|
||||
, scaleImg(false)
|
||||
, haveImg(false)
|
||||
{
|
||||
origZoomValue=font().pointSize();
|
||||
}
|
||||
@@ -39,7 +44,8 @@ QVariant TextBrowser::loadResource(int type, const QUrl &name)
|
||||
QImage img;
|
||||
img.load(name.path());
|
||||
if (!img.isNull()) {
|
||||
return img.scaled(picSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
haveImg=true;
|
||||
return img.scaled(imageSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
}
|
||||
} else if (QLatin1String("data")==name.scheme()) {
|
||||
QByteArray encoded=name.toEncoded();
|
||||
@@ -48,16 +54,72 @@ QVariant TextBrowser::loadResource(int type, const QUrl &name)
|
||||
QImage img;
|
||||
img.loadFromData(encoded);
|
||||
if (!img.isNull()) {
|
||||
return img.scaled(picSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
haveImg=true;
|
||||
return img.scaled(imageSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
}
|
||||
}
|
||||
}
|
||||
return QTextBrowser::loadResource(type, name);
|
||||
}
|
||||
|
||||
void TextBrowser::setScaleImage(bool s)
|
||||
{
|
||||
if (s!=scaleImg) {
|
||||
scaleImg=s;
|
||||
verticalScrollBar()->removeEventFilter(this);
|
||||
if (scaleImg) {
|
||||
verticalScrollBar()->installEventFilter(this);
|
||||
}
|
||||
if (haveImg) {
|
||||
setHtml(toHtml());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TextBrowser::setPal(const QPalette &pal)
|
||||
{
|
||||
setPalette(pal);
|
||||
verticalScrollBar()->setPalette(pal);
|
||||
horizontalScrollBar()->setPalette(pal);
|
||||
}
|
||||
|
||||
void TextBrowser::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
handleSizeChange();
|
||||
QTextBrowser::resizeEvent(e);
|
||||
}
|
||||
|
||||
bool TextBrowser::eventFilter(QObject *obj, QEvent *ev)
|
||||
{
|
||||
if (obj==verticalScrollBar() && (QEvent::Show==ev->type() || QEvent::Hide==ev->type())) {
|
||||
handleSizeChange();
|
||||
}
|
||||
return QTextBrowser::eventFilter(obj, ev);
|
||||
}
|
||||
|
||||
void TextBrowser::handleSizeChange()
|
||||
{
|
||||
if (haveImg && scaleImg) {
|
||||
int imgSize=imageSize().width();
|
||||
if (imgSize!=lastImageSize) {
|
||||
lastImageSize=imgSize;
|
||||
setHtml(toHtml());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QSize TextBrowser::imageSize() const
|
||||
{
|
||||
if (!scaleImage()) {
|
||||
return picSize();
|
||||
}
|
||||
|
||||
int sbarSpacing = style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarSpacing);
|
||||
if (sbarSpacing<0) {
|
||||
return size()-QSize(4, 0);
|
||||
} else {
|
||||
QScrollBar *sb=verticalScrollBar();
|
||||
int sbarWidth=sb && sb->isVisible() ? 0 : style()->pixelMetric(QStyle::PM_ScrollBarExtent);
|
||||
return size()-QSize(4 + sbarSpacing + sbarWidth, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,10 +36,24 @@ public:
|
||||
int zoom() const { return font().pointSize()-origZoomValue; }
|
||||
void setPicSize(const QSize &p) { pSize=p; }
|
||||
QSize picSize() const { return pSize; }
|
||||
void setScaleImage(bool s);
|
||||
bool scaleImage() const { return scaleImg; }
|
||||
void setPal(const QPalette &pal);
|
||||
void setHtml(const QString &s) { haveImg=false; QTextBrowser::setHtml(s); }
|
||||
void setText(const QString &s) { haveImg=false; QTextBrowser::setText(s); }
|
||||
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
bool eventFilter(QObject *obj, QEvent *ev) override;
|
||||
|
||||
private:
|
||||
void handleSizeChange();
|
||||
QSize imageSize() const;
|
||||
|
||||
private:
|
||||
int origZoomValue;
|
||||
int lastImageSize;
|
||||
bool scaleImg;
|
||||
bool haveImg;
|
||||
QSize pSize;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user