From abaab158ba5c7e46ecfee3846ae9d596df871212 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Wed, 27 Jan 2010 22:25:47 +0000 Subject: added template editor, improved status icon plugin git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1530 90c681e8-e032-0410-971d-27865f9a5e38 --- src/qmmpui/CMakeLists.txt | 4 ++ src/qmmpui/metadataformatter.cpp | 26 ++++++- src/qmmpui/metadataformatter.h | 5 +- src/qmmpui/qmmpui.pro | 9 ++- src/qmmpui/templateeditor.cpp | 100 ++++++++++++++++++++++++++ src/qmmpui/templateeditor.h | 59 ++++++++++++++++ src/qmmpui/templateeditor.ui | 110 +++++++++++++++++++++++++++++ src/qmmpui/translations/libqmmpui_cs.ts | 88 +++++++++++++++++++++++ src/qmmpui/translations/libqmmpui_de.ts | 88 +++++++++++++++++++++++ src/qmmpui/translations/libqmmpui_it.ts | 88 +++++++++++++++++++++++ src/qmmpui/translations/libqmmpui_lt.ts | 88 +++++++++++++++++++++++ src/qmmpui/translations/libqmmpui_pl.ts | 88 +++++++++++++++++++++++ src/qmmpui/translations/libqmmpui_pt_BR.ts | 88 +++++++++++++++++++++++ src/qmmpui/translations/libqmmpui_ru.ts | 90 ++++++++++++++++++++++- src/qmmpui/translations/libqmmpui_tr.ts | 88 +++++++++++++++++++++++ src/qmmpui/translations/libqmmpui_uk_UA.ts | 88 +++++++++++++++++++++++ src/qmmpui/translations/libqmmpui_zh_CN.ts | 88 +++++++++++++++++++++++ src/qmmpui/translations/libqmmpui_zh_TW.ts | 88 +++++++++++++++++++++++ 18 files changed, 1275 insertions(+), 8 deletions(-) create mode 100644 src/qmmpui/templateeditor.cpp create mode 100644 src/qmmpui/templateeditor.h create mode 100644 src/qmmpui/templateeditor.ui (limited to 'src/qmmpui') diff --git a/src/qmmpui/CMakeLists.txt b/src/qmmpui/CMakeLists.txt index 595cf4f0c..cf72e83da 100644 --- a/src/qmmpui/CMakeLists.txt +++ b/src/qmmpui/CMakeLists.txt @@ -40,6 +40,7 @@ SET(libqmmpui_SRCS tageditor.cpp playlistmanager.cpp metadataformatter.cpp + templateeditor.cpp ) SET(libqmmpui_MOC_HDRS @@ -64,6 +65,7 @@ SET(libqmmpui_MOC_HDRS tageditor.h playlistmanager.h metadataformatter.h + templateeditor.h ) SET(libqmmpui_DEVEL_HDRS @@ -84,12 +86,14 @@ SET(libqmmpui_DEVEL_HDRS tageditor.h playlistmanager.h metadataformatter.h + templateeditor.h ) SET(libqmmpui_UIS detailsdialog.ui tageditor.ui + templateeditor.ui ) QT4_WRAP_UI(libqmmpui_UIS_H ${libqmmpui_UIS}) diff --git a/src/qmmpui/metadataformatter.cpp b/src/qmmpui/metadataformatter.cpp index dba32abd2..073c6ef88 100644 --- a/src/qmmpui/metadataformatter.cpp +++ b/src/qmmpui/metadataformatter.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2009 by Ilya Kotov * + * Copyright (C) 2009-2010 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -33,6 +33,7 @@ Syntax: %f - file name %F - full path %y - year +%l - duration %if(A,B,C) %if(A&B&C,D,E) */ @@ -46,7 +47,12 @@ MetaDataFormatter::MetaDataFormatter(const QString &format) m_format = format; } -QString MetaDataFormatter::parse(const QMap metaData) +QString MetaDataFormatter::parse(AbstractPlaylistItem *item) +{ + return parse(item->metaData(), item->length()); +} + +QString MetaDataFormatter::parse(const QMap metaData, qint64 length) { QString title = m_format; title.replace("\\(", "%28"); @@ -66,6 +72,22 @@ QString MetaDataFormatter::parse(const QMap metaData) title.replace("%f", metaData[Qmmp::URL].section('/',-1)); title.replace("%F", metaData[Qmmp::URL]); title.replace("%y", metaData[Qmmp::YEAR]); + if(title.contains("l")) + { + if (length) + { + QString time; + int l = length; + if(l > 3600) + time == QString("%1:%2:%3").arg(l/3600,2,10,QChar('0')) + .arg(l%3600/60,2,10,QChar('0')).arg(l%60,2,10,QChar('0')); + else + time = QString("%1:%2").arg(l/60,2,10,QChar('0')).arg(l%60,2,10,QChar('0')); + title.replace("%l",time); + } + else + title.replace("%l",""); + } if(title.contains("%if")) title = processIfKeyWord(title); diff --git a/src/qmmpui/metadataformatter.h b/src/qmmpui/metadataformatter.h index c826cb499..b338e2085 100644 --- a/src/qmmpui/metadataformatter.h +++ b/src/qmmpui/metadataformatter.h @@ -23,6 +23,7 @@ #include #include +#include #include /*! @@ -32,12 +33,12 @@ class MetaDataFormatter { public: MetaDataFormatter(const QString &format); - QString parse(const QMap metaData); + QString parse(AbstractPlaylistItem *item); + QString parse(const QMap metaData, qint64 length = 0); private: QString m_format; QString processIfKeyWord(QString title); - }; #endif // METADATAFORMATTER_H diff --git a/src/qmmpui/qmmpui.pro b/src/qmmpui/qmmpui.pro index f7fa82662..51f2cef04 100644 --- a/src/qmmpui/qmmpui.pro +++ b/src/qmmpui/qmmpui.pro @@ -38,7 +38,8 @@ HEADERS += general.h \ detailsdialog.h \ tageditor.h \ playlistmanager.h \ - metadataformatter.h + metadataformatter.h \ + templateeditor.h SOURCES += general.cpp \ generalhandler.cpp \ playlistparser.cpp \ @@ -55,9 +56,11 @@ SOURCES += general.cpp \ detailsdialog.cpp \ tageditor.cpp \ playlistmanager.cpp \ - metadataformatter.cpp + metadataformatter.cpp \ + templateeditor.cpp FORMS += detailsdialog.ui \ - tageditor.ui + tageditor.ui \ + templateeditor.ui unix:DESTDIR = . RESOURCES += translations/libqmmpui_locales.qrc TRANSLATIONS = translations/libqmmpui_ru.ts \ diff --git a/src/qmmpui/templateeditor.cpp b/src/qmmpui/templateeditor.cpp new file mode 100644 index 000000000..203f91e6a --- /dev/null +++ b/src/qmmpui/templateeditor.cpp @@ -0,0 +1,100 @@ +/*************************************************************************** + * Copyright (C) 2010 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include +#include +#include "ui_templateeditor.h" +#include "templateeditor.h" + +TemplateEditor::TemplateEditor(QWidget *parent) : QDialog(parent), m_ui(new Ui::TemplateEditor) +{ + m_ui->setupUi(this); + createMenu(); +} + +QString TemplateEditor::currentTemplate() const +{ + return m_ui->textEdit->toPlainText (); +} + +void TemplateEditor::setTemplate(const QString &text) +{ + m_ui->textEdit->setPlainText(text); +} + +void TemplateEditor::setDefaultTemplate(const QString &text) +{ + m_defaultTemplate = text; +} + +void TemplateEditor::createMenu() +{ + QMenu *menu = new QMenu(this); + menu->addAction(tr("Artist"))->setData("%p"); + menu->addAction(tr("Album"))->setData("%a"); + menu->addAction(tr("Title"))->setData("%t"); + menu->addAction(tr("Track number"))->setData("%n"); + menu->addAction(tr("Two-digit track number"))->setData("%NN"); + menu->addAction(tr("Genre"))->setData("%g"); + menu->addAction(tr("Comment"))->setData("%c"); + menu->addAction(tr("Composer"))->setData("%C"); + menu->addAction(tr("Duration"))->setData("%l"); + menu->addAction(tr("Disc number"))->setData("%D"); + menu->addAction(tr("File name"))->setData("%f"); + menu->addAction(tr("File path"))->setData("%F"); + menu->addAction(tr("Year"))->setData("%y"); + menu->addAction(tr("Condition"))->setData("%if(%p&%t,%p - %t,%f)"); + m_ui->insertButton->setMenu(menu); + connect(menu, SIGNAL(triggered (QAction *)), SLOT(insertExpression(QAction *))); +} + +void TemplateEditor::insertExpression(QAction *a) +{ + m_ui->textEdit->insertPlainText(a->data().toString()); +} + +void TemplateEditor::on_resetButton_clicked() +{ + m_ui->textEdit->setPlainText(m_defaultTemplate); +} + +QString TemplateEditor::getTemplate (QWidget *parent, const QString &title, const QString &text, + const QString &default_template, bool *ok) +{ + TemplateEditor *editor = new TemplateEditor(parent); + editor->setWindowTitle(title); + editor->setTemplate(text); + editor->setDefaultTemplate(default_template); + if(editor->exec() == QDialog::Accepted) + { + if(ok) + *ok = TRUE; + QString t = editor->currentTemplate(); + editor->deleteLater(); + return t; + } + else + { + if(ok) + *ok = FALSE; + editor->deleteLater(); + return QString(); + } +} diff --git a/src/qmmpui/templateeditor.h b/src/qmmpui/templateeditor.h new file mode 100644 index 000000000..c53949ae4 --- /dev/null +++ b/src/qmmpui/templateeditor.h @@ -0,0 +1,59 @@ +/*************************************************************************** + * Copyright (C) 2010 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef TEMPLATEEDITOR_H +#define TEMPLATEEDITOR_H + +#include + + +namespace Ui { + class TemplateEditor; +} +class QAction; + + +/*! + * @author Ilya Kotov + */ +class TemplateEditor : public QDialog +{ +Q_OBJECT +public: + explicit TemplateEditor(QWidget *parent = 0); + + QString currentTemplate() const; + void setTemplate(const QString &text = QString()); + void setDefaultTemplate(const QString &text); + static QString getTemplate (QWidget *parent, const QString &title, const QString &text = QString(), + const QString &default_template = QString(), bool *ok = 0); + +private slots: + void insertExpression(QAction *a); + void on_resetButton_clicked(); + +private: + void createMenu(); + Ui::TemplateEditor *m_ui; + QString m_defaultTemplate; + +}; + +#endif // TEMPLATEEDITOR_H diff --git a/src/qmmpui/templateeditor.ui b/src/qmmpui/templateeditor.ui new file mode 100644 index 000000000..b1f0d9853 --- /dev/null +++ b/src/qmmpui/templateeditor.ui @@ -0,0 +1,110 @@ + + + TemplateEditor + + + + 0 + 0 + 372 + 249 + + + + Template Editor + + + + 6 + + + 6 + + + 6 + + + + + + 0 + 0 + + + + + + + + Reset + + + + + + + Insert + + + + + + + Qt::Horizontal + + + + 124 + 17 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + TemplateEditor + accept() + + + 365 + 242 + + + 157 + 274 + + + + + buttonBox + rejected() + TemplateEditor + reject() + + + 365 + 242 + + + 286 + 274 + + + + + diff --git a/src/qmmpui/translations/libqmmpui_cs.ts b/src/qmmpui/translations/libqmmpui_cs.ts index c91b1b8ae..8ec11fde8 100644 --- a/src/qmmpui/translations/libqmmpui_cs.ts +++ b/src/qmmpui/translations/libqmmpui_cs.ts @@ -167,4 +167,92 @@ p, li { white-space: pre-wrap; } Vložit vybraný tag do souboru + + TemplateEditor + + + Reset + + + + + Insert + + + + + Template Editor + + + + + Artist + Umělec + + + + Album + Album + + + + Title + Název + + + + Track number + + + + + Two-digit track number + + + + + Genre + Žánr + + + + Comment + Poznámka + + + + Composer + Skladatel + + + + Duration + + + + + Disc number + Číslo disku + + + + File name + + + + + File path + + + + + Year + Rok + + + + Condition + + + diff --git a/src/qmmpui/translations/libqmmpui_de.ts b/src/qmmpui/translations/libqmmpui_de.ts index 00b1596b7..a0813fb57 100644 --- a/src/qmmpui/translations/libqmmpui_de.ts +++ b/src/qmmpui/translations/libqmmpui_de.ts @@ -167,4 +167,92 @@ p, li { white-space: pre-wrap; } Ausgewählten Tag in Datei einbeziehen + + TemplateEditor + + + Reset + + + + + Insert + + + + + Template Editor + + + + + Artist + Interpret + + + + Album + Album + + + + Title + Titel + + + + Track number + + + + + Two-digit track number + + + + + Genre + Genre + + + + Comment + Kommentar + + + + Composer + Komponent + + + + Duration + + + + + Disc number + CD-Nummer + + + + File name + + + + + File path + + + + + Year + Jahr + + + + Condition + + + diff --git a/src/qmmpui/translations/libqmmpui_it.ts b/src/qmmpui/translations/libqmmpui_it.ts index ed807048b..9fa3e8c91 100644 --- a/src/qmmpui/translations/libqmmpui_it.ts +++ b/src/qmmpui/translations/libqmmpui_it.ts @@ -167,4 +167,92 @@ p, li { white-space: pre-wrap; } Includi le etichette selezionate nel file + + TemplateEditor + + + Reset + + + + + Insert + + + + + Template Editor + + + + + Artist + Interprete + + + + Album + Album + + + + Title + Titolo + + + + Track number + + + + + Two-digit track number + + + + + Genre + Genere + + + + Comment + Commento + + + + Composer + Compositore + + + + Duration + + + + + Disc number + Disco n° + + + + File name + + + + + File path + + + + + Year + Anno + + + + Condition + + + diff --git a/src/qmmpui/translations/libqmmpui_lt.ts b/src/qmmpui/translations/libqmmpui_lt.ts index ff5282be5..05090f4c4 100644 --- a/src/qmmpui/translations/libqmmpui_lt.ts +++ b/src/qmmpui/translations/libqmmpui_lt.ts @@ -159,4 +159,92 @@ p, li { white-space: pre-wrap; } Įtraukti meta informaciją į bylą + + TemplateEditor + + + Reset + + + + + Insert + + + + + Template Editor + + + + + Artist + Atlikėjas + + + + Album + Albumas + + + + Title + Pavadinimas + + + + Track number + + + + + Two-digit track number + + + + + Genre + Žanras + + + + Comment + Komentaras + + + + Composer + + + + + Duration + + + + + Disc number + Disko numeris + + + + File name + + + + + File path + + + + + Year + Metai + + + + Condition + + + diff --git a/src/qmmpui/translations/libqmmpui_pl.ts b/src/qmmpui/translations/libqmmpui_pl.ts index b225489f9..6b98dffa6 100644 --- a/src/qmmpui/translations/libqmmpui_pl.ts +++ b/src/qmmpui/translations/libqmmpui_pl.ts @@ -159,4 +159,92 @@ p, li { white-space: pre-wrap; } Dołącz wybrany tag do pliku + + TemplateEditor + + + Reset + + + + + Insert + + + + + Template Editor + + + + + Artist + Artysta + + + + Album + Album + + + + Title + Tytuł + + + + Track number + + + + + Two-digit track number + + + + + Genre + Gatunek + + + + Comment + Komentarz + + + + Composer + Kompozytor + + + + Duration + + + + + Disc number + Numer płyty + + + + File name + + + + + File path + + + + + Year + Rok + + + + Condition + + + diff --git a/src/qmmpui/translations/libqmmpui_pt_BR.ts b/src/qmmpui/translations/libqmmpui_pt_BR.ts index d418a02b2..e872b0444 100644 --- a/src/qmmpui/translations/libqmmpui_pt_BR.ts +++ b/src/qmmpui/translations/libqmmpui_pt_BR.ts @@ -159,4 +159,92 @@ p, li { white-space: pre-wrap; } + + TemplateEditor + + + Reset + + + + + Insert + + + + + Template Editor + + + + + Artist + + + + + Album + + + + + Title + + + + + Track number + + + + + Two-digit track number + + + + + Genre + + + + + Comment + + + + + Composer + + + + + Duration + + + + + Disc number + + + + + File name + + + + + File path + + + + + Year + + + + + Condition + + + diff --git a/src/qmmpui/translations/libqmmpui_ru.ts b/src/qmmpui/translations/libqmmpui_ru.ts index 2ff3e89cc..4bb884068 100644 --- a/src/qmmpui/translations/libqmmpui_ru.ts +++ b/src/qmmpui/translations/libqmmpui_ru.ts @@ -31,7 +31,7 @@ Composer - Композитр + Композитор @@ -159,4 +159,92 @@ p, li { white-space: pre-wrap; } Включить выбранный тег в файл + + TemplateEditor + + + Reset + Сброс + + + + Insert + Вставить + + + + Template Editor + Редактор шаблонов + + + + Artist + Исполнитель + + + + Album + Альбом + + + + Title + Название + + + + Track number + Номер трека + + + + Two-digit track number + 2-х разрядный номер трека + + + + Genre + Жанр + + + + Comment + Комментарий + + + + Composer + Композитор + + + + Duration + Длительность + + + + Disc number + Номер диска + + + + File name + Имя файла + + + + File path + Путь к файлу + + + + Year + Год + + + + Condition + Условие + + diff --git a/src/qmmpui/translations/libqmmpui_tr.ts b/src/qmmpui/translations/libqmmpui_tr.ts index 329a73a95..864ed2255 100644 --- a/src/qmmpui/translations/libqmmpui_tr.ts +++ b/src/qmmpui/translations/libqmmpui_tr.ts @@ -159,4 +159,92 @@ p, li { white-space: pre-wrap; } + + TemplateEditor + + + Reset + + + + + Insert + + + + + Template Editor + + + + + Artist + + + + + Album + + + + + Title + + + + + Track number + + + + + Two-digit track number + + + + + Genre + + + + + Comment + + + + + Composer + + + + + Duration + + + + + Disc number + + + + + File name + + + + + File path + + + + + Year + + + + + Condition + + + diff --git a/src/qmmpui/translations/libqmmpui_uk_UA.ts b/src/qmmpui/translations/libqmmpui_uk_UA.ts index 4d6d0e16a..7f2fbf338 100644 --- a/src/qmmpui/translations/libqmmpui_uk_UA.ts +++ b/src/qmmpui/translations/libqmmpui_uk_UA.ts @@ -159,4 +159,92 @@ p, li { white-space: pre-wrap; } Включити вибраний тег у файл + + TemplateEditor + + + Reset + + + + + Insert + + + + + Template Editor + + + + + Artist + Виконавець + + + + Album + Альбом + + + + Title + Заголовок + + + + Track number + + + + + Two-digit track number + + + + + Genre + Жанр + + + + Comment + Коментар + + + + Composer + Композитор + + + + Duration + + + + + Disc number + Номер диску + + + + File name + + + + + File path + + + + + Year + Рік + + + + Condition + + + diff --git a/src/qmmpui/translations/libqmmpui_zh_CN.ts b/src/qmmpui/translations/libqmmpui_zh_CN.ts index 10eda0e5d..c8db7d1ed 100644 --- a/src/qmmpui/translations/libqmmpui_zh_CN.ts +++ b/src/qmmpui/translations/libqmmpui_zh_CN.ts @@ -159,4 +159,92 @@ p, li { white-space: pre-wrap; } + + TemplateEditor + + + Reset + + + + + Insert + + + + + Template Editor + + + + + Artist + + + + + Album + + + + + Title + + + + + Track number + + + + + Two-digit track number + + + + + Genre + + + + + Comment + + + + + Composer + + + + + Duration + + + + + Disc number + + + + + File name + + + + + File path + + + + + Year + + + + + Condition + + + diff --git a/src/qmmpui/translations/libqmmpui_zh_TW.ts b/src/qmmpui/translations/libqmmpui_zh_TW.ts index 08941d523..6bad57b06 100644 --- a/src/qmmpui/translations/libqmmpui_zh_TW.ts +++ b/src/qmmpui/translations/libqmmpui_zh_TW.ts @@ -159,4 +159,92 @@ p, li { white-space: pre-wrap; } + + TemplateEditor + + + Reset + + + + + Insert + + + + + Template Editor + + + + + Artist + + + + + Album + + + + + Title + + + + + Track number + + + + + Two-digit track number + + + + + Genre + + + + + Comment + + + + + Composer + + + + + Duration + + + + + Disc number + + + + + File name + + + + + File path + + + + + Year + + + + + Condition + + + -- cgit v1.2.3-13-gbd6f