From 791534703ca3c9ba6741751f85abbd6653de3e19 Mon Sep 17 00:00:00 2001 From: David Sansome Date: Thu, 27 May 2010 22:53:07 +0000 Subject: [PATCH] Allow names for custom saved streams. Fixes issue #242 --- src/core/simpletreeitem.h | 6 ++++ src/core/simpletreemodel.h | 7 ++++ src/radio/savedradio.cpp | 48 ++++++++++++++++++++------ src/radio/savedradio.h | 25 ++++++++++++-- src/translations/ar.po | 8 ++++- src/translations/cs.po | 13 +++++-- src/translations/da.po | 13 +++++-- src/translations/de.po | 13 +++++-- src/translations/el.po | 13 +++++-- src/translations/en_GB.po | 13 +++++-- src/translations/es.po | 13 +++++-- src/translations/fi.po | 8 ++++- src/translations/fr.po | 13 +++++-- src/translations/gl.po | 8 ++++- src/translations/it.po | 13 +++++-- src/translations/kk.po | 8 ++++- src/translations/nb.po | 13 +++++-- src/translations/oc.po | 8 ++++- src/translations/pl.po | 13 +++++-- src/translations/pt.po | 13 +++++-- src/translations/pt_BR.po | 8 ++++- src/translations/ro.po | 8 ++++- src/translations/ru.po | 13 +++++-- src/translations/sk.po | 13 +++++-- src/translations/sv.po | 13 +++++-- src/translations/tr.po | 8 ++++- src/translations/translations.pot | 8 ++++- src/translations/zh_TW.po | 8 ++++- src/ui/addstreamdialog.cpp | 30 +++++++++++----- src/ui/addstreamdialog.h | 6 ++++ src/ui/addstreamdialog.ui | 57 ++++++++++++++++++++++++++----- src/ui/mainwindow.cpp | 9 +++++ 32 files changed, 382 insertions(+), 68 deletions(-) diff --git a/src/core/simpletreeitem.h b/src/core/simpletreeitem.h index c063022cb..d20a6c9aa 100644 --- a/src/core/simpletreeitem.h +++ b/src/core/simpletreeitem.h @@ -33,6 +33,7 @@ class SimpleTreeItem { void InsertNotify(T* _parent); void DeleteNotify(int child_row); void ClearNotify(); + void ChangedNotify(); void Delete(int child_row); T* ChildByKey(const QString& key) const; @@ -128,6 +129,11 @@ void SimpleTreeItem::ClearNotify() { model->EndDelete(); } +template +void SimpleTreeItem::ChangedNotify() { + model->EmitDataChanged(static_cast(this)); +} + template SimpleTreeItem::~SimpleTreeItem() { qDeleteAll(children); diff --git a/src/core/simpletreemodel.h b/src/core/simpletreemodel.h index 5d5c52ed7..ec2331f1e 100644 --- a/src/core/simpletreemodel.h +++ b/src/core/simpletreemodel.h @@ -44,6 +44,7 @@ class SimpleTreeModel : public QAbstractItemModel { void EndInsert(); void BeginDelete(T* parent, int start, int end = -1); void EndDelete(); + void EmitDataChanged(T* item); protected: virtual void LazyPopulate(T* item) = 0; @@ -144,4 +145,10 @@ void SimpleTreeModel::EndDelete() { endRemoveRows(); } +template + void SimpleTreeModel::EmitDataChanged(T *item) { + QModelIndex index(ItemToIndex(item)); + emit dataChanged(index, index); +} + #endif // SIMPLETREEMODEL_H diff --git a/src/radio/savedradio.cpp b/src/radio/savedradio.cpp index 3e1196922..639fe0cdc 100644 --- a/src/radio/savedradio.cpp +++ b/src/radio/savedradio.cpp @@ -15,6 +15,7 @@ */ #include "savedradio.h" +#include "ui/addstreamdialog.h" #include "ui/iconloader.h" #include @@ -26,13 +27,17 @@ const char* SavedRadio::kSettingsGroup = "SavedRadio"; SavedRadio::SavedRadio(RadioModel* parent) : RadioService(kServiceName, parent), root_(NULL), - context_menu_(new QMenu) + context_menu_(new QMenu), + edit_dialog_(new AddStreamDialog) { add_action_ = context_menu_->addAction(IconLoader::Load("media-playback-start"), tr("Add to playlist"), this, SLOT(AddToPlaylist())); remove_action_ = context_menu_->addAction(IconLoader::Load("list-remove"), tr("Remove"), this, SLOT(Remove())); + edit_action_ = context_menu_->addAction(IconLoader::Load("edit-rename"), tr("Edit..."), this, SLOT(Edit())); context_menu_->addSeparator(); context_menu_->addAction(IconLoader::Load("document-open-remote"), tr("Add another stream..."), this, SIGNAL(ShowAddStreamDialog())); + edit_dialog_->set_save_visible(false); + LoadStreams(); } @@ -49,7 +54,7 @@ RadioItem* SavedRadio::CreateRootItem(RadioItem* parent) { void SavedRadio::LazyPopulate(RadioItem* item) { switch (item->type) { case RadioItem::Type_Service: - foreach (const QString& stream, streams_) + foreach (const Stream& stream, streams_) ItemForStream(stream, root_); break; @@ -69,7 +74,7 @@ void SavedRadio::LoadStreams() { int count = s.beginReadArray("streams"); for (int i=0 ; isetEnabled(item != root_); remove_action_->setEnabled(item != root_); + edit_action_->setEnabled(item != root_); context_menu_->popup(global_pos); } void SavedRadio::Remove() { - streams_.removeAll(context_item_->key); + streams_.removeAll(Stream(QUrl(context_item_->key))); context_item_->parent->DeleteNotify(context_item_->row); SaveStreams(); } +void SavedRadio::Edit() { + edit_dialog_->set_name(context_item_->display_text); + edit_dialog_->set_url(context_item_->key); + if (edit_dialog_->exec() == QDialog::Rejected) + return; + + int i = streams_.indexOf(Stream(QUrl(context_item_->key))); + Stream& stream = streams_[i]; + stream.name_ = edit_dialog_->name(); + stream.url_ = edit_dialog_->url(); + + context_item_->display_text = stream.name_; + context_item_->key = stream.url_.toString(); + context_item_->ChangedNotify(); +} + void SavedRadio::AddToPlaylist() { emit AddItemToPlaylist(context_item_); } -RadioItem* SavedRadio::ItemForStream(const QUrl& url, RadioItem* parent) { - RadioItem* s = new RadioItem(this, Type_Stream, url.toString(), parent); +RadioItem* SavedRadio::ItemForStream(const Stream& stream, RadioItem* parent) { + RadioItem* s = new RadioItem(this, Type_Stream, stream.url_.toString(), parent); + if (!stream.name_.isEmpty()) + s->display_text = stream.name_; s->lazy_loaded = true; s->icon = QIcon(":last.fm/icon_radio.png"); s->playable = true; return s; } -void SavedRadio::Add(const QUrl &url) { - if (streams_.contains(url.toString())) +void SavedRadio::Add(const QUrl &url, const QString& name) { + if (streams_.contains(Stream(url))) return; - streams_ << url.toString(); + Stream stream(url, name); + streams_ << stream; if (root_->lazy_loaded) { - RadioItem* s = ItemForStream(url, NULL); + RadioItem* s = ItemForStream(stream, NULL); s->InsertNotify(root_); } SaveStreams(); diff --git a/src/radio/savedradio.h b/src/radio/savedradio.h index 8feecc871..968ba10b7 100644 --- a/src/radio/savedradio.h +++ b/src/radio/savedradio.h @@ -19,8 +19,12 @@ #include "radioservice.h" +#include + class QMenu; +class AddStreamDialog; + class SavedRadio : public RadioService { Q_OBJECT @@ -41,7 +45,7 @@ class SavedRadio : public RadioService { void ShowContextMenu(RadioItem* item, const QModelIndex& index, const QPoint& global_pos); - void Add(const QUrl& url); + void Add(const QUrl& url, const QString& name = QString()); signals: void ShowAddStreamDialog(); @@ -49,11 +53,23 @@ class SavedRadio : public RadioService { private slots: void AddToPlaylist(); void Remove(); + void Edit(); private: + struct Stream { + Stream(const QUrl& url, const QString& name = QString()) + : url_(url), name_(name) {} + + // For QList::contains + bool operator ==(const Stream& other) const { return url_ == other.url_; } + + QUrl url_; + QString name_; + }; + void LoadStreams(); void SaveStreams(); - RadioItem* ItemForStream(const QUrl& url, RadioItem* parent); + RadioItem* ItemForStream(const Stream& stream, RadioItem* parent); private: RadioItem* root_; @@ -62,8 +78,11 @@ class SavedRadio : public RadioService { QAction* add_action_; QAction* remove_action_; + QAction* edit_action_; - QStringList streams_; + QList streams_; + + boost::scoped_ptr edit_dialog_; }; #endif // SAVEDRADIO_H diff --git a/src/translations/ar.po b/src/translations/ar.po index 648173ff8..60a866ea0 100644 --- a/src/translations/ar.po +++ b/src/translations/ar.po @@ -604,6 +604,9 @@ msgstr "" msgid "Radio service couldn't be loaded :-(" msgstr "" +msgid "Edit..." +msgstr "" + msgid "Add another stream..." msgstr "" @@ -903,7 +906,10 @@ msgstr "" msgid "Enter the URL of an internet radio stream:" msgstr "" -msgid "Save this stream in the Radio tab" +msgid "Save this stream in the Internet tab" +msgstr "" + +msgid "Give it a name:" msgstr "" msgid "Cover Manager" diff --git a/src/translations/cs.po b/src/translations/cs.po index 2609364a0..94d7f9042 100644 --- a/src/translations/cs.po +++ b/src/translations/cs.po @@ -605,6 +605,9 @@ msgstr "" msgid "Radio service couldn't be loaded :-(" msgstr "Služba rádia nemohla být načtena :-(" +msgid "Edit..." +msgstr "" + msgid "Add another stream..." msgstr "Přidat další proud..." @@ -909,8 +912,11 @@ msgstr "Přidat proud" msgid "Enter the URL of an internet radio stream:" msgstr "Zadat URL proudu internetového rádia:" -msgid "Save this stream in the Radio tab" -msgstr "Uložit tento proud v kartě Rádií" +msgid "Save this stream in the Internet tab" +msgstr "" + +msgid "Give it a name:" +msgstr "" msgid "Cover Manager" msgstr "Správce obalů" @@ -1254,6 +1260,9 @@ msgstr "Hlasitost %1%" msgid "0:00:00" msgstr "0:00:00" +#~ msgid "Save this stream in the Radio tab" +#~ msgstr "Uložit tento proud v kartě Rádií" + #~ msgid "Options" #~ msgstr "Možnosti" diff --git a/src/translations/da.po b/src/translations/da.po index 153f09792..7dcab0808 100644 --- a/src/translations/da.po +++ b/src/translations/da.po @@ -607,6 +607,9 @@ msgstr "" msgid "Radio service couldn't be loaded :-(" msgstr "Radiotjeneste kunne ikke indlæses :-(" +msgid "Edit..." +msgstr "" + msgid "Add another stream..." msgstr "Tilføj endnu en stream..." @@ -912,8 +915,11 @@ msgstr "Tilføj stream" msgid "Enter the URL of an internet radio stream:" msgstr "Indtast URL'en til en internetradiostream:" -msgid "Save this stream in the Radio tab" -msgstr "Gem denne stream i radio-fanen" +msgid "Save this stream in the Internet tab" +msgstr "" + +msgid "Give it a name:" +msgstr "" msgid "Cover Manager" msgstr "Omslagshåndtering" @@ -1257,6 +1263,9 @@ msgstr "Lydstyrke %1%" msgid "0:00:00" msgstr "0:00:00" +#~ msgid "Save this stream in the Radio tab" +#~ msgstr "Gem denne stream i radio-fanen" + #~ msgid "Options" #~ msgstr "Indstillinger" diff --git a/src/translations/de.po b/src/translations/de.po index 36e3ad27f..a1268d5c0 100644 --- a/src/translations/de.po +++ b/src/translations/de.po @@ -604,6 +604,9 @@ msgstr "Magnatune durchsuchen" msgid "Radio service couldn't be loaded :-(" msgstr "Radioservice konnte nicht geladen werden" +msgid "Edit..." +msgstr "" + msgid "Add another stream..." msgstr "Stream hinzufügen..." @@ -910,8 +913,11 @@ msgstr "Stream hinzufügen" msgid "Enter the URL of an internet radio stream:" msgstr "Geben sie die Adresse eines Internetradios an:" -msgid "Save this stream in the Radio tab" -msgstr "Stream zu \"Meine Internetradios\" hinzufügen" +msgid "Save this stream in the Internet tab" +msgstr "" + +msgid "Give it a name:" +msgstr "" msgid "Cover Manager" msgstr "Cover-Verwaltung" @@ -1257,6 +1263,9 @@ msgstr "Lautstärke %1" msgid "0:00:00" msgstr "0:00:00" +#~ msgid "Save this stream in the Radio tab" +#~ msgstr "Stream zu \"Meine Internetradios\" hinzufügen" + #~ msgid "Options" #~ msgstr "Einstellungen" diff --git a/src/translations/el.po b/src/translations/el.po index f670754f0..8eac9fcbe 100644 --- a/src/translations/el.po +++ b/src/translations/el.po @@ -607,6 +607,9 @@ msgstr "Εύρεση στο Magnatune" msgid "Radio service couldn't be loaded :-(" msgstr "Η υπηρεσίες ραδιοφώνου απέτυχαν να φορτωθούν :-(" +msgid "Edit..." +msgstr "" + msgid "Add another stream..." msgstr "Προσθήκη άλλης ροής..." @@ -913,8 +916,11 @@ msgstr "Προσθήκη ροής" msgid "Enter the URL of an internet radio stream:" msgstr "Εισαγωγή της διεύθυνσης μιας ροής ραδιοφώνου:" -msgid "Save this stream in the Radio tab" -msgstr "Αποθήκευση της ροής αυτής στην καρτέλα του ραδιοφώνου" +msgid "Save this stream in the Internet tab" +msgstr "" + +msgid "Give it a name:" +msgstr "" msgid "Cover Manager" msgstr "Διαχείριση εξώφυλλων" @@ -1258,6 +1264,9 @@ msgstr "Ένταση %1%" msgid "0:00:00" msgstr "0:00:00" +#~ msgid "Save this stream in the Radio tab" +#~ msgstr "Αποθήκευση της ροής αυτής στην καρτέλα του ραδιοφώνου" + #~ msgid "Options" #~ msgstr "Επιλογές" diff --git a/src/translations/en_GB.po b/src/translations/en_GB.po index 4fd7b6d47..e0ff79ab6 100644 --- a/src/translations/en_GB.po +++ b/src/translations/en_GB.po @@ -604,6 +604,9 @@ msgstr "" msgid "Radio service couldn't be loaded :-(" msgstr "Radio service couldn't be loaded :-(" +msgid "Edit..." +msgstr "" + msgid "Add another stream..." msgstr "Add another stream..." @@ -907,8 +910,11 @@ msgstr "Add Stream" msgid "Enter the URL of an internet radio stream:" msgstr "Enter the URL of an internet radio stream:" -msgid "Save this stream in the Radio tab" -msgstr "Save this stream in the Radio tab" +msgid "Save this stream in the Internet tab" +msgstr "" + +msgid "Give it a name:" +msgstr "" msgid "Cover Manager" msgstr "Cover Manager" @@ -1252,6 +1258,9 @@ msgstr "Volume %1%" msgid "0:00:00" msgstr "0:00:00" +#~ msgid "Save this stream in the Radio tab" +#~ msgstr "Save this stream in the Radio tab" + #~ msgid "Options" #~ msgstr "Options" diff --git a/src/translations/es.po b/src/translations/es.po index d88f85f72..be6872f65 100644 --- a/src/translations/es.po +++ b/src/translations/es.po @@ -610,6 +610,9 @@ msgstr "Buscar en Magnatune" msgid "Radio service couldn't be loaded :-(" msgstr "Servicio de radio no pudo ser cargado :-(" +msgid "Edit..." +msgstr "" + msgid "Add another stream..." msgstr "Añadir un flujo de radio..." @@ -917,8 +920,11 @@ msgstr "Añadir Flujo de Radio" msgid "Enter the URL of an internet radio stream:" msgstr "Ingrese la URL de un flujo de radio por internet:" -msgid "Save this stream in the Radio tab" -msgstr "Guardar este flujo en la seccion de Radios" +msgid "Save this stream in the Internet tab" +msgstr "" + +msgid "Give it a name:" +msgstr "" msgid "Cover Manager" msgstr "Gestor de carátulas" @@ -1264,6 +1270,9 @@ msgstr "Volumen %1%" msgid "0:00:00" msgstr "0:00:00" +#~ msgid "Save this stream in the Radio tab" +#~ msgstr "Guardar este flujo en la seccion de Radios" + #~ msgid "Options" #~ msgstr "Opciones" diff --git a/src/translations/fi.po b/src/translations/fi.po index 3ea4c1bee..fc62c1468 100644 --- a/src/translations/fi.po +++ b/src/translations/fi.po @@ -604,6 +604,9 @@ msgstr "" msgid "Radio service couldn't be loaded :-(" msgstr "" +msgid "Edit..." +msgstr "" + msgid "Add another stream..." msgstr "" @@ -903,7 +906,10 @@ msgstr "" msgid "Enter the URL of an internet radio stream:" msgstr "" -msgid "Save this stream in the Radio tab" +msgid "Save this stream in the Internet tab" +msgstr "" + +msgid "Give it a name:" msgstr "" msgid "Cover Manager" diff --git a/src/translations/fr.po b/src/translations/fr.po index 4f441bca6..0a20f96b7 100644 --- a/src/translations/fr.po +++ b/src/translations/fr.po @@ -611,6 +611,9 @@ msgstr "" msgid "Radio service couldn't be loaded :-(" msgstr "Le service radio n'a pas pu être chargé :-(" +msgid "Edit..." +msgstr "" + msgid "Add another stream..." msgstr "Ajouter un autre flux..." @@ -915,8 +918,11 @@ msgstr "Ajouter un flux" msgid "Enter the URL of an internet radio stream:" msgstr "Entrez l'adresse du flux d'une radio internet :" -msgid "Save this stream in the Radio tab" -msgstr "Conserver un raccourci vers ce flux dans l'onglet Radio" +msgid "Save this stream in the Internet tab" +msgstr "" + +msgid "Give it a name:" +msgstr "" msgid "Cover Manager" msgstr "Gestionnaire de jaquettes" @@ -1262,6 +1268,9 @@ msgstr "Volume %1%" msgid "0:00:00" msgstr "0:00:00" +#~ msgid "Save this stream in the Radio tab" +#~ msgstr "Conserver un raccourci vers ce flux dans l'onglet Radio" + #~ msgid "Options" #~ msgstr "Options" diff --git a/src/translations/gl.po b/src/translations/gl.po index aa47b99f7..da12875bd 100644 --- a/src/translations/gl.po +++ b/src/translations/gl.po @@ -605,6 +605,9 @@ msgstr "" msgid "Radio service couldn't be loaded :-(" msgstr "Servizo de rádio non pudo ser carregado :-(" +msgid "Edit..." +msgstr "" + msgid "Add another stream..." msgstr "Adicionar outra stream..." @@ -905,7 +908,10 @@ msgstr "" msgid "Enter the URL of an internet radio stream:" msgstr "" -msgid "Save this stream in the Radio tab" +msgid "Save this stream in the Internet tab" +msgstr "" + +msgid "Give it a name:" msgstr "" msgid "Cover Manager" diff --git a/src/translations/it.po b/src/translations/it.po index d7a76fc21..c82f9bc00 100644 --- a/src/translations/it.po +++ b/src/translations/it.po @@ -607,6 +607,9 @@ msgstr "Cerca in Magnatune" msgid "Radio service couldn't be loaded :-(" msgstr "Il servizio radio non può essere caricato :-(" +msgid "Edit..." +msgstr "" + msgid "Add another stream..." msgstr "Aggiungi un altro flusso..." @@ -914,8 +917,11 @@ msgstr "Aggiungi flusso" msgid "Enter the URL of an internet radio stream:" msgstr "Inserisci l'URL di flusso radio in Internet:" -msgid "Save this stream in the Radio tab" -msgstr "Salva questo flusso nella scheda Radio" +msgid "Save this stream in the Internet tab" +msgstr "" + +msgid "Give it a name:" +msgstr "" msgid "Cover Manager" msgstr "Gestore copertine" @@ -1261,6 +1267,9 @@ msgstr "Volume %1%" msgid "0:00:00" msgstr "0:00:00" +#~ msgid "Save this stream in the Radio tab" +#~ msgstr "Salva questo flusso nella scheda Radio" + #~ msgid "Options" #~ msgstr "Opzioni" diff --git a/src/translations/kk.po b/src/translations/kk.po index 828399d3a..87973bc8d 100644 --- a/src/translations/kk.po +++ b/src/translations/kk.po @@ -604,6 +604,9 @@ msgstr "" msgid "Radio service couldn't be loaded :-(" msgstr "" +msgid "Edit..." +msgstr "" + msgid "Add another stream..." msgstr "" @@ -905,7 +908,10 @@ msgstr "" msgid "Enter the URL of an internet radio stream:" msgstr "" -msgid "Save this stream in the Radio tab" +msgid "Save this stream in the Internet tab" +msgstr "" + +msgid "Give it a name:" msgstr "" msgid "Cover Manager" diff --git a/src/translations/nb.po b/src/translations/nb.po index e3b8bb12f..fe777ef92 100644 --- a/src/translations/nb.po +++ b/src/translations/nb.po @@ -605,6 +605,9 @@ msgstr "" msgid "Radio service couldn't be loaded :-(" msgstr "Kunne ikke laste inn radiotjeneste :-(" +msgid "Edit..." +msgstr "" + msgid "Add another stream..." msgstr "Legg til enda en strøm..." @@ -909,8 +912,11 @@ msgstr "Legg til strøm" msgid "Enter the URL of an internet radio stream:" msgstr "Skriv adressen (URL) til en internett radiostrøm" -msgid "Save this stream in the Radio tab" -msgstr "Lagre denne strømmen" +msgid "Save this stream in the Internet tab" +msgstr "" + +msgid "Give it a name:" +msgstr "" msgid "Cover Manager" msgstr "Behandling av plateomslag" @@ -1254,6 +1260,9 @@ msgstr "Volum %1%" msgid "0:00:00" msgstr "0:00:00" +#~ msgid "Save this stream in the Radio tab" +#~ msgstr "Lagre denne strømmen" + #~ msgid "Options" #~ msgstr "Instillinger" diff --git a/src/translations/oc.po b/src/translations/oc.po index 83fa4a9c8..e524d5751 100644 --- a/src/translations/oc.po +++ b/src/translations/oc.po @@ -604,6 +604,9 @@ msgstr "" msgid "Radio service couldn't be loaded :-(" msgstr "" +msgid "Edit..." +msgstr "" + msgid "Add another stream..." msgstr "" @@ -903,7 +906,10 @@ msgstr "Apondre un flux" msgid "Enter the URL of an internet radio stream:" msgstr "" -msgid "Save this stream in the Radio tab" +msgid "Save this stream in the Internet tab" +msgstr "" + +msgid "Give it a name:" msgstr "" msgid "Cover Manager" diff --git a/src/translations/pl.po b/src/translations/pl.po index 5e096368c..df9e6a1e9 100644 --- a/src/translations/pl.po +++ b/src/translations/pl.po @@ -605,6 +605,9 @@ msgstr "" msgid "Radio service couldn't be loaded :-(" msgstr "Usługa radio nie może być załadowana :-(" +msgid "Edit..." +msgstr "" + msgid "Add another stream..." msgstr "Dodaj następny strumień..." @@ -907,8 +910,11 @@ msgstr "Dodaj URL" msgid "Enter the URL of an internet radio stream:" msgstr "Dodaj URL radia internetowego:" -msgid "Save this stream in the Radio tab" -msgstr "Zapisz URL na karcie Radio" +msgid "Save this stream in the Internet tab" +msgstr "" + +msgid "Give it a name:" +msgstr "" msgid "Cover Manager" msgstr "Menadżer okładek" @@ -1252,6 +1258,9 @@ msgstr "Głośność %1%" msgid "0:00:00" msgstr "" +#~ msgid "Save this stream in the Radio tab" +#~ msgstr "Zapisz URL na karcie Radio" + #~ msgid "Options" #~ msgstr "Opcje" diff --git a/src/translations/pt.po b/src/translations/pt.po index 4ee2845e8..f7389aedc 100644 --- a/src/translations/pt.po +++ b/src/translations/pt.po @@ -606,6 +606,9 @@ msgstr "" msgid "Radio service couldn't be loaded :-(" msgstr "Serviço de rádio não pode ser carregado :-(" +msgid "Edit..." +msgstr "" + msgid "Add another stream..." msgstr "Adicionar outro stream..." @@ -910,8 +913,11 @@ msgstr "Adicionar uma stream" msgid "Enter the URL of an internet radio stream:" msgstr "Introduza um URL de uma stream de rádio da internet:" -msgid "Save this stream in the Radio tab" -msgstr "Guarde esta stream na Rádio tab" +msgid "Save this stream in the Internet tab" +msgstr "" + +msgid "Give it a name:" +msgstr "" msgid "Cover Manager" msgstr "Gestor de Capas" @@ -1255,6 +1261,9 @@ msgstr "Volume %1%" msgid "0:00:00" msgstr "0:00:00" +#~ msgid "Save this stream in the Radio tab" +#~ msgstr "Guarde esta stream na Rádio tab" + #~ msgid "Options" #~ msgstr "Opções" diff --git a/src/translations/pt_BR.po b/src/translations/pt_BR.po index 885b59b9b..b266aac00 100644 --- a/src/translations/pt_BR.po +++ b/src/translations/pt_BR.po @@ -604,6 +604,9 @@ msgstr "" msgid "Radio service couldn't be loaded :-(" msgstr "" +msgid "Edit..." +msgstr "" + msgid "Add another stream..." msgstr "" @@ -903,7 +906,10 @@ msgstr "" msgid "Enter the URL of an internet radio stream:" msgstr "" -msgid "Save this stream in the Radio tab" +msgid "Save this stream in the Internet tab" +msgstr "" + +msgid "Give it a name:" msgstr "" msgid "Cover Manager" diff --git a/src/translations/ro.po b/src/translations/ro.po index 6abfb02fa..54eba32ad 100644 --- a/src/translations/ro.po +++ b/src/translations/ro.po @@ -604,6 +604,9 @@ msgstr "" msgid "Radio service couldn't be loaded :-(" msgstr "Serviciul de radio nu a putut fi încărcat :-(" +msgid "Edit..." +msgstr "" + msgid "Add another stream..." msgstr "Adaugă alt flux..." @@ -904,7 +907,10 @@ msgstr "Adaugă flux" msgid "Enter the URL of an internet radio stream:" msgstr "" -msgid "Save this stream in the Radio tab" +msgid "Save this stream in the Internet tab" +msgstr "" + +msgid "Give it a name:" msgstr "" msgid "Cover Manager" diff --git a/src/translations/ru.po b/src/translations/ru.po index 5ca8786d7..21b0009cc 100644 --- a/src/translations/ru.po +++ b/src/translations/ru.po @@ -604,6 +604,9 @@ msgstr "Искать на Magnatune" msgid "Radio service couldn't be loaded :-(" msgstr "Сервис радио не запустился =(" +msgid "Edit..." +msgstr "" + msgid "Add another stream..." msgstr "Добавить другой поток..." @@ -909,8 +912,11 @@ msgstr "Добавить поток" msgid "Enter the URL of an internet radio stream:" msgstr "Введите адрес радиопотока:" -msgid "Save this stream in the Radio tab" -msgstr "Сохранить поток на вкладке Радио" +msgid "Save this stream in the Internet tab" +msgstr "" + +msgid "Give it a name:" +msgstr "" msgid "Cover Manager" msgstr "Менеджер обложек" @@ -1255,6 +1261,9 @@ msgstr "Громкость %1%" msgid "0:00:00" msgstr "0:00:00" +#~ msgid "Save this stream in the Radio tab" +#~ msgstr "Сохранить поток на вкладке Радио" + #~ msgid "Options" #~ msgstr "Настройки" diff --git a/src/translations/sk.po b/src/translations/sk.po index 3fc8c968c..c7020c51d 100644 --- a/src/translations/sk.po +++ b/src/translations/sk.po @@ -605,6 +605,9 @@ msgstr "Hľadať v Magnatune" msgid "Radio service couldn't be loaded :-(" msgstr "Služba rádia sa nedá načítať :-(" +msgid "Edit..." +msgstr "" + msgid "Add another stream..." msgstr "Pridať ďalší stream..." @@ -911,8 +914,11 @@ msgstr "Pridať stream" msgid "Enter the URL of an internet radio stream:" msgstr "Vložte URL internetového rádio streamu:" -msgid "Save this stream in the Radio tab" -msgstr "Uložiť tento stream na karte Rádio" +msgid "Save this stream in the Internet tab" +msgstr "" + +msgid "Give it a name:" +msgstr "" msgid "Cover Manager" msgstr "Správca obalov" @@ -1256,6 +1262,9 @@ msgstr "Hlasitosť %1%" msgid "0:00:00" msgstr "0:00:00" +#~ msgid "Save this stream in the Radio tab" +#~ msgstr "Uložiť tento stream na karte Rádio" + #~ msgid "Options" #~ msgstr "Možnosti" diff --git a/src/translations/sv.po b/src/translations/sv.po index 7f72899ce..aa9e742bd 100644 --- a/src/translations/sv.po +++ b/src/translations/sv.po @@ -606,6 +606,9 @@ msgstr "Sök Magnatune" msgid "Radio service couldn't be loaded :-(" msgstr "Radiotjänsten kunde inte laddas :-(" +msgid "Edit..." +msgstr "" + msgid "Add another stream..." msgstr "Lägg till en annan ström..." @@ -912,8 +915,11 @@ msgstr "Lägg till ström" msgid "Enter the URL of an internet radio stream:" msgstr "Skriv in webbadressen till en radiostation på Internet:" -msgid "Save this stream in the Radio tab" -msgstr "Spara den här stationen i radiotabben" +msgid "Save this stream in the Internet tab" +msgstr "" + +msgid "Give it a name:" +msgstr "" msgid "Cover Manager" msgstr "Omslagshanterare" @@ -1257,6 +1263,9 @@ msgstr "Volym %1%" msgid "0:00:00" msgstr "0:00:00" +#~ msgid "Save this stream in the Radio tab" +#~ msgstr "Spara den här stationen i radiotabben" + #~ msgid "Options" #~ msgstr "Flaggor" diff --git a/src/translations/tr.po b/src/translations/tr.po index 4c806d3a2..55796f3b4 100644 --- a/src/translations/tr.po +++ b/src/translations/tr.po @@ -604,6 +604,9 @@ msgstr "" msgid "Radio service couldn't be loaded :-(" msgstr "" +msgid "Edit..." +msgstr "" + msgid "Add another stream..." msgstr "" @@ -903,7 +906,10 @@ msgstr "" msgid "Enter the URL of an internet radio stream:" msgstr "" -msgid "Save this stream in the Radio tab" +msgid "Save this stream in the Internet tab" +msgstr "" + +msgid "Give it a name:" msgstr "" msgid "Cover Manager" diff --git a/src/translations/translations.pot b/src/translations/translations.pot index 69ee84172..1bd8b4207 100644 --- a/src/translations/translations.pot +++ b/src/translations/translations.pot @@ -595,6 +595,9 @@ msgstr "" msgid "Radio service couldn't be loaded :-(" msgstr "" +msgid "Edit..." +msgstr "" + msgid "Add another stream..." msgstr "" @@ -894,7 +897,10 @@ msgstr "" msgid "Enter the URL of an internet radio stream:" msgstr "" -msgid "Save this stream in the Radio tab" +msgid "Save this stream in the Internet tab" +msgstr "" + +msgid "Give it a name:" msgstr "" msgid "Cover Manager" diff --git a/src/translations/zh_TW.po b/src/translations/zh_TW.po index 290478799..2de9e28cb 100644 --- a/src/translations/zh_TW.po +++ b/src/translations/zh_TW.po @@ -604,6 +604,9 @@ msgstr "" msgid "Radio service couldn't be loaded :-(" msgstr "" +msgid "Edit..." +msgstr "" + msgid "Add another stream..." msgstr "" @@ -903,7 +906,10 @@ msgstr "" msgid "Enter the URL of an internet radio stream:" msgstr "" -msgid "Save this stream in the Radio tab" +msgid "Save this stream in the Internet tab" +msgstr "" + +msgid "Give it a name:" msgstr "" msgid "Cover Manager" diff --git a/src/ui/addstreamdialog.cpp b/src/ui/addstreamdialog.cpp index 6c8ab4c80..4ac871e15 100644 --- a/src/ui/addstreamdialog.cpp +++ b/src/ui/addstreamdialog.cpp @@ -41,12 +41,7 @@ AddStreamDialog::AddStreamDialog(QWidget *parent) s.beginGroup(kSettingsGroup); ui_->save->setChecked(s.value("save", true).toBool()); ui_->url->setText(s.value("url").toString()); - - // Connections to the saved streams service - saved_radio_ = qobject_cast( - RadioModel::ServiceByName(SavedRadio::kServiceName)); - - connect(saved_radio_, SIGNAL(ShowAddStreamDialog()), SLOT(show())); + ui_->name->setText(s.value("name").toString()); } AddStreamDialog::~AddStreamDialog() { @@ -57,9 +52,27 @@ QUrl AddStreamDialog::url() const { return QUrl(ui_->url->text()); } +QString AddStreamDialog::name() const { + return ui_->name->text(); +} + +void AddStreamDialog::set_name(const QString &name) { + ui_->name->setText(name); +} + +void AddStreamDialog::set_url(const QUrl &url) { + ui_->url->setText(url.toString()); +} + +void AddStreamDialog::set_save_visible(bool visible) { + ui_->save->setVisible(visible); + if (!visible) + ui_->name_container->setEnabled(true); +} + void AddStreamDialog::accept() { - if (ui_->save->isChecked()) { - saved_radio_->Add(url()); + if (ui_->save->isChecked() && saved_radio_) { + saved_radio_->Add(url(), name()); } // Save settings @@ -67,6 +80,7 @@ void AddStreamDialog::accept() { s.beginGroup(kSettingsGroup); s.setValue("save", ui_->save->isChecked()); s.setValue("url", url().toString()); + s.setValue("name", ui_->name->text()); QDialog::accept(); } diff --git a/src/ui/addstreamdialog.h b/src/ui/addstreamdialog.h index 652807082..5fafd3e50 100644 --- a/src/ui/addstreamdialog.h +++ b/src/ui/addstreamdialog.h @@ -30,7 +30,13 @@ class AddStreamDialog : public QDialog { AddStreamDialog(QWidget *parent = 0); ~AddStreamDialog(); + void set_url(const QUrl& url); + void set_name(const QString& name); + void set_save_visible(bool visible); + void set_add_on_accept(SavedRadio* saved_radio) { saved_radio_ = saved_radio; } + QUrl url() const; + QString name() const; void accept(); diff --git a/src/ui/addstreamdialog.ui b/src/ui/addstreamdialog.ui index 67af723bf..486f73d89 100644 --- a/src/ui/addstreamdialog.ui +++ b/src/ui/addstreamdialog.ui @@ -7,7 +7,7 @@ 0 0 400 - 122 + 168 @@ -27,13 +27,32 @@ - Save this stream in the Radio tab + Save this stream in the Internet tab true + + + + + 0 + + + + + Give it a name: + + + + + + + + + @@ -59,6 +78,12 @@ + + url + save + name + button_box + @@ -68,12 +93,12 @@ accept() - 248 - 254 + 257 + 158 157 - 274 + 167 @@ -84,12 +109,28 @@ reject() - 316 - 260 + 325 + 158 286 - 274 + 167 + + + + + save + toggled(bool) + name_container + setEnabled(bool) + + + 65 + 75 + + + 111 + 97 diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index ded02b9fa..9e58bc6f8 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -40,6 +40,7 @@ #include "radio/radiomodel.h" #include "radio/radioview.h" #include "radio/radioviewcontainer.h" +#include "radio/savedradio.h" #include "transcoder/transcodedialog.h" #include "ui/about.h" #include "ui/addstreamdialog.h" @@ -325,6 +326,14 @@ MainWindow::MainWindow(NetworkAccessManager* network, Engine::Type engine, QWidg LastFMButtonVisibilityChanged(radio_model_->GetLastFMService()->AreButtonsVisible()); + // Connections to the saved streams service + SavedRadio* saved_radio_ = qobject_cast( + RadioModel::ServiceByName(SavedRadio::kServiceName)); + add_stream_dialog_->set_add_on_accept(saved_radio_); + + connect(saved_radio_, SIGNAL(ShowAddStreamDialog()), + add_stream_dialog_.get(), SLOT(show())); + // Tray icon QMenu* tray_menu = new QMenu(this); tray_menu->addAction(ui_->action_previous_track);