Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 8d36f768 authored by Scott Wheeler's avatar Scott Wheeler

Show the full image when we click on it.

svn path=/trunk/kdemultimedia/juk/; revision=361884
parent ba0abdcf
......@@ -32,6 +32,23 @@ struct Line : public QFrame
Line(QWidget *parent) : QFrame(parent) { setFrameShape(VLine); }
};
struct CoverPopup : public QWidget
{
CoverPopup(const QPixmap &image, int x, int y) : QWidget(0, 0, WX11BypassWM)
{
QHBoxLayout *layout = new QHBoxLayout(this);
QLabel *label = new QLabel(this);
layout->addWidget(label);
label->setFrameStyle(QFrame::Box | QFrame::Raised);
label->setLineWidth(1);
label->setPixmap(image);
setGeometry(x, y, label->width(), label->height());
show();
}
};
////////////////////////////////////////////////////////////////////////////////
// NowPlaying
////////////////////////////////////////////////////////////////////////////////
......@@ -83,7 +100,8 @@ void NowPlaying::slotUpdate()
CoverItem::CoverItem(NowPlaying *parent) :
QLabel(parent, "CoverItem"),
NowPlayingItem(parent)
NowPlayingItem(parent),
m_popup(0)
{
setFixedHeight(parent->height() - parent->layout()->margin() * 2);
setFrameStyle(Box | Plain);
......@@ -93,6 +111,8 @@ CoverItem::CoverItem(NowPlaying *parent) :
void CoverItem::update(const FileHandle &file)
{
m_file = file;
if(file.coverInfo()->hasCover()) {
show();
QImage image = file.coverInfo()->pixmap(CoverInfo::FullSize).convertToImage();
......@@ -102,6 +122,33 @@ void CoverItem::update(const FileHandle &file)
hide();
}
void CoverItem::mousePressEvent(QMouseEvent *event)
{
if(event->button() == LeftButton &&
m_file.coverInfo()->hasCover())
{
if(m_popup)
delete m_popup;
m_popup = new CoverPopup(m_file.coverInfo()->pixmap(CoverInfo::FullSize),
event->globalX(), event->globalY());
m_popup->installEventFilter(this);
}
QLabel::mousePressEvent(event);
}
bool CoverItem::eventFilter(QObject *object, QEvent *event)
{
if(object == m_popup && event->type() == QEvent::MouseButtonPress) {
delete m_popup;
m_popup = 0;
return true;
}
return QLabel::eventFilter(object, event);
}
////////////////////////////////////////////////////////////////////////////////
// TrackItem
////////////////////////////////////////////////////////////////////////////////
......
......@@ -68,6 +68,12 @@ class CoverItem : public QLabel, public NowPlayingItem
public:
CoverItem(NowPlaying *parent);
virtual void update(const FileHandle &file);
virtual void mousePressEvent(QMouseEvent *event);
virtual bool eventFilter(QObject *object, QEvent *event);
private:
FileHandle m_file;
QWidget *m_popup;
};
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment