diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | e2de64d6f1beb9e492daf5b886e19933c1fa41dd (patch) | |
tree | 9047cf9e6b5c43878d5bf82660adae77ceee097a /noatun/modules/htmlexport | |
download | tdemultimedia-e2de64d6f1beb9e492daf5b886e19933c1fa41dd.tar.gz tdemultimedia-e2de64d6f1beb9e492daf5b886e19933c1fa41dd.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdemultimedia@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'noatun/modules/htmlexport')
-rw-r--r-- | noatun/modules/htmlexport/Makefile.am | 16 | ||||
-rw-r--r-- | noatun/modules/htmlexport/TODO | 3 | ||||
-rw-r--r-- | noatun/modules/htmlexport/htmlexport.cpp | 308 | ||||
-rw-r--r-- | noatun/modules/htmlexport/htmlexport.h | 89 | ||||
-rw-r--r-- | noatun/modules/htmlexport/htmlexport.plugin | 124 |
5 files changed, 540 insertions, 0 deletions
diff --git a/noatun/modules/htmlexport/Makefile.am b/noatun/modules/htmlexport/Makefile.am new file mode 100644 index 00000000..bbea16ab --- /dev/null +++ b/noatun/modules/htmlexport/Makefile.am @@ -0,0 +1,16 @@ + +INCLUDES= -I$(top_srcdir)/noatun/library $(all_includes) +kde_module_LTLIBRARIES = noatun_htmlexport.la + +noatun_htmlexport_la_SOURCES = htmlexport.cpp +noinst_HEADERS = htmlexport.h + +noatun_htmlexport_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined +noatun_htmlexport_la_LIBADD = $(LIB_KFILE) $(top_builddir)/noatun/library/libnoatun.la \ + -lqtmcop -lkmedia2_idl -lsoundserver_idl + +noatun_htmlexport_la_METASOURCES = AUTO + + +noatun_modules_htmlexport_DATA = htmlexport.plugin +noatun_modules_htmlexportdir = $(kde_datadir)/noatun diff --git a/noatun/modules/htmlexport/TODO b/noatun/modules/htmlexport/TODO new file mode 100644 index 00000000..6f97ad78 --- /dev/null +++ b/noatun/modules/htmlexport/TODO @@ -0,0 +1,3 @@ +Most important TODO items: +* Read tags before writing the file +* Clean up the configure dialog and fix remaining issues diff --git a/noatun/modules/htmlexport/htmlexport.cpp b/noatun/modules/htmlexport/htmlexport.cpp new file mode 100644 index 00000000..dc48fd8f --- /dev/null +++ b/noatun/modules/htmlexport/htmlexport.cpp @@ -0,0 +1,308 @@ +#include <klocale.h> +#include <qregexp.h> +#include <qtextcodec.h> +#include <kaction.h> +#include <noatun/stdaction.h> +#include "htmlexport.h" + +extern "C" +{ + KDE_EXPORT Plugin *create_plugin() + { + return new HTMLExport(); + } +} + +HTMLExport::HTMLExport(): QObject(0, "HTMLExport"), Plugin() +{ + NOATUNPLUGINC(HTMLExport); + + mAction = new KAction(i18n("&Export Playlist..."), "filesaveas", 0, + this, SLOT(slotExport()), this, "exportlist"); + napp->pluginActionMenu()->insert(mAction); + + new Prefs(this); + config = KGlobal::config(); +} + +HTMLExport::~HTMLExport() +{ + napp->pluginActionMenu()->remove(mAction); +} + +void HTMLExport::slotExport() +{ + // init readConfig + config->setGroup("HTMLExport"); + + // get output target + KURL url = KFileDialog::getSaveURL(QString::null, + "text/html", + 0, + i18n("Export Playlist")); + + // write into tempfile + KTempFile temp; + temp.setAutoDelete(true); + QFile file(temp.name()); + file.open(IO_WriteOnly); + QTextStream str(&file); + str.setCodec(QTextCodec::codecForName("utf8")); + + str << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl; + str << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">" << endl; + str << "<!-- Generated by Noatun " << NOATUN_MAJOR << "." << NOATUN_MINOR << "." << NOATUN_PATCHLEVEL << " -->" << endl; + + str << endl; + + str << "<html>" << endl; + str << "<head>" << endl; + str << "\t<title>" << i18n("Noatun Playlist") << "</title>" << endl; + + str << "\t<style type=\"text/css\">" << endl; + str << "\t\t<!--" << endl; + // Set the heading color + str << "\t\th1 { color:#"<< getColorByEntry("headColor")<<"; }" << endl; + + // Optionally set the background image + if (!config->readPathEntry( "bgImgPath" ).stripWhiteSpace().isEmpty()) { + // Image + str << "\t\tp,li { color:#"<< getColorByEntry("txtColor") << "; }" << endl; + str << "\t\tbody { background-image: url(\"" << config->readPathEntry( "bgImgPath" ) << "\"); }" << endl; + } + else { + // Color + str << "\t\tp,li,body { color:#"<< getColorByEntry("txtColor"); + str << "; background-color:#" << getColorByEntry( "bgColor" ) << "; }" << endl; + } + + // Links are text colored, too + str << "\t\ta { color:#" << getColorByEntry("txtColor") << "; }" << endl; + if (getColorByEntry("hoverColor") != getColorByEntry("txtColor")) + str << "\t\ta:hover { color:#"<< getColorByEntry("hoverColor")<<"; }"<< endl; + + str << "\t\t-->" << endl; + str << "\t</style>" << endl; + + str << "</head>" << endl; + str << endl; + str << "<body>" << endl; + str << "\t<h1>" << i18n("Noatun Playlist") << "</h1>" << endl; + + // Cache the config settings used in the big loop + bool link_entries = config->readBoolEntry( "linkEntries" ); + bool number_entries = config->readBoolEntry( "numberEntries" ); + + if (number_entries) + str << "\t\t<ol>" << endl; + else + str << "\t\t<p>" << endl; + + + for (PlaylistItem item = napp->playlist()->getFirst();item;item = napp->playlist()->getAfter(item)) { + str << "\t\t\t"; + + if (number_entries) + str << "<li>"; + + if (link_entries) + str << "<a href=\"" << htmlEscape(item.file()) << "\">"; + + str << htmlEscape(item.title()); + + if (link_entries) + str << "</a>"; + + if (number_entries) + str << "</li>" << endl; + else + str << "<br />" << endl; + } + + if (number_entries) + str << "\t\t</ol>" << endl; + else + str << "\t\t</p>" << endl; + + str << "\t</body>" << endl; + str << "</html>" << endl; + + file.close(); + // tempfile -> userdefined file + KIO::NetAccess::upload(temp.name(), url, 0); +} + +QString HTMLExport::htmlEscape(const QString &source) { + // Escape characters that need to be escaped + QString temp = source; + + temp.replace( QRegExp("&"), "&" ); + temp.replace( QRegExp("<"), "<" ); + temp.replace( QRegExp(">"), ">" ); + + return temp; +} + +QString HTMLExport::getColorByEntry(QString s) +{ + QString res; + QString tmp; + QColor c; + + // init readConfig + + config->setGroup("HTMLExport"); + + c = config->readColorEntry( s ); + tmp = QString::number( c.red(), 16); + if (tmp.length()==1) tmp="0"+tmp; + res = tmp; + + tmp = QString::number( c.green(), 16); + if (tmp.length()==1) tmp="0"+tmp; + res += tmp; + + tmp = QString::number( c.blue(), 16); + if (tmp.length()==1) tmp="0"+tmp; + res += tmp; + + return res; + +} +//////////////////////////////////// Settings //////////////////////////////////// + +Prefs::Prefs(QObject *parent) + : CModule(i18n("Playlist Export"), i18n("Colors & Settings for HTML Export"), "html", parent) +{ + + // Init Config + KConfig *config = KGlobal::config(); + config->setGroup("HTMLExport"); + + // Set default values + if ( !config->hasKey( "headColor" ) ) + config->writeEntry( "headColor", QColor( black ) ) ; + + if ( !config->hasKey( "hoverColor" ) ) + config->writeEntry( "hoverColor", QColor( black ) ); + + if ( !config->hasKey( "bgColor" ) ) + config->writeEntry( "bgColor", QColor( white ) ) ; + + if ( !config->hasKey( "txtColor" ) ) + config->writeEntry( "txtColor", QColor( black ) ); + + config->sync(); + + // Draw Stuff and insert Settings + QVBoxLayout *top = new QVBoxLayout(this, KDialog::marginHint(), + KDialog::spacingHint() ); + + colorBox = new QGroupBox( i18n( "HTML Color Settings" ), this, "colorBox" ); + + bgcolorLabel = new QGridLayout( colorBox, 2, 5, + KDialog::marginHint(), KDialog::spacingHint() ); + + headColorSelect = new KColorButton( colorBox, "headColorSelect" ); + + hoverColorSelect = new KColorButton( colorBox, "hoverColorSelect" ); + + bgColorSelect = new KColorButton( colorBox, "bgColorSelect" ); + + txtColorSelect = new KColorButton( colorBox, "txtColorSelect" ); + + txtColorLabel = new QLabel( colorBox, "txtColorLabel" ); + txtColorLabel->setText( i18n( "Text:" ) ); + txtColorLabel->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); + + bgColorLabel = new QLabel( colorBox, "bgColorLabel" ); + bgColorLabel->setText( i18n( "Background:" ) ); + bgColorLabel->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); + + headColorLabel = new QLabel( colorBox, "headColorLabel" ); + headColorLabel->setText( i18n( "Heading:" ) ); + headColorLabel->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); + + hoverColorLabel = new QLabel( colorBox, "hoverColorLabel" ); + hoverColorLabel->setText( i18n( "Link hover:" ) ); + hoverColorLabel->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); + + bgcolorLabel->setRowStretch(0, 1); + + // Makes the spacing nice + bgcolorLabel->setColStretch(1, 2); + bgcolorLabel->setColStretch(2, 1); + bgcolorLabel->setColStretch(4, 2); + + bgcolorLabel->addWidget( txtColorLabel, 0, 0 ); + bgcolorLabel->addWidget( txtColorSelect, 0, 1 ); + bgcolorLabel->addWidget( headColorLabel, 1, 0 ); + bgcolorLabel->addWidget( headColorSelect, 1, 1 ); + bgcolorLabel->addWidget( bgColorLabel, 0, 3 ); + bgcolorLabel->addWidget( bgColorSelect, 0, 4 ); + bgcolorLabel->addWidget( hoverColorLabel, 1, 3 ); + bgcolorLabel->addWidget( hoverColorSelect, 1, 4 ); + + + // Set up the Background Image frame + bgPicBox = new QHGroupBox( i18n( "Background Image"), this, "bgPicBox" ); + + // Set up the URL requestor + bgPicPath = new KURLRequester ( bgPicBox, "bgPicPath" ); + bgPicPath->setShowLocalProtocol(true); + + // Set up the URL requestor's file dialog + bgPicPath->setMode(KFile::File | KFile::ExistingOnly); + bgPicPath->setFilter("image/gif image/jpeg image/gif image/png image/svg+xml image/tiff"); + + linkEntries = new QCheckBox( this, "linkEntries" ); + linkEntries->setText( i18n( "Hyper&link playlist entries to their URL" ) ); + linkEntries->setTristate( false ); + + numberEntries = new QCheckBox( this, "numberEntries" ); + numberEntries->setText( i18n( "&Number playlist entries" ) ); + numberEntries->setTristate( false ); + + top->addWidget( colorBox ); + top->addWidget( bgPicBox ); + top->addWidget( linkEntries ); + top->addWidget( numberEntries ); + + top->addStretch(); + + reopen(); +} + +void Prefs::save() +{ + KConfig *config = KGlobal::config(); + + QString bgRealURL = bgPicPath->url(); + + if (bgRealURL[0] == '/') + bgRealURL = "file:" + bgRealURL; + + config->setGroup( "HTMLExport" ); + config->writeEntry( "bgColor", bgColorSelect->color() ); + config->writeEntry( "txtColor", txtColorSelect->color() ); + config->writeEntry( "headColor", headColorSelect->color() ); + config->writeEntry( "hoverColor", hoverColorSelect->color() ); + config->writePathEntry( "bgImgPath", bgRealURL ); + config->writeEntry( "linkEntries", linkEntries->isChecked() ); + config->writeEntry( "numberEntries", numberEntries->isChecked() ); + config->sync(); +} + +void Prefs::reopen() +{ + KConfig *config = KGlobal::config(); + headColorSelect->setColor(config->readColorEntry( "headColor" ) ); + hoverColorSelect->setColor( config->readColorEntry( "hoverColor" ) ); + bgColorSelect->setColor( config->readColorEntry( "bgColor" ) ); + txtColorSelect->setColor( config->readColorEntry( "txtColor" ) ); + bgPicPath->setURL( config->readPathEntry( "bgImgPath" ) ); + numberEntries->setChecked( config->readBoolEntry( "numberEntries" ) ); + linkEntries->setChecked( config->readBoolEntry( "linkEntries" ) ); +} +#include "htmlexport.moc" + diff --git a/noatun/modules/htmlexport/htmlexport.h b/noatun/modules/htmlexport/htmlexport.h new file mode 100644 index 00000000..a909a5cb --- /dev/null +++ b/noatun/modules/htmlexport/htmlexport.h @@ -0,0 +1,89 @@ + +#ifndef _HTMLEXPORT_H_ +#define _HTMLEXPORT_H_ + +#include <qfile.h> +#include <qtextstream.h> +#include <qlabel.h> +#include <qhgroupbox.h> +#include <qlineedit.h> +#include <qcheckbox.h> +#include <qpushbutton.h> +#include <qlayout.h> +#include <qtooltip.h> +#include <qwhatsthis.h> + +#include <klocale.h> +#include <kpopupmenu.h> +#include <kfiledialog.h> +#include <ktempfile.h> +#include <kcolorbutton.h> +#include <kio/netaccess.h> +#include <kconfig.h> +#include <kurlrequester.h> + +//#include <kdebug.h> + +#include <noatun/app.h> +#include <noatun/playlist.h> +#include <noatun/pref.h> +#include <noatun/plugin.h> + +class KAction; + +class HTMLExport : public QObject, public Plugin +{ +Q_OBJECT +NOATUNPLUGIND +public: + HTMLExport(); + ~HTMLExport(); + + +private: + QString htmlEscape(const QString &source); + QString getColorByEntry(QString s); + KConfig *config; + KAction *mAction; + +private slots: + void slotExport(); + +}; + +class Prefs : public CModule +{ +Q_OBJECT +public: + Prefs(QObject *parent); + virtual void save(); + virtual void reopen(); + + QGroupBox* colorBox; + + KColorButton* headColorSelect; + KColorButton* hoverColorSelect; + KColorButton* bgColorSelect; + KColorButton* txtColorSelect; + + QLabel* bgColorLabel; + QLabel* txtColorLabel; + QLabel* headColorLabel; + QLabel* hoverColorLabel; + + QCheckBox* linkEntries; + QCheckBox* numberEntries; + + QGroupBox* bgPicBox; + KURLRequester* bgPicPath; + +protected: + QGridLayout* bgcolorLabel; + + +signals: + void saved(); +}; + +#endif + diff --git a/noatun/modules/htmlexport/htmlexport.plugin b/noatun/modules/htmlexport/htmlexport.plugin new file mode 100644 index 00000000..97a10fb9 --- /dev/null +++ b/noatun/modules/htmlexport/htmlexport.plugin @@ -0,0 +1,124 @@ +Filename=noatun_htmlexport.la +Author=Malte Starostik +Email=malte@kde.org +Type=other +License=Artistic +Name=HTML Playlist Export +Name[bn]=এইচ-টি-এম-এল সঙ্গীত-তালিকা রপ্তানি +Name[br]=Ezporzh ar roll tonioù e HTML +Name[bs]=Izvoz liste numera u HTML +Name[ca]=Exportació del repertori en HTML +Name[cs]=Export seznamu skladeb do HTML +Name[cy]=Allforio Rhestr Chwarae HTML +Name[da]=HTML-spilleliste-eksport +Name[de]=Export von Wiedergabelisten in HTML +Name[el]=Εξαγωγή λίστας αναπαραγωγής HTML +Name[eo]=HTML-ludlisteksporto +Name[es]=Exportador de listas de reproducción HTML +Name[et]=Esitusnimekirja eksport HTML-i +Name[eu]=HTML erreprodukzio-zerrendaren esportazioa +Name[fa]=صادرات فهرست پخش زنگام +Name[fi]=HTML-soittolistan vienti +Name[fr]=Export en HTML des listes de lecture +Name[ga]=Easpórtáil Seinmliosta mar HTML +Name[gl]=Exportación de Lista de Reprodución a HTML +Name[he]=ייצוא לרשימת ניגון בתבנית HTML +Name[hu]=Lejátszási lista exportálása HTML-fájlba +Name[is]=Útflutningur á HTML lagalista +Name[it]=Esportazione HTML delle playlist +Name[ja]=HTML プレイリストのエクスポート +Name[kk]=Орындау тізімін HTML-экспорттау +Name[km]=នាំចេញបញ្ជីចាក់ HTML +Name[ko]=HTML 재생 목록 내보내기 +Name[lt]=HTML gaidaraščio eksportas +Name[mk]=Испраќање на листа со нумери како HTML +Name[nb]=Eksport av HTML-spilleliste +Name[nds]=Afspeellist-Export na HTML +Name[ne]=HTML बजाउने सूची निर्यात +Name[nl]=HTML-afspeellijst-export +Name[nn]=Eksport av HTML-speleliste +Name[pa]=HTML ਸੰਗੀਤ-ਸੂਚੀ ਨਿਰਯਾਤ +Name[pl]=Eksport listy utworów do formatu HTML +Name[pt]=Exportação de Listas de Músicas em HTML +Name[pt_BR]=Exportação de listas de reprodução em HTML +Name[ro]=Exportare HTML listă de redare +Name[ru]=Экспорт списка песен в HTML +Name[sk]=Export playlistu do HTML +Name[sl]=Izvoz predvajalnega seznama v HTML +Name[sr]=Извожење листе нумера у HTML +Name[sr@Latn]=Izvoženje liste numera u HTML +Name[sv]=HTML-spellistexport +Name[ta]=HTML பாடல் பட்டியல் ஏற்றுமதி +Name[th]=ส่งออกรายการเล่นเป็น HTML +Name[tr]=HTML Çalma Listesi Dışarı Aktarma +Name[uk]=Експорт списку композицій до HTML +Name[zh_CN]=HTML 播放列表导出 +Name[zh_HK]=HTML 播放清單匯出 +Name[zh_TW]=HTML 播放清單匯出 +Comment=Creates a HTML file from the playlist +Comment[af]=Skep 'n Html lêer van die liedjielys +Comment[ar]=ينشئ ملف HTML من لائحة التشغيل +Comment[az]=Çalma siyahısından bir HTML faylı yarat +Comment[bg]=Експортиране на списък за изпълнение във файл от тип HTML +Comment[bn]=সঙ্গীত-তালিকা থেকে একটি এইচ-টি-এম-এল ফাইল তৈরি করে +Comment[br]=Krouiñ ur restr HTML eus ar roll tonioù +Comment[bs]=Pravi HTML dokument od liste numera +Comment[ca]=Crea un fitxer HTML d'una selecció de peces +Comment[cs]=Vytváří ze seznamu skladeb HTML soubor +Comment[cy]=Creu ffeil HTML o'r rhestr chwarae +Comment[da]=Opretter en HTML-fil fra spillelisten +Comment[de]=Erstellt eine HTML-Datei aus einer Wiedergabeliste +Comment[el]=Δημιουργεί ένα αρχείο HTML από τη λίστα αναπαραγωγής +Comment[en_GB]=Creates an HTML file from the playlist +Comment[eo]=Kreas HTML-dosieron el la ludlisto +Comment[es]=Crea un archivo HTML a partir de la lista de reproducción +Comment[et]=HTML-faili loomine nimekirjast +Comment[eu]=HTML fitxategia erreprodukzio-zerrendatik sortzen du +Comment[fa]=از فهرست پخش یک پروندۀ زنگام ایجاد میکند +Comment[fi]=Luo HTML-tiedoston soittolistasta +Comment[fr]=Crée un fichier HTML à partir de la liste de lecture +Comment[ga]=Cruthaigh comhad HTML ón seinmliosta +Comment[gl]=Crea un ficheiro HTML a partires da lista de reprodución +Comment[he]=יצירת קובץ HTML מתוך רשימת הניגון +Comment[hi]=प्लेलिस्ट से एचटीएमएल फ़ाइल बनाता है +Comment[hr]=Stvara od liste pjesama HTML datoteku +Comment[hu]=Lejátszási lista exportálása HTML-ben +Comment[is]=Býr til HTML skrá úr lagalistanum +Comment[it]=Crea un file HTML dalla playlist +Comment[ja]=プレイリストから HTML を作成 +Comment[kk]=Орындау тізімін HTML-пішімді файлға жазу +Comment[km]=បង្កើតបញ្ជីឯកសារ HTML ពីបញ្ជីចាក់ +Comment[ko]=재생 목록에서 HTML 파일 만들기 +Comment[lt]=Sukuria HTML failą iš gaidaraščio +Comment[lv]=Izveido HTML failu no plejlista +Comment[mk]=Креира датотека HTML од листата со нумери +Comment[ms]=Bina fail HTML untuk senarai main +Comment[mt]=Joħloq fajl HTML mill-playlist +Comment[nb]=Lager en HTML-fil fra spillelisten +Comment[nds]=Stellt ut de Afspeellist en HTML-Datei op +Comment[ne]=बजाउने सूचीबाट HTML फाइल सिर्जना गर्दछ +Comment[nl]=Maakt een HTML-bestand aan op basis van de speellijst +Comment[nn]=Lagar ei HTML-fil frå spelelista +Comment[pa]=ਸੰਗੀਤ-ਸੂਚੀ ਤੋਂ ਇੱਕ HTML ਫਾਇਲ ਬਣਾਓ +Comment[pl]=Tworzy plik HTML z listy nagrań +Comment[pt]=Cria um ficheiro HTML a partir de uma lista de músicas +Comment[pt_BR]=Cria um arquivo HTML a partir da lista de reprodução +Comment[ro]=Creează un fişier HTML dintr-o listă de redare +Comment[ru]=Создание HTML-файла из списка песен +Comment[se]=Ráhkada HTML-fiilla čuojahanlisttus +Comment[sk]=Vytvorí HTML súbor z playlistu +Comment[sl]=Ustvari datoteko HTML iz predvajalnega seznama +Comment[sr]=Прави HTML фајл на основу листе нумера +Comment[sr@Latn]=Pravi HTML fajl na osnovu liste numera +Comment[sv]=Skapar en HTML-fil av en spellista +Comment[ta]=பாடல் பட்டியலிலிருந்து HTML ஆவணமொன்றை உருவாக்கின்றது +Comment[tg]=Аз рӯйхати бозикуниҳо файли HTML-ро офарид +Comment[th]=สร้างแฟ้ม HTML สำหรับรายการเล่น +Comment[tr]=Çalma listesinden bir HTML dosyası oluşturur +Comment[uk]=Створює файл HTML зі списку композицій +Comment[ven]=Itani faela ya HTML u bva kha mutevhe wa tshitambi +Comment[xh]=Yenza ifayile ye HTML kuluhlu lomdlalo +Comment[zh_CN]=从播放列表创建 HTML 文件 +Comment[zh_HK]=從播放清單建立 HTML 檔案 +Comment[zh_TW]=從播放清單建立 HTML 文件檔案 +Comment[zu]=Yenza ifayela ye HTML kuluhlu lomdlalo |