Commit 4c4182af authored by Urs Fleisch's avatar Urs Fleisch
Browse files

preview picture for album cover art

parent 815b7cc1
......@@ -4,7 +4,7 @@ if (HAVE_TAGLIB)
set(TAGLIBEXT_LIBRARIES taglibext)
endif (HAVE_TAGLIB)
set(kid3_SRCS filelist.cpp filelistitem.cpp frame.cpp framelist.cpp frametable.cpp genres.cpp id3form.cpp kid3.cpp main.cpp m4afile.cpp mp3file.cpp configdialog.cpp exportdialog.cpp formatconfig.cpp formatbox.cpp importdialog.cpp importselector.cpp importparser.cpp generalconfig.cpp importconfig.cpp miscconfig.cpp freedbdialog.cpp freedbconfig.cpp freedbclient.cpp rendirdialog.cpp dirlist.cpp taggedfile.cpp musicbrainzdialog.cpp musicbrainzconfig.cpp musicbrainzclient.cpp numbertracksdialog.cpp oggfile.cpp vcedit.c flacfile.cpp commandstable.cpp taglibfile.cpp importsourceconfig.cpp importsourcedialog.cpp importsourceclient.cpp discogsdialog.cpp discogsclient.cpp discogsconfig.cpp musicbrainzreleasedialog.cpp musicbrainzreleaseclient.cpp externalprocess.cpp importtrackdata.cpp stringlistedit.cpp tracktypedialog.cpp tracktypeclient.cpp filterconfig.cpp filterdialog.cpp filefilter.cpp expressionparser.cpp pictureframe.cpp formatreplacer.cpp httpclient.cpp downloaddialog.cpp)
set(kid3_SRCS filelist.cpp filelistitem.cpp frame.cpp framelist.cpp frametable.cpp genres.cpp id3form.cpp kid3.cpp main.cpp m4afile.cpp mp3file.cpp configdialog.cpp exportdialog.cpp formatconfig.cpp formatbox.cpp importdialog.cpp importselector.cpp importparser.cpp generalconfig.cpp importconfig.cpp miscconfig.cpp freedbdialog.cpp freedbconfig.cpp freedbclient.cpp rendirdialog.cpp dirlist.cpp taggedfile.cpp musicbrainzdialog.cpp musicbrainzconfig.cpp musicbrainzclient.cpp numbertracksdialog.cpp oggfile.cpp vcedit.c flacfile.cpp commandstable.cpp taglibfile.cpp importsourceconfig.cpp importsourcedialog.cpp importsourceclient.cpp discogsdialog.cpp discogsclient.cpp discogsconfig.cpp musicbrainzreleasedialog.cpp musicbrainzreleaseclient.cpp externalprocess.cpp importtrackdata.cpp stringlistedit.cpp tracktypedialog.cpp tracktypeclient.cpp filterconfig.cpp filterdialog.cpp filefilter.cpp expressionparser.cpp pictureframe.cpp formatreplacer.cpp httpclient.cpp downloaddialog.cpp picturelabel.cpp)
if (HAVE_QTDBUS)
set(kid3_SRCS ${kid3_SRCS} scriptinterface.cpp)
......
......@@ -28,14 +28,14 @@ kid3_LDADD += taglibext/libtaglibext.la
endif
# which sources should be compiled for kid3
kid3_SOURCES = filelist.cpp filelistitem.cpp frame.cpp framelist.cpp frametable.cpp genres.cpp id3form.cpp kid3.cpp main.cpp m4afile.cpp mp3file.cpp configdialog.cpp exportdialog.cpp formatconfig.cpp formatbox.cpp importdialog.cpp importselector.cpp importparser.cpp generalconfig.cpp importconfig.cpp miscconfig.cpp freedbdialog.cpp freedbconfig.cpp freedbclient.cpp rendirdialog.cpp dirlist.cpp taggedfile.cpp musicbrainzdialog.cpp musicbrainzconfig.cpp musicbrainzclient.cpp numbertracksdialog.cpp oggfile.cpp vcedit.c flacfile.cpp commandstable.cpp taglibfile.cpp importsourceconfig.cpp importsourcedialog.cpp importsourceclient.cpp discogsdialog.cpp discogsclient.cpp discogsconfig.cpp musicbrainzreleasedialog.cpp musicbrainzreleaseclient.cpp externalprocess.cpp importtrackdata.cpp stringlistedit.cpp tracktypedialog.cpp tracktypeclient.cpp scriptinterface.cpp filterconfig.cpp filterdialog.cpp filefilter.cpp expressionparser.cpp pictureframe.cpp formatreplacer.cpp httpclient.cpp downloaddialog.cpp
kid3_SOURCES = filelist.cpp filelistitem.cpp frame.cpp framelist.cpp frametable.cpp genres.cpp id3form.cpp kid3.cpp main.cpp m4afile.cpp mp3file.cpp configdialog.cpp exportdialog.cpp formatconfig.cpp formatbox.cpp importdialog.cpp importselector.cpp importparser.cpp generalconfig.cpp importconfig.cpp miscconfig.cpp freedbdialog.cpp freedbconfig.cpp freedbclient.cpp rendirdialog.cpp dirlist.cpp taggedfile.cpp musicbrainzdialog.cpp musicbrainzconfig.cpp musicbrainzclient.cpp numbertracksdialog.cpp oggfile.cpp vcedit.c flacfile.cpp commandstable.cpp taglibfile.cpp importsourceconfig.cpp importsourcedialog.cpp importsourceclient.cpp discogsdialog.cpp discogsclient.cpp discogsconfig.cpp musicbrainzreleasedialog.cpp musicbrainzreleaseclient.cpp externalprocess.cpp importtrackdata.cpp stringlistedit.cpp tracktypedialog.cpp tracktypeclient.cpp scriptinterface.cpp filterconfig.cpp filterdialog.cpp filefilter.cpp expressionparser.cpp pictureframe.cpp formatreplacer.cpp httpclient.cpp downloaddialog.cpp picturelabel.cpp
# these headers are automatically built
BUILT_SOURCES =
CLEANFILES = allsys.h allsys.h.gch
# these are the headers for your project that won't be installed
noinst_HEADERS = configdialog.h exportdialog.h filelist.h filelistitem.h formatbox.h formatconfig.h frame.h framelist.h frametable.h freedbclient.h freedbconfig.h freedbdialog.h generalconfig.h genres.h id3form.h importconfig.h importdialog.h importparser.h importselector.h kid3.h miscconfig.h m4afile.h mp3file.h rendirdialog.h dirlist.h taggedfile.h musicbrainzclient.h musicbrainzconfig.h musicbrainzdialog.h numbertracksdialog.h oggfile.hpp vcedit.h flacfile.hpp commandstable.h taglibfile.h importsourceconfig.h importsourcedialog.h importsourceclient.h discogsdialog.h discogsclient.h discogsconfig.h musicbrainzreleasedialog.h musicbrainzreleaseclient.h qtcompatmac.h dirinfo.h externalprocess.h stringlistedit.h tracktypedialog.h tracktypeclient.h scriptinterface.h filterconfig.h filterdialog.h filefilter.h expressionparser.h pictureframe.h formatreplacer.h httpclient.h downloaddialog.h
noinst_HEADERS = configdialog.h exportdialog.h filelist.h filelistitem.h formatbox.h formatconfig.h frame.h framelist.h frametable.h freedbclient.h freedbconfig.h freedbdialog.h generalconfig.h genres.h id3form.h importconfig.h importdialog.h importparser.h importselector.h kid3.h miscconfig.h m4afile.h mp3file.h rendirdialog.h dirlist.h taggedfile.h musicbrainzclient.h musicbrainzconfig.h musicbrainzdialog.h numbertracksdialog.h oggfile.hpp vcedit.h flacfile.hpp commandstable.h taglibfile.h importsourceconfig.h importsourcedialog.h importsourceclient.h discogsdialog.h discogsclient.h discogsconfig.h musicbrainzreleasedialog.h musicbrainzreleaseclient.h qtcompatmac.h dirinfo.h externalprocess.h stringlistedit.h tracktypedialog.h tracktypeclient.h scriptinterface.h filterconfig.h filterdialog.h filefilter.h expressionparser.h pictureframe.h formatreplacer.h httpclient.h downloaddialog.h picturelabel.h
# additional files in distribution
EXTRA_DIST = kid3.desktop kid3ui.rc hi16-app-kid3.png hi32-app-kid3.png hi48-app-kid3.png hisc-app-kid3.svgz de_qt.po ru_qt.po es_qt.po fr_qt.po
......
......@@ -280,6 +280,10 @@ Id3Form::Id3Form(QWidget* parent)
QPushButton* deleteFramesPushButton =
new QPushButton(i18n("Delete"), m_idV2GroupBox);
buttonsV2VBoxLayout->addWidget(deleteFramesPushButton);
m_pictureLabel = new PictureLabel(this);
buttonsV2VBoxLayout->addWidget(m_pictureLabel);
buttonsV2VBoxLayout->addItem(
new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));
......@@ -385,7 +389,11 @@ Id3Form::Id3Form(QWidget* parent)
new QPushButton(i18n("Add"), buttonsV2VBox);
QPushButton* deleteFramesPushButton =
new QPushButton(i18n("Delete"), buttonsV2VBox);
new QWidget(buttonsV2VBox);
m_pictureLabel = new PictureLabel(buttonsV2VBox);
QWidget* expandWidget = new QWidget(buttonsV2VBox);
expandWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
rightHalfLayout->insertStretch(-1);
scrollView->addChild(m_rightHalfVBox);
......@@ -811,6 +819,20 @@ void Id3Form::hideV2(bool hide)
}
}
/**
* Hide or show picture.
*
* @param hide true to hide, false to show
*/
void Id3Form::hidePicture(bool hide)
{
if (hide) {
m_pictureLabel->hide();
} else {
m_pictureLabel->show();
}
}
/**
* Set focus on filename controls.
*/
......
......@@ -33,6 +33,7 @@
#include <qlineedit.h>
#include "filelist.h"
#include "dirlist.h"
#include "picturelabel.h"
#include "taggedfile.h"
#include "qtcompatmac.h"
......@@ -112,6 +113,13 @@ public:
*/
void hideV2(bool hide);
/**
* Hide or show picture.
*
* @param hide true to hide, false to show
*/
void hidePicture(bool hide);
/**
* Save the local settings to the configuration.
*/
......@@ -168,6 +176,12 @@ public:
*/
void markChangedFilename(bool en);
/**
* Set preview picture data.
* @param data picture data, 0 if no picture is available
*/
void setPictureData(const QByteArray* data) { m_pictureLabel->setData(data); }
/**
* Set details info text.
*
......@@ -474,6 +488,7 @@ private:
QPushButton* m_fnV1Button;
QPushButton* m_id3V2PushButton;
QWidget* m_rightHalfVBox;
PictureLabel* m_pictureLabel;
private slots:
/**
......
......@@ -449,6 +449,10 @@ void Kid3App::initActions()
i18n("Hide Tag &2"), this,
SLOT(slotSettingsShowHideV2()), actionCollection(),
"hide_v2");
KCM_KActionVar(m_settingsShowHidePicture,
i18n("Hide &Picture"), this,
SLOT(slotSettingsShowHidePicture()), actionCollection(),
"hide_picture");
KCM_KActionShortcutIcon(editPreviousFile, KShortcut("Alt+Up"), KCM_ICON_go_previous,
i18n("&Previous File"), m_view,
......@@ -734,6 +738,13 @@ void Kid3App::initActions()
connect(m_settingsShowHideV2, QCM_SIGNAL_triggered,
this, SLOT(slotSettingsShowHideV2()));
}
m_settingsShowHidePicture = new QAction(this);
if (m_settingsShowHidePicture) {
m_settingsShowHidePicture->setStatusTip(i18n("Hide Picture"));
m_settingsShowHidePicture->QCM_setMenuText(i18n("Hide &Picture"));
connect(m_settingsShowHidePicture, QCM_SIGNAL_triggered,
this, SLOT(slotSettingsShowHidePicture()));
}
QAction* settingsConfigure = new QAction(this);
if (settingsConfigure) {
settingsConfigure->setStatusTip(i18n("Configure Kid3"));
......@@ -800,6 +811,7 @@ void Kid3App::initActions()
QCM_addAction(settingsMenu, m_settingsShowHideV1);
QCM_addAction(settingsMenu, m_settingsShowHideV2);
QCM_addAction(settingsMenu, m_settingsShowHidePicture);
settingsMenu->QCM_addSeparator();
QCM_addAction(settingsMenu, settingsConfigure);
......@@ -995,6 +1007,7 @@ void Kid3App::readOptions()
#endif
updateHideV1();
updateHideV2();
updateHidePicture();
#ifdef CONFIG_USE_KDE
setAutoSaveSettings();
#if KDE_VERSION >= 0x035c00
......@@ -2097,6 +2110,31 @@ void Kid3App::updateHideV2()
#endif
}
/**
* Show or hide the picture according to the settings and
* set the menu entries appropriately.
*/
void Kid3App::updateHidePicture()
{
m_view->hidePicture(s_miscCfg.m_hidePicture);
if (s_miscCfg.m_hidePicture) {
#ifdef CONFIG_USE_KDE
m_settingsShowHidePicture->setText(i18n("Show &Picture"));
#else
m_settingsShowHidePicture->setStatusTip(i18n("Show Picture"));
m_settingsShowHidePicture->QCM_setMenuText(i18n("Show &Picture"));
#endif
} else {
#ifdef CONFIG_USE_KDE
m_settingsShowHidePicture->setText(i18n("Hide &Picture"));
#else
m_settingsShowHidePicture->setStatusTip(i18n("Hide Picture"));
m_settingsShowHidePicture->QCM_setMenuText(i18n("Hide &Picture"));
#endif
}
}
/**
* Show or hide ID3v1.1 controls.
*/
......@@ -2115,6 +2153,24 @@ void Kid3App::slotSettingsShowHideV2()
updateHideV2();
}
/**
* Show or hide picture.
*/
void Kid3App::slotSettingsShowHidePicture()
{
s_miscCfg.m_hidePicture = !s_miscCfg.m_hidePicture;
updateHidePicture();
#if QT_VERSION >= 0x040000
// In Qt3 the picture is displayed too small if Kid3 is started with picture
// hidden, and then "Show Picture" is triggered while a file with a picture
// is selected. Thus updating the controls is only done for Qt4, in Qt3 the
// file has to be selected again for the picture to be shown.
if (!s_miscCfg.m_hidePicture) {
updateGuiControls();
}
#endif
}
/**
* Preferences.
*/
......@@ -2840,6 +2896,17 @@ void Kid3App::updateGuiControls()
single_v2_file->getChangedFramesV2());
m_view->markChangedFilename(single_v2_file->isFilenameChanged());
}
if (!s_miscCfg.m_hidePicture) {
FrameCollection::const_iterator it =
m_view->frameTableV2()->frames().find(Frame(Frame::FT_Picture, "", "", -1));
if (it == m_view->frameTableV2()->frames().end()) {
m_view->setPictureData(0);
} else {
QByteArray data;
m_view->setPictureData(PictureFrame::getData(*it, data) ? &data : 0);
}
}
}
else {
m_view->setFilenameEditEnabled(false);
......@@ -2855,6 +2922,9 @@ void Kid3App::updateGuiControls()
m_view->frameTableV2()->markChangedFrames(0);
m_view->markChangedFilename(false);
}
if (!s_miscCfg.m_hidePicture) {
m_view->setPictureData(0);
}
}
m_view->frameTableV1()->setAllCheckBoxes(num_files_selected == 1);
m_view->frameTableV1()->framesToTable();
......
......@@ -535,6 +535,11 @@ public slots:
*/
void slotSettingsShowHideV2();
/**
* Show or hide picture.
*/
void slotSettingsShowHidePicture();
/**
* Preferences.
*/
......@@ -709,6 +714,12 @@ private:
*/
void updateHideV2();
/**
* Show or hide the picture according to the settings and
* set the menu entries appropriately.
*/
void updateHidePicture();
/**
* Set filter state.
*
......@@ -757,10 +768,12 @@ private:
KToggleAction* m_viewStatusBar;
KAction* m_settingsShowHideV1;
KAction* m_settingsShowHideV2;
KAction* m_settingsShowHidePicture;
#else
Kid3Settings* m_config;
QAction* m_settingsShowHideV1;
QAction* m_settingsShowHideV2;
QAction* m_settingsShowHidePicture;
static BrowserDialog* s_helpBrowser;
#endif
......
......@@ -49,9 +49,9 @@ contains(CFG_LIBS, -ltag) {
POST_TARGETDEPS += $$TAGLIBEXT_LIB
}
SOURCES = filelist.cpp filelistitem.cpp framelist.cpp frame.cpp frametable.cpp genres.cpp id3form.cpp kid3.cpp main.cpp m4afile.cpp mp3file.cpp configdialog.cpp exportdialog.cpp formatconfig.cpp formatbox.cpp importdialog.cpp importselector.cpp importparser.cpp generalconfig.cpp importconfig.cpp miscconfig.cpp freedbdialog.cpp freedbconfig.cpp freedbclient.cpp rendirdialog.cpp dirlist.cpp taggedfile.cpp musicbrainzdialog.cpp musicbrainzconfig.cpp musicbrainzclient.cpp numbertracksdialog.cpp oggfile.cpp vcedit.c flacfile.cpp commandstable.cpp taglibfile.cpp importsourceconfig.cpp importsourcedialog.cpp importsourceclient.cpp discogsdialog.cpp discogsclient.cpp discogsconfig.cpp musicbrainzreleasedialog.cpp musicbrainzreleaseclient.cpp externalprocess.cpp importtrackdata.cpp stringlistedit.cpp tracktypedialog.cpp tracktypeclient.cpp filterconfig.cpp filterdialog.cpp filefilter.cpp expressionparser.cpp pictureframe.cpp formatreplacer.cpp httpclient.cpp downloaddialog.cpp
SOURCES = filelist.cpp filelistitem.cpp framelist.cpp frame.cpp frametable.cpp genres.cpp id3form.cpp kid3.cpp main.cpp m4afile.cpp mp3file.cpp configdialog.cpp exportdialog.cpp formatconfig.cpp formatbox.cpp importdialog.cpp importselector.cpp importparser.cpp generalconfig.cpp importconfig.cpp miscconfig.cpp freedbdialog.cpp freedbconfig.cpp freedbclient.cpp rendirdialog.cpp dirlist.cpp taggedfile.cpp musicbrainzdialog.cpp musicbrainzconfig.cpp musicbrainzclient.cpp numbertracksdialog.cpp oggfile.cpp vcedit.c flacfile.cpp commandstable.cpp taglibfile.cpp importsourceconfig.cpp importsourcedialog.cpp importsourceclient.cpp discogsdialog.cpp discogsclient.cpp discogsconfig.cpp musicbrainzreleasedialog.cpp musicbrainzreleaseclient.cpp externalprocess.cpp importtrackdata.cpp stringlistedit.cpp tracktypedialog.cpp tracktypeclient.cpp filterconfig.cpp filterdialog.cpp filefilter.cpp expressionparser.cpp pictureframe.cpp formatreplacer.cpp httpclient.cpp downloaddialog.cpp picturelabel.cpp
HEADERS = configdialog.h exportdialog.h filelist.h filelistitem.h formatbox.h formatconfig.h frame.h framelist.h frametable.h freedbclient.h freedbconfig.h freedbdialog.h generalconfig.h genres.h id3form.h importconfig.h importdialog.h importparser.h importselector.h kid3.h miscconfig.h m4afile.h mp3file.h rendirdialog.h dirlist.h taggedfile.h musicbrainzclient.h musicbrainzconfig.h musicbrainzdialog.h numbertracksdialog.h oggfile.hpp vcedit.h flacfile.hpp commandstable.h taglibfile.h importsourceconfig.h importsourcedialog.h importsourceclient.h discogsdialog.h discogsclient.h discogsconfig.h musicbrainzreleasedialog.h musicbrainzreleaseclient.h qtcompatmac.h dirinfo.h externalprocess.h stringlistedit.h tracktypedialog.h tracktypeclient.h filterconfig.h filterdialog.h filefilter.h expressionparser.h pictureframe.h formatreplacer.h httpclient.h downloaddialog.h
HEADERS = configdialog.h exportdialog.h filelist.h filelistitem.h formatbox.h formatconfig.h frame.h framelist.h frametable.h freedbclient.h freedbconfig.h freedbdialog.h generalconfig.h genres.h id3form.h importconfig.h importdialog.h importparser.h importselector.h kid3.h miscconfig.h m4afile.h mp3file.h rendirdialog.h dirlist.h taggedfile.h musicbrainzclient.h musicbrainzconfig.h musicbrainzdialog.h numbertracksdialog.h oggfile.hpp vcedit.h flacfile.hpp commandstable.h taglibfile.h importsourceconfig.h importsourcedialog.h importsourceclient.h discogsdialog.h discogsclient.h discogsconfig.h musicbrainzreleasedialog.h musicbrainzreleaseclient.h qtcompatmac.h dirinfo.h externalprocess.h stringlistedit.h tracktypedialog.h tracktypeclient.h filterconfig.h filterdialog.h filefilter.h expressionparser.h pictureframe.h formatreplacer.h httpclient.h downloaddialog.h picturelabel.h
unix:program.path = $$CFG_BINDIR $$CFG_DATAROOTDIR/applications $$CFG_DATAROOTDIR/icons/hicolor/16x16/apps $$CFG_DATAROOTDIR/icons/hicolor/32x32/apps $$CFG_DATAROOTDIR/icons/hicolor/48x48/apps $$CFG_DATAROOTDIR/icons/hicolor/scalable/apps
win32 {
......
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="kid3" version="7">
<kpartgui name="kid3" version="8">
<MenuBar>
<Menu name="file"><text>&amp;File</text>
<Action name="open_directory" append="open_merge"/>
......@@ -28,6 +28,7 @@
<Menu name="settings"><text>&amp;Settings</text>
<Action name="hide_v1" append="show_merge"/>
<Action name="hide_v2" append="show_merge"/>
<Action name="hide_picture" append="show_merge"/>
<DefineGroup name="show_merge"/>
</Menu>
</MenuBar>
......
......@@ -111,6 +111,7 @@ MiscConfig::MiscConfig(const QString& group) :
m_renDirSrc(0),
m_hideV1(false),
m_hideV2(false),
m_hidePicture(false),
m_id3v2Version(ID3v2_3_0),
m_textEncodingV1(""),
m_textEncoding(TE_ISO8859_1),
......@@ -159,6 +160,7 @@ void MiscConfig::writeToConfig(
cfg.writeEntry("CustomGenres", m_customGenres);
cfg.writeEntry("HideV1", m_hideV1);
cfg.writeEntry("HideV2", m_hideV2);
cfg.writeEntry("HidePicture", m_hidePicture);
cfg.writeEntry("ID3v2Version", m_id3v2Version);
cfg.writeEntry("TextEncodingV1", m_textEncodingV1);
cfg.writeEntry("TextEncoding", m_textEncoding);
......@@ -218,6 +220,7 @@ void MiscConfig::writeToConfig(
config->QCM_writeEntry("/CustomGenres", m_customGenres);
config->QCM_writeEntry("/HideV1", m_hideV1);
config->QCM_writeEntry("/HideV2", m_hideV2);
config->QCM_writeEntry("/HidePicture", m_hidePicture);
config->QCM_writeEntry("/ID3v2Version", m_id3v2Version);
config->QCM_writeEntry("/TextEncodingV1", m_textEncodingV1);
config->QCM_writeEntry("/TextEncoding", m_textEncoding);
......@@ -291,6 +294,7 @@ void MiscConfig::readFromConfig(
m_customGenres = cfg.KCM_readListEntry("CustomGenres");
m_hideV1 = cfg.KCM_readBoolEntry("HideV1", m_hideV1);
m_hideV2 = cfg.KCM_readBoolEntry("HideV2", m_hideV2);
m_hidePicture = cfg.KCM_readBoolEntry("HidePicture", m_hidePicture);
m_id3v2Version = cfg.KCM_readNumEntry("ID3v2Version", static_cast<int>(ID3v2_3_0));
m_textEncodingV1 = cfg.readEntry("TextEncodingV1", "");
m_textEncoding = cfg.KCM_readNumEntry("TextEncoding", static_cast<int>(TE_ISO8859_1));
......@@ -351,6 +355,7 @@ void MiscConfig::readFromConfig(
m_customGenres = config->QCM_readListEntry("/CustomGenres");
m_hideV1 = config->QCM_readBoolEntry("/HideV1", m_hideV1);
m_hideV2 = config->QCM_readBoolEntry("/HideV2", m_hideV2);
m_hidePicture = config->QCM_readBoolEntry("/HidePicture", m_hidePicture);
m_id3v2Version = config->QCM_readNumEntry("/ID3v2Version", ID3v2_3_0);
m_textEncodingV1 = config->QCM_readEntry("/TextEncodingV1", "");
m_textEncoding = config->QCM_readNumEntry("/TextEncoding", TE_ISO8859_1);
......
......@@ -203,6 +203,8 @@ public:
bool m_hideV1;
/** true to hide ID3v2.3 controls */
bool m_hideV2;
/** true to hide picture preview */
bool m_hidePicture;
/** version used for new ID3v2 tags */
int m_id3v2Version;
/** text encoding used for new ID3v1 tags */
......
/**
* \file picturelabel.cpp
* Label for picture preview.
*
* \b Project: Kid3
* \author Urs Fleisch
* \date 04 Jan 2009
*/
#include "picturelabel.h"
#include "qtcompatmac.h"
#if QT_VERSION >= 0x040000
#include <QHash>
#else
#include <qimage.h>
/**
* ELF hash function.
*
* @param key bytes for which hash is calculated
*
* @return hash value for key.
*/
static uint qHash(const QByteArray& key)
{
uint hash = 0, x = 0;
for (uint i = 0; i < key.size(); ++i) {
hash = (hash << 4) + key[i];
if ((x = hash & 0xF0000000L) != 0) {
hash ^= x >> 24;
}
hash &= ~x;
}
return hash;
}
#endif
/**
* Constructor.
*
* @param parent parent widget
*/
PictureLabel::PictureLabel(QWidget* parent) : QLabel(parent), m_pixmapHash(0)
{
#if QT_VERSION >= 0x040000
setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
setWordWrap(true);
#else
setAlignment(Qt::AlignHCenter | Qt::AlignVCenter | Qt::WordBreak);
#endif
clearPicture();
}
/**
* Destructor.
*/
PictureLabel::~PictureLabel()
{
}
/**
* Get preferred height for a given width.
* @return height.
*/
int PictureLabel::heightForWidth(int w) const
{
return w;
}
/**
* Set picture.
*/
void PictureLabel::setPicture()
{
setMargin(0);
setPixmap(m_pixmap);
}
/**
* Clear picture.
*/
void PictureLabel::clearPicture()
{
setMargin(6);
setText(i18n("Drag album\nartwork\nhere"));
}
/**
* Set picture data.
*
* @param data picture data, 0 if no picture is available
*/
void PictureLabel::setData(const QByteArray* data)
{
if (data && !data->isEmpty()) {
uint hash = qHash(*data);
if (hash != m_pixmapHash) {
// creating new pixmap
#if QT_VERSION >= 0x040000
if (m_pixmap.loadFromData(*data)) {
m_pixmap = m_pixmap.scaled(width(), height(), Qt::KeepAspectRatio);
m_pixmapHash = hash;
setPicture();
} else {
clearPicture();
}
#else
QImage image;
if (image.loadFromData(*data)) {
m_pixmap.convertFromImage(image.scale(width(), height(),
QImage::ScaleMin));
m_pixmapHash = hash;
setPicture();
} else {
clearPicture();
}
#endif
} else {
if (!pixmap()) {
// using cached pixmap
setPicture();
}
// else keeping current pixmap
}
} else {
clearPicture();
}
}
/**
* \file picturelabel.h
* Label for picture preview.
*
* \b Project: Kid3
* \author Urs Fleisch
* \date 04 Jan 2009
*/
#ifndef PICTURELABEL_H
#define PICTURELABEL_H
#include <qlabel.h>
#include <qpixmap.h>
#if QT_VERSION >= 0x040000
#include <QByteArray>
#else
#include <qcstring.h>
#endif
/**
* Label for picture preview.
*/
class PictureLabel : public QLabel {
public:
/**
* Constructor.
*
* @param parent parent widget
*/
PictureLabel(QWidget* parent);
/**
* Destructor.
*/
virtual ~PictureLabel();
/**
* Get preferred height for a given width.
* @return height.
*/
virtual int heightForWidth(int w) const;
/**
* Set picture data.
*
* @param data picture data, 0 if no picture is available
*/
void setData(const QByteArray* data);
private:
/**
* Set picture.
*/
void setPicture();
/**
* Clear picture.
*/
void clearPicture();
QPixmap m_pixmap;
uint m_pixmapHash;
};
#endif // PICTURELABEL_H
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