From 70d66cdcd5f97ad6cb7e697423edf35883eaa65c Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Thu, 30 Jul 2009 18:52:11 +0000 Subject: added partial cover support git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1088 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/Input/mad/CMakeLists.txt | 2 + src/plugins/Input/mad/coverwidget.cpp | 46 ++++++++++++++++++++ src/plugins/Input/mad/coverwidget.h | 50 ++++++++++++++++++++++ src/plugins/Input/mad/detailsdialog.cpp | 15 +++++++ src/plugins/Input/mad/detailsdialog.h | 1 + src/plugins/Input/mad/detailsdialog.ui | 75 ++++++++++++++++++--------------- src/plugins/Input/mad/mad.pro | 8 ++-- 7 files changed, 161 insertions(+), 36 deletions(-) create mode 100644 src/plugins/Input/mad/coverwidget.cpp create mode 100644 src/plugins/Input/mad/coverwidget.h (limited to 'src') diff --git a/src/plugins/Input/mad/CMakeLists.txt b/src/plugins/Input/mad/CMakeLists.txt index 1167005fd..bc08f3c74 100644 --- a/src/plugins/Input/mad/CMakeLists.txt +++ b/src/plugins/Input/mad/CMakeLists.txt @@ -38,6 +38,7 @@ SET(libmad_SRCS detailsdialog.cpp settingsdialog.cpp tagextractor.cpp + coverwidget.cpp ) SET(libmad_MOC_HDRS @@ -46,6 +47,7 @@ SET(libmad_MOC_HDRS decoder_mad.h detailsdialog.h tagextractor.h + coverwidget.h ) SET(libmad_RCCS translations/translations.qrc) diff --git a/src/plugins/Input/mad/coverwidget.cpp b/src/plugins/Input/mad/coverwidget.cpp new file mode 100644 index 000000000..88379ad50 --- /dev/null +++ b/src/plugins/Input/mad/coverwidget.cpp @@ -0,0 +1,46 @@ +/*************************************************************************** + * Copyright (C) 2009 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include + +#include "coverwidget.h" + +CoverWidget::CoverWidget(QWidget *parent) + : QWidget(parent) +{} + + +CoverWidget::~CoverWidget() +{} + +void CoverWidget::setPixmap(const QPixmap &pixmap) +{ + m_pixmap = pixmap; + update(); +} + +void CoverWidget::paintEvent (QPaintEvent *p) +{ + QPainter paint(this); + if(!m_pixmap.isNull()) + paint.drawPixmap(0,0, m_pixmap.scaled(p->rect().size())); +} + diff --git a/src/plugins/Input/mad/coverwidget.h b/src/plugins/Input/mad/coverwidget.h new file mode 100644 index 000000000..b06e66f7e --- /dev/null +++ b/src/plugins/Input/mad/coverwidget.h @@ -0,0 +1,50 @@ +/*************************************************************************** + * Copyright (C) 2009 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef PIXMAPWIDGET_H +#define PIXMAPWIDGET_H + +#include +#include + +/** + @author Ilya Kotov +*/ + +class CoverWidget : public QWidget +{ +Q_OBJECT +public: + CoverWidget(QWidget *parent = 0); + + ~CoverWidget(); + + virtual void setPixmap(const QPixmap&); + +protected: + void paintEvent (QPaintEvent *event); + +private: + QPixmap m_pixmap; + + + +}; + +#endif diff --git a/src/plugins/Input/mad/detailsdialog.cpp b/src/plugins/Input/mad/detailsdialog.cpp index 0b4f3a051..64f6088e9 100644 --- a/src/plugins/Input/mad/detailsdialog.cpp +++ b/src/plugins/Input/mad/detailsdialog.cpp @@ -92,6 +92,7 @@ DetailsDialog::DetailsDialog(QWidget *parent, const QString &path) m_inputs << ui.yearLineEdit; m_inputs << ui.trackLineEdit; m_inputs << ui.genreLineEdit; + ui.coverWidget->setPixmap(findCover(path)); } @@ -341,3 +342,17 @@ void DetailsDialog::showAudioProperties(QMap p) formattedText.append(""); ui.propertiesLabel->setText(formattedText); } + +QPixmap DetailsDialog::findCover(const QString &path) +{ + QString p = QFileInfo(path).absolutePath(); + QDir dir(p); + dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); + dir.setSorting(QDir::Name); + QStringList filters; + filters << "*.jpg" << "*.png"; + QFileInfoList file_list = dir.entryInfoList(filters); + if(!file_list.isEmpty()) + return QPixmap (file_list.at(0).absoluteFilePath()); + return QPixmap(); +} diff --git a/src/plugins/Input/mad/detailsdialog.h b/src/plugins/Input/mad/detailsdialog.h index e98c4f469..98c8bedd9 100644 --- a/src/plugins/Input/mad/detailsdialog.h +++ b/src/plugins/Input/mad/detailsdialog.h @@ -50,6 +50,7 @@ private slots: void loadTag(); private: + QPixmap findCover(const QString &path); void loadMPEGInfo(); uint selectedTag(); void showAudioProperties(QMap p); diff --git a/src/plugins/Input/mad/detailsdialog.ui b/src/plugins/Input/mad/detailsdialog.ui index d8893621f..c4cd5ab8a 100644 --- a/src/plugins/Input/mad/detailsdialog.ui +++ b/src/plugins/Input/mad/detailsdialog.ui @@ -26,38 +26,6 @@ - - - - true - - - - 110 - 110 - - - - - 110 - 110 - - - - ... - - - - :/crematory.jpg:/crematory.jpg - - - - 100 - 100 - - - - @@ -95,7 +63,18 @@ - + + + false + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Arial'; font-size:10pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p></body></html> + + @@ -364,8 +343,38 @@ + + + + + 0 + 0 + + + + + 110 + 110 + + + + + 110 + 110 + + + + + + + CoverWidget + QWidget +
coverwidget.h
+ 1 +
+
diff --git a/src/plugins/Input/mad/mad.pro b/src/plugins/Input/mad/mad.pro index b48885c3b..ac3f9fd01 100644 --- a/src/plugins/Input/mad/mad.pro +++ b/src/plugins/Input/mad/mad.pro @@ -2,17 +2,19 @@ include(../../plugins.pri) FORMS += detailsdialog.ui \ - settingsdialog.ui + settingsdialog.ui HEADERS += decodermadfactory.h \ decoder_mad.h \ detailsdialog.h \ settingsdialog.h \ - tagextractor.h + tagextractor.h \ + coverwidget.h SOURCES += decoder_mad.cpp \ decodermadfactory.cpp \ detailsdialog.cpp \ settingsdialog.cpp \ - tagextractor.cpp + tagextractor.cpp \ + coverwidget.cpp TARGET =$$PLUGINS_PREFIX/Input/mad unix:QMAKE_CLEAN =$$PLUGINS_PREFIX/Input/libmad.so -- cgit v1.2.3-13-gbd6f