aboutsummaryrefslogtreecommitdiff
path: root/src/qmmpui
diff options
context:
space:
mode:
Diffstat (limited to 'src/qmmpui')
-rw-r--r--src/qmmpui/coverviewer.cpp60
-rw-r--r--src/qmmpui/coverviewer_p.h53
-rw-r--r--src/qmmpui/detailsdialog.cpp11
-rw-r--r--src/qmmpui/qmmpui.pro6
4 files changed, 127 insertions, 3 deletions
diff --git a/src/qmmpui/coverviewer.cpp b/src/qmmpui/coverviewer.cpp
new file mode 100644
index 000000000..0a9bb731b
--- /dev/null
+++ b/src/qmmpui/coverviewer.cpp
@@ -0,0 +1,60 @@
+/***************************************************************************
+ * Copyright (C) 2017 by Ilya Kotov *
+ * forkotov02@hotmail.ru *
+ * *
+ * This program 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 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program 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 this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#include <QPixmap>
+#include <QPainter>
+#include <QPaintEvent>
+#include <QAction>
+#include <qmmpui/filedialog.h>
+#include "coverviewer_p.h"
+
+CoverViewer::CoverViewer(QWidget *parent)
+ : QWidget(parent)
+{
+ QAction *saveAsAction = new QAction(tr("&Save As..."), this);
+ connect(saveAsAction, SIGNAL(triggered()), SLOT(saveAs()));
+ addAction(saveAsAction);
+ setContextMenuPolicy(Qt::ActionsContextMenu);
+}
+
+CoverViewer::~CoverViewer()
+{}
+
+void CoverViewer::setPixmap(const QPixmap &pixmap)
+{
+ m_pixmap = pixmap;
+ update();
+}
+
+void CoverViewer::paintEvent(QPaintEvent *p)
+{
+ QPainter paint(this);
+ if(!m_pixmap.isNull())
+ paint.drawPixmap(0,0, m_pixmap.scaled(p->rect().size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
+}
+
+void CoverViewer::saveAs()
+{
+ QString path = FileDialog::getSaveFileName(this, tr("Save Cover As"),
+ QDir::homePath() + "/cover.jpg",
+ tr("Images") +" (*.png *.jpg)");
+
+ if (!path.isEmpty())
+ m_pixmap.save(path);
+}
diff --git a/src/qmmpui/coverviewer_p.h b/src/qmmpui/coverviewer_p.h
new file mode 100644
index 000000000..d4a1b7bff
--- /dev/null
+++ b/src/qmmpui/coverviewer_p.h
@@ -0,0 +1,53 @@
+/***************************************************************************
+ * Copyright (C) 2017 by Ilya Kotov *
+ * forkotov02@hotmail.ru *
+ * *
+ * This program 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 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program 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 this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#ifndef COVERVIEWER_H
+#define COVERVIEWER_H
+
+#include <QWidget>
+#include <QPixmap>
+
+class QMouseEvent;
+
+/**
+ @internal
+ @author Ilya Kotov <forkotov02@hotmail.ru>
+*/
+
+class CoverViewer : public QWidget
+{
+Q_OBJECT
+public:
+ CoverViewer(QWidget *parent = 0);
+
+ ~CoverViewer();
+
+ void setPixmap(const QPixmap&);
+
+protected:
+ void paintEvent(QPaintEvent *event);
+
+private slots:
+ void saveAs();
+
+private:
+ QPixmap m_pixmap;
+};
+
+#endif
diff --git a/src/qmmpui/detailsdialog.cpp b/src/qmmpui/detailsdialog.cpp
index f3633898e..64a42906b 100644
--- a/src/qmmpui/detailsdialog.cpp
+++ b/src/qmmpui/detailsdialog.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2009-2016 by Ilya Kotov *
+ * Copyright (C) 2009-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -31,6 +31,7 @@
#include "ui_detailsdialog.h"
#include "playlisttrack.h"
#include "tageditor_p.h"
+#include "coverviewer_p.h"
#include "detailsdialog.h"
DetailsDialog::DetailsDialog(QList<PlayListTrack *> tracks, QWidget *parent)
@@ -143,6 +144,14 @@ void DetailsDialog::updatePage()
m_metaData = *m_track;
qDeleteAll(flist);
+ QPixmap cover = MetaDataManager::instance()->getCover(m_path);
+ if(!cover.isNull())
+ {
+ CoverViewer *coverViewer = new CoverViewer(this);
+ coverViewer->setPixmap(cover);
+ m_ui->tabWidget->addTab(coverViewer, tr("Cover"));
+ }
+
m_metaDataModel = MetaDataManager::instance()->createMetaDataModel(m_path, this);
if(m_metaDataModel)
diff --git a/src/qmmpui/qmmpui.pro b/src/qmmpui/qmmpui.pro
index 2c91c593c..91b78321c 100644
--- a/src/qmmpui/qmmpui.pro
+++ b/src/qmmpui/qmmpui.pro
@@ -70,7 +70,8 @@ HEADERS += general.h \
metadataformatter.h \
columneditor_p.h \
playlistheadermodel.h \
- metadatahelper_p.h
+ metadatahelper_p.h \
+ coverviewer_p.h
SOURCES += general.cpp \
playlistparser.cpp \
@@ -107,7 +108,8 @@ SOURCES += general.cpp \
metadataformatter.cpp \
columneditor.cpp \
playlistheadermodel.cpp \
- metadatahelper.cpp
+ metadatahelper.cpp \
+ coverviewer.cpp
FORMS += forms/detailsdialog.ui \
forms/tageditor.ui \