<file>black/folder.png</file>
<file>white/folder.png</file>
</qresource>
+ <qresource prefix="/images">
+ <file>defaultcover.png</file>
+ </qresource>
</RCC>
src/dbusadaptor.cpp \
src/toolswidget.cpp \
src/managelibraryform.cpp \
- src/directoryview.cpp
+ src/directoryview.cpp \
+ src/coverfinder.cpp
HEADERS += src/mainwindow.h \
src/player/player.h \
src/dbusadaptor.h \
src/toolswidget.h \
src/managelibraryform.h \
- src/directoryview.h
+ src/directoryview.h \
+ src/coverfinder.h
FORMS += src/ui/mainwindow.ui \
src/ui/playerform.ui \
--- /dev/null
+/*
+ * SomePlayer - An alternate music player for Maemo 5
+ * Copyright (C) 2010 Nikolay (somebody) Tischenko <niktischenko@gmail.com>
+ *
+ * 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 "coverfinder.h"
+#include <QDebug>
+#include <QDir>
+#include <QFileInfo>
+
+CoverFinder::CoverFinder(QObject *parent) :
+ QObject(parent)
+{
+ _defaultCover = QImage(":/images/defaultcover.png");
+ SUFFIXES << "png" << "jpg" << "bmp" << "gif";
+ NAMES << "cover" << "folder" << "album";
+ DIRS << "cover" << "folder" << ".cover" << ".folder";
+}
+
+bool CoverFinder::find(QString path) {
+ QDir dir(path);
+ QFileInfoList items = dir.entryInfoList(QDir::Files);
+ QFileInfoList dirs = dir.entryInfoList(QDir::Dirs);
+ QFileInfoList pics;
+ foreach (QFileInfo item, items) {
+ if (SUFFIXES.contains(item.suffix().toLower())) {
+ pics << item;
+ if (NAMES.contains(item.baseName().toLower())) {
+ emit found(QImage(item.absoluteFilePath()));
+ return true;
+ }
+ }
+ }
+ foreach (QFileInfo item, pics) {
+ QImage i(item.absoluteFilePath());
+ if (0.8 <= (i.width()*1.0/(i.height()+1.0)) <= 1.2) {
+ emit found(i);
+ return true;
+ }
+ }
+ foreach(QFileInfo item, dirs) {
+ if (DIRS.contains(item.baseName().toLower())) {
+ if (find(item.absoluteFilePath())) {
+ return true;
+ }
+ }
+ }
+ emit found(_defaultCover);
+ return false;
+}
+
+QImage &CoverFinder::defaultCover() {
+ return _defaultCover;
+}
--- /dev/null
+/*
+ * SomePlayer - An alternate music player for Maemo 5
+ * Copyright (C) 2010 Nikolay (somebody) Tischenko <niktischenko@gmail.com>
+ *
+ * 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 COVERFINDER_H
+#define COVERFINDER_H
+
+#include <QObject>
+#include <QImage>
+#include "someplayer.h"
+
+class CoverFinder : public QObject
+{
+ Q_OBJECT
+public:
+ explicit CoverFinder(QObject *parent = 0);
+
+signals:
+ void found(QImage);
+
+public slots:
+ bool find(QString path);
+ QImage &defaultCover();
+
+private:
+ QImage _defaultCover;
+ QStringList SUFFIXES;
+ QStringList NAMES;
+ QStringList DIRS;
+
+};
+
+#endif // COVERFINDER_H
_fscreen_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
_fscreen_button->hide();
- ui->progressLayout->removeItem(ui->seekSpacer);
_tools_widget = new ToolsWidget(this);
ui->toolsLayout->insertWidget(0, _tools_widget);
_tools_widget->hide();
ui->playlistView->setItemDelegateForColumn(0, _track_renderer);
_tag_resolver = new TagResolver(this);
+ _coverfinder = new CoverFinder(this);
connect(ui->libraryButton, SIGNAL(clicked()), this, SLOT(_library()));
connect(ui->viewButton, SIGNAL(clicked()), this, SLOT(_toggle_view()));
connect(_tools_widget, SIGNAL(toggleFullscreen(bool)), _fscreen_button, SLOT(setChecked(bool)));
connect(_fscreen_button, SIGNAL(clicked(bool)), this, SIGNAL(fullscreen(bool)));
connect(_fscreen_button, SIGNAL(clicked(bool)), _tools_widget, SLOT(setFullscreenState(bool)));
+ connect(_coverfinder, SIGNAL(found(QImage)), this, SLOT(_display_cover(QImage)));
ui->viewButton->setIcon(QIcon(":/icons/"+_icons_theme+"/playback.png"));
_top_gradient = ui->topWidget->styleSheet();
_bottom_gradient = ui->bottomWidget->styleSheet();
ui->seekSlider->setMinimum(0);
ui->seekSlider->setMaximum(track.metadata().length());
_tick(0, track.metadata().length());
+ _coverfinder->find(QFileInfo(track.source()).absolutePath());
}
void PlayerForm::_tick(int done, int all) {
}
void PlayerForm::landscapeMode() {
- ui->progressLayout->removeItem(ui->seekSpacer);
- ui->progressLayout->insertWidget(1, ui->seekSlider);
- ui->progressWidget->setVisible(false);
-
landscape = true;
+ ui->widget->layout()->removeItem(ui->coverLayout);
+ ui->widget->layout()->removeItem(ui->controlLayout);
+ ui->controlLayout->removeItem(ui->countHLayout);
+ ui->controlLayout->removeItem(ui->cverticalSpacer_0);
+ ui->controlLayout->removeWidget(ui->titleLabel);
+ ui->controlLayout->removeItem(ui->coverLayout);
+ ui->controlLayout->removeItem(ui->cverticalSpacer_1);
+ ui->controlLayout->removeItem(ui->seekLayout);
+ ui->controlLayout->removeItem(ui->progressLayout);
+ ui->controlLayout->removeItem(ui->cverticalSpacer_2);
+ ui->controlLayout->removeWidget(ui->artistAlbumLabel);
+ ui->controlLayout->removeItem(ui->cverticalSpacer_3);
+ ui->controlLayout->addItem(ui->countHLayout);
+ ui->controlLayout->addItem(ui->cverticalSpacer_0);
+ ui->controlLayout->addWidget(ui->titleLabel);
+ ui->controlLayout->addItem(ui->cverticalSpacer_1);
+ ui->controlLayout->addItem(ui->progressLayout);
+ ui->controlLayout->addItem(ui->seekLayout);
+ ui->controlLayout->addItem(ui->cverticalSpacer_2);
+ ui->controlLayout->addWidget(ui->artistAlbumLabel);
+ ui->controlLayout->addItem(ui->cverticalSpacer_3);
+
+ ((QGridLayout *)ui->widget->layout())->addItem(ui->coverLayout, 0, 0);
+ ((QGridLayout *)ui->widget->layout())->addItem(ui->controlLayout, 0, 1);
+
ui->topWidget->hide();
ui->bottomWidget->hide();
}
void PlayerForm::portraitMode() {
- ui->progressLayout->insertSpacerItem(1, ui->seekSpacer);
- ui->progressWidget->layout()->addWidget(ui->seekSlider);
- ui->progressWidget->setVisible(true);
-
ui->topWidget->show();
ui->bottomWidget->show();
landscape = false;
+ ui->widget->layout()->removeItem(ui->coverLayout);
+ ui->widget->layout()->removeItem(ui->controlLayout);
+ ui->controlLayout->removeItem(ui->countHLayout);
+ ui->controlLayout->removeItem(ui->cverticalSpacer_0);
+ ui->controlLayout->removeWidget(ui->titleLabel);
+ ui->controlLayout->removeItem(ui->coverLayout);
+ ui->controlLayout->removeItem(ui->cverticalSpacer_1);
+ ui->controlLayout->removeItem(ui->seekLayout);
+ ui->controlLayout->removeItem(ui->progressLayout);
+ ui->controlLayout->removeItem(ui->cverticalSpacer_2);
+ ui->controlLayout->removeWidget(ui->artistAlbumLabel);
+ ui->controlLayout->removeItem(ui->cverticalSpacer_3);
+
+ ui->controlLayout->addItem(ui->countHLayout);
+ ui->controlLayout->addItem(ui->progressLayout);
+ ui->controlLayout->addItem(ui->seekLayout);
+ ui->controlLayout->addItem(ui->cverticalSpacer_0);
+ ui->controlLayout->addWidget(ui->titleLabel);
+ ui->controlLayout->addItem(ui->coverLayout);
+ ui->controlLayout->addWidget(ui->artistAlbumLabel);
+ ui->controlLayout->addItem(ui->cverticalSpacer_1);
+ ui->controlLayout->invalidate();
+
+ ui->widget->layout()->addItem(ui->controlLayout);
+
ui->topWidget->layout()->removeItem(ui->thorizontalSpacer_0);
ui->topWidget->layout()->removeItem(ui->thorizontalSpacer_1);
ui->topWidget->layout()->removeItem(ui->thorizontalSpacer_2);
void PlayerForm::hideCountdown() {
ui->countdownWidget->hide();
}
+
+void PlayerForm::_display_cover(QImage image) {
+ ui->coverLabel->setPixmap(QPixmap::fromImage(image));
+}
#include "tagresolver.h"
#include "dbusadaptor.h"
#include "toolswidget.h"
+#include "coverfinder.h"
namespace Ui {
class PlayerForm;
void _toggle_random();
void _track_decoded(Track);
void _tools_widget_toggle();
+ void _display_cover(QImage);
private:
Ui::PlayerForm *ui;
Playlist _current_playlist;
QTime *_time;
QStandardItemModel *_model;
+ CoverFinder *_coverfinder;
Player *_player;
QSlider *_seek_slider;
QMenu *_context_menu;
#include "config.h"
#define _DYNAMIC_PLAYLIST_MAX_COUNT_ 50
-#define _SOMEPLAYER_VERSION_ "1.3.8"
+#define _SOMEPLAYER_VERSION_ "1.4.0-dev"
#define NDEBUG
#define _SERVICE_NAME_ "ru.somebody.someplayer"
void TagResolver::decode(QStringList files) {
emit started();
foreach (QString filename, files) {
- TagLib::FileRef file_ref(QFile::encodeName(filename).data());
+ TagLib::FileRef file_ref(QFile::encodeName(filename).data(), true, TagLib::AudioProperties::Fast);
if (!file_ref.isNull()) {
TagLib::Tag *tag = file_ref.tag();
if (NULL != tag) {
}
Track TagResolver::decodeOne(QString filename) {
- TagLib::FileRef file_ref(QFile::encodeName(filename).data());
+ TagLib::FileRef file_ref(QFile::encodeName(filename).data(), true, TagLib::AudioProperties::Fast);
if (!file_ref.isNull()) {
TagLib::Tag *tag = file_ref.tag();
if (NULL != tag) {
</property>
<item row="0" column="0">
<widget class="QWidget" name="widget" native="true">
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_5">
- <item>
- <spacer name="horizontalSpacer_2">
+ <layout class="QGridLayout" name="gridLayout_3">
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <item row="0" column="0">
+ <layout class="QGridLayout" name="coverLayout">
+ <item row="2" column="1">
+ <widget class="QLabel" name="coverLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <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="../../resources/resources.qrc">:/images/defaultcover.png</pixmap>
+ </property>
+ <property name="scaledContents">
+ <bool>true</bool>
+ </property>
+ <property name="indent">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</property>
</spacer>
</item>
- <item>
- <widget class="QLabel" name="countLabel">
- <property name="text">
- <string>0/0</string>
+ <item row="2" column="2">
+ <spacer name="chorizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
</property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
</property>
- </widget>
+ </spacer>
+ </item>
+ <item row="3" column="1">
+ <spacer name="verticalSpacer_5">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="1">
+ <spacer name="verticalSpacer_6">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
</item>
</layout>
</item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QLabel" name="titleLabel">
- <property name="text">
- <string><h3>Title</h3></string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer_2">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <layout class="QHBoxLayout" name="progressLayout">
+ <item row="0" column="1">
+ <layout class="QVBoxLayout" name="controlLayout">
+ <item>
+ <layout class="QHBoxLayout" name="countHLayout">
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="countLabel">
+ <property name="text">
+ <string>0/0</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="cverticalSpacer_0">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
<item>
- <widget class="QLabel" name="doneTimeLabel">
+ <widget class="QLabel" name="titleLabel">
<property name="text">
- <string>00:00</string>
+ <string><h3>Title</h3></string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
- <widget class="QSlider" name="seekSlider">
+ <spacer name="cverticalSpacer_1">
<property name="orientation">
- <enum>Qt::Horizontal</enum>
+ <enum>Qt::Vertical</enum>
</property>
- </widget>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="progressLayout">
+ <item>
+ <widget class="QLabel" name="doneTimeLabel">
+ <property name="text">
+ <string>00:00</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="seekSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="allTimeLabel">
+ <property name="text">
+ <string>00:00</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
<item>
- <spacer name="seekSpacer">
+ <layout class="QHBoxLayout" name="seekLayout">
+ <item>
+ <spacer name="horizontalSpacer_5">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>10</width>
+ <height>0</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QSlider" name="seekSlider">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_4">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>10</width>
+ <height>0</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="cverticalSpacer_2">
<property name="orientation">
- <enum>Qt::Horizontal</enum>
+ <enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
- <width>40</width>
- <height>20</height>
+ <width>20</width>
+ <height>40</height>
</size>
</property>
</spacer>
</item>
<item>
- <widget class="QLabel" name="allTimeLabel">
+ <widget class="QLabel" name="artistAlbumLabel">
<property name="text">
- <string>00:00</string>
+ <string><b>Artist</b><br/>album</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
</property>
</widget>
</item>
+ <item>
+ <spacer name="cverticalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
</layout>
</item>
- <item>
- <widget class="QWidget" name="progressWidget" native="true">
- <layout class="QVBoxLayout" name="verticalLayout_3">
- <property name="spacing">
- <number>0</number>
- </property>
- <property name="margin">
- <number>0</number>
- </property>
- </layout>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer_3">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QLabel" name="artistAlbumLabel">
- <property name="text">
- <string><b>Artist</b><br/>album</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer_4">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
</layout>
</widget>
</item>
<string/>
</property>
<property name="icon">
- <iconset>
+ <iconset resource="../../resources/resources.qrc">
<normaloff>:/icons/white/library.png</normaloff>:/icons/white/library.png</iconset>
</property>
<property name="flat">
<string/>
</property>
<property name="icon">
- <iconset>
+ <iconset resource="../../resources/resources.qrc">
<normaloff>:/icons/white/playlist.png</normaloff>:/icons/white/playlist.png</iconset>
</property>
<property name="checkable">
<string/>
</property>
<property name="icon">
- <iconset>
+ <iconset resource="../../resources/resources.qrc">
<normaloff>:/icons/white/repeat_off.png</normaloff>:/icons/white/repeat_off.png</iconset>
</property>
<property name="iconSize">
<string/>
</property>
<property name="icon">
- <iconset>
+ <iconset resource="../../resources/resources.qrc">
<normaloff>:/icons/white/random_off.png</normaloff>:/icons/white/random_off.png</iconset>
</property>
<property name="iconSize">
<string/>
</property>
<property name="icon">
- <iconset>
+ <iconset resource="../../resources/resources.qrc">
<normaloff>:/icons/white/prev.png</normaloff>:/icons/white/prev.png</iconset>
</property>
<property name="flat">
<string/>
</property>
<property name="icon">
- <iconset>
+ <iconset resource="../../resources/resources.qrc">
<normaloff>:/icons/white/play.png</normaloff>:/icons/white/play.png</iconset>
</property>
<property name="flat">
<string/>
</property>
<property name="icon">
- <iconset>
+ <iconset resource="../../resources/resources.qrc">
<normaloff>:/icons/white/next.png</normaloff>:/icons/white/next.png</iconset>
</property>
<property name="flat">
<string/>
</property>
<property name="icon">
- <iconset>
+ <iconset resource="../../resources/resources.qrc">
<normaloff>:/icons/white/stop.png</normaloff>:/icons/white/stop.png</iconset>
</property>
<property name="flat">
<string/>
</property>
<property name="icon">
- <iconset>
+ <iconset resource="../../resources/resources.qrc">
<normaloff>:/icons/white/more.png</normaloff>:/icons/white/more.png</iconset>
</property>
<property name="flat">
<string/>
</property>
<property name="icon">
- <iconset>
+ <iconset resource="../../resources/resources.qrc">
<normaloff>:/icons/white/directory.png</normaloff>:/icons/white/directory.png</iconset>
</property>
<property name="flat">
</item>
</layout>
</widget>
- <resources/>
+ <resources>
+ <include location="../../resources/resources.qrc"/>
+ </resources>
<connections/>
</ui>