Commit a70e35c5 authored by Urs Fleisch's avatar Urs Fleisch
Browse files

Move source files into directories to separate GUI and logic in libraries.

parent 24c036ef
......@@ -132,7 +132,7 @@ if (WITH_KDE)
set(BASIC_LIBRARIES ${BASIC_LIBRARIES} ${PHONON_LIBS})
endif (WITH_PHONON)
else (WITH_KDE)
set(BASIC_LIBRARIES ${QT_LIBRARIES})
set(BASIC_LIBRARIES ${QT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
endif (WITH_KDE)
if (WIN32)
......@@ -383,7 +383,7 @@ endif (WITH_KDE)
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
add_subdirectory(kid3)
add_subdirectory(src)
add_subdirectory(doc)
add_subdirectory(po)
......
......@@ -35,7 +35,7 @@ if (SCRIPT_ARG_HEADER_FILENAME AND SCRIPT_ARG_SRC_DIRNAME)
else (SCRIPT_ARG_INCLUDE_REGEX)
set(_includeRegex "#include <")
endif (SCRIPT_ARG_INCLUDE_REGEX)
file(GLOB _srcList "${SCRIPT_ARG_SRC_DIRNAME}/*.cpp"
file(GLOB_RECURSE _srcList "${SCRIPT_ARG_SRC_DIRNAME}/*.cpp"
"${SCRIPT_ARG_SRC_DIRNAME}/*.hpp"
"${SCRIPT_ARG_SRC_DIRNAME}/*.c"
"${SCRIPT_ARG_SRC_DIRNAME}/*.h")
......
set(TAGLIBEXT_LIBRARIES)
if (HAVE_TAGLIB)
add_subdirectory(taglibext)
set(TAGLIBEXT_LIBRARIES taglibext)
endif (HAVE_TAGLIB)
set(kid3_SRCS filelist.cpp fileproxymodel.cpp frame.cpp framelist.cpp
modeliterator.cpp taggedfileiconprovider.cpp comboboxdelegate.cpp
frametable.cpp frametablemodel.cpp genres.cpp kid3application.cpp
kid3form.cpp kid3mainwindow.cpp main.cpp m4afile.cpp
mp3file.cpp configdialog.cpp exportdialog.cpp formatconfig.cpp formatbox.cpp
importdialog.cpp importparser.cpp generalconfig.cpp
importconfig.cpp miscconfig.cpp freedbconfig.cpp
freedbimporter.cpp rendirdialog.cpp dirlist.cpp dirproxymodel.cpp taggedfile.cpp
musicbrainzdialog.cpp musicbrainzconfig.cpp musicbrainzclient.cpp
numbertracksdialog.cpp oggfile.cpp vcedit.c flacfile.cpp
commandstablemodel.cpp taglibfile.cpp serverimporterconfig.cpp
serverimportdialog.cpp importclient.cpp serverimporter.cpp
discogsimporter.cpp discogsconfig.cpp
musicbrainzreleaseimporter.cpp externalprocess.cpp trackdata.cpp trackdatamodel.cpp
stringlistedit.cpp tracktypeimporter.cpp filterconfig.cpp
filterdialog.cpp filefilter.cpp expressionparser.cpp pictureframe.cpp
formatreplacer.cpp httpclient.cpp downloaddialog.cpp downloadclient.cpp picturelabel.cpp
browsecoverartdialog.cpp configtable.cpp configtablemodel.cpp
attributedata.cpp browserdialog.cpp imageviewer.cpp editframedialog.cpp
editframefieldsdialog.cpp playlistdialog.cpp playlistconfig.cpp
playlistcreator.cpp amazonimporter.cpp amazonconfig.cpp
recentfilesmenu.cpp playtoolbar.cpp textimporter.cpp textimportdialog.cpp
trackdatamatcher.cpp tagimportdialog.cpp configstore.cpp contexthelp.cpp
iframeeditor.cpp textexporter.cpp dirrenamer.cpp audioplayer.cpp)
if (HAVE_QTDBUS)
set(kid3_SRCS ${kid3_SRCS} scriptinterface.cpp)
endif (HAVE_QTDBUS)
if (WITH_GCC_PCH)
if (WITH_KDE)
set(_includeRegex "#include <[Qkcp]")
else (WITH_KDE)
set(_includeRegex "#include <[Qcp]")
endif (WITH_KDE)
if (CMAKE_BUILD_TYPE MATCHES Debug)
set(_additionalFlags "-g -DQT_DEBUG -D_REENTRANT")
else (CMAKE_BUILD_TYPE MATCHES Debug)
set(_additionalFlags "-O3 -DQT_NO_DEBUG -D_REENTRANT -DNDEBUG")
endif (CMAKE_BUILD_TYPE MATCHES Debug)
ADD_PCH_HEADERFILE_RULE(${CMAKE_CURRENT_BINARY_DIR}/allsys.h
${CMAKE_CURRENT_SOURCE_DIR} ${_includeRegex})
ADD_PCH_RULE(allsys.h kid3_SRCS ${_additionalFlags})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Winvalid-pch -include allsys.h")
endif (WITH_GCC_PCH)
if (WITH_KDE)
kde4_add_executable(kid3 ${kid3_SRCS})
target_link_libraries(kid3 ${TAGLIBEXT_LIBRARIES} ${BASIC_LIBRARIES}
${ID3LIB_LIBRARIES} ${TAGLIB_LIBRARIES} ${VORBIS_LIBRARIES} ${FLAC_LIBRARIES}
${TUNEPIMP_LIBRARIES} ${MP4V2_LIBRARIES})
install(TARGETS kid3 DESTINATION ${BIN_INSTALL_DIR})
install(FILES kid3.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
install(FILES kid3ui.rc DESTINATION ${DATA_INSTALL_DIR}/kid3)
install(FILES net.sourceforge.Kid3.xml DESTINATION ${DBUS_INTERFACES_INSTALL_DIR})
kde4_install_icons(${ICON_INSTALL_DIR})
else (WITH_KDE)
if (APPLE)
# Icon and properties for .plist file
set(MACOSX_BUNDLE_ICON_FILE kid3.icns)
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "1.6")
set(MACOSX_BUNDLE_GUI_IDENTIFIER "net.sourceforge.kid3")
set(MACOSX_BUNDLE_COPYRIGHT "Copyright (c) 2003-2011 Urs Fleisch")
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/../macosx/kid3.icns
PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
set(kid3_SRCS ${kid3_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/../macosx/kid3.icns)
elseif (WIN32)
if (MINGW)
# support for Windows resource files with MinGW
set(CMAKE_RC_COMPILER_INIT windres)
enable_language(RC)
set(CMAKE_RC_COMPILE_OBJECT
"<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
endif (MINGW)
# add Windows resource file with icon
set(kid3_SRCS ${kid3_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/../win32/kid3win.rc)
endif (APPLE)
if (UNIX AND NOT APPLE)
# install desktop file and icons for Linux
add_custom_command(OUTPUT kid3-qt.desktop
COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/fixdesktop.pl
<${CMAKE_CURRENT_SOURCE_DIR}/kid3.desktop >kid3-qt.desktop
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/kid3.desktop
)
add_custom_target("desktop-file" ALL DEPENDS kid3-qt.desktop)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kid3-qt.desktop
DESTINATION "${WITH_DATAROOTDIR}/applications")
install(FILES hisc-app-kid3.svgz
DESTINATION "${WITH_DATAROOTDIR}/icons/hicolor/scalable/apps"
RENAME kid3-qt.svgz)
install(FILES hi48-app-kid3.png
DESTINATION "${WITH_DATAROOTDIR}/icons/hicolor/48x48/apps"
RENAME kid3-qt.png)
install(FILES hi32-app-kid3.png
DESTINATION "${WITH_DATAROOTDIR}/icons/hicolor/32x32/apps"
RENAME kid3-qt.png)
install(FILES hi16-app-kid3.png
DESTINATION "${WITH_DATAROOTDIR}/icons/hicolor/16x16/apps"
RENAME kid3-qt.png)
endif (UNIX AND NOT APPLE)
# Run moc on Q_OBJECT header files
set(kid3_MOC_HDRS filelist.h frametable.h frametablemodel.h kid3application.h
kid3form.h kid3mainwindow.h configdialog.h
exportdialog.h formatbox.h importdialog.h rendirdialog.h
musicbrainzdialog.h musicbrainzclient.h numbertracksdialog.h
serverimportdialog.h importclient.h serverimporter.h externalprocess.h stringlistedit.h
filterdialog.h filefilter.h httpclient.h downloaddialog.h downloadclient.h
browsecoverartdialog.h configtable.h browserdialog.h imageviewer.h
editframedialog.h editframefieldsdialog.h playlistdialog.h recentfilesmenu.h
playtoolbar.h fileproxymodel.h trackdatamodel.h textimportdialog.h
tagimportdialog.h audioplayer.h)
if (HAVE_QTDBUS)
set(kid3_MOC_HDRS ${kid3_MOC_HDRS} scriptinterface.h)
endif (HAVE_QTDBUS)
qt4_wrap_cpp(kid3_GEN_MOC_HDRS ${kid3_MOC_HDRS})
add_definitions(${QT_DEFINITIONS})
set(kid3_RESOURCES kid3.qrc)
qt4_add_resources(kid3_GEN_RCS ${kid3_RESOURCES})
add_executable(${KID3_EXECUTABLE} MACOSX_BUNDLE WIN32 ${kid3_SRCS}
${kid3_GEN_MOC_HDRS} ${kid3_GEN_RCS})
target_link_libraries(${KID3_EXECUTABLE} ${TAGLIBEXT_LIBRARIES}
${BASIC_LIBRARIES} ${ID3LIB_LIBRARIES} ${TAGLIB_LIBRARIES} ${VORBIS_LIBRARIES}
${FLAC_LIBRARIES} ${TUNEPIMP_LIBRARIES} ${MP4V2_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT})
install(TARGETS ${KID3_EXECUTABLE}
BUNDLE DESTINATION .
RUNTIME DESTINATION ${WITH_BINDIR})
if (APPLE OR WIN32)
# Put Qt libraries and plugins into installation package to create a standalone
# bundle on Mac OS X and Windows
set(plugin_dest_dir ${WITH_BINDIR})
set(bundle_app "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${WITH_BINDIR}/${KID3_EXECUTABLE}")
if (APPLE)
set(plugin_dest_dir kid3.app/Contents/PlugIns)
set(bundle_app "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/kid3.app")
endif (APPLE)
if (WIN32)
set(bundle_app "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${WITH_BINDIR}/kid3.exe")
endif (WIN32)
string(REPLACE "/./" "/" bundle_app ${bundle_app})
# Install Qt JPEG and Phonon plugins
install(DIRECTORY "${QT_PLUGINS_DIR}/imageformats" DESTINATION ${plugin_dest_dir}
FILES_MATCHING PATTERN "*jpeg${CMAKE_SHARED_LIBRARY_SUFFIX}"
PATTERN "*jpeg4${CMAKE_SHARED_LIBRARY_SUFFIX}")
if (HAVE_PHONON)
install(DIRECTORY "${QT_PLUGINS_DIR}/phonon_backend"
DESTINATION ${plugin_dest_dir}
FILES_MATCHING
PATTERN "*d4${CMAKE_SHARED_LIBRARY_SUFFIX}" EXCLUDE
PATTERN "*${CMAKE_SHARED_LIBRARY_SUFFIX}")
endif (HAVE_PHONON)
# Install and fix up all dependencies of the executable and the plugins.
# On Mac OS X only keep the i386 code in the Qt libraries and plugins.
install(CODE "
file(GLOB_RECURSE QTPLUGINS
\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
include(BundleUtilities)
fixup_bundle(\"${bundle_app}\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\")
if (APPLE)
file(GLOB_RECURSE _qtlibs \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/kid3.app/Contents/Frameworks/*Qt*\")
file(GLOB_RECURSE _plugins \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/kid3.app/Contents/PlugIns/*.dylib\")
foreach (_universalBinary \${_plugins} \${_qtlibs})
execute_process(COMMAND lipo \${_universalBinary} -output \${_universalBinary} -thin i386)
endforeach (_universalBinary \${plugins})
endif (APPLE)
")
endif (APPLE OR WIN32)
endif (WITH_KDE)
if (HAVE_TAGLIB)
include_directories(..)
set(taglibextsrc
aac/aacfiletyperesolver.cpp mp2/mp2filetyperesolver.cpp)
if (TAGLIB_VERSION STREQUAL "1.4")
set(taglibextsrc ${taglibextsrc}
urllinkframe.cpp unsynchronizedlyricsframe.cpp generalencapsulatedobjectframe.cpp
speex/speexfile.cpp speex/speexproperties.cpp speex/taglib_speexfiletyperesolver.cpp
trueaudio/taglib_trueaudiofiletyperesolver.cpp
trueaudio/ttafile.cpp trueaudio/ttaproperties.cpp
wavpack/taglib_wavpackfiletyperesolver.cpp wavpack/wvfile.cpp
wavpack/wvproperties.cpp)
endif (TAGLIB_VERSION STREQUAL "1.4")
add_library(taglibext STATIC ${taglibextsrc})
endif (HAVE_TAGLIB)
......@@ -56,7 +56,9 @@ else(WITH_KDE)
add_custom_command(
OUTPUT ${_tsFiles}
COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/po2ts.pl ${QT_LUPDATE_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../kid3
COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/po2ts.pl
${QT_LUPDATE_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../src
DEPENDS ${_poFiles}
)
qt4_add_translation(_qmFiles ${_tsFiles} ${_qtTsFiles})
......
#!/bin/sh
BASEDIR="../kid3" # root of translatable sources
BASEDIR="../src" # root of translatable sources
PROJECT="kid3" # project name
BUGADDR="http://sourceforge.net/tracker/?group_id=70849&atid=529221" # MSGID-Bugs
WDIR=`pwd` # working dir
......
......@@ -3,6 +3,8 @@ package po2ts;
use strict;
use File::Basename;
use File::Find;
use File::Path qw(make_path remove_tree);
use vars qw(@ISA @EXPORT);
require Exporter;
......@@ -10,14 +12,18 @@ require Exporter;
@EXPORT = qw(generateTs);
# Read all source files given in the parameter list and copy them to the
# current directory, replaceing i18n by tr and I18N_NOOP by QT_TRANSLATE_NOOP.
# output directory, replaceing i18n by tr and I18N_NOOP by QT_TRANSLATE_NOOP.
sub createTranslateSources($@)
{
my $outdir = shift;
my $indir = shift;
my @sources = @_;
my $indirLen = length($indir);
foreach my $file (@sources) {
open IF, $file or die "Could not open $file: $!\n";
my $outfn = $outdir . "/" . basename($file);
my $outfn = $outdir . substr($file, $indirLen);
my $outfndir = dirname($outfn);
make_path($outfndir) unless -d $outfndir;
open OF, ">$outfn" or die "Could not create $outfn: $!\n";
while (<IF>) {
s/i18n\(/tr(/g;
......@@ -25,7 +31,7 @@ sub createTranslateSources($@)
s/KCM_i18n2\(([^,]+), ([^,]+), ([^)]+)\)/tr($1).arg($2).arg($3)/g;
s/I18N_NOOP\(/QT_TRANSLATE_NOOP("\@default", /g;
print OF $_;
}
}
close OF;
close IF;
}
......@@ -125,30 +131,34 @@ sub setTsTranslations($$%)
close IF;
}
my @sources;
# Push .cpp file names into @sources.
sub wanted
{
/\.cpp$/ && push @sources, $File::Find::name;
}
# Generate .ts files from .po files.
# parameters: path to lupdate command, directory with po-files,
# directory with source files
sub generateTs
{
my ($lupdate_cmd, $podir, @srcdirs) = @_;
my ($lupdate_cmd, $podir, $srcdir) = @_;
my @pofiles = glob "$podir/*.po";
my @languages = map { /^.*\W(\w+)\.po$/ } @pofiles;
my $tmpdir = ".tsdir";
mkdir $tmpdir unless -d $tmpdir;
my @sources;
foreach (@srcdirs) {
push @sources, glob "$_/*.cpp";
}
createTranslateSources($tmpdir, @sources);
find(\&wanted, $srcdir);
createTranslateSources($tmpdir, $srcdir, @sources);
chdir $tmpdir or die "Could not change to $tmpdir: $!\n";
system "$lupdate_cmd " . join ' ', glob "*.cpp" . " -ts ". join ' ', map { "kid3_". $_ . ".ts" } @languages;
system "$lupdate_cmd -recursive . -ts " . join ' ', map { "kid3_". $_ . ".ts" } @languages;
chdir "..";
foreach my $lang (@languages) {
foreach my $lang (@languages) {
setTsTranslations("$tmpdir/kid3_$lang.ts", "kid3_$lang.ts",
getPoTranslations("$podir/$lang.po"));
}
unlink <$tmpdir/*>;
rmdir $tmpdir;
remove_tree($tmpdir);
}
if (!caller()) {
......
if (WITH_GCC_PCH)
if (WITH_KDE)
set(_includeRegex "#include <[Qkcp]")
else (WITH_KDE)
set(_includeRegex "#include <[Qcp]")
endif (WITH_KDE)
if (CMAKE_BUILD_TYPE MATCHES Debug)
set(_additionalFlags "-g -DQT_DEBUG -D_REENTRANT")
else (CMAKE_BUILD_TYPE MATCHES Debug)
set(_additionalFlags "-O3 -DQT_NO_DEBUG -D_REENTRANT -DNDEBUG")
endif (CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Winvalid-pch -include ${CMAKE_BINARY_DIR}/allsys.h")
macro (ADD_KID3_PCH_RULE _srcList)
ADD_PCH_HEADERFILE_RULE(${CMAKE_BINARY_DIR}/allsys.h
${CMAKE_CURRENT_SOURCE_DIR} ${_includeRegex})
ADD_PCH_RULE(${CMAKE_BINARY_DIR}/allsys.h ${_srcList} ${_additionalFlags})
endmacro (ADD_KID3_PCH_RULE _srcList)
endif (WITH_GCC_PCH)
add_subdirectory(core)
add_subdirectory(gui)
include_directories(utils config tags formats export import model)
set(core_SRCS)
set(core_MOC_HDRS)
foreach (_subdir config tags formats export import model)
include(${_subdir}/Sources.cmake)
set(core_SRCS ${core_SRCS} ${${_subdir}_SRCS})
set(core_MOC_HDRS ${core_MOC_HDRS} ${${_subdir}_MOC_HDRS})
endforeach()
if (WITH_GCC_PCH)
ADD_KID3_PCH_RULE(core_SRCS)
endif (WITH_GCC_PCH)
qt4_wrap_cpp(core_GEN_MOC_SRCS ${core_MOC_HDRS})
add_library(kid3-core ${core_SRCS} ${core_GEN_MOC_SRCS})
target_link_libraries(kid3-core
${BASIC_LIBRARIES} ${ID3LIB_LIBRARIES} ${TAGLIB_LIBRARIES} ${VORBIS_LIBRARIES}
${FLAC_LIBRARIES} ${TUNEPIMP_LIBRARIES} ${MP4V2_LIBRARIES}
)
if (WITH_KDE)
install(FILES model/net.sourceforge.Kid3.xml
DESTINATION ${DBUS_INTERFACES_INSTALL_DIR})
endif (WITH_KDE)
set(config_SRCS
config/amazonconfig.cpp
config/configstore.cpp
config/discogsconfig.cpp
config/filterconfig.cpp
config/formatconfig.cpp
config/freedbconfig.cpp
config/generalconfig.cpp
config/importconfig.cpp
config/miscconfig.cpp
config/musicbrainzconfig.cpp
config/playlistconfig.cpp
config/serverimporterconfig.cpp
)
set(config_MOC_HDRS)
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