Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Nate Graham
Kid3
Commits
4aa23b47
Commit
4aa23b47
authored
Jan 27, 2009
by
Urs Fleisch
Browse files
Browse Cover Art dialog
parent
4c4182af
Changes
19
Hide whitespace changes
Inline
Side-by-side
kid3/kid3/CMakeLists.txt
View file @
4aa23b47
...
...
@@ -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 picturelabel.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
browsecoverartdialog.cpp configtable.cpp
)
if
(
HAVE_QTDBUS
)
set
(
kid3_SRCS
${
kid3_SRCS
}
scriptinterface.cpp
)
...
...
kid3/kid3/Makefile.am
View file @
4aa23b47
...
...
@@ -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 picturelabel.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
browsecoverartdialog.cpp configtable.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 picturelabel.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
browsecoverartdialog.h configtable.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
...
...
kid3/kid3/browsecoverartdialog.cpp
0 → 100644
View file @
4aa23b47
/**
* \file browsecoverartdialog.cpp
* Browse cover art dialog.
*
* \b Project: Kid3
* \author Urs Fleisch
* \date 11-Jan-2009
*
* Copyright (C) 2009 Urs Fleisch
*
* This file is part of Kid3.
*
* Kid3 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.
*
* Kid3 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, see <http://www.gnu.org/licenses/>.
*/
#include "browsecoverartdialog.h"
#include "kid3.h"
#include "externalprocess.h"
#include "configtable.h"
#include <qlayout.h>
#include <qpushbutton.h>
#include <qtextedit.h>
#include <qstring.h>
#include <qlineedit.h>
#include <qcombobox.h>
#include <qtooltip.h>
#include <qmessagebox.h>
#include <qregexp.h>
#include <qurl.h>
#include "qtcompatmac.h"
#if QT_VERSION >= 0x040000
#include <QGroupBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#else
#include <qgroupbox.h>
#endif
/**
* Get help text for supported format codes.
*
* @return help text.
*/
static
QString
getToolTip
()
{
QString
str
=
"<table>
\n
"
;
str
+=
FrameFormatReplacer
::
getToolTip
(
true
);
str
+=
"<tr><td>%ua...</td><td>%u{artist}...</td><td>"
;
str
+=
QCM_translate
(
I18N_NOOP
(
"Encode as URL"
));
str
+=
"</td></tr>
\n
"
;
str
+=
"</table>
\n
"
;
return
str
;
}
/**
* Constructor.
*
* @param parent parent widget
*/
BrowseCoverArtDialog
::
BrowseCoverArtDialog
(
QWidget
*
parent
)
:
QDialog
(
parent
),
m_process
(
0
)
{
setModal
(
true
);
QCM_setWindowTitle
(
i18n
(
"Browse Cover Art"
));
QVBoxLayout
*
vlayout
=
new
QVBoxLayout
(
this
);
if
(
vlayout
)
{
vlayout
->
setMargin
(
6
);
vlayout
->
setSpacing
(
6
);
m_edit
=
new
QTextEdit
(
this
);
if
(
m_edit
)
{
m_edit
->
setReadOnly
(
true
);
vlayout
->
addWidget
(
m_edit
);
}
#if QT_VERSION >= 0x040000
QGroupBox
*
artistAlbumBox
=
new
QGroupBox
(
i18n
(
"&Artist/Album"
),
this
);
#else
QGroupBox
*
artistAlbumBox
=
new
QGroupBox
(
2
,
Qt
::
Horizontal
,
i18n
(
"&Artist/Album"
),
this
);
#endif
if
(
artistAlbumBox
)
{
m_artistLineEdit
=
new
QLineEdit
(
artistAlbumBox
);
m_albumLineEdit
=
new
QLineEdit
(
artistAlbumBox
);
#if QT_VERSION >= 0x040000
QHBoxLayout
*
hbox
=
new
QHBoxLayout
;
hbox
->
setMargin
(
2
);
hbox
->
addWidget
(
m_artistLineEdit
);
hbox
->
addWidget
(
m_albumLineEdit
);
artistAlbumBox
->
setLayout
(
hbox
);
#endif
vlayout
->
addWidget
(
artistAlbumBox
);
connect
(
m_artistLineEdit
,
SIGNAL
(
returnPressed
()),
this
,
SLOT
(
showPreview
()));
connect
(
m_albumLineEdit
,
SIGNAL
(
returnPressed
()),
this
,
SLOT
(
showPreview
()));
}
#if QT_VERSION >= 0x040000
QGroupBox
*
srcbox
=
new
QGroupBox
(
i18n
(
"&Source"
),
this
);
#else
QGroupBox
*
srcbox
=
new
QGroupBox
(
2
,
Qt
::
Vertical
,
i18n
(
"&Source"
),
this
);
#endif
if
(
srcbox
)
{
m_sourceComboBox
=
new
QComboBox
(
srcbox
);
m_sourceComboBox
->
setEditable
(
true
);
m_urlLineEdit
=
new
QLineEdit
(
srcbox
);
QCM_setToolTip
(
m_urlLineEdit
,
getToolTip
());
#if QT_VERSION >= 0x040000
QVBoxLayout
*
vbox
=
new
QVBoxLayout
;
vbox
->
setMargin
(
2
);
vbox
->
addWidget
(
m_sourceComboBox
);
vbox
->
addWidget
(
m_urlLineEdit
);
srcbox
->
setLayout
(
vbox
);
#endif
vlayout
->
addWidget
(
srcbox
);
connect
(
m_sourceComboBox
,
SIGNAL
(
activated
(
int
)),
this
,
SLOT
(
setSourceLineEdit
(
int
)));
connect
(
m_urlLineEdit
,
SIGNAL
(
returnPressed
()),
this
,
SLOT
(
showPreview
()));
}
#if QT_VERSION >= 0x040000
QGroupBox
*
tabbox
=
new
QGroupBox
(
i18n
(
"&URL extraction"
),
this
);
#else
QGroupBox
*
tabbox
=
new
QGroupBox
(
1
,
Qt
::
Vertical
,
i18n
(
"&URL extraction"
),
this
);
#endif
if
(
tabbox
)
{
m_matchUrlTable
=
new
ConfigTable
(
QStringList
()
<<
i18n
(
"Match"
)
<<
i18n
(
"Picture URL"
),
tabbox
);
#if QT_VERSION >= 0x040000
QVBoxLayout
*
tablayout
=
new
QVBoxLayout
;
tablayout
->
setMargin
(
2
);
tablayout
->
addWidget
(
m_matchUrlTable
);
tabbox
->
setLayout
(
tablayout
);
#endif
vlayout
->
addWidget
(
tabbox
);
}
QHBoxLayout
*
hlayout
=
new
QHBoxLayout
;
if
(
hlayout
)
{
hlayout
->
setSpacing
(
6
);
QPushButton
*
helpButton
=
new
QPushButton
(
i18n
(
"&Help"
),
this
);
if
(
helpButton
)
{
helpButton
->
setAutoDefault
(
false
);
hlayout
->
addWidget
(
helpButton
);
connect
(
helpButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
showHelp
()));
}
QPushButton
*
saveButton
=
new
QPushButton
(
i18n
(
"&Save Settings"
),
this
);
if
(
saveButton
)
{
saveButton
->
setAutoDefault
(
false
);
hlayout
->
addWidget
(
saveButton
);
connect
(
saveButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
saveConfig
()));
}
QSpacerItem
*
hspacer
=
new
QSpacerItem
(
16
,
0
,
QSizePolicy
::
Expanding
,
QSizePolicy
::
Minimum
);
hlayout
->
addItem
(
hspacer
);
QPushButton
*
browseButton
=
new
QPushButton
(
i18n
(
"&Browse"
),
this
);
QPushButton
*
cancelButton
=
new
QPushButton
(
i18n
(
"&Cancel"
),
this
);
if
(
browseButton
&&
cancelButton
)
{
browseButton
->
setAutoDefault
(
false
);
cancelButton
->
setAutoDefault
(
false
);
hlayout
->
addWidget
(
browseButton
);
hlayout
->
addWidget
(
cancelButton
);
connect
(
browseButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
accept
()));
connect
(
cancelButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
reject
()));
}
vlayout
->
addLayout
(
hlayout
);
}
}
}
/**
* Destructor.
*/
BrowseCoverArtDialog
::~
BrowseCoverArtDialog
()
{
delete
m_process
;
}
/**
* Set the format lineedits to the format selected in the combo box.
*
* @param index current index of the combo box
*/
void
BrowseCoverArtDialog
::
setSourceLineEdit
(
int
index
)
{
if
(
index
<
static_cast
<
int
>
(
m_urls
.
size
()))
{
m_urlLineEdit
->
setText
(
m_urls
[
index
]);
}
else
{
m_urlLineEdit
->
clear
();
}
showPreview
();
}
/**
* Show browse command as preview.
*/
void
BrowseCoverArtDialog
::
showPreview
()
{
m_frames
.
setArtist
(
m_artistLineEdit
->
text
());
m_frames
.
setAlbum
(
m_albumLineEdit
->
text
());
FrameFormatReplacer
fmt
(
m_frames
,
m_urlLineEdit
->
text
());
fmt
.
replaceEscapedChars
();
fmt
.
replacePercentCodes
(
FormatReplacer
::
FSF_SupportUrlEncode
);
m_url
=
fmt
.
getString
();
QString
txt
(
"<p><b>"
);
txt
+=
i18n
(
"Click Browse to start"
);
txt
+=
"</b></p><p><tt>"
;
txt
+=
Kid3App
::
s_miscCfg
.
m_browser
;
txt
+=
" "
;
txt
+=
m_url
;
txt
+=
"</tt></p><p><b>"
;
txt
+=
i18n
(
"Then drag the picture from the browser to Kid3."
);
txt
+=
"</b></p>"
;
m_edit
->
clear
();
m_edit
->
append
(
txt
);
}
/**
* Set frames for which picture has to be found.
*
* @param frames track data
*/
void
BrowseCoverArtDialog
::
setFrames
(
const
FrameCollection
&
frames
)
{
m_frames
=
frames
;
m_artistLineEdit
->
setText
(
m_frames
.
getArtist
());
m_albumLineEdit
->
setText
(
m_frames
.
getAlbum
());
showPreview
();
}
/**
* Set the source combo box and line edits from the configuration.
*/
void
BrowseCoverArtDialog
::
setSourceFromConfig
()
{
m_urls
=
Kid3App
::
s_genCfg
.
m_pictureSourceUrls
;
m_sourceComboBox
->
clear
();
m_sourceComboBox
->
QCM_addItems
(
Kid3App
::
s_genCfg
.
m_pictureSourceNames
);
m_sourceComboBox
->
QCM_setCurrentIndex
(
Kid3App
::
s_genCfg
.
m_pictureSourceIdx
);
setSourceLineEdit
(
Kid3App
::
s_genCfg
.
m_pictureSourceIdx
);
}
/**
* Read the local settings from the configuration.
*/
void
BrowseCoverArtDialog
::
readConfig
()
{
setSourceFromConfig
();
m_matchUrlTable
->
fromMap
(
Kid3App
::
s_genCfg
.
m_matchPictureUrlMap
);
if
(
Kid3App
::
s_genCfg
.
m_browseCoverArtWindowWidth
>
0
&&
Kid3App
::
s_genCfg
.
m_browseCoverArtWindowHeight
>
0
)
{
resize
(
Kid3App
::
s_genCfg
.
m_browseCoverArtWindowWidth
,
Kid3App
::
s_genCfg
.
m_browseCoverArtWindowHeight
);
}
}
/**
* Save the local settings to the configuration.
*/
void
BrowseCoverArtDialog
::
saveConfig
()
{
Kid3App
::
s_genCfg
.
m_pictureSourceIdx
=
m_sourceComboBox
->
QCM_currentIndex
();
if
(
Kid3App
::
s_genCfg
.
m_pictureSourceIdx
<
static_cast
<
int
>
(
Kid3App
::
s_genCfg
.
m_pictureSourceNames
.
size
()))
{
Kid3App
::
s_genCfg
.
m_pictureSourceNames
[
Kid3App
::
s_genCfg
.
m_pictureSourceIdx
]
=
m_sourceComboBox
->
currentText
();
Kid3App
::
s_genCfg
.
m_pictureSourceUrls
[
Kid3App
::
s_genCfg
.
m_pictureSourceIdx
]
=
m_urlLineEdit
->
text
();
}
else
{
Kid3App
::
s_genCfg
.
m_pictureSourceIdx
=
Kid3App
::
s_genCfg
.
m_pictureSourceNames
.
size
();
Kid3App
::
s_genCfg
.
m_pictureSourceNames
.
append
(
m_sourceComboBox
->
currentText
());
Kid3App
::
s_genCfg
.
m_pictureSourceUrls
.
append
(
m_urlLineEdit
->
text
());
}
m_matchUrlTable
->
toMap
(
Kid3App
::
s_genCfg
.
m_matchPictureUrlMap
);
Kid3App
::
s_genCfg
.
m_browseCoverArtWindowWidth
=
size
().
width
();
Kid3App
::
s_genCfg
.
m_browseCoverArtWindowHeight
=
size
().
height
();
setSourceFromConfig
();
}
/**
* Show help.
*/
void
BrowseCoverArtDialog
::
showHelp
()
{
Kid3App
::
displayHelp
(
"browse_pictures"
);
}
/**
* Hide modal dialog, start browse command.
*/
void
BrowseCoverArtDialog
::
accept
()
{
if
(
!
m_process
)
{
m_process
=
new
ExternalProcess
(
this
);
}
if
(
m_process
)
{
m_process
->
launchCommand
(
i18n
(
"Browse Cover Art"
),
QStringList
()
<<
Kid3App
::
s_miscCfg
.
m_browser
<<
m_url
);
}
QDialog
::
accept
();
}
/**
* Get the URL of an image file.
* The input URL is transformed using the match picture URL table to
* get the URL of an image file.
*
* @param url URL from image drag
*
* @return URL of image file, empty if no image URL found.
*/
QString
BrowseCoverArtDialog
::
getImageUrl
(
const
QString
&
url
)
{
QString
imgurl
;
if
(
url
.
startsWith
(
"http://"
))
{
if
(
url
.
endsWith
(
".jpg"
,
QCM_CaseInsensitive
)
||
url
.
endsWith
(
".jpeg"
,
QCM_CaseInsensitive
)
||
url
.
endsWith
(
".png"
,
QCM_CaseInsensitive
))
{
imgurl
=
url
;
}
else
{
for
(
QMap
<
QString
,
QString
>::
ConstIterator
it
=
Kid3App
::
s_genCfg
.
m_matchPictureUrlMap
.
begin
();
it
!=
Kid3App
::
s_genCfg
.
m_matchPictureUrlMap
.
end
();
++
it
)
{
QRegExp
re
(
it
.
key
());
if
(
re
.
exactMatch
(
url
))
{
QString
pictureUrl
(
url
);
imgurl
=
url
;
imgurl
.
replace
(
re
,
*
it
);
if
(
imgurl
.
QCM_indexOf
(
"%25"
)
!=
-
1
)
{
// double URL encoded: first decode
QCM_QUrl_decode
(
imgurl
);
}
if
(
imgurl
.
QCM_indexOf
(
"%2F"
)
!=
-
1
)
{
// URL encoded: decode
QCM_QUrl_decode
(
imgurl
);
}
break
;
}
}
}
}
return
imgurl
;
}
kid3/kid3/browsecoverartdialog.h
0 → 100644
View file @
4aa23b47
/**
* \file browsecoverartdialog.h
* Browse cover art dialog.
*
* \b Project: Kid3
* \author Urs Fleisch
* \date 11-Jan-2009
*
* Copyright (C) 2009 Urs Fleisch
*
* This file is part of Kid3.
*
* Kid3 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.
*
* Kid3 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef BROWSECOVERARTDIALOG_H
#define BROWSECOVERARTDIALOG_H
#include <qdialog.h>
#include <qstringlist.h>
#include "frame.h"
class
QTextEdit
;
class
QLineEdit
;
class
QComboBox
;
class
ExternalProcess
;
class
ConfigTable
;
/**
* Browse cover art dialog.
*/
class
BrowseCoverArtDialog
:
public
QDialog
{
Q_OBJECT
public:
/**
* Constructor.
*
* @param parent parent widget
*/
BrowseCoverArtDialog
(
QWidget
*
parent
);
/**
* Destructor.
*/
virtual
~
BrowseCoverArtDialog
();
/**
* Read the local settings from the configuration.
*/
void
readConfig
();
/**
* Set frames for which picture has to be found.
*
* @param frames track data
*/
void
setFrames
(
const
FrameCollection
&
frames
);
/**
* Get the URL of an image file.
* The input URL is transformed using the match picture URL table to
* get the URL of an image file.
*
* @param url URL from image drag
*
* @return URL of image file, empty if no image URL found.
*/
static
QString
getImageUrl
(
const
QString
&
url
);
public
slots
:
/**
* Hide modal dialog, start browse command.
*/
virtual
void
accept
();
/**
* Set the source lineedits to the source selected in the combo box.
*
* @param index current index of the combo box
*/
void
setSourceLineEdit
(
int
index
);
private
slots
:
/**
* Show browse command as preview.
*/
void
showPreview
();
/**
* Save the local settings to the configuration.
*/
void
saveConfig
();
/**
* Show help.
*/
void
showHelp
();
private:
/**
* Set the source combo box and line edits from the configuration.
*/
void
setSourceFromConfig
();
/** Text editor with command preview */
QTextEdit
*
m_edit
;
/** Combobox with artist */
QLineEdit
*
m_artistLineEdit
;
/** Combobox with album */
QLineEdit
*
m_albumLineEdit
;
/** Combobox with sources */
QComboBox
*
m_sourceComboBox
;
/** LineEdit for URL */
QLineEdit
*
m_urlLineEdit
;
/** Table to extract picture URL */
ConfigTable
*
m_matchUrlTable
;
/** URLs */
QStringList
m_urls
;
/** Formatted URL */
QString
m_url
;
/** Track data */
FrameCollection
m_frames
;
/** Process for browser command */
ExternalProcess
*
m_process
;
};
#endif
kid3/kid3/configtable.cpp
0 → 100644
View file @
4aa23b47
/**
* \file configtable.cpp
* Context menu commands configuration table.
*
* \b Project: Kid3
* \author Urs Fleisch
* \date 13 Jan 2009
*
* Copyright (C) 2009 Urs Fleisch
*
* This file is part of Kid3.
*
* Kid3 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.
*
* Kid3 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, see <http://www.gnu.org/licenses/>.
*/
#include "configtable.h"
#if QT_VERSION >= 0x040000
#include <QMenu>
#include <QHeaderView>
#else
#include <qpopupmenu.h>
#endif
/** Column indices. */
enum
ColumnIndex
{
CI_Confirm
,
CI_Output
,
CI_Name
,
CI_Command
,
CI_NumColumns
};
/**
* Constructor.
*
* @param labels column labels
* @param parent parent widget
*/
#if QT_VERSION >= 0x040000
ConfigTable
::
ConfigTable
(
const
QStringList
&
labels
,
QWidget
*
parent
)
:
QTableWidget
(
parent
)
{
const
int
numColumns
=
labels
.
size
();
setRowCount
(
1
);
setColumnCount
(
numColumns
);
setHorizontalHeaderLabels
(
labels
);
horizontalHeader
()
->
setResizeMode
(
QHeaderView
::
Stretch
);
setContextMenuPolicy
(
Qt
::
CustomContextMenu
);
connect
(
this
,
SIGNAL
(
cellActivated
(
int
,
int
)),
this
,
SLOT
(
valueChanged
(
int
,
int
)));
connect
(
this
,
SIGNAL
(
customContextMenuRequested
(
const
QPoint
&
)),
this
,
SLOT
(
customContextMenu
(
const
QPoint
&
)));
}
#else
ConfigTable
::
ConfigTable
(
const
QStringList
&
labels
,
QWidget
*
parent
)
:
QTable
(
parent
)
{
const
int
numColumns
=
labels
.
size
();
setNumRows
(
1
);
setNumCols
(
numColumns
);
setColumnLabels
(
labels
);
for
(
int
col
=
0
;
col
<
numColumns
;
++
col
)
{
setColumnStretchable
(
col
,
true
);
}
connect
(
this
,
SIGNAL
(
valueChanged
(
int
,
int
)),